Пример #1
0
 /**
  * @see CommonDBTM::getSpecificMassiveActions()
  **/
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         if (TicketFollowup::canCreate()) {
             $actions['TicketFollowup' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_followup'] = __('Add a new followup');
         }
         if (TicketTask::canCreate()) {
             $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_task'] = __('Add a new task');
         }
         if (TicketValidation::canCreate()) {
             $actions['TicketValidation' . MassiveAction::CLASS_ACTION_SEPARATOR . 'submit_validation'] = __('Approval request');
         }
         if (Item_Ticket::canCreate()) {
             $actions['Item_Ticket' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_item'] = _x('button', 'Add an item');
         }
         if (Item_Ticket::canDelete()) {
             $actions['Item_Ticket' . MassiveAction::CLASS_ACTION_SEPARATOR . 'delete_item'] = _x('button', 'Remove an item');
         }
         if (Session::haveRight(self::$rightname, UPDATE)) {
             $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_actor'] = __('Add an actor');
             $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'enable_notif'] = __('Set notifications for all actors');
             $actions['Ticket_Ticket' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add'] = _x('button', 'Link tickets');
         }
         if (Session::haveRight(self::$rightname, UPDATE)) {
             MassiveAction::getAddTransferList($actions);
         }
     }
     return $actions;
 }
Пример #2
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimelineForm($rand)
 {
     global $CFG_GLPI;
     //check global rights
     if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) {
         return false;
     }
     // javascript function for add and edit items
     echo "<script type='text/javascript' >\n";
     echo "function viewAddSubitem" . $this->fields['id'] . "{$rand}(itemtype) {\n";
     $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => -1);
     if (isset($_GET['load_kb_sol'])) {
         $params['load_kb_sol'] = $_GET['load_kb_sol'];
     }
     $out = Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline_viewsubitem.php", $params, "", false);
     echo str_replace("\"itemtype\"", "itemtype", $out);
     echo "};";
     $out = "function viewEditSubitem" . $this->fields['id'] . "{$rand}(e, itemtype, items_id, o) {\n\n               var target = e.target || window.event.srcElement;\n               if (target.nodeName == 'a') return;\n               if (target.className == 'read_more_button') return;";
     $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => 'items_id');
     $out .= Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline_viewsubitem.php", $params, "", false);
     $out = str_replace("\"itemtype\"", "itemtype", $out);
     $out = str_replace("\"items_id\"", "items_id", $out);
     echo $out;
     //scroll to edit form
     echo "\$('body').scrollTop(0);";
     echo "\$('.ui-tabs-panel').scrollTop(0);";
     // add a mark to currently edited element
     echo "var found_active = \$('.talk_active');\n            i = found_active.length;\n            while(i--) {\n               var classes = found_active[i].className.replace( /(?:^|\\s)talk_active(?!\\S)/ , '' );\n               found_active[i].className = classes;\n            }\n            o.className = o.className + ' talk_active';\n      };";
     if (isset($_GET['load_kb_sol'])) {
         echo "viewAddSubitem" . $this->fields['id'] . "{$rand}('Solution');";
     }
     echo "</script>\n";
     //check sub-items rights
     $tmp = array('tickets_id' => $this->getID());
     $fup = new TicketFollowup();
     $ttask = new TicketTask();
     $canadd_fup = TicketFollowup::canCreate() && $fup->can(-1, UPDATE, $tmp);
     $canadd_task = TicketTask::canCreate() && $ttask->can(-1, UPDATE, $tmp);
     $canadd_document = Document::canCreate();
     $canadd_solution = Ticket::canUpdate() && $this->canSolve();
     if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) {
         return false;
     }
     //show choices
     if ($this->fields["status"] != CommonITILObject::SOLVED && $this->fields["status"] != CommonITILObject::CLOSED) {
         echo "<h2>" . _sx('button', 'Add') . " : </h2>";
         echo "<div class='timeline_form'>";
         echo "<ul class='timeline_choices'>";
         if ($canadd_fup) {
             echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>";
         }
         if ($canadd_task) {
             echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>";
         }
         if ($canadd_document) {
             echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>";
         }
         if ($canadd_solution) {
             echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>";
         }
         echo "</ul>";
         // timeline_choices
         echo "<div class='clear'>&nbsp;</div>";
         echo "</div>";
         //end timeline_form
     }
     echo "<div class='ajax_box' id='viewitem" . $this->fields['id'] . "{$rand}'></div>\n";
 }
