Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(massiveAction): Fixed bug preventing the addition of tags to objects without creation rights #220

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions inc/tag.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ public static function showTagDropdown($params = [])
'id' => 0,
'itemtype' => '',
'value' => '',
'items_ids' => [],
];
$params = array_merge($default_params, $params);

Expand Down Expand Up @@ -701,14 +702,17 @@ public static function showTagDropdown($params = [])
$token_creation = "return null;";
}

$readOnly = !$tag::canUpdate()
|| ($obj->isNewItem() && !$obj->canCreateItem())
|| (!$obj->isNewItem() && !$obj->canUpdateItem())
MyvTsv marked this conversation as resolved.
Show resolved Hide resolved
;
$all_itemtype_can_update = count(array_filter($params['items_ids'], function ($value) use ($obj) {
Rom1-B marked this conversation as resolved.
Show resolved Hide resolved
$obj->getFromDB($value);
return !$obj->canUpdateItem();
})) === 0;

if (is_array($params['id']) && $tag::canUpdate()) {
$readOnly = false;
}
$readOnly = !$tag::canUpdate()
|| (empty($params['items_ids']) && (
($obj->isNewItem() && !$obj->canCreateItem())
|| (!$obj->isNewItem() && !$obj->canUpdateItem())
))
Rom1-B marked this conversation as resolved.
Show resolved Hide resolved
|| (isset($params['items_ids']) && !$all_itemtype_can_update);
Rom1-B marked this conversation as resolved.
Show resolved Hide resolved

// call select2 lib for this input
echo Html::scriptBlock("
Expand Down
2 changes: 1 addition & 1 deletion inc/tagitem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
switch ($ma->getAction()) {
case 'addTag':
case 'removeTag':
PluginTagTag::showTagDropdown(['itemtype' => $itemtype, 'id' => array_keys($ma->items[$itemtype])]);
PluginTagTag::showTagDropdown(['itemtype' => $itemtype, 'items_ids' => array_keys($ma->items[$itemtype])]);
echo Html::submit(_sx('button', 'Save'));
return true;
}
Expand Down