function plugin_init_moreticket() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['add_css']['moreticket'] = 'moreticket.css'; $PLUGIN_HOOKS['csrf_compliant']['moreticket'] = true; $PLUGIN_HOOKS['change_profile']['moreticket'] = array('PluginMoreticketProfile', 'initProfile'); if (Session::getLoginUserID()) { Plugin::registerClass('PluginMoreticketProfile', array('addtabon' => 'Profile')); if (class_exists('PluginMoreticketProfile')) { // only if plugin activated $config = new PluginMoreticketConfig(); if (Session::haveRight("plugin_moreticket", UPDATE)) { if (strpos($_SERVER['REQUEST_URI'], "ticket.form.php") !== false && ($config->useWaiting() == true || $config->useSolution() == true)) { $PLUGIN_HOOKS['add_javascript']['moreticket'][] = 'scripts/moreticket.js'; $PLUGIN_HOOKS['add_javascript']['moreticket'][] = 'scripts/moreticket.js.php'; } $PLUGIN_HOOKS['config_page']['moreticket'] = 'front/config.form.php'; $PLUGIN_HOOKS['pre_item_update']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'beforeUpdate')); $PLUGIN_HOOKS['pre_item_add']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'beforeAdd')); $PLUGIN_HOOKS['item_add']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'afterAdd')); $PLUGIN_HOOKS['item_update']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'afterUpdate')); $PLUGIN_HOOKS['item_empty']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'emptyTicket')); } if (Session::haveRight('plugin_moreticket', READ)) { Plugin::registerClass('PluginMoreticketWaitingTicket', array('addtabon' => 'Ticket')); Plugin::registerClass('PluginMoreticketCloseTicket', array('addtabon' => 'Ticket')); } } } }
static function postAddCloseTicket($item) { if (!is_array($item->input) || !count($item->input)) { // Already cancel by another plugin return false; } $ticket = new Ticket(); if (isset($_POST['solution'])) { $item->input['solution'] = str_replace(array('\\r\\n', '\\r', '\\n'), '', $_POST['solution']); } // Get allowed status $config = new PluginMoreticketConfig(); $solution_status = array_keys(json_decode($config->solutionStatus(), true)); if (isset($item->input['id'])) { if (isset($item->input['status']) && isset($_POST['solutiontypes_id']) && isset($_POST['solution']) && in_array($item->input['status'], $solution_status)) { if (self::checkMandatory($_POST)) { // Then we add tickets informations $ticket->update(array('id' => $item->input['id'], 'solutiontypes_id' => $_POST['solutiontypes_id'], 'solution' => $_POST['solution'])); unset($_SESSION['glpi_plugin_moreticket_close']); } else { //$item->input = array(); $_SESSION['saveInput'][$item->getType()] = $item->input; $item->input = array(); } } } return true; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Moreticket 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 Moreticket. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $plugin = new Plugin(); if ($plugin->isActivated("moreticket")) { $config = new PluginMoreticketConfig(); if (isset($_POST["update"])) { if (isset($_POST['solution_status'])) { $_POST['solution_status'] = json_encode($_POST['solution_status']); } else { $_POST['solution_status'] = ""; } $config->update($_POST); //Update singelton PluginMoreticketConfig::getConfig(true); Html::redirect($_SERVER['HTTP_REFERER']); } else { Html::header(PluginMoreticketConfig::getTypeName(), '', "plugins", "moreticket"); $config->showForm(); Html::footer(); }
LICENSE This file is part of Moreticket. Moreticket is free software; you can redistribute it and/or modify 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. Moreticket 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 Moreticket. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; //change mimetype header("Content-type: application/javascript"); //not executed in self-service interface & right verification if ($_SESSION['glpiactiveprofile']['interface'] == "central") { $config = new PluginMoreticketConfig(); $use_waiting = $config->useWaiting(); $use_solution = $config->useSolution(); $solution_status = $config->solutionStatus(); $params = array('root_doc' => $CFG_GLPI['root_doc'], 'waiting' => CommonITILObject::WAITING, 'closed' => CommonITILObject::CLOSED, 'use_waiting' => $use_waiting, 'use_solution' => $use_solution, 'solution_status' => $solution_status); echo "moreticket(" . json_encode($params) . ");"; }
function plugin_moreticket_getAddSearchOptions($itemtype) { $sopt = array(); if ($itemtype == "Ticket") { if (Session::haveRight("plugin_moreticket", READ)) { $config = new PluginMoreticketConfig(); $sopt[3451]['table'] = 'glpi_plugin_moreticket_waitingtickets'; $sopt[3451]['field'] = 'date_report'; $sopt[3451]['name'] = __('Postponement date', 'moreticket'); $sopt[3451]['datatype'] = "datetime"; $sopt[3451]['joinparams'] = array('jointype' => 'child'); $sopt[3451]['massiveaction'] = false; $sopt[3452]['table'] = 'glpi_plugin_moreticket_waitingtypes'; $sopt[3452]['field'] = 'name'; $sopt[3452]['name'] = PluginMoreticketWaitingType::getTypeName(1); $sopt[3452]['datatype'] = "dropdown"; $sopt[3452]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_moreticket_waitingtickets', 'joinparams' => array('jointype' => 'child'))); $sopt[3452]['massiveaction'] = false; if ($config->closeInformations()) { $sopt[3453]['table'] = 'glpi_plugin_moreticket_closetickets'; $sopt[3453]['field'] = 'date'; $sopt[3453]['name'] = __('Close ticket informations', 'moreticket') . " : " . __('Date'); $sopt[3453]['datatype'] = "datetime"; $sopt[3453]['joinparams'] = array('jointype' => 'child'); $sopt[3453]['massiveaction'] = false; $sopt[3454]['table'] = 'glpi_plugin_moreticket_closetickets'; $sopt[3454]['field'] = 'comment'; $sopt[3454]['name'] = __('Close ticket informations', 'moreticket') . " : " . __('Comments'); $sopt[3454]['datatype'] = "text"; $sopt[3454]['joinparams'] = array('jointype' => 'child'); $sopt[3454]['massiveaction'] = false; $sopt[3455]['table'] = 'glpi_plugin_moreticket_closetickets'; $sopt[3455]['field'] = 'requesters_id'; $sopt[3455]['name'] = __('Close ticket informations', 'moreticket') . " : " . __('Writer'); $sopt[3455]['datatype'] = "dropdown"; $sopt[3455]['joinparams'] = array('jointype' => 'child'); $sopt[3455]['massiveaction'] = false; $sopt[3486]['table'] = 'glpi_documents'; $sopt[3486]['field'] = 'name'; $sopt[3486]['name'] = __('Close ticket informations', 'moreticket') . " : " . _n('Document', 'Documents', Session::getPluralNumber()); $sopt[3486]['forcegroupby'] = true; $sopt[3486]['usehaving'] = true; $sopt[3486]['datatype'] = 'dropdown'; $sopt[3486]['massiveaction'] = false; $sopt[3486]['joinparams'] = array('beforejoin' => array('table' => 'glpi_documents_items', 'joinparams' => array('jointype' => 'itemtype_item', 'specific_itemtype' => 'PluginMoreticketCloseTicket', 'beforejoin' => array('table' => 'glpi_plugin_moreticket_closetickets', 'joinparams' => array())))); } } } return $sopt; }
/** * Print the waiting ticket form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * * @return Nothing (display) * */ function showForm($ID, $options = array()) { global $CFG_GLPI; // validation des droits if (!$this->canview()) { return false; } if ($ID > 0) { if (!($this->fields = self::getWaitingTicketFromDB($ID))) { $this->getEmpty(); } } else { // Create item $this->getEmpty(); } // If values are saved in session we retrieve it if (isset($_SESSION['glpi_plugin_moreticket_waiting'])) { foreach ($_SESSION['glpi_plugin_moreticket_waiting'] as $key => $value) { switch ($key) { case 'reason': $this->fields[$key] = stripslashes($value); break; default: $this->fields[$key] = $value; break; } } } unset($_SESSION['glpi_plugin_moreticket_waiting']); $config = new PluginMoreticketConfig(); echo "<div class='spaced' id='moreticket_waiting_ticket'>"; echo "</br>"; echo "<table class='moreticket_waiting_ticket' id='cl_menu'>"; echo "<tr><td>"; echo __('Reason', 'moreticket') . " : <span class='red'>*</span> "; Html::autocompletionTextField($this, "reason"); echo "</td></tr>"; echo "<tr><td>"; echo PluginMoreticketWaitingType::getTypeName(1); if ($config->mandatoryWaitingType() == true) { echo " : <span class='red'>*</span> "; } $opt = array('value' => $this->fields['plugin_moreticket_waitingtypes_id']); Dropdown::show('PluginMoreticketWaitingType', $opt); echo "</td></tr>"; echo "<tr><td>"; _e('Postponement date', 'moreticket'); if ($config->mandatoryReportDate() == true) { echo " : <span class='red'>*</span> "; } if ($this->fields['date_report'] == 'NULL') { $this->fields['date_report'] = date("Y-m-d H:i:s"); } Html::showDateTimeFormItem("date_report", $this->fields['date_report'], 1, false); echo "</td></tr>"; echo "</table>"; echo "</div>"; }