Ejemplo n.º 1
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = '/plugins/datainjection/front/clientinjection.form.php';
     if (Session::haveRight(static::$rightname, READ)) {
         $image_model = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' title='";
         $image_model .= PluginDatainjectionModel::getTypeName();
         $image_model .= "' alt='" . PluginDatainjectionModel::getTypeName() . "'>";
         $image_import = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' title='";
         $image_import .= __s('Injection of the file', 'datainjection');
         $image_import .= "' alt='" . __s('Injection of the file', 'datainjection') . "'>";
         $menu['options']['client']['title'] = self::getMenuName();
         $menu['options']['client']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         $menu['options']['client']['links']['search'] = '/plugins/datainjection/front/clientinjection.form.php';
         if (Session::haveRight('plugin_datainjection_model', READ)) {
             $menu['options']['model']['title'] = PluginDatainjectionModel::getTypeName();
             $menu['options']['model']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
             $menu['options']['model']['links']['search'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
             $menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         }
         //$menu['options']['client']['links'][$image_model]  = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         $menu['options']['model']['links'][$image_import] = '/plugins/datainjection/front/clientinjection.form.php';
         if (Session::haveRight('plugin_datainjection_model', UPDATE) || Session::haveRight('plugin_datainjection_model', CREATE)) {
             $menu['options']['model']['links']['add'] = Toolbox::getItemTypeFormUrl('PluginDatainjectionModel', false);
             $menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         }
     }
     return $menu;
 }
Ejemplo n.º 2
0
 function ExecPhp_Admin(&$cache)
 {
     $this->m_cache =& $cache;
     if (!is_admin()) {
         return;
     }
     global $wp_version;
     if (version_compare($wp_version, '2.6.dev') >= 0) {
         load_plugin_textdomain(ExecPhp_PLUGIN_ID, false, ExecPhp_HOMEDIR . '/languages');
     } else {
         load_plugin_textdomain(ExecPhp_PLUGIN_ID, ExecPhp_PLUGINDIR . '/' . ExecPhp_HOMEDIR . '/languages');
     }
     $this->m_common_l10n = array('messageContainer' => ExecPhp_ID_MESSAGE);
     $this->m_common_script =& new ExecPhp_Script(ExecPhp_ID_SCRIPT_COMMON, ExecPhp_ID_L10N_COMMON, $this->m_common_l10n, '/js/common.js', array());
     $this->m_write_ui =& new ExecPhp_WriteUi($this->m_cache, $this->m_common_script);
     $this->m_user_ui =& new ExecPhp_UserUi($this->m_cache);
     add_action('admin_notices', array(&$this, 'action_admin_notices'), 5);
     if (version_compare($wp_version, '2.1.dev') < 0) {
         return;
     }
     $this->m_style =& new ExecPhp_Style();
     $this->m_config_ui =& new ExecPhp_ConfigUi($this->m_cache, $this->m_common_script);
     if (current_user_can(ExecPhp_CAPABILITY_EDIT_PLUGINS) || current_user_can(ExecPhp_CAPABILITY_EDIT_USERS)) {
         $this->m_admin_l10n = array('noUserFound' => escape_dquote(__s('No user matching the query.', ExecPhp_PLUGIN_ID)), 'securityAlertHeading' => escape_dquote(__s('Exec-PHP Security Alert.', ExecPhp_PLUGIN_ID)), 'securityAlertText' => escape_dquote(__s('The Exec-PHP plugin found a security hole with the configured user rights of this blog. For further information consult the plugin configuration menu or contact your blog administrator.', ExecPhp_PLUGIN_ID)), 'requestFile' => get_option('siteurl') . '/wp-admin/admin-ajax.php', 'ajaxError' => escape_dquote(__s("Exec-PHP AJAX HTTP error when receiving data: ", ExecPhp_PLUGIN_ID)), 'action' => ExecPhp_ACTION_REQUEST_USERS, 'executeArticlesContainer' => ExecPhp_ID_INFO_EXECUTE_ARTICLES, 'widgetsContainer' => ExecPhp_ID_INFO_WIDGETS, 'securityHoleContainer' => ExecPhp_ID_INFO_SECURITY_HOLE);
         $this->m_admin_script =& new ExecPhp_Script(ExecPhp_ID_SCRIPT_ADMIN, ExecPhp_ID_L10N_ADMIN, $this->m_admin_l10n, '/js/admin.js', array('sack'));
         add_action('admin_footer', array(&$this, 'action_admin_footer'));
     }
 }
Ejemplo n.º 3
0
 function showForm($target, $ID)
 {
     $this->getFromDB($ID);
     $delay_expired = $this->fields["delay_expired"];
     $delay_whichexpire = $this->fields["delay_whichexpire"];
     echo "<div align='center'>";
     echo "<form method='post' action=\"{$target}\">";
     echo "<table class='tab_cadre_fixe' cellpadding='5'><tr><th>";
     echo __('Time of checking of validity of domains', 'domains') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td><div align='center'>";
     $delay_stamp_first = mktime(0, 0, 0, date("m"), date("d") - $delay_expired, date("y"));
     $delay_stamp_next = mktime(0, 0, 0, date("m"), date("d") + $delay_whichexpire, date("y"));
     $date_first = date("Y-m-d", $delay_stamp_first);
     $date_next = date("Y-m-d", $delay_stamp_next);
     echo "<tr class='tab_bg_1'><td><div align='left'>";
     _e('Domains expired since more', 'domains');
     echo "&nbsp;<input type='text' size='5' name='delay_expired' value=\"{$delay_expired}\">";
     echo "&nbsp;" . _n('Day', 'Days', 2);
     echo "&nbsp;( >" . Html::convdate($date_first) . ")<br>";
     _e('Domains expiring in less than', 'domains');
     echo "&nbsp;<input type='text' size='5' name='delay_whichexpire' value=\"{$delay_whichexpire}\">";
     echo "&nbsp;" . _n('Day', 'Days', 2);
     echo "&nbsp;( <" . Html::convdate($date_next) . ")";
     echo "</td>";
     echo "</tr>";
     echo "<tr><th>";
     echo "<input type='hidden' name='id' value='" . $ID . "'>";
     echo "<div align='center'>";
     echo "<input type='submit' name='update' value=\"" . __s('Post') . "\" class='submit' >";
     echo "</div></th></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Ejemplo n.º 4
0
 function showconfigForm()
 {
     global $CFG_GLPI;
     echo "<form name='form' method='post' action='" . $CFG_GLPI["root_doc"] . "/plugins/immobilizationsheets/front/config.form.php'>";
     echo "<div align=\"center\">";
     echo "<table class=\"tab_cadre_fixe\"  cellspacing=\"2\" cellpadding=\"2\">";
     echo "<tr><th colspan=\"2\">" . __('Options', 'immobilizationsheets') . "</th></tr>";
     echo "<tr class='tab_bg_1 top'>";
     echo "<td>" . __('Save sheets in GLPI', 'immobilizationsheets') . ": </td>";
     echo "<td>";
     Dropdown::showYesNo("use_backup", $this->fields["use_backup"]);
     echo "</td>";
     echo "<tr class='tab_bg_1 top'><td>";
     echo __('Default Heading for sheets', 'immobilizationsheets') . ": </td>";
     echo "<td>";
     Dropdown::show('DocumentCategory', array('name' => "documentcategories_id", 'value' => $this->fields["documentcategories_id"]));
     echo "</td>";
     echo "<tr><th colspan='2'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<input type=\"submit\" name=\"update_config\" class=\"submit\" value=\"" . __s('Post') . "\" >";
     echo "</th></tr>";
     echo "</table></div>";
     Html::closeForm();
     echo "<br>";
 }
Ejemplo n.º 5
0
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     $obj = $options['obj'];
     //Html::printCleanArray($obj);
     $itemtype = getItemTypeForTable($obj->getTable());
     $list_ip = array();
     $total_ip = 0;
     if ($itemtype == 'NetworkEquipment') {
         $query = "SELECT `ip`\n                   FROM `glpi_networkequipments`\n                   WHERE `id` = '" . $obj->fields['id'] . "'";
         $res = $DB->query($query);
         while ($row = $DB->fetch_array($res)) {
             if ($row['ip'] != '') {
                 $list_ip[$row['ip']] = $row['ip'];
             }
         }
     }
     $tmp = array_values($list_ip);
     if (count($tmp) > 0 && $tmp[0] == '') {
         array_pop($list_ip);
     }
     $query = "SELECT `glpi_networknames`.`name`, `glpi_ipaddresses`.`name` as ip, `glpi_networkports`.`items_id`\n               FROM `glpi_networkports` \n               LEFT JOIN `" . $obj->getTable() . "` ON (`glpi_networkports`.`items_id` = `" . $obj->getTable() . "`.`id`\n                              AND `glpi_networkports`.`itemtype` = '" . $itemtype . "')\n               LEFT JOIN `glpi_networknames` ON (`glpi_networkports`.`id` =  `glpi_networknames`.`items_id`)\n               LEFT JOIN `glpi_ipaddresses` ON (`glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`)\n                WHERE `" . $obj->getTable() . "`.`id` = '" . $obj->fields['id'] . "'";
     $res = $DB->query($query);
     while ($row = $DB->fetch_array($res)) {
         if ($row['ip'] != '') {
             $port = $row['ip'];
             if ($row['name'] != '') {
                 $port = $row['name'] . " ({$port})";
             }
             $list_ip[$row['ip']] = $port;
         }
     }
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 left'>";
     echo "<tr><th colspan='4'>" . __('IP ping', 'addressing') . "</th></tr>";
     if (count($list_ip) > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('IP') . " : </td>";
         echo "<td colspan='3'>";
         echo "<select id='ip'>";
         echo "<option>" . Dropdown::EMPTY_VALUE . "</option>";
         foreach ($list_ip as $ip => $name) {
             echo "<option value='{$ip}'>{$name}</option>";
         }
         echo "</select>";
         echo "&nbsp;<input class='submit' type='button' value='" . __s('Ping', 'addressing') . "' onclick='pingIp();'>";
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Result', 'addressing') . " : </td>";
         echo "<td colspan='3'>";
         echo "<div id='ping_response' class='plugin_addressing_ping_equipment'></div>";
         echo "</td></tr>";
     }
     echo "</table>";
     echo "\n         <script type='text/javascript'>\n            function pingIp() {\n               var ip = Ext.get('ip').dom.options[Ext.get('ip').dom.selectedIndex].value;\n               var ping_response = Ext.get('ping_response');\n\n               Ext.Ajax.request({\n                  url : '" . $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/ping.php' ,\n                  params : { ip : ip },\n                  method: 'POST',\n                  success: function ( result, request ) {\n                     ping_response.insertHtml('afterBegin', '<hr>'+result.responseText);\n                  }\n               });\n            }\n         </script>\n      ";
     if (count($list_ip) == 0) {
         echo __('No IP for this equipment', 'addressing');
     }
 }