Пример #3
0
 /**
  * @see CommonDBTM::getSpecificMassiveActions()
  **/
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if (TicketFollowup::canCreate() && $_SESSION['glpiactiveprofile']['interface'] == 'central') {
         $actions['add_followup'] = __('Add a new followup');
     }
     if (TicketTask::canCreate()) {
         $actions['add_task'] = __('Add a new task');
     }
     if (TicketValidation::canCreate()) {
         $actions['submit_validation'] = __('Approval request');
     }
     if (Session::haveRight("update_ticket", "1")) {
         $actions['add_actor'] = __('Add an actor');
         $actions['link_ticket'] = _x('button', 'Link tickets');
     }
     if (Session::haveRight('transfer', 'r') && Session::isMultiEntitiesMode() && Session::haveRight("update_ticket", "1")) {
         $actions['add_transfer_list'] = _x('button', 'Add to transfer list');
     }
     return $actions;
 }
Пример #4
0
 /**
  * Dropdown of actions for massive action
  *
  * @param $itemtype item type
  * @param $is_deleted massive action for deleted items ?
  * @param $extraparams array of extra parameters
  **/
 static function showForMassiveAction($itemtype, $is_deleted = 0, $extraparams = array())
 {
     global $LANG, $CFG_GLPI, $PLUGIN_HOOKS;
     /// TODO include in CommonDBTM defining only getAdditionalMassiveAction in sub classes
     /// for specific actions (return a array of action name and title)
     if (!class_exists($itemtype)) {
         return false;
     }
     if ($itemtype == 'NetworkPort') {
         echo "<select name='massiveaction' id='massiveaction'>";
         echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
         echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
         echo "<option value='assign_vlan'>" . $LANG['networking'][55] . "</option>";
         echo "<option value='unassign_vlan'>" . $LANG['networking'][58] . "</option>";
         // Interest of this massive action ?
         //          echo "<option value='move'>".$LANG['buttons'][20]."</option>";
         echo "</select>";
         $params = array('action' => '__VALUE__', 'itemtype' => $itemtype);
         ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionPorts.php", $params);
         echo "<span id='show_massiveaction'>&nbsp;</span>\n";
     } else {
         $item = new $itemtype();
         $infocom = new Infocom();
         $isadmin = $item->canUpdate();
         echo "<select name='massiveaction' id='massiveaction'>";
         echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
         if (!in_array($itemtype, $CFG_GLPI["massiveaction_noupdate_types"]) && ($isadmin && $itemtype != 'Ticket' || in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canUpdate() || $itemtype == 'Ticket' && haveRight('update_ticket', 1))) {
             echo "<option value='update'>" . $LANG['buttons'][14] . "</option>";
         }
         if (in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canCreate()) {
             echo "<option value='activate_infocoms'>" . $LANG['financial'][68] . "</option>";
         }
         if ($is_deleted && !in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"])) {
             if ($isadmin) {
                 echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>";
                 echo "<option value='restore'>" . $LANG['buttons'][21] . "</option>";
             }
         } else {
             // No delete for entities and tracking of not have right
             if (!in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"]) && ($isadmin && $itemtype != 'Ticket' || $itemtype == 'Ticket' && haveRight('delete_ticket', 1))) {
                 if ($item->maybeDeleted()) {
                     echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
                 } else {
                     echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>";
                 }
             }
             if ($isadmin && in_array($itemtype, array('Phone', 'Printer', 'Peripheral', 'Monitor'))) {
                 echo "<option value='connect'>" . $LANG['buttons'][9] . "</option>";
                 echo "<option value='disconnect'>" . $LANG['buttons'][10] . "</option>";
             }
             if (in_array($itemtype, $CFG_GLPI["document_types"])) {
                 $doc = new Document();
                 if ($doc->canView()) {
                     echo "<option value='add_document'>" . $LANG['document'][16] . "</option>";
                 }
             }
             if (in_array($itemtype, $CFG_GLPI["contract_types"])) {
                 $contract = new Contract();
                 if ($contract->canUpdate()) {
                     echo "<option value='add_contract'>" . $LANG['financial'][36] . "</option>";
                 }
             }
             if (haveRight('transfer', 'r') && isMultiEntitiesMode() && in_array($itemtype, array('CartridgeItem', 'Computer', 'ConsumableItem', 'Contact', 'Contract', 'Supplier', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer', 'Software', 'SoftwareLicense', 'Ticket', 'Document', 'Group', 'Link')) && $isadmin) {
                 echo "<option value='add_transfer_list'>" . $LANG['buttons'][48] . "</option>";
             }
             switch ($itemtype) {
                 case 'Software':
                     if ($isadmin && countElementsInTable("glpi_rules", "sub_type='RuleSoftwareCategory'") > 0) {
                         echo "<option value='compute_software_category'>" . $LANG['rulesengine'][38] . " " . $LANG['rulesengine'][40] . "</option>";
                     }
                     if (haveRight("rule_dictionnary_software", "w") && countElementsInTable("glpi_rules", "sub_type='RuleDictionnarySoftware'") > 0) {
                         echo "<option value='replay_dictionnary'>" . $LANG['rulesengine'][76] . "</option>";
                     }
                     break;
                 case 'Computer':
                     if ($isadmin) {
                         echo "<option value='connect_to_computer'>" . $LANG['buttons'][9] . "</option>";
                         echo "<option value='install'>" . $LANG['buttons'][4] . "</option>";
                         if ($CFG_GLPI['use_ocs_mode']) {
                             if (haveRight("ocsng", "w") || haveRight("sync_ocsng", "w")) {
                                 echo "<option value='force_ocsng_update'>" . $LANG['ocsng'][24] . "</option>";
                             }
                             echo "<option value='unlock_ocsng_field'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][16] . "</option>";
                             echo "<option value='unlock_ocsng_monitor'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][30] . "</option>";
                             echo "<option value='unlock_ocsng_peripheral'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][32] . "</option>";
                             echo "<option value='unlock_ocsng_printer'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][34] . "</option>";
                             echo "<option value='unlock_ocsng_software'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][52] . "</option>";
                             echo "<option value='unlock_ocsng_ip'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][50] . "</option>";
                             echo "<option value='unlock_ocsng_disk'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][55] . "</option>";
                         }
                     }
                     break;
                 case 'Supplier':
                     if ($isadmin) {
                         echo "<option value='add_contact'>" . $LANG['financial'][24] . "</option>";
                     }
                     break;
                 case 'Calendar':
                     echo "<option value='duplicate'>" . $LANG['buttons'][54] . "</option>";
                     break;
                 case 'Contact':
                     if ($isadmin) {
                         echo "<option value='add_enterprise'>" . $LANG['financial'][25] . "</option>";
                     }
                     break;
                 case 'User':
                     if ($isadmin) {
                         echo "<option value='add_group'>" . $LANG['setup'][604] . "</option>";
                         echo "<option value='add_userprofile'>" . $LANG['setup'][607] . "</option>";
                     }
                     if (haveRight("user_authtype", "w")) {
                         echo "<option value='change_authtype'>" . $LANG['login'][30] . "</option>";
                         echo "<option value='force_user_ldap_update'>" . $LANG['ocsng'][24] . "</option>";
                     }
                     break;
                 case 'Ticket':
                     $tmp = new TicketFollowup();
                     if ($tmp->canCreate()) {
                         echo "<option value='add_followup'>" . $LANG['job'][29] . "</option>";
                     }
                     $tmp = new TicketTask();
                     if ($tmp->canCreate()) {
                         echo "<option value='add_task'>" . $LANG['job'][30] . "</option>";
                     }
                     $tmp = new TicketValidation();
                     if ($tmp->canCreate()) {
                         echo "<option value='submit_validation'>" . $LANG['validation'][26] . "</option>";
                     }
                     if (haveRight("update_ticket", "1")) {
                         echo "<option value='add_actor'>" . $LANG['job'][27] . "</option>";
                         echo "<option value='link_ticket'>" . $LANG['job'][56] . "</option>";
                     }
                     break;
                 case 'CronTask':
                     echo "<option value='reset'>" . $LANG['buttons'][16] . " (" . $LANG['crontask'][40] . ")";
                     echo "</option>";
                     break;
                 case 'NotImportedEmail':
                     echo "<option value='delete_email'>" . $LANG['mailing'][133] . "</option>";
                     echo "<option value='import_email'>" . $LANG['buttons'][37] . "</option>";
                     break;
             }
             if ($item instanceof CommonTreeDropdown) {
                 if ($isadmin) {
                     echo "<option value='move_under'>" . $LANG['buttons'][20] . "</option>";
                 }
             }
             if ($itemtype != 'Entity' && $itemtype != 'Calendar' && $item instanceof CommonDropdown && $item->maybeRecursive()) {
                 if ($isadmin) {
                     echo "<option value='merge'>" . $LANG['buttons'][48] . " - " . $LANG['software'][48];
                     echo "</option>";
                 }
             }
             // Plugin Specific actions
             if (isset($PLUGIN_HOOKS['use_massive_action'])) {
                 foreach ($PLUGIN_HOOKS['use_massive_action'] as $plugin => $val) {
                     $actions = doOneHook($plugin, 'MassiveActions', $itemtype);
                     if (count($actions)) {
                         foreach ($actions as $key => $val) {
                             echo "<option value = '{$key}'>{$val}</option>";
                         }
                     }
                 }
             }
         }
         echo "</select>";
         $params = array('action' => '__VALUE__', 'is_deleted' => $is_deleted, 'itemtype' => $itemtype);
         if (count($extraparams)) {
             foreach ($extraparams as $key => $val) {
                 $params['extra_' . $key] = $val;
             }
         }
         ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveAction.php", $params);
         echo "<span id='show_massiveaction'>&nbsp;</span>\n";
     }
 }