getItemTypeSearchURL() статический публичный Метод

Get search URL for itemtype
static public getItemTypeSearchURL ( $itemtype, $full = true )
$itemtype string item type
$full path or relative one (true by default) return string itemtype search URL
Пример #1
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = '/plugins/connections/front/connection.php';
     $menu['links'] = array('add' => Toolbox::getItemTypeFormURL('PluginConnectionsConnection', false), 'search' => Toolbox::getItemTypeSearchURL('PluginConnectionsConnection', false));
     if (Session::haveRight(static::$rightname, READ)) {
         $menu['options']['connections'] = array('title' => self::getMenuName(), 'page' => Toolbox::getItemTypeFormURL('PluginConnectionsConnection', false), 'links' => array('add' => Toolbox::getItemTypeFormURL('PluginConnectionsConnection', false), 'search' => Toolbox::getItemTypeSearchURL('PluginConnectionsConnection', false)));
     }
     return $menu;
 }
 /**
  * Print a good title for group pages
  *
  *@return nothing (display)
  **/
 function title()
 {
     global $CFG_GLPI;
     $buttons = array();
     $title = "";
     if (Session::haveRight(static::$rightname, UPDATE)) {
         $url = Toolbox::getItemTypeSearchURL('PluginDatainjectionModel');
         $buttons[$url] = PluginDatainjectionModel::getTypeName();
         $title = "";
         Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/datainjection/pics/datainjection.png", PluginDatainjectionModel::getTypeName(), $title, $buttons);
     }
 }
Пример #3
0
 static function showForItemtype($type)
 {
     global $DB;
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     echo "<form action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     $itemtype = $type->fields['itemtype'];
     echo "<tr><th colspan='2' align='center'><strong>";
     echo __("Rights assignment") . ":&nbsp;";
     echo $itemtype::getTypeName();
     echo "</strong></th></tr>";
     foreach (getAllDatasFromTable('glpi_profiles') as $profile) {
         echo "<tr><th colspan='2' align='center'><strong>";
         echo __("Profile") . " " . $profile['name'] . "</strong></th></tr>";
         $pgf_find = self::getProfileforItemtype($profile['id'], $itemtype);
         if (!count($pgf_find) > 0) {
             self::createAccess($profile['id']);
             $pgf_find = self::getProfileforItemtype($profile['id'], $itemtype);
         }
         $PluginGenericobjectProfile = new self();
         $PluginGenericobjectProfile->getFromDB($pgf_find['id']);
         $prefix = "profiles[" . $pgf_find['id'] . "]";
         if ($profile['interface'] == 'central') {
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . __("Access object", "genericobject") . ":</td><td>";
             Profile::dropdownNoneReadWrite($prefix . "[right]", $PluginGenericobjectProfile->fields['right'], 1, 1, 1);
             echo "</td></tr>";
         }
         if ($type->canUseTickets()) {
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . __("Associate tickets to this object", "genericobject") . ":</td><td>";
             Dropdown::showYesNo($prefix . "[open_ticket]", $PluginGenericobjectProfile->fields['open_ticket']);
             echo "</td></tr>";
         }
     }
     if ($canedit) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center' colspan='2'>";
         echo "<input type='submit' name='update_all_rights' value=\"" . _sx('button', 'Post') . "\" class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Пример #4
0
function plugin_init_genericobject()
{
    global $PLUGIN_HOOKS, $CFG_GLPI, $GO_BLACKLIST_FIELDS, $GO_FIELDS, $GENERICOBJECT_PDF_TYPES, $GO_LINKED_TYPES, $GO_READONLY_FIELDS;
    $GO_READONLY_FIELDS = array("is_helpdesk_visible", "comment");
    $GO_BLACKLIST_FIELDS = array("itemtype", "table", "is_deleted", "id", "entities_id", "is_recursive", "is_template", "notepad", "template_name", "date_mod", "name", "is_helpdesk_visible", "comment");
    $GO_LINKED_TYPES = array('Computer', 'Phone', 'Peripheral', 'Software', 'Monitor', 'Printer', 'NetworkEquipment');
    $PLUGIN_HOOKS['csrf_compliant']['genericobject'] = true;
    $GENERICOBJECT_PDF_TYPES = array();
    $plugin = new Plugin();
    if ($plugin->isInstalled("genericobject") && $plugin->isActivated("genericobject")) {
        plugin_genericobject_includeCommonFields();
        $PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1;
        /* load changeprofile function */
        $PLUGIN_HOOKS['change_profile']['genericobject'] = array('PluginGenericobjectProfile', 'changeProfile');
        // Display a menu entry ?
        $PLUGIN_HOOKS['menu_entry']['genericobject'] = true;
        //Do not display icon if not using the genericobject plugin
        if (isset($_GET['id']) && $_GET['id'] != '' && strpos($_SERVER['REQUEST_URI'], Toolbox::getItemTypeFormURL("PluginGenericobjectType")) !== false) {
            $url = '/plugins/genericobject/index.php';
            $type = new PluginGenericobjectType();
            $type->getFromDB($_GET['id']);
            if ($type->fields['is_active']) {
                $url .= '?itemtypes_id=' . $_GET['id'];
                $image = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/stats_item.png' title=\"" . __("Go to objects list", "genericobject") . "\" alt=\"" . __("Go to objects list", "genericobject") . "\">";
                $PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links'][$image] = $url;
            }
        }
        $PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links']['add'] = Toolbox::getItemTypeFormURL('PluginGenericobjectType', false);
        $PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links']['search'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType', false);
        // Config page
        if (Session::haveRight('config', 'w')) {
            $PLUGIN_HOOKS['submenu_entry']['genericobject']['config'] = 'front/type.php';
            $PLUGIN_HOOKS['config_page']['genericobject'] = 'front/type.php';
            $PLUGIN_HOOKS['submenu_entry']['genericobject']['add']['type'] = 'front/type.form.php';
            $PLUGIN_HOOKS['submenu_entry']['genericobject']['search']['type'] = 'front/type.php';
        }
        $PLUGIN_HOOKS['assign_to_ticket']['genericobject'] = true;
        $PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1;
        $PLUGIN_HOOKS['post_init']['genericobject'] = 'plugin_post_init_genericobject';
        $PLUGIN_HOOKS['plugin_datainjection_populate']['genericobject'] = "plugin_datainjection_populate_genericobject";
    }
}
Пример #5
0
 /**
  * @param $tt           TicketTemplate object
  * @param $withtemplate (default '')
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $itilcategory = new self();
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) {
         return false;
     }
     $ttm = new self();
     $rand = mt_rand();
     echo "<div class='center'>";
     $query = "SELECT `glpi_itilcategories`.*\n                FROM `glpi_itilcategories`\n                WHERE (`tickettemplates_id_incident` = '{$ID}')\n                       OR (`tickettemplates_id_demand` = '{$ID}')\n                ORDER BY `name`";
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='3'>";
         echo "<a href='" . Toolbox::getItemTypeSearchURL($itilcategory->getType()) . "'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</a>";
         echo "</th></tr>";
         $used_incident = array();
         $used_demand = array();
         if ($DB->numrows($result)) {
             echo "<th>" . __('Name') . "</th>";
             echo "<th>" . __('Incident') . "</th>";
             echo "<th>" . __('Request') . "</th>";
             echo "</tr>";
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'>";
                 $itilcategory->getFromDB($data['id']);
                 echo "<td>" . $itilcategory->getLink(array('comments' => true)) . "</td>";
                 if ($data['tickettemplates_id_incident'] == $ID) {
                     echo "<td class='center'>\n                        <img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' alt=\"" . __('OK') . "\" width='14' height='14'>\n                        </td>";
                     $used_incident[] = $data["id"];
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($data['tickettemplates_id_demand'] == $ID) {
                     echo "<td class='center'>\n                        <img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' alt=\"" . __('OK') . "\" width='14' height='14'>\n                        </td>";
                     $used_demand[] = $data["id"];
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
             }
         } else {
             echo "<tr><th colspan='3'>" . __('No item found') . "</th></tr>";
         }
         echo "</table></div>";
     }
 }
Пример #6
0
 static function showMinimalList($params = array())
 {
     global $DB, $CFG_GLPI;
     $item = new self();
     $itemtype = $item->getType();
     $itemtable = $item->getTable();
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['id'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     $p['withtemplate'] = 0;
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $PluginResourcesResource = new PluginResourcesResource();
     $PluginResourcesResource->getFromDB($p['id']);
     $canedit = $PluginResourcesResource->can($p['id'], 'w');
     if (isset($_POST["start"])) {
         $p['start'] = $_POST["start"];
     } else {
         $p['start'] = 0;
     }
     if (isset($_POST["sort"])) {
         $p['sort'] = $_POST["sort"];
     } else {
         $p['sort'] = 1;
     }
     if (isset($_POST["order"]) && $_POST["order"] == "DESC") {
         $p['order'] = "DESC";
     } else {
         $p['order'] = "ASC";
     }
     // Manage defautll seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     $target = Toolbox::getItemTypeSearchURL($itemtype);
     $limitsearchopt = Search::getCleanedOptions($itemtype);
     $LIST_LIMIT = $_SESSION['glpilist_limit'];
     // Set display type for export if define
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == Search::GLOBAL_SEARCH) {
             $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT;
         }
     }
     $entity_restrict = $item->isEntityAssign();
     // Get the items to display
     $toview = Search::addDefaultToView($itemtype);
     // Add items to display depending of personal prefs
     $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID());
     if (count($displaypref)) {
         foreach ($displaypref as $val) {
             array_push($toview, $val);
         }
     }
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
     // Add order item
     if (!in_array($p['sort'], $toview)) {
         array_push($toview, $p['sort']);
     }
     // Clean toview array
     $toview = array_unique($toview);
     foreach ($toview as $key => $val) {
         if (!isset($limitsearchopt[$val])) {
             unset($toview[$key]);
         }
     }
     $toview_count = count($toview);
     //// 1 - SELECT
     $query = "SELECT " . Search::addDefaultSelect($itemtype);
     // Add select for all toview item
     foreach ($toview as $key => $val) {
         $query .= Search::addSelect($itemtype, $val, $key, 0);
     }
     $query .= "`" . $itemtable . "`.`id` AS id ";
     //// 2 - FROM AND LEFT JOIN
     // Set reference table
     $query .= " FROM `" . $itemtable . "`";
     // Init already linked tables array in order not to link a table several times
     $already_link_tables = array();
     // Put reference table
     array_push($already_link_tables, $itemtable);
     // Add default join
     $COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables);
     $query .= $COMMONLEFTJOIN;
     $searchopt = array();
     $searchopt[$itemtype] =& Search::getOptions($itemtype);
     // Add all table for toview items
     foreach ($toview as $key => $val) {
         $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]);
     }
     // Search all case :
     if (in_array("all", $p['field'])) {
         foreach ($searchopt[$itemtype] as $key => $val) {
             // Do not search on Group Name
             if (is_array($val)) {
                 $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]);
             }
         }
     }
     $query .= " WHERE `" . $itemtable . "`.`plugin_resources_resources_id` = '" . $p['id'] . "'";
     $query .= " AND `" . $itemtable . "`.`is_deleted` = '" . $p['is_deleted'] . "' ";
     //// 7 - Manage GROUP BY
     $GROUPBY = "";
     // Meta Search / Search All / Count tickets
     if (in_array('all', $p['field'])) {
         $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
     }
     if (empty($GROUPBY)) {
         foreach ($toview as $key2 => $val2) {
             if (!empty($GROUPBY)) {
                 break;
             }
             if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) {
                 $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
             }
         }
     }
     $query .= $GROUPBY;
     //// 4 - ORDER
     $ORDER = " ORDER BY `id` ";
     foreach ($toview as $key => $val) {
         if ($p['sort'] == $val) {
             $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key);
         }
     }
     $query .= $ORDER;
     // Get it from database
     if ($result = $DB->query($query)) {
         $numrows = $DB->numrows($result);
         $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']);
         $parameters = "sort=" . $p['sort'] . "&amp;order=" . $p['order'] . $globallinkto;
         if ($output_type == Search::GLOBAL_SEARCH) {
             if (class_exists($itemtype)) {
                 echo "<div class='center'><h2>" . $item->getTypeName();
                 // More items
                 if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) {
                     echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>";
                 }
                 echo "</h2></div>\n";
             } else {
                 return false;
             }
         }
         if ($p['start'] < $numrows) {
             if ($output_type == Search::HTML_OUTPUT && !$p['withtemplate']) {
                 echo "<div align='center'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?contains%5B0%5D=" . $p['id'] . "&field%5B0%5D=13&sort=1&is_deleted=0&start=0'>" . _x('button', 'Search') . "</a><br>";
                 echo "</div>";
             }
             // Pager
             if ($output_type == Search::HTML_OUTPUT) {
                 // HTML display - massive modif
                 $search_config = "";
                 if ($item->canCreate() && $canedit) {
                     $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&amp;itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\"";
                     $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' ";
                     $search_config .= $tmp . ">";
                 }
                 //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']);
             }
             // Pager
             if ($output_type == Search::HTML_OUTPUT) {
                 Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows, $search_config);
                 echo "<br>";
             }
             // Define begin and end var for loop
             // Search case
             $begin_display = $p['start'];
             $end_display = $p['start'] + $LIST_LIMIT;
             // Export All case
             if ($p['export_all']) {
                 $begin_display = 0;
                 $end_display = $numrows;
             }
             //massive action
             $sel = "";
             if (isset($_GET["select"]) && $_GET["select"] == "all") {
                 $sel = "checked";
             }
             if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) {
                 Html::openMassiveActionsForm('massform' . $itemtype);
                 $massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => true, 'is_deleted' => $p['is_deleted']);
                 Html::showMassiveActions($itemtype, $massiveactionparams);
             }
             // Add toview elements
             $nbcols = $toview_count;
             if ($output_type == Search::HTML_OUTPUT) {
                 // HTML display - massive modif
                 $nbcols++;
             }
             // Display List Header
             echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols, 1);
             $header_num = 1;
             // Display column Headers for toview items
             $headers_line = '';
             $headers_line_top = '';
             $headers_line_bottom = '';
             echo Search::showNewLine($output_type);
             if ($output_type == Search::HTML_OUTPUT && $item->canCreate() && $canedit) {
                 // HTML display - massive modif
                 $headers_line_top .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']);
                 $headers_line_bottom .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']);
             }
             // Display column Headers for toview items
             foreach ($toview as $key => $val) {
                 $linkto = '';
                 if (!isset($searchopt[$itemtype][$val]['nosort']) || !$searchopt[$itemtype][$val]['nosort']) {
                     $linkto = "javascript:reloadTab('sort=" . $val . "&amp;order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&amp;start=" . $p['start'] . $globallinkto . "')";
                 }
                 $headers_line .= Search::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']);
             }
             // End Line for column headers
             $headers_line .= Search::showEndLine($output_type);
             $headers_line_top .= $headers_line;
             $headers_line_bottom .= $headers_line;
             echo $headers_line_top;
             $DB->data_seek($result, $p['start']);
             // Define begin and end var for loop
             // Search case
             $i = $begin_display;
             // Init list of items displayed
             if ($output_type == Search::HTML_OUTPUT) {
                 Session::initNavigateListItems($itemtype, PluginResourcesResource::getTypeName(2) . " = " . (empty($PluginResourcesResource->fields['name']) ? "(" . $p['id'] . ")" : $PluginResourcesResource->fields['name']));
             }
             // Num of the row (1=header_line)
             $row_num = 1;
             // Display Loop
             while ($i < $numrows && $i < $end_display) {
                 $item_num = 1;
                 $data = $DB->fetch_array($result);
                 $i++;
                 $row_num++;
                 echo Search::showNewLine($output_type, $i % 2);
                 Session::addToNavigateListItems($itemtype, $data['id']);
                 $tmpcheck = "";
                 if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) {
                     $sel = "";
                     $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>";
                 }
                 echo Search::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'");
                 foreach ($toview as $key => $val) {
                     echo Search::showItem($output_type, Search::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, Search::displayConfigItem($itemtype, $val, $data, $key));
                 }
                 echo Search::showEndLine($output_type);
             }
             // Close Table
             $title = "";
             // Create title
             if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
                 $title .= __('Tasks list', 'resources');
             }
             // Display footer
             echo Search::showFooter($output_type, $title);
             //massive action
             if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) {
                 $massiveactionparams['ontop'] = false;
                 Html::showMassiveActions($itemtype, $massiveactionparams);
                 Html::closeForm();
             } else {
                 echo "</table></div>";
             }
             // Pager
             if ($output_type == Search::HTML_OUTPUT) {
                 echo "<br>";
                 Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows);
             }
         } else {
             echo Search::showError($output_type);
         }
     }
 }
Пример #7
0
 /**
  * Get the search page URL for the current class
  *
  * @param $full path or relative one (true by default)
  **/
 static function getSearchURL($full = true)
 {
     return Toolbox::getItemTypeSearchURL(get_called_class(), $full);
 }
Пример #8
0
 /**
  * Print out list kb item
  *
  * @param $options            $_GET
  * @param $type      string   search type : browse / search (default search)
  **/
 static function showList($options, $type = 'search')
 {
     global $DB, $CFG_GLPI;
     // Default values of parameters
     $params['faq'] = !Session::haveRight(self::$rightname, READ);
     $params["start"] = "0";
     $params["knowbaseitemcategories_id"] = "0";
     $params["contains"] = "";
     $params["target"] = $_SERVER['PHP_SELF'];
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $ki = new self();
     switch ($type) {
         case 'myunpublished':
             if (!Session::haveRightsOr(self::$rightname, array(UPDATE, self::PUBLISHFAQ))) {
                 return false;
             }
             break;
         case 'allunpublished':
             if (!Session::haveRight(self::$rightname, self::KNOWBASEADMIN)) {
                 return false;
             }
             break;
         default:
             break;
     }
     if (!$params["start"]) {
         $params["start"] = 0;
     }
     $query = self::getListRequest($params, $type);
     // Get it from database
     if ($result = $DB->query($query)) {
         $KbCategory = new KnowbaseItemCategory();
         $title = "";
         if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) {
             $title = empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name'];
             $title = sprintf(__('%1$s: %2$s'), __('Category'), $title);
         }
         Session::initNavigateListItems('KnowbaseItem', $title);
         $numrows = $DB->numrows($result);
         $list_limit = $_SESSION['glpilist_limit'];
         $showwriter = in_array($type, array('myunpublished', 'allunpublished', 'allmy'));
         // Limit the result, if no limit applies, use prior result
         if ($numrows > $list_limit && !isset($_GET['export_all'])) {
             $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " ";
             $result_limit = $DB->query($query_limit);
             $numrows_limit = $DB->numrows($result_limit);
         } else {
             $numrows_limit = $numrows;
             $result_limit = $result;
         }
         if ($numrows_limit > 0) {
             // Set display type for export if define
             $output_type = Search::HTML_OUTPUT;
             if (isset($_GET["display_type"])) {
                 $output_type = $_GET["display_type"];
             }
             // Pager
             $parameters = "start=" . $params["start"] . "&amp;knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&amp;contains=" . $params["contains"] . "&amp;is_faq=" . $params['faq'];
             if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
                 $parameters .= "&amp;item_items_id=" . $options['item_items_id'] . "&amp;item_itemtype=" . $options['item_itemtype'];
             }
             if ($output_type == Search::HTML_OUTPUT) {
                 Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
             }
             $nbcols = 1;
             // Display List Header
             echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols);
             echo Search::showNewLine($output_type);
             $header_num = 1;
             echo Search::showHeaderItem($output_type, __('Subject'), $header_num);
             if ($output_type != Search::HTML_OUTPUT) {
                 echo Search::showHeaderItem($output_type, __('Content'), $header_num);
             }
             if ($showwriter) {
                 echo Search::showHeaderItem($output_type, __('Writer'), $header_num);
             }
             echo Search::showHeaderItem($output_type, __('Category'), $header_num);
             if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
                 echo Search::showHeaderItem($output_type, '&nbsp;', $header_num);
             }
             // Num of the row (1=header_line)
             $row_num = 1;
             for ($i = 0; $i < $numrows_limit; $i++) {
                 $data = $DB->fetch_assoc($result_limit);
                 Session::addToNavigateListItems('KnowbaseItem', $data["id"]);
                 // Column num
                 $item_num = 1;
                 $row_num++;
                 echo Search::showNewLine($output_type, $i % 2);
                 $item = new self();
                 $item->getFromDB($data["id"]);
                 $name = $data["name"];
                 $answer = $data["answer"];
                 // Manage translations
                 if (isset($data['transname']) && !empty($data['transname'])) {
                     $name = $data["transname"];
                 }
                 if (isset($data['transanswer']) && !empty($data['transanswer'])) {
                     $answer = $data["transanswer"];
                 }
                 if ($output_type == Search::HTML_OUTPUT) {
                     $toadd = '';
                     if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
                         $href = " href='#' onClick=\"" . Html::jsGetElementbyID('kbshow' . $data["id"]) . ".dialog('open');\"";
                         $toadd = Ajax::createIframeModalWindow('kbshow' . $data["id"], $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=" . $data["id"], array('display' => false));
                     } else {
                         $href = " href=\"" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\" ";
                     }
                     echo Search::showItem($output_type, "<div class='kb'>{$toadd}<a " . ($data['is_faq'] ? " class='pubfaq' title='" . __("This item is part of the FAQ") . "' " : " class='knowbase' ") . " {$href}>" . Html::resume_text($name, 80) . "</a></div>\n                                          <div class='kb_resume'>" . Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($answer)), 600) . "</div>", $item_num, $row_num);
                 } else {
                     echo Search::showItem($output_type, $name, $item_num, $row_num);
                     echo Search::showItem($output_type, Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($answer, ENT_QUOTES, "UTF-8"))), $item_num, $row_num);
                 }
                 $showuserlink = 0;
                 if (Session::haveRight('user', READ)) {
                     $showuserlink = 1;
                 }
                 if ($showwriter) {
                     echo Search::showItem($output_type, getUserName($data["users_id"], $showuserlink), $item_num, $row_num);
                 }
                 $categ = $data["category"];
                 if ($output_type == Search::HTML_OUTPUT) {
                     $cathref = $ki->getSearchURL() . "?knowbaseitemcategories_id=" . $data["knowbaseitemcategories_id"] . '&amp;forcetab=Knowbase$2';
                     $categ = "<a href='{$cathref}'>" . $categ . '</a>';
                 }
                 echo Search::showItem($output_type, $categ, $item_num, $row_num);
                 if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
                     $forcetab = $options['item_itemtype'];
                     if (!$_SESSION['glpiticket_timeline'] || $_SESSION['glpiticket_timeline_keep_replaced_tabs']) {
                         $forcetab .= '$2';
                         //Solution tab
                     } else {
                         $forcetab .= '$1';
                         //Timeline tab
                     }
                     $content = "<a href='" . Toolbox::getItemTypeFormURL($options['item_itemtype']) . "?load_kb_sol=" . $data['id'] . "&amp;id=" . $options['item_items_id'] . "&amp;forcetab=" . $forcetab . "'>" . __('Use as a solution') . "</a>";
                     echo Search::showItem($output_type, $content, $item_num, $row_num);
                 }
                 // End Line
                 echo Search::showEndLine($output_type);
             }
             // Display footer
             if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) {
                 echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id']));
             } else {
                 echo Search::showFooter($output_type);
             }
             echo "<br>";
             if ($output_type == Search::HTML_OUTPUT) {
                 Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
             }
         } else {
             echo "<div class='center b'>" . __('No item found') . "</div>";
         }
     }
 }
 public function submitForm($postvars)
 {
     if (isset($postvars['forcestart'])) {
         Session::checkRight('plugin_fusioninventory_task', UPDATE);
         /**
          * TODO: forcing the task execution should be done in the task object
          */
         $pfTaskjob = new PluginFusioninventoryTaskjob();
         $pfTaskjob->forceRunningTask($postvars['id']);
         Html::back();
     } else {
         if (isset($postvars["add"])) {
             Session::checkRight('plugin_fusioninventory_task', CREATE);
             $items_id = $this->add($postvars);
             Html::redirect(str_replace("add=1", "", $_SERVER['HTTP_REFERER']) . "?id=" . $items_id);
         } else {
             if (isset($postvars["purge"])) {
                 Session::checkRight('plugin_fusioninventory_task', PURGE);
                 $pfTaskJob = new PluginFusioninventoryTaskjob();
                 $taskjobs = $pfTaskJob->find("`plugin_fusioninventory_tasks_id` = '" . $postvars['id'] . "' ");
                 foreach ($taskjobs as $taskjob) {
                     $pfTaskJob->delete($taskjob);
                 }
                 $this->delete($postvars);
                 Html::redirect(Toolbox::getItemTypeSearchURL(get_class($this)));
             } else {
                 if (isset($_POST["update"])) {
                     Session::checkRight('plugin_fusioninventory_task', UPDATE);
                     $this->getFromDB($postvars['id']);
                     //Ensure empty value are set to NULL for datetime fields
                     if (isset($postvars['datetime_start']) and $postvars['datetime_start'] === '') {
                         $postvars['datetime_start'] = 'NULL';
                     }
                     if (isset($postvars['datetime_end']) and $postvars['datetime_end'] === '') {
                         $postvars['datetime_end'] = 'NULL';
                     }
                     $this->update($postvars);
                     Html::back();
                 }
             }
         }
     }
 }
