Skip to content

Commit d002f1c

Browse files
tsmrRom1-B
andauthored
See Tag Only On Active Itemtypes (#221)
* See Tag Only On Active Itemtypes * Fix CS * Fix for global tags * Update inc/tag.class.php Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> * Change function order --------- Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
1 parent bd9f004 commit d002f1c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

inc/tag.class.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,23 @@ public static function getBlacklistItemtype()
7575
*/
7676
public static function canItemtype($itemtype = '')
7777
{
78-
return !empty($itemtype) && class_exists($itemtype) && !in_array($itemtype, self::getBlacklistItemtype());
78+
if (empty($itemtype) || !class_exists($itemtype) || in_array($itemtype, self::getBlacklistItemtype())) {
79+
return false;
80+
}
81+
82+
$tags = new self();
83+
$types_menu = [];
84+
$use_global_tag = false;
85+
86+
foreach ($tags->find(['is_active' => 1]) as $tag) {
87+
if (!empty($tag['type_menu'])) {
88+
$types_menu = array_merge($types_menu, json_decode($tag['type_menu']));
89+
} else {
90+
$use_global_tag = true;
91+
}
92+
}
93+
94+
return $use_global_tag || in_array($itemtype, $types_menu);
7995
}
8096

8197
public function showForm($ID, $options = [])

0 commit comments

Comments
 (0)