function plugin_init_badges()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['badges'] = true;
    $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true;
    $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'initProfile');
    if (Session::getLoginUserID()) {
        Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true));
        Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask'));
        if (class_exists('PluginResourcesResource')) {
            PluginResourcesResource::registerType('PluginBadgesBadge');
        }
        $plugin = new Plugin();
        if (!$plugin->isActivated('environment') && Session::haveRight("plugin_badges", READ)) {
            $PLUGIN_HOOKS['menu_toadd']['badges'] = array('assets' => 'PluginBadgesMenu');
        }
        if (Session::haveRight("plugin_badges", UPDATE)) {
            $PLUGIN_HOOKS['use_massive_action']['badges'] = 1;
        }
        if (class_exists('PluginBadgesBadge')) {
            // only if plugin activated
            $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges';
        }
        // Import from Data_Injection plugin
        $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges';
    }
}
Beispiel #2
0
function plugin_init_badges()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['badges'] = true;
    $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'changeProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true;
    if (Session::getLoginUserID()) {
        Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true));
        Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask'));
        if (class_exists('PluginResourcesResource')) {
            PluginResourcesResource::registerType('PluginBadgesBadge');
        }
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            $_SESSION["glpi_plugin_environment_badges"] = 1;
            if (plugin_badges_haveRight("badges", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['title'] = PluginBadgesBadge::getTypeName(2);
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['page'] = '/plugins/badges/front/badge.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['links']['search'] = '/plugins/badges/front/badge.php';
            }
            if (plugin_badges_haveRight("badges", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['links']['add'] = '/plugins/badges/front/badge.form.php';
            }
        } else {
            if (plugin_badges_haveRight("badges", "r")) {
                $PLUGIN_HOOKS['menu_entry']['badges'] = 'front/badge.php';
                $PLUGIN_HOOKS['submenu_entry']['badges']['search'] = 'front/badge.php';
            }
            if (plugin_badges_haveRight("badges", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['badges']['add'] = 'front/badge.form.php?new=1';
            }
        }
        if (class_exists('PluginBadgesBadge')) {
            // only if plugin activated
            //Clean Plugin on Profile delete
            $PLUGIN_HOOKS['pre_item_purge']['badges'] = array('Profile
                                             ' => array('PluginBadgesProfile', 'purgeProfiles'));
            $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges';
        }
        // Import from Data_Injection plugin
        $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges';
    }
}