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

See Tag Only On Active Itemtypes #221

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tsmr
Copy link

@tsmr tsmr commented Dec 19, 2024

  • [X ] I have performed a self-review of my code.
  • [X ] I have added tests (when available) that prove my fix is effective or that my feature works.

Description

By design you will see Tag dropdown on all objects, but in fact you nee to display the dropdown only on itemtypes with active tag

Copy link
Contributor

@stonebuzz stonebuzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @tsmr

if I remember correctly, if a tag is not linked to a specific itemtype, it means it is available for all objects in GLPI !

inc/tag.class.php Outdated Show resolved Hide resolved
Co-authored-by: Romain B. <[email protected]>
@stonebuzz
Copy link
Contributor

@tsmr

can you try this

public static function canItemtype($itemtype = '')
{
    if (empty($itemtype) || !class_exists($itemtype) || in_array($itemtype, self::getBlacklistItemtype())) {
        return false;
    }

    $tags = new self();
    $types_menu = [];
    $use_global_tag = false;

    foreach ($tags->find(['is_active' => 1]) as $tag) {
        if (!empty($tag['type_menu'])) {
            $types_menu = array_merge($types_menu, json_decode($tag['type_menu']));
        } else {
            $use_global_tag = true;
        }
    }

    return $use_global_tag || in_array($itemtype, $types_menu);
}

@tsmr tsmr requested a review from stonebuzz December 21, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants