/**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     if ($profile->getField('interface') == 'central') {
         $rights = $this->getAllRights();
         $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Helpdesk') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_racks_open_ticket'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Associable items to a ticket') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_racks_open_ticket', 'checked' => $effective_rights['plugin_racks_open_ticket']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = array(array('itemtype' => 'PluginAddressingAddressing', 'label' => __('Generate reports', 'addressing'), 'field' => 'plugin_addressing'));
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_addressing_use_ping_in_equipment'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Use ping on equipment form', 'addressing') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_addressing_use_ping_in_equipment[1_0]', 'checked' => $effective_rights['plugin_addressing_use_ping_in_equipment']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 function getAdditionalFields()
 {
     $tab = array(array('name' => $this->getForeignKeyField(), 'label' => __('As child of'), 'type' => 'parent', 'list' => false), array('name' => 'users_id', 'label' => __('Technician in charge of the hardware'), 'type' => 'UserDropdown', 'right' => 'own_ticket', 'list' => true), array('name' => 'groups_id', 'label' => __('Group in charge of the hardware'), 'type' => 'dropdownValue', 'condition' => '`is_assign`', 'list' => true), array('name' => 'knowbaseitemcategories_id', 'label' => __('Knowledge base'), 'type' => 'dropdownValue', 'list' => true), array('name' => 'is_helpdeskvisible', 'label' => __('Visible in the simplified interface'), 'type' => 'bool', 'list' => true), array('name' => 'is_incident', 'label' => __('Visible for an incident'), 'type' => 'bool', 'list' => true), array('name' => 'is_request', 'label' => __('Visible for a request'), 'type' => 'bool', 'list' => true), array('name' => 'is_problem', 'label' => __('Visible for a problem'), 'type' => 'bool', 'list' => true), array('name' => 'is_change', 'label' => __('Visible for a change'), 'type' => 'bool', 'list' => true), array('name' => 'tickettemplates_id_demand', 'label' => __('Template for a request'), 'type' => 'dropdownValue', 'list' => true), array('name' => 'tickettemplates_id_incident', 'label' => __('Template for an incident'), 'type' => 'dropdownValue', 'list' => true));
     if (!Session::haveRightsOr('problem', array(CREATE, UPDATE, DELETE, Problem::READALL, Problem::READMY))) {
         unset($tab[7]);
     }
     return $tab;
 }
 /**
  * Fonction native GLPI
  * @param CommonGLPI $item
  * @param int $tabnum
  * @param int $withtemplate
  * @return boolean
  */
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if ($item->getType() == 'Computer' || $item->getType() == 'Monitor') {
         if (Session::haveRightsOr('plugin_reforme_reforme', array(CREATE))) {
             $reforme = new self();
             $ID = $item->getField('id');
             $Name = $item->getField('name');
             // j'affiche le formulaire
             $reforme->showForm($ID, $item->getType());
         }
     }
 }
 /**
  * Is the current user have right to show the current task ?
  *
  * @return boolean
  **/
 function canViewItem()
 {
     if (!parent::canReadITILItem()) {
         return false;
     }
     if (Session::haveRightsOr(self::$rightname, array(self::SEEPRIVATE, self::SEEPUBLIC))) {
         return true;
     }
     if (!$this->fields['is_private'] && Session::haveRight(self::$rightname, self::SEEPUBLIC)) {
         return true;
     }
     if ($this->fields["users_id"] === Session::getLoginUserID()) {
         return true;
     }
     return false;
 }
 /**
  * @param $prof   Profile object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB;
     $canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE));
     if ($canedit) {
         echo "<form method='post' action='" . $prof->getFormURL() . "'>";
     }
     $rights = self::getAllRights();
     $prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Rights management by profil', 'reports')));
     if ($canedit) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $prof->getField('id')));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     $profile = new Profile();
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile->getFromDB($profiles_id);
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Reforme', 'reforme')));
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         echo Html::closeForm(false);
     }
     echo "</div>";
 }
Example #8
0
 /**
  * Is the current user have right to show the current task ?
  *
  * @return boolean
  **/
 function canViewItem()
 {
     if (!parent::canReadITILItem()) {
         return false;
     }
     if (Session::haveRightsOr(self::$rightname, array(parent::SEEPRIVATE, parent::SEEPUBLIC))) {
         return true;
     }
     if (!$this->fields['is_private'] && Session::haveRight(self::$rightname, parent::SEEPUBLIC)) {
         return true;
     }
     // see task created or affected to me
     if ($this->fields["users_id"] === Session::getLoginUserID() || $this->fields["users_id_tech"] === Session::getLoginUserID()) {
         return true;
     }
     if ($this->fields["groups_id_tech"] && $this->fields["groups_id_tech"] > 0 && isset($_SESSION["glpigroups"]) && in_array($this->fields["groups_id_tech"], $_SESSION["glpigroups"])) {
         return true;
     }
     return false;
 }
Example #9
0
function plugin_init_timelineticket()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['timelineticket'] = true;
    $Plugin = new Plugin();
    if ($Plugin->isActivated('timelineticket')) {
        // check if plugin is active
        $PLUGIN_HOOKS['change_profile']['timelineticket'] = array('PluginTimelineticketProfile', 'initProfile');
        Plugin::registerClass('PluginTimelineticketProfile', array('addtabon' => 'Profile'));
        if (Session::haveRightsOr('plugin_timelineticket_ticket', array(READ, UPDATE))) {
            Plugin::registerClass('PluginTimelineticketDisplay', array('addtabon' => array('Ticket')));
        }
        $PLUGIN_HOOKS['item_purge']['timelineticket'] = array('Ticket' => 'plugin_timelineticket_ticket_purge', 'Group_Ticket' => array('PluginTimelineticketAssignGroup', 'deleteGroupTicket'), 'Ticket_User' => array('PluginTimelineticketAssignUser', 'deleteUserTicket'));
        $PLUGIN_HOOKS['item_add']['timelineticket'] = array('Ticket' => 'plugin_timelineticket_ticket_add', 'Group_Ticket' => array('PluginTimelineticketAssignGroup', 'addGroupTicket'), 'Ticket_User' => array('PluginTimelineticketAssignUser', 'addUserTicket'));
        $PLUGIN_HOOKS['item_update']['timelineticket'] = array('Ticket' => 'plugin_timelineticket_ticket_update');
        if (Session::haveRight("config", UPDATE) || Session::haveRight('plugin_timelineticket_ticket', UPDATE)) {
            // Config page
            $PLUGIN_HOOKS['config_page']['timelineticket'] = 'front/config.form.php';
        }
    }
}
Example #10
0
 static function isAvailable()
 {
     global $CFG_GLPI;
     // Cache in session
     if (isset($_SESSION['glpiplanningreminder_isavailable'])) {
         return $_SESSION['glpiplanningreminder_isavailable'];
     }
     $_SESSION['glpiplanningreminder_isavailable'] = 0;
     if ($CFG_GLPI["use_mailing"]) {
         $task = new Crontask();
         if ($task->getFromDBbyName('PlanningRecall', 'planningrecall')) {
             // Only disabled by config
             if ($task->isDisabled() != 1) {
                 if (Session::haveRightsOr("planning", array(Planning::READMY, Planning::READGROUP), Planning::READALL)) {
                     $_SESSION['glpiplanningreminder_isavailable'] = 1;
                 }
             }
         }
     }
     return $_SESSION['glpiplanningreminder_isavailable'];
 }