Ejemplo n.º 6
0
 function action_sidebar_admin_page()
 {
     if ($this->rtfm_widget()) {
         $heading = __s('Exec-PHP Widget Conversion Warning.', ExecPhp_PLUGIN_ID);
         $text = __s('Saving the widgets will render all contained PHP code permanently unuseful. Ignore this warning in case the text widgets do not contain PHP code. <a href="%s">Read the Exec-PHP documentation if you are unsure what to do next</a>.', ExecPhp_PLUGIN_ID, ExecPhp_HOME_URL . '/docs/' . __s('readme.html', ExecPhp_PLUGIN_ID) . '#execute_php');
         $this->m_script->print_message($heading, $text);
     }
 }
Ejemplo n.º 7
0
 /**
  * @see CommonGLPI::getAdditionalMenuLinks()
  **/
 static function getAdditionalMenuLinks()
 {
     global $CFG_GLPI;
     $links = array();
     $links['config'] = '/plugins/example/index.php';
     $links["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title='" . __s('Show all') . "' alt='" . __s('Show all') . "'>"] = '/plugins/example/index.php';
     $links[__s('Test link', 'example')] = '/plugins/example/index.php';
     return $links;
 }
Ejemplo n.º 8
0
 function showAddForm($target)
 {
     echo "<div align='center'><form method='post'  action=\"{$target}\">";
     echo "<table class='tab_cadre_fixe' cellpadding='5'><tr ><th colspan='2'>";
     echo __('add not-used status in expiration mail', 'certificates') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td>";
     Dropdown::show('PluginCertificatesCertificateState', array('name' => "plugin_certificates_certificatestates_id"));
     echo "</td>";
     echo "<td>";
     echo "<div align='center'><input type='submit' name='add' value=\"" . __s('Post') . "\" class='submit' ></div></td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Ejemplo n.º 9
0
 function showForm()
 {
     $this->getFromDB('1');
     echo "<div align='center'>";
     echo "<form method='post' action=\"./config.form.php\">";
     echo "<table class='tab_cadre' cellpadding='5'>";
     echo "<tr>";
     echo "<th colspan='2'>" . __('Identification parameters of inventory number', 'financialreports') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Computer', 'Computers', 2) . "</td>";
     echo "<td><input type='text' name='computers_otherserial' value='" . $this->fields["computers_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Notebook', 'Notebooks', 2, 'financialreports') . "</td>";
     echo "<td><input type='text' name='notebooks_otherserial' value='" . $this->fields["notebooks_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Server', 'Servers', 2, 'financialreports') . "</td>";
     echo "<td><input type='text' name='servers_otherserial' value='" . $this->fields["servers_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Monitor', 'Monitors', 2) . "</td>";
     echo "<td><input type='text' name='monitors_otherserial' value='" . $this->fields["monitors_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Printer', 'Printers', 2) . "</td>";
     echo "<td><input type='text' name='printers_otherserial' value='" . $this->fields["printers_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Device', 'Devices', 2) . "</td>";
     echo "<td><input type='text' name='peripherals_otherserial' value='" . $this->fields["peripherals_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Network device', 'Network devices', 2) . "</td>";
     echo "<td><input type='text' name='networkequipments_otherserial' value='" . $this->fields["networkequipments_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Phone', 'Phones', 2) . "</td>";
     echo "<td><input type='text' name='phones_otherserial' value='" . $this->fields["phones_otherserial"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center'>";
     echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
     echo "<input type='submit' name='update_parameters' value='" . __s('Post') . "' class='submit' >";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Ejemplo n.º 10
0
function plugin_talk_MassiveActionsDisplay($options = array())
{
    switch ($options['itemtype']) {
        case 'Profile':
            switch ($options['action']) {
                case "plugin_talk_edit_profile":
                    echo _sx('button', 'Enable') . " : ";
                    Dropdown::showYesNo("is_active", 1);
                    echo "&nbsp;<input type='submit' name='massiveaction' class='submit' value='" . __s('Post') . "'>";
                    break;
            }
            break;
    }
    return "";
}
Ejemplo n.º 11
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = "/plugins/ocsinventoryng/front/ocsng.php";
     $menu['links']['search'] = "/plugins/ocsinventoryng/front/ocsng.php";
     if (Session::haveRight(static::$rightname, UPDATE) || Session::haveRight("config", UPDATE)) {
         //Entry icon in breadcrumb
         $menu['links']['config'] = PluginOcsinventoryngConfig::getSearchURL(false);
         //Link to config page in admin plugins list
         $menu['config_page'] = PluginOcsinventoryngConfig::getSearchURL(false);
     }
     // Ocsserver
     $menu['options']['ocsserver']['title'] = __s("Configuration of OCSNG server", 'ocsinventoryng');
     $menu['options']['ocsserver']['page'] = '/plugins/ocsinventoryng/front/ocsserver.php';
     $menu['options']['ocsserver']['links']['add'] = '/plugins/ocsinventoryng/front/ocsserver.form.php';
     $menu['options']['ocsserver']['links']['search'] = '/plugins/ocsinventoryng/front/ocsserver.php';
     // Import
     $menu['options']['import']['title'] = __s('Import new computers', 'ocsinventoryng');
     $menu['options']['import']['page'] = '/plugins/ocsinventoryng/front/ocsng.import.php';
     // Sync
     $menu['options']['sync']['title'] = __s('Synchronize computers already imported', 'ocsinventoryng');
     $menu['options']['sync']['page'] = '/plugins/ocsinventoryng/front/ocsng.sync.php';
     // Link
     $menu['options']['link']['title'] = __s('Link new OCSNG computers to existing GLPI computers', 'ocsinventoryng');
     $menu['options']['link']['page'] = '/plugins/ocsinventoryng/front/ocsng.link.php';
     // Thread
     $menu['options']['thread']['title'] = __s('Scripts execution of automatic actions', 'ocsinventoryng');
     $menu['options']['thread']['page'] = '/plugins/ocsinventoryng/front/thread.php';
     // Detail
     $menu['options']['detail']['title'] = __('Computers imported by automatic actions', 'ocsinventoryng');
     $menu['options']['detail']['page'] = '/plugins/ocsinventoryng/front/detail.php';
     // Notimported
     $menu['options']['notimported']['title'] = __s('Computers not imported by automatic actions', 'ocsinventoryng');
     $menu['options']['notimported']['page'] = '/plugins/ocsinventoryng/front/notimportedcomputer.php';
     if (Session::haveRight("plugin_ocsinventoryng_clean", READ)) {
         // Deleted_equiv
         $menu['options']['deleted_equiv']['title'] = __s('Clean OCSNG deleted computers', 'ocsinventoryng');
         $menu['options']['deleted_equiv']['page'] = '/plugins/ocsinventoryng/front/deleted_equiv.php';
         // Clean
         $menu['options']['clean']['title'] = __s('Clean links between GLPI and OCSNG', 'ocsinventoryng');
         $menu['options']['clean']['page'] = '/plugins/ocsinventoryng/front/ocsng.clean.php';
     }
     return $menu;
 }
Ejemplo n.º 12
0
 function showForm($target)
 {
     global $CFG_GLPI;
     $categories = getAllDatasFromTable($this->getTable());
     if (!empty($categories)) {
         echo "<div align='center'>";
         $rand = mt_rand();
         echo "<form method='post' name='massiveaction_form_ticket{$rand}' \n                                    id='massiveaction_form_ticket{$rand}' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe' cellpadding='5'>";
         echo "<tr>";
         echo "<th></th><th>" . __('Category of created tickets', 'resources') . "</th>";
         echo "</tr>";
         foreach ($categories as $categorie) {
             $ID = $categorie["id"];
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center' width='10'>";
             echo "<input type='hidden' name='id' value='{$ID}'>";
             echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
             echo "</td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_itilcategories", $categorie["ticketcategories_id"]) . "</td>";
             echo "</tr>";
         }
         Html::openArrowMassives("massiveaction_form_ticket{$rand}", true);
         Html::closeArrowMassives(array('delete_ticket' => __s('Delete permanently')));
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     } else {
         echo "<div align='center'><form method='post'  action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe' cellpadding='5'><tr ><th colspan='2'>";
         echo __('Category of created tickets', 'resources') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         Dropdown::show('ITILCategory', array('name' => "ticketcategories_id"));
         echo "</td>";
         echo "<td>";
         echo "<div align='center'>";
         echo "<input type='submit' name='add_ticket' value=\"" . _sx('button', 'Add') . "\" \n                                                                                 class='submit'>";
         echo "</div></td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
 }
Ejemplo n.º 13
0
/**
 * Display group form
**/
function displaySearchForm()
{
    global $_SERVER, $_GET, $CFG_GLPI;
    echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>";
    echo "<table class='tab_cadre' cellpadding='5'>";
    echo "<tr class='tab_bg_1 center'>";
    echo "<td>";
    echo __('Group') . "&nbsp;&nbsp;";
    Group::dropdown(array('name =>' => "group", 'value' => $_GET["group"], 'entity' => $_SESSION["glpiactive_entity"], 'condition' => "is_itemgroup"));
    echo "</td>";
    // Display Reset search
    echo "<td>";
    echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/reports/report/equipmentbygroups/equipmentbygroups.php?reset_search=reset_search'>" . "<img title='" . __s('Blank') . "' alt='" . __s('Blank') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
    echo "</td>";
    echo "<td>";
    echo "<input type='submit' value='Valider' class='submit' />";
    echo "</td>";
    echo "</tr></table>";
    Html::closeForm();
}
 function showGenericSearch($itemtype, $params)
 {
     global $CFG_GLPI;
     // Default values of parameters
     $p = array();
     $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 = Search::getCleanedOptions($itemtype);
     //      $target  = Toolbox::getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $linked = Search::getMetaItemtypeAvailable($itemtype);
     if (!isset($_GET['id']) || strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
         $item->getEmpty();
     } else {
         $item->getFromDB($_GET['id']);
     }
     if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
         echo "<form name='searchform{$itemtype}' method='get' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayview_rule.form.php\">";
     } else {
         echo "<form name='searchform{$itemtype}' method='get' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/componentscatalog_rule.form.php\">";
     }
     $item->showFormHeader();
     //      echo "<form name='searchform$itemtype' method='get' action=\"".
     //              $CFG_GLPI['root_doc']."/plugins/monitoring/front/componentscatalog_rule.form.php\">";
     //      echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Name') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='name' value='" . $_GET['name'] . "'/>";
     echo "</td>";
     echo "<td>";
     echo __('Status') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo $_GET['itemtype'];
     echo "</td>";
     echo "</tr>";
     if (isset($_GET['itemtype'])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         echo "<table>";
         // Display normal search parameters
         for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
             echo "<tr><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','','','');
                 //                      document.forms['searchform$itemtype'].submit();\">
                 //                      <img src=\"".$CFG_GLPI["root_doc"]."/pics/showdeleted".
                 //                       (!$p['is_deleted']?'_no':'').".png\" name='img_deleted'  alt=\"".
                 //                       (!$p['is_deleted']?$LANG['common'][3]:$LANG['common'][81])."\" title=\"".
                 //                       (!$p['is_deleted']?$LANG['common'][3]:$LANG['common'][81])."\" ></a>";
                 //               // Dropdown::showYesNo("is_deleted",$p['is_deleted']);
                 //               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;";
             }
             // display select box to define search item
             echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
             echo "<option value='view' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
                 echo "selected";
             }
             echo ">" . __('Items seen') . "</option>\n";
             reset($options);
             $first_group = true;
             $selected = 'view';
             $str_limit = 28;
             $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;
                         }
                         $group .= ">" . Toolbox::substr($val["name"], 0, $str_limit) . "</option>\n";
                     }
                 }
             }
             if (!$first_group) {
                 $group .= "</optgroup>\n";
             }
             if ($nb_in_group) {
                 echo $group;
             }
             echo "<option value='all' ";
             if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
                 echo "selected";
             }
             echo ">" . __('All') . "</option>";
             echo "</select>\n";
             echo "</td><td class='left'>";
             echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
             $_POST['itemtype'] = $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' => $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, false);
             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])) {
                         $linkitem = new $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, false);
                 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, false);
                     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'>".$LANG['search'][4];
               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);
         if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayview_rule.form.php?" . "reset=reset" . "&name=" . $_GET['name'] . "&plugin_monitoring_displayviews_id=" . $_GET['plugin_monitoring_displayviews_id'] . "&itemtype=" . $_GET['itemtype'] . "' >";
         } else {
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/componentscatalog_rule.form.php?" . "reset=reset" . "&name=" . $_GET['name'] . "&plugin_monitoring_componentscalalog_id=" . $_GET['plugin_monitoring_componentscalalog_id'] . "&itemtype=" . $_GET['itemtype'] . "' >";
         }
         echo "&nbsp;&nbsp;<img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
         echo "</td></tr>";
         echo "</table>\n";
         echo "</td></tr>";
         echo "<tr>";
     }
     if (isset($_GET['id'])) {
         echo "<td colspan='2' class='center'>";
         if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) {
             echo "<input type='hidden' name='plugin_monitoring_displayviews_id' value='" . $_GET['plugin_monitoring_displayviews_id'] . "' >";
         } else {
             echo "<input type='hidden' name='plugin_monitoring_componentscalalog_id' value='" . $_GET['plugin_monitoring_componentscalalog_id'] . "' >";
         }
         echo "<input type='hidden' name='id' value='" . $_GET['id'] . "' >";
         echo "<input type='submit' name='updaterule' value=\"Update this rule\" class='submit' >";
         echo "</td>";
         echo "<td colspan='2' class='center'>";
         echo "<input type='submit' name='deleterule' value=\"Delete this rule\" class='submit' >";
     } else {
         echo "<td colspan='4' class='center'>";
         echo "<input type='hidden' name='plugin_monitoring_componentscalalog_id' value='" . $_GET['plugin_monitoring_componentscalalog_id'] . "' >";
         echo "<input type='submit' name='addrule' value=\"Add this rule\" class='submit' >";
     }
     echo "</td>";
     echo "</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'>";
     Html::closeForm();
 }
 function prev_form($host, $user, $password)
 {
     echo "<br><form action='install.php' method='post'>";
     echo "<input type='hidden' name='db_host' value='" . $host . "'>";
     echo "<input type='hidden' name='db_user' value='" . $user . "'>";
     echo " <input type='hidden' name='db_pass' value='" . rawurlencode($password) . "'>";
     echo "<input type='hidden' name='update' value='no'>";
     echo "<input type='hidden' name='install' value='Etape_2'>";
     echo "<p class='submit'><input type='submit' name='submit' class='submit' value='" . __s('Back') . "'></p>";
     Html::closeForm();
 }
