notificationtargetinfocom.class.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * @version $Id: notificationtargetinfocom.class.php 20129 2013-02-04 16:53:59Z 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 NotificationTargetInfocom extends NotificationTarget {
00040 
00041 
00042    function getEvents() {
00043       return array('alert' => __('Alarms on financial and administrative information'));
00044    }
00045 
00046 
00047    /**
00048     * Get all data needed for template processing
00049     *
00050     * @param $event
00051     * @param $options   array
00052    **/
00053    function getDatasForTemplate($event, $options=array()) {
00054       global $CFG_GLPI;
00055 
00056       $events                                 = $this->getAllEvents();
00057 
00058       $this->datas['##infocom.entity##']      = Dropdown::getDropdownName('glpi_entities',
00059                                                                           $options['entities_id']);
00060       $this->datas['##infocom.action##']      = $events[$event];
00061 
00062       foreach ($options['items'] as $id => $item) {
00063          $tmp                                = array();
00064          if ($obj = getItemForItemtype($item['itemtype'])) {
00065             $tmp['##infocom.itemtype##']       = $obj->getTypeName(1);
00066             $tmp['##infocom.item##']           = $item['item_name'];
00067             $tmp['##infocom.expirationdate##'] = $item['warrantyexpiration'];
00068             $tmp['##infocom.url##']            = urldecode($CFG_GLPI["url_base"].
00069                                                            "/index.php?redirect=".
00070                                                            strtolower($item['itemtype'])."_".
00071                                                            $item['items_id']."_Infocom");
00072          }
00073          $this->datas['infocoms'][] = $tmp;
00074       }
00075 
00076       $this->getTags();
00077       foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
00078          if (!isset($this->datas[$tag])) {
00079             $this->datas[$tag] = $values['label'];
00080          }
00081       }
00082    }
00083 
00084 
00085    function getTags() {
00086 
00087       $tags = array('infocom.action'         => _n('Event', 'Events', 1),
00088                     'infocom.itemtype'       => __('Item type'),
00089                     'infocom.item'           => __('Associated item'),
00090                     'infocom.expirationdate' => __('Expiration date'),
00091                     'infocom.entity'         => __('Entity'));
00092 
00093       foreach ($tags as $tag => $label) {
00094          $this->addTagToList(array('tag'   => $tag,
00095                                    'label' => $label,
00096                                    'value' => true));
00097       }
00098 
00099       $this->addTagToList(array('tag'     => 'items',
00100                                 'label'   => __('Device list'),
00101                                 'value'   => false,
00102                                 'foreach' => true));
00103 
00104       asort($this->tag_descriptions);
00105    }
00106 
00107 }
00108 ?>