Пример #1
0
function plugin_init_escalation()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['change_profile']['escalation'] = array('PluginEscalationProfile', 'changeprofile');
    $PLUGIN_HOOKS['csrf_compliant']['escalation'] = true;
    // After escalation, if user can't see the ticket (dan't see all ticket right), it redirect to ticket list
    if (isset($_SERVER['HTTP_REFERER']) and strstr($_SERVER['HTTP_REFERER'], "escalation/front/group_group.form.php")) {
        if (isset($_GET['id'])) {
            $ticket = new Ticket();
            $ticket->getFromDB($_GET['id']);
            if (!$ticket->canViewItem()) {
                // Can't see ticket, go in ticket list
                $ticket->redirectToList();
            }
        }
    }
    if (isset($_SESSION["glpiID"])) {
        $plugin = new Plugin();
        if ($plugin->isActivated('escalation')) {
            Plugin::registerClass('PluginEscalationProfile', array('addtabon' => array('Profile')));
            Plugin::registerClass('PluginEscalationTicketCopy', array('addtabon' => array('Ticket')));
            Plugin::registerClass('PluginEscalationConfig', array('addtabon' => array('Entity')));
            Plugin::registerClass('PluginEscalationGroup_Group', array('addtabon' => array('Ticket', 'Group')));
            $PLUGIN_HOOKS['menu_entry']['escalation'] = false;
            PluginEscalationGroup_Group::convertNewTicket();
            // limit group
            $peConfig = new PluginEscalationConfig();
            if ($peConfig->getValue('limitgroup', $_SESSION['glpidefault_entity']) == '1') {
                if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id'])) {
                    $group = new Group();
                    $a_groups = array();
                    $a_groups[0] = Dropdown::EMPTY_VALUE;
                    foreach ($_SESSION['glpigroups'] as $groups_id) {
                        $group->getFromDB($groups_id);
                        $a_groups[$groups_id] = $group->getName();
                    }
                    $_SESSION['plugin_escalation_requestergroups'] = $a_groups;
                    register_shutdown_function('plugin_escalation_on_exit');
                    ob_start();
                }
            }
            // end limit group
        }
        $PLUGIN_HOOKS['pre_item_add']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'selectGroupOnAdd'));
        $PLUGIN_HOOKS['item_add']['escalation'] = array('Ticket' => array('PluginEscalationTicketCopy', 'finishAdd'));
        //         $PLUGIN_HOOKS['pre_item_update']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'notMultiple'));
    }
}