Пример #10
0
 /**
  *  @see CommonGLPI::getMenuContent()
  *
  *  @since version 0.85
  **/
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     if (Session::haveRight("rule_ldap", READ) || Session::haveRight("rule_ocs", READ) || Session::haveRight("entity_rule_ticket", READ) || Session::haveRight("rule_softwarecategories", READ) || Session::haveRight("rule_mailcollector", READ)) {
         $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['rule']['page'] = static::getSearchURL(false);
         foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
             $rulecollection = new $rulecollectionclass();
             if ($rulecollection->canList()) {
                 $ruleclassname = $rulecollection->getRuleClassName();
                 $menu['rule']['options'][$rulecollection->menu_option]['title'] = $rulecollection->getRuleClass()->getTitle();
                 $menu['rule']['options'][$rulecollection->menu_option]['page'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                 $menu['rule']['options'][$rulecollection->menu_option]['links']['search'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                 if ($rulecollection->canCreate()) {
                     $menu['rule']['options'][$rulecollection->menu_option]['links']['add'] = Toolbox::getItemTypeFormURL($ruleclassname, false);
                 }
             }
         }
     }
     if (Transfer::canView() && Session::isMultiEntitiesMode()) {
         $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['rule']['page'] = static::getSearchURL(false);
         $menu['rule']['options']['transfer']['title'] = __('Transfer');
         $menu['rule']['options']['transfer']['page'] = "/front/transfer.php";
         $menu['rule']['options']['transfer']['links']['search'] = "/front/transfer.php";
         if (Session::haveRightsOr("transfer", array(CREATE, UPDATE))) {
             $menu['rule']['options']['transfer']['links']['summary'] = "/front/transfer.action.php";
             $menu['rule']['options']['transfer']['links']['add'] = "/front/transfer.form.php";
         }
     }
     if (Session::haveRight("rule_dictionnary_dropdown", READ) || Session::haveRight("rule_dictionnary_software", READ) || Session::haveRight("rule_dictionnary_printer", READ)) {
         $menu['dictionnary']['title'] = _n('Dictionary', 'Dictionaries', Session::getPluralNumber());
         $menu['dictionnary']['shortcut'] = '';
         $menu['dictionnary']['page'] = '/front/dictionnary.php';
         $menu['dictionnary']['options']['manufacturers']['title'] = _n('Manufacturer', 'Manufacturers', Session::getPluralNumber());
         $menu['dictionnary']['options']['manufacturers']['page'] = '/front/ruledictionnarymanufacturer.php';
         $menu['dictionnary']['options']['manufacturers']['links']['search'] = '/front/ruledictionnarymanufacturer.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['manufacturers']['links']['add'] = '/front/ruledictionnarymanufacturer.form.php';
         }
         $menu['dictionnary']['options']['software']['title'] = _n('Software', 'Software', Session::getPluralNumber());
         $menu['dictionnary']['options']['software']['page'] = '/front/ruledictionnarysoftware.php';
         $menu['dictionnary']['options']['software']['links']['search'] = '/front/ruledictionnarysoftware.php';
         if (RuleDictionnarySoftware::canCreate()) {
             $menu['dictionnary']['options']['software']['links']['add'] = '/front/ruledictionnarysoftware.form.php';
         }
         $menu['dictionnary']['options']['model.computer']['title'] = _n('Computer model', 'Computer models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.computer']['page'] = '/front/ruledictionnarycomputermodel.php';
         $menu['dictionnary']['options']['model.computer']['links']['search'] = '/front/ruledictionnarycomputermodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.computer']['links']['add'] = '/front/ruledictionnarycomputermodel.form.php';
         }
         $menu['dictionnary']['options']['model.monitor']['title'] = _n('Monitor model', 'Monitor models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.monitor']['page'] = '/front/ruledictionnarymonitormodel.php';
         $menu['dictionnary']['options']['model.monitor']['links']['search'] = '/front/ruledictionnarymonitormodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.monitor']['links']['add'] = '/front/ruledictionnarymonitormodel.form.php';
         }
         $menu['dictionnary']['options']['model.printer']['title'] = _n('Printer model', 'Printer models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.printer']['page'] = '/front/ruledictionnaryprintermodel.php';
         $menu['dictionnary']['options']['model.printer']['links']['search'] = '/front/ruledictionnaryprintermodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.printer']['links']['add'] = '/front/ruledictionnaryprintermodel.form.php';
         }
         $menu['dictionnary']['options']['model.peripheral']['title'] = _n('Peripheral model', 'Peripheral models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.peripheral']['page'] = '/front/ruledictionnaryperipheralmodel.php';
         $menu['dictionnary']['options']['model.peripheral']['links']['search'] = '/front/ruledictionnaryperipheralmodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.peripheral']['links']['add'] = '/front/ruledictionnaryperipheralmodel.form.php';
         }
         $menu['dictionnary']['options']['model.networking']['title'] = _n('Networking equipment model', 'Networking equipment models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.networking']['page'] = '/front/ruledictionnarynetworkequipmentmodel.php';
         $menu['dictionnary']['options']['model.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmentmodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmentmodel.form.php';
         }
         $menu['dictionnary']['options']['model.phone']['title'] = _n('Phone model', 'Phone models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.phone']['page'] = '/front/ruledictionnaryphonemodel.php';
         $menu['dictionnary']['options']['model.phone']['links']['search'] = '/front/ruledictionnaryphonemodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.phone']['links']['add'] = '/front/ruledictionnaryphonemodel.form.php';
         }
         $menu['dictionnary']['options']['type.computer']['title'] = _n('Computer type', 'Computer types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.computer']['page'] = '/front/ruledictionnarycomputertype.php';
         $menu['dictionnary']['options']['type.computer']['links']['search'] = '/front/ruledictionnarycomputertype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.computer']['links']['add'] = '/front/ruledictionnarycomputertype.form.php';
         }
         $menu['dictionnary']['options']['type.monitor']['title'] = _n('Monitor type', 'Monitors types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.monitor']['page'] = '/front/ruledictionnarymonitortype.php';
         $menu['dictionnary']['options']['type.monitor']['links']['search'] = '/front/ruledictionnarymonitortype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.monitor']['links']['add'] = '/front/ruledictionnarymonitortype.form.php';
         }
         $menu['dictionnary']['options']['type.printer']['title'] = _n('Printer type', 'Printer types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.printer']['page'] = '/front/ruledictionnaryprintertype.php';
         $menu['dictionnary']['options']['type.printer']['links']['search'] = '/front/ruledictionnaryprintertype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.printer']['links']['add'] = '/front/ruledictionnaryprintertype.form.php';
         }
         $menu['dictionnary']['options']['type.peripheral']['title'] = _n('Peripheral type', 'Peripheral types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.peripheral']['page'] = '/front/ruledictionnaryperipheraltype.php';
         $menu['dictionnary']['options']['type.peripheral']['links']['search'] = '/front/ruledictionnaryperipheraltype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.peripheral']['links']['add'] = '/front/ruledictionnaryperipheraltype.form.php';
         }
         $menu['dictionnary']['options']['type.networking']['title'] = _n('Networking equipment type', 'Networking equipment types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.networking']['page'] = '/front/ruledictionnarynetworkequipmenttype.php';
         $menu['dictionnary']['options']['type.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmenttype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmenttype.form.php';
         }
         $menu['dictionnary']['options']['type.phone']['title'] = _n('Phone type', 'Phone types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.phone']['page'] = '/front/ruledictionnaryphonetype.php';
         $menu['dictionnary']['options']['type.phone']['links']['search'] = '/front/ruledictionnaryphonetype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.phone']['links']['add'] = '/front/ruledictionnaryphonetype.form.php';
         }
         $menu['dictionnary']['options']['os']['title'] = __('Operating system');
         $menu['dictionnary']['options']['os']['page'] = '/front/ruledictionnaryoperatingsystem.php';
         $menu['dictionnary']['options']['os']['links']['search'] = '/front/ruledictionnaryoperatingsystem.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os']['links']['add'] = '/front/ruledictionnaryoperatingsystem.form.php';
         }
         $menu['dictionnary']['options']['os_sp']['title'] = __('Service pack');
         $menu['dictionnary']['options']['os_sp']['page'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
         $menu['dictionnary']['options']['os_sp']['links']['search'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os_sp']['links']['add'] = '/front/ruledictionnaryoperatingsystemservicepack.form.php';
         }
         $menu['dictionnary']['options']['os_version']['title'] = __('Version of the operating system');
         $menu['dictionnary']['options']['os_version']['page'] = '/front/ruledictionnaryoperatingsystemversion.php';
         $menu['dictionnary']['options']['os_version']['links']['search'] = '/front/ruledictionnaryoperatingsystemversion.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os_version']['links']['add'] = '/front/ruledictionnaryoperatingsystemversion.form.php';
         }
         $menu['dictionnary']['options']['printer']['title'] = _n('Printer', 'Printers', Session::getPluralNumber());
         $menu['dictionnary']['options']['printer']['page'] = '/front/ruledictionnaryprinter.php';
         $menu['dictionnary']['options']['printer']['links']['search'] = '/front/ruledictionnaryprinter.php';
         if (RuleDictionnaryPrinter::canCreate()) {
             $menu['dictionnary']['options']['printer']['links']['add'] = '/front/ruledictionnaryprinter.form.php';
         }
     }
     if (count($menu)) {
         $menu['is_multi_entries'] = true;
         return $menu;
     }
     return false;
 }
Пример #11
0
 /**
  * Requests the nodes from the GLPI database
  **/
 function getNodesFromDb()
 {
     global $DB, $CFG_GLPI;
     // get entity name
     foreach ($_SESSION['glpiactiveprofile']['entities'] as $entity) {
         $ID = $entity['id'];
     }
     $sql = "SELECT `glpi_entities`.`completename` AS entity\n                       FROM `glpi_entities`\n                       WHERE `id` = '{$ID}'";
     $req = $DB->request($sql);
     if ($nb = $req->numrows()) {
         foreach ($req as $data) {
             $ent = $data["entity"];
         }
     }
     // The tree object
     echo "var d = new dTree('d');\n";
     echo "d.add(0,-1,'" . __($ent, 'treeview') . "');\n";
     $config = new PluginTreeviewConfig();
     // Request the display settings from the database and store them in the global object $config
     $this->getFromDB(1);
     $itemName = $this->fields["itemName"];
     $locationName = $this->fields["locationName"];
     $target = $this->fields["target"];
     $folderLinks = $this->fields["folderLinks"];
     $useSelection = $this->fields["useSelection"];
     $useLines = $this->fields["useLines"];
     $useIcons = $this->fields["useIcons"];
     $closeSameLevel = $this->fields["closeSameLevel"];
     // Load the settings in JavaSript so that dTree script can apply them
     echo "d.config.target         = '" . $target . "';\n";
     echo "d.config.folderLinks    = " . $folderLinks . ";\n";
     echo "d.config.useSelection   = " . $useSelection . ";\n";
     echo "d.config.useLines       = " . $useLines . ";\n";
     echo "d.config.useIcons       = " . $useIcons . ";\n";
     echo "d.config.closeSameLevel = " . $closeSameLevel . ";\n";
     $dontLoad = 'false';
     // Get the lowest level of the tree nodes and the highest primary key
     $query = "  SELECT MAX(`id`) AS `max_id`,\n                         MAX(`level`) AS `max_level`\n                  FROM `glpi_locations` ";
     $query .= getEntitiesRestrictRequest(" WHERE ", "glpi_locations", '', '', true);
     $result = $DB->query($query);
     $max_level = $DB->result($result, 0, "max_level");
     $tv_id = $max_id = $DB->result($result, 0, "max_id");
     $tv_id++;
     // Is this the first time we load the page?
     if (isset($_GET['nodes']) && $_GET['nodes'] != "") {
         // If no then get all the nodes requested by the client
         $nodes = array_reverse(explode('.', $_GET['nodes']));
     } else {
         // If yes then get only the root node
         $nodes[0] = 0;
     }
     // If an item group is requested, then save its type to use it later in the openTo function
     if (isset($_GET['openedType']) && $_GET['openedType'] != "") {
         $openedType = $_GET['openedType'];
     } else {
         $openedType = -1;
     }
     // Characters which need to be removed from JS output.
     $trans = array("\"" => "`", "\r" => " ", "\n" => " ");
     for ($n = 1; $n <= count($nodes); $n++) {
         if ($nodes[$n - 1] <= $max_id && $n <= $max_level) {
             $query = "SELECT *\n                      FROM `glpi_locations`\n                      WHERE `level` = '{$n}'\n                            AND `locations_id` = '" . $nodes[$n - 1] . "'";
             $query .= getEntitiesRestrictRequest(" AND ", "glpi_locations", '', '', true);
             $query .= "ORDER BY `completename` ASC";
             $result = $DB->query($query);
             while ($r = $DB->fetch_assoc($result)) {
                 // Location's name schema
                 if ($locationName == 0) {
                     $l_name = $r['name'];
                 } else {
                     if ($locationName == 1) {
                         $l_name = $r['completename'];
                     } else {
                         if ($locationName == 2) {
                             $l_name = $r['name'];
                             if ($r['comment'] != "") {
                                 $l_name .= ' (' . $r['comment'] . ')';
                             }
                         } else {
                             if ($locationName == 3) {
                                 $l_name = $r['completename'];
                                 if ($r['comment'] != "") {
                                     $l_name .= ' (' . $r['comment'] . ')';
                                 }
                             }
                         }
                     }
                 }
                 // Is this location requested by the user to be opened
                 if (in_array($r['id'], $nodes)) {
                     echo "d.add(" . $r['id'] . ", " . $r['locations_id'] . ", \"" . strtr($l_name, $trans) . "\", true, -1,'');\n";
                     $dontLoad = 'true';
                     // Then add aloso its items
                     foreach (self::$types as $type) {
                         $item = new $type();
                         $itemtable = getTableForItemType($type);
                         $query = "SELECT *\n                               FROM `{$itemtable}`\n                               WHERE `locations_id` = '" . $r['id'] . "'";
                         if ($item->maybeTemplate()) {
                             $query .= " AND `{$itemtable}`.`is_template` = '0'";
                         }
                         if ($item->maybeDeleted()) {
                             $query .= " AND `{$itemtable}`.`is_deleted` = '0'";
                         }
                         if ($this->isEntityAssign()) {
                             $query .= " AND `{$itemtable}`.`entities_id` = '" . $_SESSION["glpiactive_entity"] . "'";
                         }
                         $query .= " ORDER BY `{$itemtable}`.`name`";
                         $result_1 = $DB->query($query);
                         if ($DB->numrows($result_1)) {
                             $pid = $tv_id;
                             $field_num = 3;
                             $query_location = "SELECT `completename`\n                                           FROM `glpi_locations`\n                                           WHERE `id` = '" . $r['id'] . "'";
                             $result_location = $DB->query($query_location);
                             while ($row = $DB->fetch_assoc($result_location)) {
                                 $name_location = $row['completename'];
                             }
                             $getParam = '?is_deleted=0' . '&criteria[0][field]=' . $field_num . '&criteria[0][searchtype]=equals&criteria[0][value]=' . $r['id'] . '&itemtype=' . $type;
                             // Add items parent node
                             echo "d.add({$tv_id}," . $r['id'] . ",\"" . strtr($item::getTypeName(2), $trans) . "\", {$dontLoad}, '" . $type . "', '" . Toolbox::getItemTypeSearchURL($type) . $getParam . "', '', '', '" . self::getPicbyType($type) . "', '" . self::getPicbyType($type) . "');\n";
                             if ($openedType == $type && $nodes[count($nodes) - 1] == $tv_id) {
                                 $openedType = $tv_id;
                             }
                             $tv_id++;
                         }
                         while ($r_1 = $DB->fetch_assoc($result_1)) {
                             // Item's name schema
                             if ($itemName == 0 || $type == 'Software') {
                                 $i_name = $r_1['name'];
                             } else {
                                 if ($itemName == 1) {
                                     if (isset($r_1['otherserial']) && !empty($r_1['otherserial'])) {
                                         $i_name = $r_1['otherserial'];
                                     } else {
                                         $i_name = $r_1['name'];
                                     }
                                 } else {
                                     if ($itemName == 2) {
                                         $i_name = $r_1['name'] != "" ? $r_1['name'] : "";
                                         if (isset($r_1['otherserial']) && !empty($r_1['otherserial'])) {
                                             $i_name .= $r_1['otherserial'] != "" ? $r_1['name'] != "" ? ' / ' . $r_1['otherserial'] : $r_1['otherserial'] : "";
                                         } else {
                                             $i_name .= '';
                                         }
                                     } else {
                                         if ($itemName == 3) {
                                             if (isset($r_1['otherserial']) && !empty($r_1['otherserial'])) {
                                                 $i_name = $r_1['otherserial'] != "" ? $r_1['otherserial'] : "";
                                                 $i_name .= $r_1['name'] != "" ? $r_1['otherserial'] != "" ? ' / ' . $r_1['name'] : $r_1['name'] : "";
                                             } else {
                                                 $i_name = $r_1['name'];
                                             }
                                         }
                                     }
                                 }
                             }
                             $url = Toolbox::getItemTypeFormURL($type) . "?id=" . $r_1['id'];
                             $pic = "pics/node.gif";
                             $name = strtr($i_name, $trans);
                             $opt = array('url' => $url, 'pic' => $pic, 'name' => $name);
                             $params = array('itemtype' => $type, 'id' => $r_1['id'], 'url' => $url, 'pic' => $pic, 'name' => $name);
                             $opt = Plugin::doHookFunction('treeview_params', $params);
                             // Add the item
                             echo "d.add(" . $tv_id++ . ", {$pid}, \"" . $opt['name'] . "\", true, -1, '" . $opt['url'] . "', '', '', '" . $opt['pic'] . "','" . $opt['pic'] . "');\n";
                         }
                     }
                     // Add only the location without its items
                 } else {
                     echo "d.add(" . $r['id'] . "," . $r['locations_id'] . ",\"" . strtr($l_name, $trans) . "\", false, -1,'', '', '', '', '', false, true);\n";
                 }
             }
         }
     }
     // Print the node from JavaScript
     echo "document.write(d);\n";
     // Open the tree to the desired node
     if ($openedType != -1) {
         echo "d.openTo(" . $openedType . ");\n";
     } else {
         echo "d.openTo(" . $nodes[count($nodes) - 1] . ");\n";
     }
 }
