Esempio n. 1
0
 /**
  * Print a nice HTML head for help page
  *
  * @param $title  title of the page
  * @param $url    not used anymore (default '')
  **/
 static function helpHeader($title, $url = '')
 {
     global $CFG_GLPI, $HEADER_LOADED, $PLUGIN_HOOKS;
     // Print a nice HTML-head for help page
     if ($HEADER_LOADED) {
         return;
     }
     $HEADER_LOADED = true;
     self::includeHeader($title);
     // Body
     $body_class = "layout_" . $_SESSION['glpilayout'];
     if (strpos($_SERVER['REQUEST_URI'], "form.php") !== false && isset($_GET['id']) && $_GET['id'] > 0) {
         if (!CommonGLPI::isLayoutExcludedPage()) {
             $body_class .= " form";
         } else {
             $body_class = "";
         }
     }
     echo "<body class='{$body_class}'>";
     // Main Headline
     echo "<div id='header'>";
     echo "<div id='header_top'>";
     echo "<div id='c_logo'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' accesskey='1' title=\"" . __s('Home') . "\"><span class='invisible'>Logo</span></a>";
     echo "</div>";
     // Les préférences + lien déconnexion
     echo "<div id='c_preference' >";
     echo "<ul>";
     echo "<li id='deconnexion'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/logout.php";
     /// logout witout noAuto login for extauth
     if (isset($_SESSION['glpiextauth']) && $_SESSION['glpiextauth']) {
         echo "?noAUTO=1";
     }
     echo "' title=\"" . __s('Logout') . "\">";
     // check user id : header used for display messages when session logout
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/logout.png' title=\"" . __s('Logout') . "\"  alt=\"" . __s('Logout') . "\" class='button-icon'>";
     echo "</a>";
     echo "</li>\n";
     echo "<li id='preferences_link'><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . __s('My settings') . "\">";
     echo "<span id='preferences_icon' title=\"" . __s('My settings') . "\"  alt=\"" . __s('My settings') . "\" class='button-icon' /></span>";
     // check user id : header used for display messages when session logout
     if (Session::getLoginUserID()) {
         echo "<span id='myname'>";
         echo formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20);
         echo "</span>";
     }
     echo "</a></li>";
     echo "<li>";
     Ajax::createIframeModalWindow('loadbookmark', $CFG_GLPI["root_doc"] . "/front/bookmark.php?action=load", array('title' => __('Load a bookmark'), 'reloadonclose' => true));
     echo "<a href='#' onClick=\"" . Html::jsGetElementbyID('loadbookmark') . ".dialog('open');\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png' title=\"" . __s('Load a bookmark') . "\"  alt=\"" . __s('Load a bookmark') . "\" class='button-icon'>";
     echo "</a></li>";
     echo "<li id='help_link'>" . "<a href='" . (empty($CFG_GLPI["helpdesk_doc_url"]) ? "http://glpi-project.org/help-helpdesk" : $CFG_GLPI["helpdesk_doc_url"]) . "' target='_blank' title=\"" . __s('Help') . "\">" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/help.png' title=\"" . __s('Help') . "\"  alt=\"" . __s('Help') . "\" class='button-icon'>";
     "</a></li>";
     echo "</ul>";
     echo "</div>";
     //-- Le moteur de recherche --
     echo "<div id='c_recherche'></div>";
     echo "</div>";
     //-- Le menu principal --
     echo "<div id='c_menu'>";
     echo "<ul id='menu'>";
     // Build the navigation-elements
     // Home
     echo "<li id='menu1'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\" class='itemP'>" . __('Home') . "</a>";
     echo "</li>";
     //  Create ticket
     if (Session::haveRight("ticket", CREATE)) {
         echo "<li id='menu2'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1' " . "title=\"" . __s('Create a ticket') . "\" class='itemP'>" . __('Create a ticket') . "</a>";
         echo "</li>";
     }
     //  Suivi ticket
     if (Session::haveRight("ticket", Ticket::READMY) || Session::haveRight("followup", TicketFollowup::SEEPUBLIC)) {
         echo "<li id='menu3'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php' title=\"" . __s('Ticket followup') . "\" class='itemP'>" . _n('Ticket', 'Tickets', Session::getPluralNumber()) . "</a>";
         echo "</li>";
     }
     // Reservation
     if (Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
         echo "<li id='menu4'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.php' title=\"" . _sn('Reservation', 'Reservations', Session::getPluralNumber()) . "\" class='itemP'>" . _n('Reservation', 'Reservations', Session::getPluralNumber()) . "</a>";
         echo "</li>";
     }
     // FAQ
     if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
         echo "<li id='menu5' >";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.faq.php' title=\"" . __s('FAQ') . "\" class='itemP'>" . __('FAQ') . "</a>";
         echo "</li>";
     }
     // PLUGINS
     $plugins = array();
     if (isset($PLUGIN_HOOKS["helpdesk_menu_entry"]) && count($PLUGIN_HOOKS["helpdesk_menu_entry"])) {
         foreach ($PLUGIN_HOOKS["helpdesk_menu_entry"] as $plugin => $active) {
             if ($active) {
                 $plugins[$plugin] = Plugin::getInfo($plugin);
             }
         }
     }
     if (isset($plugins) && count($plugins) > 0) {
         $list = array();
         foreach ($plugins as $key => $val) {
             $list[$key] = $val["name"];
         }
         asort($list);
         echo "<li id='menu5' onmouseover=\"javascript:menuAff('menu5','menu');\">";
         echo "<a href='#' title=\"" . _sn('Plugin', 'Plugins', Session::getPluralNumber()) . "\" class='itemP'>" . __('Plugins') . "</a>";
         // default none
         echo "<ul class='ssmenu'>";
         // list menu item
         foreach ($list as $key => $val) {
             $link = "";
             if (is_string($PLUGIN_HOOKS["helpdesk_menu_entry"][$key])) {
                 $link = $PLUGIN_HOOKS["helpdesk_menu_entry"][$key];
             }
             echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/plugins/" . $key . $link . "'>" . $plugins[$key]["name"] . "</a></li>\n";
         }
         echo "</ul></li>";
     }
     echo "</ul>";
     echo "</div>";
     // End navigation bar
     // End headline
     //  Le fil d ariane
     echo "<div id='c_ssmenu2'>";
     echo "<ul>";
     echo "<li class='breadcrumb_item'>" . "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\">" . __('Home') . "</a></li>";
     if (TicketValidation::getValidateRights()) {
         $opt = array();
         $opt['reset'] = 'reset';
         $opt['criteria'][0]['field'] = 55;
         // validation status
         $opt['criteria'][0]['searchtype'] = 'equals';
         $opt['criteria'][0]['value'] = TicketValidation::WAITING;
         $opt['criteria'][0]['link'] = 'AND';
         $opt['criteria'][1]['field'] = 59;
         // validation aprobator
         $opt['criteria'][1]['searchtype'] = 'equals';
         $opt['criteria'][1]['value'] = Session::getLoginUserID();
         $opt['criteria'][1]['link'] = 'AND';
         $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&amp;');
         $pic_validate = "<a href='{$url_validate}'>" . "<img title=\"" . __s('Ticket waiting for your approval') . "\" alt=\"" . __s('Ticket waiting for your approval') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' class='pointer'></a>";
         echo "<li class='icons_block'>{$pic_validate}</li>\n";
     }
     if (Session::haveRight('ticket', CREATE) && strpos($_SERVER['PHP_SELF'], "ticket")) {
         echo "<li class='icons_block'><a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1'>";
         echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\" class='pointer'></a></li>";
     }
     // check user id : header used for display messages when session logout
     if (Session::getLoginUserID()) {
         self::showProfileSelecter($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
     }
     echo "</ul></div>";
     echo "</div>";
     // fin header
     echo "<div id='page' >";
     // call static function callcron() every 5min
     CronTask::callCron();
     self::displayMessageAfterRedirect();
 }
