diff --git a/lib/form/tags.php b/lib/form/tags.php index 3a66e69b402..7f9bab6b74a 100644 --- a/lib/form/tags.php +++ b/lib/form/tags.php @@ -128,6 +128,9 @@ class MoodleQuickForm_tags extends MoodleQuickForm_autocomplete { */ public function onQuickFormEvent($event, $arg, &$caller) { if ($event === 'createElement') { + if (!is_array($arg[2])) { + $arg[2] = []; + } $arg[2] += array('itemtype' => '', 'component' => ''); } return parent::onQuickFormEvent($event, $arg, $caller); diff --git a/tag/classes/output/tagareacollection.php b/tag/classes/output/tagareacollection.php index cb845ad9482..a2928b7ee44 100644 --- a/tag/classes/output/tagareacollection.php +++ b/tag/classes/output/tagareacollection.php @@ -43,8 +43,17 @@ class tagareacollection extends \core\output\inplace_editable { * @param \stdClass $tagarea */ public function __construct($tagarea) { + if (!empty($tagarea->locked)) { + // If the tag collection for the current tag area is locked, display the + // name of the collection without possibility to edit it. + $tagcoll = \core_tag_collection::get_by_id($tagarea->tagcollid); + parent::__construct('core_tag', 'tagareacollection', $tagarea->id, false, + \core_tag_collection::display_name($tagcoll), $tagarea->tagcollid); + return; + } + $tagcollections = \core_tag_collection::get_collections_menu(true); - $editable = (count($tagcollections) > 1) && empty($tagarea->locked) && + $editable = (count($tagcollections) > 1) && has_capability('moodle/tag:manage', context_system::instance()); $areaname = core_tag_area::display_name($tagarea->component, $tagarea->itemtype); $edithint = new lang_string('edittagcollection', 'core_tag');