Пример #12
0
 static function getSearchURL($full = true)
 {
     return Toolbox::getItemTypeSearchURL(get_parent_class(), $full) . "?itemtype=" . get_called_class();
 }
Пример #13
0
 /**
  * Display a list to select a itemtype with link to search form
  *
  * @param $optgroup array (group of dropdown) of array (itemtype => localized name)
  */
 static function showItemTypeList($optgroup)
 {
     echo "<div id='list_nav'>";
     $nb = 0;
     foreach ($optgroup as $label => $dp) {
         $nb += count($dp);
     }
     $step = $nb > 15 ? $nb / 3 : $nb;
     echo "<table class='tab_glpi'><tr class='top'><td width='33% class='center'>";
     echo "<table class='tab_cadre'>";
     $i = 1;
     foreach ($optgroup as $label => $dp) {
         echo "<tr><th>{$label}</th></tr>\n";
         foreach ($dp as $key => $val) {
             $class = "class='tab_bg_4'";
             if (($itemtype = getItemForItemtype($key)) && $itemtype->isEntityAssign()) {
                 $class = "class='tab_bg_2'";
             }
             echo "<tr {$class}><td><a href='" . Toolbox::getItemTypeSearchURL($key) . "'>";
             echo "{$val}</a></td></tr>\n";
             $i++;
         }
         if ($i >= $step) {
             echo "</table></td><td width='25'>&nbsp;</td><td><table class='tab_cadre'>";
             $step += $step;
         }
     }
     echo "</table></td></tr></table></div>";
 }
Пример #14
0
 /**
  * Print the HTML array for Items linked to current contract
  *
  * @since version 0.84
  *
  * @param $contract   Contract object
  *
  * @return Nothing (display)
  **/
 static function showForContract(Contract $contract)
 {
     global $DB, $CFG_GLPI;
     $instID = $contract->fields['id'];
     if (!$contract->can($instID, READ)) {
         return false;
     }
     $canedit = $contract->can($instID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`contracts_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $data = array();
     $totalnb = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                                 `glpi_contracts_items`.`id` AS IDD,\n                                 `glpi_entities`.`id` AS entity\n                          FROM `glpi_contracts_items`,\n                               `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_contracts_items`.`items_id`\n                              AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'\n                              AND `glpi_contracts_items`.`contracts_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             if ($nb > $_SESSION['glpilist_limit']) {
                 $opt = array('order' => 'ASC', 'is_deleted' => 0, 'reset' => 'reset', 'start' => 0, 'sort' => 80, 'criteria' => array(0 => array('value' => '$$$$' . $instID, 'searchtype' => 'contains', 'field' => 29)));
                 $link = "<a href='" . Toolbox::getItemTypeSearchURL($itemtype) . "?" . Toolbox::append_params($opt) . "'>" . __('Device list') . "</a>";
                 $data[$itemtype] = array('longlist' => true, 'name' => sprintf(__('%1$s: %2$s'), $item->getTypeName($nb), $nb), 'link' => $link);
             } else {
                 if ($nb > 0) {
                     for ($prem = true; $objdata = $DB->fetch_assoc($result_linked); $prem = false) {
                         $data[$itemtype][$objdata['id']] = $objdata;
                     }
                 }
             }
             $totalnb += $nb;
         }
     }
     if ($canedit && ($contract->fields['max_links_allowed'] == 0 || $contract->fields['max_links_allowed'] > $totalnb)) {
         echo "<div class='firstbloc'>";
         echo "<form name='contract_form{$rand}' id='contract_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $CFG_GLPI["contract_types"], 'entity_restrict' => $contract->fields['is_recursive'] ? getSonsOf('glpi_entities', $contract->fields['entities_id']) : $contract->fields['entities_id'], 'checkright' => true));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $totalnb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $totalnb) {
         $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_top .= "</th>";
         $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= "</th>";
     }
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Serial number') . "</th>";
     $header_end .= "<th>" . __('Inventory number') . "</th>";
     $header_end .= "<th>" . __('Status') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $totalnb = 0;
     foreach ($data as $itemtype => $datas) {
         if (isset($datas['longlist'])) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>&nbsp;</td>";
             }
             echo "<td class='center'>" . $datas['name'] . "</td>";
             echo "<td class='center' colspan='2'>" . $datas['link'] . "</td>";
             echo "<td class='center'>-</td><td class='center'>-</td></tr>";
         } else {
             $prem = true;
             $nb = count($datas);
             foreach ($datas as $id => $objdata) {
                 $name = $objdata["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     $name = sprintf(__('%1$s (%2$s)'), $name, $objdata["id"]);
                 }
                 $link = $itemtype::getFormURLWithID($objdata["id"]);
                 $name = "<a href=\"" . $link . "\">" . $name . "</a>";
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td width='10'>";
                     Html::showMassiveActionCheckBox(__CLASS__, $objdata["IDD"]);
                     echo "</td>";
                 }
                 if ($prem) {
                     $item = new $itemtype();
                     $typename = $item->getTypeName($nb);
                     echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>";
                     $prem = false;
                 }
                 echo "<td class='center'>";
                 echo Dropdown::getDropdownName("glpi_entities", $objdata['entity']) . "</td>";
                 echo "<td class='center" . (isset($objdata['is_deleted']) && $objdata['is_deleted'] ? " tab_bg_2_2'" : "'");
                 echo ">" . $name . "</td>";
                 echo "<td class='center'>" . (isset($objdata["serial"]) ? "" . $objdata["serial"] . "" : "-") . "</td>";
                 echo "<td class='center'>" . (isset($objdata["otherserial"]) ? "" . $objdata["otherserial"] . "" : "-") . "</td>";
                 echo "<td class='center'>";
                 if (isset($objdata["states_id"])) {
                     echo Dropdown::getDropdownName("glpi_states", $objdata['states_id']);
                 } else {
                     echo '&nbsp;';
                 }
                 echo "</td></tr>";
             }
         }
     }
     if ($number) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Display the menu of FusionInventory
  *
  *@param type value "big" or "mini"
  *
  *@return nothing
  **/
 static function displayMenu($type = "big")
 {
     global $CFG_GLPI;
     if (PLUGIN_FUSIONINVENTORY_OFFICIAL_RELEASE != 1) {
         echo "<center>";
         echo "<a href='http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/" . "wiki/Beta_test'>";
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/beta.png'/></a>";
         echo "&nbsp;<a href='https://www.transifex.com/projects/p/FusionInventory/resource/" . "plugin-fusioninventory-084/'>";
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/Translate.png'/>" . "</a>";
         echo "<H1>Version '" . PLUGIN_FUSIONINVENTORY_REALVERSION . "'</H1></center><br/>\n";
     }
     $pfEntity = new PluginFusioninventoryEntity();
     if (strlen($pfEntity->getValue('agent_base_url', 0)) < 10 && !strstr($_SERVER['PHP_SELF'], 'front/config.form.php')) {
         echo "<div class='msgboxmonit msgboxmonit-red'>";
         print "<center><a href=\"" . $CFG_GLPI['root_doc'] . "/front/entity.form.php?id=0&forcetab=PluginFusioninventoryEntity\$0\">";
         print __('The server needs to kown the URL the agents use to access the server. Please ' . 'configure it in the General Configuration page.', 'fusioninventory');
         print "</a></center>";
         echo "</div>";
         exit;
     }
     $width_status = 0;
     echo "<div align='center' style='height: 35px; display: inline-block; width: 100%; margin: 0 auto;'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td align='center'>";
     echo "<table>";
     echo "<tr>";
     echo "<td>";
     /*
      * General
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_agent', READ)) {
         $a_menu[0]['name'] = __('Agents management', 'fusioninventory');
         $a_menu[0]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_agents.png";
         $a_menu[0]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryAgent');
     }
     if (Session::haveRight('plugin_fusioninventory_group', READ)) {
         $a_menu[2]['name'] = __('Groups of computers', 'fusioninventory');
         $a_menu[2]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_group.png";
         $a_menu[2]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/deploygroup.php";
     }
     if (Session::haveRight('config', UPDATE) || Session::haveRight('plugin_fusioninventory_configuration', UPDATE)) {
         $a_menu[3]['name'] = __('General configuration', 'fusioninventory');
         $a_menu[3]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_agents.png";
         $a_menu[3]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/config.form.php";
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('General', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Tasks
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_task', READ)) {
         //$a_menu[1]['name'] = __('Task management', 'fusioninventory')." (".__s('Summary').")";
         //$a_menu[1]['pic']  = $CFG_GLPI['root_doc']."/plugins/fusioninventory/pics/menu_task.png";
         //$a_menu[1]['link'] = $CFG_GLPI['root_doc'].
         //                        "/plugins/fusioninventory/front/tasksummary.php";
         $a_menu[2]['name'] = __('Task management', 'fusioninventory');
         $a_menu[2]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_task.png";
         $a_menu[2]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTask');
         $a_menu[3]['name'] = __('Monitoring / Logs', 'fusioninventory');
         $a_menu[3]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_runningjob.png";
         $a_menu[3]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTaskJob');
     }
     if (Session::haveRight('plugin_fusioninventory_importxml', CREATE)) {
         $a_menu[0]['name'] = __('Import agent XML file', 'fusioninventory');
         $a_menu[0]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_importxml.png";
         $a_menu[0]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventorycomputerimportxml.php";
     }
     if (Session::haveRight("plugin_fusioninventory_collect", READ)) {
         $a_menu[11]['name'] = __('Additional computer information', 'fusioninventory');
         $a_menu[11]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_task.png";
         $a_menu[11]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryCollect');
     }
     if (Session::haveRight('plugin_fusioninventory_task', READ)) {
         $a_menu[12]['name'] = __('Time slot', 'fusioninventory');
         $a_menu[12]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_timeslot.png";
         $a_menu[12]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTimeslot');
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Tasks', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Rules
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_ruleimport', READ)) {
         $a_menu[1]['name'] = __('Equipment import and link rules', 'fusioninventory');
         $a_menu[1]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[1]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryInventoryRuleImport');
     }
     if (Session::haveRight('plugin_fusioninventory_ignoredimportdevice', READ)) {
         $a_menu[2]['name'] = __('Ignored import devices', 'fusioninventory');
         $a_menu[2]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[2]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryIgnoredimportdevice');
     }
     if (Session::haveRight('plugin_fusioninventory_ruleentity', READ)) {
         $a_menu[3]['name'] = __('Computer entity rules', 'fusioninventory');
         $a_menu[3]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[3]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventoryruleentity.php";
     }
     if (Session::haveRight('plugin_fusioninventory_rulelocation', READ)) {
         $a_menu[4]['name'] = __('Computer location rules', 'fusioninventory');
         $a_menu[4]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[4]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventoryrulelocation.php";
     }
     if (Session::haveRight("plugin_fusioninventory_rulecollect", READ)) {
         $a_menu[5]['name'] = __('Additional computer information rules', 'fusioninventory');
         $a_menu[5]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[5]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/collectrule.php";
     }
     if (Session::haveRight("plugin_fusioninventory_rulecollect", READ)) {
         $a_menu[6]['name'] = __('Dictionnary of computer architectures', 'fusioninventory');
         $a_menu[6]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[6]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/ruledictionnarycomputerarch.php";
     }
     if (Session::haveRight('plugin_fusioninventory_blacklist', READ)) {
         $a_menu[7]['name'] = _n('Blacklist', 'Blacklists', 1);
         $a_menu[7]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_blacklist.png";
         $a_menu[7]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventorycomputerblacklist.php";
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Rules', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Network
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_iprange', READ)) {
         $a_menu[] = array('name' => __('IP Ranges', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rangeip.png", 'link' => Toolbox::getItemTypeSearchURL('PluginFusioninventoryIPRange'));
     }
     if (Session::haveRight('plugin_fusioninventory_credentialip', READ)) {
         $a_menu[] = array('name' => __('Remote devices to inventory (VMware)', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_credentialips.png", 'link' => Toolbox::getItemTypeSearchURL('PluginFusioninventoryCredentialip'));
     }
     if (Session::haveRight('plugin_fusioninventory_configsecurity', READ)) {
         $a_menu[] = array('name' => __('SNMP authentication', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_authentification.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/configsecurity.php");
     }
     if (Session::haveRight('plugin_fusioninventory_credential', READ)) {
         $a_menu[] = array('name' => __('Authentication for remote devices (VMware)', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_authentification.png", 'link' => Toolbox::getItemTypeSearchURL('PluginFusioninventoryCredential'));
     }
     if (Session::haveRight('plugin_fusioninventory_task', READ)) {
         $a_menu[] = array('name' => __('Discovery status', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_discovery_status.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/statediscovery.php");
         $a_menu[] = array('name' => __('Network inventory status', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_inventory_status.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/stateinventory.php");
     }
     if (Session::haveRight('plugin_fusioninventory_model', READ)) {
         $a_menu[] = array('name' => __('SNMP models creation', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_constructmodel.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/constructmodel.php");
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Networking', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Deploy
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_package', READ)) {
         $a_menu[] = array('name' => __('Package management', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_package.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/deploypackage.php");
     }
     if (Session::haveRight('plugin_fusioninventory_deploymirror', READ)) {
         $a_menu[1]['name'] = __('Mirror servers', 'fusioninventory');
         $a_menu[1]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_files.png";
         $a_menu[1]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/deploymirror.php";
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Deploy', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Guide
      */
     $a_menu = array();
     $a_menu[] = array('name' => "FI> " . __('Computer inv.', 'fusioninventory'), 'pic' => "", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/menu_inventory.php");
     $a_menu[] = array('name' => "FI> " . __('SNMP inv.', 'fusioninventory'), 'pic' => "", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/menu_snmpinventory.php");
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Guide', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</div><br/><br/><br/>";
 }
Пример #16
0
            $tmp = array_pop($mytypes);
            if (count($tmp) == 1) {
                Html::redirect(Toolbox::getItemTypeSearchURL(key($tmp)));
            }
        }
    }
    Html::header(__("Objects management", "genericobject"), $_SERVER['PHP_SELF'], "plugins", "genericobject");
    foreach ($types as $family => $typeData) {
        $PluginGenericobjectTypefamily = new PluginGenericobjectTypefamily();
        $PluginGenericobjectTypefamily->getFromDB($family);
        echo "<table class='tab_cadre_fixe'>";
        if ($family == 0) {
            echo "<tr class='tab_bg_2'><th>" . __("Empty family", "genericobject") . "</th></tr>";
        } else {
            echo "<tr class='tab_bg_2'><th>" . $PluginGenericobjectTypefamily->getField("name") . "</th></tr>";
        }
        if (!count($types)) {
            echo "<tr class='tab_bg_1'><td align='center'>" . __("No item to display") . "</td></tr>";
        } else {
            foreach ($typeData as $ID => $value) {
                echo "<tr class='tab_bg_1'><td align='center'>";
                echo "<a href='" . Toolbox::getItemTypeSearchURL($value['itemtype']) . "'>";
                $itemtype = $value['itemtype'];
                echo $itemtype::getTypeName();
                echo "</a></td></tr>";
            }
        }
        echo "</table>";
    }
    Html::footer();
}
Пример #17
0
  @copyright Copyright (c) 2012-2013 Surveyticket plugin team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/surveyticket
  @since     2012

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Html::header("survey", $_SERVER["PHP_SELF"], "plugins", "surveyticket", "answers");
$psAnswer = new PluginSurveyticketAnswer();
if (isset($_POST["add"])) {
    $psAnswer->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $psAnswer->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $psAnswer->delete($_POST);
            Html::redirect(Toolbox::getItemTypeSearchURL('PluginSurveyticketAnswer'));
        }
    }
}
if (isset($_GET["id"])) {
    $psAnswer->showForm($_GET["id"]);
} else {
    $psAnswer->showForm(0);
}
Html::footer();
Пример #18
0
 /**
  * Print generic search form
  *
  * @param $itemtype        type to display the form
  * @param $params    array of parameters may include field, contains, sort, is_deleted, link,
  *                         link2, contains2, field2, type2
  *
  * @return nothing (displays)
  **/
 static function showGenericSearch($itemtype, array $params)
 {
     global $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = self::getCleanedOptions($itemtype);
     $target = Toolbox::getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     $linked = self::getMetaItemtypeAvailable($itemtype);
     echo "<form name='searchform{$itemtype}' method='get' action=\"{$target}\">";
     echo "<div id='searchcriterias'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     if ($_SESSION["glpisearchcount"][$itemtype] + $_SESSION["glpisearchcount2"][$itemtype] > 1) {
         echo "<td width='10' class='center'>";
         echo "<a href=\"javascript:toggleTableDisplay('searchcriteriastable','searchcriteriasimg',\n                                                       '" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png',\n                                                       '" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png')\">";
         echo "<img alt='' name='searchcriteriasimg' src=\"" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png\">";
         echo "</td>";
     }
     echo "<td>";
     echo "<table id='searchcriteriastable'>";
     // Display normal search parameters
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         echo "<tr " . ($i == 0 ? "class='headerRow'" : '') . "><td class='left' width='50%'>";
         // First line display add / delete images for normal and meta search items
         if ($i == 0) {
             echo "<input type='hidden' disabled id='add_search_count' name='add_search_count'\n                   value='1'>";
             echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;\n                   document.forms['searchform{$itemtype}'].submit();\">";
             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title=\"" . __s('Add a search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
                 echo "<input type='hidden' disabled id='delete_search_count'\n                      name='delete_search_count' value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title=\"" . __s('Delete a search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             }
             if (is_array($linked) && count($linked) > 0) {
                 echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2'\n                      value='1'>";
                 echo "<a href='#' onClick=\"document.getElementById('add_search_count2').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title=\"" . __s('Add a global search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
                     echo "<input type='hidden' disabled id='delete_search_count2'\n                         name='delete_search_count2' value='1'>";
                     echo "<a href='#' onClick=\"document.getElementById('delete_search_count2').disabled=false;\n                         document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . __s('Delete a global search criterion') . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 }
             }
             $itemtable = getTableForItemType($itemtype);
             if ($item && $item->maybeDeleted()) {
                 echo "<input type='hidden' id='is_deleted' name='is_deleted' value='" . $p['is_deleted'] . "'>";
                 echo "<a href='#' onClick = \"toogle('is_deleted','','','');\n                      document.forms['searchform{$itemtype}'].submit();\">\n                      <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/showdeleted" . (!$p['is_deleted'] ? '_no' : '') . ".png\" name='img_deleted' alt=\"" . (!$p['is_deleted'] ? __s('Show the dustbin') : __s("Don't show deleted items")) . "\" title=\"" . (!$p['is_deleted'] ? __s('Show the dustbin') : __s("Don't show deleted items")) . "\"></a>";
                 echo '&nbsp;&nbsp;';
             }
         }
         // Display link item
         if ($i > 0) {
             echo "<select name='link[{$i}]'>";
             echo "<option value = 'AND' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>&nbsp;";
         }
         $selected = $first = '';
         // display select box to define search item
         echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
         if ($CFG_GLPI['allow_search_view'] == 2) {
             echo "<option value='view' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
                 echo "selected";
                 $selected = 'view';
             }
             echo ">" . __('Items seen') . "</option>\n";
         }
         reset($options);
         $first_group = true;
         $str_limit = 28;
         // Not $_SESSION['glpidropdown_chars_limit'] because must be really to short (5 or 10) and search engine will be unusable
         $nb_in_group = 0;
         $group = '';
         foreach ($options as $key => $val) {
             // print groups
             if (!is_array($val)) {
                 if (!$first_group) {
                     $group .= "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 if ($nb_in_group) {
                     echo $group;
                 }
                 $group = '';
                 $nb_in_group = 0;
                 $group .= "<optgroup label=\"" . Toolbox::substr($val, 0, $str_limit) . "\">";
             } else {
                 if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                     $nb_in_group++;
                     $group .= "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'";
                     if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                         $group .= "selected";
                         $selected = $key;
                     } else {
                         if (empty($first)) {
                             $first = $key;
                         }
                     }
                     $group .= ">" . Toolbox::substr($val["name"], 0, $str_limit) . "</option>\n";
                 }
             }
         }
         if (!$first_group) {
             $group .= "</optgroup>\n";
         }
         if ($nb_in_group) {
             echo $group;
         }
         if ($CFG_GLPI['allow_search_view'] == 1) {
             echo "<option value='view' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
                 echo "selected";
                 $selected = 'view';
             }
             echo ">" . __('Items seen') . "</option>\n";
         }
         if ($CFG_GLPI['allow_search_all']) {
             echo "<option value='all' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
                 echo "selected";
                 $selected = 'all';
             }
             echo ">" . __('All') . "</option>";
         }
         if (empty($selected)) {
             $selected = $first;
         }
         echo "</select>\n";
         echo "</td><td class='left'>";
         echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
         $used_itemtype = $itemtype;
         // Force Computer itemtype for AllAssets to permit to show specific items
         if ($itemtype == 'AllAssets') {
             $used_itemtype = 'Computer';
         }
         $_POST['itemtype'] = $used_itemtype;
         $_POST['num'] = $i;
         $_POST['field'] = $selected;
         $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
         $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
         include GLPI_ROOT . "/ajax/searchoption.php";
         echo "</div>\n";
         $params = array('field' => '__VALUE__', 'itemtype' => $used_itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
         Ajax::updateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params);
         echo "</td></tr>\n";
     }
     $metanames = array();
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             echo "<tr><td class='left' colspan='2'>";
             $rand = mt_rand();
             echo "<table width='100%'><tr class='left'><td width='35%'>";
             // Display link item (not for the first item)
             echo "<select name='link2[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>\n";
             echo "</select>&nbsp;";
             // Display select of the linked item type available
             echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
             echo "<option value=''>" . Dropdown::EMPTY_VALUE . "</option>";
             foreach ($linked as $key) {
                 if (!isset($metanames[$key])) {
                     if ($linkitem = getItemForItemtype($key)) {
                         $metanames[$key] = $linkitem->getTypeName();
                     }
                 }
                 echo "<option value='{$key}'>" . Toolbox::substr($metanames[$key], 0, 20) . "</option>\n";
             }
             echo "</select>&nbsp;";
             echo "</td><td>";
             // Ajax script for display search met& item
             echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'>&nbsp;</span>\n";
             $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
             Ajax::updateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params);
             if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
                 $params['itemtype'] = $p['itemtype2'][$i];
                 Ajax::updateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params);
                 echo "<script type='text/javascript' >";
                 echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
                 echo "</script>\n";
             }
             echo "</td></tr></table>";
             echo "</td></tr>\n";
         }
     }
     echo "</table>\n";
     echo "</td>\n";
     echo "<td width='150px'>";
     echo "<table width='100%'>";
     // Display sort selection
     /*      echo "<tr><td colspan='2'>".__('sorted by');
           echo "&nbsp;<select name='sort' size='1'>";
           reset($options);
           $first_group=true;
           foreach ($options as $key => $val) {
              if (!is_array($val)) {
                 if (!$first_group) {
                    echo "</optgroup>\n";
                 } else {
                    $first_group=false;
                 }
                 echo "<optgroup label=\"$val\">";
              } else {
                 echo "<option value='$key'";
                 if ($key == $p['sort']) {
                    echo " selected";
                 }
                 echo ">".Toolbox::substr($val["name"],0,20)."</option>\n";
              }
           }
           if (!$first_group) {
              echo "</optgroup>\n";
           }
           echo "</select> ";
           echo "</td></tr>\n";
     */
     // Display deleted selection
     echo "<tr>";
     // Display submit button
     echo "<td width='80' class='center'>";
     echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit' >";
     echo "</td><td>";
     Bookmark::showSaveButton(Bookmark::SEARCH, $itemtype);
     echo "<a href='{$target}?reset=reset' >";
     echo "&nbsp;&nbsp;<img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
     echo "</td></tr></table>\n";
     echo "</td></tr>";
     echo "</table>\n";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     echo "</div>";
     Html::closeForm();
 }
