Esempio n. 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'));
    }
}
Esempio n. 2
0
 function showForm(Ticket $ticket)
 {
     global $CFG_GLPI;
     echo "<form method='post' name='' id=''  action=\"" . $CFG_GLPI['root_doc'] . "/plugins/escalation/front/ticketcopy.form.php\">";
     echo "<table width='950' class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo "Copie de ticket (Liste des champs à copier)";
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='3' align='center'>";
     echo "<a href=\"javascript:showHideDiv('listfields','imgcat0','../../pics/folder.png'," . "'../../pics/folder-open.png');\">";
     echo "Voir tous les champs</a>";
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     echo "</td>";
     echo "<td>";
     echo "Lier au ticket";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo('link');
     echo "</td>";
     echo "</tr>";
     $this->displayField(__('Title'), "name", $ticket->fields['name'], '', 'checked');
     $this->displayField(__('Description'), "content", $ticket->fields['content'], '', 'checked');
     echo "</table>";
     echo "<div id='listfields' style='display:none;'>";
     echo "<table width='950' class='tab_cadre_fixe'>";
     $this->displayField(__('Status'), "status", Ticket::getStatus($ticket->fields['status']), $ticket->fields['status']);
     $this->displayField(__('Type'), "type", Ticket::getTicketTypeName($ticket->fields['type']), $ticket->fields['type']);
     $this->displayField(__('Urgency'), "urgency", Ticket::getUrgencyName($ticket->fields['urgency']), $ticket->fields['urgency']);
     $this->displayField(__('Impact'), "impact", Ticket::getImpactName($ticket->fields['impact']), $ticket->fields['impact']);
     $this->displayField(__('Priority'), "priority", Ticket::getPriorityName($ticket->fields['priority']), $ticket->fields['priority']);
     $this->displayField(__('Due date'), "due_date", Html::convDateTime($ticket->fields['due_date']), $ticket->fields['due_date']);
     $this->displayField(__('Category'), "itilcategories_id", Dropdown::getDropdownName('glpi_itilcategories', $ticket->fields['itilcategories_id']), $ticket->fields['itilcategories_id']);
     if ($ticket->fields['items_id'] > 0) {
         $this->displayField(__('Associated element') . ' - ' . __('Type'), "itemtype", call_user_func(array($ticket->fields['itemtype'], 'getTypeName')), $ticket->fields['itemtype']);
         $this->displayField(__('Associated element'), "items_id", Dropdown::getDropdownName(getTableForItemType($ticket->fields['itemtype']), $ticket->fields['items_id']), $ticket->fields['items_id']);
     }
     $this->displayField(__('Request source'), "requesttypes_id", Dropdown::getDropdownName('glpi_requesttypes', $ticket->fields['requesttypes_id']), $ticket->fields['requesttypes_id']);
     $this->displayField(__('SLA'), "slas_id", Dropdown::getDropdownName('glpi_slas', $ticket->fields['slas_id']), $ticket->fields['slas_id']);
     $ticket_User = new Ticket_User();
     $a_ticket_users = $ticket_User->find("`tickets_id`='" . $ticket->getID() . "'\n         AND `type`='1'");
     foreach ($a_ticket_users as $data) {
         $name = '';
         if ($data['users_id'] == 0) {
             $name = $data['alternative_email'];
         } else {
             $name = Dropdown::getDropdownName('glpi_users', $data['users_id']);
         }
         $this->displayField(__('Requester'), "_users_id_requester", $name, $data['id']);
     }
     $group_Ticket = new Group_Ticket();
     $a_group_tickets = $group_Ticket->find("`tickets_id`='" . $ticket->getID() . "'\n         AND `type`='1'");
     foreach ($a_group_tickets as $data) {
         $this->displayField(__('Requester group'), "_groups_id_requester", Dropdown::getDropdownName('glpi_groups', $data['groups_id']), $data['groups_id']);
     }
     // Techs
     $peConfig = new PluginEscalationConfig();
     if ($peConfig->getValue('workflow', $ticket->fields['entities_id']) == '0') {
         $a_ticket_uers = $ticket_User->find("`tickets_id`='" . $ticket->getID() . "'\n            AND `type`='2'");
         foreach ($a_ticket_uers as $data) {
             $name = '';
             if ($data['users_id'] == 0) {
                 $name = $data['alternative_email'];
             } else {
                 $name = Dropdown::getDropdownName('glpi_users', $data['users_id']);
             }
             $this->displayField(__('Technician'), "_users_id_assign", $name, $data['id']);
         }
         $a_group_tickets = $group_Ticket->find("`tickets_id`='" . $ticket->getID() . "'\n            AND `type`='2'");
         foreach ($a_group_tickets as $data) {
             $this->displayField(__('Group in charge of the ticket'), "_groups_id_assign", Dropdown::getDropdownName('glpi_groups', $data['groups_id']), $data['groups_id']);
         }
     }
     $ticketFollowup = new TicketFollowup();
     $followups = $ticketFollowup->find("`tickets_id`='" . $ticket->getID() . "'");
     foreach ($followups as $data) {
         $this->displayField(__('Follow-up'), "followup-" . $data['id'], $data['content'], $data['id']);
     }
     $ticketTask = new TicketTask();
     $tasks = $ticketTask->find("`tickets_id`='" . $ticket->getID() . "'");
     foreach ($tasks as $data) {
         $this->displayField(__('Task'), "task-" . $data['id'], $data['content'], $data['id']);
     }
     // Documents
     //      $document_Item = new Document_Item();
     //      $docs = $document_Item->find("`items_id`='".$ticket->getID()."'
     //         AND `itemtype`='Ticket'");
     //      foreach ($docs as $data) {
     //         $this->displayField($LANG['document'][18], "filename",
     //            Dropdown::getDropdownName("glpi_documents", $data['documents_id']),
     //            $data['documents_id']);
     //      }
     //      // filename[]
     echo "</table>";
     echo "</div>";
     echo "<table width='950' class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_3'>";
     echo "<td class='center'>";
     echo "<input type='submit' name='add' value=\"Créer\" class='submit'>";
     echo "<input type='hidden' name='tickets_id' value='" . $ticket->fields['id'] . "'>";
     echo "</td>";
     echo "</tr>";
     Html::closeForm();
     echo "</table>";
     echo "<br/>";
     echo "<br/>";
 }