Example #11
0
 static function canView()
 {
     return Session::haveRightsOr(self::$rightname, array(self::READALL, self::READMY));
 }
 /**
  * Show the current ticketfollowup summary
  *
  * @param $ticket Ticket object
  **/
 function showSummary($ticket)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRightsOr(self::$rightname, array(self::SEEPUBLIC, self::SEEPRIVATE))) {
         return false;
     }
     $tID = $ticket->fields['id'];
     // Display existing Followups
     $showprivate = Session::haveRight(self::$rightname, self::SEEPRIVATE);
     $caneditall = Session::haveRight(self::$rightname, self::UPDATEALL);
     $tmp = array('tickets_id' => $tID);
     $canadd = $this->can(-1, CREATE, $tmp);
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $techs = $ticket->getAllUsers(CommonITILActor::ASSIGN);
     $reopen_case = false;
     if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray()) && $ticket->isAllowedStatus($ticket->fields['status'], Ticket::INCOMING)) {
         $reopen_case = true;
     }
     $tech = Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
     $RESTRICT = "";
     if (!$showprivate) {
         $RESTRICT = " AND (`is_private` = '0'\n                            OR `users_id` ='" . Session::getLoginUserID() . "') ";
     }
     $query = "SELECT `glpi_ticketfollowups`.*, `glpi_users`.`picture`\n                FROM `glpi_ticketfollowups`\n                LEFT JOIN `glpi_users` ON (`glpi_ticketfollowups`.`users_id` = `glpi_users`.`id`)\n                WHERE `tickets_id` = '{$tID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     $rand = mt_rand();
     if ($caneditall || $canadd) {
         echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
     }
     if ($canadd) {
         echo "<script type='text/javascript' >\n";
         echo "function viewAddFollowup" . $ticket->fields['id'] . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo Html::jsHide('addbutton' . $ticket->fields['id'] . "{$rand}");
         echo "};";
         echo "</script>\n";
         // Not closed ticket or closed
         if (!in_array($ticket->fields["status"], array_merge($ticket->getSolvedStatusArray(), $ticket->getClosedStatusArray())) || $reopen_case) {
             if (isset($_GET['_openfollowup']) && $_GET['_openfollowup']) {
                 echo Html::scriptBlock("viewAddFollowup" . $ticket->fields['id'] . "{$rand}()");
             } else {
                 echo "<div id='addbutton" . $ticket->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddFollowup" . $ticket->fields['id'] . "{$rand}();'>";
                 if ($reopen_case) {
                     _e('Reopen the ticket');
                 } else {
                     _e('Add a new followup');
                 }
                 echo "</a></div>\n";
             }
         }
     }
     if ($DB->numrows($result) == 0) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
         echo "<th class='b'>" . __('No followup for this ticket.') . "</th></tr></table>";
     } else {
         $today = strtotime('today');
         $lastmonday = strtotime('last monday');
         $lastlastmonday = strtotime('last monday', strtotime('last monday'));
         // Case of monday
         if ($today - $lastmonday == 7 * DAY_TIMESTAMP) {
             $lastlastmonday = $lastmonday;
             $lastmonday = $today;
         }
         $steps = array(0 => array('end' => $today, 'name' => __('Today')), 1 => array('end' => $lastmonday, 'name' => __('This week')), 2 => array('end' => $lastlastmonday, 'name' => __('Last week')), 3 => array('end' => strtotime('midnight first day of'), 'name' => __('This month')), 4 => array('end' => strtotime('midnight first day of last month'), 'name' => __('Last month')), 5 => array('end' => 0, 'name' => __('Before the last month')));
         $currentpos = -1;
         while ($data = $DB->fetch_assoc($result)) {
             $this->getFromDB($data['id']);
             $candelete = $this->canPurge() && $this->canPurgeItem();
             $canedit = $this->canUpdate() && $this->canUpdateItem();
             $time = strtotime($data['date']);
             if (!isset($steps[$currentpos]) || $steps[$currentpos]['end'] > $time) {
                 $currentpos++;
                 while ($steps[$currentpos]['end'] > $time && isset($steps[$currentpos + 1])) {
                     $currentpos++;
                 }
                 if (isset($steps[$currentpos])) {
                     echo "<h3>" . $steps[$currentpos]['name'] . "</h3>";
                 }
             }
             $id = 'followup' . $data['id'] . $rand;
             $color = 'byuser';
             if (isset($techs[$data['users_id']])) {
                 $color = 'bytech';
             }
             $classtoadd = '';
             if ($canedit) {
                 $classtoadd = " pointer";
             }
             echo "<div class='boxnote {$color}' id='view{$id}'";
             echo ">";
             echo "<div class='boxnoteleft'>";
             echo "<img class='user_picture_verysmall' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($data['picture']) . "'>";
             echo "</div>";
             // boxnoteleft
             echo "<div class='boxnotecontent'";
             echo ">";
             echo "<div class='boxnotefloatleft'>";
             $username = NOT_AVAILABLE;
             if ($data['users_id']) {
                 $username = getUserName($data['users_id'], $showuserlink);
             }
             $name = sprintf(__('Create by %1$s on %2$s'), $username, Html::convDateTime($data['date']));
             if ($data['requesttypes_id']) {
                 $name = sprintf(__('%1$s - %2$s'), $name, Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']));
             }
             if ($showprivate && $data["is_private"]) {
                 $name = sprintf(__('%1$s - %2$s'), $name, __('Private'));
             }
             echo $name;
             echo "</div>";
             // floatright
             echo "<div class='boxnotetext {$classtoadd}'";
             if ($canedit) {
                 echo " onClick=\"viewEditFollowup" . $ticket->fields['id'] . $data['id'] . "{$rand}(); " . Html::jsHide("view{$id}") . " " . Html::jsShow("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}") . "\" ";
             }
             echo ">";
             $content = nl2br($data['content']);
             if (empty($content)) {
                 $content = NOT_AVAILABLE;
             }
             echo $content . '</div>';
             // boxnotetext
             echo "</div>";
             // boxnotecontent
             echo "<div class='boxnoteright'>";
             if ($candelete) {
                 Html::showSimpleForm(Toolbox::getItemTypeFormURL('TicketFollowup'), array('purge' => 'purge'), _x('button', 'Delete permanently'), array('id' => $data['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png", '', __('Confirm the final deletion?'));
             }
             echo "</div>";
             // boxnoteright
             echo "</div>";
             // boxnote
             if ($canedit) {
                 echo "<div id='viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}' class='starthidden'></div>\n";
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditFollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $data["tickets_id"], 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
         }
     }
 }
 /**
  * Form to add a solution to an ITIL object
  *
  * @param $knowbase_id_toload integer  load a kb article as solution (0 = no load by default)
  *                                     (default 0)
  **/
 function showSolutionForm($knowbase_id_toload = 0)
 {
     global $CFG_GLPI;
     $this->check($this->getField('id'), READ);
     $canedit = $this->canSolve();
     $options = array();
     if ($knowbase_id_toload > 0) {
         $kb = new KnowbaseItem();
         if ($kb->getFromDB($knowbase_id_toload)) {
             $this->fields['solution'] = $kb->getField('answer');
         }
     }
     // Alert if validation waiting
     $validationtype = $this->getType() . 'Validation';
     if (method_exists($validationtype, 'alertValidation')) {
         $validationtype::alertValidation($this, 'solution');
     }
     $this->showFormHeader($options);
     $show_template = $canedit;
     //                        && $this->getField('solutiontypes_id') == 0
     //                        && empty($this->fields['solution']);
     $rand_template = mt_rand();
     $rand_text = $rand_type = 0;
     if ($canedit) {
         $rand_text = mt_rand();
         $rand_type = mt_rand();
     }
     if ($show_template) {
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . _n('Solution template', 'Solution templates', 1) . "</td><td>";
         SolutionTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type))));
         echo "</td><td colspan='2'>";
         if (Session::haveRightsOr('knowbase', array(READ, KnowbaseItem::READFAQ))) {
             echo "<a class='vsubmit' title=\"" . __s('Search a solution') . "\"\n                   href='" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.php?item_itemtype=" . $this->getType() . "&amp;item_items_id=" . $this->getField('id') . "&amp;forcetab=Knowbase\$1'>" . __('Search a solution') . "</a>";
         }
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Solution type') . "</td><td>";
     $current = $this->fields['status'];
     // Settings a solution will set status to solved
     if ($canedit) {
         SolutionType::dropdown(array('value' => $this->getField('solutiontypes_id'), 'rand' => $rand_type, 'entity' => $this->getEntityID()));
     } else {
         echo Dropdown::getDropdownName('glpi_solutiontypes', $this->getField('solutiontypes_id'));
     }
     echo "</td><td colspan='2'>&nbsp;</td></tr>";
     if ($canedit && Session::haveRight('knowbase', UPDATE)) {
         echo "<tr class='tab_bg_2'><td>" . __('Save and add to the knowledge base') . "</td><td>";
         Dropdown::showYesNo('_sol_to_kb', false);
         echo "</td><td colspan='2'>&nbsp;</td></tr>";
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Description') . "</td><td colspan='3'>";
     if ($canedit) {
         $rand = mt_rand();
         Html::initEditorSystem("solution{$rand}");
         echo "<div id='solution{$rand_text}'>";
         echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80' class='form-control'>" . $this->getField('solution') . "</textarea></div>";
     } else {
         echo Toolbox::unclean_cross_side_scripting_deep($this->getField('solution'));
     }
     echo "</td></tr>";
     $options['candel'] = false;
     $options['canedit'] = $canedit;
     $this->showFormButtons($options);
 }
Example #14
0
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::haveRightsOr('device', array(CREATE, UPDATE, PURGE));
Html::header(_n('Component', 'Components', 2), $_SERVER['PHP_SELF'], "config", "commondevice");
echo "<div class='center'>";
$optgroup = Dropdown::getDeviceItemTypes();
Dropdown::showItemTypeMenu(_n('Component', 'Components', 2), $optgroup);
Dropdown::showItemTypeList($optgroup);
echo "</div>";
Html::footer();
Example #15
0
 /**
  * Display for reservation
  *
  * @param $ID              ID of the reservation (empty for create new)
  * @param $options   array of possibles options:
  *     - item  reservation items ID for creation process
  *     - date date for creation process
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
         return false;
     }
     $resa = new self();
     if (!empty($ID)) {
         if (!$resa->getFromDB($ID)) {
             return false;
         }
         if (!$resa->can($ID, UPDATE)) {
             return false;
         }
         // Set item if not set
         if ((!isset($options['item']) || count($options['item']) == 0) && ($itemid = $resa->getField('reservationitems_id'))) {
             $options['item'][$itemid] = $itemid;
         }
     } else {
         $resa->getEmpty();
         $resa->fields["begin"] = $options['begin'];
         if (!isset($options['end'])) {
             $resa->fields["end"] = date("Y-m-d H:00:00", strtotime($resa->fields["begin"]) + HOUR_TIMESTAMP);
         } else {
             $resa->fields["end"] = $options['end'];
         }
     }
     // No item : problem
     if (!isset($options['item']) || count($options['item']) == 0) {
         return false;
     }
     echo "<div class='center'><form method='post' name=form action='reservation.form.php'>";
     if (!empty($ID)) {
         echo "<input type='hidden' name='id' value='{$ID}'>";
     }
     echo "<table class='tab_cadre' width='700px'>";
     echo "<tr><th colspan='2'>" . __('Reserve an item') . "</th></tr>\n";
     // Add Hardware name
     $r = new ReservationItem();
     echo "<tr class='tab_bg_1'><td>" . __('Item') . "</td>";
     echo "<td>";
     foreach ($options['item'] as $itemID) {
         $r->getFromDB($itemID);
         $type = $r->fields["itemtype"];
         $name = NOT_AVAILABLE;
         $item = NULL;
         if ($item = getItemForItemtype($r->fields["itemtype"])) {
             $type = $item->getTypeName();
             if ($item->getFromDB($r->fields["items_id"])) {
                 $name = $item->getName();
             } else {
                 $item = NULL;
             }
         }
         echo "<span class='b'>" . sprintf(__('%1$s - %2$s'), $type, $name) . "</span><br>";
         echo "<input type='hidden' name='items[{$itemID}]' value='{$itemID}'>";
     }
     echo "</td></tr>\n";
     if (!Session::haveRight("reservation", UPDATE) || is_null($item) || !Session::haveAccessToEntity($item->fields["entities_id"])) {
         echo "<input type='hidden' name='users_id' value='" . Session::getLoginUserID() . "'>";
     } else {
         echo "<tr class='tab_bg_2'><td>" . __('By') . "</td>";
         echo "<td>";
         if (empty($ID)) {
             User::dropdown(array('value' => Session::getLoginUserID(), 'entity' => $item->getEntityID(), 'right' => 'all'));
         } else {
             User::dropdown(array('value' => $resa->fields["users_id"], 'entity' => $item->getEntityID(), 'right' => 'all'));
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     $rand_begin = Html::showDateTimeField("resa[begin]", array('value' => $resa->fields["begin"], 'timestep' => -1, 'maybeempty' => false));
     echo "</td></tr>\n";
     $default_delay = floor((strtotime($resa->fields["end"]) - strtotime($resa->fields["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
     echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
     $rand = Dropdown::showTimeStamp("resa[_duration]", array('min' => 0, 'max' => 24 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $params = array('duration' => '__VALUE__', 'end' => $resa->fields["end"], 'name' => "resa[end]");
     Ajax::updateItemOnSelectEvent("dropdown_resa[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     if ($default_delay == 0) {
         $params['duration'] = 0;
         Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     }
     Alert::displayLastAlert('Reservation', $ID);
     echo "</td></tr>\n";
     if (empty($ID)) {
         echo "<tr class='tab_bg_2'><td>" . __('Rehearsal') . "</td>";
         echo "<td>";
         $values = array('' => _x('periodicity', 'None'), 'day' => _x('periodicity', 'Daily'), 'week' => _x('periodicity', 'Weekly'), 'month' => _x('periodicity', 'Monthly'));
         $rand = Dropdown::showFromArray('periodicity[type]', $values);
         $field_id = Html::cleanId("dropdown_periodicity[type]{$rand}");
         $params = array('type' => '__VALUE__', 'end' => $resa->fields["end"]);
         Ajax::updateItemOnSelectEvent($field_id, "resaperiodcontent{$rand}", $CFG_GLPI["root_doc"] . "/ajax/resaperiod.php", $params);
         echo "<br><div id='resaperiodcontent{$rand}'></div>";
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'><td>" . __('Comments') . "</td>";
     echo "<td><textarea name='comment' rows='8' cols='60'>" . $resa->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     if (empty($ID)) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='2' class='top center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
     } else {
         if ($resa->fields["users_id"] == Session::getLoginUserID() || Session::haveRightsOr(static::$rightname, array(PURGE, UPDATE))) {
             echo "<tr class='tab_bg_2'>";
             if ($resa->fields["users_id"] == Session::getLoginUserID() || Session::haveRight(static::$rightname, PURGE)) {
                 echo "<td class='top center'>";
                 echo "<input type='submit' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\"\n                      class='submit'>";
                 if ($resa->fields["group"] > 0) {
                     echo "<br><input type='checkbox' name='_delete_group'>&nbsp;" . __s('Delete all rehearsals');
                 }
                 echo "</td>";
             }
             if ($resa->fields["users_id"] == Session::getLoginUserID() || Session::haveRight(static::$rightname, UPDATE)) {
                 echo "<td class='top center'>";
                 echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n                     class='submit'>";
                 echo "</td>";
             }
             echo "</tr>\n";
         }
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
 }
Example #16
0
 /**
  * @since version 0.85
  **/
 static function canView()
 {
     global $CFG_GLPI;
     return Session::haveRightsOr(self::$rightname, array(READ, self::RESERVEANITEM));
 }
Example #17
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimelineForm($rand)
 {
     global $CFG_GLPI;
     //check global rights
     if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) {
         return false;
     }
     // javascript function for add and edit items
     echo "<script type='text/javascript' >\n";
     echo "function viewAddSubitem" . $this->fields['id'] . "{$rand}(itemtype) {\n";
     $params = array('action' => 'viewsubitem', 'type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => -1);
     if (isset($_GET['load_kb_sol'])) {
         $params['load_kb_sol'] = $_GET['load_kb_sol'];
     }
     $out = Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline.php", $params, "", false);
     echo str_replace("\"itemtype\"", "itemtype", $out);
     echo "\$('#approbation_form{$rand}').remove()";
     echo "};";
     echo "\n\n      function change_task_state(tasks_id, target) {\n         \$.post('" . $CFG_GLPI["root_doc"] . "/ajax/timeline.php',\n                {'action':     'change_task_state',\n                  'tasks_id':   tasks_id,\n                  'tickets_id': " . $this->fields['id'] . "\n                })\n                .done(function(new_state) {\n                  \$(target).removeClass('state_1 state_2')\n                           .addClass('state_'+new_state);\n                });\n      }\n\n      function viewEditSubitem" . $this->fields['id'] . "{$rand}(e, itemtype, items_id, o, domid) {\n               domid = (typeof domid === 'undefined')\n                         ? 'viewitem" . $this->fields['id'] . $rand . "'\n                         : domid;\n               var target = e.target || window.event.srcElement;\n               if (target.nodeName == 'a') return;\n               if (target.className == 'read_more_button') return;\n               \$('#'+domid).addClass('edited');\n               \$('#'+domid+' .displayed_content').hide();\n               \$('#'+domid+' .cancel_edit_item_content').show()\n                                                        .click(function() {\n                                                            \$(this).hide();\n                                                            \$('#'+domid).removeClass('edited');\n                                                            \$('#'+domid+' .edit_item_content').empty().hide();\n                                                            \$('#'+domid+' .displayed_content').show();\n                                                        });\n               \$('#'+domid+' .edit_item_content').show()\n                                                 .load('" . $CFG_GLPI["root_doc"] . "/ajax/timeline.php',\n                                                       {'action'    : 'viewsubitem',\n                                                        'type'      : itemtype,\n                                                        'parenttype': 'Ticket',\n                                                        'tickets_id': " . $this->fields['id'] . ",\n                                                        'id'        : items_id\n                                                       });\n\n\n      };";
     if (isset($_GET['load_kb_sol'])) {
         echo "viewAddSubitem" . $this->fields['id'] . "{$rand}('Solution');";
     }
     echo "</script>\n";
     //check sub-items rights
     $tmp = array('tickets_id' => $this->getID());
     $fup = new TicketFollowup();
     $ttask = new TicketTask();
     $doc = new Document();
     $canadd_fup = $fup->can(-1, CREATE, $tmp);
     $canadd_task = $ttask->can(-1, CREATE, $tmp);
     $canadd_document = $doc->can(-1, CREATE, $tmp) && $this->canAddItem('Document');
     $canadd_solution = Ticket::canUpdate() && $this->canSolve();
     if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) {
         return false;
     }
     //show choices
     echo "<h2>" . _sx('button', 'Add') . " : </h2>";
     echo "<div class='timeline_form'>";
     echo "<ul class='timeline_choices'>";
     if ($canadd_fup) {
         echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>";
     }
     if ($canadd_task) {
         echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>";
     }
     if ($canadd_document) {
         echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>";
     }
     if ($canadd_solution) {
         echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>";
     }
     echo "</ul>";
     // timeline_choices
     echo "<div class='clear'>&nbsp;</div>";
     echo "</div>";
     //end timeline_form
     echo "<div class='ajax_box' id='viewitem" . $this->fields['id'] . "{$rand}'></div>\n";
 }
Example #18
0
 /**
  * Show the User having a profile, in allowed Entity
  *
  * @param $prof Profile object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB, $CFG_GLPI;
     $ID = $prof->fields['id'];
     $canedit = Session::haveRightsOr("user", array(CREATE, UPDATE, DELETE, PURGE));
     $rand = mt_rand();
     if (!$prof->can($ID, READ)) {
         return false;
     }
     $query = "SELECT `glpi_users`.*,\n                       `glpi_profiles_users`.`entities_id` AS entity,\n                       `glpi_profiles_users`.`id` AS linkID,\n                       `glpi_profiles_users`.`is_dynamic`,\n                       `glpi_profiles_users`.`is_recursive`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_entities`.`id`=`glpi_profiles_users`.`entities_id`)\n                LEFT JOIN `glpi_users`\n                     ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`profiles_id` = '{$ID}'\n                      AND `glpi_users`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_profiles_users", 'entities_id', $_SESSION['glpiactiveentities'], true) . "\n                ORDER BY `glpi_entities`.`completename`";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'><tr>";
     echo "<th>" . sprintf(__('%1$s: %2$s'), __('Profile'), $prof->fields["name"]) . "</th></tr>\n";
     echo "<tr><th colspan='2'>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive')) . "</th></tr>";
     echo "</table>\n";
     echo "<table class='tab_cadre_fixe'>";
     $i = 0;
     $nb_per_line = 3;
     $rand = mt_rand();
     // Just to avoid IDE warning
     $canedit_entity = false;
     if ($nb) {
         $temp = -1;
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["entity"] != $temp) {
                 while ($i % $nb_per_line != 0) {
                     if ($canedit_entity) {
                         echo "<td width='10'>&nbsp;</td>";
                     }
                     echo "<td class='tab_bg_1'>&nbsp;</td>\n";
                     $i++;
                 }
                 if ($i != 0) {
                     echo "</table>";
                     echo "</div>";
                     echo "</td></tr>\n";
                 }
                 // New entity
                 $i = 0;
                 $temp = $data["entity"];
                 $canedit_entity = $canedit && in_array($temp, $_SESSION['glpiactiveentities']);
                 $rand = mt_rand();
                 echo "<tr class='tab_bg_2'>";
                 echo "<td>";
                 echo "<a href=\"javascript:showHideDiv('entity{$temp}{$rand}','imgcat{$temp}', '" . $CFG_GLPI['root_doc'] . "/pics/folder.png','" . $CFG_GLPI['root_doc'] . "/pics/folder-open.png');\">";
                 echo "<img alt='' name='imgcat{$temp}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/folder.png\">&nbsp;";
                 echo "<span class='b'>" . Dropdown::getDropdownName('glpi_entities', $data["entity"]) . "</span>";
                 echo "</a>";
                 echo "</td></tr>\n";
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<div class='center' id='entity{$temp}{$rand}' style='display:none;'>\n";
                 echo Html::checkAllAsCheckbox("entity{$temp}{$rand}") . __('All');
                 echo "<table class='tab_cadre_fixe'>\n";
             }
             if ($i % $nb_per_line == 0) {
                 if ($i != 0) {
                     echo "</tr>\n";
                 }
                 echo "<tr class='tab_bg_1'>\n";
                 $i = 0;
             }
             if ($canedit_entity) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             $username = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
             if ($data["is_dynamic"] || $data["is_recursive"]) {
                 $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
                 if ($data["is_dynamic"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, __('D'));
                 }
                 if ($data["is_dynamic"] && $data["is_recursive"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, ", ");
                 }
                 if ($data["is_recursive"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, __('R'));
                 }
                 $username = sprintf(__('%1$s%2$s'), $username, ")</span>");
             }
             echo "<td class='tab_bg_1'>" . $username . "</td>\n";
             $i++;
         }
         if ($i % $nb_per_line != 0) {
             while ($i % $nb_per_line != 0) {
                 if ($canedit_entity) {
                     echo "<td width='10'>&nbsp;</td>";
                 }
                 echo "<td class='tab_bg_1'>&nbsp;</td>";
                 $i++;
             }
         }
         if ($i != 0) {
             echo "</table>";
             echo "</div>";
             echo "</td></tr>\n";
         }
     } else {
         echo "<tr class='tab_bg_2'><td class='tab_bg_1 center'>" . __('No user found') . "</td></tr>\n";
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>\n";
 }
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';
$group = new Group();
if (!Session::haveRightsOr('group', array(CREATE, UPDATE))) {
    Session::redirectIfNotLoggedIn();
    Html::displayRightError();
}
Session::checkRight('user', User::UPDATEAUTHENT);
Html::header(__('LDAP directory link'), $_SERVER['PHP_SELF'], "admin", "group", "ldap");
if (isset($_GET['next'])) {
    AuthLdap::ldapChooseDirectory($_SERVER['PHP_SELF']);
} else {
    if (isset($_POST["change_ldap_filter"])) {
        if (isset($_POST["ldap_filter"])) {
            $_SESSION["ldap_group_filter"] = $_POST["ldap_filter"];
        }
        if (isset($_POST["ldap_filter2"])) {
            $_SESSION["ldap_group_filter2"] = $_POST["ldap_filter2"];
        }
 /**
  * Print the config form for default user prefs
  *
  * @param $data array containing datas
  * (CFG_GLPI for global config / glpi_users fields for user prefs)
  *
  * @return Nothing (display)
  **/
 function showFormUserPrefs($data = array())
 {
     global $DB, $CFG_GLPI;
     $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central";
     $userpref = false;
     $url = Toolbox::getItemTypeFormURL(__CLASS__);
     if (array_key_exists('last_login', $data)) {
         $userpref = true;
         if ($data["id"] === Session::getLoginUserID()) {
             $url = $CFG_GLPI['root_doc'] . "/front/preference.php";
         } else {
             $url = $CFG_GLPI['root_doc'] . "/front/user.form.php";
         }
     }
     echo "<form name='form' action='{$url}' method='post'>";
     // Only set id for user prefs
     if ($userpref) {
         echo "<input type='hidden' name='id' value='" . $data['id'] . "'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Personalization') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . ($userpref ? __('Language') : __('Default language')) . "</td>";
     echo "<td width='20%'>";
     if (Config::canUpdate() || !GLPI_DEMO_MODE) {
         Dropdown::showLanguages("language", array('value' => $data["language"]));
     } else {
         echo "&nbsp;";
     }
     echo "<td width='30%'>" . __('Date format') . "</td>";
     echo "<td width='20%'>";
     $date_formats = array(0 => __('YYYY-MM-DD'), 1 => __('DD-MM-YYYY'), 2 => __('MM-DD-YYYY'));
     Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Results to display by page') . "</td><td>";
     // Limit using global config
     $value = $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max'];
     Dropdown::showNumber('list_limit', array('value' => $value, 'min' => 5, 'max' => $CFG_GLPI['list_limit_max'], 'step' => 5));
     echo "</td>";
     echo "<td>" . __('Number format') . "</td>";
     $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56', 3 => '1234.56', 4 => '1234,56');
     echo "<td>";
     Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Display order of surnames firstnames') . "</td><td>";
     $values = array(User::REALNAME_BEFORE => __('Surname, First name'), User::FIRSTNAME_BEFORE => __('First name, Surname'));
     Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"]));
     echo "</td>";
     echo "<td>" . __("Color palette") . "</td><td>";
     $themes_files = scandir(GLPI_ROOT . "/css/palettes/");
     echo "<select name='palette' id='theme-selector'>";
     foreach ($themes_files as $key => $file) {
         if (strpos($file, ".css") !== false) {
             $name = substr($file, 0, -4);
             $selected = "";
             if ($data["palette"] == $name) {
                 $selected = "selected='selected'";
             }
             echo "<option value='{$name}' {$selected}>" . ucfirst($name) . "</option>";
         }
     }
     echo Html::scriptBlock("\n         function formatThemes(theme) {\n             return \"&nbsp;<img src='../css/palettes/previews/\" + theme.text.toLowerCase() + \".png'/>\"\n                     + \"&nbsp;\" + theme.text;\n         }\n         \$(\"#theme-selector\").select2({\n             formatResult: formatThemes,\n             formatSelection: formatThemes,\n             width: '100%',\n             escapeMarkup: function(m) { return m; }\n         });\n      ");
     echo "</select>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     if ($oncentral) {
         echo "<td>" . __('Display the complete name in tree dropdowns') . "</td><td>";
         Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     if (!$userpref || $CFG_GLPI['show_count_on_tabs'] != -1) {
         echo "<td>" . __('Display counts in tabs') . "</td><td>";
         $values = array(0 => __('No'), 1 => __('Yes'));
         if (!$userpref) {
             $values[-1] = __('Never');
         }
         Dropdown::showFromArray('show_count_on_tabs', $values, array('value' => $data["show_count_on_tabs"]));
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     if ($oncentral) {
         echo "<td>" . __('Show GLPI ID') . "</td><td>";
         Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "<td>" . __('CSV delimiter') . "</td><td>";
     $values = array(';' => ';', ',' => ',');
     Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Notifications for my changes') . "</td><td>";
     Dropdown::showYesNo("notification_to_myself", $data["notification_to_myself"]);
     echo "</td>";
     if ($oncentral) {
         echo "<td>" . __('Results to display on home page') . "</td><td>";
         Dropdown::showNumber('display_count_on_home', array('value' => $data['display_count_on_home'], 'min' => 0, 'max' => 30));
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('PDF export font') . "</td><td>";
     Dropdown::showFromArray("pdffont", GLPIPDF::getFontList(), array('value' => $data["pdffont"], 'width' => 200));
     echo "</td>";
     echo "<td>" . __('Keep devices when purging an item') . "</td><td>";
     Dropdown::showYesNo('keep_devices_when_purging_item', $data['keep_devices_when_purging_item']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Go to created item after creation') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("backcreated", $data["backcreated"]);
     echo "</td>";
     echo "<td>" . __('Layout') . "</td><td>";
     $layout_options = array('lefttab' => __("Tabs on left"), 'classic' => __("Classic view"), 'vsplit' => __("Vertical split"));
     echo "<select name='layout' id='layout-selector'>";
     foreach ($layout_options as $key => $name) {
         $selected = "";
         if ($data["layout"] == $key) {
             $selected = "selected='selected'";
         }
         echo "<option value='{$key}' {$selected}>" . ucfirst($name) . "</option>";
     }
     echo Html::scriptBlock("\n         function formatLayout(layout) {\n             return \"&nbsp;<img src='../pics/layout_\" + layout.id.toLowerCase() + \".png'/>\"\n                     + \"&nbsp;\" + layout.text;\n         }\n         \$(\"#layout-selector\").select2({\n             formatResult: formatLayout,\n             formatSelection: formatLayout,\n             escapeMarkup: function(m) { return m; }\n         });\n      ");
     echo "</select>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Enable ticket timeline') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('ticket_timeline', $data['ticket_timeline']);
     echo "</td>";
     echo "<td>" . __('Keep tabs replaced by the ticket timeline') . "</td><td>";
     Dropdown::showYesNo('ticket_timeline_keep_replaced_tabs', $data['ticket_timeline_keep_replaced_tabs']);
     echo "</td></tr>";
     if ($oncentral) {
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Assistance') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Private followups by default') . "</td><td>";
         Dropdown::showYesNo("followup_private", $data["followup_private"]);
         echo "</td><td>" . __('Show new tickets on the home page') . "</td><td>";
         if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN))) {
             Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]);
         } else {
             echo Dropdown::getYesNo(0);
         }
         echo " </td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Private tasks by default') . "</td><td>";
         Dropdown::showYesNo("task_private", $data["task_private"]);
         echo "</td><td> " . __('Request sources by default') . "</td><td>";
         RequestType::dropdown(array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id"));
         echo "</td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Tasks state by default') . "</td><td>";
         Planning::dropdownState("task_state", $data["task_state"]);
         echo "</td><td colspan='2'>&nbsp;</td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Pre-select me as a technician when creating a ticket') . "</td><td>";
         if (!$userpref || Session::haveRight('ticket', Ticket::OWN)) {
             Dropdown::showYesNo("set_default_tech", $data["set_default_tech"]);
         } else {
             echo Dropdown::getYesNo(0);
         }
         echo "</td><td>" . __('Automatically refresh the list of tickets (minutes)') . "</td><td>";
         Dropdown::showNumber('refresh_ticket_list', array('value' => $data["refresh_ticket_list"], 'min' => 1, 'max' => 30, 'step' => 1, 'toadd' => array(0 => __('Never'))));
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Priority colors') . "</td>";
         echo "<td colspan='3'>";
         echo "<table><tr>";
         echo "<td>1&nbsp;";
         Html::showColorField('priority_1', array('value' => $data["priority_1"]));
         echo "</td>";
         echo "<td>2&nbsp;";
         Html::showColorField('priority_2', array('value' => $data["priority_2"]));
         echo "</td>";
         echo "<td>3&nbsp;";
         Html::showColorField('priority_3', array('value' => $data["priority_3"]));
         echo "</td>";
         echo "<td>4&nbsp;";
         Html::showColorField('priority_4', array('value' => $data["priority_4"]));
         echo "</td>";
         echo "<td>5&nbsp;";
         Html::showColorField('priority_5', array('value' => $data["priority_5"]));
         echo "</td>";
         echo "<td>6&nbsp;";
         Html::showColorField('priority_6', array('value' => $data["priority_6"]));
         echo "</td>";
         echo "</tr></table>";
         echo "</td></tr>";
     }
     // Only for user
     if (array_key_exists('personal_token', $data)) {
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Remote access key') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Remote access key');
         if (!empty($data["personal_token"])) {
             //TRANS: %s is the generation date
             echo "<br>" . sprintf(__('generated on %s'), Html::convDateTime($data["personal_token_date"]));
         }
         echo "</td><td colspan='3'>";
         echo "<input type='checkbox' name='_reset_personal_token'>&nbsp;" . __('Regenerate');
         echo "</td></tr>";
     }
     echo "<tr><th colspan='4'>" . __('Due date progression') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td>" . __('OK state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedateok_color', array('value' => $data["duedateok_color"]));
     echo "</td><td colspan='2'>&nbsp;</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Warning state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedatewarning_color', array('value' => $data["duedatewarning_color"]));
     echo "</td>";
     echo "<td>" . __('Warning state threshold') . "</td>";
     echo "<td>";
     Dropdown::showNumber("duedatewarning_less", array('value' => $data['duedatewarning_less']));
     $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber()));
     echo "&nbsp;";
     Dropdown::showFromArray("duedatewarning_unit", $elements, array('value' => $data['duedatewarning_unit']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>" . "<td>" . __('Critical state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedatecritical_color', array('value' => $data["duedatecritical_color"]));
     echo "</td>";
     echo "<td>" . __('Critical state threshold') . "</td>";
     echo "<td>";
     Dropdown::showNumber("duedatecritical_less", array('value' => $data['duedatecritical_less']));
     echo "&nbsp;";
     $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber()));
     Dropdown::showFromArray("duedatecritical_unit", $elements, array('value' => $data['duedatecritical_unit']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
     echo "</td></tr>";
     echo "</table></div>";
     Html::closeForm();
 }
Example #21
0
 /**
  * @since version 0.84 (before in entitydata.class)
  *
  * @param $entity Entity object
  **/
 static function showHelpdeskOptions(Entity $entity)
 {
     global $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ) || !Session::haveRightsOr(self::$rightname, array(self::READHELPDESK, self::UPDATEHELPDESK))) {
         return false;
     }
     $canedit = Session::haveRight(self::$rightname, self::UPDATEHELPDESK) && Session::haveAccessToEntity($ID);
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . _n('Ticket template', 'Ticket templates', 1) . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     $options = array('value' => $entity->fields["tickettemplates_id"], 'entity' => $ID, 'toadd' => $toadd);
     TicketTemplate::dropdown($options);
     if ($entity->fields["tickettemplates_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $tt = new TicketTemplate();
         $tid = self::getUsedConfig('tickettemplates_id', $ID, '', 0);
         if (!$tid) {
             echo Dropdown::EMPTY_VALUE;
         } else {
             if ($tt->getFromDB($tid)) {
                 echo $tt->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Calendar') . "</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entity->fields["calendars_id"], 'emptylabel' => __('24/7'));
     if ($ID != 0) {
         $options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Calendar::dropdown($options);
     if ($entity->fields["calendars_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $calendar = new Calendar();
         $cid = self::getUsedConfig('calendars_id', $ID, '', 0);
         if (!$cid) {
             _e('24/7');
         } else {
             if ($calendar->getFromDB($cid)) {
                 echo $calendar->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Tickets default type') . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd));
     if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE));
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . __('Automatic assignment of tickets') . "</td>";
     echo "<td colspan='2'>";
     $autoassign = self::getAutoAssignMode();
     if ($ID == 0) {
         unset($autoassign[self::CONFIG_PARENT]);
     }
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"]));
     if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) {
         $auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']);
         echo "<font class='green'>&nbsp;&nbsp;";
         echo $autoassign[$auto_assign_mode];
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>";
     echo "<td colspan='2'>";
     $autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly'));
     if ($ID == 0) {
         unset($autoclose[self::CONFIG_PARENT]);
     }
     Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day'));
     if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) {
         $autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER);
         echo "<br><font class='green'>&nbsp;&nbsp;";
         if ($autoclose_mode >= 0) {
             printf(_n('%d day', '%d days', $autoclose_mode), $autoclose_mode);
         } else {
             echo $autoclose[$autoclose_mode];
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . __('Configuring the satisfaction survey') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Configuring the satisfaction survey') . "</td>";
     echo "<td colspan='2'>";
     /// no inquest case = rate 0
     $typeinquest = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), 1 => __('Internal survey'), 2 => __('External survey'));
     // No inherit from parent for root entity
     if ($ID == 0) {
         unset($typeinquest[self::CONFIG_PARENT]);
         if ($entity->fields['inquest_config'] == self::CONFIG_PARENT) {
             $entity->fields['inquest_config'] = 1;
         }
     }
     $rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entity->fields['inquest_config']));
     echo "</td></tr>\n";
     // Do not display for root entity in inherit case
     if ($entity->fields['inquest_config'] == self::CONFIG_PARENT && $ID != 0) {
         $inquestconfig = self::getUsedConfig('inquest_config', $entity->fields['entities_id']);
         $inquestrate = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_rate');
         echo "<tr class='tab_bg_1'><td colspan='4' class='green center'>";
         if ($inquestrate == 0) {
             _e('Disabled');
         } else {
             echo $typeinquest[$inquestconfig] . '<br>';
             $inqconf = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_delay');
             printf(_n('%d day', '%d days', $inqconf), $inqconf);
             echo "<br>";
             //TRANS: %d is the percentage. %% to display %
             printf(__('%d%%'), $inquestrate);
             if ($inquestconfig == 2) {
                 echo "<br>";
                 echo self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_URL');
             }
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $_POST = array('inquest_config' => $entity->fields['inquest_config'], 'entities_id' => $ID);
     $params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
     echo "<div id='inquestconfig'>";
     include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
     echo "</div>\n";
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='4'>";
         echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n                  class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
     echo "</div>";
     Ajax::updateItemOnSelectEvent("dropdown_inquest_config{$rand}", "inquestconfig", $CFG_GLPI["root_doc"] . "/ajax/ticketsatisfaction.php", $params);
 }
Example #22
0
 function canEditAll()
 {
     return Session::haveRightsOr('problem', array(CREATE, UPDATE, DELETE, PURGE));
 }
Example #23
0
 /**
  * Print the central form for a profile
  *
  * @param $openform     boolean  open the form (true by default)
  * @param $closeform    boolean  close the form (true by default)
  **/
 function showFormSetup($openform = true, $closeform = true)
 {
     if (!self::canView()) {
         return false;
     }
     echo "<div class='spaced'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $this->getFormURL() . "'>";
     }
     $dropdown_rights = CommonDBTM::getRights();
     unset($dropdown_rights[DELETE]);
     unset($dropdown_rights[UNLOCK]);
     $rights = array(array('itemtype' => 'Config', 'label' => __('General setup'), 'field' => 'config'), array('itemtype' => 'DisplayPreference', 'label' => __('Search result display'), 'field' => 'search_config'), array('itemtype' => 'Item_Devices', 'label' => _n('Component', 'Components', Session::getPluralNumber()), 'field' => 'device'), array('rights' => $dropdown_rights, 'label' => _n('Global dropdown', 'Global dropdowns', Session::getPluralNumber()), 'field' => 'dropdown'), __('Entity dropdowns'), array('itemtype' => 'Domain', 'label' => _n('Domain', 'Domains', Session::getPluralNumber()), 'field' => 'domain'), array('itemtype' => 'Location', 'label' => _n('Location', 'Locations', Session::getPluralNumber()), 'field' => 'location'), array('itemtype' => 'ITILCategory', 'label' => _n('Ticket category', 'Ticket categories', Session::getPluralNumber()), 'field' => 'itilcategory'), array('itemtype' => 'KnowbaseItemCategory', 'label' => _n('Knowledge base category', 'Knowledge base categories', Session::getPluralNumber()), 'field' => 'knowbasecategory'), array('itemtype' => 'Netpoint', 'label' => _n('Network outlet', 'Network outlets', Session::getPluralNumber()), 'field' => 'netpoint'), array('itemtype' => 'TaskCategory', 'label' => _n('Task category', 'Task categories', Session::getPluralNumber()), 'field' => 'taskcategory'), array('itemtype' => 'State', 'label' => _n('Status of items', 'Statuses of items', Session::getPluralNumber()), 'field' => 'state'), array('itemtype' => 'SolutionTemplate', 'label' => _n('Solution template', 'Solution templates', Session::getPluralNumber()), 'field' => 'solutiontemplate'), array('itemtype' => 'Calendar', 'label' => _n('Calendar', 'Calendars', Session::getPluralNumber()), 'field' => 'calendar'), array('itemtype' => 'DocumentType', 'label' => __('Document type'), 'field' => 'typedoc'), array('itemtype' => 'Link', 'label' => _n('External link', 'External links', Session::getPluralNumber()), 'field' => 'link'), array('itemtype' => 'Notification', 'label' => _n('Notification', 'Notifications', Session::getPluralNumber()), 'field' => 'notification'), array('itemtype' => 'SLA', 'label' => __('SLA'), 'field' => 'sla'));
     $this->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Setup')));
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value='" . $this->fields['id'] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
     $this->showLegend();
 }
Example #24
0
 static function showForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $CFG_GLPI;
     $is_device = $item instanceof CommonDevice;
     $ID = $item->getField('id');
     if (!$item->can($ID, READ)) {
         return false;
     }
     $canedit = $withtemplate != 2 && $item->canEdit($ID) && Session::haveRightsOr('device', array(UPDATE, PURGE));
     echo "<div class='spaced'>";
     $rand = mt_rand();
     if ($canedit) {
         echo "\n<form id='form_device_add{$rand}' name='form_device_add{$rand}'\n                  action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n";
         echo "\t<input type='hidden' name='items_id' value='{$ID}'>\n";
         echo "\t<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
     }
     $table = new HTMLTableMain();
     $table->setTitle(_n('Component', 'Components', Session::getPluralNumber()));
     if ($canedit) {
         $delete_all_column = $table->addHeader('delete all', Html::getCheckAllAsCheckbox("form_device_action{$rand}", '__RAND__'));
         $delete_all_column->setHTMLClass('center');
     } else {
         $delete_all_column = NULL;
     }
     $column_label = $is_device ? _n('Item', 'Items', Session::getPluralNumber()) : __('Type of component');
     $common_column = $table->addHeader('common', $column_label);
     $specific_column = $table->addHeader('specificities', __('Specificities'));
     $specific_column->setHTMLClass('center');
     $dynamic_column = '';
     if ($item->isDynamic()) {
         $dynamic_column = $table->addHeader('is_dynamic', __('Automatic inventory'));
         $dynamic_column->setHTMLClass('center');
     }
     if ($canedit) {
         $massiveactionparams = array('container' => "form_device_action{$rand}", 'fixed' => false, 'display_arrow' => false);
         $content = array(array('function' => 'Html::showMassiveActions', 'parameters' => array($massiveactionparams)));
         $delete_column = $table->addHeader('delete one', $content);
         $delete_column->setHTMLClass('center');
     } else {
         $delete_column = NULL;
     }
     $table_options = array('canedit' => $canedit, 'rand' => $rand);
     if ($is_device) {
         Session::initNavigateListItems(static::getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach (array_merge(array(''), self::getConcernedItems()) as $itemtype) {
             $table_options['itemtype'] = $itemtype;
             $link = getItemForItemtype(static::getType());
             $link->getTableGroup($item, $table, $table_options, $delete_all_column, $common_column, $specific_column, $delete_column, $dynamic_column);
         }
     } else {
         $devtypes = array();
         foreach (self::getItemAffinities($item->getType()) as $link_type) {
             $devtypes[] = $link_type::getDeviceType();
             $link = getItemForItemtype($link_type);
             Session::initNavigateListItems($link_type, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
             $link->getTableGroup($item, $table, $table_options, $delete_all_column, $common_column, $specific_column, $delete_column, $dynamic_column);
         }
     }
     if ($canedit) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><td>";
         echo __('Add a new component') . "</td><td class=left width='70%'>";
         if ($is_device) {
             Dropdown::showNumber('number_devices_to_add', array('value' => 0, 'min' => 0, 'max' => 10));
         } else {
             Dropdown::showSelectItemFromItemtypes(array('itemtype_name' => 'devicetype', 'items_id_name' => 'devices_id', 'itemtypes' => $devtypes, 'entity_restrict' => $item->getEntityID(), 'showItemSpecificity' => $CFG_GLPI['root_doc'] . '/ajax/selectUnaffectedOrNewItem_Device.php'));
         }
         echo "</td><td>";
         echo "<input type='submit' class='submit' name='add' value='" . _sx('button', 'Add') . "'>";
         echo "</td></tr></table>";
         Html::closeForm();
     }
     if ($canedit) {
         echo "\n<form id='form_device_action{$rand}' name='form_device_action{$rand}'\n                  action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n";
         echo "\t<input type='hidden' name='items_id' value='{$ID}'>\n";
         echo "\t<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
     }
     $table->display(array('display_super_for_each_group' => false, 'display_title_for_each_group' => false));
     if ($canedit) {
         //          echo "<input type='submit' class='submit' name='updateall' value='" .
         //               _sx('button', 'Save')."'>";
         Html::closeForm();
     }
     echo "</div>";
     // Force disable selected items
     $_SESSION['glpimassiveactionselected'] = array();
 }
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
*/
if (!defined('GLPI_ROOT')) {
    include '../inc/includes.php';
}
Html::popHeader(__('Setup'), $_SERVER['PHP_SELF']);
Session::haveRightsOr('serach_config', array(DisplayPreference::PERSONAL, DisplayPreference::GENERAL));
$setupdisplay = new DisplayPreference();
if (isset($_POST["activate"])) {
    $setupdisplay->activatePerso($_POST);
} else {
    if (isset($_POST["disable"])) {
        if ($_POST['users_id'] == Session::getLoginUserID()) {
            $setupdisplay->deleteByCriteria(array('users_id' => $_POST['users_id'], 'itemtype' => $_POST['itemtype']));
        }
    } else {
        if (isset($_POST["add"])) {
            $setupdisplay->add($_POST);
        } else {
            if (isset($_POST["purge"]) || isset($_POST["purge_x"])) {
                $setupdisplay->delete($_POST, 1);
            } else {
Example #26
0
 /**
  * Generic Function to add Default left join to a request
  *
  * @param $itemtype                    reference ID
  * @param $ref_table                   reference table
  * @param &$already_link_tables  array of tables already joined
  *
  * @return Left join string
  **/
 static function addDefaultJoin($itemtype, $ref_table, array &$already_link_tables)
 {
     switch ($itemtype) {
         // No link
         case 'User':
             return self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_profiles_users", "profiles_users_id", 0, 0, array('jointype' => 'child'));
         case 'Reminder':
             return Reminder::addVisibilityJoins();
         case 'RSSFeed':
             return RSSFeed::addVisibilityJoins();
         case 'ProjectTask':
             // Same structure in addDefaultWhere
             $out = '';
             $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_projecttaskteams", "projecttaskteams_id", 0, 0, array('jointype' => 'child'));
             return $out;
         case 'Project':
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("project", Project::READALL)) {
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_projectteams", "projectteams_id", 0, 0, array('jointype' => 'child'));
             }
             return $out;
         case 'Ticket':
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("ticket", Ticket::READALL)) {
                 $searchopt =& self::getOptions($itemtype);
                 // show mine : requester
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[4]['joinparams']['beforejoin']['joinparams']);
                 if (Session::haveRight("ticket", Ticket::READGROUP)) {
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[71]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
                 // show mine : observer
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[66]['joinparams']['beforejoin']['joinparams']);
                 if (count($_SESSION['glpigroups'])) {
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[65]['joinparams']['beforejoin']['joinparams']);
                 }
                 if (Session::haveRight("ticket", Ticket::OWN)) {
                     // Can own ticket : show assign to me
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                 }
                 if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READASSIGN))) {
                     // show mine + assign to me
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[8]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
                 if (Session::haveRightsOr('ticketvalidation', array(TicketValidation::VALIDATEINCIDENT, TicketValidation::VALIDATEREQUEST))) {
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_ticketvalidations", "ticketvalidations_id", 0, 0, $searchopt[58]['joinparams']['beforejoin']['joinparams']);
                 }
             }
             return $out;
         case 'Change':
         case 'Problem':
             if ($itemtype == 'Change') {
                 $right = 'change';
                 $table = 'changes';
                 $groupetable = "glpi_changes_groups";
                 $linkfield = "changes_groups_id";
             } else {
                 if ($itemtype == 'Problem') {
                     $right = 'problem';
                     $table = 'problems';
                     $groupetable = "glpi_groups_problems";
                     $linkfield = "groups_problems_id";
                 }
             }
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("{$right}", $itemtype::READALL)) {
                 $searchopt =& self::getOptions($itemtype);
                 if (Session::haveRight("{$right}", $itemtype::READMY)) {
                     // show mine : requester
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[4]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[71]['joinparams']['beforejoin']['joinparams']);
                     }
                     // show mine : observer
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[66]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[65]['joinparams']['beforejoin']['joinparams']);
                     }
                     // show mine : assign
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[8]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
             }
             return $out;
         default:
             // Plugin can override core definition for its type
             if ($plug = isPluginItemType($itemtype)) {
                 $function = 'plugin_' . $plug['plugin'] . '_addDefaultJoin';
                 if (function_exists($function)) {
                     $out = $function($itemtype, $ref_table, $already_link_tables);
                     if (!empty($out)) {
                         return $out;
                     }
                 }
             }
             return "";
     }
 }