Пример #19
0
$array = $relation->getListClaseHelpDesk();
if (isset($_POST["add"])) {
    $_POST['name'] = $relation->getNameDropdown($array, $_POST['name']);
    $newID = $tipoRelaciones->add($_POST);
    Html::redirect($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $tipoRelaciones->delete($_POST);
        Html::redirect(Toolbox::getItemTypeSearchURL('PluginRelationClase'));
    } else {
        if (isset($_POST["restore"])) {
            $tipoRelaciones->restore($_POST);
            Html::redirect(Toolbox::getItemTypeSearchURL('PluginRelationClase'));
        } else {
            if (isset($_POST["purge"])) {
                $tipoRelaciones->delete($_POST, 1);
                Html::redirect(Toolbox::getItemTypeSearchURL('PluginRelationClase'));
            } else {
                if (isset($_POST["update"])) {
                    $_POST['name'] = $relation->getNameDropdown($array, $_POST['name']);
                    $tipoRelaciones->update($_POST);
                    Html::redirect($_SERVER['HTTP_REFERER']);
                } else {
                    Html::header(__('Relation', 'relation'), $_SERVER['PHP_SELF'], "config", "PluginRelationConfig", "clase");
                    $tipoRelaciones->display(array('id' => $_GET["id"]));
                    Html::footer();
                }
            }
        }
    }
}
Пример #20
0
 function showModels($itemtype, $id, $rand)
 {
     global $DB;
     $PluginRacksConfig = new PluginRacksConfig();
     $link = Toolbox::getItemTypeFormURL($itemtype);
     $table = getTableForItemType($itemtype);
     $search = Toolbox::getItemTypeSearchURL($itemtype);
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>&nbsp;</th>";
     echo "<th>" . __('Equipment', 'racks') . "</th>";
     echo "<th>" . __('Total Current', 'racks') . "<br>(" . __('amps', 'racks') . ")</th>";
     echo "<th>" . __('Power supplies number', 'racks') . "</th>";
     echo "<th>" . __('Calorific waste', 'racks') . "<br> (";
     // Dissipation calorifique
     $PluginRacksConfig->getUnit("dissipation");
     echo ")</th>";
     echo "<th>" . __('Flow Rate', 'racks') . "<br> (";
     // Débit d'air frais
     $PluginRacksConfig->getUnit("rate");
     echo ")</th>";
     echo "<th>" . __('Size') . " (" . __('U', 'racks') . ")</th>";
     echo "<th>" . __('Weight', 'racks') . "<br> (";
     // poids
     $PluginRacksConfig->getUnit("weight");
     echo ")</th>";
     echo "<th>" . __('Full-depth item', 'racks') . "</th>";
     echo "</tr>";
     $modelid = -1;
     $result = $DB->query("SELECT *\n                        FROM `" . $this->getTable() . "` " . ($itemtype != -1 ? "WHERE `itemtype` = '{$itemtype}'" : "") . " ");
     while ($data = $DB->fetch_assoc($result)) {
         $modelid = $data['model_id'];
         $id = $data['id'];
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>";
         echo "<input type='checkbox' name='item[{$id}]' value='1'>";
         echo "</td>";
         echo "<td>";
         echo "<a href=\"" . $link . "?id=" . $modelid . "\">";
         echo Dropdown::getDropdownName($table, $modelid);
         echo "</a>";
         echo "</td>";
         echo "<td>" . Html::formatNumber($data['amps'], true) . "</td>";
         echo "<td>" . $data['nb_alim'] . "</td>";
         echo "<td>" . Html::formatNumber($data['dissipation'], true) . "</td>";
         echo "<td>" . Html::formatNumber($data['flow_rate'], true) . "</td>";
         echo "<td>" . $data['size'] . "</td>";
         echo "<td>" . Html::formatNumber($data['weight'], true) . "</td>";
         echo "<td>" . Dropdown::getYesNo($data['length']) . "</td>";
     }
     echo "<tr class='tab_bg_1'><td colspan='10'>";
     if ($this->canCreate()) {
         echo "<div align='center'><a onclick= \"if ( markCheckboxes('massiveaction_form{$rand}') ) return false;\" href='#'>" . __('Check all') . "</a>";
         echo " - <a onclick= \"if ( unMarkCheckboxes('massiveaction_form{$rand}') ) return false;\" href='#'>" . __('Uncheck all') . "</a> ";
         echo "<input type='submit' name='deleteSpec' value=\"" . __s('Delete permanently') . "\" class='submit' ></div></td></tr>";
         echo "<tr class='tab_bg_1 right'><td colspan='10'>";
         echo "<a href=\"" . $search . "\">";
         echo __('Add specifications for servers models', 'racks');
         echo "</a>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Пример #21
0
 /**
  * Print out list kb item
  *
  * @param $options            $_GET
  * @param $type      string   search type : browse / search (default search)
  **/
 static function showList($options, $type = 'search')
 {
     global $DB, $CFG_GLPI;
     // Default values of parameters
     $params['faq'] = !Session::haveRight("knowbase", "r");
     $params["start"] = "0";
     $params["knowbaseitemcategories_id"] = "0";
     $params["contains"] = "";
     $params["target"] = $_SERVER['PHP_SELF'];
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $ki = new self();
     switch ($type) {
         case 'myunpublished':
             if (!Session::haveRight('knowbase', 'w') && !Session::haveRight('faq', 'w')) {
                 return false;
             }
             break;
         case 'allunpublished':
             if (!Session::haveRight('knowbase_admin', 1)) {
                 return false;
             }
             break;
         default:
             break;
     }
     if (!$params["start"]) {
         $params["start"] = 0;
     }
     $query = self::getListRequest($params, $type);
     // Get it from database
     if ($result = $DB->query($query)) {
         $KbCategory = new KnowbaseItemCategory();
         $title = "";
         if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) {
             $title = empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name'];
             $title = sprintf(__('%1$s: %2$s'), __('Category'), $title);
         }
         Session::initNavigateListItems('KnowbaseItem', $title);
         $numrows = $DB->numrows($result);
         $list_limit = $_SESSION['glpilist_limit'];
         $showwriter = in_array($type, array('myunpublished', 'allunpublished', 'allmy'));
         // Limit the result, if no limit applies, use prior result
         if ($numrows > $list_limit && !isset($_GET['export_all'])) {
             $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " ";
             $result_limit = $DB->query($query_limit);
             $numrows_limit = $DB->numrows($result_limit);
         } else {
             $numrows_limit = $numrows;
             $result_limit = $result;
         }
         if ($numrows_limit > 0) {
             // Set display type for export if define
             $output_type = Search::HTML_OUTPUT;
             if (isset($_GET["display_type"])) {
                 $output_type = $_GET["display_type"];
             }
             // Pager
             $parameters = "start=" . $params["start"] . "&amp;knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&amp;contains=" . $params["contains"] . "&amp;is_faq=" . $params['faq'];
             if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
                 $parameters .= "&amp;item_items_id=" . $options['item_items_id'] . "&amp;item_itemtype=" . $options['item_itemtype'];
             }
             if ($output_type == Search::HTML_OUTPUT) {
                 Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
             }
             $nbcols = 1;
             // Display List Header
             echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols);
             $header_num = 1;
             echo Search::showHeaderItem($output_type, __('Subject'), $header_num);
             if ($output_type != Search::HTML_OUTPUT) {
                 echo Search::showHeaderItem($output_type, __('Content'), $header_num);
             }
             if ($showwriter) {
                 echo Search::showHeaderItem($output_type, __('Writer'), $header_num);
             }
             echo Search::showHeaderItem($output_type, __('Category'), $header_num);
             if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
                 echo Search::showHeaderItem($output_type, '&nbsp;', $header_num);
             }
             // Num of the row (1=header_line)
             $row_num = 1;
             for ($i = 0; $i < $numrows_limit; $i++) {
                 $data = $DB->fetch_assoc($result_limit);
                 Session::addToNavigateListItems('KnowbaseItem', $data["id"]);
                 // Column num
                 $item_num = 1;
                 $row_num++;
                 echo Search::showNewLine($output_type, $i % 2);
                 if ($output_type == Search::HTML_OUTPUT) {
                     if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
                         $href = " href='#' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=show_kb&amp;id=" . $data['id'] . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' );" . "w.focus();\"";
                     } else {
                         $href = " href=\"" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\" ";
                     }
                     echo Search::showItem($output_type, "<div class='kb'><a " . ($data['is_faq'] ? " class='pubfaq' " : " class='knowbase' ") . " {$href}>" . Html::resume_text($data["name"], 80) . "</a></div>\n                                          <div class='kb_resume'>" . Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($data["answer"])), 600) . "</div>", $item_num, $row_num);
                 } else {
                     echo Search::showItem($output_type, $data["name"], $item_num, $row_num);
                     echo Search::showItem($output_type, Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($data["answer"], ENT_QUOTES, "UTF-8"))), $item_num, $row_num);
                 }
                 if ($showwriter) {
                     echo Search::showItem($output_type, getUserName($data["users_id"], 1), $item_num, $row_num);
                 }
                 $categ = $data["category"];
                 if ($output_type == Search::HTML_OUTPUT) {
                     $cathref = $ki->getSearchURL() . "?knowbaseitemcategories_id=" . $data["knowbaseitemcategories_id"] . '&amp;forcetab=Knowbase$2';
                     $categ = "<a href='{$cathref}'>" . $categ . '</a>';
                 }
                 echo Search::showItem($output_type, $categ, $item_num, $row_num);
                 if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
                     $content = "<a href='" . Toolbox::getItemTypeFormURL($options['item_itemtype']) . "?load_kb_sol=" . $data['id'] . "&amp;id=" . $options['item_items_id'] . "&amp;forcetab=" . $options['item_itemtype'] . "\$2'>" . __('Use as a solution') . "</a>";
                     echo Search::showItem($output_type, $content, $item_num, $row_num);
                 }
                 // End Line
                 echo Search::showEndLine($output_type);
             }
             // Display footer
             if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) {
                 echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id']));
             } else {
                 echo Search::showFooter($output_type);
             }
             echo "<br>";
             if ($output_type == Search::HTML_OUTPUT) {
                 Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
             }
         } else {
             echo "<div class='center b'>" . __('No item found') . "</div>";
         }
     }
 }
Пример #22
0
*/
include '../inc/includes.php';
Session::checkCentralAccess();
Html::header(Rule::getTypeName(2), $_SERVER['PHP_SELF'], "admin", "rule", -1);
echo "<table class='tab_cadre'>";
echo "<tr><th>" . __('Rule type') . "</th></tr>";
foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
    $rulecollection = new $rulecollectionclass();
    if ($rulecollection->canList()) {
        if ($plug = isPluginItemType($rulecollectionclass)) {
            $title = sprintf(__('%1$s - %2$s'), Plugin::getInfo($plug['plugin'], 'name'), $rulecollection->getTitle());
        } else {
            $title = $rulecollection->getTitle();
        }
        echo "<tr class='tab_bg_1'><td class='center b'>";
        echo "<a href='" . Toolbox::getItemTypeSearchURL($rulecollection->getRuleClassName()) . "'>";
        echo $title . "</a></td></tr>";
    }
}
if (Session::haveRight("transfer", "r") && Session::isMultiEntitiesMode()) {
    echo "<tr class='tab_bg_1'><td class='center b'>";
    echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/transfer.php'>" . __('Transfer') . "</a>";
    echo "</td></tr>";
}
if (Session::haveRight("config", "r")) {
    echo "<tr class='tab_bg_1'><td class='center b'>";
    echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/blacklist.php'>" . _n('Blacklist', 'Blacklists', 2) . "</a>";
    echo "</td></tr>";
}
echo "</table>";
Html::footer();
 /**
  *  Check if we can edit (or delete) this item
  *  If it's not possible display an error message
  **/
 function getEditErrorMessage($order_type = NULL)
 {
     $this->getRunningTasks();
     $error_message = "";
     $tasklist = array();
     if (isset($order_type)) {
         $tasklist = array_filter($this->running_tasks, create_function('$task', 'return $task["taskjob"]["method"]=="deploy' . $order_type . '";'));
     } else {
         $tasklist = $this->running_tasks;
     }
     if (count($tasklist) > 0) {
         // Display error message
         $error_message .= "<h3 class='red'>";
         $error_message .= __("Modification Denied", 'fusioninventory');
         $error_message .= "</h3>\n";
         $error_message .= "<h4>" . _n("The following task is running with this package", "The following tasks are running with this package", count($this->running_tasks), 'fusioninventory') . "</h4>\n";
         //         $taskurl_list_ids = implode( ', ',
         //            array_map(
         //               create_function('$task', 'return $task["task"]["id"];'),
         //               $this->running_tasks
         //            )
         //         );
         $taskurl_list_names = implode(', ', array_map(create_function('$task', 'return "\\"".$task["task"]["name"]."\\"";'), $this->running_tasks));
         /**
          * WARNING:
          * The following may be considered as a hack until we get
          * the Search class splitted to get a SearchUrl correctly
          * (cf. https://forge.indepnet.net/issues/2476)
          **/
         $taskurl_base = Toolbox::getItemTypeSearchURL("PluginFusioninventoryTaskJob", TRUE);
         $taskurl_args = implode("&", array(urlencode("field[0]") . "=4", urlencode("searchtype[0]") . "=contains", urlencode("contains[0]") . "= " . urlencode('[' . $taskurl_list_names . ']'), "itemtype=PluginFusioninventoryTask", "start=0"));
         $error_message .= "<a href='{$taskurl_base}?{$taskurl_args}'>";
         $error_message .= $taskurl_list_names;
         $error_message .= "</a>";
     }
     return $error_message;
 }
