Commit 121238a8 authored by Johan Cwiklinski's avatar Johan Cwiklinski

Merge branch '9.5/bugfixes'

parents 7b0cb0ed fca1a4a2
......@@ -95,6 +95,10 @@ The present file will list all changes made to the project; according to the
- `Reservation::displayReservationDay()`
- `Reservation::displayReservationsForAnItem()`
## [9.5.3] 2020-11-25
### Deprecated
- Usage of alternative DB connection encoding (`DB::$dbenc` property).
## [9.5.2] 2020-10-07
......
......@@ -1192,6 +1192,16 @@ class CommonGLPI {
function display($options = []) {
global $CFG_GLPI;
// Init active tab to main if not defined
if (!isset($_SESSION['glpi_tabs'][self::getType()])) {
// TODO: use array_key_first when php 7.3 is supported
$tabs = array_keys($this->defineTabs());
$first_tab = array_shift($tabs);
if ($first_tab) {
Session::setActiveTab(self::getType(), $first_tab);
}
}
if (isset($options['id'])
&& !$this->isNewID($options['id'])) {
if (!$this->getFromDB($options['id'])) {
......
......@@ -71,6 +71,7 @@ class TimestampsCommand extends AbstractCommand {
],
'WHERE' => [
'information_schema.columns.table_schema' => $this->db->dbdefault,
'information_schema.columns.table_name' => ['LIKE', 'glpi_%'],
'information_schema.columns.data_type' => 'datetime'
],
'ORDER' => [
......
......@@ -150,7 +150,7 @@ JAVASCRIPT;
}
static function group_tech(string $value = "0"): string {
return self::dropdown($value, 'group_tech', Group::class);
return self::dropdown($value, 'group_tech', Group::class, ['toadd' => [-1 => __("My groups")]]);
}
static function user_tech(string $value = "0"): string {
......@@ -195,7 +195,6 @@ JAVASCRIPT;
return $js.self::field($fieldname, $field, $label, $value > 0);
}
/**
* Get generic HTML for a filter
*
......
......@@ -1290,36 +1290,44 @@ class Provider extends CommonGLPI {
];
}
if (isset($apply_filters['group_tech'])
&& (int) $apply_filters['group_tech'] > 0) {
if (isset($apply_filters['group_tech'])) {
if ($DB->fieldExists($table, 'groups_id_tech')) {
$where += [
"$table.groups_id_tech" => (int) $apply_filters['group_tech']
];
} else if (in_array($table, [
Ticket::getTable(),
Change::getTable(),
Problem::getTable(),
])) {
$itemtype = getItemTypeForTable($table);
$main_item = getItemForItemtype($itemtype);
$grouplink = $main_item->grouplinkclass;
$gl_table = $grouplink::getTable();
$fk = $main_item->getForeignKeyField();
$groups_id = null;
if ((int) $apply_filters['group_tech'] > 0) {
$groups_id = (int) $apply_filters['group_tech'];
} else if ((int) $apply_filters['group_tech'] == -1) {
$groups_id = $_SESSION['glpigroups'];
}
$join += [
"$gl_table as gl" => [
'ON' => [
'gl' => $fk,
$table => 'id',
if ($groups_id != null) {
if ($DB->fieldExists($table, 'groups_id_tech')) {
$where += [
"$table.groups_id_tech" => $groups_id
];
} else if (in_array($table, [
Ticket::getTable(),
Change::getTable(),
Problem::getTable(),
])) {
$itemtype = getItemTypeForTable($table);
$main_item = getItemForItemtype($itemtype);
$grouplink = $main_item->grouplinkclass;
$gl_table = $grouplink::getTable();
$fk = $main_item->getForeignKeyField();
$join += [
"$gl_table as gl" => [
'ON' => [
'gl' => $fk,
$table => 'id',
]
]
]
];
$where += [
"gl.type" => \CommonITILActor::ASSIGN,
"gl.groups_id" => (int) $apply_filters['group_tech']
];
];
$where += [
"gl.type" => \CommonITILActor::ASSIGN,
"gl.groups_id" => $groups_id
];
}
}
}
......@@ -1367,7 +1375,6 @@ class Provider extends CommonGLPI {
return $criteria;
}
private static function getDatesCriteria(string $field = "", array $dates = []): array {
$begin = strtotime($dates[0]);
$end = strtotime($dates[1]);
......
......@@ -198,6 +198,9 @@ class DBmysql {
$this->connected = false;
$this->error = 2;
} else {
if (isset($this->dbenc)) {
Toolbox::deprecated('Usage of alternative DB connection encoding (`DB::$dbenc` property) is deprecated.');
}
$dbenc = isset($this->dbenc) ? $this->dbenc : "utf8";
$this->dbh->set_charset($dbenc);
if ($dbenc === "utf8") {
......@@ -1467,8 +1470,9 @@ class DBmysql {
'COUNT' => 'cpt',
'FROM' => 'information_schema.columns',
'WHERE' => [
'information_schema.columns.table_schema' => $DB->dbdefault,
'information_schema.columns.data_type' => ['datetime']
'information_schema.columns.table_schema' => $DB->dbdefault,
'information_schema.columns.table_name' => ['LIKE', 'glpi_%'],
'information_schema.columns.data_type' => ['datetime']
]
])->next();
return (int)$result['cpt'];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment