mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-54837 tags: fixed bug when collection is locked
also fixed fatal error for upgraded plugins that did not pass tag component to the tag form element
This commit is contained in:
parent
4ee8ef5d41
commit
6ee5e596b8
@ -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);
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user