Пример #24
0
 /**
  * Print the acccount form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  * @return Nothing (display)
  **/
 public function showForm($ID, $options = array())
 {
     if (!$this->canView()) {
         return false;
     }
     $hashclass = new PluginAccountsHash();
     $restrict = getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', '', $hashclass->maybeRecursive());
     if ($ID < 1 && countElementsInTable("glpi_plugin_accounts_hashes", $restrict) == 0) {
         echo "<div class='center'>" . __('There is no encryption key for this entity', 'accounts') . "<br><br>";
         echo "<a href='" . Toolbox::getItemTypeSearchURL('PluginAccountsAccount') . "'>";
         _e('Back');
         echo "</a></div>";
         return false;
     }
     /*
           if ($ID > 0) {
              $this->check($ID, READ);
              if (!Session::haveRight("plugin_accounts_see_all_users", 1)) {
                 $access = 0;
                 if (Session::haveRight("plugin_accounts_my_groups", 1)) {
                    if ($this->fields["groups_id"]) {
                       if (count($_SESSION['glpigroups'])
                                && in_array($this->fields["groups_id"], $_SESSION['glpigroups'])
                       ) {
                          $access = 1;
                       }
                    }
                    if ($this->fields["users_id"]) {
                       if ($this->fields["users_id"] == Session::getLoginUserID())
                          $access = 1;
                    }
                 }
                 if (!Session::haveRight("plugin_accounts_my_groups", 1)
                          && $this->fields["users_id"] == Session::getLoginUserID()
                 )
                    $access = 1;
     
                 if ($access != 1)
                    return false;
              }
           } else {
              // Create item
              $this->check(-1, UPDATE);
              $this->getEmpty();
           }
     */
     $options["formoptions"] = "id = 'account_form'";
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Status') . "</td><td>";
     Dropdown::show('PluginAccountsAccountState', array('value' => $this->fields["plugin_accounts_accountstates_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Login') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "login");
     echo "</td>";
     echo "<td>" . __('Type') . "</td><td>";
     Dropdown::show('PluginAccountsAccountType', array('value' => $this->fields["plugin_accounts_accounttypes_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     //hash
     $hash = 0;
     $restrict = getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', $this->getEntityID(), $hashclass->maybeRecursive());
     $hashes = getAllDatasFromTable("glpi_plugin_accounts_hashes", $restrict);
     if (!empty($hashes)) {
         foreach ($hashes as $hashe) {
             $hash = $hashe["hash"];
             $hash_id = $hashe["id"];
         }
         $alert = '';
     } else {
         $alert = __('There is no encryption key for this entity', 'accounts');
     }
     $aeskey = new PluginAccountsAesKey();
     //aeskey non enregistre
     if ($hash) {
         if (!$aeskey->getFromDBByHash($hash_id) || !$aeskey->fields["name"]) {
             echo "<td>" . __('Encryption key', 'accounts') . "</div></td><td>";
             echo "<input type='password' autocomplete='off' name='aeskey' id='aeskey'>";
             echo Html::hidden('encrypted_password', array('value' => $this->fields["encrypted_password"], 'id' => 'encrypted_password'));
             echo Html::hidden('good_hash', array('value' => $hash, 'id' => 'good_hash'));
             echo Html::hidden('wrong_key_locale', array('value' => __('Wrong encryption key', 'accounts'), 'id' => 'wrong_key_locale'));
             if (!empty($ID) || $ID > 0) {
                 $url = $this->getFormURL();
                 echo "&nbsp;<input type='button' id='decrypte_link' name='decrypte' value='" . __s('Uncrypt', 'accounts') . "'\n                        class='submit'>";
             }
             echo "</td>";
         } else {
             echo "<td></td><td>";
             echo "</td>";
         }
     } else {
         echo "<td>" . __('Encryption key', 'accounts') . "</div></td><td><div class='red'>";
         echo $alert;
         echo "</div></td>";
     }
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         echo "<td>" . __('Affected User', 'accounts') . "</td><td>";
         if ($this->canCreate()) {
             User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         } else {
             echo getUserName($this->fields["users_id"]);
         }
         echo "</td>";
     } else {
         echo "<td>" . __('Affected User', 'accounts') . "</td><td>";
         echo getUserName($this->fields["users_id"]);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Password') . "</td>";
     echo "<td>";
     //aeskey enregistre
     if (isset($hash_id) && $aeskey->getFromDBByHash($hash_id) && $aeskey->fields["name"]) {
         echo Html::hidden('good_hash', array('value' => $hash, 'id' => 'good_hash'));
         echo Html::hidden('aeskey', array('value' => $aeskey->fields["name"], 'id' => 'aeskey', 'autocomplete' => 'off'));
         echo Html::hidden('encrypted_password', array('value' => $this->fields["encrypted_password"], 'id' => 'encrypted_password'));
         echo Html::hidden('wrong_key_locale', array('value' => __('Wrong encryption key', 'accounts'), 'id' => 'wrong_key_locale'));
         echo Html::scriptBlock("auto_decrypt();");
     }
     echo "<input type='text' name='hidden_password' id='hidden_password' size='30' >";
     echo "</td>";
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         echo "<td>" . __('Affected Group', 'accounts') . "</td><td>";
         if (self::canCreate()) {
             Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'condition' => '`is_itemgroup`'));
         } else {
             echo Dropdown::getDropdownName("glpi_groups", $this->fields["groups_id"]);
         }
         echo "</td>";
     } else {
         echo "<td>" . __('Affected Group', 'accounts') . ":\t</td><td>";
         echo Dropdown::getDropdownName("glpi_groups", $this->fields["groups_id"]);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Creation date') . "</td>";
     echo "<td>";
     Html::showDateFormItem("date_creation", $this->fields["date_creation"], true, true);
     echo "</td>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"], 'entity' => $this->fields["entities_id"], 'right' => 'interface'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration date') . "&nbsp;";
     Html::showToolTip(nl2br(__('Empty for infinite', 'accounts')));
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("date_expiration", $this->fields["date_expiration"], true, true);
     echo "</td>";
     echo "<td>" . __('Group in charge of the hardware') . "</td><td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Others') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "others");
     echo "</td>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan = '4'>";
     echo "<table cellpadding='2' cellspacing='2' border='0'><tr><td>";
     echo __('Comments') . "</td></tr>";
     echo "<tr><td class='center'>";
     echo "<textarea cols='125' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr></table>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td>";
     echo "<td colspan='2'>";
     printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     echo "</td>";
     echo "</tr>";
     if (self::canCreate()) {
         if (empty($ID) || $ID < 0) {
             echo "<tr>";
             echo "<td class='tab_bg_2 top' colspan='4'>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add' id='account_add' value='" . _sx('button', 'Add') . "' class='submit'>";
             echo "</div>";
             echo Html::scriptBlock("\$('#account_form').submit(function(event){\n               if (\$('#hidden_password').val() == '' || \$('#aeskey').val() == '') {\n                  alert('" . __('You have not filled the password and encryption key', 'accounts') . "');\n                  return false;\n               };\n               if (!check_hash()) {\n                  alert('" . __('Wrong encryption key', 'accounts') . "');\n                  return false;\n               } else {\n                  encrypt_password();\n               }\n            });");
             echo "</td>";
             echo "</tr>";
         } else {
             echo "<tr>";
             echo "<td class='tab_bg_2'  colspan='4 top'><div align='center'>";
             echo "<input type='hidden' name='id' value=\"{$ID}\">";
             echo "<input type='submit' name='update' id='account_update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
             echo Html::scriptBlock("\$('#account_form').submit(function(event){\n               if (\$('#hidden_password').val() == '' || \$('#aeskey').val() == '') {\n                  alert('" . __('Password will not be modified', 'accounts') . "');\n               } else if (!check_hash()) {\n                  alert('" . __('Wrong encryption key', 'accounts') . "');\n                  return false;\n               } else {\n                  encrypt_password();\n               }\n            });");
             if ($this->fields["is_deleted"] == '0') {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='delete' value=\"" . _sx('button', 'Put in dustbin') . "\" class='submit'></div>";
             } else {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='restore' value=\"" . _sx('button', 'Restore') . "\" class='submit'>";
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'></div>";
             }
             echo "</td>";
             echo "</tr>";
         }
     }
     $options['canedit'] = false;
     $options['candel'] = false;
     $this->showFormButtons($options);
     Html::closeForm();
     return true;
 }
Пример #25
0
 /**
  * Print generic search form
  *
  * Params need to parsed before using Search::manageParams function
  *
  * @param $itemtype        type to display the form
  * @param $params    array of parameters may include sort, is_deleted, criteria, metacriteria
  *
  * @return nothing (displays)
  **/
 static function showGenericSearch($itemtype, array $params)
 {
     global $CFG_GLPI;
     // Default values of parameters
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['criteria'] = array();
     $p['metacriteria'] = array();
     if (class_exists($itemtype)) {
         $p['target'] = $itemtype::getSearchURL();
     } else {
         $p['target'] = Toolbox::getItemTypeSearchURL($itemtype);
     }
     $p['showreset'] = true;
     $p['showbookmark'] = true;
     $p['addhidden'] = array();
     $p['actionname'] = 'search';
     $p['actionvalue'] = _sx('button', 'Search');
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     echo "<form name='searchform{$itemtype}' method='get' action=\"" . $p['target'] . "\">";
     echo "<div id='searchcriterias'>";
     $nbsearchcountvar = 'nbcriteria' . strtolower($itemtype) . mt_rand();
     $nbmetasearchcountvar = 'nbmetacriteria' . strtolower($itemtype) . mt_rand();
     $searchcriteriatableid = 'criteriatable' . strtolower($itemtype) . mt_rand();
     // init criteria count
     $js = "var {$nbsearchcountvar}=" . count($p['criteria']) . ";";
     $js .= "var {$nbmetasearchcountvar}=" . count($p['metacriteria']) . ";";
     echo Html::scriptBlock($js);
     echo "<table class='tab_cadre_fixe' >";
     echo "<tr class='tab_bg_1'>";
     if (count($p['criteria']) + count($p['metacriteria']) > 1) {
         echo "<td width='10' class='center'>";
         echo "<a href=\"javascript:toggleTableDisplay('{$searchcriteriatableid}','searchcriteriasimg',\n                                                       '" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png',\n                                                       '" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png')\">";
         echo "<img alt='' name='searchcriteriasimg' src=\"" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png\">";
         echo "</td>";
     }
     echo "<td>";
     echo "<table class='tab_format' id='{$searchcriteriatableid}'>";
     // Display normal search parameters
     for ($i = 0; $i < count($p['criteria']); $i++) {
         $_POST['itemtype'] = $itemtype;
         $_POST['num'] = $i;
         include GLPI_ROOT . '/ajax/searchrow.php';
     }
     $metanames = array();
     $linked = self::getMetaItemtypeAvailable($itemtype);
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < count($p['metacriteria']); $i++) {
             $_POST['itemtype'] = $itemtype;
             $_POST['num'] = $i;
             include GLPI_ROOT . '/ajax/searchmetarow.php';
         }
     }
     echo "</table>\n";
     echo "</td>\n";
     echo "<td width='150px'>";
     echo "<table width='100%'>";
     // Display deleted selection
     echo "<tr>";
     // Display submit button
     echo "<td width='80' class='center'>";
     echo "<input type='submit' name='" . $p['actionname'] . "' value=\"" . $p['actionvalue'] . "\" class='submit' >";
     echo "</td>";
     if ($p['showbookmark'] || $p['showreset']) {
         echo "<td>";
         if ($p['showbookmark']) {
             Bookmark::showSaveButton(Bookmark::SEARCH, $itemtype);
         }
         if ($p['showreset']) {
             echo "<a href='" . $p['target'] . (strpos($p['target'], '?') ? '&amp;' : '?') . "reset=reset' >";
             echo "&nbsp;&nbsp;<img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier pointer'></a>";
         }
         echo "</td>";
     }
     echo "</tr></table>\n";
     echo "</td></tr>";
     echo "</table>\n";
     if (count($p['addhidden'])) {
         foreach ($p['addhidden'] as $key => $val) {
             echo Html::hidden($key, array('value' => $val));
         }
     }
     // For dropdown
     echo Html::hidden('itemtype', array('value' => $itemtype));
     // Reset to start when submit new search
     echo Html::hidden('start', array('value' => 0));
     echo "</div>";
     Html::closeForm();
 }
Пример #26
0
 static function registerType()
 {
     global $DB, $PLUGIN_HOOKS, $UNINSTALL_TYPES, $ORDER_TYPES, $CFG_GLPI, $GO_LINKED_TYPES;
     $class = get_called_class();
     $item = new $class();
     $fields = PluginGenericobjectSingletonObjectField::getInstance($class);
     PluginGenericobjectType::includeLocales($item->getObjectTypeName());
     PluginGenericobjectType::includeConstants($item->getObjectTypeName());
     $options = array("document_types" => $item->canUseDocuments(), "helpdesk_visible_types" => $item->canUseTickets(), "linkgroup_types" => $item->canUseTickets() && isset($fields["groups_id"]), "linkuser_types" => $item->canUseTickets() && isset($fields["users_id"]), "ticket_types" => $item->canUseTickets(), "infocom_types" => $item->canUseInfocoms(), "networkport_types" => $item->canUseNetworkPorts(), "reservation_types" => $item->canBeReserved(), "contract_types" => $item->canUseContracts(), "unicity_types" => $item->canUseUnicity());
     Plugin::registerClass($class, $options);
     if (Session::haveRight($class, "r")) {
         //Change url for adding a new object, depending on template management activation
         if ($item->canUseTemplate()) {
             //Template management is active
             $add_url = "/front/setup.templates.php?itemtype={$class}&amp;add=1";
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['template'] = "/front/setup.templates.php?itemtype={$class}&amp;add=0";
         } else {
             //Template management is not active
             $add_url = Toolbox::getItemTypeFormURL($class, false);
         }
         //Menu management
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['title'] = $class::getTypeName();
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['page'] = Toolbox::getItemTypeSearchURL($class, false);
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['search'] = Toolbox::getItemTypeSearchURL($class, false);
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = $add_url;
         //Add configuration icon, if user has right
         if (Session::haveRight('config', 'w')) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['config'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType', false) . "?itemtype={$class}";
         }
         //Item can be linked to tickets
         if ($item->canUseTickets()) {
             if (!in_array($class, $_SESSION['glpiactiveprofile']['helpdesk_item_type'])) {
                 $_SESSION['glpiactiveprofile']['helpdesk_item_type'][] = $class;
             }
         }
         if ($item->canUsePluginUninstall()) {
             if (!in_array($class, $UNINSTALL_TYPES)) {
                 array_push($UNINSTALL_TYPES, $class);
             }
         }
         if ($item->canUsePluginOrder()) {
             if (!in_array($class, $ORDER_TYPES)) {
                 array_push($ORDER_TYPES, $class);
             }
         }
         if ($item->canUseGlobalSearch()) {
             if (!in_array($class, $CFG_GLPI['state_types'])) {
                 array_push($CFG_GLPI['state_types'], $class);
             }
         }
         if ($item->canUseDirectConnections()) {
             if (!in_array($class, $GO_LINKED_TYPES)) {
                 array_push($GO_LINKED_TYPES, $class);
             }
             $items_class = $class . "_Item";
             //if (class_exists($items_class)) {
             $items_class::registerType();
             //}
         }
     }
     foreach (PluginGenericobjectType::getDropdownForItemtype($class) as $table) {
         $itemtype = getItemTypeForTable($table);
         $item = new $itemtype();
         //If entity dropdown, check rights to view & create
         if ($itemtype::canView()) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$itemtype]['links']['search'] = Toolbox::getItemTypeSearchURL($itemtype, false);
             if ($itemtype::canCreate()) {
                 $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = Toolbox::getItemTypeFormURL($class, false);
             }
         }
     }
 }
Пример #27
0
 /**
  * Print the HTML array for infocoms linked
  *
  *@return Nothing (display)
  *
  **/
 function showInfocoms()
 {
     global $DB, $CFG_GLPI;
     $instID = $this->fields['id'];
     if (!$this->can($instID, 'r')) {
         return false;
     }
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_infocoms`\n                WHERE `suppliers_id` = '{$instID}'\n                      AND `itemtype` NOT IN ('ConsumableItem', 'CartridgeItem', 'Software')\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>";
     Html::printPagerForm();
     echo "</th><th colspan='3'>";
     if ($DB->numrows($result) == 0) {
         _e('No associated item');
     } else {
         echo _n('Associated item', 'Associated items', $DB->numrows($result));
     }
     echo "</th></tr>";
     echo "<tr><th>" . __('Type') . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     $num = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $linktype = $itemtype;
             $linkfield = 'id';
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `glpi_infocoms`.`entities_id`, `name`, `{$itemtable}`.*\n                      FROM `glpi_infocoms`\n                      INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`) ";
             // Set $linktype for entity restriction AND link to search engine
             if ($itemtype == 'Cartridge') {
                 $query .= "INNER JOIN `glpi_cartridgeitems`\n                            ON (`glpi_cartridgeitems`.`id`=`glpi_cartridges`.`cartridgeitems_id`) ";
                 $linktype = 'CartridgeItem';
                 $linkfield = 'cartridgeitems_id';
             }
             if ($itemtype == 'Consumable') {
                 $query .= "INNER JOIN `glpi_consumableitems`\n                            ON (`glpi_consumableitems`.`id`=`glpi_consumables`.`consumableitems_id`) ";
                 $linktype = 'ConsumableItem';
                 $linkfield = 'consumableitems_id';
             }
             $linktable = getTableForItemType($linktype);
             $query .= "WHERE `glpi_infocoms`.`itemtype` = '{$itemtype}'\n                             AND `glpi_infocoms`.`suppliers_id` = '{$instID}'" . getEntitiesRestrictRequest(" AND", $linktable) . "\n                       ORDER BY `glpi_infocoms`.`entities_id`,\n                                `{$linktable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             // Set $linktype for link to search engine pnly
             if ($itemtype == 'SoftwareLicense' && $nb > $_SESSION['glpilist_limit']) {
                 $linktype = 'Software';
                 $linkfield = 'softwares_id';
             }
             if ($nb > $_SESSION['glpilist_limit']) {
                 echo "<tr class='tab_bg_1'>";
                 $title = $item->getTypeName($nb);
                 if ($nb > 0) {
                     $title = sprintf(__('%1$s: %2$s'), $title, $nb);
                 }
                 echo "<td class='center'>" . $title . "</td>";
                 echo "<td class='center' colspan='2'>";
                 echo "<a href='" . Toolbox::getItemTypeSearchURL($linktype) . "?" . rawurlencode("contains[0]") . "=" . rawurlencode('$$$$' . $instID) . "&" . rawurlencode("field[0]") . "=53&sort=80&order=ASC&is_deleted=0&start=0" . "'>" . __('Device list') . "</a></td>";
                 echo "<td class='center'>-</td><td class='center'>-</td></tr>";
             } else {
                 if ($nb) {
                     for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                         $name = $data["name"];
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
                         }
                         $link = Toolbox::getItemTypeFormURL($linktype);
                         $name = "<a href=\"" . $link . "?id=" . $data[$linkfield] . "\">" . $name . "</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($prem) {
                             $title = $item->getTypeName($nb);
                             if ($nb > 0) {
                                 $title = sprintf(__('%1$s: %2$s'), $title, $nb);
                             }
                             echo "<td class='center top' rowspan='{$nb}'>" . $title . "</td>";
                         }
                         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "</td>";
                         echo "<td class='center";
                         echo (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'") . ">";
                         echo $name . "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
             $num += $nb;
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center'>" . ($num > 0 ? sprintf(__('%1$s = %2$s'), __('Total'), $num) : "&nbsp;") . "</td>";
     echo "<td colspan='4'>&nbsp;</td></tr> ";
     echo "</table></div>";
 }
