diff --git a/inc/tag.class.php b/inc/tag.class.php index ff20fb9..29f3f61 100644 --- a/inc/tag.class.php +++ b/inc/tag.class.php @@ -600,6 +600,7 @@ public static function showTagDropdown($params = []) 'id' => 0, 'itemtype' => '', 'value' => '', + 'items_ids' => [], ]; $params = array_merge($default_params, $params); @@ -701,10 +702,16 @@ public static function showTagDropdown($params = []) $token_creation = "return null;"; } + // Returns false if at least one item in "items_ids" cannot be updated + $can_update_all = count(array_filter($params['items_ids'], function ($value) use ($obj) { + $obj->getFromDB($value); + return !$obj->canUpdateItem(); + })) === 0; + $readOnly = !$tag::canUpdate() || ($obj->isNewItem() && !$obj->canCreateItem()) || (!$obj->isNewItem() && !$obj->canUpdateItem()) - ; + || (!empty($params['items_ids']) && !$can_update_all); // call select2 lib for this input echo Html::scriptBlock(" diff --git a/inc/tagitem.class.php b/inc/tagitem.class.php index 80b216d..a930617 100644 --- a/inc/tagitem.class.php +++ b/inc/tagitem.class.php @@ -492,7 +492,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma) switch ($ma->getAction()) { case 'addTag': case 'removeTag': - PluginTagTag::showTagDropdown(['itemtype' => $itemtype]); + PluginTagTag::showTagDropdown(['itemtype' => $itemtype, 'items_ids' => array_keys($ma->items[$itemtype])]); echo Html::submit(_sx('button', 'Save')); return true; }