Esempio n. 2
0
    /**
     * Print a nice HTML head for help page
     *
     * @param $title  title of the page
     * @param $url    not used anymore (default '')
     **/
    static function helpHeader($title, $url = '')
    {
        global $CFG_GLPI, $HEADER_LOADED, $PLUGIN_HOOKS, $DB;
        // Print a nice HTML-head for help page
        if ($HEADER_LOADED) {
            return;
        }
        $HEADER_LOADED = true;
        self::includeHeader($title);
        // Body
        echo "<body>";
        echo '
<nav class="navbar navbar-default" id="menuHeader">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="' . $CFG_GLPI["root_doc"] . '/front/central.php">
      	<img src="' . $CFG_GLPI["root_doc"] . '/pics/fd_logo1.png" style="margin-top:-4px;" />
      	<span class=\'invisible\'>Logo</span>
      </a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">';
        echo "<li id='menu1'>";
        echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\" class='itemP'>" . __('Home') . "</a>";
        echo "</li>";
        //  Create ticket
        if (Session::haveRight("ticket", CREATE)) {
            echo "<li id='menu2'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1' " . "title=\"" . __s('Create a ticket') . "\" class='itemP'>" . __('Create a ticket') . "</a>";
            echo "</li>";
        }
        //  Suivi ticket
        if (Session::haveRight("ticket", Ticket::READMY) || Session::haveRight("followup", TicketFollowup::SEEPUBLIC)) {
            echo "<li id='menu3'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php' title=\"" . __s('Ticket followup') . "\" class='itemP'>" . _n('Ticket', 'Tickets', Session::getPluralNumber()) . "</a>";
            echo "</li>";
        }
        // Reservation
        if (Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
            echo "<li id='menu4'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.php' title=\"" . _sn('Reservation', 'Reservations', Session::getPluralNumber()) . "\" class='itemP'>" . _n('Reservation', 'Reservations', Session::getPluralNumber()) . "</a>";
            echo "</li>";
        }
        // FAQ
        if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
            echo "<li id='menu5' >";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.faq.php' title=\"" . __s('FAQ') . "\" class='itemP'>" . __('FAQ') . "</a>";
            echo "</li>";
        }
        // PLUGINS
        $plugins = array();
        if (isset($PLUGIN_HOOKS["helpdesk_menu_entry"]) && count($PLUGIN_HOOKS["helpdesk_menu_entry"])) {
            foreach ($PLUGIN_HOOKS["helpdesk_menu_entry"] as $plugin => $active) {
                if ($active) {
                    $plugins[$plugin] = Plugin::getInfo($plugin);
                }
            }
        }
        if (isset($plugins) && count($plugins) > 0) {
            $list = array();
            foreach ($plugins as $key => $val) {
                $list[$key] = $val["name"];
            }
            asort($list);
            //echo "<li id='menu5' onmouseover=\"javascript:menuAff('menu5','menu');\">";
            echo "<li id='menu5'>";
            echo "<a href='#' title=\"" . _sn('Plugin', 'Plugins', Session::getPluralNumber()) . "\" class='itemP'>" . __('Plugins') . "</a>";
            // default none
            echo "<ul class='ssmenu'>";
            // list menu item
            foreach ($list as $key => $val) {
                $link = "";
                if (is_string($PLUGIN_HOOKS["helpdesk_menu_entry"][$key])) {
                    $link = $PLUGIN_HOOKS["helpdesk_menu_entry"][$key];
                }
                echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/plugins/" . $key . $link . "'>" . $plugins[$key]["name"] . "</a></li>\n";
            }
            echo "</ul></li>";
        }
        echo "<div class='sep'></div>";
        echo '</ul>';
        echo '<ul class="nav navbar-nav navbar-right">';
        $sql_photo2 = "SELECT picture\n\t\t\t\t\t\t\t\tFROM glpi_users\n\t\t\t\t\t\t\t\tWHERE id = " . $_SESSION["glpiID"] . " ";
        $res_photo2 = $DB->query($sql_photo2);
        $pic2 = $DB->result($res_photo2, 0, 'picture');
        $photo_url2 = User::getURLForPicture($pic2);
        echo '<li class="dropdown">';
        echo '<a href="#" style="padding:0px; margin:0px;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><img src="' . $photo_url2 . '" class="avatar" alt="" title="' . formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20) . '" /></a>';
        echo "<ul class=\"dropdown-menu\" role=\"menu\">";
        echo "<li><a href='" . (empty($CFG_GLPI["central_doc_url"]) ? "http://glpi-project.org/help-central" : $CFG_GLPI["central_doc_url"]) . "' target='_blank' title=\"" . __s('Help') . "\"><i class='fa fa-question-circle'></i> " . __('Help') . "</a></li>";
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . __s('My settings') . "\"><i class='fa fa-cog'></i> " . __('My settings') . "</a></li>";
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . addslashes(Dropdown::getLanguageName($_SESSION['glpilanguage'])) . "\"><i class='fa fa-flag'></i> " . Dropdown::getLanguageName($_SESSION['glpilanguage']) . "</a></li>";
        echo "<li id='deconnexion'><a href='" . $CFG_GLPI["root_doc"] . "/front/logout.php";
        // logout witout noAuto login for extauth
        if (isset($_SESSION['glpiextauth']) && $_SESSION['glpiextauth']) {
            echo "?noAUTO=1";
        }
        echo "' title=\"" . __s('Logout') . "\"><i class='fa fa-lock'></i> " . __('Logout') . "</a>";
        // check user id : header used for display messages when session logout
        if (Session::getLoginUserID()) {
            //echo " (";
            // echo formatUserName (0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20);
            // echo ")";
        }
        echo "</li>\n";
        echo "</ul>";
        echo '  </li>';
        echo '
			      </ul>
			    </div><!-- /.navbar-collapse -->
			  </div><!-- /.container-fluid -->
			</nav> ';
        echo '<nav class="navbar navbar-default nav2" style="margin-top: -20px;">';
        // Display item
        echo "<div id='c_ssmenu2'>";
        echo "<ul>";
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\">" . __('Home') . "></a></li>";
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        if (Session::haveRightsOr('ticketvalidation', array(TicketValidation::VALIDATEREQUEST, TicketValidation::VALIDATEINCIDENT))) {
            $opt = array();
            $opt['reset'] = 'reset';
            $opt['criteria'][0]['field'] = 55;
            // validation status
            $opt['criteria'][0]['searchtype'] = 'equals';
            $opt['criteria'][0]['value'] = TicketValidation::WAITING;
            $opt['criteria'][0]['link'] = 'AND';
            $opt['criteria'][1]['field'] = 59;
            // validation aprobator
            $opt['criteria'][1]['searchtype'] = 'equals';
            $opt['criteria'][1]['value'] = Session::getLoginUserID();
            $opt['criteria'][1]['link'] = 'AND';
            $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&amp;');
            $pic_validate = "<a href='{$url_validate}'>" . "<img title=\"" . __s('Ticket waiting for your approval') . "\" alt=\"" . __s('Ticket waiting for your approval') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png'></a>";
            echo "<li>{$pic_validate}</li>\n";
        }
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        if (Session::haveRight('ticket', CREATE) && strpos($_SERVER['PHP_SELF'], "ticket")) {
            echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1'>";
            echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"></a></li>";
        }
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        /// Bookmark load
        echo "<li>";
        Ajax::createIframeModalWindow('loadbookmark', $CFG_GLPI["root_doc"] . "/front/bookmark.php?action=load", array('title' => __('Load a bookmark'), 'reloadonclose' => true));
        echo "<a href='#' onClick=\"" . Html::jsGetElementbyID('loadbookmark') . ".dialog('open');\"\">";
        echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png' title=\"" . __s('Load a bookmark') . "\" alt=\"" . __s('Load a bookmark') . "\">";
        echo "</a></li>";
        // check user id : header used for display messages when session logout
        if (Session::getLoginUserID()) {
            self::showProfileSelecter($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
        }
        echo "</ul></div>";
        //end c_ssmenu2
        Html::scriptStart();
        echo self::jsGetElementbyID('show_all_menu') . ".dialog({\n         height: 'auto',\n         width: 'auto',\n         modal: true,\n         autoOpen: false\n         });";
        echo Html::scriptEnd();
        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        // echo "</li>";
        echo '</nav>';
    }
