function cleanDBonPurge() { global $DB; $supplierjob = new Supplier_Ticket(); $supplierjob->cleanDBonItemDelete($this->getType(), $this->fields['id']); $cs = new Contract_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); $cs = new Contact_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); // Ticket rules use suppliers_id_assign Rule::cleanForItemAction($this, 'suppliers_id%'); }
function cleanDBonPurge() { global $DB; $supplierjob = new Supplier_Ticket(); $supplierjob->cleanDBonItemDelete($this->getType(), $this->fields['id']); $ps = new Problem_Supplier(); $ps->cleanDBonItemDelete($this->getType(), $this->fields['id']); $cs = new Change_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); $query1 = "DELETE\n FROM `glpi_projecttaskteams`\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . __CLASS__ . "'"; $DB->query($query1); $query1 = "DELETE\n FROM `glpi_projectteams`\n WHERE `items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . __CLASS__ . "'"; $DB->query($query1); $cs = new Contract_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); $cs = new Contact_Supplier(); $cs->cleanDBonItemDelete($this->getType(), $this->fields['id']); // Ticket rules use suppliers_id_assign Rule::cleanForItemAction($this, 'suppliers_id%'); }
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 * @since version 0.85 */ if (!defined('GLPI_ROOT')) { include '../inc/includes.php'; } $link = new Supplier_Ticket(); Session::checkLoginUser(); Html::popHeader(__('Email followup'), $_SERVER['PHP_SELF']); if (isset($_POST["update"])) { $link->check($_POST["id"], UPDATE); $link->update($_POST); echo "<script type='text/javascript' >\n"; echo "window.parent.location.reload();"; echo "</script>"; } else { if (isset($_POST['delete'])) { $link->check($_POST['id'], DELETE); $link->delete($_POST); Event::log($link->fields['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $link->fields['tickets_id']); } else {
/** function buildTicket - Builds,and returns, the major structure of the ticket to be entered. * * @param $i mail ID * @param $options array of possible options * * @return ticket fields array */ function buildTicket($i, $options = array()) { global $CFG_GLPI; $play_rules = isset($options['play_rules']) && $options['play_rules']; $head = $this->getHeaders($i); // Get Header Info Return Array Of Headers // **Key Are (subject,to,toOth,toNameOth,from,fromName) $tkt = array(); $tkt['_blacklisted'] = false; // For RuleTickets $tkt['_mailgate'] = $options['mailgates_id']; // Use mail date if it's defined if ($this->fields['use_mail_date']) { $tkt['date'] = $head['date']; } // Detect if it is a mail reply $glpi_message_match = "/GLPI-([0-9]+)\\.[0-9]+\\.[0-9]+@\\w*/"; // Check if email not send by GLPI : if yes -> blacklist if (!isset($head['message_id']) || preg_match($glpi_message_match, $head['message_id'], $match)) { $tkt['_blacklisted'] = true; return $tkt; } // manage blacklist $blacklisted_emails = Blacklist::getEmails(); // Add name of the mailcollector as blacklisted $blacklisted_emails[] = $this->fields['name']; if (Toolbox::inArrayCaseCompare($head['from'], $blacklisted_emails)) { $tkt['_blacklisted'] = true; return $tkt; } // max size = 0 : no import attachments if ($this->fields['filesize_max'] > 0) { if (is_writable(GLPI_TMP_DIR)) { $tkt['_filename'] = $this->getAttached($i, GLPI_TMP_DIR . "/", $this->fields['filesize_max']); $tkt['_tag'] = $this->tags; } else { //TRANS: %s is a directory Toolbox::logInFile('mailgate', sprintf(__('%s is not writable'), GLPI_TMP_DIR . "/")); } } // Who is the user ? $tkt['_users_id_requester'] = User::getOrImportByEmail($head['from']); $tkt["_users_id_requester_notif"]['use_notification'] = 1; // Set alternative email if user not found / used if anonymous mail creation is enable if (!$tkt['_users_id_requester']) { $tkt["_users_id_requester_notif"]['alternative_email'] = $head['from']; } // Add to and cc as additional observer if user found if (count($head['ccs'])) { foreach ($head['ccs'] as $cc) { if ($cc != $head['from'] && !Toolbox::inArrayCaseCompare($cc, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($cc)) > 0) { $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1); } } } if (count($head['tos'])) { foreach ($head['tos'] as $to) { if ($to != $head['from'] && !Toolbox::inArrayCaseCompare($to, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($to)) > 0) { $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1); } } } // Auto_import $tkt['_auto_import'] = 1; // For followup : do not check users_id = login user $tkt['_do_not_check_users_id'] = 1; $body = $this->getBody($i); // Do it before using charset variable $head['subject'] = $this->decodeMimeString($head['subject']); $tkt['_head'] = $head; if (!empty($this->charset) && !$this->body_converted) { $body = Toolbox::encodeInUtf8($body, $this->charset); $this->body_converted = true; } if (!Toolbox::seems_utf8($body)) { $tkt['content'] = Toolbox::encodeInUtf8($body); } else { $tkt['content'] = $body; } // See In-Reply-To field if (isset($head['in_reply_to'])) { if (preg_match($glpi_message_match, $head['in_reply_to'], $match)) { $tkt['tickets_id'] = intval($match[1]); } } // See in References if (!isset($tkt['tickets_id']) && isset($head['references'])) { if (preg_match($glpi_message_match, $head['references'], $match)) { $tkt['tickets_id'] = intval($match[1]); } } // See in title if (!isset($tkt['tickets_id']) && preg_match('/\\[.+#(\\d+)\\]/', $head['subject'], $match)) { $tkt['tickets_id'] = intval($match[1]); } $is_html = false; //If files are present and content is html if (isset($this->files) && count($this->files) && $tkt['content'] != strip_tags($tkt['content']) && !isset($tkt['tickets_id'])) { $is_html = true; $tkt['content'] = Ticket::convertContentForTicket($tkt['content'], array_merge($this->files, $this->altfiles), $this->tags); } $tkt['content'] = $this->cleanMailContent($tkt['content']); if ($is_html && !isset($tkt['tickets_id'])) { $tkt['content'] = nl2br($tkt['content']); } $tkt['_supplier_email'] = false; // Found ticket link if (isset($tkt['tickets_id'])) { // it's a reply to a previous ticket $job = new Ticket(); $tu = new Ticket_User(); $st = new Supplier_Ticket(); // Check if ticket exists and users_id exists in GLPI /// TODO check if users_id have right to add a followup to the ticket if ($job->getFromDB($tkt['tickets_id']) && $job->fields['status'] != CommonITILObject::CLOSED && ($CFG_GLPI['use_anonymous_followups'] || $tkt['_users_id_requester'] > 0 || $tu->isAlternateEmailForITILObject($tkt['tickets_id'], $head['from']) || ($tkt['_supplier_email'] = $st->isSupplierEmail($tkt['tickets_id'], $head['from'])))) { if ($tkt['_supplier_email']) { $tkt['content'] = sprintf(__('From %s'), $head['from']) . "\n\n" . $tkt['content']; } $content = explode("\n", $tkt['content']); $tkt['content'] = ""; $to_keep = array(); // Move requester to author of followup : $tkt['users_id'] = $tkt['_users_id_requester']; $begin_strip = -1; $end_strip = -1; $begin_match = "/" . NotificationTargetTicket::HEADERTAG . ".*" . NotificationTargetTicket::HEADERTAG . "/"; $end_match = "/" . NotificationTargetTicket::FOOTERTAG . ".*" . NotificationTargetTicket::FOOTERTAG . "/"; foreach ($content as $ID => $val) { // Get first tag for begin if ($begin_strip < 0) { if (preg_match($begin_match, $val)) { $begin_strip = $ID; } } // Get last tag for end if ($begin_strip >= 0) { if (preg_match($end_match, $val)) { $end_strip = $ID; continue; } } } if ($begin_strip >= 0) { // Clean first and last lines $content[$begin_strip] = preg_replace($begin_match, '', $content[$begin_strip]); } if ($end_strip >= 0) { // Clean first and last lines $content[$end_strip] = preg_replace($end_match, '', $content[$end_strip]); } if ($begin_strip >= 0) { $length = count($content); // Use end strip if set if ($end_strip >= 0 && $end_strip < $length) { $length = $end_strip; } for ($i = $begin_strip + 1; $i < $length; $i++) { unset($content[$i]); } } $to_keep = array(); // Aditional clean for thunderbird foreach ($content as $ID => $val) { if (!isset($val[0]) || $val[0] != '>') { $to_keep[$ID] = $ID; } } $tkt['content'] = ""; foreach ($to_keep as $ID) { $tkt['content'] .= $content[$ID] . "\n"; } // Do not play rules for followups : WRONG : play rules only for refuse options //$play_rules = false; } else { // => to handle link in Ticket->post_addItem() $tkt['_linkedto'] = $tkt['tickets_id']; unset($tkt['tickets_id']); } } // Add message from getAttached if ($this->addtobody) { $tkt['content'] .= $this->addtobody; } $tkt['name'] = $this->textCleaner($head['subject']); if (!isset($tkt['tickets_id'])) { // Which entity ? //$tkt['entities_id']=$this->fields['entities_id']; //$tkt['Subject']= $head['subject']; // not use for the moment // Medium $tkt['urgency'] = "3"; // No hardware associated $tkt['itemtype'] = ""; // Mail request type } else { // Reopen if needed $tkt['add_reopen'] = 1; } $tkt['requesttypes_id'] = RequestType::getDefault('mail'); if ($play_rules) { $rule_options['ticket'] = $tkt; $rule_options['headers'] = $head; $rule_options['mailcollector'] = $options['mailgates_id']; $rule_options['_users_id_requester'] = $tkt['_users_id_requester']; $rulecollection = new RuleMailCollectorCollection(); $output = $rulecollection->processAllRules(array(), array(), $rule_options); // New ticket : compute all if (!isset($tkt['tickets_id'])) { foreach ($output as $key => $value) { $tkt[$key] = $value; } } else { // Followup only copy refuse data $tobecopied = array('_refuse_email_no_response', '_refuse_email_with_response'); foreach ($tobecopied as $val) { if (isset($output[$val])) { $tkt[$val] = $output[$val]; } } } } $tkt = Toolbox::addslashes_deep($tkt); return $tkt; }
///TODO try to move it to specific form page $ticket_user = new Ticket_User(); $ticket_user->check($_POST['id'], 'd'); $ticket_user->delete($_POST); Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']); } else { if (isset($_POST['delete_group'])) { $group_ticket = new Group_Ticket(); $group_ticket->check($_POST['id'], 'd'); $group_ticket->delete($_POST); Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']); } else { if (isset($_POST['delete_supplier'])) { $supplier_ticket = new Supplier_Ticket(); $supplier_ticket->check($_POST['id'], 'd'); $supplier_ticket->delete($_POST); Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']); } else { if (isset($_POST['addme_observer'])) { $ticket_user = new Ticket_User(); $track->check($_POST['tickets_id'], 'r'); $input = array('tickets_id' => $_POST['tickets_id'], 'users_id' => Session::getLoginUserID(), 'use_notification' => 1, 'type' => CommonITILActor::OBSERVER); $ticket_user->add($input); Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s adds an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']); } } }
/** * Assign and actor in a ticket for an authenticated user * * @param $params array of options (ticket, id2name) * @param $protocol the communication protocol used * * @return array of hashtable as glpi.getTicket **/ static function methodsetTicketAssign($params, $protocol) { global $DB, $CFG_GLPI; if (isset($params['help'])) { return array('ticket' => 'integer,mandatory', 'user' => 'integer,optional', 'supplier' => 'integer,optional', 'group' => 'integer,optional', 'user_email' => 'string,optional', 'use_email_notification' => 'bool,optional', 'help' => 'bool,optional'); } if (!Session::getLoginUserID()) { return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } if (!Session::haveRight("assign_ticket", "1")) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if (!isset($params['user']) && !isset($params['group']) && !isset($params['supplier'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'user or group or supplier'); } $ticket = new Ticket(); if (!isset($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket'); } if (!is_numeric($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket=' . $params['ticket']); } if (!$ticket->can($params['ticket'], 'r')) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND); } if (!$ticket->getFromDB($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket'); } $ticket_user = new Ticket_User(); $user = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN); // technician : optionnal, default = none if (isset($params['user'])) { if (!is_numeric($params['user'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user'); } $user['users_id'] = $params['user']; if ($ticket->getFromDB($params['ticket'])) { $entity = $ticket->getField('entities_id'); } if (!$ticket_user->can(-1, 'w', $user) || !self::checkUserRights($params['user'], "own_ticket", 1, $entity)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if ($ticket->isUser(CommonITILActor::ASSIGN, $user['users_id'])) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'User already assign for this ticket'); } if (isset($params['user_email'])) { if (!NotificationMail::isUserAddressValid($params['user_email'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user_email'); } $user['alternative_email'] = $params['user_email']; $user['use_notification'] = 1; } else { if (isset($params['use_email_notification']) && $params['use_email_notification']) { $user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 1); } else { if (isset($params['use_email_notification']) && !$params['use_email_notification']) { $user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 0); } } } if (!$ticket_user->add($user)) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'user not assign'); } } // group (technicians group) : optionnal, default = none $group_ticket = new Group_Ticket(); $group = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN); if (isset($params['group'])) { if (!is_numeric($params['group'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'group'); } $group['groups_id'] = $params['group']; if (!$group_ticket->can(-1, 'w', $group)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if ($ticket->isGroup(CommonITILActor::ASSIGN, $params['group'])) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'Group already assign for this ticket'); } if (!$group_ticket->add($group)) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'group not assign'); } } // supplier to assign : optionnal, default = none $supplier_ticket = new Supplier_Ticket(); $supplier = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN); if (isset($params['supplier'])) { if (!is_numeric($params['supplier'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'supplier'); } $supplier['suppliers_id'] = $params['supplier']; if (!$supplier_ticket->can(-1, 'w', $supplier)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if ($ticket->isSupplier(CommonITILActor::ASSIGN, $params['supplier'])) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'Supplier already assign for this ticket'); } if (!$supplier_ticket->add($supplier)) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'supplier not assign'); } } return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol); return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError()); }
/** * Save form datas to the target * * @param PluginFormcreatorFormanswer $formanswer Answers previously saved */ public function save(PluginFormcreatorFormanswer $formanswer) { $datas = array(); $ticket = new Ticket(); $docItem = new Document_Item(); $form = new PluginFormcreatorForm(); $form->getFromDB($formanswer->fields['plugin_formcreator_forms_id']); // Get default request type $query = "SELECT id FROM `glpi_requesttypes` WHERE `name` LIKE 'Formcreator';"; $result = $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error()); list($requesttypes_id) = $GLOBALS['DB']->fetch_array($result); $datas['requesttypes_id'] = $requesttypes_id; // Get predefined Fields $ttp = new TicketTemplatePredefinedField(); $predefined_fields = $ttp->getPredefinedFields($this->fields['tickettemplates_id'], true); $datas = array_merge($datas, $predefined_fields); // Parse datas and tags $datas['name'] = addslashes($this->parseTags($this->fields['name'], $formanswer)); $datas['content'] = htmlentities($this->parseTags($this->fields['comment'], $formanswer)); $datas['entities_id'] = isset($_SESSION['glpiactive_entity']) ? $_SESSION['glpiactive_entity'] : $form->fields['entities_id']; $datas['_users_id_requester'] = 0; $datas['_users_id_recipient'] = $_SESSION['glpiID']; $datas['_tickettemplates_id'] = $this->fields['tickettemplates_id']; // Define due date $answer = new PluginFormcreatorAnswer(); $found = $answer->find('plugin_formcreator_formanwers_id = ' . (int) $formanswer->fields['id'] . ' AND plugin_formcreator_question_id = ' . (int) $this->fields['due_date_question']); $date = array_shift($found); $str = "+" . $this->fields['due_date_value'] . " " . $this->fields['due_date_period']; switch ($this->fields['due_date_rule']) { case 'answer': $due_date = $date['answer']; break; case 'ticket': $due_date = date('Y-m-d H:i:s', strtotime($str)); break; case 'calcul': $due_date = date('Y-m-d H:i:s', strtotime($date['answer'] . " " . $str)); break; default: $due_date = null; break; } if (!is_null($due_date)) { $datas['due_date'] = $due_date; } // Select ticket actors $query = "SELECT id, actor_type, actor_value, use_notification\n FROM glpi_plugin_formcreator_targettickets_actors\n WHERE plugin_formcreator_targettickets_id = " . $this->getID() . "\n AND actor_role = 'requester'"; $result = $GLOBALS['DB']->query($query); // If there is only one requester add it on creation, otherwize we will add them later if ($GLOBALS['DB']->numrows($result) == 1) { $actor = $GLOBALS['DB']->fetch_array($result); switch ($actor['actor_type']) { case 'creator': $user_id = $formanswer->fields['requester_id']; break; case 'validator': $user_id = $formanswer->fields['validator_id']; break; case 'person': case 'group': case 'supplier': $user_id = $actor['actor_value']; break; case 'question_person': case 'question_group': case 'question_supplier': $answer = new PluginFormcreatorAnswer(); $found = $answer->find('`plugin_formcreator_question_id` = ' . (int) $actor['actor_value'] . ' AND `plugin_formcreator_formanwers_id` = ' . (int) $formanswer->fields['id']); $found = array_shift($found); if (empty($found['answer'])) { continue; } else { $user_id = (int) $found['answer']; } break; } $datas['_users_id_requester'] = $user_id; } // Create the target ticket if (!($ticketID = $ticket->add($datas))) { return false; } // Add link between Ticket and FormAnswer $itemlink = new Item_Ticket(); $itemlink->add(array('itemtype' => 'PluginFormcreatorFormanswer', 'items_id' => $formanswer->fields['id'], 'tickets_id' => $ticketID)); // Add actors to ticket $query = "SELECT id, actor_role, actor_type, actor_value, use_notification\n FROM glpi_plugin_formcreator_targettickets_actors\n WHERE plugin_formcreator_targettickets_id = " . $this->getID(); $result = $GLOBALS['DB']->query($query); while ($actor = $GLOBALS['DB']->fetch_array($result)) { // If actor type is validator and if the form doesn't have a validator, continue to other actors if ($actor['actor_type'] == 'validator' && !$form->fields['validation_required']) { continue; } switch ($actor['actor_role']) { case 'requester': $role = CommonITILActor::REQUESTER; break; case 'observer': $role = CommonITILActor::OBSERVER; break; case 'assigned': $role = CommonITILActor::ASSIGN; break; } switch ($actor['actor_type']) { case 'creator': $user_id = $formanswer->fields['requester_id']; break; case 'validator': $user_id = $formanswer->fields['validator_id']; break; case 'person': case 'group': case 'supplier': $user_id = $actor['actor_value']; break; case 'question_person': case 'question_group': case 'question_supplier': $answer = new PluginFormcreatorAnswer(); $found = $answer->find('`plugin_formcreator_question_id` = ' . (int) $actor['actor_value'] . ' AND `plugin_formcreator_formanwers_id` = ' . (int) $formanswer->fields['id']); $found = array_shift($found); if (empty($found['answer'])) { continue; } else { $user_id = (int) $found['answer']; } break; } switch ($actor['actor_type']) { case 'creator': case 'validator': case 'person': case 'question_person': $obj = new Ticket_User(); $obj->add(array('tickets_id' => $ticketID, 'users_id' => $user_id, 'type' => $role, 'use_notification' => $actor['use_notification'])); break; case 'group': case 'question_group': $obj = new Group_Ticket(); $obj->add(array('tickets_id' => $ticketID, 'groups_id' => $user_id, 'type' => $role, 'use_notification' => $actor['use_notification'])); break; case 'supplier': case 'question_supplier': $obj = new Supplier_Ticket(); $obj->add(array('tickets_id' => $ticketID, 'suppliers_id' => $user_id, 'type' => $role, 'use_notification' => $actor['use_notification'])); break; } } // Attach documents to ticket $found = $docItem->find("itemtype = 'PluginFormcreatorFormanswer' AND items_id = " . (int) $formanswer->getID()); if (count($found) > 0) { foreach ($found as $document) { $docItem->add(array('documents_id' => $document['documents_id'], 'itemtype' => 'Ticket', 'items_id' => $ticketID)); } } // Attach validation message as first ticket followup if validation is required and // if is set in ticket target configuration // /!\ Followup is directly saved to the database to avoid double notification on ticket // creation and add followup if ($form->fields['validation_required'] && $this->fields['validation_followup']) { $message = addslashes(__('Your form have been accepted by the validator', 'formcreator')); if (!empty($formanswer->fields['comment'])) { $message .= "\n" . addslashes($formanswer->fields['comment']); } $query = "INSERT INTO `glpi_ticketfollowups` SET\n `tickets_id` = {$ticketID},\n `date` = NOW(),\n `users_id` = {$_SESSION['glpiID']},\n `content` = \"{$message}\""; $GLOBALS['DB']->query($query); } return true; }