/** * Print the config form for default user prefs * * @param $data array containing datas * (CFG_GLPI for global config / glpi_users fields for user prefs) * * @return Nothing (display) **/ function showFormUserPrefs($data = array()) { global $DB, $CFG_GLPI; $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central"; $userpref = false; $url = Toolbox::getItemTypeFormURL(__CLASS__); if (array_key_exists('last_login', $data)) { $userpref = true; if ($data["id"] === Session::getLoginUserID()) { $url = $CFG_GLPI['root_doc'] . "/front/preference.php"; } else { $url = $CFG_GLPI['root_doc'] . "/front/user.form.php"; } } echo "<form name='form' action='{$url}' method='post'>"; // Only set id for user prefs if ($userpref) { echo "<input type='hidden' name='id' value='" . $data['id'] . "'>"; } echo "<div class='center' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('Personalization') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td width='30%'>" . ($userpref ? __('Language') : __('Default language')) . "</td>"; echo "<td width='20%'>"; if (Config::canUpdate() || !GLPI_DEMO_MODE) { Dropdown::showLanguages("language", array('value' => $data["language"])); } else { echo " "; } echo "<td width='30%'>" . __('Date format') . "</td>"; echo "<td width='20%'>"; $date_formats = array(0 => __('YYYY-MM-DD'), 1 => __('DD-MM-YYYY'), 2 => __('MM-DD-YYYY')); Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Results to display by page') . "</td><td>"; // Limit using global config $value = $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max']; Dropdown::showNumber('list_limit', array('value' => $value, 'min' => 5, 'max' => $CFG_GLPI['list_limit_max'], 'step' => 5)); echo "</td>"; echo "<td>" . __('Number format') . "</td>"; $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56', 3 => '1234.56', 4 => '1234,56'); echo "<td>"; Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Display order of surnames firstnames') . "</td><td>"; $values = array(User::REALNAME_BEFORE => __('Surname, First name'), User::FIRSTNAME_BEFORE => __('First name, Surname')); Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"])); echo "</td>"; echo "<td>" . __("Color palette") . "</td><td>"; $themes_files = scandir(GLPI_ROOT . "/css/palettes/"); echo "<select name='palette' id='theme-selector'>"; foreach ($themes_files as $key => $file) { if (strpos($file, ".css") !== false) { $name = substr($file, 0, -4); $selected = ""; if ($data["palette"] == $name) { $selected = "selected='selected'"; } echo "<option value='{$name}' {$selected}>" . ucfirst($name) . "</option>"; } } echo Html::scriptBlock("\n function formatThemes(theme) {\n return \" <img src='../css/palettes/previews/\" + theme.text.toLowerCase() + \".png'/>\"\n + \" \" + theme.text;\n }\n \$(\"#theme-selector\").select2({\n formatResult: formatThemes,\n formatSelection: formatThemes,\n width: '100%',\n escapeMarkup: function(m) { return m; }\n });\n "); echo "</select>"; echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Display the complete name in tree dropdowns') . "</td><td>"; Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } if (!$userpref || $CFG_GLPI['show_count_on_tabs'] != -1) { echo "<td>" . __('Display counts in tabs') . "</td><td>"; $values = array(0 => __('No'), 1 => __('Yes')); if (!$userpref) { $values[-1] = __('Never'); } Dropdown::showFromArray('show_count_on_tabs', $values, array('value' => $data["show_count_on_tabs"])); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . __('Show GLPI ID') . "</td><td>"; Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "<td>" . __('CSV delimiter') . "</td><td>"; $values = array(';' => ';', ',' => ','); Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Notifications for my changes') . "</td><td>"; Dropdown::showYesNo("notification_to_myself", $data["notification_to_myself"]); echo "</td>"; if ($oncentral) { echo "<td>" . __('Results to display on home page') . "</td><td>"; Dropdown::showNumber('display_count_on_home', array('value' => $data['display_count_on_home'], 'min' => 0, 'max' => 30)); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('PDF export font') . "</td><td>"; Dropdown::showFromArray("pdffont", GLPIPDF::getFontList(), array('value' => $data["pdffont"], 'width' => 200)); echo "</td>"; echo "<td>" . __('Keep devices when purging an item') . "</td><td>"; Dropdown::showYesNo('keep_devices_when_purging_item', $data['keep_devices_when_purging_item']); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Go to created item after creation') . "</td>"; echo "<td>"; Dropdown::showYesNo("backcreated", $data["backcreated"]); echo "</td>"; echo "<td>" . __('Layout') . "</td><td>"; $layout_options = array('lefttab' => __("Tabs on left"), 'classic' => __("Classic view"), 'vsplit' => __("Vertical split")); echo "<select name='layout' id='layout-selector'>"; foreach ($layout_options as $key => $name) { $selected = ""; if ($data["layout"] == $key) { $selected = "selected='selected'"; } echo "<option value='{$key}' {$selected}>" . ucfirst($name) . "</option>"; } echo Html::scriptBlock("\n function formatLayout(layout) {\n return \" <img src='../pics/layout_\" + layout.id.toLowerCase() + \".png'/>\"\n + \" \" + layout.text;\n }\n \$(\"#layout-selector\").select2({\n formatResult: formatLayout,\n formatSelection: formatLayout,\n escapeMarkup: function(m) { return m; }\n });\n "); echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'><td>" . __('Enable ticket timeline') . "</td>"; echo "<td>"; Dropdown::showYesNo('ticket_timeline', $data['ticket_timeline']); echo "</td>"; echo "<td>" . __('Keep tabs replaced by the ticket timeline') . "</td><td>"; Dropdown::showYesNo('ticket_timeline_keep_replaced_tabs', $data['ticket_timeline_keep_replaced_tabs']); echo "</td></tr>"; if ($oncentral) { echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Assistance') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Private followups by default') . "</td><td>"; Dropdown::showYesNo("followup_private", $data["followup_private"]); echo "</td><td>" . __('Show new tickets on the home page') . "</td><td>"; if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN))) { Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]); } else { echo Dropdown::getYesNo(0); } echo " </td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Private tasks by default') . "</td><td>"; Dropdown::showYesNo("task_private", $data["task_private"]); echo "</td><td> " . __('Request sources by default') . "</td><td>"; RequestType::dropdown(array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id")); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Tasks state by default') . "</td><td>"; Planning::dropdownState("task_state", $data["task_state"]); echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Pre-select me as a technician when creating a ticket') . "</td><td>"; if (!$userpref || Session::haveRight('ticket', Ticket::OWN)) { Dropdown::showYesNo("set_default_tech", $data["set_default_tech"]); } else { echo Dropdown::getYesNo(0); } echo "</td><td>" . __('Automatically refresh the list of tickets (minutes)') . "</td><td>"; Dropdown::showNumber('refresh_ticket_list', array('value' => $data["refresh_ticket_list"], 'min' => 1, 'max' => 30, 'step' => 1, 'toadd' => array(0 => __('Never')))); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Priority colors') . "</td>"; echo "<td colspan='3'>"; echo "<table><tr>"; echo "<td>1 "; Html::showColorField('priority_1', array('value' => $data["priority_1"])); echo "</td>"; echo "<td>2 "; Html::showColorField('priority_2', array('value' => $data["priority_2"])); echo "</td>"; echo "<td>3 "; Html::showColorField('priority_3', array('value' => $data["priority_3"])); echo "</td>"; echo "<td>4 "; Html::showColorField('priority_4', array('value' => $data["priority_4"])); echo "</td>"; echo "<td>5 "; Html::showColorField('priority_5', array('value' => $data["priority_5"])); echo "</td>"; echo "<td>6 "; Html::showColorField('priority_6', array('value' => $data["priority_6"])); echo "</td>"; echo "</tr></table>"; echo "</td></tr>"; } // Only for user if (array_key_exists('personal_token', $data)) { echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Remote access key') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Remote access key'); if (!empty($data["personal_token"])) { //TRANS: %s is the generation date echo "<br>" . sprintf(__('generated on %s'), Html::convDateTime($data["personal_token_date"])); } echo "</td><td colspan='3'>"; echo "<input type='checkbox' name='_reset_personal_token'> " . __('Regenerate'); echo "</td></tr>"; } echo "<tr><th colspan='4'>" . __('Due date progression') . "</th></tr>"; echo "<tr class='tab_bg_1'>" . "<td>" . __('OK state color') . "</td>"; echo "<td>"; Html::showColorField('duedateok_color', array('value' => $data["duedateok_color"])); echo "</td><td colspan='2'> </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Warning state color') . "</td>"; echo "<td>"; Html::showColorField('duedatewarning_color', array('value' => $data["duedatewarning_color"])); echo "</td>"; echo "<td>" . __('Warning state threshold') . "</td>"; echo "<td>"; Dropdown::showNumber("duedatewarning_less", array('value' => $data['duedatewarning_less'])); $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber())); echo " "; Dropdown::showFromArray("duedatewarning_unit", $elements, array('value' => $data['duedatewarning_unit'])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>" . "<td>" . __('Critical state color') . "</td>"; echo "<td>"; Html::showColorField('duedatecritical_color', array('value' => $data["duedatecritical_color"])); echo "</td>"; echo "<td>" . __('Critical state threshold') . "</td>"; echo "<td>"; Dropdown::showNumber("duedatecritical_less", array('value' => $data['duedatecritical_less'])); echo " "; $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber())); Dropdown::showFromArray("duedatecritical_unit", $elements, array('value' => $data['duedatecritical_unit'])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">"; echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); }