notificationtargetticket.class.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * @version $Id: notificationtargetticket.class.php 21397 2013-07-24 13:24:31Z moyo $
00004  -------------------------------------------------------------------------
00005  GLPI - Gestionnaire Libre de Parc Informatique
00006  Copyright (C) 2003-2013 by the INDEPNET Development Team.
00007 
00008  http://indepnet.net/   http://glpi-project.org
00009  -------------------------------------------------------------------------
00010 
00011  LICENSE
00012 
00013  This file is part of GLPI.
00014 
00015  GLPI is free software; you can redistribute it and/or modify
00016  it under the terms of the GNU General Public License as published by
00017  the Free Software Foundation; either version 2 of the License, or
00018  (at your option) any later version.
00019 
00020  GLPI is distributed in the hope that it will be useful,
00021  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  GNU General Public License for more details.
00024 
00025  You should have received a copy of the GNU General Public License
00026  along with GLPI. If not, see <http://www.gnu.org/licenses/>.
00027  --------------------------------------------------------------------------
00028  */
00029 
00030 /** @file
00031 * @brief
00032 */
00033 
00034 if (!defined('GLPI_ROOT')) {
00035    die("Sorry. You can't access directly to this file");
00036 }
00037 
00038 // Class NotificationTarget
00039 class NotificationTargetTicket extends NotificationTargetCommonITILObject {
00040 
00041    var $private_profiles = array();
00042 
00043    public $html_tags = array('##ticket.solution.description##');
00044 
00045 
00046    /**
00047     * @param $entity          (default '')
00048     * @param $event           (default '')
00049     * @param $object          (default null)
00050     * @param $options   array
00051     */
00052    function __construct($entity='', $event='', $object=null, $options=array()) {
00053 
00054       parent::__construct($entity, $event, $object, $options);
00055 
00056       $this->options['sendprivate'] = false;
00057 
00058       if (isset($options['followup_id'])) {
00059          $this->options['sendprivate'] = $options['is_private'];
00060       }
00061 
00062       if (isset($options['task_id'])) {
00063          $this->options['sendprivate'] = $options['is_private'];
00064       }
00065    }
00066 
00067 
00068    /**
00069     * @see NotificationTarget::validateSendTo()
00070    **/
00071    function validateSendTo($event, array $infos, $notify_me=false) {
00072       // Always send notification for satisfaction : if send on ticket closure
00073       if ($event != 'satisfaction') {
00074          // Check global ones for notification to myself
00075          if (!parent::validateSendTo($event, $infos, $notify_me)) {
00076             return false;
00077          }
00078 
00079          // Private object and no right to see private items : do not send
00080          if ($this->isPrivate()
00081             && (!isset($infos['additionnaloption']['show_private'])
00082                || !$infos['additionnaloption']['show_private'])) {
00083             return false;
00084          }
00085       }
00086       return true;
00087    }
00088 
00089 
00090    /**
00091     * @param $event  (default '')
00092    **/
00093    function getSubjectPrefix($event='') {
00094 
00095       if ($event !='alertnotclosed') {
00096          $perso_tag = trim(Entity::getUsedConfig('notification_subject_tag', $this->getEntity(),
00097                                                  '', ''));
00098 
00099          if (empty($perso_tag)) {
00100             $perso_tag = 'GLPI';
00101          }
00102          return sprintf("[$perso_tag #%07d] ", $this->obj->getField('id'));
00103       }
00104       return parent::getSubjectPrefix();
00105    }
00106 
00107 
00108    /**
00109     * @since version 0.84
00110     *
00111     * @return string
00112    **/
00113    function getMessageID() {
00114       return "GLPI-".$this->obj->getField('id').".".time().".".rand(). "@".php_uname('n');
00115    }
00116 
00117 
00118    function addAdditionnalInfosForTarget() {
00119       global $DB;
00120 
00121       $query = "SELECT `id`
00122                 FROM `glpi_profiles`
00123                 WHERE `glpi_profiles`.`show_full_ticket` = '1'";
00124 
00125       foreach ($DB->request($query) as $data) {
00126          $this->private_profiles[$data['id']] = $data['id'];
00127       }
00128    }
00129 
00130 
00131    /**
00132     * Get item associated with the object on which the event was raised
00133     *
00134     * @param $event  (default '')
00135     *
00136     * @return the object associated with the itemtype
00137    **/
00138    function getObjectItem($event='') {
00139 
00140       if ($this->obj) {
00141          $itemtype = $this->obj->getField('itemtype');
00142 
00143          if (($itemtype != NOT_AVAILABLE) && ($itemtype != '')
00144              && ($item = getItemForItemtype($itemtype))) {
00145             $item->getFromDB($this->obj->getField('items_id'));
00146             $this->target_object = $item;
00147          }
00148       }
00149    }
00150 
00151 
00152    /**
00153     * @param $data   array
00154    **/
00155    function addAdditionnalUserInfo(array $data) {
00156       global $DB;
00157 
00158       if (!isset($data['id'])) {
00159          return array('show_private' => 0);
00160       }
00161 
00162       $query = "SELECT COUNT(*) AS cpt
00163                 FROM `glpi_profiles_users`
00164                 WHERE `users_id`='".$data['id']."' ".
00165                       getEntitiesRestrictRequest("AND", "glpi_profiles_users", "entities_id",
00166                                                  $this->getEntity(), true)."
00167                       AND profiles_id IN (".implode(',',$this->private_profiles).")";
00168       $result = $DB->query($query);
00169 
00170       if ($DB->result($result,0,'cpt')) {
00171          return array('show_private' => 1);
00172       }
00173       return array('show_private' => 0);
00174    }
00175 
00176 
00177    /**
00178     *Get events related to tickets
00179    **/
00180    function getEvents() {
00181 
00182       $events = array('new'               => __('New ticket'),
00183                       'update'            => __('Update of a ticket'),
00184                       'solved'            => __('Ticket solved'),
00185                       'validation'        => __('Validation request'),
00186                       'validation_answer' => __('Validation request answer'),
00187                       'add_followup'      => __("New followup"),
00188                       'update_followup'   => __('Update of a followup'),
00189                       'delete_followup'   => __('Deletion of a followup'),
00190                       'add_task'          => __('New task'),
00191                       'update_task'       => __('Update of a task'),
00192                       'delete_task'       => __('Deletion of a task'),
00193                       'closed'            => __('Closing of the ticket'),
00194                       'delete'            => __('Deletion of a ticket'),
00195                       'alertnotclosed'    => __('Not solved tickets'),
00196                       'recall'            => __('Automatic reminders of SLAs'),
00197                       'satisfaction'      => __('Satisfaction survey'));
00198       asort($events);
00199       return $events;
00200    }
00201 
00202 
00203    /**
00204     * Restrict by profile and by config
00205     * to avoid send notification to a user without rights
00206    **/
00207    function getProfileJoinSql() {
00208 
00209       $query = " INNER JOIN `glpi_profiles_users`
00210                      ON (`glpi_profiles_users`.`users_id` = `glpi_users`.`id` ".
00211                          getEntitiesRestrictRequest("AND", "glpi_profiles_users", "entities_id",
00212                                                     $this->getEntity(), true).")";
00213 
00214       if ($this->isPrivate()) {
00215          $query .= " INNER JOIN `glpi_profiles`
00216                      ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`
00217                          AND `glpi_profiles`.`interface` = 'central'
00218                          AND `glpi_profiles`.`show_full_ticket` = '1') ";
00219       }
00220       return $query;
00221    }
00222 
00223 
00224    function isPrivate() {
00225 
00226       if (isset($this->options['sendprivate']) && ($this->options['sendprivate'] == 1)) {
00227          return true;
00228       }
00229       return false;
00230    }
00231 
00232 
00233    /**
00234     * @see NotificationTargetCommonITILObject::getDatasForObject()
00235    **/
00236    function getDatasForObject(CommonDBTM $item, array $options, $simple=false) {
00237       global $CFG_GLPI;
00238 
00239       // Common ITIL datas
00240       $datas                               = parent::getDatasForObject($item, $options, $simple);
00241 
00242       // Specific datas
00243       $datas["##ticket.costfixed"]         = $item->getField('cost_fixed');
00244       $datas["##ticket.costmaterial"]      = $item->getField('cost_material');
00245       $datas["##ticket.costtime"]          = $item->getField('cost_time');
00246 
00247 
00248       $datas['##ticket.urlvalidation##']
00249                         = $this->formatURL($options['additionnaloption']['usertype'],
00250                                            "ticket_".$item->getField("id")."_TicketValidation$1");
00251       $datas['##ticket.globalvalidation##']
00252                         = TicketValidation::getStatus($item->getField('global_validation'));
00253       $datas['##ticket.type##']
00254                         = Ticket::getTicketTypeName($item->getField('type'));
00255       $datas['##ticket.requesttype##']
00256                         = Dropdown::getDropdownName('glpi_requesttypes',
00257                                                     $item->getField('requesttypes_id'));
00258 
00259       $autoclose_value  = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '',
00260                                                 Entity::CONFIG_NEVER);
00261 
00262       $datas['##ticket.autoclose##']             = __('Never');
00263       $datas['##lang.ticket.autoclosewarning##'] = "";
00264       if ($autoclose_value > 0) {
00265          $datas['##ticket.autoclose##'] = $autoclose_value;
00266          $datas['##lang.ticket.autoclosewarning##']
00267                      //TRANS: %s is the number of days before auto closing
00268             = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day',
00269                          'Without a reply, the ticket will be automatically closed after %s days',
00270                          $autoclose_value),
00271                       $autoclose_value);
00272       }
00273 
00274       $datas['##ticket.sla##'] = '';
00275       if ($item->getField('slas_id')) {
00276          $datas['##ticket.sla##']
00277                      = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
00278       }
00279 
00280       // is ticket deleted
00281       $datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
00282 
00283 
00284       //Tags associated with the object linked to the ticket
00285       $datas['##ticket.itemtype##']           = '';
00286       $datas['##ticket.item.name##']          = '';
00287       $datas['##ticket.item.serial##']        = '';
00288       $datas['##ticket.item.otherserial##']   = '';
00289       $datas['##ticket.item.location##']      = '';
00290       $datas['##ticket.item.contact']         = '';
00291       $datas['##ticket.item.contactnumber##'] = '';
00292       $datas['##ticket.item.user##']          = '';
00293       $datas['##ticket.item.group##']         = '';
00294       $datas['##ticket.item.model##']         = '';
00295 
00296       if (isset($item->fields['itemtype'])
00297           && ($hardware = getItemForItemtype($item->fields['itemtype']))
00298           && isset($item->fields["items_id"])
00299           && $hardware->getFromDB($item->fields["items_id"])) {
00300          //Object type
00301          $datas['##ticket.itemtype##']  = $hardware->getTypeName();
00302 
00303          //Object name
00304          $datas['##ticket.item.name##'] = $hardware->getField('name');
00305 
00306          //Object serial
00307          if ($hardware->isField('serial')) {
00308             $datas['##ticket.item.serial##'] = $hardware->getField('serial');
00309          }
00310 
00311          //Object contact
00312          if ($hardware->isField('contact')) {
00313             $datas['##ticket.item.contact##'] = $hardware->getField('contact');
00314          }
00315 
00316          //Object contact num
00317          if ($hardware->isField('contact_num')) {
00318             $datas['##ticket.item.contactnumber##']
00319                         = $hardware->getField('contact_num');
00320          }
00321 
00322          //Object otherserial
00323          if ($hardware->isField('otherserial')) {
00324             $datas['##ticket.item.otherserial##']
00325                         = $hardware->getField('otherserial');
00326          }
00327 
00328          //Object location
00329          if ($hardware->isField('locations_id')) {
00330             $datas['##ticket.item.location##']
00331                         = Dropdown::getDropdownName('glpi_locations',
00332                                                     $hardware->getField('locations_id'));
00333          }
00334 
00335          //Object user
00336          if ($hardware->getField('users_id')) {
00337             $user_tmp = new User();
00338             if ($user_tmp->getFromDB($hardware->getField('users_id'))) {
00339                $datas['##ticket.item.user##'] = $user_tmp->getName();
00340             }
00341          }
00342 
00343          //Object group
00344          if ($hardware->getField('groups_id')) {
00345             $datas['##ticket.item.group##']
00346                         = Dropdown::getDropdownName('glpi_groups',
00347                                                     $hardware->getField('groups_id'));
00348          }
00349 
00350          $modeltable = getSingular($hardware->getTable())."models";
00351          $modelfield = getForeignKeyFieldForTable($modeltable);
00352 
00353          if ($hardware->isField($modelfield)) {
00354             $datas['##ticket.item.model##']
00355                   = Dropdown::getDropdownName($modeltable, $hardware->getField($modelfield));
00356          }
00357 
00358       }
00359 
00360       // Get tasks, followups, log, validation, satisfaction, linked tickets
00361       if (!$simple) {
00362          // Linked tickets
00363          $linked_tickets         = Ticket_Ticket::getLinkedTicketsTo($item->getField('id'));
00364          $datas['linkedtickets'] = array();
00365          if (count($linked_tickets)) {
00366             $linkedticket = new Ticket();
00367             foreach ($linked_tickets as $data) {
00368                if ($linkedticket->getFromDB($data['tickets_id'])) {
00369                   $tmp                          = array();
00370                   $tmp['##linkedticket.id##']   = $data['tickets_id'];
00371                   $tmp['##linkedticket.link##'] = Ticket_Ticket::getLinkName($data['link']);
00372                   $tmp['##linkedticket.url##']  = $this->formatURL($options['additionnaloption']['usertype'],
00373                                                                    "ticket_".$data['tickets_id']);
00374 
00375 
00376                   $tmp['##linkedticket.title##']   = $linkedticket->getField('name');
00377                   $tmp['##linkedticket.content##'] = $linkedticket->getField('content');
00378 
00379                   $datas['linkedtickets'][] = $tmp;
00380                }
00381             }
00382          }
00383 
00384          $datas['##ticket.numberoflinkedtickets##'] = count($datas['linkedtickets']);
00385 
00386          $restrict = "`tickets_id`='".$item->getField('id')."'";
00387          $problems = getAllDatasFromTable('glpi_problems_tickets',$restrict);
00388          $datas['problems'] = array();
00389          if (count($problems)) {
00390             $problem = new Problem();
00391             foreach ($problems as $data) {
00392                if ($problem->getFromDB($data['problems_id'])) {
00393                   $tmp                       = array();
00394                   $tmp['##problem.id##']     = $data['problems_id'];
00395                   $tmp['##problem.date##']   = $problem->getField('date');
00396                   $tmp['##problem.title##']  = $problem->getField('name');
00397                   $tmp['##problem.url##']    = $this->formatURL($options['additionnaloption']['usertype'],
00398                                                                 "problem_".$data['problems_id']);
00399                   $tmp['##problem.content##'] = $problem->getField('content');
00400 
00401                   $datas['problems'][] = $tmp;
00402                }
00403             }
00404          }
00405 
00406          $datas['##ticket.numberofproblems##'] = count($datas['problems']);
00407 
00408          $restrict = "`tickets_id`='".$item->getField('id')."'";
00409          if (!isset($options['additionnaloption']['show_private'])
00410              || !$options['additionnaloption']['show_private']) {
00411             $restrict .= " AND `is_private` = '0'";
00412          }
00413          $restrict .= " ORDER BY `date` DESC, `id` ASC";
00414 
00415          //Task infos
00416          $tasks = getAllDatasFromTable('glpi_tickettasks',$restrict);
00417 
00418          foreach ($tasks as $task) {
00419             $tmp                          = array();
00420             $tmp['##task.isprivate##']    = Dropdown::getYesNo($task['is_private']);
00421             $tmp['##task.author##']       = Html::clean(getUserName($task['users_id']));
00422             $tmp['##task.category##']     = Dropdown::getDropdownName('glpi_taskcategories',
00423                                                                       $task['taskcategories_id']);
00424             $tmp['##task.date##']         = Html::convDateTime($task['date']);
00425             $tmp['##task.description##']  = $task['content'];
00426             $tmp['##task.time##']         = Ticket::getActionTime($task['actiontime']);
00427             $tmp['##task.status##']    = Planning::getState($task['state']);
00428 
00429 
00430             $tmp['##task.user##']         = "";
00431             $tmp['##task.begin##']        = "";
00432             $tmp['##task.end##']          = "";
00433             if (!is_null($task['begin'])) {
00434                $tmp['##task.user##']      = Html::clean(getUserName($task['users_id_tech']));
00435                $tmp['##task.begin##']     = Html::convDateTime($task['begin']);
00436                $tmp['##task.end##']       = Html::convDateTime($task['end']);
00437             }
00438 
00439             $datas['tasks'][] = $tmp;
00440          }
00441 
00442          $datas['##ticket.numberoftasks##'] = 0;
00443          if (!empty($datas['tasks'])) {
00444             $datas['##ticket.numberoftasks##'] = count($datas['tasks']);
00445          }
00446 
00447          //Followup infos
00448          $followups = getAllDatasFromTable('glpi_ticketfollowups',$restrict);
00449          foreach ($followups as $followup) {
00450             $tmp                             = array();
00451             $tmp['##followup.isprivate##']   = Dropdown::getYesNo($followup['is_private']);
00452             $tmp['##followup.author##']      = Html::clean(getUserName($followup['users_id']));
00453             $tmp['##followup.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes',
00454                                                                          $followup['requesttypes_id']);
00455             $tmp['##followup.date##']        = Html::convDateTime($followup['date']);
00456             $tmp['##followup.description##'] = $followup['content'];
00457             $datas['followups'][]            = $tmp;
00458          }
00459 
00460          $datas['##ticket.numberoffollowups##'] = 0;
00461          if (isset($datas['followups'])) {
00462             $datas['##ticket.numberoffollowups##'] = count($datas['followups']);
00463          }
00464 
00465          //Validation infos
00466          $restrict = "`tickets_id`='".$item->getField('id')."'";
00467 
00468          if (isset($options['validation_id']) && $options['validation_id']) {
00469             $restrict .= " AND `glpi_ticketvalidations`.`id` = '".$options['validation_id']."'";
00470          }
00471 
00472          $restrict .= " ORDER BY `submission_date` DESC, `id` ASC";
00473 
00474          $validations = getAllDatasFromTable('glpi_ticketvalidations',$restrict);
00475 
00476          foreach ($validations as $validation) {
00477             $tmp = array();
00478             $tmp['##validation.submission.title##']
00479                   //TRANS: %s is the user name
00480                   = sprintf(__('An approval request has been submitted by %s'),
00481                             Html::clean(getUserName($validation['users_id'])));
00482             $tmp['##validation.answer.title##']
00483                   //TRANS: %s is the user name
00484                   = sprintf(__('An answer to an an approval request was produced by %s'),
00485                             Html::clean(getUserName($validation['users_id_validate'])));
00486 
00487             $tmp['##validation.author##'] = Html::clean(getUserName($validation['users_id']));
00488 
00489             $tmp['##validation.status##'] = TicketValidation::getStatus($validation['status']);
00490             $tmp['##validation.storestatus##']
00491                                           = $validation['status'];
00492             $tmp['##validation.submissiondate##']
00493                                           = Html::convDateTime($validation['submission_date']);
00494             $tmp['##validation.commentsubmission##']
00495                                           = $validation['comment_submission'];
00496             $tmp['##validation.validationdate##']
00497                                           = Html::convDateTime($validation['validation_date']);
00498             $tmp['##validation.validator##']
00499                                           =  Html::clean(getUserName($validation['users_id_validate']));
00500             $tmp['##validation.commentvalidation##']
00501                                           = $validation['comment_validation'];
00502             $datas['validations'][]       = $tmp;
00503          }
00504 
00505          // Ticket Satisfaction
00506          $inquest                                = new TicketSatisfaction();
00507          $datas['##satisfaction.type##']         = '';
00508          $datas['##satisfaction.datebegin##']    = '';
00509          $datas['##satisfaction.dateanswered##'] = '';
00510          $datas['##satisfaction.satisfaction##'] = '';
00511          $datas['##satisfaction.description##']  = '';
00512 
00513          if ($inquest->getFromDB($item->getField('id'))) {
00514             // internal inquest
00515             if ($inquest->fields['type'] == 1) {
00516                $datas['##ticket.urlsatisfaction##']
00517                            = $this->formatURL($options['additionnaloption']['usertype'],
00518                                               "ticket_".$item->getField("id").'_Ticket$3');
00519             // external inquest
00520             } else if ($inquest->fields['type'] == 2) {
00521                $datas['##ticket.urlsatisfaction##'] = Entity::generateLinkSatisfaction($item);
00522             }
00523 
00524             $datas['##satisfaction.type##'] = $inquest->getTypeInquestName($inquest->getfield('type'));
00525             $datas['##satisfaction.datebegin##']
00526                                             = Html::convDateTime($inquest->fields['date_begin']);
00527             $datas['##satisfaction.dateanswered##']
00528                                             = Html::convDateTime($inquest->fields['date_answered']);
00529             $datas['##satisfaction.satisfaction##']
00530                                              = $inquest->fields['satisfaction'];
00531             $datas['##satisfaction.description##']
00532                                              = $inquest->fields['comment'];
00533          }
00534       }
00535 
00536       return $datas;
00537    }
00538 
00539 
00540    static function isAuthorMailingActivatedForHelpdesk() {
00541       global $DB,$CFG_GLPI;
00542 
00543       if ($CFG_GLPI['use_mailing']) {
00544          $query = "SELECT COUNT(`glpi_notifications`.`id`)
00545                    FROM `glpi_notifications`
00546                    INNER JOIN `glpi_notificationtargets`
00547                      ON (`glpi_notifications`.`id` = `glpi_notificationtargets`.`notifications_id`)
00548                    WHERE `glpi_notifications`.`itemtype` = 'Ticket'
00549                          AND `glpi_notifications`.`mode` = 'mail'
00550                          AND `glpi_notificationtargets`.`type` = '".Notification::USER_TYPE."'
00551                          AND `glpi_notificationtargets`.`items_id` = '".Notification::AUTHOR."'";
00552 
00553          if ($result = $DB->query($query)) {
00554             if ($DB->result($result,0,0) > 0) {
00555                return true;
00556             }
00557          }
00558       }
00559       return false;
00560    }
00561 
00562 
00563    function getTags() {
00564 
00565       parent::getTags();
00566 
00567       //Locales
00568       $tags = array('ticket.type'                  => __('Type'),
00569                     'ticket.sla'                   => __('SLA'),
00570                     'ticket.requesttype'           => __('Request source'),
00571                     'ticket.itemtype'              => __('Item type'),
00572                     'ticket.item.name'             => __('Associated item'),
00573                     'ticket.item.serial'           => __('Serial number'),
00574                     'ticket.item.otherserial'      => __('Inventory number'),
00575                     'ticket.item.location'         => __('Location'),
00576                     'ticket.item.model'            => __('Model'),
00577                     'ticket.item.contact'          => __('Alternate username'),
00578                     'ticket.item.contactnumber'    => __('Alternate username number'),
00579                     'ticket.item.user'             => __('User'),
00580                     'ticket.item.group'            => __('Group'),
00581                     'ticket.costtime'              => __('Time cost'),
00582                     'ticket.costfixed'             => __('Fixed cost'),
00583                     'ticket.costmaterial'          => __('Material cost'),
00584                     'ticket.isdeleted'             => __('Deleted'),
00585                     'task.author'                  => __('Writer'),
00586                     'task.isprivate'               => __('Private'),
00587                     'task.date'                    => __('Opening date'),
00588                     'task.description'             => __('Description'),
00589                     'task.category'                => __('Category'),
00590                     'task.time'                    => __('Total duration'),
00591                     'task.user'                    => __('By'),
00592                     'task.begin'                   => __('Start date'),
00593                     'task.end'                     => __('End date'),
00594                     'task.status'                  => __('Status'),
00595                     'followup.date'                => __('Opening date'),
00596                     'followup.isprivate'           => __('Private'),
00597                     'followup.author'              => __('Writer'),
00598                     'followup.description'         => __('Description'),
00599                     'followup.requesttype'         => __('Request source'),
00600                     'ticket.numberoffollowups'     => __('Number of followups'),
00601                     'ticket.numberoftasks'         => __('Number of tasks'),
00602                     'ticket.numberoflinkedtickets' => __('Number of linked tickets'),
00603                     'ticket.numberofproblems'      => __('Number of problems'),
00604                     'ticket.autoclose'             => __('Automatic closing of solved tickets after'),
00605                     'ticket.globalvalidation'      => __('Global approval status'),
00606                   );
00607 
00608       foreach ($tags as $tag => $label) {
00609          $this->addTagToList(array('tag'    => $tag,
00610                                    'label'  => $label,
00611                                    'value'  => true,
00612                                    'events' => NotificationTarget::TAG_FOR_ALL_EVENTS));
00613       }
00614 
00615      //Events specific for validation
00616      $tags = array('validation.author'            => __('Requester'),
00617                    'validation.status'            => __('Status of the approval request'),
00618                    'validation.submissiondate'    => sprintf(__('%1$s: %2$s'), __('Request'),
00619                                                              __('Date')),
00620                    'validation.commentsubmission' => sprintf(__('%1$s: %2$s'), __('Request'),
00621                                                              __('Comments')),
00622                    'validation.validationdate'    => sprintf(__('%1$s: %2$s'), __('Validation'),
00623                                                              __('Date')),
00624                    'validation.validator'         => __('Decision-maker'),
00625                    'validation.commentvalidation' => sprintf(__('%1$s: %2$s'), __('Validation'),
00626                                                              __('Comments'))
00627                    );
00628 
00629       foreach ($tags as $tag => $label) {
00630          $this->addTagToList(array('tag'    => $tag,
00631                                    'label'  => $label,
00632                                    'value'  => true,
00633                                    'events' => array('validation', 'validation_answer')));
00634       }
00635       //Tags without lang for validation
00636       $tags = array('validation.submission.title' => __('A validation request has been submitted'),
00637                     'validation.answer.title'     => __('An answer to a validation request was produced')
00638                     );
00639 
00640       foreach ($tags as $tag => $label) {
00641          $this->addTagToList(array('tag'   => $tag,
00642                                    'label' => $label,
00643                                    'value' => true,
00644                                    'lang'  => false,
00645                                    'events' => array('validation', 'validation_answer')));
00646       }
00647 
00648 
00649 
00650       // Events for ticket satisfaction
00651       $tags = array('satisfaction.datebegin'           => __('Creation date of the satisfaction survey'),
00652                     'satisfaction.dateanswered'        => __('Response date to the satisfaction survey'),
00653                     'satisfaction.satisfaction'        => __('Satisfaction'),
00654                     'satisfaction.description'         => __('Comments to the satisfaction survey'));
00655 
00656       foreach ($tags as $tag => $label) {
00657          $this->addTagToList(array('tag'    => $tag,
00658                                    'label'  => $label,
00659                                    'value'  => true,
00660                                    'events' => array('satisfaction')));
00661       }
00662 
00663       $tags = array('satisfaction.type'  => __('Survey type'),);
00664 
00665       foreach ($tags as $tag => $label) {
00666          $this->addTagToList(array('tag'    => $tag,
00667                                    'label'  => $label,
00668                                    'value'  => true,
00669                                    'lang'   => false,
00670                                    'events' => array('satisfaction')));
00671       }
00672 
00673       $tags = array('satisfaction.text' => __('Invitation to fill out the survey'));
00674 
00675       foreach ($tags as $tag => $label) {
00676          $this->addTagToList(array('tag'    => $tag,
00677                                    'label'  => $label,
00678                                    'value'  => false,
00679                                    'lang'   => true,
00680                                    'events' => array('satisfaction')));
00681       }
00682 
00683      //Foreach global tags
00684      $tags = array('followups'     => _n('Followup', 'Followups', 2),
00685                    'tasks'         => _n('Task', 'Tasks', 2),
00686                    'validations'   => _n('Validation','Validations',2),
00687                    'linkedtickets' => _n('Linked ticket', 'Linked tickets', 2),
00688                    'problems'      => _n('Problem', 'Problems', 2));
00689 
00690       foreach ($tags as $tag => $label) {
00691          $this->addTagToList(array('tag'     => $tag,
00692                                    'label'   => $label,
00693                                    'value'   => false,
00694                                    'foreach' => true));
00695       }
00696 
00697 
00698       //Tags with just lang
00699       $tags = array('ticket.linkedtickets'    => _n('Linked ticket', 'Linked tickets', 2),
00700                     'ticket.problems'         => _n('Problem', 'Problems', 2),
00701                     'ticket.autoclosewarning'
00702                      => sprintf(_n('Without a reply, the ticket will be automatically closed after %s day',
00703                                    'Without a reply, the ticket will be automatically closed after %s days',
00704                                    2),
00705                                 '?'));
00706 
00707       foreach ($tags as $tag => $label) {
00708          $this->addTagToList(array('tag'   => $tag,
00709                                    'label' => $label,
00710                                    'value' => false,
00711                                    'lang'  => true));
00712       }
00713 
00714 
00715       //Foreach tag for alertnotclosed
00716       $this->addTagToList(array('tag'     => 'tickets',
00717                                 'label'   => __('Not solved tickets'),
00718                                 'value'   => false,
00719                                 'foreach' => true,
00720                                 'events'  => array('alertnotclosed')));
00721 
00722       //Tags without lang
00723       $tags = array('ticket.urlvalidation'    => sprintf(__('%1$s: %2$s'), __('Validation request'),
00724                                                          __('URL')),
00725                     'ticket.urlsatisfaction'  => sprintf(__('%1$s: %2$s'), __('Satisfaction'),
00726                                                          __('URL')),
00727                     'linkedticket.id'         => sprintf(__('%1$s: %2$s'),
00728                                                          _n('Linked ticket', 'Linked tickets', 1),
00729                                                          __('ID')),
00730                     'linkedticket.link'       => sprintf(__('%1$s: %2$s'),
00731                                                          _n('Linked ticket', 'Linked tickets', 1),
00732                                                          __('Link')),
00733                     'linkedticket.url'        => sprintf(__('%1$s: %2$s'),
00734                                                          _n('Linked ticket', 'Linked tickets', 1),
00735                                                          __('URL')),
00736                     'linkedticket.title'      => sprintf(__('%1$s: %2$s'),
00737                                                          _n('Linked ticket', 'Linked tickets', 1),
00738                                                          __('Title')),
00739                     'linkedticket.content'    => sprintf(__('%1$s: %2$s'),
00740                                                          _n('Linked ticket', 'Linked tickets', 1),
00741                                                          __('Description')),
00742                     'problem.id'              => sprintf(__('%1$s: %2$s'), __('Problem'), __('ID')),
00743                     'problem.date'            => sprintf(__('%1$s: %2$s'), __('Problem'), __('Date')),
00744                     'problem.url'             => sprintf(__('%1$s: %2$s'), __('Problem'), ('URL')),
00745                     'problem.title'           => sprintf(__('%1$s: %2$s'), __('Problem'),
00746                                                          __('Title')),
00747                     'problem.content'         => sprintf(__('%1$s: %2$s'), __('Problem'),
00748                                                          __('Description'))
00749                    );
00750 
00751       foreach ($tags as $tag => $label) {
00752          $this->addTagToList(array('tag'   => $tag,
00753                                    'label' => $label,
00754                                    'value' => true,
00755                                    'lang'  => false));
00756       }
00757 
00758       //Tickets with a fixed set of values
00759       $allowed_validation = array();
00760       $status = TicketValidation::getAllStatusArray(false,true);
00761       foreach ($status as $key => $value) {
00762          $allowed_validation[] = $key;
00763       }
00764 
00765       $tags = array('validation.validationstatus'
00766                      => array('text'           => __('Status value in database'),
00767                               'allowed_values' => $allowed_validation));
00768 
00769       foreach ($tags as $tag => $label) {
00770          $this->addTagToList(array('tag'            => $tag,
00771                                    'label'          => $label['text'],
00772                                    'value'          => true,
00773                                    'lang'           => false,
00774                                    'allowed_values' => $label['allowed_values']));
00775       }
00776 
00777       asort($this->tag_descriptions);
00778    }
00779 
00780 }
00781 ?>