MDL-13728 - Tag form editing now provides a checkbox to set the tag type (official or not), and it's all base on tag:manage. (merge)

This commit is contained in:
scyrma 2008-02-29 09:35:04 +00:00
parent be4c1a81d6
commit 603443b519
4 changed files with 19 additions and 12 deletions

View File

@ -21,6 +21,7 @@ $string['name'] = 'Tag name';
$string['namesalreadybeeingused'] = 'Tag names already being used';
$string['newname'] = 'New tag name';
$string['noresultsfor'] = 'No results for \"$a\"';
$string['officialtag'] = 'Official tag';
$string['owner'] = 'Owner';
$string['otags'] = 'Official tags';
$string['ptags'] = 'User defined tags (Comma separated)';

View File

@ -1139,17 +1139,6 @@ $moodle_capabilities = array(
)
),
'moodle/tag:changetype' => array(
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'admin' => CAP_ALLOW
)
),
'moodle/tag:create' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,

View File

@ -48,6 +48,11 @@ if (can_use_html_editor()) {
$errorstring = '';
$tagform = new tag_edit_form();
if ( $tag->tagtype == 'official' ) {
$tag->tagtype = '1';
} else {
$tag->tagtype = '0';
}
$tagform->set_data($tag);
// If new data has been sent, update the tag record
@ -55,6 +60,15 @@ if ($tagnew = $tagform->get_data()) {
tag_description_set($tag_id, stripslashes($tagnew->description), $tagnew->descriptionformat);
if (has_capability('moodle/tag:manage', $systemcontext)) {
if (($tag->tagtype != 'default') && ($tagnew->tagtype != '1')) {
tag_type_set($tag->id, 'default');
} elseif (($tag->tagtype != 'official') && ($tagnew->tagtype == '1')) {
tag_type_set($tag->id, 'official');
}
}
if (!has_capability('moodle/tag:manage', $systemcontext)) {
unset($tagnew->name);
unset($tagnew->rawname);

View File

@ -23,13 +23,16 @@ class tag_edit_form extends moodleform {
$mform->addElement('format', 'descriptionformat', get_string('format'));
if (has_capability('moodle/tag:manage', $systemcontext)) {
$mform->addElement('checkbox', 'tagtype', get_string('officialtag', 'tag'));
}
$mform->addElement('html', '<br/><div id="relatedtags-autocomplete-container">');
$mform->addElement('textarea', 'relatedtags', get_string('relatedtags','tag'), 'cols="50" rows="3"');
$mform->setType('relatedtags', PARAM_TAGLIST);
$mform->addElement('html', '</div>');
$mform->addElement('html', '<div id="relatedtags-autocomplete"></div>');
$this->add_action_buttons(false, get_string('updatetag', 'tag'));
}