/** * @param $output * @param $params **/ function executeActions($output, $params) { if (count($this->actions)) { foreach ($this->actions as $action) { switch ($action->fields["action_type"]) { case "send": $ticket = new Ticket(); if ($ticket->getFromDB($output['id'])) { NotificationEvent::raiseEvent('recall', $ticket); } break; case "add_validation": if (isset($output['_add_validation']) && !is_array($output['_add_validation'])) { $output['_add_validation'] = array($output['_add_validation']); } switch ($action->fields['field']) { case 'users_id_validate_requester_supervisor': $output['_add_validation'][] = 'requester_supervisor'; break; case 'users_id_validate_assign_supervisor': $output['_add_validation'][] = 'assign_supervisor'; break; case 'groups_id_validate': $output['_add_validation']['group'][] = $action->fields["value"]; break; case 'users_id_validate': $output['_add_validation'][] = $action->fields["value"]; break; case 'validation_percent': $output[$action->fields["field"]] = $action->fields["value"]; break; default: $output['_add_validation'][] = $action->fields["value"]; break; } break; case "assign": $output[$action->fields["field"]] = $action->fields["value"]; // Special case of users_id_requester if ($action->fields["field"] === '_users_id_requester') { // Add groups of requester if (!isset($output['_groups_id_of_requester'])) { $output['_groups_id_of_requester'] = array(); } foreach (Group_User::getUserGroups($action->fields["value"]) as $g) { $output['_groups_id_of_requester'][$g['id']] = $g['id']; } } break; case "append": $actions = $this->getActions(); $value = $action->fields["value"]; if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) { $value = $actions[$action->fields["field"]]["appendtoarray"]; $value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"]; } $output[$actions[$action->fields["field"]]["appendto"]][] = $value; // Special case of users_id_requester if ($action->fields["field"] === '_users_id_requester') { // Add groups of requester if (!isset($output['_groups_id_of_requester'])) { $output['_groups_id_of_requester'] = array(); } foreach (Group_User::getUserGroups($action->fields["value"]) as $g) { $output['_groups_id_of_requester'][$g['id']] = $g['id']; } } break; case 'fromuser': if ($action->fields['field'] == 'locations_id' && isset($output['users_locations'])) { $output['locations_id'] = $output['users_locations']; } break; case 'fromitem': if ($action->fields['field'] == 'locations_id' && isset($output['items_locations'])) { $output['locations_id'] = $output['items_locations']; } if ($action->fields['field'] == 'groups_id' && isset($output['items_groups'])) { $output['groups_id'] = $output['items_groups']; } break; case 'compute': // Value could be not set (from test) $urgency = isset($output['urgency']) ? $output['urgency'] : 3; $impact = isset($output['impact']) ? $output['impact'] : 3; // Apply priority_matrix from config $output['priority'] = Ticket::computePriority($urgency, $impact); break; case "affectbyip": case "affectbyfqdn": case "affectbymac": if (!isset($output["entities_id"])) { $output["entities_id"] = $params["entities_id"]; } if (isset($this->regex_results[0])) { $regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]); } else { $regexvalue = $action->fields["value"]; } switch ($action->fields["action_type"]) { case "affectbyip": $result = IPAddress::getUniqueItemByIPAddress($regexvalue, $output["entities_id"]); break; case "affectbyfqdn": $result = FQDNLabel::getUniqueItemByFQDN($regexvalue, $output["entities_id"]); break; case "affectbymac": $result = NetworkPortInstantiation::getUniqueItemByMac($regexvalue, $output["entities_id"]); break; default: $result = array(); } if (!empty($result)) { $output["items_id"][$result["itemtype"]][] = $result["id"]; } break; } } } return $output; }
$options = array(); foreach ($available_options as $key) { if (isset($_GET[$key])) { $options[$key] = $_GET[$key]; } } $track->showForm($_GET["id"], $options); } else { commonHeader($LANG['job'][13], '', "maintain", "ticket"); $users_id_requester = getLoginUserID(); // No default requester if own ticket right = tech and update_ticket right to update requester if (haveRight('own_ticket', 1) && haveRight('update_ticket', 1)) { $users_id_requester = 0; } // Set default value... $values = array('_users_id_requester' => $users_id_requester, '_users_id_requester_notif' => array('use_notification' => 1), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1), '_groups_id_observer' => 0, 'suppliers_id_assign' => 0, 'name' => '', 'content' => '', 'ticketcategories_id' => 0, 'urgency' => 3, 'impact' => 3, 'priority' => Ticket::computePriority(3, 3), 'requesttypes_id' => $_SESSION["glpidefault_requesttypes_id"], 'hour' => 0, 'minute' => 0, 'date' => $_SESSION["glpi_currenttime"], 'entities_id' => $_SESSION["glpiactive_entity"], 'status' => 'new', 'followup' => array(), 'itemtype' => '', 'items_id' => 0, 'plan' => array(), 'global_validation' => 'none', 'due_date' => '', 'slas_id' => 0, '_add_validation' => 0, 'type' => -1); // Restore saved value or override with page parameter foreach ($values as $name => $value) { if (isset($_REQUEST[$name])) { $values[$name] = $_REQUEST[$name]; } else { if (isset($_SESSION["helpdeskSaved"][$name])) { $values[$name] = $_SESSION["helpdeskSaved"]["{$name}"]; } } } // Clean text fields $values['name'] = stripslashes($values['name']); $values['content'] = cleanPostForTextArea($values['content']); if (isset($_SESSION["helpdeskSaved"])) { unset($_SESSION["helpdeskSaved"]);
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; // Send UTF8 Headers header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); if (isset($_POST["urgency"]) && isset($_POST["impact"]) && isset($_POST["priority"])) { $priority = Ticket::computePriority($_POST["urgency"], $_POST["impact"]); if ($_POST["priority"]) { echo "<script type='text/javascript' >\n"; echo "document.getElementById('" . $_POST["priority"] . "').value = {$priority};"; echo "\n</script>"; } else { echo Ticket::getPriorityName($priority); } }
function executeActions($output, $params) { if (count($this->actions)) { foreach ($this->actions as $action) { switch ($action->fields["action_type"]) { case "send": $ticket = new Ticket(); if ($ticket->getFromDB($output['id'])) { NotificationEvent::raiseEvent('recall', $ticket); } break; case "add_validation": $output['_add_validation'] = $action->fields["value"]; break; case "assign": $output[$action->fields["field"]] = $action->fields["value"]; break; case 'compute': // Value could be not set (from test) $urgency = isset($output['urgency']) ? $output['urgency'] : 3; $impact = isset($output['impact']) ? $output['impact'] : 3; // Apply priority_matrix from config $output['priority'] = Ticket::computePriority($urgency, $impact); break; case "affectbyip": case "affectbyfqdn": case "affectbymac": if (!isset($output["entities_id"])) { $output["entities_id"] = $params["entities_id"]; } if (isset($this->regex_results[0])) { $regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]); } else { $regexvalue = $action->fields["value"]; } switch ($action->fields["action_type"]) { case "affectbyip": $result = NetworkPort::getUniqueObjectIDByIPAddressOrMac($regexvalue, "IP", $output["entities_id"]); break; case "affectbyfqdn": $result = NetworkPort::getUniqueObjectIDByFQDN($regexvalue, $output["entities_id"]); break; case "affectbymac": $result = NetworkPort::getUniqueObjectIDByIPAddressOrMac($regexvalue, "MAC", $output["entities_id"]); break; default: $result = array(); } if (!empty($result)) { $output["itemtype"] = $result["itemtype"]; $output["items_id"] = $result["id"]; } break; } } } return $output; }