Example #27
0
 static function canView()
 {
     return Session::haveRightsOr('change', array(Change::READALL, Change::READMY));
 }
Example #28
0
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.

-------------------------------------------------------------------------

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::haveRightsOr('change', array(Change::READALL, Change::READMY));
Html::header(Change::getTypeName(Session::getPluralNumber()), '', "helpdesk", "change");
Search::show('Change');
Html::footer();
 /**
  *  @see CommonGLPI::getMenuContent()
  *
  *  @since version 0.85
  **/
 static function getMenuContent()
 {
     $menu = array();
     if (Session::haveRightsOr('device', array(CREATE, UPDATE, PURGE))) {
         $menu['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['page'] = '/front/device.php';
         $dps = Dropdown::getDeviceItemTypes();
         foreach ($dps as $tab) {
             foreach ($tab as $key => $val) {
                 if ($tmp = getItemForItemtype($key)) {
                     $menu['options'][$key]['title'] = $val;
                     $menu['options'][$key]['page'] = $tmp->getSearchURL(false);
                     $menu['options'][$key]['links']['search'] = $tmp->getSearchURL(false);
                     if ($tmp->canCreate()) {
                         $menu['options'][$key]['links']['add'] = $tmp->getFormURL(false);
                     }
                 }
             }
         }
     }
     if (count($menu)) {
         return $menu;
     }
     return false;
 }
 static function canView()
 {
     return Session::haveRightsOr('problem', array(Problem::READALL, Problem::READMY));
 }