Пример #28
0
 /**
  * Print a nice HTML head for every page
  *
  * @param $title     title of the page
  * @param $url       not used anymore (default '')
  * @param $sector    sector in which the page displayed is (default 'none')
  * @param $item      item corresponding to the page displayed (default 'none')
  * @param $option    option corresponding to the page displayed (default '')
  **/
 static function header($title, $url = '', $sector = "none", $item = "none", $option = "")
 {
     global $CFG_GLPI, $PLUGIN_HOOKS, $HEADER_LOADED, $DB;
     // Print a nice HTML-head for every page
     if ($HEADER_LOADED) {
         return;
     }
     $HEADER_LOADED = true;
     self::includeHeader($title);
     // Body
     echo "<body>";
     // Generate array for menu and check right
     // INVENTORY
     $showallassets = false;
     $menu['inventory']['title'] = __('Assets');
     if (Session::haveRight("computer", "r")) {
         $menu['inventory']['default'] = '/front/computer.php';
         $menu['inventory']['content']['computer']['title'] = _n('Computer', 'Computers', 2);
         $menu['inventory']['content']['computer']['shortcut'] = 'o';
         $menu['inventory']['content']['computer']['page'] = '/front/computer.php';
         $menu['inventory']['content']['computer']['links']['search'] = '/front/computer.php';
         if (Session::haveRight("computer", "w")) {
             $menu['inventory']['content']['computer']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Computer&amp;add=1';
             $menu['inventory']['content']['computer']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Computer&amp;add=0';
         }
         $showallassets = true;
     }
     if (Session::haveRight("monitor", "r")) {
         $menu['inventory']['content']['monitor']['title'] = _n('Monitor', 'Monitors', 2);
         $menu['inventory']['content']['monitor']['shortcut'] = '';
         $menu['inventory']['content']['monitor']['page'] = '/front/monitor.php';
         $menu['inventory']['content']['monitor']['links']['search'] = '/front/monitor.php';
         if (Session::haveRight("monitor", "w")) {
             $menu['inventory']['content']['monitor']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Monitor&amp;add=1';
             $menu['inventory']['content']['monitor']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Monitor&amp;add=0';
         }
         $showallassets = true;
     }
     if (Session::haveRight("software", "r")) {
         $menu['inventory']['content']['software']['title'] = _n('Software', 'Software', 2);
         $menu['inventory']['content']['software']['shortcut'] = 's';
         $menu['inventory']['content']['software']['page'] = '/front/software.php';
         $menu['inventory']['content']['software']['links']['search'] = '/front/software.php';
         if (Session::haveRight("software", "w")) {
             $menu['inventory']['content']['software']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Software&amp;add=1';
             $menu['inventory']['content']['software']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Software&amp;add=0';
         }
     }
     if (Session::haveRight("networking", "r")) {
         $menu['inventory']['content']['networking']['title'] = _n('Network', 'Networks', 2);
         $menu['inventory']['content']['networking']['shortcut'] = '';
         $menu['inventory']['content']['networking']['page'] = '/front/networkequipment.php';
         $menu['inventory']['content']['networking']['links']['search'] = '/front/networkequipment.php';
         $menu['inventory']['content']['networking']['options']['networkport']['title'] = _n('Network port', 'Network ports', 2);
         $menu['inventory']['content']['networking']['options']['networkport']['page'] = '/front/networkport.form.php';
         $menu['inventory']['content']['networking']['options']['networkport']['links'] = array();
         if (Session::haveRight("networking", "w")) {
             $menu['inventory']['content']['networking']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=NetworkEquipment&amp;add=1';
             $menu['inventory']['content']['networking']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=NetworkEquipment&amp;add=0';
         }
         $showallassets = true;
     }
     if (Session::haveRight("peripheral", "r")) {
         $menu['inventory']['content']['peripheral']['title'] = _n('Device', 'Devices', 2);
         $menu['inventory']['content']['peripheral']['shortcut'] = '';
         $menu['inventory']['content']['peripheral']['page'] = '/front/peripheral.php';
         $menu['inventory']['content']['peripheral']['links']['search'] = '/front/peripheral.php';
         if (Session::haveRight("peripheral", "w")) {
             $menu['inventory']['content']['peripheral']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Peripheral&amp;add=1';
             $menu['inventory']['content']['peripheral']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Peripheral&amp;add=0';
         }
         $showallassets = true;
     }
     if (Session::haveRight("printer", "r")) {
         $menu['inventory']['content']['printer']['title'] = _n('Printer', 'Printers', 2);
         $menu['inventory']['content']['printer']['shortcut'] = '';
         $menu['inventory']['content']['printer']['page'] = '/front/printer.php';
         $menu['inventory']['content']['printer']['links']['search'] = '/front/printer.php';
         if (Session::haveRight("printer", "w")) {
             $menu['inventory']['content']['printer']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Printer&amp;add=1';
             $menu['inventory']['content']['printer']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Printer&amp;add=0';
         }
         $showallassets = true;
     }
     if (Session::haveRight("cartridge", "r")) {
         $menu['inventory']['content']['cartridge']['title'] = _n('Cartridge', 'Cartridges', 2);
         $menu['inventory']['content']['cartridge']['shortcut'] = '';
         $menu['inventory']['content']['cartridge']['page'] = '/front/cartridgeitem.php';
         $menu['inventory']['content']['cartridge']['links']['search'] = '/front/cartridgeitem.php';
         if (Session::haveRight("cartridge", "w")) {
             $menu['inventory']['content']['cartridge']['links']['add'] = '/front/cartridgeitem.form.php';
         }
     }
     if (Session::haveRight("consumable", "r")) {
         $menu['inventory']['content']['consumable']['title'] = _n('Consumable', 'Consumables', 2);
         $menu['inventory']['content']['consumable']['shortcut'] = '';
         $menu['inventory']['content']['consumable']['page'] = '/front/consumableitem.php';
         $menu['inventory']['content']['consumable']['links']['search'] = '/front/consumableitem.php';
         if (Session::haveRight("consumable", "w")) {
             $menu['inventory']['content']['consumable']['links']['add'] = '/front/consumableitem.form.php';
         }
         $menu['inventory']['content']['consumable']['links']['summary'] = '/front/consumableitem.php?' . 'synthese=yes';
     }
     if (Session::haveRight("phone", "r")) {
         $menu['inventory']['content']['phone']['title'] = _n('Phone', 'Phones', 2);
         $menu['inventory']['content']['phone']['shortcut'] = '';
         $menu['inventory']['content']['phone']['page'] = '/front/phone.php';
         $menu['inventory']['content']['phone']['links']['search'] = '/front/phone.php';
         if (Session::haveRight("phone", "w")) {
             $menu['inventory']['content']['phone']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Phone&amp;add=1';
             $menu['inventory']['content']['phone']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Phone&amp;add=0';
         }
         $showallassets = true;
     }
     if ($showallassets) {
         $menu['inventory']['content']['allassets']['title'] = __('Global');
         $menu['inventory']['content']['allassets']['shortcut'] = '';
         $menu['inventory']['content']['allassets']['page'] = '/front/allassets.php';
         $menu['inventory']['content']['allassets']['links']['search'] = '/front/allassets.php';
     }
     // ASSISTANCE
     $menu['maintain']['title'] = __('Assistance');
     if (Session::haveRight("observe_ticket", "1") || Session::haveRight("show_all_ticket", "1") || Session::haveRight("create_ticket", "1")) {
         $menu['maintain']['default'] = '/front/ticket.php';
         $menu['maintain']['content']['ticket']['title'] = _n('Ticket', 'Tickets', 2);
         $menu['maintain']['content']['ticket']['shortcut'] = 't';
         $menu['maintain']['content']['ticket']['page'] = '/front/ticket.php';
         $menu['maintain']['content']['ticket']['links']['search'] = '/front/ticket.php';
         if (Session::haveRight('tickettemplate', 'r')) {
             $menu['maintain']['content']['ticket']['options']['TicketTemplate']['title'] = _n('Ticket template', 'Ticket templates', 2);
             $menu['maintain']['content']['ticket']['options']['TicketTemplate']['page'] = '/front/tickettemplate.php';
             $menu['maintain']['content']['ticket']['options']['TicketTemplate']['links']['search'] = '/front/tickettemplate.php';
             if (Session::haveRight('tickettemplate', 'w')) {
                 $menu['maintain']['content']['ticket']['options']['TicketTemplate']['links']['add'] = '/front/tickettemplate.form.php';
             }
             $menu['maintain']['content']['ticket']['links']['template'] = '/front/tickettemplate.php';
         }
         if (Session::haveRight('validate_incident', 1) || Session::haveRight('validate_request', 1)) {
             $opt = array();
             $opt['reset'] = 'reset';
             $opt['field'][0] = 55;
             // validation status
             $opt['searchtype'][0] = 'equals';
             $opt['contains'][0] = 'waiting';
             $opt['link'][0] = 'AND';
             $opt['field'][1] = 59;
             // validation aprobator
             $opt['searchtype'][1] = 'equals';
             $opt['contains'][1] = Session::getLoginUserID();
             $opt['link'][1] = 'AND';
             $pic_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'>";
             $menu['maintain']['content']['ticket']['links'][$pic_validate] = '/front/ticket.php?' . Toolbox::append_params($opt, '&amp;');
         }
     }
     if (Session::haveRight("create_ticket", "1")) {
         $menu['maintain']['content']['ticket']['links']['add'] = '/front/ticket.form.php';
     }
     if (Session::haveRight("show_all_problem", "1") || Session::haveRight("show_my_problem", "1") || Session::haveRight("delete_problem", "1")) {
         $menu['maintain']['content']['problem']['title'] = _n('Problem', 'Problems', 2);
         $menu['maintain']['content']['problem']['shortcut'] = '';
         $menu['maintain']['content']['problem']['page'] = '/front/problem.php';
         $menu['maintain']['content']['problem']['links']['search'] = '/front/problem.php';
         if (Session::haveRight("edit_all_problem", "1")) {
             $menu['maintain']['content']['problem']['links']['add'] = '/front/problem.form.php';
         }
     }
     //       if (Session::haveRight("show_all_change","1")
     //           || Session::haveRight("show_my_change","1")) {
     //          $menu['maintain']['content']['change']['title']           = _n('Change', 'Changes', 2);
     //          $menu['maintain']['content']['change']['shortcut']        = '';
     //          $menu['maintain']['content']['change']['page']            = '/front/change.php';
     //          $menu['maintain']['content']['change']['links']['search'] = '/front/change.php';
     //          if (Session::haveRight("edit_all_change","1")) {
     //             $menu['maintain']['content']['change']['links']['add'] = '/front/change.form.php';
     //          }
     //       }
     if (Session::haveRight("show_planning", "1") || Session::haveRight("show_all_planning", "1") || Session::haveRight("show_group_planning", "1")) {
         $menu['maintain']['content']['planning']['title'] = __('Planning');
         $menu['maintain']['content']['planning']['shortcut'] = 'p';
         $menu['maintain']['content']['planning']['page'] = '/front/planning.php';
         $menu['maintain']['content']['planning']['links']['search'] = '/front/planning.php';
     }
     if (Session::haveRight("statistic", "1")) {
         $menu['maintain']['content']['stat']['title'] = __('Statistics');
         $menu['maintain']['content']['stat']['shortcut'] = 'a';
         $menu['maintain']['content']['stat']['page'] = '/front/stat.php';
     }
     if (Session::haveRight("ticketrecurrent", "r")) {
         $menu['maintain']['content']['ticketrecurrent']['title'] = __('Recurrent tickets');
         $menu['maintain']['content']['ticketrecurrent']['shortcut'] = '';
         $menu['maintain']['content']['ticketrecurrent']['page'] = '/front/ticketrecurrent.php';
         $menu['maintain']['content']['ticketrecurrent']['links']['search'] = '/front/ticketrecurrent.php';
         if (Session::haveRight("ticketrecurrent", "w")) {
             $menu['maintain']['content']['ticketrecurrent']['links']['add'] = '/front/ticketrecurrent.form.php';
         }
     }
     // FINANCIAL
     $menu['financial']['title'] = __('Management');
     if (Session::haveRight("budget", "r")) {
         $menu['financial']['default'] = '/front/budget.php';
         $menu['financial']['content']['budget']['title'] = _n('Budget', 'Budgets', 2);
         $menu['financial']['content']['budget']['shortcut'] = '';
         $menu['financial']['content']['budget']['page'] = '/front/budget.php';
         $menu['financial']['content']['budget']['links']['search'] = '/front/budget.php';
         if (Session::haveRight("budget", "w")) {
             $menu['financial']['content']['budget']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Budget&amp;add=1';
             $menu['financial']['content']['budget']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Budget&amp;add=0';
         }
     }
     if (Session::haveRight("contact_enterprise", "r")) {
         $menu['financial']['content']['supplier']['title'] = _n('Supplier', 'Suppliers', 2);
         $menu['financial']['content']['supplier']['shortcut'] = '';
         $menu['financial']['content']['supplier']['page'] = '/front/supplier.php';
         $menu['financial']['content']['supplier']['links']['search'] = '/front/supplier.php';
         $menu['financial']['content']['contact']['title'] = _n('Contact', 'Contacts', 2);
         $menu['financial']['content']['contact']['shortcut'] = '';
         $menu['financial']['content']['contact']['page'] = '/front/contact.php';
         $menu['financial']['content']['contact']['links']['search'] = '/front/contact.php';
         if (Session::haveRight("contact_enterprise", "w")) {
             $menu['financial']['content']['contact']['links']['add'] = '/front/contact.form.php';
             $menu['financial']['content']['supplier']['links']['add'] = '/front/supplier.form.php';
         }
     }
     if (Session::haveRight("contract", "r")) {
         $menu['financial']['content']['contract']['title'] = _n('Contract', 'Contracts', 2);
         $menu['financial']['content']['contract']['shortcut'] = '';
         $menu['financial']['content']['contract']['page'] = '/front/contract.php';
         $menu['financial']['content']['contract']['links']['search'] = '/front/contract.php';
         if (Session::haveRight("contract", "w")) {
             $menu['financial']['content']['contract']['links']['add'] = '/front/setup.templates.php?itemtype=Contract&amp;add=1';
             $menu['financial']['content']['contract']['links']['template'] = '/front/setup.templates.php?itemtype=Contract&amp;add=0';
         }
     }
     if (Session::haveRight("document", "r")) {
         $menu['financial']['content']['document']['title'] = _n('Document', 'Documents', 2);
         $menu['financial']['content']['document']['shortcut'] = 'd';
         $menu['financial']['content']['document']['page'] = '/front/document.php';
         $menu['financial']['content']['document']['links']['search'] = '/front/document.php';
         if (Session::haveRight("document", "w")) {
             $menu['financial']['content']['document']['links']['add'] = '/front/document.form.php';
         }
     }
     // UTILS
     $menu['utils']['title'] = __('Tools');
     $menu['utils']['default'] = '/front/reminder.php';
     if (Session::haveRight('reminder_public', 'r')) {
         $menu['utils']['content']['reminder']['title'] = _n('Reminder', 'Reminders', 2);
     } else {
         $menu['utils']['content']['reminder']['title'] = _n('Personal reminder', 'Personal reminders', 2);
     }
     $menu['utils']['content']['reminder']['page'] = '/front/reminder.php';
     $menu['utils']['content']['reminder']['links']['search'] = '/front/reminder.php';
     $menu['utils']['content']['reminder']['links']['add'] = '/front/reminder.form.php';
     $menu['utils']['content']['rssfeed']['title'] = _n('RSS feed', 'RSS feeds', 2);
     $menu['utils']['content']['rssfeed']['page'] = '/front/rssfeed.php';
     $menu['utils']['content']['rssfeed']['links']['search'] = '/front/rssfeed.php';
     $menu['utils']['content']['rssfeed']['links']['add'] = '/front/rssfeed.form.php';
     if (Session::haveRight("knowbase", "r") || Session::haveRight("faq", "r")) {
         if (Session::haveRight("knowbase", "r")) {
             $menu['utils']['content']['knowbase']['title'] = __('Knowledge base');
         } else {
             $menu['utils']['content']['knowbase']['title'] = __('FAQ');
         }
         $menu['utils']['content']['knowbase']['shortcut'] = 'b';
         $menu['utils']['content']['knowbase']['page'] = '/front/knowbaseitem.php';
         $menu['utils']['content']['knowbase']['links']['search'] = '/front/knowbaseitem.php';
         if (Session::haveRight("knowbase", "w") || Session::haveRight("faq", "w")) {
             $menu['utils']['content']['knowbase']['links']['add'] = '/front/knowbaseitem.form.php?id=new';
         }
     }
     if (Session::haveRight("reservation_helpdesk", "1") || Session::haveRight("reservation_central", "r")) {
         $menu['utils']['content']['reservation']['title'] = _n('Reservation', 'Reservations', 2);
         $menu['utils']['content']['reservation']['shortcut'] = 'r';
         $menu['utils']['content']['reservation']['page'] = '/front/reservationitem.php';
         $menu['utils']['content']['reservation']['links']['search'] = '/front/reservationitem.php';
         $menu['utils']['content']['reservation']['links']['showall'] = '/front/reservation.php';
     }
     if (Session::haveRight("reports", "r")) {
         $menu['utils']['content']['report']['title'] = _n('Report', 'Reports', 2);
         $menu['utils']['content']['report']['shortcut'] = 'e';
         $menu['utils']['content']['report']['page'] = '/front/report.php';
     }
     if (!isset($_SESSION['glpishowmigrationcleaner'])) {
         if (TableExists('glpi_networkportmigrations') && countElementsInTable('glpi_networkportmigrations') > 0) {
             $_SESSION['glpishowmigrationcleaner'] = true;
         } else {
             $_SESSION['glpishowmigrationcleaner'] = false;
         }
     }
     if ($_SESSION['glpishowmigrationcleaner'] && (Session::haveRight("networking", "w") || Session::haveRight("internet", "w"))) {
         $menu['utils']['content']['migration']['title'] = __('Migration cleaner');
         $menu['utils']['content']['migration']['page'] = '/front/migration_cleaner.php';
         $menu['utils']['content']['migration']['options']['networkportmigration']['title'] = __('Network port migration');
         $menu['utils']['content']['migration']['options']['networkportmigration']['page'] = '/front/networkportmigration.php';
         $menu['utils']['content']['migration']['options']['networkportmigration']['links']['search'] = '/front/networkportmigration.php';
     }
     // PLUGINS
     if (isset($PLUGIN_HOOKS["menu_entry"]) && count($PLUGIN_HOOKS["menu_entry"])) {
         $menu['plugins']['title'] = __('Plugins');
         $plugins = array();
         foreach ($PLUGIN_HOOKS["menu_entry"] as $plugin => $active) {
             if ($active) {
                 // true or a string
                 $plugins[$plugin] = Plugin::getInfo($plugin);
             }
         }
         if (count($plugins)) {
             $list = array();
             foreach ($plugins as $key => $val) {
                 $list[$key] = $val["name"];
             }
             asort($list);
             foreach ($list as $key => $val) {
                 $menu['plugins']['content'][$key]['title'] = $val;
                 $menu['plugins']['content'][$key]['page'] = '/plugins/' . $key . '/';
                 if (is_string($PLUGIN_HOOKS["menu_entry"][$key])) {
                     $menu['plugins']['content'][$key]['page'] .= $PLUGIN_HOOKS["menu_entry"][$key];
                 }
                 // Set default link for plugins
                 if (!isset($menu['plugins']['default'])) {
                     $menu['plugins']['default'] = $menu['plugins']['content'][$key]['page'];
                 }
                 if ($sector == "plugins" && $item == $key) {
                     if (isset($PLUGIN_HOOKS["submenu_entry"][$key]) && is_array($PLUGIN_HOOKS["submenu_entry"][$key])) {
                         foreach ($PLUGIN_HOOKS["submenu_entry"][$key] as $name => $link) {
                             // New complete option management
                             if ($name == "options") {
                                 $menu['plugins']['content'][$key]['options'] = $link;
                             } else {
                                 // Keep it for compatibility
                                 if (is_array($link)) {
                                     // Simple link option
                                     if (isset($link[$option])) {
                                         $menu['plugins']['content'][$key]['links'][$name] = '/plugins/' . $key . '/' . $link[$option];
                                     }
                                 } else {
                                     $menu['plugins']['content'][$key]['links'][$name] = '/plugins/' . $key . '/' . $link;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /// ADMINISTRATION
     $menu['admin']['title'] = __('Administration');
     if (Session::haveRight("user", "r")) {
         $menu['admin']['default'] = '/front/user.php';
         $menu['admin']['content']['user']['title'] = _n('User', 'Users', 2);
         $menu['admin']['content']['user']['shortcut'] = 'u';
         $menu['admin']['content']['user']['page'] = '/front/user.php';
         $menu['admin']['content']['user']['links']['search'] = '/front/user.php';
         if (Session::haveRight("user", "w")) {
             $menu['admin']['content']['user']['links']['add'] = "/front/user.form.php";
         }
         $menu['admin']['content']['user']['options']['ldap']['title'] = _n('LDAP directory', 'LDAP directories', 2);
         $menu['admin']['content']['user']['options']['ldap']['page'] = "/front/ldap.php";
     }
     if (Session::haveRight("group", "r")) {
         $menu['admin']['content']['group']['title'] = _n('Group', 'Groups', 2);
         $menu['admin']['content']['group']['shortcut'] = 'g';
         $menu['admin']['content']['group']['page'] = '/front/group.php';
         $menu['admin']['content']['group']['links']['search'] = '/front/group.php';
         if (Session::haveRight("group", "w")) {
             $menu['admin']['content']['group']['links']['add'] = "/front/group.form.php";
             $menu['admin']['content']['group']['options']['ldap']['title'] = _n('LDAP directory', 'LDAP directories', 2);
             $menu['admin']['content']['group']['options']['ldap']['page'] = "/front/ldap.group.php";
         }
     }
     if (Session::haveRight("entity", "r")) {
         $menu['admin']['content']['entity']['title'] = _n('Entity', 'Entities', 2);
         $menu['admin']['content']['entity']['shortcut'] = '';
         $menu['admin']['content']['entity']['page'] = '/front/entity.php';
         $menu['admin']['content']['entity']['links']['search'] = '/front/entity.php';
         $menu['admin']['content']['entity']['links']['add'] = "/front/entity.form.php";
     }
     if (Session::haveRight("rule_ldap", "r") || Session::haveRight("rule_import", "r") || Session::haveRight("entity_rule_ticket", "r") || Session::haveRight("rule_softwarecategories", "r") || Session::haveRight("rule_mailcollector", "r")) {
         $menu['admin']['content']['rule']['title'] = _n('Rule', 'Rules', 2);
         $menu['admin']['content']['rule']['shortcut'] = '';
         $menu['admin']['content']['rule']['page'] = '/front/rule.php';
         if ($sector == 'admin' && $item == 'rule') {
             foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
                 $rulecollection = new $rulecollectionclass();
                 if ($rulecollection->canList()) {
                     $ruleclassname = $rulecollection->getRuleClassName();
                     $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['title'] = $rulecollection->getRuleClass()->getTitle();
                     $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['page'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                     $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['links']['search'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                     if ($rulecollection->canCreate()) {
                         $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['links']['add'] = Toolbox::getItemTypeFormURL($ruleclassname, false);
                     }
                 }
             }
         }
     }
     if (Session::haveRight("transfer", "r") && Session::isMultiEntitiesMode()) {
         $menu['admin']['content']['rule']['options']['transfer']['title'] = __('Transfer');
         $menu['admin']['content']['rule']['options']['transfer']['page'] = "/front/transfer.php";
         $menu['admin']['content']['rule']['options']['transfer']['links']['search'] = "/front/transfer.php";
         if (Session::haveRight("transfer", "w")) {
             $menu['admin']['content']['rule']['options']['transfer']['links']['summary'] = "/front/transfer.action.php";
             $menu['admin']['content']['rule']['options']['transfer']['links']['add'] = "/front/transfer.form.php";
         }
     }
     if (Session::haveRight("rule_dictionnary_dropdown", "r") || Session::haveRight("rule_dictionnary_software", "r") || Session::haveRight("rule_dictionnary_printer", "r")) {
         $menu['admin']['content']['dictionnary']['title'] = __('Dictionaries');
         $menu['admin']['content']['dictionnary']['shortcut'] = '';
         $menu['admin']['content']['dictionnary']['page'] = '/front/dictionnary.php';
         if ($sector == 'admin' && $item == 'dictionnary') {
             $menu['admin']['content']['dictionnary']['options']['manufacturers']['title'] = _n('Manufacturer', 'Manufacturers', 2);
             $menu['admin']['content']['dictionnary']['options']['manufacturers']['page'] = '/front/ruledictionnarymanufacturer.php';
             $menu['admin']['content']['dictionnary']['options']['manufacturers']['links']['search'] = '/front/ruledictionnarymanufacturer.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['manufacturers']['links']['add'] = '/front/ruledictionnarymanufacturer.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['software']['title'] = _n('Software', 'Software', 2);
             $menu['admin']['content']['dictionnary']['options']['software']['page'] = '/front/ruledictionnarysoftware.php';
             $menu['admin']['content']['dictionnary']['options']['software']['links']['search'] = '/front/ruledictionnarysoftware.php';
             if (Session::haveRight("rule_dictionnary_software", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['software']['links']['add'] = '/front/ruledictionnarysoftware.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['model.computer']['title'] = _n('Computer model', 'Computer models', 2);
             $menu['admin']['content']['dictionnary']['options']['model.computer']['page'] = '/front/ruledictionnarycomputermodel.php';
             $menu['admin']['content']['dictionnary']['options']['model.computer']['links']['search'] = '/front/ruledictionnarycomputermodel.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['model.computer']['links']['add'] = '/front/ruledictionnarycomputermodel.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['model.monitor']['title'] = _n('Monitor model', 'Monitor models', 2);
             $menu['admin']['content']['dictionnary']['options']['model.monitor']['page'] = '/front/ruledictionnarymonitormodel.php';
             $menu['admin']['content']['dictionnary']['options']['model.monitor']['links']['search'] = '/front/ruledictionnarymonitormodel.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['model.monitor']['links']['add'] = '/front/ruledictionnarymonitormodel.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['model.printer']['title'] = _n('Printer model', 'Printer models', 2);
             $menu['admin']['content']['dictionnary']['options']['model.printer']['page'] = '/front/ruledictionnaryprintermodel.php';
             $menu['admin']['content']['dictionnary']['options']['model.printer']['links']['search'] = '/front/ruledictionnaryprintermodel.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['model.printer']['links']['add'] = '/front/ruledictionnaryprintermodel.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['model.peripheral']['title'] = _n('Peripheral model', 'Peripheral models', 2);
             $menu['admin']['content']['dictionnary']['options']['model.peripheral']['page'] = '/front/ruledictionnaryperipheralmodel.php';
             $menu['admin']['content']['dictionnary']['options']['model.peripheral']['links']['search'] = '/front/ruledictionnaryperipheralmodel.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['model.peripheral']['links']['add'] = '/front/ruledictionnaryperipheralmodel.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['model.networking']['title'] = _n('Networking equipment model', 'Networking equipment models', 2);
             $menu['admin']['content']['dictionnary']['options']['model.networking']['page'] = '/front/ruledictionnarynetworkequipmentmodel.php';
             $menu['admin']['content']['dictionnary']['options']['model.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmentmodel.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['model.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmentmodel.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['model.phone']['title'] = _n('Phone model', 'Phone models', 2);
             $menu['admin']['content']['dictionnary']['options']['model.phone']['page'] = '/front/ruledictionnaryphonemodel.php';
             $menu['admin']['content']['dictionnary']['options']['model.phone']['links']['search'] = '/front/ruledictionnaryphonemodel.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['model.phone']['links']['add'] = '/front/ruledictionnaryphonemodel.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['type.computer']['title'] = _n('Computer type', 'Computer types', 2);
             $menu['admin']['content']['dictionnary']['options']['type.computer']['page'] = '/front/ruledictionnarycomputertype.php';
             $menu['admin']['content']['dictionnary']['options']['type.computer']['links']['search'] = '/front/ruledictionnarycomputertype.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['type.computer']['links']['add'] = '/front/ruledictionnarycomputertype.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['type.monitor']['title'] = _n('Monitor type', 'Monitors types', 2);
             $menu['admin']['content']['dictionnary']['options']['type.monitor']['page'] = '/front/ruledictionnarymonitortype.php';
             $menu['admin']['content']['dictionnary']['options']['type.monitor']['links']['search'] = '/front/ruledictionnarymonitortype.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['type.monitor']['links']['add'] = '/front/ruledictionnarymonitortype.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['type.printer']['title'] = _n('Printer type', 'Printer types', 2);
             $menu['admin']['content']['dictionnary']['options']['type.printer']['page'] = '/front/ruledictionnaryprintertype.php';
             $menu['admin']['content']['dictionnary']['options']['type.printer']['links']['search'] = '/front/ruledictionnaryprintertype.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['type.printer']['links']['add'] = '/front/ruledictionnaryprintertype.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['type.peripheral']['title'] = _n('Peripheral type', 'Peripheral types', 2);
             $menu['admin']['content']['dictionnary']['options']['type.peripheral']['page'] = '/front/ruledictionnaryperipheraltype.php';
             $menu['admin']['content']['dictionnary']['options']['type.peripheral']['links']['search'] = '/front/ruledictionnaryperipheraltype.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['type.peripheral']['links']['add'] = '/front/ruledictionnaryperipheraltype.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['type.networking']['title'] = _n('Networking equipment type', 'Networking equipment types', 2);
             $menu['admin']['content']['dictionnary']['options']['type.networking']['page'] = '/front/ruledictionnarynetworkequipmenttype.php';
             $menu['admin']['content']['dictionnary']['options']['type.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmenttype.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['type.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmenttype.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['type.phone']['title'] = _n('Phone type', 'Phone types', 2);
             $menu['admin']['content']['dictionnary']['options']['type.phone']['page'] = '/front/ruledictionnaryphonetype.php';
             $menu['admin']['content']['dictionnary']['options']['type.phone']['links']['search'] = '/front/ruledictionnaryphonetype.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['type.phone']['links']['add'] = '/front/ruledictionnaryphonetype.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['os']['title'] = __('Operating system');
             $menu['admin']['content']['dictionnary']['options']['os']['page'] = '/front/ruledictionnaryoperatingsystem.php';
             $menu['admin']['content']['dictionnary']['options']['os']['links']['search'] = '/front/ruledictionnaryoperatingsystem.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['os']['links']['add'] = '/front/ruledictionnaryoperatingsystem.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['os_sp']['title'] = __('Service pack');
             $menu['admin']['content']['dictionnary']['options']['os_sp']['page'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
             $menu['admin']['content']['dictionnary']['options']['os_sp']['links']['search'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['os_sp']['links']['add'] = '/front/ruledictionnaryoperatingsystemservicepack.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['os_version']['title'] = __('Version of the operating system');
             $menu['admin']['content']['dictionnary']['options']['os_version']['page'] = '/front/ruledictionnaryoperatingsystemversion.php';
             $menu['admin']['content']['dictionnary']['options']['os_version']['links']['search'] = '/front/ruledictionnaryoperatingsystemversion.php';
             if (Session::haveRight("rule_dictionnary_dropdown", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['os_version']['links']['add'] = '/front/ruledictionnaryoperatingsystemversion.form.php';
             }
             $menu['admin']['content']['dictionnary']['options']['printer']['title'] = _n('Printer', 'Printers', 2);
             $menu['admin']['content']['dictionnary']['options']['printer']['page'] = '/front/ruledictionnaryprinter.php';
             $menu['admin']['content']['dictionnary']['options']['printer']['links']['search'] = '/front/ruledictionnaryprinter.php';
             if (Session::haveRight("rule_dictionnary_printer", "w")) {
                 $menu['admin']['content']['dictionnary']['options']['printer']['links']['add'] = '/front/ruledictionnaryprinter.form.php';
             }
         }
     }
     if (Session::haveRight("profile", "r")) {
         $menu['admin']['content']['profile']['title'] = _n('Profile', 'Profiles', 2);
         $menu['admin']['content']['profile']['shortcut'] = '';
         $menu['admin']['content']['profile']['page'] = '/front/profile.php';
         $menu['admin']['content']['profile']['links']['search'] = "/front/profile.php";
         if (Session::haveRight("profile", "w")) {
             $menu['admin']['content']['profile']['links']['add'] = "/front/profile.form.php";
         }
     }
     if (Session::haveRight("backup", "w")) {
         $menu['admin']['content']['backup']['title'] = __('Maintenance');
         $menu['admin']['content']['backup']['shortcut'] = '';
         $menu['admin']['content']['backup']['page'] = '/front/backup.php';
     }
     if (Session::haveRight("logs", "r")) {
         $menu['admin']['content']['log']['title'] = _n('Log', 'Logs', 2);
         $menu['admin']['content']['log']['shortcut'] = '';
         $menu['admin']['content']['log']['page'] = '/front/event.php';
     }
     /// CONFIG
     $config = array();
     $addconfig = array();
     $menu['config']['title'] = __('Setup');
     if (Session::haveRight("dropdown", "r") || Session::haveRight("entity_dropdown", "r") || Session::haveRight("internet", "r")) {
         $menu['config']['content']['dropdowns']['title'] = _n('Dropdown', 'Dropdowns', 2);
         $menu['config']['content']['dropdowns']['shortcut'] = 'n';
         $menu['config']['content']['dropdowns']['page'] = '/front/dropdown.php';
         $menu['config']['default'] = '/front/dropdown.php';
         if ($item == "dropdowns") {
             $dps = Dropdown::getStandardDropdownItemTypes();
             foreach ($dps as $tab) {
                 foreach ($tab as $key => $val) {
                     if ($key == $option) {
                         if ($tmp = getItemForItemtype($key)) {
                             $menu['config']['content']['dropdowns']['options'][$option]['title'] = $val;
                             $menu['config']['content']['dropdowns']['options'][$option]['page'] = $tmp->getSearchURL(false);
                             $menu['config']['content']['dropdowns']['options'][$option]['links']['search'] = $tmp->getSearchURL(false);
                             if ($tmp->canCreate()) {
                                 $menu['config']['content']['dropdowns']['options'][$option]['links']['add'] = $tmp->getFormURL(false);
                             }
                         }
                     }
                 }
             }
         }
     }
     if (Session::haveRight("device", "w")) {
         $menu['config']['content']['device']['title'] = _n('Component', 'Components', 2);
         $menu['config']['content']['device']['page'] = '/front/device.php';
         if ($item == "device") {
             $dps = Dropdown::getDeviceItemTypes();
             foreach ($dps as $tab) {
                 foreach ($tab as $key => $val) {
                     if ($key == $option) {
                         if ($tmp = getItemForItemtype($key)) {
                             $menu['config']['content']['device']['options'][$option]['title'] = $val;
                             $menu['config']['content']['device']['options'][$option]['page'] = $tmp->getSearchURL(false);
                             $menu['config']['content']['device']['options'][$option]['links']['search'] = $tmp->getSearchURL(false);
                             if ($tmp->canCreate()) {
                                 $menu['config']['content']['device']['options'][$option]['links']['add'] = $tmp->getFormURL(false);
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($CFG_GLPI['use_mailing'] && Session::haveRight("notification", "r") || Session::haveRight("config", "w")) {
         $menu['config']['content']['mailing']['title'] = _n('Notification', 'Notifications', 2);
         $menu['config']['content']['mailing']['page'] = '/front/setup.notification.php';
         $menu['config']['content']['mailing']['options']['notification']['title'] = _n('Notification', 'Notifications', 2);
         $menu['config']['content']['mailing']['options']['notification']['page'] = '/front/notification.php';
         $menu['config']['content']['mailing']['options']['notification']['links']['add'] = '/front/notification.form.php';
         $menu['config']['content']['mailing']['options']['notification']['links']['search'] = '/front/notification.php';
     }
     if (Session::haveRight("sla", "r")) {
         $menu['config']['content']['sla']['title'] = _n('SLA', 'SLA', 2);
         $menu['config']['content']['sla']['page'] = '/front/sla.php';
         $menu['config']['content']['sla']['links']['search'] = "/front/sla.php";
         if (Session::haveRight("sla", "w")) {
             $menu['config']['content']['sla']['links']['add'] = "/front/sla.form.php";
         }
     }
     if (Session::haveRight("config", "w")) {
         //TRANS: menu title for "General setup""
         $menu['config']['content']['config']['title'] = _x('setup', 'General');
         $menu['config']['content']['config']['page'] = '/front/config.form.php';
         $menu['config']['content']['control']['title'] = _n('Check', 'Checks', 2);
         $menu['config']['content']['control']['page'] = '/front/control.php';
         $menu['config']['content']['control']['options']['FieldUnicity']['title'] = __('Fields unicity');
         $menu['config']['content']['control']['options']['FieldUnicity']['page'] = '/front/fieldunicity.php';
         $menu['config']['content']['control']['options']['FieldUnicity']['links']['add'] = '/front/fieldunicity.form.php';
         $menu['config']['content']['control']['options']['FieldUnicity']['links']['search'] = '/front/fieldunicity.php';
         $menu['config']['content']['crontask']['title'] = _n('Automatic action', 'Automatic actions', 2);
         $menu['config']['content']['crontask']['page'] = '/front/crontask.php';
         $menu['config']['content']['crontask']['links']['search'] = "/front/crontask.php";
         $menu['config']['content']['mailing']['options']['config']['title'] = __('Email');
         $menu['config']['content']['mailing']['options']['config']['page'] = '/front/notificationmailsetting.form.php';
         $menu['config']['content']['mailing']['options']['notificationtemplate']['title'] = _n('Notification template', 'Notification templates', 2);
         $menu['config']['content']['mailing']['options']['notificationtemplate']['page'] = '/front/notificationtemplate.php';
         $menu['config']['content']['mailing']['options']['notificationtemplate']['links']['add'] = '/front/notificationtemplate.form.php';
         $menu['config']['content']['mailing']['options']['notificationtemplate']['links']['search'] = '/front/notificationtemplate.php';
         $menu['config']['content']['extauth']['title'] = __('Authentication');
         $menu['config']['content']['extauth']['page'] = '/front/setup.auth.php';
         $menu['config']['content']['extauth']['options']['ldap']['title'] = _n('LDAP directory', 'LDAP directories', 2);
         $menu['config']['content']['extauth']['options']['ldap']['page'] = '/front/authldap.php';
         $menu['config']['content']['extauth']['options']['imap']['title'] = _n('Mail server', 'Mail servers', 2);
         $menu['config']['content']['extauth']['options']['imap']['page'] = '/front/authmail.php';
         $menu['config']['content']['extauth']['options']['others']['title'] = __('Others');
         $menu['config']['content']['extauth']['options']['others']['page'] = '/front/auth.others.php';
         $menu['config']['content']['extauth']['options']['settings']['title'] = __('Setup');
         $menu['config']['content']['extauth']['options']['settings']['page'] = '/front/auth.settings.php';
         switch ($option) {
             case "ldap":
                 // LDAP
                 $menu['config']['content']['extauth']['options']['ldap']['links']['search'] = '/front/authldap.php';
                 $menu['config']['content']['extauth']['options']['ldap']['links']['add'] = '' . '/front/authldap.form.php';
                 break;
             case "imap":
                 // IMAP
                 $menu['config']['content']['extauth']['links']['search'] = '/front/authmail.php';
                 $menu['config']['content']['extauth']['links']['add'] = '' . '/front/authmail.form.php';
                 break;
         }
         $menu['config']['content']['mailcollector']['title'] = _n('Receiver', 'Receivers', 2);
         $menu['config']['content']['mailcollector']['page'] = '/front/mailcollector.php';
         if (Toolbox::canUseImapPop()) {
             $menu['config']['content']['mailcollector']['links']['search'] = '/front/mailcollector.php';
             $menu['config']['content']['mailcollector']['links']['add'] = '/front/mailcollector.form.php';
             $menu['config']['content']['mailcollector']['options']['rejectedemails']['links']['search'] = '/front/notimportedemail.php';
         }
     }
     if (Session::haveRight("link", "r")) {
         $menu['config']['content']['link']['title'] = _n('External link', 'External links', 2);
         $menu['config']['content']['link']['page'] = '/front/link.php';
         $menu['config']['content']['link']['hide'] = true;
         $menu['config']['content']['link']['links']['search'] = '/front/link.php';
         if (Session::haveRight("link", "w")) {
             $menu['config']['content']['link']['links']['add'] = "/front/link.form.php";
         }
     }
     if (Session::haveRight("config", "w")) {
         $menu['config']['content']['plugins']['title'] = __('Plugins');
         $menu['config']['content']['plugins']['page'] = '/front/plugin.php';
     }
     // Special items
     $menu['preference']['title'] = __('My settings');
     $menu['preference']['default'] = '/front/preference.php';
     $already_used_shortcut = array('1');
     echo "<div id='header'>";
     echo "<div id='c_logo'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/central.php' accesskey='1' title=\"" . __s('Home') . "\">";
     echo "</a></div>";
     /// Prefs / Logout link
     echo "<div id='c_preference' >";
     echo "<ul>";
     echo "<li id='deconnexion'><a href='" . $CFG_GLPI["root_doc"] . "/logout.php";
     /// logout witout noAuto login for extauth
     if (isset($_SESSION['glpiextauth']) && $_SESSION['glpiextauth']) {
         echo "?noAUTO=1";
     }
     echo "' title=\"" . __s('Logout') . "\">" . __('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 "<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') . "\">" . __('Help') . "</a></li>";
     echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . __s('My settings') . "\">" . __('My settings') . "</a></li>";
     echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . addslashes(Dropdown::getLanguageName($_SESSION['glpilanguage'])) . "\">" . Dropdown::getLanguageName($_SESSION['glpilanguage']) . "</a></li>";
     echo "</ul>";
     echo "<div class='sep'></div>";
     echo "</div>\n";
     /// Search engine
     echo "<div id='c_recherche' >\n";
     if ($CFG_GLPI['allow_search_global']) {
         echo "<form method='get' action='" . $CFG_GLPI["root_doc"] . "/front/search.php'>\n";
         echo "<div id='boutonRecherche'>";
         echo "<input type='image' src='" . $CFG_GLPI["root_doc"] . "/pics/search.png' value='OK'\n                title=\"" . _sx('button', 'Post') . "\"  alt=\"" . _sx('button', 'Post') . "\"></div>";
         echo "<div id='champRecherche'><input size='15' type='text' name='globalsearch'\n                                         value='" . __s('Search') . "' onfocus=\"this.value='';\">";
         echo "</div>";
         Html::closeForm();
     }
     //echo "</div>";
     echo "<div class='sep'></div>\n";
     echo "</div>";
     ///Main menu
     echo "<div id='c_menu'>";
     echo "<ul id='menu'>";
     // Get object-variables and build the navigation-elements
     $i = 1;
     foreach ($menu as $part => $data) {
         if (isset($data['content']) && count($data['content'])) {
             echo "<li id='menu{$i}' onmouseover=\"javascript:menuAff('menu{$i}','menu');\" >";
             $link = "#";
             if (isset($data['default']) && !empty($data['default'])) {
                 $link = $CFG_GLPI["root_doc"] . $data['default'];
             }
             if (Toolbox::strlen($data['title']) > 14) {
                 $data['title'] = Toolbox::substr($data['title'], 0, 14) . "...";
             }
             echo "<a href='{$link}' class='itemP'>" . $data['title'] . "</a>";
             echo "<ul class='ssmenu'>";
             // list menu item
             foreach ($data['content'] as $key => $val) {
                 if (isset($val['page']) && isset($val['title'])) {
                     echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val['page'] . "'";
                     if (isset($val['shortcut']) && !empty($val['shortcut'])) {
                         if (!isset($already_used_shortcut[$val['shortcut']])) {
                             echo " accesskey='" . $val['shortcut'] . "'";
                             $already_used_shortcut[$val['shortcut']] = $val['shortcut'];
                         }
                         echo ">" . Toolbox::shortcut($val['title'], $val['shortcut']) . "</a></li>\n";
                     } else {
                         echo ">" . $val['title'] . "</a></li>\n";
                     }
                 }
             }
             echo "</ul></li>";
             $i++;
         }
     }
     echo "</ul>";
     echo "<div class='sep'></div>";
     echo "</div>";
     // End navigation bar
     // End headline
     // Le sous menu contextuel 1
     echo "<div id='c_ssmenu1' >";
     echo "<ul>";
     // list sous-menu item
     if (isset($menu[$sector])) {
         if (isset($menu[$sector]['content']) && is_array($menu[$sector]['content'])) {
             $ssmenu = $menu[$sector]['content'];
             if (count($ssmenu) > 12) {
                 foreach ($ssmenu as $key => $val) {
                     if (isset($val['hide'])) {
                         unset($ssmenu[$key]);
                     }
                 }
                 $ssmenu = array_splice($ssmenu, 0, 12);
             }
             foreach ($ssmenu as $key => $val) {
                 if (isset($val['page']) && isset($val['title'])) {
                     echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val['page'] . "'";
                     if (isset($val['shortcut']) && !empty($val['shortcut'])) {
                         echo ">" . Toolbox::shortcut($val['title'], $val['shortcut']) . "</a></li>\n";
                     } else {
                         echo ">" . $val['title'] . "</a></li>\n";
                     }
                 }
             }
         } else {
             echo "<li>&nbsp;</li>";
         }
     } else {
         echo "<li>&nbsp;</li>";
     }
     echo "</ul></div>";
     //  Le fil d ariane
     echo "<div id='c_ssmenu2' >";
     echo "<ul>";
     // Display item
     echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/central.php' title=\"" . __s('Home') . "\">" . __('Home') . "</a> ></li>";
     if (isset($menu[$sector])) {
         $link = "/front/central.php";
         if (isset($menu[$sector]['default'])) {
             $link = $menu[$sector]['default'];
         }
         echo "<li><a href='" . $CFG_GLPI["root_doc"] . $link . "' title=\"" . $menu[$sector]['title'] . "\">" . $menu[$sector]['title'] . "</a> ></li>";
     }
     if (isset($menu[$sector]['content'][$item])) {
         // Title
         $with_option = false;
         if (!empty($option) && isset($menu[$sector]['content'][$item]['options'][$option]['title']) && isset($menu[$sector]['content'][$item]['options'][$option]['page'])) {
             $with_option = true;
         }
         if (isset($menu[$sector]['content'][$item]['page'])) {
             echo "<li><a href='" . $CFG_GLPI["root_doc"] . $menu[$sector]['content'][$item]['page'] . "' " . ($with_option ? "" : "class='here'") . " title=\"" . $menu[$sector]['content'][$item]['title'] . "\" >" . $menu[$sector]['content'][$item]['title'] . "</a>" . (!$with_option ? "" : " > ") . "</li>";
         }
         if ($with_option) {
             echo "<li><a href='" . $CFG_GLPI["root_doc"] . $menu[$sector]['content'][$item]['options'][$option]['page'] . "' class='here' title=\"" . $menu[$sector]['content'][$item]['options'][$option]['title'] . "\" >";
             echo self::resume_name($menu[$sector]['content'][$item]['options'][$option]['title'], 17);
             echo "</a></li>";
         }
         echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
         $links = array();
         // Item with Option case
         if (!empty($option) && isset($menu[$sector]['content'][$item]['options'][$option]['links']) && is_array($menu[$sector]['content'][$item]['options'][$option]['links'])) {
             $links = $menu[$sector]['content'][$item]['options'][$option]['links'];
             // Without option case : only item links
         } else {
             if (isset($menu[$sector]['content'][$item]['links']) && is_array($menu[$sector]['content'][$item]['links'])) {
                 $links = $menu[$sector]['content'][$item]['links'];
             }
         }
         // Add item
         echo "<li>";
         if (isset($links['add'])) {
             echo "<a href='" . $CFG_GLPI["root_doc"] . $links['add'] . "'>";
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . __s('Add') . "\"\n                   alt=\"" . __s('Add') . "\"></a>";
         } else {
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add_off.png' title=\"" . __s('Add') . "\"\n                   alt=\"" . __s('Add') . "\">";
         }
         echo "</li>";
         // Search Item
         if (isset($links['search'])) {
             echo "<li><a href='" . $CFG_GLPI["root_doc"] . $links['search'] . "'>";
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_search.png'\n                   title=\"" . __s('Search') . "\" alt=\"" . __s('Search') . "\"></a></li>";
         } else {
             echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_search_off.png'\n                       title=\"" . __s('Search') . "\" alt=\"" . __s('Search') . "\"></li>";
         }
         // Links
         if (count($links) > 0) {
             foreach ($links as $key => $val) {
                 switch ($key) {
                     case "add":
                     case "search":
                         break;
                     case "template":
                         echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . __s('Manage templates...') . "\" alt=\"" . __s('Manage templates...') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_addtemplate.png'></a>" . "</li>";
                         break;
                     case "showall":
                         echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . __s('Show all') . "\" alt=\"" . __s('Show all') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png'></a></li>";
                         break;
                     case "summary":
                         echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . __s('Summary') . "\" alt=\"" . __s('Summary') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_show.png'></a></li>";
                         break;
                     case "config":
                         echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . __s('Setup') . "\" alt=\"" . __s('Setup') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_config.png'></a></li>";
                         break;
                     default:
                         echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'>" . $key . "</a></li>";
                         break;
                 }
             }
         }
     } else {
         echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
         echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . "&nbsp;&nbsp;&nbsp;&nbsp;</li>";
     }
     // Add common items
     echo "<li>";
     // Display MENU ALL
     echo "<div id='show_all_menu' onmouseover=\"completecleandisplay('show_all_menu');\">";
     $items_per_columns = 15;
     $i = -1;
     echo "<table><tr><td class='top'><table>";
     foreach ($menu as $part => $data) {
         if (isset($data['content']) && count($data['content'])) {
             if ($i > $items_per_columns) {
                 $i = 0;
                 echo "</table></td><td class='top'><table>";
             }
             $link = "#";
             if (isset($data['default']) && !empty($data['default'])) {
                 $link = $CFG_GLPI["root_doc"] . $data['default'];
             }
             echo "<tr><td class='tab_bg_1 b'>";
             echo "<a href='{$link}' title=\"" . $data['title'] . "\" class='itemP'>" . $data['title'] . "</a>";
             echo "</td></tr>";
             $i++;
             // list menu item
             foreach ($data['content'] as $key => $val) {
                 if ($i > $items_per_columns) {
                     $i = 0;
                     echo "</table></td><td class='top'><table>";
                 }
                 if (isset($val['page']) && isset($val['title'])) {
                     echo "<tr><td><a href='" . $CFG_GLPI["root_doc"] . $val['page'] . "'";
                     if (isset($data['shortcut']) && !empty($data['shortcut'])) {
                         echo " accesskey='" . $val['shortcut'] . "'";
                     }
                     echo ">" . $val['title'] . "</a></td></tr>\n";
                     $i++;
                 }
             }
         }
     }
     echo "</table></td></tr></table>";
     echo "</div>";
     echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
     echo "</li>";
     /// Bookmark load
     echo "<li>";
     echo "<a href='#' onClick=\"var w=window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=load_bookmark' ,'glpibookmarks', 'height=500, width=" . (Bookmark::WIDTH + 250) . ", top=100, left=100, scrollbars=yes' );w.focus();\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png' title=\"" . __s('Load a bookmark') . "\"  alt=\"" . __s('Load a bookmark') . "\">";
     echo "</a></li>";
     /// MENU ALL
     echo "<li >";
     echo "<img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/menu_all.png' " . "onclick=\"completecleandisplay('show_all_menu')\">";
     echo "</li>";
     // check user id : header used for display messages when session logout
     if (Session::getLoginUserID()) {
         self::showProfileSelecter($CFG_GLPI["root_doc"] . "/front/central.php");
     }
     echo "</ul>";
     echo "</div>";
     echo "</div>\n";
     // fin header
     echo "<div id='page' >";
     if ($DB->isSlave() && !$DB->first_connection) {
         echo "<div id='dbslave-float'>";
         echo "<a href='#see_debug'>" . __('MySQL replica: read only') . "</a>";
         echo "</div>";
     }
     // call static function callcron() every 5min
     CronTask::callCron();
     self::displayMessageAfterRedirect();
 }
Пример #29
0
 static function showListSimple()
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight(self::$rightname, self::RESERVEANITEM)) {
         return false;
     }
     $ri = new self();
     $ok = false;
     $showentity = Session::isMultiEntitiesMode();
     $values = array();
     if (isset($_SESSION['glpi_saved']['ReservationItem'])) {
         $_POST = $_SESSION['glpi_saved']['ReservationItem'];
     }
     if (isset($_POST['reserve'])) {
         echo "<div id='viewresasearch'  class='center'>";
         Toolbox::manageBeginAndEndPlanDates($_POST['reserve']);
         echo "<div id='nosearch' class='center firstbloc'>" . "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/reservationitem.php\">";
         echo __('See all reservable items') . "</a></div>\n";
     } else {
         echo "<div id='makesearch' class='center firstbloc'>" . "<a class='pointer' onClick=\"javascript:showHideDiv('viewresasearch','','','');" . "showHideDiv('makesearch','','','')\">";
         echo __('Find a free item in a specific period') . "</a></div>\n";
         echo "<div id='viewresasearch' style=\"display:none;\" class='center'>";
         $begin_time = time();
         $begin_time -= $begin_time % HOUR_TIMESTAMP;
         $_POST['reserve']["begin"] = date("Y-m-d H:i:s", $begin_time);
         $_POST['reserve']["end"] = date("Y-m-d H:i:s", $begin_time + HOUR_TIMESTAMP);
         $_POST['reservation_types'] = '';
     }
     echo "<form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
     echo "<th colspan='3'>" . __('Find a free item in a specific period') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     Html::showDateTimeField("reserve[begin]", array('value' => $_POST['reserve']["begin"], 'maybeempty' => false));
     echo "</td><td rowspan='3'>";
     echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
     $default_delay = floor((strtotime($_POST['reserve']["end"]) - strtotime($_POST['reserve']["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
     $rand = Dropdown::showTimeStamp("reserve[_duration]", array('min' => 0, 'max' => 48 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $params = array('duration' => '__VALUE__', 'end' => $_POST['reserve']["end"], 'name' => "reserve[end]");
     Ajax::updateItemOnSelectEvent("dropdown_reserve[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Item type') . "</td><td>";
     $sql = "SELECT DISTINCT(`itemtype`)\n              FROM `glpi_reservationitems`\n              WHERE `is_active` = 1" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']);
     $result = $DB->query($sql);
     while ($data = $DB->fetch_assoc($result)) {
         $values[$data['itemtype']] = $data['itemtype']::getTypeName();
     }
     $query = "SELECT `glpi_peripheraltypes`.`name`, `glpi_peripheraltypes`.`id`\n                FROM `glpi_peripheraltypes`\n                LEFT JOIN `glpi_peripherals`\n                  ON `glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`\n                LEFT JOIN `glpi_reservationitems`\n                  ON `glpi_reservationitems`.`items_id` = `glpi_peripherals`.`id`\n                WHERE `itemtype` = 'Peripheral'\n                      AND `is_active` = 1\n                      AND `peripheraltypes_id`" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']) . "\n                ORDER BY `glpi_peripheraltypes`.`name`";
     foreach ($DB->request($query) as $ptype) {
         $id = $ptype['id'];
         $values["Peripheral#{$id}"] = $ptype['name'];
     }
     Dropdown::showFromArray("reservation_types", $values, array('value' => $_POST['reservation_types'], 'display_emptychoice' => true));
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
     // GET method passed to form creation
     echo "<div id='nosearch' class='center'>";
     echo "<form name='form' method='GET' action='reservation.form.php'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n";
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $itemtable = getTableForItemType($itemtype);
         $otherserial = "'' AS otherserial";
         if ($item->isField('otherserial')) {
             $otherserial = "`{$itemtable}`.`otherserial`";
         }
         $begin = $_POST['reserve']["begin"];
         $end = $_POST['reserve']["end"];
         $left = "";
         $where = "";
         if (isset($_POST['submit']) && isset($begin) && isset($end)) {
             $left = "LEFT JOIN `glpi_reservations`\n                        ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n                            AND '" . $begin . "' < `glpi_reservations`.`end`\n                            AND '" . $end . "' > `glpi_reservations`.`begin`)";
             $where = " AND `glpi_reservations`.`id` IS NULL ";
         }
         if (isset($_POST["reservation_types"]) && !empty($_POST["reservation_types"])) {
             $tmp = explode('#', $_POST["reservation_types"]);
             $where .= " AND `glpi_reservationitems`.`itemtype` = '" . $tmp[0] . "'";
             if (isset($tmp[1]) && $tmp[0] == 'Peripheral' && $itemtype == 'Peripheral') {
                 $left .= " LEFT JOIN `glpi_peripheraltypes`\n                              ON (`glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`)";
                 $where .= " AND `{$itemtable}`.`peripheraltypes_id` = '" . $tmp[1] . "'";
             }
         }
         $query = "SELECT `glpi_reservationitems`.`id`,\n                          `glpi_reservationitems`.`comment`,\n                          `{$itemtable}`.`name` AS name,\n                          `{$itemtable}`.`entities_id` AS entities_id,\n                          {$otherserial},\n                          `glpi_locations`.`id` AS location,\n                          `glpi_reservationitems`.`items_id` AS items_id\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `{$itemtable}`\n                        ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n                            AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n                   {$left}\n                   LEFT JOIN `glpi_locations`\n                        ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n                   WHERE `glpi_reservationitems`.`is_active` = '1'\n                         AND `glpi_reservationitems`.`is_deleted` = '0'\n                         AND `{$itemtable}`.`is_deleted` = '0'\n                         {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n                   ORDER BY `{$itemtable}`.`entities_id`,\n                            `{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             while ($row = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>";
                 $typename = $item->getTypeName();
                 if ($itemtype == 'Peripheral') {
                     $item->getFromDB($row['items_id']);
                     if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
                         $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
                     }
                 }
                 echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>" . sprintf(__('%1$s - %2$s'), $typename, $row["name"]) . "</a></td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_locations", $row["location"]) . "</td>";
                 echo "<td>" . nl2br($row["comment"]) . "</td>";
                 if ($showentity) {
                     echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>";
                 }
                 echo "</tr>\n";
                 $ok = true;
             }
         }
     }
     if ($ok) {
         echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>";
         if (isset($_POST['reserve'])) {
             echo Html::hidden('begin', array('value' => $_POST['reserve']["begin"]));
             echo Html::hidden('end', array('value' => $_POST['reserve']["end"]));
         }
         echo "<input type='submit' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>\n";
     }
     echo "</table>\n";
     echo "<input type='hidden' name='id' value=''>";
     echo "</form>";
     // No CSRF token needed
     echo "</div>\n";
 }
 /**
  * Fonction permettant d'afficher les reservations actuelles
  * 
  **/
 function showCurrentResa()
 {
     global $DB, $CFG_GLPI, $datesresa;
     $showentity = Session::isMultiEntitiesMode();
     $config = new PluginReservationConfig();
     $methode = $config->getConfigurationMethode();
     $begin = $datesresa["begin"];
     $end = $datesresa["end"];
     $left = "";
     $where = "";
     //tableau contenant un tableau des reservations par utilisateur
     // exemple : (salleman => ( 0=> (resaid => 1, debut => '12/12/2054', fin => '12/12/5464', comment => 'tralala', name => 'hobbit16'
     $ResaByUser = array();
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $itemtable = getTableForItemType($itemtype);
         $otherserial = "'' AS otherserial";
         if ($item->isField('otherserial')) {
             $otherserial = "`{$itemtable}`.`otherserial`";
         }
         if (isset($begin) && isset($end)) {
             $left = "LEFT JOIN `glpi_reservations`\n\t  ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n\t      AND '" . $begin . "' < `glpi_reservations`.`end`\n\t      AND '" . $end . "' > `glpi_reservations`.`begin`)";
             $where = " AND `glpi_reservations`.`id` IS NOT NULL ";
         }
         $query = "SELECT `glpi_reservationitems`.`id`,\n\t`glpi_reservationitems`.`comment`,\n\t`{$itemtable}`.`name` AS name,\n\t`{$itemtable}`.`entities_id` AS entities_id,\n\t{$otherserial},\n\t`glpi_reservations`.`id` AS resaid,\n\t`glpi_reservations`.`comment`,\n\t`glpi_reservations`.`begin`,\n\t`glpi_reservations`.`end`,\n\t`glpi_users`.`name` AS username,\n\t`glpi_reservationitems`.`items_id` AS items_id\n\t  FROM `glpi_reservationitems`\n\t  {$left}\n\t  INNER JOIN `{$itemtable}`\n\t  ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n\t      AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n\t  LEFT JOIN `glpi_users` \n\t  ON (`glpi_reservations`.`users_id` = `glpi_users`.`id`)\n\t  WHERE `glpi_reservationitems`.`is_active` = '1'\n\t  AND `glpi_reservationitems`.`is_deleted` = '0'\n\t  AND `{$itemtable}`.`is_deleted` = '0'\n\t  {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n\t  ORDER BY username,\n\t`{$itemtable}`.`entities_id`,\n\t`{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             // on regroupe toutes les reservations d'un meme user dans un tableau.
             while ($row = $DB->fetch_assoc($result)) {
                 if (!array_key_exists($row["username"], $ResaByUser)) {
                     $ResaByUser[$row["username"]] = array();
                 }
                 $tmp = array("resaid" => $row["resaid"], "name" => $row['name'], "debut" => $row["begin"], "fin" => $row["end"], "comment" => nl2br($row["comment"]));
                 $ResaByUser[$row["username"]][] = $tmp;
                 //on trie par date
                 usort($ResaByUser[$row["username"]], 'compare_date_by_user');
             }
         }
     }
     echo "<div class='center'>";
     echo "<table class='tab_cadre'>";
     echo "<thead>";
     echo "<tr><th colspan='" . ($showentity ? "11" : "10") . "'>" . "Matériels empruntés" . "</th></tr>\n";
     echo "<tr class='tab_bg_2'>";
     /*echo "<th><a href=\"#\" onclick=\"sortTable(this,0); return false;\">Utilisateur</a></th>";
       echo "<th><a href=\"#\" onclick=\"sortTable(this,1); return false;\">Materiel</a></th>";
       echo "<th><a href=\"#\" onclick=\"sortTable(this,2); return false;\">Debut</a></th>";
       echo "<th><a href=\"#\" onclick=\"sortTable(this,3); return false;\">Fin</a></th>";
       echo "<th><a href=\"#\" onclick=\"sortTable(this,4); return false;\">Commentaires</a></th>";
       echo "<th><a href=\"#\" onclick=\"sortTable(this,5); return false;\">Mouvement</a></th>";*/
     echo "<th>Utilisateur</a></th>";
     echo "<th>Materiel</a></th>";
     echo "<th>Debut</a></th>";
     echo "<th>Fin</a></th>";
     echo "<th>Commentaires</a></th>";
     echo "<th>Mouvement</a></th>";
     echo "<th>Acquitter</th>";
     echo "<th colspan='" . ($methode == "manual" ? 3 : 2) . "'>Actions</th>";
     echo "</tr></thead>";
     echo "<tbody>";
     //on parcourt le tableau pour construire la table à afficher
     foreach ($ResaByUser as $User => $arrayResa) {
         $nbLigne = 1;
         $limiteLigneNumber = count($arrayResa);
         $flag = 0;
         echo "<tr class='tab_bg_2'>";
         echo "<td rowspan=" . count($arrayResa) . ">" . $User . "</td>";
         foreach ($arrayResa as $Num => $resa) {
             $colorRed = "";
             $flagSurveille = 0;
             // on regarde si la reservation actuelle a été prolongée par le plugin
             $query = "SELECT `date_return`, `date_theorique`, `dernierMail` FROM `glpi_plugin_reservation_manageresa` WHERE `resaid` = " . $resa["resaid"];
             if ($result = $DB->query($query)) {
                 $dates = $DB->fetch_row($result);
             }
             if ($DB->numrows($result)) {
                 if ($dates[1] < date("Y-m-d H:i:s", time()) && $dates[0] == NULL) {
                     // on colore  en rouge seulement si la date de retour theorique est depassée et si le materiel n'est pas marqué comme rendu (avec une date de retour effectif)
                     $colorRed = "bgcolor=\"red\"";
                     $flagSurveille = 1;
                 }
             }
             // le nom du materiel
             echo "<td {$colorRed}>" . $resa['name'] . "</td>";
             if (!$flag) {
                 $i = $Num;
                 while ($i < count($arrayResa) - 1) {
                     if ($arrayResa[$i + 1]['debut'] == $resa['debut'] && $arrayResa[$Num + 1]['fin'] == $resa['fin']) {
                         $nbLigne++;
                     } else {
                         break;
                     }
                     $i++;
                 }
                 $limiteLigneNumber = $Num + $nbLigne - 1;
             }
             //date de debut de la resa
             if (!$flag) {
                 echo "<td rowspan=" . $nbLigne . " {$colorRed}>" . date("d-m-Y \\à H:i:s", strtotime($resa["debut"])) . "</td>";
                 // si c'est une reservation prolongée, on affiche la date theorique plutot que la date reelle (qui est prolongée jusqu'au retour du materiel)
                 if ($DB->numrows($result) && $dates[0] == NULL) {
                     echo "<td rowspan=" . $nbLigne . " {$colorRed}>" . date("d-m-Y \\à H:i:s", strtotime($dates[1])) . "</td>";
                 } else {
                     echo "<td rowspan=" . $nbLigne . " {$colorRed}>" . date("d-m-Y \\à H:i:s", strtotime($resa["fin"])) . "</td>";
                 }
                 //le commentaire
                 echo "<td rowspan=" . $nbLigne . " {$colorRed}>" . $resa["comment"] . "</td>";
                 // les fleches de mouvements
                 echo "<td rowspan=" . $nbLigne . " ><center>";
                 if (date("Y-m-d", strtotime($resa["debut"])) == date("Y-m-d", strtotime($begin))) {
                     echo "<img title=\"\" alt=\"\" src=\"../pics/up-icon.png\"></img>";
                 }
                 if (date("Y-m-d", strtotime($resa["fin"])) == date("Y-m-d", strtotime($end))) {
                     echo "<img title=\"\" alt=\"\" src=\"../pics/down-icon.png\"></img>";
                 }
                 echo "</center></td>";
             }
             if ($nbLigne > 1) {
                 $flag = 1;
             }
             if ($Num == $limiteLigneNumber) {
                 $flag = 0;
                 $nbLigne = 1;
             }
             // si la reservation est rendue, on affiche la date du retour, sinon le bouton pour acquitter le retour
             if ($dates[0] != NULL) {
                 echo "<td>" . date("d-m-Y \\à H:i:s", strtotime($dates[0])) . "</td>";
             } else {
                 echo "<td><center><a title=\"Marquer comme rendu\" href=\"reservation.php?resareturn=" . $resa['resaid'] . "\"><img title=\"\" alt=\"\" src=\"../pics/greenbutton.png\"></img></a></center></td>";
             }
             // boutons action
             $matDispo = getMatDispo();
             echo "<td>";
             echo "<ul>";
             echo "<li><span class=\"bouton\" id=\"bouton_add" . $resa['resaid'] . "\" onclick=\"javascript:afficher_cacher('add" . $resa['resaid'] . "');\">Ajouter un materiel</span>\n          <div id=\"add" . $resa['resaid'] . "\" style=\"display:none;\">\n          <form method='POST' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
             echo '<select name="matDispoAdd">';
             foreach ($matDispo as $mat) {
                 echo "\t", '<option value="', key($mat), '">', current($mat), '</option>';
             }
             echo "<input type='hidden' name='AjouterMatToResa' value='" . $resa['resaid'] . "'>";
             echo "<input type='submit' class='submit' name='submit' value=Ajouter>";
             Html::closeForm();
             echo "</div></li>";
             echo "<li><span class=\"bouton\" id=\"bouton_replace" . $resa['resaid'] . "\" onclick=\"javascript:afficher_cacher('replace" . $resa['resaid'] . "');\">Remplacer le materiel</span>\n          <div id=\"replace" . $resa['resaid'] . "\" style=\"display:none;\">\n          <form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
             echo '<select name="matDispoReplace">';
             foreach ($matDispo as $mat) {
                 echo "\t", '<option value="', key($mat), '">', current($mat), '</option>';
             }
             echo "<input type='hidden' name='ReplaceMatToResa' value='" . $resa['resaid'] . "'>";
             echo "<input type='submit' class='submit' name='submit' value=Remplacer>";
             Html::closeForm();
             echo "</div></li>";
             echo "</ul>";
             echo "</td>";
             echo "<td>";
             echo "<ul>";
             echo "<li><a class=\"bouton\" title=\"Editer la reservation\" href='../../../front/reservation.form.php?id=" . $resa['resaid'] . "'>Editer la reservation</a></li>";
             echo "</ul>";
             echo "</td>";
             if ($methode == "manual") {
                 echo "<td>";
                 echo "<ul>";
                 if ($flagSurveille) {
                     echo "<li><a class=\"bouton\" title=\"Envoyer un mail de rappel\" href=\"reservation.php?mailuser="******"\">Envoyer un mail de rappel</a></li>";
                     if (isset($dates[2])) {
                         echo "<li>Dernier mail envoyé le : </li>";
                         echo "<li>" . date("d-m-Y \\à H:i:s", strtotime($dates[2])) . "</li>";
                     }
                 }
                 echo "</ul>";
                 echo "</td>";
             }
             echo "</tr>";
             echo "<tr class='tab_bg_2'>";
         }
         echo "</tr>\n";
     }
     echo "</tbody>";
     echo "</table>\n";
     echo "</div>\n";
 }