Esempio n. 3
0
 /**
  * Make a select box for Ticket my devices
  *
  * @param $userID          User ID for my device section (default 0)
  * @param $entity_restrict restrict to a specific entity (default -1)
  * @param $itemtype        of selected item (default 0)
  * @param $items_id        of selected item (default 0)
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdownMyDevices($userID = 0, $entity_restrict = -1, $itemtype = 0, $items_id = 0)
 {
     global $DB, $CFG_GLPI;
     if ($userID == 0) {
         $userID = Session::getLoginUserID();
     }
     $rand = mt_rand();
     $already_add = array();
     if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, self::HELPDESK_MY_HARDWARE)) {
         $my_devices = "";
         $my_item = $itemtype . '_' . $items_id;
         // My items
         foreach ($CFG_GLPI["linkuser_types"] as $itemtype) {
             if (($item = getItemForItemtype($itemtype)) && parent::isPossibleToAssignType($itemtype)) {
                 $itemtable = getTableForItemType($itemtype);
                 $query = "SELECT *\n                             FROM `{$itemtable}`\n                             WHERE `users_id` = '{$userID}'";
                 if ($item->maybeDeleted()) {
                     $query .= " AND `is_deleted` = '0' ";
                 }
                 if ($item->maybeTemplate()) {
                     $query .= " AND `is_template` = '0' ";
                 }
                 if (in_array($itemtype, $CFG_GLPI["helpdesk_visible_types"])) {
                     $query .= " AND `is_helpdesk_visible` = '1' ";
                 }
                 $query .= getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict, $item->maybeRecursive()) . "\n                         ORDER BY `name` ";
                 $result = $DB->query($query);
                 $nb = $DB->numrows($result);
                 if ($DB->numrows($result) > 0) {
                     $type_name = $item->getTypeName($nb);
                     while ($data = $DB->fetch_assoc($result)) {
                         $output = $data["name"];
                         if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
                             $output = sprintf(__('%1$s (%2$s)'), $output, $data['id']);
                         }
                         $output = sprintf(__('%1$s - %2$s'), $type_name, $output);
                         if ($itemtype != 'Software') {
                             if (!empty($data['serial'])) {
                                 $output = sprintf(__('%1$s - %2$s'), $output, $data['serial']);
                             }
                             if (!empty($data['otherserial'])) {
                                 $output = sprintf(__('%1$s - %2$s'), $output, $data['otherserial']);
                             }
                         }
                         $my_devices .= "<option title=\"{$output}\" value='" . $itemtype . "_" . $data["id"] . "' " . ($my_item == $itemtype . "_" . $data["id"] ? "selected" : "") . ">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
                         $already_add[$itemtype][] = $data["id"];
                     }
                 }
             }
         }
         if (!empty($my_devices)) {
             $my_devices = "<optgroup label=\"" . __s('My devices') . "\">" . $my_devices . "</optgroup>";
         }
         // My group items
         if (Session::haveRight("show_group_hardware", "1")) {
             $group_where = "";
             $query = "SELECT `glpi_groups_users`.`groups_id`, `glpi_groups`.`name`\n                            FROM `glpi_groups_users`\n                            LEFT JOIN `glpi_groups`\n                              ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`)\n                            WHERE `glpi_groups_users`.`users_id` = '{$userID}' " . getEntitiesRestrictRequest("AND", "glpi_groups", "", $entity_restrict, true);
             $result = $DB->query($query);
             $first = true;
             if ($DB->numrows($result) > 0) {
                 while ($data = $DB->fetch_assoc($result)) {
                     if ($first) {
                         $first = false;
                     } else {
                         $group_where .= " OR ";
                     }
                     $a_groups = getAncestorsOf("glpi_groups", $data["groups_id"]);
                     $a_groups[$data["groups_id"]] = $data["groups_id"];
                     $group_where .= " `groups_id` IN (" . implode(',', $a_groups) . ") ";
                 }
                 $tmp_device = "";
                 foreach ($CFG_GLPI["linkgroup_types"] as $itemtype) {
                     if (($item = getItemForItemtype($itemtype)) && parent::isPossibleToAssignType($itemtype)) {
                         $itemtable = getTableForItemType($itemtype);
                         $query = "SELECT *\n                                    FROM `{$itemtable}`\n                                    WHERE ({$group_where}) " . getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict, $item->maybeRecursive());
                         if ($item->maybeDeleted()) {
                             $query .= " AND `is_deleted` = '0' ";
                         }
                         if ($item->maybeTemplate()) {
                             $query .= " AND `is_template` = '0' ";
                         }
                         $result = $DB->query($query);
                         if ($DB->numrows($result) > 0) {
                             $type_name = $item->getTypeName();
                             if (!isset($already_add[$itemtype])) {
                                 $already_add[$itemtype] = array();
                             }
                             while ($data = $DB->fetch_assoc($result)) {
                                 if (!in_array($data["id"], $already_add[$itemtype])) {
                                     $output = '';
                                     if (isset($data["name"])) {
                                         $output = $data["name"];
                                     }
                                     if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
                                         $output = sprintf(__('%1$s (%2$s)'), $output, $data['id']);
                                     }
                                     $output = sprintf(__('%1$s - %2$s'), $type_name, $output);
                                     if (isset($data['serial'])) {
                                         $output = sprintf(__('%1$s - %2$s'), $output, $data['serial']);
                                     }
                                     if (isset($data['otherserial'])) {
                                         $output = sprintf(__('%1$s - %2$s'), $output, $data['otherserial']);
                                     }
                                     $tmp_device .= "<option title=\"{$output}\" value='" . $itemtype . "_" . $data["id"] . "' " . ($my_item == $itemtype . "_" . $data["id"] ? "selected" : "") . ">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
                                     $already_add[$itemtype][] = $data["id"];
                                 }
                             }
                         }
                     }
                 }
                 if (!empty($tmp_device)) {
                     $my_devices .= "<optgroup label=\"" . __s('Devices own by my groups') . "\">" . $tmp_device . "</optgroup>";
                 }
             }
         }
         // Get linked items to computers
         if (isset($already_add['Computer']) && count($already_add['Computer'])) {
             $search_computer = " XXXX IN (" . implode(',', $already_add['Computer']) . ') ';
             $tmp_device = "";
             // Direct Connection
             $types = array('Monitor', 'Peripheral', 'Phone', 'Printer');
             foreach ($types as $itemtype) {
                 if (in_array($itemtype, $_SESSION["glpiactiveprofile"]["helpdesk_item_type"]) && ($item = getItemForItemtype($itemtype))) {
                     $itemtable = getTableForItemType($itemtype);
                     if (!isset($already_add[$itemtype])) {
                         $already_add[$itemtype] = array();
                     }
                     $query = "SELECT DISTINCT `{$itemtable}`.*\n                            FROM `glpi_computers_items`\n                            LEFT JOIN `{$itemtable}`\n                                 ON (`glpi_computers_items`.`items_id` = `{$itemtable}`.`id`)\n                            WHERE `glpi_computers_items`.`itemtype` = '{$itemtype}'\n                                  AND  " . str_replace("XXXX", "`glpi_computers_items`.`computers_id`", $search_computer);
                     if ($item->maybeDeleted()) {
                         $query .= " AND `{$itemtable}`.`is_deleted` = '0' ";
                     }
                     if ($item->maybeTemplate()) {
                         $query .= " AND `{$itemtable}`.`is_template` = '0' ";
                     }
                     $query .= getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict) . "\n                            ORDER BY `{$itemtable}`.`name`";
                     $result = $DB->query($query);
                     if ($DB->numrows($result) > 0) {
                         $type_name = $item->getTypeName();
                         while ($data = $DB->fetch_assoc($result)) {
                             if (!in_array($data["id"], $already_add[$itemtype])) {
                                 $output = $data["name"];
                                 if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
                                     $output = sprintf(__('%1$s (%2$s)'), $output, $data['id']);
                                 }
                                 $output = sprintf(__('%1$s - %2$s'), $type_name, $output);
                                 if ($itemtype != 'Software') {
                                     $output = sprintf(__('%1$s - %2$s'), $output, $data['otherserial']);
                                 }
                                 $tmp_device .= "<option title=\"{$output}\" value='" . $itemtype . "_" . $data["id"] . "' " . ($my_item == $itemtype . "_" . $data["id"] ? "selected" : "") . ">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
                                 $already_add[$itemtype][] = $data["id"];
                             }
                         }
                     }
                 }
             }
             if (!empty($tmp_device)) {
                 $my_devices .= "<optgroup label=\"" . __s('Connected devices') . "\">" . $tmp_device . "</optgroup>";
             }
             // Software
             if (in_array('Software', $_SESSION["glpiactiveprofile"]["helpdesk_item_type"])) {
                 $query = "SELECT DISTINCT `glpi_softwareversions`.`name` AS version,\n                                `glpi_softwares`.`name` AS name, `glpi_softwares`.`id`\n                         FROM `glpi_computers_softwareversions`, `glpi_softwares`,\n                              `glpi_softwareversions`\n                         WHERE `glpi_computers_softwareversions`.`softwareversions_id` =\n                                   `glpi_softwareversions`.`id`\n                               AND `glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`\n                               AND " . str_replace("XXXX", "`glpi_computers_softwareversions`.`computers_id`", $search_computer) . "\n                               AND `glpi_softwares`.`is_helpdesk_visible` = '1' " . getEntitiesRestrictRequest("AND", "glpi_softwares", "", $entity_restrict) . "\n                         ORDER BY `glpi_softwares`.`name`";
                 $result = $DB->query($query);
                 if ($DB->numrows($result) > 0) {
                     $tmp_device = "";
                     $item = new Software();
                     $type_name = $item->getTypeName();
                     if (!isset($already_add['Software'])) {
                         $already_add['Software'] = array();
                     }
                     while ($data = $DB->fetch_assoc($result)) {
                         if (!in_array($data["id"], $already_add['Software'])) {
                             $output = sprintf(__('%1$s - %2$s'), $type_name, $data["name"]);
                             $output = sprintf(__('%1$s (%2$s)'), $output, sprintf(__('%1$s: %2$s'), __('version'), $data["version"]));
                             if ($_SESSION["glpiis_ids_visible"]) {
                                 $output = sprintf(__('%1$s (%2$s)'), $output, $data["id"]);
                             }
                             $tmp_device .= "<option title=\"{$output}\" value='Software_" . $data["id"] . "' " . ($my_item == 'Software' . "_" . $data["id"] ? "selected" : "") . ">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
                             $already_add['Software'][] = $data["id"];
                         }
                     }
                     if (!empty($tmp_device)) {
                         $my_devices .= "<optgroup label=\"" . _sn('Installed software', 'Installed software', 2) . "\">";
                         $my_devices .= $tmp_device . "</optgroup>";
                     }
                 }
             }
         }
         echo "<div id='tracking_my_devices'>";
         echo "<select id='my_items' name='_my_items'>";
         echo "<option value=''>--- ";
         echo __('General') . " ---</option>{$my_devices}</select></div>";
         // Auto update summary of active or just solved tickets
         $params = array('my_items' => '__VALUE__');
         Ajax::updateItemOnSelectEvent("my_items", "item_ticket_selection_information", $CFG_GLPI["root_doc"] . "/ajax/ticketiteminformation.php", $params);
     }
 }
Esempio n. 4
0
 /**
  * Display massive actions
  *
  * @since 0.84 (before Search::displayMassiveActions)
  *
  * @param $itemtype  string itemtype for massive actions
  * @param $options   array    of parameters
  * may contains :
  *    - num_displayed   : integer number of displayed items. Permit to check suhosin limit. (default -1 not to check)
  *    - ontop           : boolean true if displayed on top (default true)
  *    - fixed           : boolean true if used with fixed table display (default true)
  *    - forcecreate     : boolean force creation of modal window (default = false).
  *            Modal is automatically created when displayed the ontop item.
  *            If only a bottom one is displayed use it
  *    - check_itemtype   : string alternate itemtype to check right if different from main itemtype (default empty)
  *    - check_items_id   : integer ID of the alternate item used to check right / optional (default empty)
  *    - is_deleted       : boolean is massive actions for deleted items ?
  *    - extraparams      : string extra URL parameters to pass to massive actions (default empty)
  *    - specific_actions : array of specific actions (do not use standard one)
  *    - confirm          : string of confirm message before massive action
  *
  * @return nothing
  **/
 static function showMassiveActions($itemtype, $options = array())
 {
     global $CFG_GLPI;
     $p['ontop'] = true;
     $p['num_displayed'] = -1;
     $p['fixed'] = true;
     $p['forcecreate'] = false;
     $p['check_itemtype'] = '';
     $p['check_items_id'] = '';
     $p['is_deleted'] = false;
     $p['extraparams'] = array();
     $p['width'] = 800;
     $p['height'] = 400;
     $p['specific_actions'] = array();
     $p['confirm'] = '';
     $p['rand'] = '';
     foreach ($options as $key => $val) {
         if (isset($p[$key])) {
             $p[$key] = $val;
         }
     }
     $p['extraparams']['itemtype'] = $itemtype;
     $url = $CFG_GLPI['root_doc'] . "/ajax/massiveaction.php";
     if ($p['is_deleted']) {
         $p['extraparams']['is_deleted'] = 1;
     }
     if (!empty($p['check_itemtype'])) {
         $p['extraparams']['check_itemtype'] = $p['check_itemtype'];
     }
     if (!empty($p['check_items_id'])) {
         $p['extraparams']['check_items_id'] = $p['check_items_id'];
     }
     if (is_array($p['specific_actions']) && count($p['specific_actions'])) {
         $p['extraparams']['specific_actions'] = $p['specific_actions'];
     }
     if ($p['fixed']) {
         $width = '950px';
     } else {
         $width = '80%';
     }
     $identifier = md5($url . $itemtype . serialize($p['extraparams']) . $p['rand']);
     $max = Toolbox::get_max_input_vars();
     if ($p['num_displayed'] >= 0 && $max > 0 && $max < $p['num_displayed'] + 10) {
         if (!$p['ontop'] || isset($p['forcecreate']) && $p['forcecreate']) {
             echo "<table class='tab_cadre' width='{$width}'><tr class='tab_bg_1'>" . "<td><span class='b'>";
             echo __('Selection too large, massive action disabled.') . "</span>";
             if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
                 echo "<br>" . __('To increase the limit: change max_input_vars or suhosin.post.max_vars in php configuration.');
             }
             echo "</td></tr></table>";
         }
     } else {
         // Create Modal window on top
         if ($p['ontop'] || isset($p['forcecreate']) && $p['forcecreate']) {
             echo "<div id='massiveactioncontent{$identifier}'></div>";
             //             echo "<script type='text/javascript' >\n";
             //             echo "Ext.DomHelper.append(document.body, {tag: 'div', id: 'massiveactioncontent$identifier'});";
             //             echo "</script>";
             Ajax::createModalWindow('massiveaction_window' . $identifier, $url, array('title' => _n('Action', 'Actions', 2), 'container' => 'massiveactioncontent' . $identifier, 'extraparams' => $p['extraparams'], 'width' => $p['width'], 'height' => $p['height']));
         }
         echo "<table class='tab_glpi' width='{$width}'><tr>";
         echo "<td width='30px'><img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left" . ($p['ontop'] ? '-top' : '') . ".png' alt=''></td>";
         echo "<td width='100%' class='left'>";
         echo "<a class='vsubmit' ";
         if (is_array($p['confirm'] || strlen($p['confirm']))) {
             echo self::addConfirmationOnAction($p['confirm'], "massiveaction_window{$identifier}.show();");
         } else {
             echo "onclick='massiveaction_window{$identifier}.show();'";
         }
         echo "href='#modal_massaction_content{$identifier}' title=\"" . _sn('Action', 'Actions', 2) . "\">";
         echo _n('Action', 'Actions', 2) . "</a>";
         echo "</td>";
         echo "</tr></table>";
         if (!$p['ontop'] || isset($p['forcecreate']) && $p['forcecreate']) {
             // Clean selection
             $_SESSION['glpimassiveactionselected'][$itemtype] = array();
         }
     }
 }
