diff --git a/css/itsm2.scss b/css/itsm2.scss index abb85e2019..25d2b212b0 100644 --- a/css/itsm2.scss +++ b/css/itsm2.scss @@ -37,7 +37,7 @@ div#searchbar { border-radius: 20px; background-color: white; padding: 2px 10px; - + input[type="search"] { height: 90%; outline: 0; @@ -158,14 +158,14 @@ main { div.menu-close + & { width: calc(100% - var(--nav-close-width)); margin-left: var(--nav-close-width); - + .menu-right & { margin-right: var(--nav-close-width); } } } - + #menu-border{ position: absolute; z-index: 10; @@ -193,7 +193,7 @@ main { right: 6px; bottom: auto; color: black; - + // >i { // position: static !important; // color: black !important; @@ -229,7 +229,7 @@ main { &.show >i{ rotate: 180deg; } - + >i { font-size: 1.5em; // rotate: 180deg; @@ -241,19 +241,19 @@ main { } .menu-top &, .menu-bubble & { - >i { + >i { rotate: 90deg; } &.show >i{ rotate: 270deg; } - } + } .menu-close & { display: none; } - i { + i { position: relative !important; } .menu-positions { @@ -329,7 +329,7 @@ main { height: var(--_size); width: var(--_size); border-radius: 50%; - + .menu-right & { right: auto; left: -1.2rem; @@ -345,7 +345,7 @@ main { position: relative; left: 5px; transition: transform .3s ease; - + .menu-right & { left: auto; right: 5px; @@ -355,7 +355,7 @@ main { .menu-close & { transform: rotate(180deg); } - + } } @@ -373,7 +373,7 @@ main { i { color: $favorite-color; } - + } #bubble { display: none; @@ -401,7 +401,7 @@ main { border-radius: var(--_border-radius); color: var(--_color); background: linear-gradient(90deg,var(--_background-color) 75%, transparent 75%); - + &::before{ position: relative; right: var(--_uncenter); @@ -437,7 +437,7 @@ main { display: flex; flex-direction: row; justify-content: center; - align-items: center; + align-items: center; } .bubble-icon { --_padding: 18px; @@ -449,7 +449,7 @@ main { background-size: 100000%; border-radius: 30px; } - + .submenu-icon { padding: 18px; color: white !important; @@ -521,7 +521,11 @@ main { } } } - + +.menu-top .nav-side-menu { + height: initial; +} + .nav-side-menu { height: calc(100vh - 3rem - var(--header-height)); position: relative; @@ -533,7 +537,7 @@ main { line-height: 1; overflow-y: hidden; // width: 100%; - + #menu-favorite.hidden{ display: none; } @@ -564,7 +568,7 @@ main { display: none; } } - + i.submenu-icon, i.bubble-icon { --_size: 1.5em; width: var(--_size); @@ -584,7 +588,7 @@ main { flex-direction: column; overflow-y: visible; } - + .menu-right & { justify-content: end; } @@ -626,7 +630,7 @@ main { flex-direction: column; align-items: normal; user-select: none; - + .menu-top &{ flex-direction: row; justify-content: space-evenly; @@ -667,8 +671,8 @@ main { padding: 5px; margin: 0; } - - + + > div { // width: 100%; padding: 5px 10px; @@ -684,7 +688,7 @@ main { background-color: $nav-hover-color; } } - + i { .menu-close & { margin-right: 0px; @@ -710,7 +714,7 @@ main { .menu-top &{ margin: 0; - padding: 5px 2px; + padding: 5px 2px; top: 2.5em; position: absolute; background-color: color-mix(in srgb, rgb(0, 0, 0) 30%, $nav-background-color 70%); @@ -733,7 +737,7 @@ main { border-radius: 5px; // pointer-events: auto; font-size: 12px; - + .menu-close & { padding: 1px 2px; margin: 0 !important; @@ -745,12 +749,12 @@ main { &.active, &:hover{ background-color: $nav-hover-color; } - + .menu-top &{ padding: 5px 2px; } a { - display: flex; + display: flex; align-items: center; // width: 100%; font-size: inherit !important; @@ -762,7 +766,7 @@ main { i { margin-right: 3px; color: $nav-text-color; - + .menu-close & { margin-right: 0px; } @@ -799,7 +803,7 @@ main { content: "\f005"; line-height: 1; } - .favorite-mode & { + .favorite-mode & { pointer-events: auto; &::before { display: inline-block; @@ -819,7 +823,7 @@ main { // } } - #submenu-favorite { + #submenu-favorite { >p{ display: inline; @@ -828,7 +832,7 @@ main { &:not(:only-child) { display: none; } - + } } @@ -854,7 +858,7 @@ main { .nav-side-menu ul ul a li p { font-weight: 400; } - + // .nav-side-menu p:hover { // background-color: transparent; // } @@ -882,7 +886,7 @@ main { border-bottom-left-radius: 20px; } } - + .menu-close & { #main-test:not(.menu-top, .menu-bubble) &{ >ul>:not(#menu-options){ @@ -927,8 +931,8 @@ main { &:hover { text-decoration: none !important; } - } - + } + span { margin: 0; @@ -979,8 +983,8 @@ main { // .copyright-message a { // color: white; // } - -.menu-close .copyright-message { + +.menu-close .copyright-message, .menu-top .copyright-message { display: none; } /* .nav-side-menu li a { @@ -1026,7 +1030,7 @@ main { .dropdown-menu.show { display: block; } - + .dropdown-menu { max-height: 50vh; overflow-x: hidden; @@ -1105,7 +1109,7 @@ div.chip>p { .search { height: 2rem; border-radius: 0; - + input { height: 100%; border: 1px solid $primary-color !important; @@ -1177,7 +1181,7 @@ div.chip>p { filter: invert(1) !important; & * { background-color: black !important; - color: white !important; + color: white !important; } } @@ -1261,4 +1265,4 @@ div.chip>p { #data-selection-widget-modal input[name="search"] { display: none; -} \ No newline at end of file +} diff --git a/inc/config.class.php b/inc/config.class.php index e0183cde60..ea81194b92 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -40,64 +40,64 @@ use Laminas\Cache\Storage\AvailableSpaceCapableInterface; if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access this file directly"); + die("Sorry. You can't access this file directly"); } /** * Config class -**/ + **/ class Config extends CommonDBTM { - const DELETE_ALL = -1; - const KEEP_ALL = 0; + const DELETE_ALL = -1; + const KEEP_ALL = 0; - // From CommonGLPI - protected $displaylist = false; + // From CommonGLPI + protected $displaylist = false; - // From CommonDBTM - public $auto_message_on_action = false; - public $showdebug = true; + // From CommonDBTM + public $auto_message_on_action = false; + public $showdebug = true; - static $rightname = 'config'; + static $rightname = 'config'; - static $undisclosedFields = ['proxy_passwd', 'smtp_passwd']; - static $saferUndisclosedFields = ['admin_email', 'admin_reply']; + static $undisclosedFields = ['proxy_passwd', 'smtp_passwd']; + static $saferUndisclosedFields = ['admin_email', 'admin_reply']; - static function getTypeName($nb = 0) { - return __('Setup'); + static function getTypeName($nb = 0) { + return __('Setup'); } static function getMenuContent() { - $menu = []; - if (static::canView()) { - $menu['title'] = _x('setup', 'General'); - $menu['page'] = Config::getFormURL(false); - $menu['icon'] = Config::getIcon(); + $menu = []; + if (static::canView()) { + $menu['title'] = _x('setup', 'General'); + $menu['page'] = Config::getFormURL(false); + $menu['icon'] = Config::getIcon(); - $menu['options']['apiclient']['title'] = APIClient::getTypeName(Session::getPluralNumber()); - $menu['options']['apiclient']['page'] = Config::getFormURL(false) . '?forcetab=Config$8'; - $menu['options']['apiclient']['links']['search'] = Config::getFormURL(false) . '?forcetab=Config$8'; - $menu['options']['apiclient']['links']['add'] = '/front/apiclient.form.php'; + $menu['options']['apiclient']['title'] = APIClient::getTypeName(Session::getPluralNumber()); + $menu['options']['apiclient']['page'] = Config::getFormURL(false) . '?forcetab=Config$8'; + $menu['options']['apiclient']['links']['search'] = Config::getFormURL(false) . '?forcetab=Config$8'; + $menu['options']['apiclient']['links']['add'] = '/front/apiclient.form.php'; } if (count($menu)) { - return $menu; + return $menu; } return false; } static function canCreate() { - return false; + return false; } function canViewItem() { - if (isset($this->fields['context']) && - ($this->fields['context'] == 'core' || - Plugin::isPluginActive($this->fields['context']))) { - return true; + if (isset($this->fields['context']) && + ($this->fields['context'] == 'core' || + Plugin::isPluginActive($this->fields['context']))) { + return true; } return false; } @@ -105,37 +105,37 @@ function canViewItem() { function defineTabs($options = []) { - $ong = []; - $this->addStandardTab(__CLASS__, $ong, $options); - $this->addStandardTab('Log', $ong, $options); + $ong = []; + $this->addStandardTab(__CLASS__, $ong, $options); + $this->addStandardTab('Log', $ong, $options); - return $ong; + return $ong; } function prepareInputForUpdate($input) { - global $CFG_GLPI; + global $CFG_GLPI; - // Unset _no_history to not save it as a configuration value - unset($input['_no_history']); + // Unset _no_history to not save it as a configuration value + unset($input['_no_history']); - // Update only an item - if (isset($input['context'])) { - return $input; + // Update only an item + if (isset($input['context'])) { + return $input; } // Process configuration for plugins if (!empty($input['config_context'])) { - $config_context = $input['config_context']; - unset($input['id']); - unset($input['_glpi_csrf_token']); - unset($input['update']); - unset($input['config_context']); - if ((!empty($input['config_class'])) - && (class_exists($input['config_class'])) - && (method_exists ($input['config_class'], 'configUpdate'))) { - $config_method = $input['config_class'].'::configUpdate'; - unset($input['config_class']); - $input = call_user_func($config_method, $input); + $config_context = $input['config_context']; + unset($input['id']); + unset($input['_glpi_csrf_token']); + unset($input['update']); + unset($input['config_context']); + if ((!empty($input['config_class'])) + && (class_exists($input['config_class'])) + && (method_exists ($input['config_class'], 'configUpdate'))) { + $config_method = $input['config_class'].'::configUpdate'; + unset($input['config_class']); + $input = call_user_func($config_method, $input); } $this->setConfigurationValues($config_context, $input); return false; @@ -144,74 +144,74 @@ function prepareInputForUpdate($input) { // Trim automatically endig slash for url_base config as, for all existing occurences, // this URL will be prepended to something that starts with a slash. if (isset($input["url_base"]) && !empty($input["url_base"])) { - if (Toolbox::isValidWebUrl($input["url_base"])) { - $input["url_base"] = rtrim($input["url_base"], '/'); + if (Toolbox::isValidWebUrl($input["url_base"])) { + $input["url_base"] = rtrim($input["url_base"], '/'); } else { - Session::addMessageAfterRedirect(__('Invalid base URL!'), false, ERROR); - return false; + Session::addMessageAfterRedirect(__('Invalid base URL!'), false, ERROR); + return false; } } if (isset($input["url_base_api"]) && !empty($input["url_base_api"])) { - if (!Toolbox::isValidWebUrl($input["url_base_api"])) { - Session::addMessageAfterRedirect(__('Invalid API base URL!'), false, ERROR); - return false; + if (!Toolbox::isValidWebUrl($input["url_base_api"])) { + Session::addMessageAfterRedirect(__('Invalid API base URL!'), false, ERROR); + return false; } } if (isset($input['allow_search_view']) && !$input['allow_search_view']) { - // Global search need "view" - $input['allow_search_global'] = 0; + // Global search need "view" + $input['allow_search_global'] = 0; } if (isset($input["smtp_passwd"]) && empty($input["smtp_passwd"])) { - unset($input["smtp_passwd"]); + unset($input["smtp_passwd"]); } if (isset($input["_blank_smtp_passwd"]) && $input["_blank_smtp_passwd"]) { - $input['smtp_passwd'] = ''; + $input['smtp_passwd'] = ''; } if (isset($input["proxy_passwd"]) && empty($input["proxy_passwd"])) { - unset($input["proxy_passwd"]); + unset($input["proxy_passwd"]); } if (isset($input["_blank_proxy_passwd"]) && $input["_blank_proxy_passwd"]) { - $input['proxy_passwd'] = ''; + $input['proxy_passwd'] = ''; } // Manage DB Slave process if (isset($input['_dbslave_status'])) { - $already_active = DBConnection::isDBSlaveActive(); + $already_active = DBConnection::isDBSlaveActive(); - if ($input['_dbslave_status']) { - DBConnection::changeCronTaskStatus(true); + if ($input['_dbslave_status']) { + DBConnection::changeCronTaskStatus(true); - if (!$already_active) { - // Activate Slave from the "system" tab - DBConnection::createDBSlaveConfig(); + if (!$already_active) { + // Activate Slave from the "system" tab + DBConnection::createDBSlaveConfig(); } else if (isset($input["_dbreplicate_dbhost"])) { - // Change parameter from the "replicate" tab - DBConnection::saveDBSlaveConf($input["_dbreplicate_dbhost"], - $input["_dbreplicate_dbuser"], - $input["_dbreplicate_dbpassword"], - $input["_dbreplicate_dbdefault"]); + // Change parameter from the "replicate" tab + DBConnection::saveDBSlaveConf($input["_dbreplicate_dbhost"], + $input["_dbreplicate_dbuser"], + $input["_dbreplicate_dbpassword"], + $input["_dbreplicate_dbdefault"]); } } if (!$input['_dbslave_status'] && $already_active) { - DBConnection::deleteDBSlaveConfig(); - DBConnection::changeCronTaskStatus(false); + DBConnection::deleteDBSlaveConfig(); + DBConnection::changeCronTaskStatus(false); } } // Matrix for Impact / Urgence / Priority if (isset($input['_matrix'])) { - $tab = []; + $tab = []; - for ($urgency=1; $urgency<=5; $urgency++) { - for ($impact=1; $impact<=5; $impact++) { - $priority = $input["_matrix_{$urgency}_{$impact}"]; - $tab[$urgency][$impact] = $priority; + for ($urgency=1; $urgency<=5; $urgency++) { + for ($impact=1; $impact<=5; $impact++) { + $priority = $input["_matrix_{$urgency}_{$impact}"]; + $tab[$urgency][$impact] = $priority; } } @@ -220,30 +220,30 @@ function prepareInputForUpdate($input) { $input['impact_mask'] = 0; for ($i=1; $i<=5; $i++) { - if ($input["_urgency_{$i}"]) { - $input['urgency_mask'] += (1<<$i); + if ($input["_urgency_{$i}"]) { + $input['urgency_mask'] += (1<<$i); } if ($input["_impact_{$i}"]) { - $input['impact_mask'] += (1<<$i); + $input['impact_mask'] += (1<<$i); } } } if (isset($input['_update_devices_in_menu'])) { - $input['devices_in_menu'] = exportArrayToDB( - (isset($input['devices_in_menu']) ? $input['devices_in_menu'] : []) + $input['devices_in_menu'] = exportArrayToDB( + (isset($input['devices_in_menu']) ? $input['devices_in_menu'] : []) ); } // lock mechanism update if (isset( $input['lock_use_lock_item'])) { $input['lock_item_list'] = exportArrayToDB((isset($input['lock_item_list']) - ? $input['lock_item_list'] : [])); + ? $input['lock_item_list'] : [])); } if (isset($input[Impact::CONF_ENABLED])) { - $input[Impact::CONF_ENABLED] = exportArrayToDB($input[Impact::CONF_ENABLED]); + $input[Impact::CONF_ENABLED] = exportArrayToDB($input[Impact::CONF_ENABLED]); } // Beware : with new management system, we must update each value @@ -253,10 +253,10 @@ function prepareInputForUpdate($input) { // Add skipMaintenance if maintenance mode update if (isset($input['maintenance_mode']) && $input['maintenance_mode']) { - $_SESSION['glpiskipMaintenance'] = 1; - $url = $CFG_GLPI['root_doc']."/index.php?skipMaintenance=1"; - Session::addMessageAfterRedirect(sprintf(__('Maintenance mode activated. Backdoor using: %s'), - "$url"), + $_SESSION['glpiskipMaintenance'] = 1; + $url = $CFG_GLPI['root_doc']."/index.php?skipMaintenance=1"; + Session::addMessageAfterRedirect(sprintf(__('Maintenance mode activated. Backdoor using: %s'), + "$url"), false, WARNING); } @@ -266,12 +266,12 @@ function prepareInputForUpdate($input) { } static public function unsetUndisclosedFields(&$fields) { - if (isset($fields['context']) && isset($fields['name'])) { - if ($fields['context'] == 'core' - && in_array($fields['name'], self::$undisclosedFields)) { - unset($fields['value']); + if (isset($fields['context']) && isset($fields['name'])) { + if ($fields['context'] == 'core' + && in_array($fields['name'], self::$undisclosedFields)) { + unset($fields['value']); } else { - $fields = Plugin::doHookFunction('undiscloseConfigValue', $fields); + $fields = Plugin::doHookFunction('undiscloseConfigValue', $fields); } } } @@ -280,216 +280,216 @@ static public function unsetUndisclosedFields(&$fields) { * Print the config form for display * * @return void - **/ + **/ function showFormDisplay() { - global $CFG_GLPI; + global $CFG_GLPI; - if (!self::canView()) { - return; + if (!self::canView()) { + return; } $rand = mt_rand(); $canedit = Session::haveRight(self::$rightname, UPDATE); $form = [ - 'action' => $canedit ? Toolbox::getItemTypeFormURL('config') : '', - 'buttons' => $canedit ? [ - [ - 'type' => 'submit', - 'name' => 'update', - 'value' => __('Update'), - 'class' => 'btn btn-secondary' + 'action' => $canedit ? Toolbox::getItemTypeFormURL('config') : '', + 'buttons' => $canedit ? [ + [ + 'type' => 'submit', + 'name' => 'update', + 'value' => __('Update'), + 'class' => 'btn btn-secondary' ] ] : [], 'content' => [ - __('General setup') => [ - 'visible' => true, - 'inputs' => [ - __('URL of the application') => [ - 'name' => 'url_base', - 'type' => 'text', - 'value' => $CFG_GLPI["url_base"], - 'col_lg' => 12, - 'col_md' => 12, + __('General setup') => [ + 'visible' => true, + 'inputs' => [ + __('URL of the application') => [ + 'name' => 'url_base', + 'type' => 'text', + 'value' => $CFG_GLPI["url_base"], + 'col_lg' => 12, + 'col_md' => 12, ], __('Text in the login box') => [ - 'name' => 'text_login', - 'type' => 'textarea', - 'value' => $CFG_GLPI["text_login"], - 'col_lg' => 12, - 'col_md' => 12, + 'name' => 'text_login', + 'type' => 'textarea', + 'value' => $CFG_GLPI["text_login"], + 'col_lg' => 12, + 'col_md' => 12, ], __('Simplified interface help link') => [ - 'name' => 'helpdesk_doc_url', - 'type' => 'text', - 'value' => $CFG_GLPI["helpdesk_doc_url"], - 'col_lg' => 6, + 'name' => 'helpdesk_doc_url', + 'type' => 'text', + 'value' => $CFG_GLPI["helpdesk_doc_url"], + 'col_lg' => 6, ], __('Standard interface help link') => [ - 'name' => 'central_doc_url', - 'type' => 'text', - 'value' => $CFG_GLPI["central_doc_url"], - 'col_lg' => 6, + 'name' => 'central_doc_url', + 'type' => 'text', + 'value' => $CFG_GLPI["central_doc_url"], + 'col_lg' => 6, ], __('Allow FAQ anonymous access') => [ - 'name' => 'use_public_faq', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["use_public_faq"], - 'col_lg' => 6, + 'name' => 'use_public_faq', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["use_public_faq"], + 'col_lg' => 6, ], __('Default characters limit (summary text boxes)') => [ - 'name' => 'cut', - 'type' => 'number', - 'value' => $CFG_GLPI["cut"], - 'col_lg' => 6, + 'name' => 'cut', + 'type' => 'number', + 'value' => $CFG_GLPI["cut"], + 'col_lg' => 6, ], __('Default url length limit') => [ - 'name' => 'url_maxlength', - 'type' => 'number', - 'value' => $CFG_GLPI["url_maxlength"], - 'min' => 20, - 'max' => 80, - 'step' => 5, - 'col_lg' => 6, + 'name' => 'url_maxlength', + 'type' => 'number', + 'value' => $CFG_GLPI["url_maxlength"], + 'min' => 20, + 'max' => 80, + 'step' => 5, + 'col_lg' => 6, ], __('Default decimals limit') => [ - 'name' => 'decimal_number', - 'type' => 'number', - 'value' => $CFG_GLPI["decimal_number"], - 'min' => 1, - 'max' => 4, + 'name' => 'decimal_number', + 'type' => 'number', + 'value' => $CFG_GLPI["decimal_number"], + 'min' => 1, + 'max' => 4, ], __("Translation of dropdowns") => [ - 'name' => 'translate_dropdowns', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["translate_dropdowns"], + 'name' => 'translate_dropdowns', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["translate_dropdowns"], ], __("Knowledge base translation") => [ - 'name' => 'translate_kb', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["translate_kb"], + 'name' => 'translate_kb', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["translate_kb"], ], __("Translation of reminders") => [ - 'name' => 'translate_reminders', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["translate_reminders"], + 'name' => 'translate_reminders', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["translate_reminders"], ], ] ], __('Dynamic display') => [ - 'visible' => true, - 'inputs' => [ - __('Page size for dropdown (paging using scroll)') => [ - 'name' => 'dropdown_max', - 'type' => 'number', - 'value' => $CFG_GLPI["dropdown_max"], - 'min' => 1, - 'max' => 200, - 'col_lg' => 6, + 'visible' => true, + 'inputs' => [ + __('Page size for dropdown (paging using scroll)') => [ + 'name' => 'dropdown_max', + 'type' => 'number', + 'value' => $CFG_GLPI["dropdown_max"], + 'min' => 1, + 'max' => 200, + 'col_lg' => 6, ], __('Autocompletion of text fields') => [ - 'name' => 'use_ajax_autocompletion', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["use_ajax_autocompletion"], - 'col_lg' => 6, + 'name' => 'use_ajax_autocompletion', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["use_ajax_autocompletion"], + 'col_lg' => 6, ], __("Don't show search engine in dropdowns if the number of items is less than") => [ - 'name' => 'ajax_limit_count', - 'type' => 'number', - 'value' => $CFG_GLPI["ajax_limit_count"], - 'min' => 1, - 'max' => 200, - 'step' => 1, - 'after' => "0 => " . __('Never'), - 'col_lg' => 12, - 'col_mg' => 12, + 'name' => 'ajax_limit_count', + 'type' => 'number', + 'value' => $CFG_GLPI["ajax_limit_count"], + 'min' => 1, + 'max' => 200, + 'step' => 1, + 'after' => "0 => " . __('Never'), + 'col_lg' => 12, + 'col_mg' => 12, ], ] ], __('Search engine') => [ - 'visible' => true, - 'inputs' => [ - __('Items seen') => [ - 'name' => 'allow_search_view', - 'type' => 'select', - 'values' => [ - 0 => __('No'), - 1 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('last criterion')), - 2 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('default criterion')) + 'visible' => true, + 'inputs' => [ + __('Items seen') => [ + 'name' => 'allow_search_view', + 'type' => 'select', + 'values' => [ + 0 => __('No'), + 1 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('last criterion')), + 2 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('default criterion')) ], 'value' => $CFG_GLPI['allow_search_view'], ], __('Global search') => [ - 'name' => 'allow_search_global', - 'type' => 'select', - 'values' => [ - 0 => __('No'), - 1 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('last criterion')) + 'name' => 'allow_search_global', + 'type' => 'select', + 'values' => [ + 0 => __('No'), + 1 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('last criterion')) ], 'value' => $CFG_GLPI['allow_search_global'], ], __('All') => [ - 'name' => 'allow_search_all', - 'type' => 'select', - 'values' => [ - 0 => __('No'), - 1 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('last criterion')) + 'name' => 'allow_search_all', + 'type' => 'select', + 'values' => [ + 0 => __('No'), + 1 => sprintf(__('%1$s (%2$s)'), __('Yes'), __('last criterion')) ], 'value' => $CFG_GLPI['allow_search_all'], ], ] ], __('Item locks') => [ - 'visible' => true, - 'inputs' => [ - __('Use locks') => [ - 'name' => 'lock_use_lock_item', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["lock_use_lock_item"], + 'visible' => true, + 'inputs' => [ + __('Use locks') => [ + 'name' => 'lock_use_lock_item', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["lock_use_lock_item"], ], __('Profile to be used when locking items') => ($CFG_GLPI["lock_use_lock_item"]) ? [ - 'name' => 'lock_lockprofile_id', - 'type' => 'select', - 'values' => getOptionForItems('Profile'), - 'value' => $CFG_GLPI["lock_lockprofile_id"], - 'action' => getItemActionButtons(['info'], 'Profile'), + 'name' => 'lock_lockprofile_id', + 'type' => 'select', + 'values' => getOptionForItems('Profile'), + 'value' => $CFG_GLPI["lock_lockprofile_id"], + 'action' => getItemActionButtons(['info'], 'Profile'), ] : [ - 'content' => Dropdown::getDropdownName(Profile::getTable(), $CFG_GLPI['lock_lockprofile_id']), + 'content' => Dropdown::getDropdownName(Profile::getTable(), $CFG_GLPI['lock_lockprofile_id']), ], __('List of items to lock') => [ - 'name' => 'lock_item_list', - 'type' => 'checklist', - 'options' => ObjectLock::getLockableObjects(), - 'values' => $CFG_GLPI['lock_item_list'], - !$CFG_GLPI["lock_use_lock_item"] ? 'disabled' : '', + 'name' => 'lock_item_list', + 'type' => 'checklist', + 'options' => ObjectLock::getLockableObjects(), + 'values' => $CFG_GLPI['lock_item_list'], + !$CFG_GLPI["lock_use_lock_item"] ? 'disabled' : '', ], ] ], __('Auto Login') => [ - 'visible' => true, - 'inputs' => [ - __('Time to allow "Remember Me"') => [ - 'name' => 'login_remember_time', - 'type' => 'select', - 'values' => array_merge([__('Disabled')], Timezone::GetTimeStamp([ - 'value' => $CFG_GLPI["login_remember_time"], - 'min' => 0, - 'max' => MONTH_TIMESTAMP * 2, - 'step' => DAY_TIMESTAMP, - 'toadd' => [HOUR_TIMESTAMP, HOUR_TIMESTAMP * 2, HOUR_TIMESTAMP * 6, HOUR_TIMESTAMP * 12], - 'rand' => $rand + 'visible' => true, + 'inputs' => [ + __('Time to allow "Remember Me"') => [ + 'name' => 'login_remember_time', + 'type' => 'select', + 'values' => array_merge([__('Disabled')], Timezone::GetTimeStamp([ + 'value' => $CFG_GLPI["login_remember_time"], + 'min' => 0, + 'max' => MONTH_TIMESTAMP * 2, + 'step' => DAY_TIMESTAMP, + 'toadd' => [HOUR_TIMESTAMP, HOUR_TIMESTAMP * 2, HOUR_TIMESTAMP * 6, HOUR_TIMESTAMP * 12], + 'rand' => $rand ])), 'value' => $CFG_GLPI["login_remember_time"], ], __("Default state of checkbox") => [ - 'name' => 'login_remember_default', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["login_remember_default"], + 'name' => 'login_remember_default', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["login_remember_default"], ], __('Display source dropdown on login page') => [ - 'name' => 'display_login_source', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["display_login_source"], + 'name' => 'display_login_source', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["display_login_source"], ], ] ], @@ -503,12 +503,12 @@ function showFormDisplay() { * Print the config form for restrictions * * @return void - **/ + **/ function showFormInventory() { - global $CFG_GLPI; + global $CFG_GLPI; - if (!self::canView()) { - return; + if (!self::canView()) { + return; } $rand = mt_rand(); @@ -516,202 +516,202 @@ function showFormInventory() { $item_devices_types = []; foreach ($CFG_GLPI['itemdevices'] as $key => $itemtype) { - if ($item = getItemForItemtype($itemtype)) { - $item_devices_types[$itemtype] = $item->getTypeName(); + if ($item = getItemForItemtype($itemtype)) { + $item_devices_types[$itemtype] = $item->getTypeName(); } else { - unset($CFG_GLPI['itemdevices'][$key]); + unset($CFG_GLPI['itemdevices'][$key]); } } $form = [ - 'action' => $canedit ? Toolbox::getItemTypeFormURL('config') : '', - 'buttons' => [ - $canedit ? [ - 'type' => 'submit', - 'name' => 'update', - 'value' => __('Update'), - 'class' => 'btn btn-secondary' + 'action' => $canedit ? Toolbox::getItemTypeFormURL('config') : '', + 'buttons' => [ + $canedit ? [ + 'type' => 'submit', + 'name' => 'update', + 'value' => __('Update'), + 'class' => 'btn btn-secondary' ] : [], ], 'content' => [ - __('Assets') => [ - 'visible' => true, - 'inputs' => [ - __('Enable the financial and administrative information by default') => [ - 'name' => 'auto_create_infocoms', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["auto_create_infocoms"], - 'col_lg' => 6, + __('Assets') => [ + 'visible' => true, + 'inputs' => [ + __('Enable the financial and administrative information by default') => [ + 'name' => 'auto_create_infocoms', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["auto_create_infocoms"], + 'col_lg' => 6, ], __('Software category deleted by the dictionary rules') => [ - 'name' => 'softwarecategories_id_ondelete', - 'type' => 'select', - 'values' => getOptionForItems('SoftwareCategory'), - 'value' => $CFG_GLPI["softwarecategories_id_ondelete"], - 'col_lg' => 6, + 'name' => 'softwarecategories_id_ondelete', + 'type' => 'select', + 'values' => getOptionForItems('SoftwareCategory'), + 'value' => $CFG_GLPI["softwarecategories_id_ondelete"], + 'col_lg' => 6, ], __('Restrict monitor management') => [ - 'name' => 'monitors_management_restrict', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["monitors_management_restrict"], - 'col_lg' => 6, + 'name' => 'monitors_management_restrict', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["monitors_management_restrict"], + 'col_lg' => 6, ], __('Restrict device management') => [ - 'name' => 'peripherals_management_restrict', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["peripherals_management_restrict"], - 'col_lg' => 6, + 'name' => 'peripherals_management_restrict', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["peripherals_management_restrict"], + 'col_lg' => 6, ], __('Restrict phone management') => [ - 'name' => 'phones_management_restrict', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["phones_management_restrict"], - 'col_lg' => 6, + 'name' => 'phones_management_restrict', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["phones_management_restrict"], + 'col_lg' => 6, ], __('Restrict printer management') => [ - 'name' => 'printers_management_restrict', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["printers_management_restrict"], - 'col_lg' => 6, + 'name' => 'printers_management_restrict', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["printers_management_restrict"], + 'col_lg' => 6, ], __('End of fiscal year') => [ - 'name' => 'date_tax', - 'type' => 'date', - 'value' => $CFG_GLPI["date_tax"], - 'rand' => $rand, - 'col_lg' => 6, - 'required' => true, + 'name' => 'date_tax', + 'type' => 'date', + 'value' => $CFG_GLPI["date_tax"], + 'rand' => $rand, + 'col_lg' => 6, + 'required' => true, ], __('Automatic fields (marked by *)') => [ - 'name' => 'use_autoname_by_entity', - 'type' => 'select', - 'values' => [ - 0 => __('Global'), - 1 => __('By entity') + 'name' => 'use_autoname_by_entity', + 'type' => 'select', + 'values' => [ + 0 => __('Global'), + 1 => __('By entity') ], 'value' => $CFG_GLPI["use_autoname_by_entity"], 'rand' => $rand, 'col_lg' => 6, ], __('Devices displayed in menu') => [ - 'type' => 'checklist', - 'name' => 'devices_in_menu', - 'options' => $item_devices_types, - 'values' => $CFG_GLPI['devices_in_menu'], + 'type' => 'checklist', + 'name' => 'devices_in_menu', + 'options' => $item_devices_types, + 'values' => $CFG_GLPI['devices_in_menu'], ], [ - 'name' => '_update_devices_in_menu', - 'type' => 'hidden', - 'value' => 1, + 'name' => '_update_devices_in_menu', + 'type' => 'hidden', + 'value' => 1, ], __('Automatic transfer of computers') => (Session::haveRightsOr("transfer", [CREATE, UPDATE]) - && Session::isMultiEntitiesMode()) ? [ - 'name' => 'transfers_id_auto', - 'type' => 'select', - 'values' => array_merge([__('No automatic transfer')], getOptionForItems('Transfer')), - 'value' => $CFG_GLPI["transfers_id_auto"], + && Session::isMultiEntitiesMode()) ? [ + 'name' => 'transfers_id_auto', + 'type' => 'select', + 'values' => array_merge([__('No automatic transfer')], getOptionForItems('Transfer')), + 'value' => $CFG_GLPI["transfers_id_auto"], ] : [], ] ], __('Automatically update of the elements related to the computers') . ' : ' . __('Unit management') => [ - 'visible' => true, - 'inputs' => [ - __('Alternate username') . '(' . __('When connecting or updating') . ')' => [ - 'name' => 'is_contact_autoupdate', - 'type' => 'select', - 'values' => [ - 0 => __('Do not copy'), - 1 => __('Copy'), + 'visible' => true, + 'inputs' => [ + __('Alternate username') . '(' . __('When connecting or updating') . ')' => [ + 'name' => 'is_contact_autoupdate', + 'type' => 'select', + 'values' => [ + 0 => __('Do not copy'), + 1 => __('Copy'), ], 'value' => $CFG_GLPI["is_contact_autoupdate"], 'col_lg' => 6, ], __('Alternate username') . '(' . __('When disconnecting') . ')' => [ - 'name' => 'is_contact_autoclean', - 'type' => 'select', - 'values' => [ - 0 => __('Do not delete'), - 1 => __('Clear'), + 'name' => 'is_contact_autoclean', + 'type' => 'select', + 'values' => [ + 0 => __('Do not delete'), + 1 => __('Clear'), ], 'value' => $CFG_GLPI["is_contact_autoclean"], 'col_lg' => 6, ], User::getTypeName(1) . '(' . __('When connecting or updating') . ')' => [ - 'name' => 'is_user_autoupdate', - 'type' => 'select', - 'values' => [ - 0 => __('Do not copy'), - 1 => __('Copy'), + 'name' => 'is_user_autoupdate', + 'type' => 'select', + 'values' => [ + 0 => __('Do not copy'), + 1 => __('Copy'), ], 'value' => $CFG_GLPI["is_user_autoupdate"], 'col_lg' => 6, ], User::getTypeName(1) . '(' . __('When disconnecting') . ')' => [ - 'name' => 'is_user_autoclean', - 'type' => 'select', - 'values' => [ - 0 => __('Do not delete'), - 1 => __('Clear'), + 'name' => 'is_user_autoclean', + 'type' => 'select', + 'values' => [ + 0 => __('Do not delete'), + 1 => __('Clear'), ], 'value' => $CFG_GLPI["is_user_autoclean"], 'col_lg' => 6, ], Group::getTypeName(1) . '(' . __('When connecting or updating') . ')' => [ - 'name' => 'is_group_autoupdate', - 'type' => 'select', - 'values' => [ - 0 => __('Do not copy'), - 1 => __('Copy'), + 'name' => 'is_group_autoupdate', + 'type' => 'select', + 'values' => [ + 0 => __('Do not copy'), + 1 => __('Copy'), ], 'value' => $CFG_GLPI["is_group_autoupdate"], 'col_lg' => 6, ], Group::getTypeName(1) . '(' . __('When disconnecting') . ')' => [ - 'name' => 'is_group_autoclean', - 'type' => 'select', - 'values' => [ - 0 => __('Do not delete'), - 1 => __('Clear'), + 'name' => 'is_group_autoclean', + 'type' => 'select', + 'values' => [ + 0 => __('Do not delete'), + 1 => __('Clear'), ], 'value' => $CFG_GLPI["is_group_autoclean"], 'col_lg' => 6, ], Location::getTypeName(1) . '(' . __('When connecting or updating') . ')' => [ - 'name' => 'is_location_autoupdate', - 'type' => 'select', - 'values' => [ - 0 => __('Do not copy'), - 1 => __('Copy'), + 'name' => 'is_location_autoupdate', + 'type' => 'select', + 'values' => [ + 0 => __('Do not copy'), + 1 => __('Copy'), ], 'value' => $CFG_GLPI["is_location_autoupdate"], 'col_lg' => 6, ], Location::getTypeName(1) . '(' . __('When disconnecting') . ')' => [ - 'name' => 'is_location_autoclean', - 'type' => 'select', - 'values' => [ - 0 => __('Do not delete'), - 1 => __('Clear'), + 'name' => 'is_location_autoclean', + 'type' => 'select', + 'values' => [ + 0 => __('Do not delete'), + 1 => __('Clear'), ], 'value' => $CFG_GLPI["is_location_autoclean"], 'col_lg' => 6, ], __('Status') . '(' . __('When connecting or updating') . ')' => [ - 'name' => 'state_autoupdate_mode', - 'type' => 'select', - 'values' => [ - 0 => __('Do not copy'), - 1 => __('Copy computer status'), + 'name' => 'state_autoupdate_mode', + 'type' => 'select', + 'values' => [ + 0 => __('Do not copy'), + 1 => __('Copy computer status'), ], 'value' => $CFG_GLPI["state_autoupdate_mode"], 'col_lg' => 6, ], __('Status') . '(' . __('When disconnecting') . ')' => [ - 'name' => 'state_autoclean_mode', - 'type' => 'select', - 'values' => [ - 0 => __('Do not delete'), - 1 => __('Clear status'), + 'name' => 'state_autoclean_mode', + 'type' => 'select', + 'values' => [ + 0 => __('Do not delete'), + 1 => __('Clear status'), ], 'value' => $CFG_GLPI["state_autoclean_mode"], 'col_lg' => 6, @@ -728,50 +728,50 @@ function showFormInventory() { * Print the config form for restrictions * * @return void - **/ + **/ function showFormAuthentication() { - global $CFG_GLPI; + global $CFG_GLPI; - if (!Config::canUpdate()) { - return; + if (!Config::canUpdate()) { + return; } $form = [ - 'action' => Toolbox::getItemTypeFormURL('config'), - 'buttons' => [ - [ - 'type' => 'submit', - 'name' => 'update_auth', - 'value' => _sx('button', 'Save'), - 'class' => 'btn btn-secondary', - ], + 'action' => Toolbox::getItemTypeFormURL('config'), + 'buttons' => [ + [ + 'type' => 'submit', + 'name' => 'update_auth', + 'value' => _sx('button', 'Save'), + 'class' => 'btn btn-secondary', + ], ], 'content' => [ - __('Authentication') => [ - 'visible' => true, - 'inputs' => [ - __('Automatically add users from an external authentication source') => [ - 'name' => 'is_users_auto_add', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["is_users_auto_add"], + __('Authentication') => [ + 'visible' => true, + 'inputs' => [ + __('Automatically add users from an external authentication source') => [ + 'name' => 'is_users_auto_add', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["is_users_auto_add"], ], __('Add a user without accreditation from a LDAP directory') => [ - 'name' => 'use_noright_users_add', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["use_noright_users_add"], + 'name' => 'use_noright_users_add', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["use_noright_users_add"], ], __('Action when a user is deleted from the LDAP directory') => [ - 'name' => 'user_deleted_ldap', - 'type' => 'select', - 'values' => AuthLDAP::getLdapDeletedUserActionOptions(), - 'value' => $CFG_GLPI["user_deleted_ldap"], + 'name' => 'user_deleted_ldap', + 'type' => 'select', + 'values' => AuthLDAP::getLdapDeletedUserActionOptions(), + 'value' => $CFG_GLPI["user_deleted_ldap"], ], __('ITSM-NG server time zone') => [ - 'name' => 'time_offset', - 'type' => 'select', - // 'values' => '' ?? Timezone::showGMT(), - 'values' => [], - 'value' => $CFG_GLPI["time_offset"], + 'name' => 'time_offset', + 'type' => 'select', + // 'values' => '' ?? Timezone::showGMT(), + 'values' => [], + 'value' => $CFG_GLPI["time_offset"], ], ], ], @@ -786,12 +786,12 @@ function showFormAuthentication() { * Print the config form for slave DB * * @return void - **/ + **/ function showFormDBSlave() { - global $DB, $CFG_GLPI, $DBslave; + global $DB, $CFG_GLPI, $DBslave; - if (!Config::canUpdate()) { - return; + if (!Config::canUpdate()) { + return; } echo "
"; @@ -800,13 +800,13 @@ function showFormDBSlave() { echo ""; echo ""; + ""; $DBslave = DBConnection::getDBSlaveConf(); if (is_array($DBslave->dbhost)) { - $host = implode(' ', $DBslave->dbhost); + $host = implode(' ', $DBslave->dbhost); } else { - $host = $DBslave->dbhost; + $host = $DBslave->dbhost; } echo ""; echo ""; @@ -820,25 +820,25 @@ function showFormDBSlave() { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if ($DBslave->connected && !$DB->isSlave()) { - echo ""; + echo ""; } echo ""; $ext = 'Zend OPcache'; if (extension_loaded($ext) && ($info = opcache_get_status(false))) { - $msg = sprintf(__s('%s extension is installed'), $ext); - echo " - - - "; - - // Memory - $used = $info['memory_usage']['used_memory']; - $free = $info['memory_usage']['free_memory']; - $rate = round(100.0 * $used / ($used + $free)); - $max = Toolbox::getSize($used + $free); - $used = Toolbox::getSize($used); - echo " - + + + "; + + // Memory + $used = $info['memory_usage']['used_memory']; + $free = $info['memory_usage']['free_memory']; + $rate = round(100.0 * $used / ($used + $free)); + $max = Toolbox::getSize($used + $free); + $used = Toolbox::getSize($used); + echo " + "; @@ -1821,93 +1822,93 @@ function showPerformanceInformations() { $max = $hits+$miss; $rate = round($info['opcache_statistics']['opcache_hit_rate']); echo " - "; // Restart (1 seems ok, can happen) $max = $info['opcache_statistics']['oom_restarts']; echo " - "; if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { - echo ""; + echo ""; } } else { - $msg = sprintf(__s('%s extension is not present'), $ext); - echo " - "; + $msg = sprintf(__s('%s extension is not present'), $ext); + echo " + "; } echo ""; $ext = strtolower(get_class($GLPI_CACHE)); $ext = substr($ext, strrpos($ext, '\\')+1); if (in_array($ext, ['apcu', 'memcache', 'memcached', 'wincache', 'redis'])) { - $msg = sprintf(__s('The "%s" cache extension is installed'), $ext); + $msg = sprintf(__s('The "%s" cache extension is installed'), $ext); } else { - $msg = sprintf(__s('"%s" cache system is used'), $ext); + $msg = sprintf(__s('"%s" cache system is used'), $ext); } echo " - - - "; + + + "; if ($ext != 'filesystem' && $GLPI_CACHE instanceof AvailableSpaceCapableInterface && $GLPI_CACHE instanceof TotalSpaceCapableInterface) { - $free = $GLPI_CACHE->getAvailableSpace(); - $max = $GLPI_CACHE->getTotalSpace(); - $used = $max - $free; - $rate = round(100.0 * $used / $max); - $max = Toolbox::getSize($max); - $used = Toolbox::getSize($used); - - echo " - + "; } if ($GLPI_CACHE instanceof FlushableInterface) { - echo ""; + echo ""; } echo ""; @@ -1916,19 +1917,19 @@ function showPerformanceInformations() { $adapter = substr($adapter_class, strrpos($adapter_class, '\\')+1); $msg = sprintf(__s('"%s" cache system is used'), $adapter); echo " - "; + "; if ($translation_cache instanceof FlushableInterface) { - echo ""; + echo ""; } echo "
" . _n('SQL replica', 'SQL replicas', Session::getPluralNumber()) . - "
" . __('SQL server (MariaDB or MySQL)') . "" . __('SQL password') . ""; + rawurldecode($DBslave->dbpassword)."'>"; echo "
" . __('Use the slave for the search engine') . ""; $values = [0 => __('Never'), - 1 => __('If synced (all changes)'), - 2 => __('If synced (current user changes)'), - 3 => __('If synced or read-only account'), - 4 => __('Always')]; + 1 => __('If synced (all changes)'), + 2 => __('If synced (current user changes)'), + 3 => __('If synced or read-only account'), + 4 => __('Always')]; Dropdown::showFromArray('use_slave_for_search', $values, - ['value' => $CFG_GLPI["use_slave_for_search"]]); + ['value' => $CFG_GLPI["use_slave_for_search"]]); echo " 
"; - DBConnection::showAllReplicateDelay(); - echo "
"; + DBConnection::showAllReplicateDelay(); + echo "
"; @@ -857,55 +857,55 @@ function showFormDBSlave() { * @return void **/ function showFormAPI() { - global $CFG_GLPI; + global $CFG_GLPI; - if (!self::canView()) { - return; + if (!self::canView()) { + return; } $inline_doc_api = trim($CFG_GLPI['url_base_api'], '/')."/"; $form = [ - 'action' => Toolbox::getItemTypeFormURL(__CLASS__), - 'method' => 'post', - 'content' => [ - __('API') => [ - 'visible' => true, - 'inputs' => [ - __('URL of the API') => [ - 'name' => 'url_base_api', - 'type' => 'text', - 'size' => 80, - 'value' => $CFG_GLPI["url_base_api"], - 'col_lg' => 6, + 'action' => Toolbox::getItemTypeFormURL(__CLASS__), + 'method' => 'post', + 'content' => [ + __('API') => [ + 'visible' => true, + 'inputs' => [ + __('URL of the API') => [ + 'name' => 'url_base_api', + 'type' => 'text', + 'size' => 80, + 'value' => $CFG_GLPI["url_base_api"], + 'col_lg' => 6, ], __('Enable Rest API') => [ - 'name' => 'enable_api', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["enable_api"], - 'col_lg' => 6, + 'name' => 'enable_api', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["enable_api"], + 'col_lg' => 6, ], '' => $CFG_GLPI['enable_api'] ? [ - 'content' => "".__("API inline Documentation")."" + 'content' => "".__("API inline Documentation")."" ] : [], ] ], __('Authentication') => [ - 'visible' => true, - 'inputs' => [ - __('Enable login with credentials') => [ - 'name' => 'enable_api_login_credentials', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["enable_api_login_credentials"] + 'visible' => true, + 'inputs' => [ + __('Enable login with credentials') => [ + 'name' => 'enable_api_login_credentials', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["enable_api_login_credentials"] ], __('Enable login with external token') => [ - 'name' => 'enable_api_login_external_token', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["enable_api_login_external_token"] + 'name' => 'enable_api_login_external_token', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["enable_api_login_external_token"] ], [ - 'name' => 'update', - 'type' => 'hidden', - 'value' => 1 + 'name' => 'update', + 'type' => 'hidden', + 'value' => 1 ] ] ], @@ -915,12 +915,12 @@ function showFormAPI() { renderTwigForm($form); $buttons = [ - 'apiclient.form.php' => __('Add API client'), + 'apiclient.form.php' => __('Add API client'), ]; Html::displayTitle("", - self::getTypeName(Session::getPluralNumber()), - "", - $buttons); + self::getTypeName(Session::getPluralNumber()), + "", + $buttons); Search::show("APIClient"); } @@ -929,173 +929,173 @@ function showFormAPI() { * Print the config form for connections * * @return void - **/ + **/ function showFormHelpdesk() { - global $CFG_GLPI; + global $CFG_GLPI; - if (!self::canView()) { - return; + if (!self::canView()) { + return; } $canedit = Config::canUpdate(); for ($index=0; $index<=100; $index += 10) { - $sizes[$index*1048576] = sprintf(__('%s Mio'), $index); + $sizes[$index*1048576] = sprintf(__('%s Mio'), $index); } $sizes[0] = __('No import'); $urgencynames = [ - 1 => Ticket::getUrgencyName(1), - 2 => Ticket::getUrgencyName(2), - 3 => Ticket::getUrgencyName(3), - 4 => Ticket::getUrgencyName(4), - 5 => Ticket::getUrgencyName(5), + 1 => Ticket::getUrgencyName(1), + 2 => Ticket::getUrgencyName(2), + 3 => Ticket::getUrgencyName(3), + 4 => Ticket::getUrgencyName(4), + 5 => Ticket::getUrgencyName(5), ]; $headers = []; $headers['title'] = __('Urgency') . ' / ' . __('Impact'); for ($i=5; $i>0; $i--) { - ob_start(); - if ($i != 3) { - renderTwigTemplate('macros/input.twig', [ - 'name' => "_impact_{$i}", - 'type' => 'checkbox', - 'value' => ($CFG_GLPI['impact_mask'] & (1<<$i)) >0, + ob_start(); + if ($i != 3) { + renderTwigTemplate('macros/input.twig', [ + 'name' => "_impact_{$i}", + 'type' => 'checkbox', + 'value' => ($CFG_GLPI['impact_mask'] & (1<<$i)) >0, ]); } else { - echo ""; + echo ""; } $headers['x'][$i] = Ticket::getImpactName($i) . ob_get_clean(); ob_start(); if ($i != 3) { - renderTwigTemplate('macros/input.twig', [ - 'name' => "_urgency_{$i}", - 'type' => 'checkbox', - 'value' => ($CFG_GLPI['urgency_mask'] & (1<<$i)) >0, + renderTwigTemplate('macros/input.twig', [ + 'name' => "_urgency_{$i}", + 'type' => 'checkbox', + 'value' => ($CFG_GLPI['urgency_mask'] & (1<<$i)) >0, ]); } else { - echo ""; + echo ""; } $headers['y'][$i] = Ticket::getUrgencyName($i) . ob_get_clean(); } $matrix = []; for ($urgency=1; $urgency<=5; $urgency++) { - for ($impact=5; $impact>0; $impact--) { - $pri = round(($urgency+$impact)/2); + for ($impact=5; $impact>0; $impact--) { + $pri = round(($urgency+$impact)/2); - if (isset($CFG_GLPI['priority_matrix'][$urgency][$impact])) { - $pri = $CFG_GLPI['priority_matrix'][$urgency][$impact]; + if (isset($CFG_GLPI['priority_matrix'][$urgency][$impact])) { + $pri = $CFG_GLPI['priority_matrix'][$urgency][$impact]; } if (($CFG_GLPI['impact_mask'] & (1<<$impact)) != 0 - && ($CFG_GLPI['urgency_mask'] & (1<<$urgency)) != 0) { - ob_start(); - renderTwigTemplate('macros/input.twig', [ - 'name' => "_matrix_{$urgency}_{$impact}", - 'type' => 'select', - 'values' => $urgencynames, - 'value' => $CFG_GLPI['priority_matrix'][$urgency][$impact] + && ($CFG_GLPI['urgency_mask'] & (1<<$urgency)) != 0) { + ob_start(); + renderTwigTemplate('macros/input.twig', [ + 'name' => "_matrix_{$urgency}_{$impact}", + 'type' => 'select', + 'values' => $urgencynames, + 'value' => $CFG_GLPI['priority_matrix'][$urgency][$impact] ]); - $content = ob_get_clean(); - $matrix[$urgency][$impact] = [ - 'content' => $content, - 'style' => "background:" . $_SESSION['glpipriority_'.$pri], + $content = ob_get_clean(); + $matrix[$urgency][$impact] = [ + 'content' => $content, + 'style' => "background:" . $_SESSION['glpipriority_'.$pri], ]; } else { - $matrix[$urgency][$impact] = [ - 'content' => "", + $matrix[$urgency][$impact] = [ + 'content' => "", ]; } } } $form = [ - 'action' => $canedit ? Toolbox::getItemTypeFormURL('config') : '', - 'buttons' => [ - $canedit ? [ - 'type' => 'submit', - 'name' => 'update', - 'value' => __('Update'), - 'class' => 'btn btn-secondary' + 'action' => $canedit ? Toolbox::getItemTypeFormURL('config') : '', + 'buttons' => [ + $canedit ? [ + 'type' => 'submit', + 'name' => 'update', + 'value' => __('Update'), + 'class' => 'btn btn-secondary' ] : [], ], 'content' => [ - __('Assistance') => [ - 'visible' => true, - 'inputs' => [ - __('Limit of the schedules for planning : From') => [ - 'name' => 'planning_begin', - 'type' => 'time', - 'value' => $CFG_GLPI["planning_begin"], - 'col_lg' => 6, + __('Assistance') => [ + 'visible' => true, + 'inputs' => [ + __('Limit of the schedules for planning : From') => [ + 'name' => 'planning_begin', + 'type' => 'time', + 'value' => $CFG_GLPI["planning_begin"], + 'col_lg' => 6, ], __('To') => [ - 'name' => 'planning_end', - 'type' => 'time', - 'value' => $CFG_GLPI["planning_end"], - 'col_lg' => 6, + 'name' => 'planning_end', + 'type' => 'time', + 'value' => $CFG_GLPI["planning_end"], + 'col_lg' => 6, ], __('Step for the hours (minutes)') => [ - 'name' => 'time_step', - 'type' => 'number', - 'value' => $CFG_GLPI["time_step"], - 'min' => 1, - 'max' => 60, - 'step' => 1, + 'name' => 'time_step', + 'type' => 'number', + 'value' => $CFG_GLPI["time_step"], + 'min' => 1, + 'max' => 60, + 'step' => 1, ], __('Default file size limit imported by the mails receiver') => [ - 'name' => 'default_mailcollector_filesize_max', - 'type' => 'select', - 'values' => $sizes, - 'value' => $CFG_GLPI["default_mailcollector_filesize_max"], + 'name' => 'default_mailcollector_filesize_max', + 'type' => 'select', + 'values' => $sizes, + 'value' => $CFG_GLPI["default_mailcollector_filesize_max"], ], __('Default heading when adding a document to a ticket') => [ - 'name' => 'documentcategories_id_forticket', - 'type' => 'select', - 'values' => getOptionForItems('DocumentCategory'), - 'value' => $CFG_GLPI["documentcategories_id_forticket"], - 'actions' => getItemActionButtons(['info', 'add'], 'DocumentCategory'), + 'name' => 'documentcategories_id_forticket', + 'type' => 'select', + 'values' => getOptionForItems('DocumentCategory'), + 'value' => $CFG_GLPI["documentcategories_id_forticket"], + 'actions' => getItemActionButtons(['info', 'add'], 'DocumentCategory'), ], __('By default, a software may be linked to a ticket') => [ - 'name' => 'default_software_helpdesk_visible', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["default_software_helpdesk_visible"], + 'name' => 'default_software_helpdesk_visible', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["default_software_helpdesk_visible"], ], __('Keep tickets when purging hardware in the inventory') => [ - 'name' => 'keep_tickets_on_delete', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["keep_tickets_on_delete"], + 'name' => 'keep_tickets_on_delete', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["keep_tickets_on_delete"], ], __('Show personnal information in new ticket form (simplified interface)') => [ - 'name' => 'use_check_pref', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["use_check_pref"], + 'name' => 'use_check_pref', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["use_check_pref"], ], __('Allow anonymous ticket creation (helpdesk.receiver)') => [ - 'name' => 'use_anonymous_helpdesk', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["use_anonymous_helpdesk"], + 'name' => 'use_anonymous_helpdesk', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["use_anonymous_helpdesk"], ], __('Allow anonymous followups (receiver)') => [ - 'name' => 'use_anonymous_followups', - 'type' => 'checkbox', - 'value' => $CFG_GLPI["use_anonymous_followups"], + 'name' => 'use_anonymous_followups', + 'type' => 'checkbox', + 'value' => $CFG_GLPI["use_anonymous_followups"], ], [ - 'type' => 'hidden', - 'name' => '_matrix', - 'value' => 1, + 'type' => 'hidden', + 'name' => '_matrix', + 'value' => 1, ], __('Matrix of calculus for priority') => [ - 'type' => 'twig', - 'template' => 'matrix.twig', - 'col_lg' => 12, - 'col_md' => 12, - 'headers' => $headers, - 'matrix' => $matrix, + 'type' => 'twig', + 'template' => 'matrix.twig', + 'col_lg' => 12, + 'col_md' => 12, + 'headers' => $headers, + 'matrix' => $matrix, ] ] ] @@ -1196,17 +1196,13 @@ function showFormHelpdesk() { * @return void **/ function showFormUserPrefs($data = []) { - global $CFG_GLPI, $DB; + global $CFG_GLPI, $DB; - $oncentral = (Session::getCurrentInterface() == "central"); - $userpref = false; - $url = Toolbox::getItemTypeFormURL(__CLASS__); - $rand = mt_rand(); + $oncentral = (Session::getCurrentInterface() == "central"); + $userpref = false; - $canedit = Config::canUpdate(); - $canedituser = Session::haveRight('personalization', UPDATE); - if (array_key_exists('last_login', $data)) { - $userpref = true; + if (array_key_exists('last_login', $data)) { + $userpref = true; } echo Html::scriptBlock(" function formatThemes(theme) { @@ -1253,6 +1249,11 @@ function formatThemes(theme) { 'values' => Dropdown::getLanguages(), 'value' => $data["language"], ], + __('Accessibility menu') => [ + 'type' => 'checkbox', + 'name' => 'accessibility_menu', + 'value' => $data["accessibility_menu"], + ], __('Date format') => [ 'type' => 'select', 'name' => 'date_format', @@ -1642,55 +1643,55 @@ static function displayPasswordSecurityChecks($field = 'password') { ".Html::jsGetElementByID('password_min_length').".removeClass('red'); }"; if ($CFG_GLPI["password_need_number"]) { - $needs[] = "".__('Digit').""; - echo "var numberRegex = new RegExp('[0-9]', 'g'); - if (false == numberRegex.test(pwd.val())) { - ".Html::jsGetElementByID('password_need_number').".addClass('red'); - ".Html::jsGetElementByID('password_need_number').".removeClass('green'); + $needs[] = "".__('Digit').""; + echo "var numberRegex = new RegExp('[0-9]', 'g'); + if (false == numberRegex.test(pwd.val())) { + ".Html::jsGetElementByID('password_need_number').".addClass('red'); + ".Html::jsGetElementByID('password_need_number').".removeClass('green'); } else { - ".Html::jsGetElementByID('password_need_number').".addClass('green'); - ".Html::jsGetElementByID('password_need_number').".removeClass('red'); + ".Html::jsGetElementByID('password_need_number').".addClass('green'); + ".Html::jsGetElementByID('password_need_number').".removeClass('red'); }"; } if ($CFG_GLPI["password_need_letter"]) { - $needs[] = "".__('Lowercase').""; - echo "var letterRegex = new RegExp('[a-z]', 'g'); - if (false == letterRegex.test(pwd.val())) { - ".Html::jsGetElementByID('password_need_letter').".addClass('red'); - ".Html::jsGetElementByID('password_need_letter').".removeClass('green'); + $needs[] = "".__('Lowercase').""; + echo "var letterRegex = new RegExp('[a-z]', 'g'); + if (false == letterRegex.test(pwd.val())) { + ".Html::jsGetElementByID('password_need_letter').".addClass('red'); + ".Html::jsGetElementByID('password_need_letter').".removeClass('green'); } else { - ".Html::jsGetElementByID('password_need_letter').".addClass('green'); - ".Html::jsGetElementByID('password_need_letter').".removeClass('red'); + ".Html::jsGetElementByID('password_need_letter').".addClass('green'); + ".Html::jsGetElementByID('password_need_letter').".removeClass('red'); }"; } if ($CFG_GLPI["password_need_caps"]) { - $needs[] = "".__('Uppercase').""; - echo "var capsRegex = new RegExp('[A-Z]', 'g'); - if (false == capsRegex.test(pwd.val())) { - ".Html::jsGetElementByID('password_need_caps').".addClass('red'); - ".Html::jsGetElementByID('password_need_caps').".removeClass('green'); + $needs[] = "".__('Uppercase').""; + echo "var capsRegex = new RegExp('[A-Z]', 'g'); + if (false == capsRegex.test(pwd.val())) { + ".Html::jsGetElementByID('password_need_caps').".addClass('red'); + ".Html::jsGetElementByID('password_need_caps').".removeClass('green'); } else { - ".Html::jsGetElementByID('password_need_caps').".addClass('green'); - ".Html::jsGetElementByID('password_need_caps').".removeClass('red'); + ".Html::jsGetElementByID('password_need_caps').".addClass('green'); + ".Html::jsGetElementByID('password_need_caps').".removeClass('red'); }"; } if ($CFG_GLPI["password_need_symbol"]) { - $needs[] = "".__('Symbol').""; - echo "var capsRegex = new RegExp('[^a-zA-Z0-9_]', 'g'); - if (false == capsRegex.test(pwd.val())) { - ".Html::jsGetElementByID('password_need_symbol').".addClass('red'); - ".Html::jsGetElementByID('password_need_symbol').".removeClass('green'); + $needs[] = "".__('Symbol').""; + echo "var capsRegex = new RegExp('[^a-zA-Z0-9_]', 'g'); + if (false == capsRegex.test(pwd.val())) { + ".Html::jsGetElementByID('password_need_symbol').".addClass('red'); + ".Html::jsGetElementByID('password_need_symbol').".removeClass('green'); } else { - ".Html::jsGetElementByID('password_need_symbol').".addClass('green'); - ".Html::jsGetElementByID('password_need_symbol').".removeClass('red'); + ".Html::jsGetElementByID('password_need_symbol').".addClass('green'); + ".Html::jsGetElementByID('password_need_symbol').".removeClass('red'); }"; } } echo "}"; echo ''; if (count($needs)) { - echo "
"; - printf(__('%1$s: %2$s'), __('Password must contains'), implode(', ', $needs)); + echo "
"; + printf(__('%1$s: %2$s'), __('Password must contains'), implode(', ', $needs)); } } @@ -1706,65 +1707,65 @@ static function displayPasswordSecurityChecks($field = 'password') { * @throws PasswordTooWeakException when $display is false and the password does not matches the requirements * * @return boolean is password valid? - **/ + **/ static function validatePassword($password, $display = true) { - global $CFG_GLPI; + global $CFG_GLPI; - $ok = true; - $exception = new PasswordTooWeakException(); - if ($CFG_GLPI["use_password_security"]) { - if (Toolbox::strlen($password) < $CFG_GLPI['password_min_length']) { - $ok = false; - if ($display) { - Session::addMessageAfterRedirect(__('Password too short!'), false, ERROR); + $ok = true; + $exception = new PasswordTooWeakException(); + if ($CFG_GLPI["use_password_security"]) { + if (Toolbox::strlen($password) < $CFG_GLPI['password_min_length']) { + $ok = false; + if ($display) { + Session::addMessageAfterRedirect(__('Password too short!'), false, ERROR); } else { - $exception->addMessage(__('Password too short!')); + $exception->addMessage(__('Password too short!')); } } if ($CFG_GLPI["password_need_number"] && !preg_match("/[0-9]+/", $password)) { - $ok = false; - if ($display) { - Session::addMessageAfterRedirect(__('Password must include at least a digit!'), - false, ERROR); + $ok = false; + if ($display) { + Session::addMessageAfterRedirect(__('Password must include at least a digit!'), + false, ERROR); } else { - $exception->addMessage(__('Password must include at least a digit!')); + $exception->addMessage(__('Password must include at least a digit!')); } } if ($CFG_GLPI["password_need_letter"] && !preg_match("/[a-z]+/", $password)) { - $ok = false; - if ($display) { - Session::addMessageAfterRedirect(__('Password must include at least a lowercase letter!'), - false, ERROR); + $ok = false; + if ($display) { + Session::addMessageAfterRedirect(__('Password must include at least a lowercase letter!'), + false, ERROR); } else { - $exception->addMessage(__('Password must include at least a lowercase letter!')); + $exception->addMessage(__('Password must include at least a lowercase letter!')); } } if ($CFG_GLPI["password_need_caps"] && !preg_match("/[A-Z]+/", $password)) { - $ok = false; - if ($display) { - Session::addMessageAfterRedirect(__('Password must include at least a uppercase letter!'), - false, ERROR); + $ok = false; + if ($display) { + Session::addMessageAfterRedirect(__('Password must include at least a uppercase letter!'), + false, ERROR); } else { - $exception->addMessage(__('Password must include at least a uppercase letter!')); + $exception->addMessage(__('Password must include at least a uppercase letter!')); } } if ($CFG_GLPI["password_need_symbol"] && !preg_match("/\W+/", $password)) { - $ok = false; - if ($display) { - Session::addMessageAfterRedirect(__('Password must include at least a symbol!'), - false, ERROR); + $ok = false; + if ($display) { + Session::addMessageAfterRedirect(__('Password must include at least a symbol!'), + false, ERROR); } else { - $exception->addMessage(__('Password must include at least a symbol!')); + $exception->addMessage(__('Password must include at least a symbol!')); } } } if (!$ok && !$display) { - throw $exception; + throw $exception; } return $ok; } @@ -1776,12 +1777,12 @@ static function validatePassword($password, $display = true) { * - user data cache (apcu / apcu-bc) * * @since 9.1 - **/ + **/ function showPerformanceInformations() { - $GLPI_CACHE = self::getCache('cache_db', 'core', false); + $GLPI_CACHE = self::getCache('cache_db', 'core', false); - if (!Config::canUpdate()) { - return false; + if (!Config::canUpdate()) { + return false; } echo "
"; @@ -1790,28 +1791,28 @@ function showPerformanceInformations() { echo "
" . __('PHP opcode cache') . "
" . sprintf(__('The "%s" extension is installed'), $ext) . "" . phpversion($ext) . "$msg
" . _n('Memory', 'Memories', 1) . "" . sprintf(__('%1$s / %2$s'), $used, $max) . ""; - Html::displayProgressBar('100', $rate, ['simple' => true, - 'forcepadding' => false]); - - $class = 'info-circle missing'; - $msg = sprintf(__s('%1$s memory usage is too low or too high'), $ext); - if ($rate > 5 && $rate < 75) { - $class = 'check-circle ok'; - $msg = sprintf(__s('%1$s memory usage is correct'), $ext); + $msg = sprintf(__s('%s extension is installed'), $ext); + echo "
" . sprintf(__('The "%s" extension is installed'), $ext) . "" . phpversion($ext) . "$msg
" . _n('Memory', 'Memories', 1) . "" . sprintf(__('%1$s / %2$s'), $used, $max) . ""; + Html::displayProgressBar('100', $rate, ['simple' => true, + 'forcepadding' => false]); + + $class = 'info-circle missing'; + $msg = sprintf(__s('%1$s memory usage is too low or too high'), $ext); + if ($rate > 5 && $rate < 75) { + $class = 'check-circle ok'; + $msg = sprintf(__s('%1$s memory usage is correct'), $ext); } echo "
" . __('Hits rate') . "" . sprintf(__('%1$s / %2$s'), $hits, $max) . ""; + " . sprintf(__('%1$s / %2$s'), $hits, $max) . ""; Html::displayProgressBar('100', $rate, ['simple' => true, - 'forcepadding' => false]); + 'forcepadding' => false]); $class = 'info-circle missing'; $msg = sprintf(__s('%1$s hits rate is low'), $ext); if ($rate > 90) { - $class = 'check-circle ok'; - $msg = sprintf(__s('%1$s hits rate is correct'), $ext); + $class = 'check-circle ok'; + $msg = sprintf(__s('%1$s hits rate is correct'), $ext); } echo "
" . __('Out of memory restart') . "$max"; + $max"; $class = 'info-circle missing'; $msg = sprintf(__s('%1$s restart rate is too high'), $ext); if ($max < 2) { - $class = 'check-circle ok'; - $msg = sprintf(__s('%1$s restart rate is correct'), $ext); + $class = 'check-circle ok'; + $msg = sprintf(__s('%1$s restart rate is correct'), $ext); } echo "
"; - echo ''; - echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); - echo Html::hidden('reset_opcache', ['value' => 1]); - echo ''; - echo ''; - echo "
"; + echo '
'; + echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); + echo Html::hidden('reset_opcache', ['value' => 1]); + echo ''; + echo '
'; + echo "
" . sprintf(__('Installing and enabling the "%s" extension may improve ITSM-NG performance'), $ext) . "$msg
" . sprintf(__('Installing and enabling the "%s" extension may improve ITSM-NG performance'), $ext) . "$msg
" . __('User data cache') . "
" . $msg . "" . phpversion($ext) . "$msg
" . phpversion($ext) . "$msg
" . _n('Memory', 'Memories', 1) . "" . sprintf(__('%1$s / %2$s'), $used, $max) . ""; - Html::displayProgressBar('100', $rate, ['simple' => true, - 'forcepadding' => false]); - $class = 'info-circle missing'; - $msg = sprintf(__s('%1$s memory usage is too high'), $ext); - if ($rate < 80) { - $class = 'check-circle ok'; - $msg = sprintf(__s('%1$s memory usage is correct'), $ext); + $free = $GLPI_CACHE->getAvailableSpace(); + $max = $GLPI_CACHE->getTotalSpace(); + $used = $max - $free; + $rate = round(100.0 * $used / $max); + $max = Toolbox::getSize($max); + $used = Toolbox::getSize($used); + + echo "
" . _n('Memory', 'Memories', 1) . "" . sprintf(__('%1$s / %2$s'), $used, $max) . ""; + Html::displayProgressBar('100', $rate, ['simple' => true, + 'forcepadding' => false]); + $class = 'info-circle missing'; + $msg = sprintf(__s('%1$s memory usage is too high'), $ext); + if ($rate < 80) { + $class = 'check-circle ok'; + $msg = sprintf(__s('%1$s memory usage is correct'), $ext); } echo "
"; - echo '
'; - echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); - echo Html::hidden('reset_cache', ['value' => 1]); - echo Html::hidden('optname', ['value' => 'cache_db']); - echo ''; - echo '
'; - echo "
"; + echo '
'; + echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); + echo Html::hidden('reset_cache', ['value' => 1]); + echo Html::hidden('optname', ['value' => 'cache_db']); + echo ''; + echo '
'; + echo "
" . __('Translation cache') . "
" . $msg . "$msg
$msg
"; - echo '
'; - echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); - echo Html::hidden('reset_cache', ['value' => 1]); - echo Html::hidden('optname', ['value' => 'cache_trans']); - echo ''; - echo '
'; - echo "
"; + echo '
'; + echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); + echo Html::hidden('reset_cache', ['value' => 1]); + echo Html::hidden('optname', ['value' => 'cache_trans']); + echo ''; + echo '
'; + echo "
\n"; @@ -1938,10 +1939,10 @@ function showPerformanceInformations() { * Display a HTML report about systeme information / configuration **/ function showSystemInformations() { - global $DB, $CFG_GLPI; + global $DB, $CFG_GLPI; - if (!Config::canUpdate()) { - return false; + if (!Config::canUpdate()) { + return false; } $clear = __('Clear'); @@ -1963,47 +1964,47 @@ function showSystemInformations() { $exts = get_loaded_extensions(); sort($exts); echo wordwrap("PHP ".phpversion().' '.php_sapi_name()." (".implode(', ', $exts).")\n", - $width, "\n\t"); + $width, "\n\t"); $msg = "Setup: "; foreach (['max_execution_time', 'memory_limit', 'post_max_size', 'safe_mode', - 'session.save_handler', 'upload_max_filesize'] as $key) { - $msg .= $key.'="'.ini_get($key).'" '; + 'session.save_handler', 'upload_max_filesize'] as $key) { + $msg .= $key.'="'.ini_get($key).'" '; } echo wordwrap($msg."\n", $width, "\n\t"); $msg = 'Software: '; if (isset($_SERVER["SERVER_SOFTWARE"])) { - $msg .= $_SERVER["SERVER_SOFTWARE"]; + $msg .= $_SERVER["SERVER_SOFTWARE"]; } if (isset($_SERVER["SERVER_SIGNATURE"])) { - $msg .= ' ('.Html::clean($_SERVER["SERVER_SIGNATURE"]).')'; + $msg .= ' ('.Html::clean($_SERVER["SERVER_SIGNATURE"]).')'; } echo wordwrap($msg."\n", $width, "\n\t"); if (isset($_SERVER["HTTP_USER_AGENT"])) { - echo "\t" . Toolbox::clean_cross_side_scripting_deep($_SERVER["HTTP_USER_AGENT"]) . "\n"; + echo "\t" . Toolbox::clean_cross_side_scripting_deep($_SERVER["HTTP_USER_AGENT"]) . "\n"; } foreach ($DB->getInfo() as $key => $val) { - echo "$key: $val\n\t"; + echo "$key: $val\n\t"; } echo "\n"; $core_requirements = (new RequirementsManager())->getCoreRequirementList($DB); /* @var \Glpi\System\Requirement\RequirementInterface $requirement */ foreach ($core_requirements as $requirement) { - if ($requirement->isOutOfContext()) { - continue; // skip requirement if not relevant + if ($requirement->isOutOfContext()) { + continue; // skip requirement if not relevant } $img = $requirement->isValidated() - ? 'ok' - : ($requirement->isOptional() ? 'warning' : 'ko'); + ? 'ok' + : ($requirement->isOptional() ? 'warning' : 'ko'); $messages = Html::entities_deep($requirement->getValidationMessages()); echo '' . implode(' ', $messages) . ''; + . ' alt="' . implode(' ', $messages) . '" title="' . implode(' ', $messages) . '" />'; echo implode("\n", $messages); echo "\n"; @@ -2014,8 +2015,8 @@ function showSystemInformations() { echo "GLPI constants\n"; echo "
\n \n";
       foreach (get_defined_constants() as $constant_name => $constant_value) {
-         if (preg_match('/^GLPI_/', $constant_name)) {
-            echo $constant_name . ': ' . $constant_value . "\n";
+          if (preg_match('/^GLPI_/', $constant_name)) {
+              echo $constant_name . ': ' . $constant_value . "\n";
          }
       }
       echo "\n
"; @@ -2023,22 +2024,22 @@ function showSystemInformations() { self::showLibrariesInformation(); foreach ($CFG_GLPI["systeminformations_types"] as $type) { - $tmp = new $type(); - $tmp->showSystemInformations($width); + $tmp = new $type(); + $tmp->showSystemInformations($width); } Session::loadLanguage($oldlang); $files = array_merge( - glob(GLPI_LOCAL_I18N_DIR."/**/*.php"), - glob(GLPI_LOCAL_I18N_DIR."/**/*.mo") + glob(GLPI_LOCAL_I18N_DIR."/**/*.php"), + glob(GLPI_LOCAL_I18N_DIR."/**/*.mo") ); sort($files); if (count($files)) { - echo "Locales overrides\n"; - echo "\n"; - foreach ($files as $file) { - echo "$file
\n"; + echo "Locales overrides\n"; + echo "\n"; + foreach ($files as $file) { + echo "$file
\n"; } echo ""; } @@ -2051,99 +2052,99 @@ function showSystemInformations() { $serverLogs = ob_get_clean(); $form = [ - 'action' => Toolbox::getItemTypeFormURL(__CLASS__), - 'buttons' => [ - 'submit' => [ - 'type' => 'submit', - 'name' => 'update', - 'value' => _sx('button', 'Save'), - 'class' => 'btn btn-secondary', + 'action' => Toolbox::getItemTypeFormURL(__CLASS__), + 'buttons' => [ + 'submit' => [ + 'type' => 'submit', + 'name' => 'update', + 'value' => _sx('button', 'Save'), + 'class' => 'btn btn-secondary', ], ], 'content' => [ - __('General setup') => [ - 'visible' => true, - 'inputs' => [ - __('Log Level') => [ - 'type' => 'select', - 'name' => 'event_loglevel', - 'values' => [ - 1 => __('1- Critical (login error only)'), - 2 => __('2- Severe (not used)'), - 3 => __('3- Important (successful logins)'), - 4 => __('4- Notices (add, delete, tracking)'), - 5 => __('5- Complete (all)'), + __('General setup') => [ + 'visible' => true, + 'inputs' => [ + __('Log Level') => [ + 'type' => 'select', + 'name' => 'event_loglevel', + 'values' => [ + 1 => __('1- Critical (login error only)'), + 2 => __('2- Severe (not used)'), + 3 => __('3- Important (successful logins)'), + 4 => __('4- Notices (add, delete, tracking)'), + 5 => __('5- Complete (all)'), ], 'value' => $CFG_GLPI["event_loglevel"], ], __('Maximal number of automatic actions (run by CLI)') => [ - 'type' => 'number', - 'name' => 'cron_limit', - 'min' => 1, - 'max' => 30, - 'value' => $CFG_GLPI["cron_limit"], - 'col_lg' => 8, - 'col_md' => 12, + 'type' => 'number', + 'name' => 'cron_limit', + 'min' => 1, + 'max' => 30, + 'value' => $CFG_GLPI["cron_limit"], + 'col_lg' => 8, + 'col_md' => 12, ], __('Logs in files (SQL, email, automatic action...)') => [ - 'type' => 'checkbox', - 'name' => 'use_log_in_files', - 'value' => $CFG_GLPI["use_log_in_files"], - 'col_lg' => 6, + 'type' => 'checkbox', + 'name' => 'use_log_in_files', + 'value' => $CFG_GLPI["use_log_in_files"], + 'col_lg' => 6, ], _n('SQL replica', 'SQL replicas', 1) => [ - 'type' => 'checkbox', - 'name' => 'use_db_slave', - 'value' => DBConnection::isDBSlaveActive(), - 'col_lg' => 6, + 'type' => 'checkbox', + 'name' => 'use_db_slave', + 'value' => DBConnection::isDBSlaveActive(), + 'col_lg' => 6, ], ] ], __('Maintenance mode') => [ - 'visible' => true, - 'inputs' => [ - __('Maintenance mode') => [ - 'type' => 'checkbox', - 'name' => 'maintenance_mode', - 'value' => $CFG_GLPI["maintenance_mode"], + 'visible' => true, + 'inputs' => [ + __('Maintenance mode') => [ + 'type' => 'checkbox', + 'name' => 'maintenance_mode', + 'value' => $CFG_GLPI["maintenance_mode"], ], __('Maintenance text') => [ - 'type' => 'textarea', - 'name' => 'maintenance_text', - 'value' => $CFG_GLPI["maintenance_text"], - 'col_lg' => 8, - 'col_md' => 12, + 'type' => 'textarea', + 'name' => 'maintenance_text', + 'value' => $CFG_GLPI["maintenance_text"], + 'col_lg' => 8, + 'col_md' => 12, ] ] ], __('Proxy configuration for upgrade check') => [ - 'visible' => true, - 'inputs' => [ - __('Server') => [ - 'type' => 'text', - 'name' => 'proxy_name', - 'value' => $CFG_GLPI["proxy_name"], - 'col_lg' => 6, + 'visible' => true, + 'inputs' => [ + __('Server') => [ + 'type' => 'text', + 'name' => 'proxy_name', + 'value' => $CFG_GLPI["proxy_name"], + 'col_lg' => 6, ], __('Port') => [ - 'type' => 'text', - 'name' => 'proxy_port', - 'value' => $CFG_GLPI["proxy_port"], - 'col_lg' => 6, + 'type' => 'text', + 'name' => 'proxy_port', + 'value' => $CFG_GLPI["proxy_port"], + 'col_lg' => 6, ], __('Login') => [ - 'type' => 'text', - 'name' => 'proxy_user', - 'value' => $CFG_GLPI["proxy_user"], - 'col_lg' => 6, + 'type' => 'text', + 'name' => 'proxy_user', + 'value' => $CFG_GLPI["proxy_user"], + 'col_lg' => 6, ], __('Password') => [ - 'type' => 'password', - 'name' => 'proxy_passwd', - 'value' => '', - 'autocomplete' => 'new-password', - 'col_lg' => 6, - 'after' => << 'password', + 'name' => 'proxy_passwd', + 'value' => '', + 'autocomplete' => 'new-password', + 'col_lg' => 6, + 'after' => << HTML, diff --git a/inc/html.class.php b/inc/html.class.php index 5765f6e73a..9b54f52c3e 100755 --- a/inc/html.class.php +++ b/inc/html.class.php @@ -36,7 +36,7 @@ use ScssPhp\ScssPhp\Compiler; if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access this file directly"); + die("Sorry. You can't access this file directly"); } /** @@ -45,54 +45,54 @@ **/ class Html { - static private $css = [ - 'vendor/wenzhixin/bootstrap-table/dist/bootstrap-table.min.css', - 'css/bootstrap-select.min.css', - 'node_modules/@jarstone/dselect/dist/css/dselect.min.css', - "node_modules/jquery-ui-dist/jquery-ui.min.css", - 'node_modules/@fortawesome/fontawesome-free/css/all.css', - 'css/jstree-glpi.css', + static private $css = [ + 'vendor/wenzhixin/bootstrap-table/dist/bootstrap-table.min.css', + 'css/bootstrap-select.min.css', + 'node_modules/@jarstone/dselect/dist/css/dselect.min.css', + "node_modules/jquery-ui-dist/jquery-ui.min.css", + 'node_modules/@fortawesome/fontawesome-free/css/all.css', + 'css/jstree-glpi.css', ]; - static private $scss = [ - 'css/styles', - 'css/itsm2.scss', + static private $scss = [ + 'css/styles', + 'css/itsm2.scss', ]; - static private $js = [ - "node_modules/jquery-ui-dist/jquery-ui.min.js", - "vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js", - "node_modules/tableexport.jquery.plugin/tableExport.min.js", - "vendor/wenzhixin/bootstrap-table/dist/bootstrap-table.min.js", - "vendor/wenzhixin/bootstrap-table/src/extensions/export/bootstrap-table-export.js", - "node_modules/@jarstone/dselect/dist/js/dselect.min.js", - "src/ngFunctions.js", + static private $js = [ + "node_modules/jquery-ui-dist/jquery-ui.min.js", + "vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js", + "node_modules/tableexport.jquery.plugin/tableExport.min.js", + "vendor/wenzhixin/bootstrap-table/dist/bootstrap-table.min.js", + "vendor/wenzhixin/bootstrap-table/src/extensions/export/bootstrap-table-export.js", + "node_modules/@jarstone/dselect/dist/js/dselect.min.js", + "src/ngFunctions.js", ]; - static private function getFilePath($file, $isScss = false) - { - global $CFG_GLPI; - return $CFG_GLPI['root_doc'] . ($isScss ? '/front/css.php?file=' : '/') . $file; + static private function getFilePath($file, $isScss = false) + { + global $CFG_GLPI; + return $CFG_GLPI['root_doc'] . ($isScss ? '/front/css.php?file=' : '/') . $file; } static public function getCss() { - $allCss = []; - foreach (self::$css as $file) { - $allCss[] = self::getFilePath($file); + $allCss = []; + foreach (self::$css as $file) { + $allCss[] = self::getFilePath($file); } foreach (self::$scss as $file) { - $allCss[] = self::getFilePath($file, true); + $allCss[] = self::getFilePath($file, true); } return $allCss; } static public function getJs() { - $allJs = []; - foreach (self::$js as $file) { - $allJs[] = self::getFilePath($file); + $allJs = []; + foreach (self::$js as $file) { + $allJs[] = self::getFilePath($file); } return $allJs; } @@ -109,39 +109,39 @@ static public function getJs() **/ static function clean($value, $striptags = true, $keep_bad = 2) { - $value = Html::entity_decode_deep($value); + $value = Html::entity_decode_deep($value); - // Change to email@domain so it is not removed by htmLawed - // Search for strings that is an email surrounded by `<` and `>` but that cannot be an HTML tag: - // - absence of quotes indicate that values is not part of an HTML attribute, - // - absence of > ensure that ending `>` has not been reached. - $regex = "/(<[^\"'>]+?@[^>\"']+?>)/"; - $value = preg_replace_callback($regex, function ($matches) { - return substr($matches[1], 1, (strlen($matches[1]) - 2)); + // Change to email@domain so it is not removed by htmLawed + // Search for strings that is an email surrounded by `<` and `>` but that cannot be an HTML tag: + // - absence of quotes indicate that values is not part of an HTML attribute, + // - absence of > ensure that ending `>` has not been reached. + $regex = "/(<[^\"'>]+?@[^>\"']+?>)/"; + $value = preg_replace_callback($regex, function ($matches) { + return substr($matches[1], 1, (strlen($matches[1]) - 2)); }, $value); // Clean MS office tags $value = str_replace(["", ""], '', $value); if ($striptags) { - // Strip ToolTips - $specialfilter = [ - '@]*?tooltip_picture[^>]*?>.*?]*?>@si', - '@]*?tooltip_text[^>]*?>.*?]*?>@si', - '@]*?tooltip_picture_border[^>]*?>.*?]*?>@si', - '@]*?invisible[^>]*?>.*?]*?>@si' + // Strip ToolTips + $specialfilter = [ + '@]*?tooltip_picture[^>]*?>.*?]*?>@si', + '@]*?tooltip_text[^>]*?>.*?]*?>@si', + '@]*?tooltip_picture_border[^>]*?>.*?]*?>@si', + '@]*?invisible[^>]*?>.*?]*?>@si' ]; - $value = preg_replace($specialfilter, '', $value); + $value = preg_replace($specialfilter, '', $value); - $value = preg_replace("/<(p|br|div)( [^>]*)?" . ">/i", "\n", $value); - $value = preg_replace("/( | |\xC2\xA0)+/", " ", $value); + $value = preg_replace("/<(p|br|div)( [^>]*)?" . ">/i", "\n", $value); + $value = preg_replace("/( | |\xC2\xA0)+/", " ", $value); } $search = [ - '@]*?>.*?]*?>@si', // Strip out javascript - '@]*?>.*?]*?>@si', // Strip out style - '@]*?>.*?]*?>@si', // Strip out title - '@]*?>@si', // Strip out !DOCTYPE + '@]*?>.*?]*?>@si', // Strip out javascript + '@]*?>.*?]*?>@si', // Strip out style + '@]*?>.*?]*?>@si', // Strip out title + '@]*?>@si', // Strip out !DOCTYPE ]; $value = preg_replace($search, '', $value); @@ -151,7 +151,7 @@ static function clean($value, $striptags = true, $keep_bad = 2) $config = Toolbox::getHtmLawedSafeConfig(); $config['keep_bad'] = $keep_bad; // 1: neutralize tag and content, 2 : remove tag and neutralize content if ($striptags) { - $config['elements'] = 'none'; + $config['elements'] = 'none'; } $value = htmLawed($value, $config); @@ -159,10 +159,10 @@ static function clean($value, $striptags = true, $keep_bad = 2) // Special case : remove the 'denied:' for base64 img in case the base64 have characters // combinaison introduce false positive foreach (['png', 'gif', 'jpg', 'jpeg'] as $imgtype) { - $value = str_replace( - 'src="denied:data:image/' . $imgtype . ';base64,', - 'src="data:image/' . $imgtype . ';base64,', - $value + $value = str_replace( + 'src="denied:data:image/' . $imgtype . ';base64,', + 'src="data:image/' . $imgtype . ';base64,', + $value ); } @@ -183,8 +183,8 @@ static function clean($value, $striptags = true, $keep_bad = 2) static function entity_decode_deep($value) { - return (is_array($value) ? array_map([__CLASS__, 'entity_decode_deep'], $value) - : html_entity_decode($value, ENT_QUOTES, "UTF-8")); + return (is_array($value) ? array_map([__CLASS__, 'entity_decode_deep'], $value) + : html_entity_decode($value, ENT_QUOTES, "UTF-8")); } @@ -198,8 +198,8 @@ static function entity_decode_deep($value) static function entities_deep($value) { - return (is_array($value) ? array_map([__CLASS__, 'entities_deep'], $value) - : htmlentities($value, ENT_QUOTES, "UTF-8")); + return (is_array($value) ? array_map([__CLASS__, 'entities_deep'], $value) + : htmlentities($value, ENT_QUOTES, "UTF-8")); } @@ -216,39 +216,39 @@ static function entities_deep($value) static function convDate($time, $format = null) { - if (is_null($time) || trim($time) == '' || in_array($time, ['NULL', '0000-00-00', '0000-00-00 00:00:00'])) { - return null; + if (is_null($time) || trim($time) == '' || in_array($time, ['NULL', '0000-00-00', '0000-00-00 00:00:00'])) { + return null; } if (!isset($_SESSION["glpidate_format"])) { - $_SESSION["glpidate_format"] = 0; + $_SESSION["glpidate_format"] = 0; } if (!$format) { - $format = $_SESSION["glpidate_format"]; + $format = $_SESSION["glpidate_format"]; } try { - $date = new \DateTime($time); + $date = new \DateTime($time); } catch (\Exception $e) { - Toolbox::logWarning("Invalid date $time!"); - Session::addMessageAfterRedirect( - sprintf( - __('%1$s %2$s'), - $time, - _x('adjective', 'Invalid') + Toolbox::logWarning("Invalid date $time!"); + Session::addMessageAfterRedirect( + sprintf( + __('%1$s %2$s'), + $time, + _x('adjective', 'Invalid') ) ); - return $time; + return $time; } $mask = 'Y-m-d'; switch ($format) { - case 1: // DD-MM-YYYY - $mask = 'd-m-Y'; - break; - case 2: // MM-DD-YYYY - $mask = 'm-d-Y'; - break; + case 1: // DD-MM-YYYY + $mask = 'd-m-Y'; + break; + case 2: // MM-DD-YYYY + $mask = 'm-d-Y'; + break; } return $date->format($mask); @@ -266,8 +266,8 @@ static function convDate($time, $format = null) static function convDateTime($time, $format = null) { - if (is_null($time) || ($time == 'NULL')) { - return null; + if (is_null($time) || ($time == 'NULL')) { + return null; } return self::convDate($time, $format) . ' ' . substr($time, 11, 5); @@ -283,7 +283,7 @@ static function convDateTime($time, $format = null) **/ static function cleanInputText($string) { - return preg_replace('/\'/', ''', preg_replace('/\"/', '"', $string ?? '')); + return preg_replace('/\'/', ''', preg_replace('/\"/', '"', $string ?? '')); } @@ -297,8 +297,8 @@ static function cleanInputText($string) static function cleanParametersURL($url) { - $url = preg_replace("/(\/[0-9a-zA-Z\.\-\_]+\.php).*/", "$1", $url); - return preg_replace("/\?.*/", "", $url); + $url = preg_replace("/(\/[0-9a-zA-Z\.\-\_]+\.php).*/", "$1", $url); + return preg_replace("/\?.*/", "", $url); } @@ -312,8 +312,8 @@ static function cleanParametersURL($url) static function nl2br_deep($value) { - return (is_array($value) ? array_map([__CLASS__, 'nl2br_deep'], $value) - : nl2br($value)); + return (is_array($value) ? array_map([__CLASS__, 'nl2br_deep'], $value) + : nl2br($value)); } @@ -328,8 +328,8 @@ static function nl2br_deep($value) static function resume_text($string, $length = 255) { - if (Toolbox::strlen($string) > $length) { - $string = Toolbox::substr($string, 0, $length) . " (...)"; + if (Toolbox::strlen($string) > $length) { + $string = Toolbox::substr($string, 0, $length) . " (...)"; } return $string; @@ -347,8 +347,8 @@ static function resume_text($string, $length = 255) static function resume_name($string, $length = 255) { - if (strlen($string) > $length) { - $string = Toolbox::substr($string, 0, $length) . "..."; + if (strlen($string) > $length) { + $string = Toolbox::substr($string, 0, $length) . "..."; } return $string; @@ -365,25 +365,25 @@ static function resume_name($string, $length = 255) static function cleanPostForTextArea($value) { - if (is_array($value)) { - $methodName = __METHOD__; - return array_map(function($item) use ($methodName) { - return $methodName($item); + if (is_array($value)) { + $methodName = __METHOD__; + return array_map(function($item) use ($methodName) { + return $methodName($item); }, $value); } $order = [ - '\r\n', - '\n', - "\\'", - '\"', - '\\\\' + '\r\n', + '\n', + "\\'", + '\"', + '\\\\' ]; $replace = [ - "\n", - "\n", - "'", - '"', - "\\" + "\n", + "\n", + "'", + '"', + "\\" ]; return str_replace($order, $replace, $value); } @@ -400,42 +400,42 @@ static function cleanPostForTextArea($value) **/ static function formatNumber($number, $edit = false, $forcedecimal = -1) { - global $CFG_GLPI; + global $CFG_GLPI; - // Php 5.3 : number_format() expects parameter 1 to be double, - if ($number == "") { - $number = 0; + // Php 5.3 : number_format() expects parameter 1 to be double, + if ($number == "") { + $number = 0; } else if ($number == "-") { // used for not defines value (from Infocom::Amort, p.e.) - return "-"; + return "-"; } $number = doubleval($number); $decimal = $CFG_GLPI["decimal_number"]; if ($forcedecimal >= 0) { - $decimal = $forcedecimal; + $decimal = $forcedecimal; } // Edit : clean display for mysql if ($edit) { - return number_format($number, $decimal, '.', ''); + return number_format($number, $decimal, '.', ''); } // Display : clean display switch ($_SESSION['glpinumber_format']) { - case 0: // French - return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); + case 0: // French + return str_replace(' ', ' ', number_format($number, $decimal, '.', ' ')); - case 2: // Other French - return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); + case 2: // Other French + return str_replace(' ', ' ', number_format($number, $decimal, ',', ' ')); - case 3: // No space with dot - return number_format($number, $decimal, '.', ''); + case 3: // No space with dot + return number_format($number, $decimal, '.', ''); - case 4: // No space with comma - return number_format($number, $decimal, ',', ''); + case 4: // No space with comma + return number_format($number, $decimal, ',', ''); - default: // English - return number_format($number, $decimal, '.', ','); + default: // English + return number_format($number, $decimal, '.', ','); } } @@ -452,61 +452,61 @@ static function formatNumber($number, $edit = false, $forcedecimal = -1) static function timestampToString($time, $display_sec = true, $use_days = true) { - $time = (float)$time; + $time = (float)$time; - $sign = ''; - if ($time < 0) { - $sign = '- '; - $time = abs($time); + $sign = ''; + if ($time < 0) { + $sign = '- '; + $time = abs($time); } $time = floor($time); // Force display seconds if time is null if ($time < MINUTE_TIMESTAMP) { - $display_sec = true; + $display_sec = true; } $units = Toolbox::getTimestampTimeUnits($time); if ($use_days) { - if ($units['day'] > 0) { - if ($display_sec) { - //TRANS: %1$s is the sign (-or empty), %2$d number of days, %3$d number of hours, - // %4$d number of minutes, %5$d number of seconds - return sprintf( - __('%1$s%2$d days %3$d hours %4$d minutes %5$d seconds'), - $sign, - $units['day'], - $units['hour'], - $units['minute'], - $units['second'] + if ($units['day'] > 0) { + if ($display_sec) { + //TRANS: %1$s is the sign (-or empty), %2$d number of days, %3$d number of hours, + // %4$d number of minutes, %5$d number of seconds + return sprintf( + __('%1$s%2$d days %3$d hours %4$d minutes %5$d seconds'), + $sign, + $units['day'], + $units['hour'], + $units['minute'], + $units['second'] ); } //TRANS: %1$s is the sign (-or empty), %2$d number of days, %3$d number of hours, // %4$d number of minutes return sprintf( - __('%1$s%2$d days %3$d hours %4$d minutes'), - $sign, - $units['day'], - $units['hour'], - $units['minute'] + __('%1$s%2$d days %3$d hours %4$d minutes'), + $sign, + $units['day'], + $units['hour'], + $units['minute'] ); } } else { - if ($units['day'] > 0) { - $units['hour'] += 24 * $units['day']; + if ($units['day'] > 0) { + $units['hour'] += 24 * $units['day']; } } if ($units['hour'] > 0) { - if ($display_sec) { - //TRANS: %1$s is the sign (-or empty), %2$d number of hours, %3$d number of minutes, - // %4$d number of seconds - return sprintf( - __('%1$s%2$d hours %3$d minutes %4$d seconds'), - $sign, - $units['hour'], - $units['minute'], - $units['second'] + if ($display_sec) { + //TRANS: %1$s is the sign (-or empty), %2$d number of hours, %3$d number of minutes, + // %4$d number of seconds + return sprintf( + __('%1$s%2$d hours %3$d minutes %4$d seconds'), + $sign, + $units['hour'], + $units['minute'], + $units['second'] ); } //TRANS: %1$s is the sign (-or empty), %2$d number of hours, %3$d number of minutes @@ -514,29 +514,29 @@ static function timestampToString($time, $display_sec = true, $use_days = true) } if ($units['minute'] > 0) { - if ($display_sec) { - //TRANS: %1$s is the sign (-or empty), %2$d number of minutes, %3$d number of seconds - return sprintf( - __('%1$s%2$d minutes %3$d seconds'), - $sign, - $units['minute'], - $units['second'] + if ($display_sec) { + //TRANS: %1$s is the sign (-or empty), %2$d number of minutes, %3$d number of seconds + return sprintf( + __('%1$s%2$d minutes %3$d seconds'), + $sign, + $units['minute'], + $units['second'] ); } //TRANS: %1$s is the sign (-or empty), %2$d number of minutes return sprintf( - _n('%1$s%2$d minute', '%1$s%2$d minutes', $units['minute']), - $sign, - $units['minute'] + _n('%1$s%2$d minute', '%1$s%2$d minutes', $units['minute']), + $sign, + $units['minute'] ); } if ($display_sec) { - //TRANS: %1$s is the sign (-or empty), %2$d number of seconds - return sprintf( - _n('%1$s%2$s second', '%1$s%2$s seconds', $units['second']), - $sign, - $units['second'] + //TRANS: %1$s is the sign (-or empty), %2$d number of seconds + return sprintf( + _n('%1$s%2$s second', '%1$s%2$s seconds', $units['second']), + $sign, + $units['second'] ); } return ''; @@ -553,22 +553,22 @@ static function timestampToString($time, $display_sec = true, $use_days = true) static function timestampToCsvString($time) { - if ($time < 0) { - $time = abs($time); + if ($time < 0) { + $time = abs($time); } $time = floor($time); $units = Toolbox::getTimestampTimeUnits($time); if ($units['day'] > 0) { - $units['hour'] += 24 * $units['day']; + $units['hour'] += 24 * $units['day']; } return str_pad($units['hour'], 2, '0', STR_PAD_LEFT) - . ':' - . str_pad($units['minute'], 2, '0', STR_PAD_LEFT) - . ':' - . str_pad($units['second'], 2, '0', STR_PAD_LEFT); + . ':' + . str_pad($units['minute'], 2, '0', STR_PAD_LEFT) + . ':' + . str_pad($units['second'], 2, '0', STR_PAD_LEFT); } @@ -582,8 +582,8 @@ static function timestampToCsvString($time) static function weblink_extract($value) { - $value = preg_replace('/]*>[^<]*<\/a>/i', "$1", $value); - return $value; + $value = preg_replace('/]*>[^<]*<\/a>/i', "$1", $value); + return $value; } @@ -594,7 +594,7 @@ static function weblink_extract($value) **/ static function back() { - self::redirect(self::getBackUrl()); + self::redirect(self::getBackUrl()); } @@ -609,26 +609,26 @@ static function back() static function redirect($dest, $http_response_code = 302) { - $toadd = ''; - $dest = addslashes($dest); + $toadd = ''; + $dest = addslashes($dest); - if (!headers_sent() && !Toolbox::isAjax()) { - header("Location: $dest", true, $http_response_code); - exit(); + if (!headers_sent() && !Toolbox::isAjax()) { + header("Location: $dest", true, $http_response_code); + exit(); } if (strpos($dest, "?") !== false) { - $toadd = '&tokonq=' . Toolbox::getRandomString(5); + $toadd = '&tokonq=' . Toolbox::getRandomString(5); } else { - $toadd = '?tokonq=' . Toolbox::getRandomString(5); + $toadd = '?tokonq=' . Toolbox::getRandomString(5); } echo ""; exit(); @@ -1913,7 +1913,10 @@ static function header($title, $url = '', $sector = "none", $item = "none", $opt . "/front/" . (Session::getCurrentInterface() == 'central' ? 'central' : 'helpdesk.public') . ".php"); $twig_vars['profileSelect'] = ob_get_clean(); - $twig_vars['accessibilityMenu'] = Session::haveRight("accessibility", READ); + + $user = new User(); + $user->getFromDB(Session::getLoginUserID()); + $twig_vars['accessibilityMenu'] = $user->fields['accessibility_menu']; $twig_vars['username'] = getUserName(Session::getLoginUserID()); $twig_vars['main_menu']['args']['access'] = Session::getCurrentInterface(); @@ -7000,12 +7003,12 @@ static function fuzzySearch($action = '') } /** - * Manage the shortcut js/hotkeys.js - * - * - */ + * Manage the shortcut js/hotkeys.js + * + * + */ - static function hotkeys(){ + static function hotkeys(){ global $CFG_GLPI; $user = new User(); @@ -7025,7 +7028,7 @@ static function hotkeys(){ } } - } + } /** * Return Twig ITSM "bottom" (help, parameters, logout) menu diff --git a/inc/log.class.php b/inc/log.class.php index ffc5db6ecb..d1bb57d1f4 100644 --- a/inc/log.class.php +++ b/inc/log.class.php @@ -225,8 +225,8 @@ static function history ($items_id, $itemtype, $changes, $itemtype_link = '', $l ); } - $old_value = $DB->escape(Toolbox::substr(stripslashes($old_value), 0, 180)); - $new_value = $DB->escape(Toolbox::substr(stripslashes($new_value), 0, 180)); + $old_value = Toolbox::substr(stripslashes($old_value), 0, 180); + $new_value = Toolbox::substr(stripslashes($new_value), 0, 180); // Security to be sure that values do not pass over the max length if (Toolbox::strlen($old_value) > 255) { @@ -236,6 +236,9 @@ static function history ($items_id, $itemtype, $changes, $itemtype_link = '', $l $new_value = Toolbox::substr($new_value, 0, 250); } + $old_value = $DB->escape($old_value); + $new_value = $DB->escape($new_value); + $params = [ 'items_id' => $items_id, 'itemtype' => $itemtype, diff --git a/inc/oidc.class.php b/inc/oidc.class.php index d91147a7f0..a3ceec17ae 100644 --- a/inc/oidc.class.php +++ b/inc/oidc.class.php @@ -164,7 +164,7 @@ static function auth() Session::init($auth); $_SESSION['itsm_is_oidc'] = 1; $_SESSION['itsm_oidc_idtoken'] = $oidc->getIdToken(); - Auth::redirectIfAuthenticated($_REQUEST['redirect']); + Auth::redirectIfAuthenticated($_REQUEST['redirect'] ?? null); } /** diff --git a/inc/search.class.php b/inc/search.class.php index bd3c26f252..ba78b61939 100644 --- a/inc/search.class.php +++ b/inc/search.class.php @@ -723,6 +723,9 @@ static function constructSQL(array &$data) { $numrows = 0; //No search : count number of items using a simple count(ID) request and LIMIT search if ($data['search']['no_search']) { + if ($data['search']['list_limit'] == 0) { + $data['search']['list_limit'] = '18446744073709551615'; + } $LIMIT = " LIMIT ".(int)$data['search']['start'].", ".(int)$data['search']['list_limit']; $count = "count(DISTINCT `$itemtable`.`id`)"; diff --git a/install/itsm_update_151_200.php b/install/itsm_update_151_200.php index e0cbdf7d77..351ebd5a31 100644 --- a/install/itsm_update_151_200.php +++ b/install/itsm_update_151_200.php @@ -45,39 +45,24 @@ function update151to200() : bool { $migration->displayTitle(sprintf(__('Update to %s'), '2.0.0_rc3')); $migration->setVersion('2.0.0_rc3'); - if(!$DB->fieldExists('glpi_users', 'menu_favorite')) { - $query = "alter table glpi_users add column menu_favorite longtext default '{}';"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); + $userModifications = [ + 'menu_favorite' => "longtext default '{}'", + 'menu_favorite_on' => "text default '1'", + 'menu_position' => "text default 'menu-left'", + 'menu_small' => "text default 'false'", + 'menu_width' => "text default 'null'", + 'menu_open' => "longtext default '[]'", + 'bubble_pos' => "text default 'null'", + 'accessibility_menu' => "tinyint(1) default '0'", + ]; + foreach ($userModifications as $field => $definition) { + if (!$DB->fieldExists('glpi_users', $field)) { + $migration->addField('glpi_users', $field, $definition); + } } - if(!$DB->fieldExists('glpi_users', 'menu_favorite_on')) { - $query = "alter table glpi_users add column menu_favorite_on text default '1';"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); - } - - if(!$DB->fieldExists('glpi_users', 'menu_position')) { - $query = "alter table glpi_users add column menu_position text default 'menu-left';"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); - } - - if(!$DB->fieldExists('glpi_users', 'menu_small')) { - $query = "alter table glpi_users add column menu_small text default 'false';"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); - } - - if(!$DB->fieldExists('glpi_users', 'menu_width')) { - $query = "alter table glpi_users add column menu_width text default 'null';"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); - } - - if(!$DB->fieldExists('glpi_users', 'menu_open')) { - $query = "alter table glpi_users add column menu_open longtext default '[]';"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); - } - - if(!$DB->fieldExists('glpi_users', 'bubble_pos')) { - $query = "alter table glpi_users add column bubble_pos text default NULL;"; - $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_users".$DB->error()); + if (!$DB->fieldExists('glpi_oidc_config', $field)) { + $migration->addField('glpi_oidc_config', 'logout', 'VARCHAR(255) NULL'); } if (!$DB->tableExists('glpi_user_menu')) { @@ -106,10 +91,6 @@ function update151to200() : bool { $DB->queryOrDie($query, "erreur lors de la mise a jour de la table de glpi_dashboards".$DB->error()); } - if (!$DB->fieldExists('glpi_oidc_config', 'logout')) { - $migration->addField('glpi_oidc_config', 'logout', 'VARCHAR(255) NULL'); - } - // ************ Keep it at the end ************** $migration->executeMigration(); return $updateresult; diff --git a/locales/glpi.pot b/locales/glpi.pot index 7c5b14a24e..41ad89aa46 100644 --- a/locales/glpi.pot +++ b/locales/glpi.pot @@ -21853,4 +21853,8 @@ msgstr "" #: inc/includes.php:155 msgid "CSRF token is invalid" -msgstr "" \ No newline at end of file +msgstr "" + +#: inc/config.class.php:1252 +msgid "Acessibility menu" +msgstr "" diff --git a/src/dashboard/dashboard.ajax.php b/src/dashboard/dashboard.ajax.php index 0f5670441e..befb3d608a 100644 --- a/src/dashboard/dashboard.ajax.php +++ b/src/dashboard/dashboard.ajax.php @@ -38,7 +38,7 @@ if ($_REQUEST['action'] == 'preview' && isset($_REQUEST['dataFilters'])) { Session::checkRight("dashboard", READ); $dataFilters = json_decode(stripslashes($_REQUEST['dataFilters'] ?? '[]'), true); - echo json_encode(Search::getDatas($dataFilters['itemtype'], $dataFilters + ['list_limit' => 9999999])); // TODO make this limit dynamic + echo json_encode(Search::getDatas($dataFilters['itemtype'], $dataFilters + ['list_limit' => 0])); } else if (($_REQUEST['action'] == 'delete') && isset($_REQUEST['coords']) && isset($_REQUEST['id'])) { Session::checkRight("dashboard", UPDATE); $dashboard = new Dashboard();