Skip to content

Commit 51fdecb

Browse files
author
Jean-François Hivert
committed
Minor fix about equipment infos
1 parent a63c42e commit 51fdecb

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

services/shell/abstract.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ protected function _printObjectInfos(array $cases, array $args, $fromCurrentPath
105105
}
106106
}
107107

108-
return (isset($objectType)) ? ($this->_printInformations($objectType, $infos)) : (false);
108+
if(isset($objectType)) {
109+
$status = $this->_printInformations($objectType, $infos);
110+
return array($status, $objectType, $infos);
111+
}
112+
else {
113+
return false;
114+
}
109115
}
110116
else {
111117
return false;
@@ -134,11 +140,6 @@ protected function _printInformations($type, $items)
134140
if(array_key_exists($key, $item))
135141
{
136142
$field = $item[$key];
137-
138-
if(Tools::is('array', $field)) {
139-
$field = implode(PHP_EOL, $field);
140-
}
141-
142143
$field = vsprintf($format, $field);
143144

144145
switch($key)

services/shell/dcim.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,21 @@ public function printObjectInfos(array $args, $fromCurrentPath = true)
222222
'equipment' => '_getEquipmentInfos'
223223
);
224224

225-
return $this->_printObjectInfos($cases, $args, $fromCurrentPath);
225+
$result = $this->_printObjectInfos($cases, $args, $fromCurrentPath);
226+
227+
if($result !== false)
228+
{
229+
list($status, $objectType, $infos) = $result;
230+
231+
if($status && $objectType === 'equipment') {
232+
$this->printEquipmentExtra($infos);
233+
}
234+
235+
return $status;
236+
}
237+
else {
238+
return false;
239+
}
226240
}
227241

228242
public function printLocationInfos(array $args, $fromCurrentPath = true, $recursion = false)
@@ -291,14 +305,8 @@ public function printEquipmentInfos(array $args, $fromCurrentPath = true, $recur
291305
if($status === false) {
292306
Tools::e("Equipement introuvable", 'orange');
293307
}
294-
elseif(count($infos) === 1)
295-
{
296-
$this->_MAIN->displayWaitingMsg();
297-
298-
$path = $infos[0]['path'].'/'.$infos[0]['name'];
299-
$objects = $this->_getObjects($path);
300-
$this->_MAIN->deleteWaitingMsg();
301-
$this->_printObjectsList($objects);
308+
else {
309+
$this->printEquipmentExtra($infos);
302310
}
303311

304312
return true;
@@ -307,6 +315,19 @@ public function printEquipmentInfos(array $args, $fromCurrentPath = true, $recur
307315
return false;
308316
}
309317

318+
protected function printEquipmentExtra(array $infos)
319+
{
320+
if(count($infos) === 1)
321+
{
322+
$this->_MAIN->displayWaitingMsg();
323+
324+
$path = $infos[0]['path'].'/'.$infos[0]['name'];
325+
$objects = $this->_getObjects($path);
326+
$this->_MAIN->deleteWaitingMsg();
327+
$this->_printObjectsList($objects);
328+
}
329+
}
330+
310331
protected function _getLocationInfos($location, $fromCurrentPath, $path = null, $recursion = false)
311332
{
312333
$items = array();

0 commit comments

Comments
 (0)