Esempio n. 5
0
}
// Why this test ?? For me it's doing nothing
if (isset($_GET["dropdown"])) {
    $_GET["dropdown"] = $_GET["dropdown"];
}
if (empty($_GET["dropdown"])) {
    $_GET["dropdown"] = "ComputerType";
}
if (!isset($_GET['itemtype'])) {
    $_GET['itemtype'] = 'Ticket';
}
Stat::title();
echo "<form method='get' name='form' action='stat.location.php'>";
echo "<table class='tab_cadre'><tr class='tab_bg_2'><td rowspan='2'>";
echo "<select name='dropdown'>";
echo "<optgroup label=\"" . _sn('Dropdown', 'Dropdowns', 2) . "\">";
echo "<option value='ComputerType' " . ($_GET["dropdown"] == "ComputerType" ? "selected" : "") . ">" . __('Type') . "</option>";
echo "<option value='ComputerModel' " . ($_GET["dropdown"] == "ComputerModel" ? "selected" : "") . ">" . __('Model') . "</option>";
echo "<option value='OperatingSystem' " . ($_GET["dropdown"] == "OperatingSystem" ? "selected" : "") . ">" . __('Operating system') . "</option>";
echo "<option value='Location' " . ($_GET["dropdown"] == "Location" ? "selected" : "") . ">" . __('Location') . "</option>";
echo "</optgroup>";
$devices = Dropdown::getDeviceItemTypes();
foreach ($devices as $label => $dp) {
    echo "<optgroup label=\"{$label}\">";
    foreach ($dp as $i => $name) {
        echo "<option value='{$i}' " . ($_GET["dropdown"] == $i ? "selected" : "") . ">{$name}</option>";
    }
    echo "</optgroup>";
}
echo "</select></td>";
echo "<td class='right'>" . __('Start date') . "</td><td>";
Esempio n. 6
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $LANG;
     if ($item->getType() == 'Profile') {
         return _sn('SIM card', 'SIM cards', 2, 'simcard');
     }
     return '';
 }
