From: scyrma Date: Fri, 29 Feb 2008 09:35:04 +0000 (+0000) Subject: MDL-13728 - Tag form editing now provides a checkbox to set the tag type (official... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=603443b5195f208611d66b7637aeaea05b6c4a91;p=moodle.git 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) --- diff --git a/lang/en_utf8/tag.php b/lang/en_utf8/tag.php index dfce19a079..a9976fb937 100644 --- a/lang/en_utf8/tag.php +++ b/lang/en_utf8/tag.php @@ -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)'; diff --git a/lib/db/access.php b/lib/db/access.php index 87670253b1..3bb9f05fbc 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -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, diff --git a/tag/edit.php b/tag/edit.php index 8da09367e6..e567e77da5 100644 --- a/tag/edit.php +++ b/tag/edit.php @@ -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); diff --git a/tag/edit_form.php b/tag/edit_form.php index 4311b94a7e..fbfdf067b8 100644 --- a/tag/edit_form.php +++ b/tag/edit_form.php @@ -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', '
'); $mform->addElement('textarea', 'relatedtags', get_string('relatedtags','tag'), 'cols="50" rows="3"'); $mform->setType('relatedtags', PARAM_TAGLIST); $mform->addElement('html', '
'); $mform->addElement('html', '
'); - $this->add_action_buttons(false, get_string('updatetag', 'tag')); }