Merge branch 'MDL-54837-master' of git://github.com/marinaglancy/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 13 Jun 2016 07:51:56 +0000 (08:51 +0100)
committerDan Poltawski <dan@moodle.com>
Mon, 13 Jun 2016 07:51:56 +0000 (08:51 +0100)
lib/form/tags.php
tag/classes/output/tagareacollection.php
tag/classes/tag.php

index 3a66e69..7f9bab6 100644 (file)
@@ -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);
index cb845ad..a2928b7 100644 (file)
@@ -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');
index 26ee690..02d568b 100644 (file)
@@ -1297,7 +1297,7 @@ class core_tag_tag {
                 require_once($CFG->dirroot . '/' . ltrim($tagarea->callbackfile, '/'));
             }
             $callback = $tagarea->callback;
-            return $callback($this, $exclusivemode, $fromctx, $ctx, $rec, $page);
+            return call_user_func_array($callback, [$this, $exclusivemode, $fromctx, $ctx, $rec, $page]);
         }
         return null;
     }