Esempio n. 7
0
function plugin_simcard_getAddSearchOptions($itemtype)
{
    global $LANG;
    $sopt = array();
    $reservedTypeIndex = PluginSimcardConfig::RESERVED_TYPE_RANGE_MIN;
    if (in_array($itemtype, PluginSimcardSimcard_Item::getClasses())) {
        if (PluginSimcardSimcard::canView()) {
            $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards';
            $sopt[$reservedTypeIndex]['field'] = 'name';
            $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard') . " - " . __s('Name');
            $sopt[$reservedTypeIndex]['forcegroupby'] = true;
            $sopt[$reservedTypeIndex]['massiveaction'] = false;
            $sopt[$reservedTypeIndex]['datatype'] = 'itemlink';
            $sopt[$reservedTypeIndex]['itemlink_type'] = 'PluginSimcardSimcard';
            $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_simcard_simcards_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $reservedTypeIndex++;
            $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards';
            $sopt[$reservedTypeIndex]['field'] = 'phonenumber';
            $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard') . " - " . __s('Phone number', 'simcard');
            $sopt[$reservedTypeIndex]['massiveaction'] = false;
            $sopt[$reservedTypeIndex]['forcegroupby'] = true;
            $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_simcard_simcards_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $reservedTypeIndex++;
            $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards';
            $sopt[$reservedTypeIndex]['field'] = 'serial';
            $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard') . " - " . __s('IMSI', 'simcard');
            $sopt[$reservedTypeIndex]['massiveaction'] = false;
            $sopt[$reservedTypeIndex]['forcegroupby'] = true;
            $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_simcard_simcards_items', 'joinparams' => array('jointype' => 'itemtype_item')));
        }
    }
    return $sopt;
}
Esempio n. 8
0
 /**
  * @see CommonGLPI::getAdditionalMenuLinks()
  **/
 static function getAdditionalMenuLinks()
 {
     global $CFG_GLPI;
     $links = array();
     if (static::canView() || Session::haveRight('projecttask', ProjectTask::READMY)) {
         $pic_validate = "<img title=\"" . _sn('Task', 'Tasks', 2) . "\" alt=\"" . _sn('Task', 'Tasks', 2) . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' class='pointer'>";
         $links[$pic_validate] = '/front/projecttask.php';
         $links['summary'] = '/front/project.form.php?showglobalgantt=1';
     }
     if (count($links)) {
         return $links;
     }
     return false;
 }
Esempio n. 9
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $LANG;
     if (in_array(get_class($item), PluginSimcardSimcard_Item::getClasses()) || get_class($item) == 'Profile') {
         return array(1 => _sn('SIM card', 'SIM cards', 2, 'simcard'));
     } elseif (get_class($item) == __CLASS__) {
         return _sn('SIM card', 'SIM cards', 2, 'simcard');
     }
     return '';
 }
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $LANG;
     if (in_array(get_class($item), PluginSimcardSimcard_Item::getClasses())) {
         return array(1 => _sn('SIM card', 'SIM cards', 2, 'simcard'));
     } elseif (get_class($item) == 'PluginSimcardSimcard') {
         return _n('Associated item', 'Associated items', 2);
         return _n('connect');
     }
     return '';
 }