Ejemplo n.º 16
0
 /**
  * Send password recovery for a user.
  *
  * @param $email email of the user
  *
  * @return nothing : send email or display error message
  **/
 function forgetPassword($email)
 {
     global $CFG_GLPI;
     echo "<div class='center'>";
     if ($this->getFromDBbyEmail($email, "`glpi_users`.`is_active` AND NOT `glpi_users`.`is_deleted`")) {
         // Send token if auth DB or not external auth defined
         if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) {
             if (NotificationMail::isUserAddressValid($email)) {
                 $input['password_forget_token'] = sha1(Toolbox::getRandomString(30));
                 $input['password_forget_token_date'] = $_SESSION["glpi_currenttime"];
                 $input['id'] = $this->fields['id'];
                 $this->update($input);
                 // Notication on root entity (glpi_users.entities_id is only a pref)
                 NotificationEvent::raiseEvent('passwordforget', $this, array('entities_id' => 0));
                 _e('An email has been sent to your email address. The email contains information for reset your password.');
             } else {
                 _e('Invalid email address');
             }
         } else {
             _e("The authentication method configuration doesn't allow you to change your password.");
         }
     } else {
         _e('Email address not found.');
     }
     echo "<br>";
     echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/index.php\">" . __s('Back') . "</a>";
     echo "</div>";
 }
