Commit c7d1d24f authored by Johan Cwiklinski's avatar Johan Cwiklinski

Merge branch '9.4/bugfixes' into 9.5/bugfixes

parents a73f4b3f e0ace969
......@@ -518,7 +518,7 @@ $ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/71?expand_drodpowns=true'
'http://path/to/glpi/apirest.php/Computer/71?expand_dropdowns=true'
< 200 OK
< {
......@@ -613,9 +613,9 @@ $ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/?expand_drodpowns=true'
'http://path/to/glpi/apirest.php/Computer/?expand_dropdowns=true'
< 200 OK
< 206 OK
< Content-Range: 0-50/200
< Accept-Range: 990
< [
......
......@@ -240,14 +240,18 @@ class APIRest extends API {
$range = [0, $_SESSION['glpilist_limit']];
if (isset($this->parameters['range'])) {
$range = explode("-", $this->parameters['range']);
// fix end range
if ($range[1] > $totalcount - 1) {
$range[1] = $totalcount - 1;
}
if ($range[1] - $range[0] + 1 < $totalcount) {
$code = 206; // partial content
}
}
// fix end range
if ($range[1] > $totalcount - 1) {
$range[1] = $totalcount - 1;
}
// trigger partial content return code
if ($range[1] - $range[0] + 1 < $totalcount) {
$code = 206; // partial content
}
$additionalheaders["Accept-Range"] = $itemtype." ".Toolbox::get_max_input_vars();
if ($totalcount > 0) {
$additionalheaders["Content-Range"] = implode('-', $range)."/".$totalcount;
......
......@@ -176,14 +176,18 @@ class APIXmlrpc extends API {
$range = [0, $_SESSION['glpilist_limit']];
if (isset($this->parameters['range'])) {
$range = explode("-", $this->parameters['range']);
// fix end range
if ($range[1] > $totalcount - 1) {
$range[1] = $totalcount - 1;
}
if ($range[1] - $range[0] + 1 < $totalcount) {
$code = 206; // partial content
}
}
// fix end range
if ($range[1] > $totalcount - 1) {
$range[1] = $totalcount - 1;
}
// trigger partial content return code
if ($range[1] - $range[0] + 1 < $totalcount) {
$code = 206; // partial content
}
$additionalheaders = [];
$additionalheaders["Accept-Range"] = $this->parameters['itemtype']." ".
Toolbox::get_max_input_vars();
......
......@@ -4220,6 +4220,14 @@ class CommonDBTM extends CommonGLPI {
* @return string the string to display
**/
static function getSpecificValueToDisplay($field, $values, array $options = []) {
switch ($field) {
case '_virtual_datacenter_position':
if (method_exists(static::class, 'getDcBreadcrumbSpecificValueToDisplay')) {
return static::getDcBreadcrumbSpecificValueToDisplay($values['id']);
}
}
return '';
}
......
......@@ -769,6 +769,8 @@ class Computer extends CommonDBTM {
$tab = array_merge($tab, ComputerAntivirus::rawSearchOptionsToAdd());
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
......
......@@ -139,6 +139,29 @@ class Datacenter extends CommonDBTM {
return $tab;
}
static public function rawSearchOptionsToAdd($itemtype) {
return [
[
'id' => 'datacenter',
'name' => _n('Data center', 'Data centers', Session::getPluralNumber())
],
[
'id' => '175',
'table' => $itemtype::getTable(),
'field' => '_virtual_datacenter_position', // virtual field
'additionalfields' => [
'id',
'name'
],
'name' => __('Data center position'),
'datatype' => 'specific',
'nosearch' => true,
'massiveaction' => false
],
];
}
static function getAdditionalMenuLinks() {
$links = [];
if (static::canView()) {
......
......@@ -40,12 +40,11 @@ if (!defined('GLPI_ROOT')) {
trait DCBreadcrumb {
/**
* Display datacenter element breadcrumb
* @see CommonGLPI::showNavigationHeader()
* Get datacenter element breadcrumb
*
* @return void
* @return array
*/
function showDcBreadcrumb() {
protected function getDcBreadcrumb() {
global $CFG_GLPI;
$item = $this;
......@@ -94,6 +93,18 @@ trait DCBreadcrumb {
}
}
return $breadcrumb;
}
/**
* Display datacenter element breadcrumb
* @see CommonGLPI::showNavigationHeader()
*
* @return void
*/
protected function showDcBreadcrumb() {
$breadcrumb = $this->getDcBreadcrumb();
if (count($breadcrumb)) {
echo "<tr class='tab_bg_1'>
<td>" . __('Data center position') . "</td>
......@@ -158,4 +169,23 @@ trait DCBreadcrumb {
return $found;
}
/**
* Specific value for "Data center position".
*
* @return array
*/
protected static function getDcBreadcrumbSpecificValueToDisplay($items_id) {
$item = new static();
if ($item->getFromDB($items_id)) {
$breadcrumb = $item->getDcBreadcrumb();
if (count($breadcrumb) > 0) {
return implode(' > ', array_reverse($item->getDcBreadcrumb()));
}
}
return '&nbsp;';
}
}
......@@ -304,6 +304,8 @@ class DCRoom extends CommonDBTM {
$tab = array_merge($tab, Notepad::rawSearchOptionsToAdd());
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
......
......@@ -324,6 +324,8 @@ class Enclosure extends CommonDBTM {
$tab = array_merge($tab, Notepad::rawSearchOptionsToAdd());
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
......
......@@ -629,6 +629,8 @@ class Monitor extends CommonDBTM {
$tab = array_merge($tab, Notepad::rawSearchOptionsToAdd());
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
......
......@@ -655,6 +655,8 @@ class NetworkEquipment extends CommonDBTM {
$tab = array_merge($tab, Item_Devices::rawSearchOptionsToAdd(get_class($this)));
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
}
......@@ -320,6 +320,8 @@ class PDU extends CommonDBTM {
'datatype' => 'dropdown'
];
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
......
......@@ -537,6 +537,8 @@ class Peripheral extends CommonDBTM {
$tab = array_merge($tab, Notepad::rawSearchOptionsToAdd());
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
}
......@@ -486,6 +486,8 @@ class Rack extends CommonDBTM {
$tab = array_merge($tab, Notepad::rawSearchOptionsToAdd());
$tab = array_merge($tab, Datacenter::rawSearchOptionsToAdd(get_class($this)));
return $tab;
}
......
......@@ -855,7 +855,7 @@ abstract class APIBaseClass extends \atoum {
$data = $this->query('getItems',
['itemtype' => 'Config',
'headers' => ['Session-Token' => $this->session_token],
'query' => ['expand_dropdowns' => true]]);
'query' => ['expand_dropdowns' => true]], 206);
$this->variable($data)->isNotFalse();
$this->array($data)->hasKey('headers');
......
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