From 51fdecba2bb0f7d995d51b81c38796e8548dcd6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Hivert?= Date: Fri, 3 Aug 2018 20:24:47 +0200 Subject: [PATCH] Minor fix about equipment infos --- services/shell/abstract.php | 13 +++++++------ services/shell/dcim.php | 39 ++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/services/shell/abstract.php b/services/shell/abstract.php index 7630d7d..b5c0a41 100644 --- a/services/shell/abstract.php +++ b/services/shell/abstract.php @@ -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; @@ -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) diff --git a/services/shell/dcim.php b/services/shell/dcim.php index 8a79c75..fb6b774 100644 --- a/services/shell/dcim.php +++ b/services/shell/dcim.php @@ -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) @@ -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; @@ -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();