Ejemplo n.º 17
0
 /**
  * Print the search config form
  *
  * @param $target    form target
  * @param $itemtype  item type
  *
  * @return nothing
  **/
 function showFormGlobal($target, $itemtype)
 {
     global $CFG_GLPI, $DB;
     $searchopt = Search::getOptions($itemtype);
     if (!is_array($searchopt)) {
         return false;
     }
     $IDuser = 0;
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     $global_write = Session::haveRight(self::$rightname, self::GENERAL);
     echo "<div class='center' id='tabsbody' >";
     // Defined items
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `itemtype` = '{$itemtype}'\n                      AND `users_id` = '{$IDuser}'\n                ORDER BY `rank`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     echo "<table class='tab_cadre_fixehov'><tr><th colspan='4'>";
     echo __('Select default items to show') . "</th></tr>\n";
     if ($global_write) {
         $already_added = self::getForTypeUser($itemtype, $IDuser);
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<form method='post' action='{$target}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
         $group = '';
         $values = array();
         $searchopt = Search::getCleanedOptions($itemtype);
         foreach ($searchopt as $key => $val) {
             if (!is_array($val)) {
                 $group = $val;
             } else {
                 if ($key != 1 && !in_array($key, $already_added) && (!isset($val['nodisplay']) || !$val['nodisplay'])) {
                     $values[$group][$key] = $val["name"];
                 }
             }
         }
         if ($values) {
             Dropdown::showFromArray('num', $values);
             echo "<span class='small_space'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</span>";
         }
         Html::closeForm();
         echo "</td></tr>";
     }
     // print first element
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' width='50%'>" . $searchopt[1]["name"];
     if ($global_write) {
         echo "</td><td colspan='3'>&nbsp;";
     }
     echo "</td></tr>";
     // print entity
     if (Session::isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>";
         echo "<td colspan='3'>&nbsp;</td>";
         echo "</tr>";
     }
     $i = 0;
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["num"] != 1 && isset($searchopt[$data["num"]])) {
                 echo "<tr class='tab_bg_2'><td class='center' width='50%'>";
                 echo $searchopt[$data["num"]]["name"];
                 echo "</td>";
                 if ($global_write) {
                     if ($i != 0) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='up' value=\"" . __s('Bring up') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up.png' alt=\"" . __s('Bring up') . "\"  title=\"" . __s('Bring up') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     if ($i != $numrows - 1) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='down' value=\"" . __s('Bring down') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down.png' alt=\"" . __s('Bring down') . "\" title=\"" . __s('Bring down') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     echo "<td class='center middle'>";
                     echo "<form method='post' action='{$target}'>";
                     echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                     echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                     echo "<input type='image' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png' alt=\"" . __s('Delete permanently') . "\" title=\"" . __s('Delete permanently') . "\"  class='pointer'>";
                     Html::closeForm();
                     echo "</td>\n";
                 }
                 echo "</tr>";
                 $i++;
             }
         }
     }
     echo "</table>";
     echo "</div>";
 }
 /**
  * Show the current ticketfollowup summary
  *
  * @param $ticket Ticket object
  **/
 function showSummary($ticket)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRightsOr(self::$rightname, array(self::SEEPUBLIC, self::SEEPRIVATE))) {
         return false;
     }
     $tID = $ticket->fields['id'];
     // Display existing Followups
     $showprivate = Session::haveRight(self::$rightname, self::SEEPRIVATE);
     $caneditall = Session::haveRight(self::$rightname, self::UPDATEALL);
     $tmp = array('tickets_id' => $tID);
     $canadd = $this->can(-1, CREATE, $tmp);
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $techs = $ticket->getAllUsers(CommonITILActor::ASSIGN);
     $reopen_case = false;
     if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray()) && $ticket->isAllowedStatus($ticket->fields['status'], Ticket::INCOMING)) {
         $reopen_case = true;
     }
     $tech = Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
     $RESTRICT = "";
     if (!$showprivate) {
         $RESTRICT = " AND (`is_private` = '0'\n                            OR `users_id` ='" . Session::getLoginUserID() . "') ";
     }
     $query = "SELECT `glpi_ticketfollowups`.*, `glpi_users`.`picture`\n                FROM `glpi_ticketfollowups`\n                LEFT JOIN `glpi_users` ON (`glpi_ticketfollowups`.`users_id` = `glpi_users`.`id`)\n                WHERE `tickets_id` = '{$tID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     $rand = mt_rand();
     if ($caneditall || $canadd) {
         echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
     }
     if ($canadd) {
         echo "<script type='text/javascript' >\n";
         echo "function viewAddFollowup" . $ticket->fields['id'] . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo Html::jsHide('addbutton' . $ticket->fields['id'] . "{$rand}");
         echo "};";
         echo "</script>\n";
         // Not closed ticket or closed
         if (!in_array($ticket->fields["status"], array_merge($ticket->getSolvedStatusArray(), $ticket->getClosedStatusArray())) || $reopen_case) {
             if (isset($_GET['_openfollowup']) && $_GET['_openfollowup']) {
                 echo Html::scriptBlock("viewAddFollowup" . $ticket->fields['id'] . "{$rand}()");
             } else {
                 echo "<div id='addbutton" . $ticket->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddFollowup" . $ticket->fields['id'] . "{$rand}();'>";
                 if ($reopen_case) {
                     _e('Reopen the ticket');
                 } else {
                     _e('Add a new followup');
                 }
                 echo "</a></div>\n";
             }
         }
     }
     if ($DB->numrows($result) == 0) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
         echo "<th class='b'>" . __('No followup for this ticket.') . "</th></tr></table>";
     } else {
         $today = strtotime('today');
         $lastmonday = strtotime('last monday');
         $lastlastmonday = strtotime('last monday', strtotime('last monday'));
         // Case of monday
         if ($today - $lastmonday == 7 * DAY_TIMESTAMP) {
             $lastlastmonday = $lastmonday;
             $lastmonday = $today;
         }
         $steps = array(0 => array('end' => $today, 'name' => __('Today')), 1 => array('end' => $lastmonday, 'name' => __('This week')), 2 => array('end' => $lastlastmonday, 'name' => __('Last week')), 3 => array('end' => strtotime('midnight first day of'), 'name' => __('This month')), 4 => array('end' => strtotime('midnight first day of last month'), 'name' => __('Last month')), 5 => array('end' => 0, 'name' => __('Before the last month')));
         $currentpos = -1;
         while ($data = $DB->fetch_assoc($result)) {
             $this->getFromDB($data['id']);
             $candelete = $this->canPurge() && $this->canPurgeItem();
             $canedit = $this->canUpdate() && $this->canUpdateItem();
             $time = strtotime($data['date']);
             if (!isset($steps[$currentpos]) || $steps[$currentpos]['end'] > $time) {
                 $currentpos++;
                 while ($steps[$currentpos]['end'] > $time && isset($steps[$currentpos + 1])) {
                     $currentpos++;
                 }
                 if (isset($steps[$currentpos])) {
                     echo "<h3>" . $steps[$currentpos]['name'] . "</h3>";
                 }
             }
             $id = 'followup' . $data['id'] . $rand;
             $color = 'byuser';
             if (isset($techs[$data['users_id']])) {
                 $color = 'bytech';
             }
             $classtoadd = '';
             if ($canedit) {
                 $classtoadd = " pointer";
             }
             echo "<div class='boxnote {$color}' id='view{$id}'";
             echo ">";
             echo "<div class='boxnoteleft'>";
             echo "<img class='user_picture_verysmall' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($data['picture']) . "'>";
             echo "</div>";
             // boxnoteleft
             echo "<div class='boxnotecontent'";
             echo ">";
             echo "<div class='boxnotefloatleft'>";
             $username = NOT_AVAILABLE;
             if ($data['users_id']) {
                 $username = getUserName($data['users_id'], $showuserlink);
             }
             $name = sprintf(__('Create by %1$s on %2$s'), $username, Html::convDateTime($data['date']));
             if ($data['requesttypes_id']) {
                 $name = sprintf(__('%1$s - %2$s'), $name, Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']));
             }
             if ($showprivate && $data["is_private"]) {
                 $name = sprintf(__('%1$s - %2$s'), $name, __('Private'));
             }
             echo $name;
             echo "</div>";
             // floatright
             echo "<div class='boxnotetext {$classtoadd}'";
             if ($canedit) {
                 echo " onClick=\"viewEditFollowup" . $ticket->fields['id'] . $data['id'] . "{$rand}(); " . Html::jsHide("view{$id}") . " " . Html::jsShow("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}") . "\" ";
             }
             echo ">";
             $content = nl2br($data['content']);
             if (empty($content)) {
                 $content = NOT_AVAILABLE;
             }
             echo $content . '</div>';
             // boxnotetext
             echo "</div>";
             // boxnotecontent
             echo "<div class='boxnoteright'>";
             if ($candelete) {
                 Html::showSimpleForm(Toolbox::getItemTypeFormURL('TicketFollowup'), array('purge' => 'purge'), _x('button', 'Delete permanently'), array('id' => $data['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png", '', __('Confirm the final deletion?'));
             }
             echo "</div>";
             // boxnoteright
             echo "</div>";
             // boxnote
             if ($canedit) {
                 echo "<div id='viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}' class='starthidden'></div>\n";
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditFollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $data["tickets_id"], 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "assign_vlan":
             Vlan::dropdown();
             echo "&nbsp;" . __('Tagged') . "&nbsp;<input type='checkbox' name='tagged' value='1'>";
             echo "&nbsp;<input type='submit' name='assign_vlan' class='submit' value='" . __s('Associate') . "'>";
             return true;
         case "unassign_vlan":
             Vlan::dropdown();
             echo "&nbsp;<input type='submit' name='unassign_vlan' class='submit' value='" . __s('Dissociate') . "'>";
             return true;
         case "move_port":
             Dropdown::show('NetworkEquipment', array('name' => 'items_id'));
             echo "&nbsp;<input type='submit' name='move' class='submit' value=\"" . __s('Move') . "\">";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
Ejemplo n.º 20
0
 static function showMoreButton($rand)
 {
     global $CFG_GLPI;
     echo "&nbsp;<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer;margin-left:2px;'\n           onClick=\"var w = window.open('" . $CFG_GLPI['root_doc'] . "/plugins/tag/front/tag.form.php?popup=1&amp;rand=" . $rand . "', " . "'glpipopup', 'height=400, width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
 }
Ejemplo n.º 21
0
 /**
  * Display choice matrix
  *
  * @since version 0.85
  * @param $columns   array   of column field name => column label
  * @param $rows      array    of field name => array(
  *      'label' the label of the row
  *       'columns' an array of specific information regaring current row and given column indexed by column field_name
  *                 * a string if only have to display a string
  *                 * an array('value' => ???, 'readonly' => ???) that is used to Dropdown::showYesNo()
  * @param $options   array   possible:
  *       'title'         of the matrix
  *       'first_cell'    the content of the upper-left cell
  *       'row_check_all' set to true to display a checkbox to check all elements of the row
  *       'col_check_all' set to true to display a checkbox to check all elements of the col
  *       'rand'          random number to use for ids
  *
  * @return random value used to generate the ids
  **/
 static function showCheckboxMatrix(array $columns, array $rows, array $options = array())
 {
     $param['title'] = '';
     $param['first_cell'] = '&nbsp;';
     $param['row_check_all'] = false;
     $param['col_check_all'] = false;
     $param['rotate_column_titles'] = false;
     $param['rand'] = mt_rand();
     $param['table_class'] = 'tab_cadre_fixehov';
     $param['cell_class_method'] = NULL;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $param[$key] = $val;
         }
     }
     $cb_options = array('title' => __s('Check/uncheck all'));
     $number_columns = count($columns) + 1;
     if ($param['row_check_all']) {
         $number_columns += 1;
     }
     $width = round(100 / $number_columns);
     echo "\n<table class='" . $param['table_class'] . "'>\n";
     if (!empty($param['title'])) {
         echo "\t<tr>\n";
         echo "\t\t<th colspan='{$number_columns}'>" . $param['title'] . "</th>\n";
         echo "\t</tr>\n";
     }
     echo "\t<tr class='tab_bg_1'>\n";
     echo "\t\t<td>" . $param['first_cell'] . "</td>\n";
     foreach ($columns as $col_name => $column) {
         $nb_cb_per_col[$col_name] = array('total' => 0, 'checked' => 0);
         $col_id = Html::cleanId('col_label_' . $col_name . '_' . $param['rand']);
         echo "\t\t<td class='center b";
         if ($param['rotate_column_titles']) {
             echo " rotate";
         }
         echo "' id='{$col_id}' width='{$width}%'>";
         if (!is_array($column)) {
             $columns[$col_name] = $column = array('label' => $column);
         }
         if (isset($column['short']) && isset($column['long'])) {
             echo $column['short'];
             self::showToolTip($column['long'], array('applyto' => $col_id));
         } else {
             echo $column['label'];
         }
         echo "</td>\n";
     }
     if ($param['row_check_all']) {
         $col_id = Html::cleanId('col_of_table_' . $param['rand']);
         echo "\t\t<td class='center";
         if ($param['rotate_column_titles']) {
             echo " rotate";
         }
         echo "' id='{$col_id}'>" . __('Select/unselect all') . "</td>\n";
     }
     echo "\t</tr>\n";
     foreach ($rows as $row_name => $row) {
         if (!is_string($row) && !is_array($row)) {
             continue;
         }
         echo "\t<tr class='tab_bg_1'>\n";
         if (is_string($row)) {
             echo "\t\t<th colspan='{$number_columns}'>{$row}</th>\n";
         } else {
             $row_id = Html::cleanId('row_label_' . $row_name . '_' . $param['rand']);
             if (isset($row['class'])) {
                 $class = $row['class'];
             } else {
                 $class = '';
             }
             echo "\t\t<td class='b {$class}' id='{$row_id}'>";
             if (!empty($row['label'])) {
                 echo $row['label'];
             } else {
                 echo "&nbsp;";
             }
             echo "</td>\n";
             $nb_cb_per_row = array('total' => 0, 'checked' => 0);
             foreach ($columns as $col_name => $column) {
                 $class = '';
                 if (!empty($row['class']) && !empty($column['class'])) {
                     if (is_callable($param['cell_class_method'])) {
                         $class = $param['cell_class_method']($row['class'], $column['class']);
                     }
                 } else {
                     if (!empty($row['class'])) {
                         $class = $row['class'];
                     } else {
                         if (!empty($column['class'])) {
                             $class = $column['class'];
                         }
                     }
                 }
                 echo "\t\t<td class='center {$class}'>";
                 // Warning: isset return false if the value is NULL ...
                 if (array_key_exists($col_name, $row['columns'])) {
                     $content = $row['columns'][$col_name];
                     if (is_array($content) && array_key_exists('checked', $content)) {
                         if (!array_key_exists('readonly', $content)) {
                             $content['readonly'] = false;
                         }
                         $content['massive_tags'] = array();
                         if ($param['row_check_all']) {
                             $content['massive_tags'][] = 'row_' . $row_name . '_' . $param['rand'];
                         }
                         if ($param['col_check_all']) {
                             $content['massive_tags'][] = 'col_' . $col_name . '_' . $param['rand'];
                         }
                         if ($param['row_check_all'] && $param['col_check_all']) {
                             $content['massive_tags'][] = 'table_' . $param['rand'];
                         }
                         $content['name'] = $row_name . "[{$col_name}]";
                         $content['id'] = Html::cleanId('cb_' . $row_name . '_' . $col_name . '_' . $param['rand']);
                         Html::showCheckbox($content);
                         $nb_cb_per_col[$col_name]['total']++;
                         $nb_cb_per_row['total']++;
                         if ($content['checked']) {
                             $nb_cb_per_col[$col_name]['checked']++;
                             $nb_cb_per_row['checked']++;
                         }
                     } else {
                         if (is_string($content)) {
                             echo $content;
                         } else {
                             echo "&nbsp;";
                         }
                     }
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>\n";
             }
         }
         if ($param['row_check_all'] && !is_string($row) && $nb_cb_per_row['total'] > 1) {
             $cb_options['criterion'] = array('tag_for_massive' => 'row_' . $row_name . '_' . $param['rand']);
             $cb_options['massive_tags'] = 'table_' . $param['rand'];
             $cb_options['id'] = Html::cleanId('cb_checkall_row_' . $row_name . '_' . $param['rand']);
             $cb_options['checked'] = $nb_cb_per_row['checked'] > $nb_cb_per_row['total'] / 2;
             echo "\t\t<td class='center'>" . Html::getCheckbox($cb_options) . "</td>\n";
         }
         echo "\t</tr>\n";
     }
     if ($param['col_check_all']) {
         echo "\t<tr class='tab_bg_1'>\n";
         echo "\t\t<td>" . __('Select/unselect all') . "</td>\n";
         foreach ($columns as $col_name => $column) {
             echo "\t\t<td class='center'>";
             if ($nb_cb_per_col[$col_name]['total'] > 1) {
                 $cb_options['criterion'] = array('tag_for_massive' => 'col_' . $col_name . '_' . $param['rand']);
                 $cb_options['massive_tags'] = 'table_' . $param['rand'];
                 $cb_options['id'] = Html::cleanId('cb_checkall_col_' . $col_name . '_' . $param['rand']);
                 $cb_options['checked'] = $nb_cb_per_col[$col_name]['checked'] > $nb_cb_per_col[$col_name]['total'] / 2;
                 echo Html::getCheckbox($cb_options);
             } else {
                 echo "&nbsp;";
             }
             echo "</td>\n";
         }
         if ($param['row_check_all']) {
             $cb_options['criterion'] = array('tag_for_massive' => 'table_' . $param['rand']);
             $cb_options['massive_tags'] = '';
             $cb_options['id'] = Html::cleanId('cb_checkall_table_' . $param['rand']);
             echo "\t\t<td class='center'>" . Html::getCheckbox($cb_options) . "</td>\n";
         }
         echo "\t</tr>\n";
     }
     echo "</table>\n";
     return $param['rand'];
 }
 /**
  * Form to add a solution to an ITIL object
  *
  * @param $knowbase_id_toload integer  load a kb article as solution (0 = no load by default)
  *                                     (default 0)
  **/
 function showSolutionForm($knowbase_id_toload = 0)
 {
     global $CFG_GLPI;
     $this->check($this->getField('id'), READ);
     $canedit = $this->canSolve();
     $options = array();
     if ($knowbase_id_toload > 0) {
         $kb = new KnowbaseItem();
         if ($kb->getFromDB($knowbase_id_toload)) {
             $this->fields['solution'] = $kb->getField('answer');
         }
     }
     // Alert if validation waiting
     $validationtype = $this->getType() . 'Validation';
     if (method_exists($validationtype, 'alertValidation')) {
         $validationtype::alertValidation($this, 'solution');
     }
     $this->showFormHeader($options);
     $show_template = $canedit;
     //                        && $this->getField('solutiontypes_id') == 0
     //                        && empty($this->fields['solution']);
     $rand_template = mt_rand();
     $rand_text = $rand_type = 0;
     if ($canedit) {
         $rand_text = mt_rand();
         $rand_type = mt_rand();
     }
     if ($show_template) {
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . _n('Solution template', 'Solution templates', 1) . "</td><td>";
         SolutionTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type))));
         echo "</td><td colspan='2'>";
         if (Session::haveRightsOr('knowbase', array(READ, KnowbaseItem::READFAQ))) {
             echo "<a class='vsubmit' title=\"" . __s('Search a solution') . "\"\n                   href='" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.php?item_itemtype=" . $this->getType() . "&amp;item_items_id=" . $this->getField('id') . "&amp;forcetab=Knowbase\$1'>" . __('Search a solution') . "</a>";
         }
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Solution type') . "</td><td>";
     $current = $this->fields['status'];
     // Settings a solution will set status to solved
     if ($canedit) {
         SolutionType::dropdown(array('value' => $this->getField('solutiontypes_id'), 'rand' => $rand_type, 'entity' => $this->getEntityID()));
     } else {
         echo Dropdown::getDropdownName('glpi_solutiontypes', $this->getField('solutiontypes_id'));
     }
     echo "</td><td colspan='2'>&nbsp;</td></tr>";
     if ($canedit && Session::haveRight('knowbase', UPDATE)) {
         echo "<tr class='tab_bg_2'><td>" . __('Save and add to the knowledge base') . "</td><td>";
         Dropdown::showYesNo('_sol_to_kb', false);
         echo "</td><td colspan='2'>&nbsp;</td></tr>";
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Description') . "</td><td colspan='3'>";
     if ($canedit) {
         $rand = mt_rand();
         Html::initEditorSystem("solution{$rand}");
         echo "<div id='solution{$rand_text}'>";
         echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80' class='form-control'>" . $this->getField('solution') . "</textarea></div>";
     } else {
         echo Toolbox::unclean_cross_side_scripting_deep($this->getField('solution'));
     }
     echo "</td></tr>";
     $options['candel'] = false;
     $options['canedit'] = $canedit;
     $this->showFormButtons($options);
 }
Ejemplo n.º 23
0
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkCentralAccess();
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
try {
    $ma = new MassiveAction($_POST, $_GET, 'process');
} catch (Exception $e) {
    Html::popHeader(__('Bulk modification error'), $_SERVER['PHP_SELF']);
    echo "<div class='center'><img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='" . __s('Warning') . "'><br><br>";
    echo "<span class='b'>" . $e->getMessage() . "</span><br>";
    Html::displayBackLink();
    echo "</div>";
    Html::popFooter();
    exit;
}
Html::popHeader(__('Bulk modification'), $_SERVER['PHP_SELF']);
$results = $ma->process();
$nbok = $results['ok'];
$nbko = $results['ko'];
$nbnoright = $results['noright'];
if ($nbok == 0) {
    $message = __('Failed operation');
} else {
    if ($nbnoright || $nbko) {
Ejemplo n.º 24
0
 /**
  * Get links for an enterprise (website / edit)
  *
  * @param $withname boolean : also display name ? (false by default)
  **/
 function getLinks($withname = false)
 {
     global $CFG_GLPI;
     $ret = '&nbsp;&nbsp;&nbsp;&nbsp;';
     if ($withname) {
         $ret .= $this->fields["name"];
         $ret .= "&nbsp;&nbsp;";
     }
     if (!empty($this->fields['website'])) {
         $ret .= "<a href='" . formatOutputWebLink($this->fields['website']) . "' target='_blank'>\n                  <img src='" . $CFG_GLPI["root_doc"] . "/pics/web.png' class='middle' alt=\"" . __s('Web') . "\" title=\"" . __s('Web') . "\"></a>&nbsp;&nbsp;";
     }
     if ($this->can($this->fields['id'], 'r')) {
         $ret .= "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id=" . $this->fields['id'] . "'>\n                  <img src='" . $CFG_GLPI["root_doc"] . "/pics/edit.png' class='middle' alt=\"" . __s('Update') . "\" title=\"" . __s('Update') . "\"></a>";
     }
     return $ret;
 }
Ejemplo n.º 25
0
 static function getTypeName($nb = 0)
 {
     global $LANG;
     return __s('Size', 'simcard');
 }
Ejemplo n.º 26
0
 /**
  *  Cron process to check DB replicate state
  *
  * @param $task to log and get param
  **/
 static function cronCheckDBreplicate($task)
 {
     global $DB;
     //Lauch cron only is :
     // 1 the master database is avalaible
     // 2 the slave database is configurated
     if (!$DB->isSlave() && self::isDBSlaveActive()) {
         $DBslave = self::getDBSlaveConf();
         if (is_array($DBslave->dbhost)) {
             $hosts = $DBslave->dbhost;
         } else {
             $hosts = array($DBslave->dbhost);
         }
         foreach ($hosts as $num => $name) {
             $diff = self::getReplicateDelay($num);
             // Quite strange, but allow simple stat
             $task->addVolume($diff);
             if ($diff > 1000000000) {
                 // very large means slave is disconnect
                 $task->log(sprintf(__s("Mysql server: %s can't connect to the database"), $name));
             } else {
                 //TRANS: %1$s is the server name, %2$s is the time
                 $task->log(sprintf(__('Mysql server: %1$s, difference between master and slave: %2$s'), $name, Html::timestampToString($diff, true)));
             }
             if ($diff > $task->fields['param'] * 60) {
                 //Raise event if replicate is not synchronized
                 $options = array('diff' => $diff, 'name' => $name, 'entities_id' => 0);
                 // entity to avoid warning in getReplyTo
                 NotificationEvent::raiseEvent('desynchronization', new self(), $options);
             }
         }
         return 1;
     }
     return 0;
 }
Ejemplo n.º 27
0
 function showForm($ID, $options = array())
 {
     if (!self::canView()) {
         return false;
     }
     $r = new self();
     if ($r->getFromDB($ID)) {
         $type = $r->fields["itemtype"];
         $name = NOT_AVAILABLE;
         if ($item = getItemForItemtype($r->fields["itemtype"])) {
             $type = $item->getTypeName();
             if ($item->getFromDB($r->fields["items_id"])) {
                 $name = $item->getName();
             }
         }
         echo "<div class='center'><form method='post' name=form action='" . $this->getFormURL() . "'>";
         echo "<input type='hidden' name='id' value='{$ID}'>";
         echo "<table class='tab_cadre'>";
         echo "<tr><th colspan='2'>" . __s('Modify the comment') . "</th></tr>";
         // Ajouter le nom du materiel
         echo "<tr class='tab_bg_1'><td>" . __('Item') . "</td>";
         echo "<td class='b'>" . sprintf(__('%1$s - %2$s'), $type, $name) . "</td></tr>\n";
         echo "<tr class='tab_bg_1'><td>" . __('Comments') . "</td>";
         echo "<td><textarea name='comment' cols='30' rows='10' >" . $r->fields["comment"];
         echo "</textarea></td></tr>\n";
         echo "<tr class='tab_bg_2'><td colspan='2' class='top center'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         return true;
     }
     return false;
 }
Ejemplo n.º 28
0
 /**
  * Get the group of elements regarding given item.
  * Two kind of item :
  *              - Device* feed by a link to the attached item (Computer, Printer ...)
  *              - Computer, Printer ...: feed by the "global" properties of the CommonDevice
  * Then feed with the specificities of the Item_Device elements
  * In cas of $item is an instance, then $options contains the type of the item (Computer,
  * Printer ...).
  *
  * @param $item
  * @param $table
  * @param $options            array
  * @param $delete_all_column          (default NULL)
  * @param $common_column
  * @param $specific_column
  * @param $delete_column               (default NULL)
  * @param $dynamic_column
  **/
 function getTableGroup(CommonDBTM $item, HTMLTableMain $table, array $options, HTMLTableSuperHeader $delete_all_column = NULL, HTMLTableSuperHeader $common_column, HTMLTableSuperHeader $specific_column, HTMLTableSuperHeader $delete_column = NULL, $dynamic_column)
 {
     global $DB;
     $is_device = $item instanceof CommonDevice;
     if ($is_device) {
         $peer_type = $options['itemtype'];
         if (empty($peer_type)) {
             $column_label = __('Dissociated devices');
             $group_name = 'None';
         } else {
             $column_label = $peer_type::getTypeName(Session::getPluralNumber());
             $group_name = $peer_type;
         }
         $table_group = $table->createGroup($group_name, '');
         $peer_column = $table_group->addHeader('item', $column_label, $common_column, NULL);
         if (!empty($peer_type)) {
             //TRANS : %1$s is the type of the device
             //        %2$s is the type of the item
             //        %3$s is the name of the item (used for headings of a list),
             $itemtype_nav_title = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
             $peer_column->setItemType($peer_type, $itemtype_nav_title);
         }
     } else {
         $peer_type = $this->getDeviceType();
         $table_group = $table->createGroup($peer_type, '');
         //TRANS : %1$s is the type of the device
         //        %2$s is the type of the item
         //        %3$s is the name of the item (used for headings of a list),
         $options['itemtype_title'] = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
         $peer_type::getHTMLTableHeader($item->getType(), $table_group, $common_column, NULL, $options);
     }
     $specificity_columns = array();
     $link_column = $table_group->addHeader('spec_link', '', $specific_column);
     $spec_column = $link_column;
     foreach ($this->getSpecificities() as $field => $attributs) {
         $spec_column = $table_group->addHeader('spec_' . $field, $attributs['long name'], $specific_column, $spec_column);
         $specificity_columns[$field] = $spec_column;
     }
     $infocom_column = $table_group->addHeader('infocom', Infocom::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
     $document_column = $table_group->addHeader('document', Document::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
     if ($item->isDynamic()) {
         $dynamics_column = $table_group->addHeader('one', '&nbsp;', $dynamic_column, $spec_column);
         $previous_column = $dynamics_column;
     } else {
         $previous_column = $spec_column;
     }
     if ($options['canedit']) {
         $group_checkbox_tag = empty($peer_type) ? '__' : $peer_type;
         $content = Html::getCheckbox(array('criterion' => array('tag_for_massive' => $group_checkbox_tag)));
         $delete_one = $table_group->addHeader('one', $content, $delete_column, $previous_column);
     }
     if ($is_device) {
         $fk = 'items_id';
         // Entity restrict
         $leftjoin = '';
         $where = "";
         if (!empty($peer_type)) {
             $leftjoin = "LEFT JOIN `" . getTableForItemType($peer_type) . "`\n                        ON (`" . $this->getTable() . "`.`items_id` = `" . getTableForItemType($peer_type) . "`.`id`\n                            AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}')";
             $where = getEntitiesRestrictRequest(" AND", getTableForItemType($peer_type));
         }
         $query = "SELECT `" . $this->getTable() . "`.*\n                   FROM `" . $this->getTable() . "`\n                   {$leftjoin}\n                   WHERE `" . $this->getDeviceForeignKey() . "` = '" . $item->getID() . "'\n                         AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}'\n                         AND `" . $this->getTable() . "`.`is_deleted` = '0'\n                         {$where}\n                   ORDER BY `" . $this->getTable() . "`.`itemtype`, `" . $this->getTable() . "`.`{$fk}`";
     } else {
         $fk = $this->getDeviceForeignKey();
         $query = "SELECT *\n                   FROM `" . $this->getTable() . "`\n                   WHERE `itemtype` = '" . $item->getType() . "'\n                         AND `items_id` = '" . $item->getID() . "'\n                         AND `is_deleted` = '0'\n                   ORDER BY {$fk}";
     }
     if (!empty($peer_type)) {
         $peer = new $peer_type();
         $peer->getEmpty();
     } else {
         $peer = NULL;
     }
     foreach ($DB->request($query) as $link) {
         Session::addToNavigateListItems(static::getType(), $link["id"]);
         $this->getFromDB($link['id']);
         if (is_null($peer) || $link[$fk] != $peer->getID()) {
             if ($peer instanceof CommonDBTM) {
                 $peer->getFromDB($link[$fk]);
             }
             $current_row = $table_group->createRow();
             $peer_group = $peer_type . '_' . $link[$fk] . '_' . mt_rand();
             $current_row->setHTMLID($peer_group);
             if ($options['canedit']) {
                 $cell_value = Html::getCheckAllAsCheckbox($peer_group);
                 $current_row->addCell($delete_all_column, $cell_value);
             }
             if ($is_device) {
                 $cell = $current_row->addCell($peer_column, $peer ? $peer->getLink() : __('None'), NULL, $peer);
                 if (is_null($peer)) {
                     $cell->setHTMLClass('center');
                 }
             } else {
                 $peer->getHTMLTableCellForItem($current_row, $item, NULL, $options);
             }
         }
         if (Session::haveRight('device', UPDATE)) {
             $mode = __s('Update');
         } else {
             $mode = __s('View');
         }
         $spec_cell = $current_row->addCell($link_column, "<a href='" . $this->getLinkURL() . "'>{$mode}</a>");
         foreach ($this->getSpecificities() as $field => $attributs) {
             if (!empty($link[$field])) {
                 $content = $link[$field];
             } else {
                 $content = '';
             }
             $spec_cell = $current_row->addCell($specificity_columns[$field], $content, $spec_cell);
         }
         if (countElementsInTable('glpi_infocoms', "`itemtype`='" . $this->getType() . "' AND\n                                                    `items_id`='" . $link['id'] . "'")) {
             $content = array(array('function' => 'Infocom::showDisplayLink', 'parameters' => array($this->getType(), $link['id'])));
         } else {
             $content = '';
         }
         $current_row->addCell($infocom_column, $content, $spec_cell);
         $content = array();
         // The order is to be sure that specific documents appear first
         $query = "SELECT `documents_id`\n                   FROM `glpi_documents_items`\n                   WHERE (`itemtype` = '" . $this->getType() . "' AND `items_id` = '" . $link['id'] . "')\n                          OR (`itemtype` = '" . $this->getDeviceType() . "'\n                              AND `items_id` = '" . $link[$this->getDeviceForeignKey()] . "')\n                   ORDER BY `itemtype` = '" . $this->getDeviceType() . "'";
         $document = new Document();
         foreach ($DB->request($query) as $document_link) {
             if ($document->can($document_link['documents_id'], READ)) {
                 $content[] = $document->getLink();
             }
         }
         $content = implode('<br>', $content);
         $current_row->addCell($document_column, $content, $spec_cell);
         if ($item->isDynamic()) {
             $previous_cell = $current_row->addCell($dynamics_column, Dropdown::getYesNo($link['is_dynamic']), $spec_cell);
         } else {
             $previous_cell = $spec_cell;
         }
         if ($options['canedit']) {
             $cell_value = Html::getMassiveActionCheckBox($this->getType(), $link['id'], array('massive_tags' => $group_checkbox_tag));
             $current_row->addCell($delete_one, $cell_value, $previous_cell);
         }
     }
 }
 /**
  * @since version 0.84
  *
  * @warning note the difference between getHTMLTableCellForItem and getHTMLTableCellsForItem
  *
  * @param $row                HTMLTableRow object
  * @param $item               CommonDBTM object (default NULL)
  * @param $father             HTMLTableCell object (default NULL)
  * @param $options   array
  **/
 function getHTMLTableCellForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     global $CFG_GLPI;
     $this_type = $this->getType();
     if (isset($options['dont_display'][$this_type])) {
         return $father;
     }
     if (static::canView()) {
         $content = $this->getLink();
     } else {
         $content = $this->getName();
     }
     if ($options['canedit']) {
         $field_name = 'quantity_' . $this->getType() . '_' . $this->getID();
         $content .= "&nbsp;<img title='" . __s('Add') . "' alt='" . __s('Add') . "'\n                      onClick=\"" . Html::jsShow($field_name) . "\"\n                      class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         $content .= "<span id='{$field_name}' style='display:none'><br>";
         $content .= __('Add') . "&nbsp;";
         $content = array($content, array('function' => 'Dropdown::showInteger', 'parameters' => array($field_name, 0, 0, 10)), "</span>");
     }
     $linktype = static::getItem_DeviceType();
     if (in_array($item->getType(), $linktype::itemAffinity())) {
         $cell = $row->addCell($row->getHeaderByName('common', 'device'), $content, $father, $this);
     } else {
         $cell = $father;
     }
     return $cell;
 }
Ejemplo n.º 30
0
 /**
  * Generic Function to display Items
  *
  * @param $itemtype              item type
  * @param $ID                    ID of the SEARCH_OPTION item
  * @param $data            array containing data results
  * @param $num                   item num in the request
  * @param $meta                  is a meta item ? (default 0)
  * @param $addobjectparams array added parameters for union search
  *
  * @return string to print
  **/
 static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array())
 {
     global $CFG_GLPI, $DB;
     $searchopt =& self::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) {
             return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']);
         }
         return self::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     if (count($addobjectparams)) {
         $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     //       if ($meta) {
     //          $NAME = "META_";
     //       }
     if (isset($searchopt[$ID]["table"])) {
         $table = $searchopt[$ID]["table"];
         $field = $searchopt[$ID]["field"];
         $linkfield = $searchopt[$ID]["linkfield"];
         /// TODO try to clean all specific cases using SpecificToDisplay
         switch ($table . '.' . $field) {
             case "glpi_users.name":
                 // USER search case
                 if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                     $out = "";
                     $count_display = 0;
                     $added = array();
                     $showuserlink = 0;
                     if (Session::haveRight('user', READ)) {
                         $showuserlink = 1;
                     }
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0 || isset($data[$num][$k][2]) && $data[$num][$k][2] != '') {
                             if ($count_display) {
                                 $out .= self::LBBR;
                             }
                             if ($itemtype == 'Ticket') {
                                 if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0) {
                                     $userdata = getUserName($data[$num][$k]['name'], 2);
                                     $tooltip = "";
                                     if (Session::haveRight('user', READ)) {
                                         $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                                     }
                                     $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip);
                                     $count_display++;
                                 }
                             } else {
                                 $out .= getUserName($data[$num][$k]['name'], $showuserlink);
                                 $count_display++;
                             }
                             // Manage alternative_email for tickets_users
                             if ($itemtype == 'Ticket' && isset($data[$num][$k][2])) {
                                 $split = explode(self::LONGSEP, $data[$num][$k][2]);
                                 for ($l = 0; $l < count($split); $l++) {
                                     $split2 = explode(" ", $split[$l]);
                                     if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) {
                                         if ($count_display) {
                                             $out .= self::LBBR;
                                         }
                                         $count_display++;
                                         $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>";
                                     }
                                 }
                             }
                         }
                     }
                     return $out;
                 }
                 if ($itemtype != 'User') {
                     $toadd = '';
                     if ($itemtype == 'Ticket' && $data[$num][0]['id'] > 0) {
                         $userdata = getUserName($data[$num][0]['id'], 2);
                         $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                     }
                     $usernameformat = formatUserName($data[$num][0]['id'], $data[$num][0]['name'], $data[$num][0]['realname'], $data[$num][0]['firstname'], 1);
                     return sprintf(__('%1$s %2$s'), $usernameformat, $toadd);
                 }
                 break;
             case "glpi_profiles.name":
                 if ($itemtype == 'User' && $ID == 20) {
                     $out = "";
                     $count_display = 0;
                     $added = array();
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (strlen(trim($data[$num][$k]['name'])) > 0) {
                             $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_entities', $data[$num][$k]['entities_id']));
                             $comp = '';
                             if ($data[$num][$k]['is_recursive']) {
                                 $comp = __('R');
                                 if ($data[$num][$k]['is_dynamic']) {
                                     $comp = sprintf(__('%1$s%2$s'), $comp, ", ");
                                 }
                             }
                             if ($data[$num][$k]['is_dynamic']) {
                                 $comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
                             }
                             if (!empty($comp)) {
                                 $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
                             }
                             if (!in_array($text, $added)) {
                                 if ($count_display) {
                                     $out .= self::LBBR;
                                 }
                                 $count_display++;
                                 $out .= $text;
                                 $added[] = $text;
                             }
                         }
                     }
                     return $out;
                 }
                 break;
             case "glpi_entities.completename":
                 if ($itemtype == 'User') {
                     $out = "";
                     $added = array();
                     $count_display = 0;
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (strlen(trim($data[$num][$k]['name'])) > 0) {
                             $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_profiles', $data[$num][$k]['profiles_id']));
                             $comp = '';
                             if ($data[$num][$k]['is_recursive']) {
                                 $comp = __('R');
                                 if ($data[$num][$k]['is_dynamic']) {
                                     $comp = sprintf(__('%1$s%2$s'), $comp, ", ");
                                 }
                             }
                             if ($data[$num][$k]['is_dynamic']) {
                                 $comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
                             }
                             if (!empty($comp)) {
                                 $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
                             }
                             if (!in_array($text, $added)) {
                                 if ($count_display) {
                                     $out .= self::LBBR;
                                 }
                                 $count_display++;
                                 $out .= $text;
                                 $added[] = $text;
                             }
                         }
                     }
                     return $out;
                 }
                 break;
             case "glpi_documenttypes.icon":
                 if (!empty($data[$num][0]['name'])) {
                     return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>";
                 }
                 return "&nbsp;";
             case "glpi_documents.filename":
                 $doc = new Document();
                 if ($doc->getFromDB($data['id'])) {
                     return $doc->getDownloadLink();
                 }
                 return NOT_AVAILABLE;
             case "glpi_tickets_tickets.tickets_id_1":
                 $out = "";
                 $displayed = array();
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     $linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2'];
                     if ($linkid > 0 && !isset($displayed[$linkid])) {
                         $text = "<a ";
                         $text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">";
                         $text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>";
                         if (count($displayed)) {
                             $out .= self::LBBR;
                         }
                         $displayed[$linkid] = $linkid;
                         $out .= $text;
                     }
                 }
                 return $out;
             case "glpi_problems.id":
                 if ($searchopt[$ID]["datatype"] == 'count') {
                     if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) {
                         if ($itemtype == 'ITILCategory') {
                             $options['criteria'][0]['field'] = 7;
                             $options['criteria'][0]['searchtype'] = 'equals';
                             $options['criteria'][0]['value'] = $data['id'];
                             $options['criteria'][0]['link'] = 'AND';
                         } else {
                             $options['criteria'][0]['field'] = 12;
                             $options['criteria'][0]['searchtype'] = 'equals';
                             $options['criteria'][0]['value'] = 'all';
                             $options['criteria'][0]['link'] = 'AND';
                             $options['metacriteria'][0]['itemtype'] = $itemtype;
                             $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name');
                             $options['metacriteria'][0]['searchtype'] = 'equals';
                             $options['metacriteria'][0]['value'] = $data['id'];
                             $options['metacriteria'][0]['link'] = 'AND';
                         }
                         $options['reset'] = 'reset';
                         $out = "<a id='problem{$itemtype}" . $data['id'] . "' ";
                         $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&amp;') . "\">";
                         $out .= $data[$num][0]['name'] . "</a>";
                         return $out;
                     }
                 }
                 break;
             case "glpi_tickets.id":
                 if ($searchopt[$ID]["datatype"] == 'count') {
                     if ($data[$num][0]['name'] > 0 && Session::haveRight("ticket", Ticket::READALL)) {
                         if ($itemtype == 'User') {
                             // Requester
                             if ($ID == 60) {
                                 $options['criteria'][0]['field'] = 4;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             }
                             // Writer
                             if ($ID == 61) {
                                 $options['criteria'][0]['field'] = 22;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             }
                             // Assign
                             if ($ID == 64) {
                                 $options['criteria'][0]['field'] = 5;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             }
                         } else {
                             if ($itemtype == 'ITILCategory') {
                                 $options['criteria'][0]['field'] = 7;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             } else {
                                 $options['criteria'][0]['field'] = 12;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = 'all';
                                 $options['criteria'][0]['link'] = 'AND';
                                 $options['metacriteria'][0]['itemtype'] = $itemtype;
                                 $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name');
                                 $options['metacriteria'][0]['searchtype'] = 'equals';
                                 $options['metacriteria'][0]['value'] = $data['id'];
                                 $options['metacriteria'][0]['link'] = 'AND';
                             }
                         }
                         $options['reset'] = 'reset';
                         $out = "<a id='ticket{$itemtype}" . $data['id'] . "' ";
                         $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&amp;') . "\">";
                         $out .= $data[$num][0]['name'] . "</a>";
                         return $out;
                     }
                 }
                 break;
             case "glpi_tickets.due_date":
             case "glpi_problems.due_date":
             case "glpi_changes.due_date":
                 // Due date + progress
                 if ($ID == 151) {
                     $out = Html::convDate($data[$num][0]['name']);
                     // No due date in waiting status
                     if ($data[$num][0]['status'] == CommonITILObject::WAITING) {
                         return '';
                     }
                     if (empty($data[$num][0]['name'])) {
                         return '';
                     }
                     if ($data[$num][0]['status'] == Ticket::SOLVED || $data[$num][0]['status'] == Ticket::CLOSED) {
                         return $out;
                     }
                     $itemtype = getItemTypeForTable($table);
                     $item = new $itemtype();
                     $item->getFromDB($data['id']);
                     $percentage = 0;
                     $totaltime = 0;
                     $currenttime = 0;
                     if ($item->isField('slas_id') && $item->fields['slas_id'] != 0) {
                         // Have SLA
                         $sla = new SLA();
                         $sla->getFromDB($item->fields['slas_id']);
                         $currenttime = $sla->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s'));
                         $totaltime = $sla->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']);
                     } else {
                         $calendars_id = Entity::getUsedConfig('calendars_id', $item->fields['entities_id']);
                         if ($calendars_id != 0) {
                             // Ticket entity have calendar
                             $calendar = new Calendar();
                             $calendar->getFromDB($calendars_id);
                             $currenttime = $calendar->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s'));
                             $totaltime = $calendar->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']);
                         } else {
                             // No calendar
                             $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($item->fields['date']);
                             $totaltime = strtotime($data[$num][0]['name']) - strtotime($item->fields['date']);
                         }
                     }
                     if ($totaltime != 0) {
                         $percentage = round(100 * $currenttime / $totaltime);
                     } else {
                         // Total time is null : no active time
                         $percentage = 100;
                     }
                     if ($percentage > 100) {
                         $percentage = 100;
                     }
                     $percentage_text = $percentage;
                     if ($_SESSION['glpiduedatewarning_unit'] == '%') {
                         $less_warn_limit = $_SESSION['glpiduedatewarning_less'];
                         $less_warn = 100 - $percentage;
                     } else {
                         if ($_SESSION['glpiduedatewarning_unit'] == 'hour') {
                             $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * HOUR_TIMESTAMP;
                             $less_warn = $totaltime - $currenttime;
                         } else {
                             if ($_SESSION['glpiduedatewarning_unit'] == 'day') {
                                 $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * DAY_TIMESTAMP;
                                 $less_warn = $totaltime - $currenttime;
                             }
                         }
                     }
                     if ($_SESSION['glpiduedatecritical_unit'] == '%') {
                         $less_crit_limit = $_SESSION['glpiduedatecritical_less'];
                         $less_crit = 100 - $percentage;
                     } else {
                         if ($_SESSION['glpiduedatecritical_unit'] == 'hour') {
                             $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * HOUR_TIMESTAMP;
                             $less_crit = $totaltime - $currenttime;
                         } else {
                             if ($_SESSION['glpiduedatecritical_unit'] == 'day') {
                                 $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * DAY_TIMESTAMP;
                                 $less_crit = $totaltime - $currenttime;
                             }
                         }
                     }
                     $color = $_SESSION['glpiduedateok_color'];
                     if ($less_crit < $less_crit_limit) {
                         $color = $_SESSION['glpiduedatecritical_color'];
                     } else {
                         if ($less_warn < $less_warn_limit) {
                             $color = $_SESSION['glpiduedatewarning_color'];
                         }
                     }
                     //Calculate bar progress
                     $out .= "<div class='center' style='background-color: #ffffff; width: 100%;\n                            border: 1px solid #9BA563; position: relative;' >";
                     $out .= "<div style='position:absolute;'>&nbsp;" . $percentage_text . "%</div>";
                     $out .= "<div class='center' style='background-color: " . $color . ";\n                            width: " . $percentage . "%; height: 12px' ></div>";
                     $out .= "</div>";
                     return $out;
                 }
                 break;
             case "glpi_softwarelicenses.number":
                 if ($data[$num][0]['min'] == -1) {
                     return __('Unlimited');
                 }
                 if (empty($data[$num][0]['name'])) {
                     return 0;
                 }
                 return $data[$num][0]['name'];
             case "glpi_auth_tables.name":
                 return Auth::getMethodName($data[$num][0]['name'], $data[$num][0]['auths_id'], 1, $data[$num][0]['ldapname'] . $data[$num][0]['mailname']);
             case "glpi_reservationitems.comment":
                 if (empty($data[$num][0]['name'])) {
                     return "<a title=\"" . __s('Modify the comment') . "\"\n                           href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>";
                 }
                 return "<a title=\"" . __s('Modify the comment') . "\"\n                        href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$num][0]['name']) . "</a>";
             case 'glpi_crontasks.description':
                 $tmp = new CronTask();
                 return $tmp->getDescription($data[$num][0]['name']);
             case 'glpi_changes.status':
                 $status = Change::getStatus($data[$num][0]['name']);
                 return "<img src=\"" . Change::getStatusIconURL($data[$num][0]['name']) . "\"\n                        alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
             case 'glpi_problems.status':
                 $status = Problem::getStatus($data[$num][0]['name']);
                 return "<img src=\"" . Problem::getStatusIconURL($data[$num][0]['name']) . "\"\n                        alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
             case 'glpi_tickets.status':
                 $status = Ticket::getStatus($data[$num][0]['name']);
                 return "<img src=\"" . Ticket::getStatusIconURL($data[$num][0]['name']) . "\"\n                        alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
             case 'glpi_projectstates.name':
                 $out = '';
                 $query = "SELECT `color`\n                         FROM `glpi_projectstates`\n                         WHERE `name` = '" . $data[$num][0]['name'] . "'";
                 foreach ($DB->request($query) as $color) {
                     $color = $color['color'];
                     $out = "<div style=\"background-color:" . $color . ";\">";
                     $name = $data[$num][0]['name'];
                     if (isset($data[$num][0]['trans'])) {
                         $name = $data[$num][0]['trans'];
                     }
                     if ($itemtype == 'ProjectState') {
                         $out .= "<a href='" . $CFG_GLPI["root_doc"] . "/front/projectstate.form.php?id=" . $data[$num][0]["id"] . "'>" . $name . "</a></div>";
                     } else {
                         $out .= $name . "</div>";
                     }
                 }
                 return $out;
             case 'glpi_items_tickets.items_id':
             case 'glpi_items_problems.items_id':
                 if (!empty($data[$num])) {
                     $items = array();
                     foreach ($data[$num] as $key => $val) {
                         if (is_numeric($key)) {
                             if (!empty($val['itemtype']) && ($item = getItemForItemtype($val['itemtype']))) {
                                 if ($item->getFromDB($val['name'])) {
                                     $items[] = $item->getLink(array('comments' => true));
                                 }
                             }
                         }
                     }
                     if (!empty($items)) {
                         return implode("<br>", $items);
                     }
                 }
                 return '&nbsp;';
             case 'glpi_items_tickets.itemtype':
             case 'glpi_items_problems.itemtype':
                 if (!empty($data[$num])) {
                     $itemtypes = array();
                     foreach ($data[$num] as $key => $val) {
                         if (is_numeric($key)) {
                             if (!empty($val['name'])) {
                                 if (substr($val['name'], 0, 6) == 'Plugin') {
                                     $plug = new $val['name']();
                                     $name = $plug->getTypeName();
                                     $itemtypes[] = __($name);
                                 } else {
                                     $itemtypes[] = __($val['name']);
                                 }
                             }
                         }
                     }
                     if (!empty($itemtypes)) {
                         return implode("<br>", $itemtypes);
                     }
                 }
                 return '&nbsp;';
             case 'glpi_tickets.name':
             case 'glpi_problems.name':
             case 'glpi_changes.name':
                 if (isset($data[$num][0]['content']) && isset($data[$num][0]['id']) && isset($data[$num][0]['status'])) {
                     $link = Toolbox::getItemTypeFormURL($itemtype);
                     $out = "<a id='{$itemtype}" . $data[$num][0]['id'] . "' href=\"" . $link;
                     $out .= strstr($link, '?') ? '&amp;' : '?';
                     $out .= 'id=' . $data[$num][0]['id'];
                     // Force solution tab if solved
                     if ($item = getItemForItemtype($itemtype)) {
                         if (in_array($data[$num][0]['status'], $item->getSolvedStatusArray())) {
                             $out .= "&amp;forcetab={$itemtype}\$2";
                         }
                     }
                     $out .= "\">";
                     $name = $data[$num][0]['name'];
                     if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) {
                         $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][0]['id']);
                     }
                     $out .= $name . "</a>";
                     $hdecode = Html::entity_decode_deep($data[$num][0]['content']);
                     $content = Toolbox::unclean_cross_side_scripting_deep($hdecode);
                     $out = sprintf(__('%1$s %2$s'), $out, Html::showToolTip(nl2br(Html::Clean($content)), array('applyto' => $itemtype . $data[$num][0]['id'], 'display' => false)));
                     return $out;
                 }
             case 'glpi_ticketvalidations.status':
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if ($data[$num][$k]['name']) {
                         $status = TicketValidation::getStatus($data[$num][$k]['name']);
                         $bgcolor = TicketValidation::getStatusColor($data[$num][$k]['name']);
                         $out .= (empty($out) ? '' : self::LBBR) . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>';
                     }
                 }
                 return $out;
             case 'glpi_ticketsatisfactions.satisfaction':
                 if (self::$output_type == self::HTML_OUTPUT) {
                     return TicketSatisfaction::displaySatisfaction($data[$num][0]['name']);
                 }
                 break;
             case 'glpi_projects._virtual_planned_duration':
                 return Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($data["id"]), false);
             case 'glpi_projects._virtual_effective_duration':
                 return Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($data["id"]), false);
             case 'glpi_cartridgeitems._virtual':
                 return Cartridge::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT);
             case 'glpi_printers._virtual':
                 return Cartridge::getCountForPrinter($data["id"], self::$output_type != self::HTML_OUTPUT);
             case 'glpi_consumableitems._virtual':
                 return Consumable::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT);
             case 'glpi_links._virtual':
                 $out = '';
                 $link = new Link();
                 if (($item = getItemForItemtype($itemtype)) && $item->getFromDB($data['id']) && $link->getfromDB($data[$num][0]['id']) && $item->fields['entities_id'] == $link->fields['entities_id']) {
                     if (count($data[$num])) {
                         $count_display = 0;
                         foreach ($data[$num] as $val) {
                             if (is_array($val)) {
                                 $links = Link::getAllLinksFor($item, $val);
                                 foreach ($links as $link) {
                                     if ($count_display) {
                                         $out .= self::LBBR;
                                     }
                                     $out .= $link;
                                     $count_display++;
                                 }
                             }
                         }
                     }
                 }
                 return $out;
             case 'glpi_reservationitems._virtual':
                 if ($data[$num][0]['is_active']) {
                     return "<a href='reservation.php?reservationitems_id=" . $data["refID"] . "' title=\"" . __s('See planning') . "\">" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''></a>";
                 } else {
                     return "&nbsp;";
                 }
         }
     }
     //// Default case
     // Link with plugin tables : need to know left join structure
     if (isset($table)) {
         if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
             if (count($matches) == 2) {
                 $plug = $matches[1];
                 $function = 'plugin_' . $plug . '_giveItem';
                 if (function_exists($function)) {
                     $out = $function($itemtype, $ID, $data, $num);
                     if (!empty($out)) {
                         return $out;
                     }
                 }
             }
         }
     }
     $unit = '';
     if (isset($searchopt[$ID]['unit'])) {
         $unit = $searchopt[$ID]['unit'];
     }
     // Preformat items
     if (isset($searchopt[$ID]["datatype"])) {
         switch ($searchopt[$ID]["datatype"]) {
             case "itemlink":
                 $linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]);
                 $out = "";
                 $count_display = 0;
                 $separate = self::LBBR;
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = self::LBHR;
                 }
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (isset($data[$num][$k]['id'])) {
                         if ($count_display) {
                             $out .= $separate;
                         }
                         $count_display++;
                         $page = $linkitemtype::getFormUrl();
                         $page .= strpos($page, '?') ? '&id' : '?id';
                         $name = Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit);
                         if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][$k]['name'])) {
                             $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][$k]['id']);
                         }
                         $out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $data[$num][$k]['id'] . "' href='{$page}=" . $data[$num][$k]['id'] . "'>" . $name . "</a>";
                     }
                 }
                 return $out;
             case "text":
                 $separate = self::LBBR;
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = self::LBHR;
                 }
                 $out = '';
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= $separate;
                         }
                         $count_display++;
                         $text = "";
                         if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) {
                             $text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($data[$num][$k]['name'])));
                         } else {
                             $text = nl2br($data[$num][$k]['name']);
                         }
                         if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) {
                             $rand = mt_rand();
                             $out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false)));
                         } else {
                             $out .= $text;
                         }
                     }
                 }
                 return $out;
             case "date":
             case "date_delay":
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) {
                         $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel'];
                     } else {
                         $out .= (empty($out) ? '' : self::LBBR) . Html::convDate($data[$num][$k]['name']);
                     }
                 }
                 return $out;
             case "datetime":
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) {
                         $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel'];
                     } else {
                         $out .= (empty($out) ? '' : self::LBBR) . Html::convDateTime($data[$num][$k]['name']);
                     }
                 }
                 return $out;
             case "timestamp":
                 $withseconds = false;
                 if (isset($searchopt[$ID]['withseconds'])) {
                     $withseconds = $searchopt[$ID]['withseconds'];
                 }
                 $withdays = true;
                 if (isset($searchopt[$ID]['withdays'])) {
                     $withdays = $searchopt[$ID]['withdays'];
                 }
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     $out .= (empty($out) ? '' : '<br>') . Html::timestampToString($data[$num][$k]['name'], $withseconds, $withdays);
                 }
                 return $out;
             case "email":
                 $out = '';
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if ($count_display) {
                         $out .= self::LBBR;
                     }
                     $count_display++;
                     if (!empty($data[$num][$k]['name'])) {
                         $out .= empty($out) ? '' : self::LBBR;
                         $out .= "<a href='mailto:" . $data[$num][$k]['name'] . "'>" . $data[$num][$k]['name'];
                         $out .= "</a>";
                     }
                 }
                 return empty($out) ? "&nbsp;" : $out;
             case "weblink":
                 $orig_link = trim($data[$num][0]['name']);
                 if (!empty($orig_link)) {
                     // strip begin of link
                     $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link);
                     $link = preg_replace('/\\/$/', '', $link);
                     if (Toolbox::strlen($link) > $CFG_GLPI["url_maxlength"]) {
                         $link = Toolbox::substr($link, 0, $CFG_GLPI["url_maxlength"]) . "...";
                     }
                     return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>";
                 }
                 return "&nbsp;";
             case "count":
             case "number":
                 $out = "";
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= self::LBBR;
                         }
                         $count_display++;
                         if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) {
                             $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']];
                         } else {
                             $number = str_replace(' ', '&nbsp;', Html::formatNumber($data[$num][$k]['name'], false, 0));
                             $out .= Dropdown::getValueWithUnit($number, $unit);
                         }
                     }
                 }
                 return $out;
             case "decimal":
                 $out = "";
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= self::LBBR;
                         }
                         $count_display++;
                         if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) {
                             $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']];
                         } else {
                             $number = str_replace(' ', '&nbsp;', Html::formatNumber($data[$num][$k]['name']));
                             $out .= Dropdown::getValueWithUnit($number, $unit);
                         }
                     }
                 }
                 return $out;
             case "bool":
                 $out = "";
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= self::LBBR;
                         }
                         $count_display++;
                         $out .= Dropdown::getValueWithUnit(Dropdown::getYesNo($data[$num][$k]['name']), $unit);
                     }
                 }
                 return $out;
             case "itemtypename":
                 if ($obj = getItemForItemtype($data[$num][0]['name'])) {
                     return $obj->getTypeName();
                 }
                 return "";
             case "language":
                 if (isset($CFG_GLPI['languages'][$data[$num][0]['name']])) {
                     return $CFG_GLPI['languages'][$data[$num][0]['name']][0];
                 }
                 return __('Default value');
         }
     }
     // Manage items with need group by / group_concat
     $out = "";
     $count_display = 0;
     $separate = self::LBBR;
     if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
         $separate = self::LBHR;
     }
     for ($k = 0; $k < $data[$num]['count']; $k++) {
         if (strlen(trim($data[$num][$k]['name'])) > 0) {
             if ($count_display) {
                 $out .= $separate;
             }
             $count_display++;
             // Get specific display if available
             $itemtype = getItemTypeForTable($table);
             if ($item = getItemForItemtype($itemtype)) {
                 $tmpdata = $data[$num][$k];
                 // Copy name to real field
                 $tmpdata[$field] = $data[$num][$k]['name'];
                 $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true, 'searchopt' => $searchopt[$ID]));
             }
             if (!empty($specific)) {
                 $out .= $specific;
             } else {
                 if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) {
                     $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']];
                 } else {
                     // Empty is 0 or empty
                     if (empty($split[0]) && isset($searchopt[$ID]['emptylabel'])) {
                         $out .= $searchopt[$ID]['emptylabel'];
                     } else {
                         // Trans field exists
                         if (isset($data[$num][$k]['trans']) && !empty($data[$num][$k]['trans'])) {
                             $out .= Dropdown::getValueWithUnit($data[$num][$k]['trans'], $unit);
                         } else {
                             $out .= Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit);
                         }
                     }
                 }
             }
         }
     }
     return $out;
     // Trans in group concat
     if (count($split) == 3 && !empty($split[1])) {
         return Dropdown::getValueWithUnit($split[1], $unit);
     }
     return Dropdown::getValueWithUnit($split[0], $unit);
 }