Skip to content

Commit

Permalink
Minor fix about equipment infos
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-François Hivert committed Aug 3, 2018
1 parent a63c42e commit 51fdecb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
13 changes: 7 additions & 6 deletions services/shell/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ protected function _printObjectInfos(array $cases, array $args, $fromCurrentPath
}
}

return (isset($objectType)) ? ($this->_printInformations($objectType, $infos)) : (false);
if(isset($objectType)) {
$status = $this->_printInformations($objectType, $infos);
return array($status, $objectType, $infos);
}
else {
return false;
}
}
else {
return false;
Expand Down Expand Up @@ -134,11 +140,6 @@ protected function _printInformations($type, $items)
if(array_key_exists($key, $item))
{
$field = $item[$key];

if(Tools::is('array', $field)) {
$field = implode(PHP_EOL, $field);
}

$field = vsprintf($format, $field);

switch($key)
Expand Down
39 changes: 30 additions & 9 deletions services/shell/dcim.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,21 @@ public function printObjectInfos(array $args, $fromCurrentPath = true)
'equipment' => '_getEquipmentInfos'
);

return $this->_printObjectInfos($cases, $args, $fromCurrentPath);
$result = $this->_printObjectInfos($cases, $args, $fromCurrentPath);

if($result !== false)
{
list($status, $objectType, $infos) = $result;

if($status && $objectType === 'equipment') {
$this->printEquipmentExtra($infos);
}

return $status;
}
else {
return false;
}
}

public function printLocationInfos(array $args, $fromCurrentPath = true, $recursion = false)
Expand Down Expand Up @@ -291,14 +305,8 @@ public function printEquipmentInfos(array $args, $fromCurrentPath = true, $recur
if($status === false) {
Tools::e("Equipement introuvable", 'orange');
}
elseif(count($infos) === 1)
{
$this->_MAIN->displayWaitingMsg();

$path = $infos[0]['path'].'/'.$infos[0]['name'];
$objects = $this->_getObjects($path);
$this->_MAIN->deleteWaitingMsg();
$this->_printObjectsList($objects);
else {
$this->printEquipmentExtra($infos);
}

return true;
Expand All @@ -307,6 +315,19 @@ public function printEquipmentInfos(array $args, $fromCurrentPath = true, $recur
return false;
}

protected function printEquipmentExtra(array $infos)
{
if(count($infos) === 1)
{
$this->_MAIN->displayWaitingMsg();

$path = $infos[0]['path'].'/'.$infos[0]['name'];
$objects = $this->_getObjects($path);
$this->_MAIN->deleteWaitingMsg();
$this->_printObjectsList($objects);
}
}

protected function _getLocationInfos($location, $fromCurrentPath, $path = null, $recursion = false)
{
$items = array();
Expand Down

0 comments on commit 51fdecb

Please sign in to comment.