$language = new NotificationTemplateTranslation();
if (isset($_POST["add"])) {
    $language->check(-1, CREATE, $_POST);
    $newID = $language->add($_POST);
    Event::log($newID, "notificationtemplatetranslations", 4, "notification", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["language"]));
    Html::back();
} else {
    if (isset($_POST["purge"])) {
        $language->check($_POST["id"], PURGE);
        $language->delete($_POST, 1);
        Event::log($_POST["id"], "notificationtemplatetranslations", 4, "notification", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        $language->redirectToList();
    } else {
        if (isset($_POST["update"])) {
            $language->check($_POST["id"], UPDATE);
            $language->update($_POST);
            Event::log($_POST["id"], "notificationtemplatetranslations", 4, "notification", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
            Html::back();
        } else {
            Html::header(NotificationTemplate::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "notification", "notificationtemplate");
            if ($_GET["id"] == '') {
                $options = array("notificationtemplates_id" => $_GET["notificationtemplates_id"]);
            } else {
                $options = array();
            }
            $options['id'] = $_GET["id"];
            $language->display($options);
            Html::footer();
        }
    }
}
Ejemplo n.º 2
0
Copyright (C) 2003-2014 by the INDEPNET Development Team.

http://indepnet.net/   http://glpi-project.org
-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI 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.

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';
Session::checkRight("config", "r");
Html::header(NotificationTemplate::getTypeName(2), $_SERVER['PHP_SELF'], "config", "mailing", "notificationtemplate");
Search::show('NotificationTemplate');
Html::footer();
 /**
  * @param $template        NotificationTemplate object
  * @param $options   array
  **/
 function showSummary(NotificationTemplate $template, $options = array())
 {
     global $DB, $CFG_GLPI;
     $nID = $template->getField('id');
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<div class='center'>" . "<a class='vsubmit' href='" . Toolbox::getItemTypeFormURL('NotificationTemplateTranslation') . "?notificationtemplates_id=" . $nID . "'>" . __('Add a new translation') . "</a></div><br>";
     }
     echo "<div class='center' id='tabsbody'>";
     Session::initNavigateListItems('NotificationTemplateTranslation', sprintf(__('%1$s = %2$s'), NotificationTemplate::getTypeName(1), $template->getName()));
     if ($canedit) {
         $rand = mt_rand();
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     if ($canedit) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Language') . "</th></tr>";
     foreach ($DB->request('glpi_notificationtemplatetranslations', array('notificationtemplates_id' => $nID)) as $data) {
         if ($this->getFromDB($data['id'])) {
             Session::addToNavigateListItems('NotificationTemplateTranslation', $data['id']);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td class='center'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>";
             echo "<a href='" . Toolbox::getItemTypeFormURL('NotificationTemplateTranslation') . "?id=" . $data['id'] . "&amp;notificationtemplates_id=" . $nID . "'>";
             if ($data['language'] != '') {
                 echo $CFG_GLPI['languages'][$data['language']][0];
             } else {
                 _e('Default translation');
             }
             echo "</a></td></tr>";
         }
     }
     echo "</table>";
     if ($canedit) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Ejemplo n.º 4
0
 /**
  * Display notification registered for a group
  *
  * @since version 0.83
  *
  * @param $group Group object
  *
  * @return nothing
  **/
 static function showForGroup(Group $group)
 {
     global $DB;
     if (!Notification::canView()) {
         return false;
     }
     $sql = "SELECT `glpi_notifications`.`id`\n              FROM `glpi_notificationtargets`\n              INNER JOIN `glpi_notifications`\n                    ON (`glpi_notifications`.`id` = `glpi_notificationtargets`.`notifications_id`)\n              WHERE `items_id` = '" . $group->getID() . "'\n                    AND (`type` = '" . Notification::SUPERVISOR_GROUP_TYPE . "'\n                         OR `type` = '" . Notification::GROUP_TYPE . "') " . getEntitiesRestrictRequest('AND', 'glpi_notifications', '', '', true);
     $req = $DB->request($sql);
     echo "<table class='tab_cadre_fixe'>";
     if ($req->numrows()) {
         echo "<tr><th>" . __('Name') . "</th>";
         echo "<th>" . Entity::getTypeName(1) . "</th>";
         echo "<th>" . __('Active') . "</th>";
         echo "<th>" . __('Type') . "</th>";
         echo "<th>" . __('Notification method') . "</th>";
         echo "<th>" . NotificationEvent::getTypeName(1) . "</th>";
         echo "<th>" . NotificationTemplate::getTypeName(1) . "</th></tr>";
         $notif = new Notification();
         Session::initNavigateListItems('Notification', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName()));
         foreach ($req as $data) {
             Session::addToNavigateListItems('Notification', $data['id']);
             if ($notif->getFromDB($data['id'])) {
                 echo "<tr class='tab_bg_2'><td>" . $notif->getLink();
                 echo "</td><td>" . Dropdown::getDropdownName('glpi_entities', $notif->getEntityID());
                 echo "</td><td>" . Dropdown::getYesNo($notif->getField('is_active')) . "</td><td>";
                 $itemtype = $notif->getField('itemtype');
                 if ($tmp = getItemForItemtype($itemtype)) {
                     echo $tmp->getTypeName(1);
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td><td>" . Notification::getMode($notif->getField('mode'));
                 echo "</td><td>" . NotificationEvent::getEventName($itemtype, $notif->getField('event'));
                 echo "</td>" . "<td>" . Dropdown::getDropdownName('glpi_notificationtemplates', $notif->getField('notificationtemplates_id'));
                 echo "</td></tr>";
             }
         }
     } else {
         echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>";
     }
     echo "</table>";
 }
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='6' class='middle right'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='6'><textarea cols='45' rows='9' class='form-control' name='comment' >" . $this->fields["comment"] . "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Type') . "</td>";
     echo "<td>";
     if (!Session::haveRight(static::$rightname, UPDATE)) {
         $itemtype = $this->fields['itemtype'];
         echo $itemtype::getTypeName(1);
         $rand = '';
     } else {
         if (Config::canUpdate() && $this->getEntityID() == 0) {
             $rand = Dropdown::showItemTypes('itemtype', $CFG_GLPI["notificationtemplates_types"], array('value' => $this->fields['itemtype']));
         } else {
             $rand = Dropdown::showItemTypes('itemtype', array_diff($CFG_GLPI["notificationtemplates_types"], array('Crontask', 'DBConnection', 'User')), array('value' => $this->fields['itemtype']));
         }
     }
     $params = array('itemtype' => '__VALUE__');
     Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_events", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationEvent.php", $params);
     Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_templates", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationTemplate.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Notification method') . "</td>";
     echo "<td>";
     self::dropdownMode(array('value' => $this->fields['mode']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . NotificationEvent::getTypeName(1) . "</td>";
     echo "<td><span id='show_events'>";
     NotificationEvent::dropdownEvents($this->fields['itemtype'], array('value' => $this->fields['event']));
     echo "</span></td></tr>";
     echo "<tr class='tab_bg_1'><td>" . NotificationTemplate::getTypeName(1) . "</td>";
     echo "<td><span id='show_templates'>";
     NotificationTemplate::dropdownTemplates('notificationtemplates_id', $this->fields['itemtype'], $this->fields['notificationtemplates_id']);
     echo "</span></td></tr>";
     $this->showFormButtons($options);
     return true;
 }
 function showSummary(NotificationTemplate $template, $options = array())
 {
     global $DB, $LANG, $CFG_GLPI;
     $nID = $template->getField('id');
     $canedit = haveRight("config", "w");
     if ($canedit) {
         echo "<div class='center'>" . "<a href='" . getItemTypeFormURL('NotificationTemplateTranslation') . "?notificationtemplates_id=" . $nID . "'>" . $LANG['mailing'][124] . "</a></div><br>";
     }
     echo "<div class='center' id='tabsbody'>";
     initNavigateListItems('NotificationTemplateTranslation', $template->getTypeName() . " = " . $template->fields["name"]);
     echo "<form name='form_language' id='form_language' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th></th><th>" . $LANG['setup'][41] . "</th></tr>";
     foreach ($DB->request('glpi_notificationtemplatetranslations', array('notificationtemplates_id' => $nID)) as $data) {
         if ($this->getFromDB($data['id'])) {
             addToNavigateListItems('NotificationTemplateTranslation', $data['id']);
             echo "<tr class='tab_bg_1'><td class='center'>";
             echo "<input type='checkbox' name=\"languages[" . $data['id'] . "]\"></td>";
             echo "<td class='center'>";
             echo "<a href='" . getItemTypeFormURL('NotificationTemplateTranslation') . "?id=" . $data['id'] . "&notificationtemplates_id=" . $nID . "'>";
             if ($data['language'] != '') {
                 echo $CFG_GLPI['languages'][$data['language']][0];
             } else {
                 echo $LANG['mailing'][125];
             }
             echo "</a></td></tr>";
         }
     }
     echo "</table>";
     if ($canedit) {
         openArrowMassive("form_language", true);
         closeArrowMassive("delete_languages", $LANG["buttons"][6]);
     }
 }