Esempio n. 3
0
 static function notMultiple($item)
 {
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         $peConfig = new PluginEscalationConfig();
         $unique_assigned = $peConfig->getValue("unique_assigned", $item->fields['entities_id']);
         if ($unique_assigned == '1') {
             $ticket_User = new Ticket_User();
             $group_Ticket = new Group_Ticket();
             $group_User = new Group_User();
             if (isset($item->input['_itil_assign'])) {
                 if ($item->input['_itil_assign']['_type'] == 'user') {
                     $in_group = 0;
                     $a_groups = $group_Ticket->find("`type`='2'\n                     AND `tickets_id`='" . $item->fields['id'] . "'");
                     $groups = Group_User::getUserGroups($item->input['_itil_assign']['users_id']);
                     if (count($a_groups) > 0) {
                         foreach ($a_groups as $data) {
                             foreach ($groups as $dat) {
                                 if ($dat['id'] == $data['groups_id']) {
                                     $in_group = 1;
                                 }
                             }
                         }
                     }
                     //if ($in_group == '0') {
                     //   unset($item->input['_itil_assign']['users_id']);
                     //}
                 } else {
                     if ($item->input['_itil_assign']['_type'] == 'group') {
                         $a_groups = $group_Ticket->find("`type`='2'\n                     AND `tickets_id`='" . $item->getID() . "'");
                         if (count($a_groups) > 0) {
                             foreach ($a_groups as $data) {
                                 $group_Ticket->delete($data);
                             }
                         }
                         $a_users = $ticket_User->find("`type`='2'\n                     AND `tickets_id`='" . $item->getID() . "'");
                         foreach ($a_users as $data) {
                             if (countElementsInTable($group_User->getTable(), "`users_id`='" . $data['users_id'] . "'\n                             AND `groups_id`='" . $item->input['_itil_assign']['groups_id'] . "'") == '0') {
                                 $ticket_User->delete($data);
                             }
                         }
                     }
                 }
             }
         }
     }
 }