host_list.report.php (fogproject-1.5.5) | : | host_list.report.php (fogproject-1.5.6) | ||
---|---|---|---|---|
<?php | <?php | |||
/** | /** | |||
* Reports hosts within. | * Reports hosts within. | |||
* | * | |||
* PHP version 5 | * PHP version 5 | |||
* | * | |||
* @category Host_List | * @category Host_List | |||
* @package FOGProject | * @package FOGProject | |||
* @author Tom Elliott <tommygunsster@gmail.com> | * @author Tom Elliott <tommygunsster@gmail.com> | |||
* @author Fernando Gietz <fernando.gietz@gmail.com> | ||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 | * @license http://opensource.org/licenses/gpl-3.0 GPLv3 | |||
* @link https://fogproject.org | * @link https://fogproject.org | |||
*/ | */ | |||
/** | /** | |||
* Reports hosts within. | * Reports hosts within. | |||
* | * | |||
* @category Host_List | * @category Host_List | |||
* @package FOGProject | * @package FOGProject | |||
* @author Tom Elliott <tommygunsster@gmail.com> | * @author Tom Elliott <tommygunsster@gmail.com> | |||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 | * @license http://opensource.org/licenses/gpl-3.0 GPLv3 | |||
* @link https://fogproject.org | * @link https://fogproject.org | |||
*/ | */ | |||
class Host_List extends ReportManagementPage | class Host_List extends ReportManagementPage | |||
{ | { | |||
/** | /** | |||
* Display page. | * Display search page. | |||
* | * | |||
* @return void | * @return void | |||
*/ | */ | |||
public function file() | public function file() | |||
{ | { | |||
$this->title = _('FOG Host - Search'); | ||||
unset( | ||||
$this->data, | ||||
$this->form, | ||||
$this->headerData, | ||||
$this->templates, | ||||
$this->attributes | ||||
); | ||||
$this->templates = array( | ||||
'${field}', | ||||
'${input}' | ||||
); | ||||
$this->attributes = array( | ||||
array('class' => 'col-xs-4'), | ||||
array('class' => 'col-xs-8 form-group') | ||||
); | ||||
$groupNames = self::getSubObjectIDs( | ||||
'Group', | ||||
'', | ||||
'name' | ||||
); | ||||
$groupNames = array_values( | ||||
array_filter( | ||||
array_unique( | ||||
(array)$groupNames | ||||
) | ||||
) | ||||
); | ||||
if (in_array('location', (array)self::$pluginsinstalled)) { | ||||
$locationNames = self::getSubObjectIDs( | ||||
'Location', | ||||
'', | ||||
'name' | ||||
); | ||||
natcasesort($locationNames); | ||||
if (count($locationNames) > 0) { | ||||
$locationSelForm = self::selectForm( | ||||
'locationsearch', | ||||
$locationNames | ||||
); | ||||
unset($locationNames); | ||||
} | ||||
} | ||||
if (in_array('site', (array)self::$pluginsinstalled)) { | ||||
$siteNames = self::getSubObjectIDs( | ||||
'site', | ||||
'', | ||||
'name' | ||||
); | ||||
natcasesort($siteNames); | ||||
if (count($siteNames) > 0) { | ||||
$siteSelForm = self::selectForm( | ||||
'sitesearch', | ||||
$siteNames | ||||
); | ||||
unset($siteNames); | ||||
} | ||||
} | ||||
natcasesort($groupNames); | ||||
if (count($groupNames) > 0) { | ||||
$groupSelForm = self::selectForm( | ||||
'groupsearch', | ||||
$groupNames | ||||
); | ||||
unset($groupNames); | ||||
} | ||||
$fields = array( | ||||
'<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>' => $groupSelForm, | ||||
'<label for="performsearch">' | ||||
. _('Perform search') | ||||
. '</label>' => '<button type="submit" name="performsearch" ' | ||||
. 'class="btn btn-info btn-block" id="performsearch">' | ||||
. _('Search') | ||||
. '</button>' | ||||
); | ||||
if (in_array('location', (array)self::$pluginsinstalled)) { | ||||
self::arrayInsertAfter( | ||||
'<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>', | ||||
$fields, | ||||
'<label for="locationsearch">' | ||||
. _('Enter a location name to search for') | ||||
. '</label>', | ||||
$locationSelForm | ||||
); | ||||
} | ||||
if (in_array('site', (array)self::$pluginsinstalled)) { | ||||
self::arrayInsertAfter( | ||||
'<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>', | ||||
$fields, | ||||
'<label for="sitesearch">' | ||||
. _('Enter a site name to search for') | ||||
. '</label>', | ||||
$siteSelForm | ||||
); | ||||
} | ||||
array_walk($fields, $this->fieldsToData); | ||||
echo '<div class="col-xs-9">'; | ||||
echo '<div class="panel panel-info">'; | ||||
echo '<div class="panel-heading text-center">'; | ||||
echo '<h4 class="title">'; | ||||
echo $this->title; | ||||
echo '</h4>'; | ||||
echo '</div>'; | ||||
echo '<div class="panel-body">'; | ||||
echo '<form class="form-horizontal" method="post" action="' | ||||
. $this->formAction | ||||
. '">'; | ||||
$this->render(12); | ||||
echo '</form>'; | ||||
echo '</div>'; | ||||
echo '</div>'; | ||||
echo '</div>'; | ||||
} | ||||
/** | ||||
* Display page. | ||||
* | ||||
* @return void | ||||
*/ | ||||
public function filePost() | ||||
{ | ||||
$this->title = _('Host Listing Export'); | $this->title = _('Host Listing Export'); | |||
$groupsearch = filter_input( | ||||
INPUT_POST, | ||||
'groupsearch' | ||||
); | ||||
if (!$groupsearch) { | ||||
$groupsearch = '%'; | ||||
} | ||||
$locationsearch = filter_input( | ||||
INPUT_POST, | ||||
'locationsearch' | ||||
); | ||||
$sitesearch = filter_input( | ||||
INPUT_POST, | ||||
'sitesearch' | ||||
); | ||||
$csvHead = array( | $csvHead = array( | |||
_('Host ID') => 'id', | _('Host ID') => 'id', | |||
_('Host Name') => 'name', | _('Host Name') => 'name', | |||
_('Host Desc') => 'description', | _('Host Desc') => 'description', | |||
_('Host MAC') => 'primac', | _('Host MAC') => 'primac', | |||
_('Host Created') => 'createdTime', | _('Host Created') => 'createdTime', | |||
_('Host AD Join') => 'useAD', | _('Host AD Join') => 'useAD', | |||
_('Host AD OU') => 'ADOU', | _('Host AD OU') => 'ADOU', | |||
_('Host AD Domain') => 'ADDomain', | _('Host AD Domain') => 'ADDomain', | |||
_('Host Kernel') => 'kernel', | _('Host Kernel') => 'kernel', | |||
skipping to change at line 63 | skipping to change at line 208 | |||
$this->headerData = array( | $this->headerData = array( | |||
_('Hostname'), | _('Hostname'), | |||
_('Host MAC'), | _('Host MAC'), | |||
_('Image Name'), | _('Image Name'), | |||
); | ); | |||
$this->templates = array( | $this->templates = array( | |||
'${host_name}', | '${host_name}', | |||
'${host_mac}', | '${host_mac}', | |||
'${image_name}', | '${image_name}', | |||
); | ); | |||
Route::listem('host'); | $groupIDs = self::getSubObjectIDs( | |||
'Group', | ||||
array('name' => $groupsearch), | ||||
'id' | ||||
); | ||||
$groupHostIDs = self::getSubObjectIDs( | ||||
'GroupAssociation', | ||||
array('groupID' => $groupIDs), | ||||
'hostID' | ||||
); | ||||
if (in_array('location', (array)self::$pluginsinstalled) && $locationsea | ||||
rch) { | ||||
$locationIDs = self::getSubObjectIDs( | ||||
'Location', | ||||
array('name' => $locationsearch), | ||||
'id' | ||||
); | ||||
$locationHostIDs = self::getSubObjectIDs( | ||||
'LocationAssociation', | ||||
array('locationID' => $locationIDs), | ||||
'hostID' | ||||
); | ||||
$groupHostIDs = array_intersect($locationHostIDs, $groupHostIDs); | ||||
} | ||||
if (in_array('site', (array)self::$pluginsinstalled) && $sitesearch) { | ||||
$siteIDs = self::getSubObjectIDs( | ||||
'Site', | ||||
array('name' => $sitesearch), | ||||
'id' | ||||
); | ||||
$siteHostIDs = self::getSubObjectIDs( | ||||
'SiteHostAssociation', | ||||
array('siteID' => $siteIDs), | ||||
'hostID' | ||||
); | ||||
$groupHostIDs = array_intersect($siteHostIDs, $groupHostIDs); | ||||
} | ||||
Route::listem( | ||||
'host', | ||||
'name', | ||||
'false', | ||||
array( | ||||
'id' => $groupHostIDs | ||||
) | ||||
); | ||||
$Hosts = json_decode( | $Hosts = json_decode( | |||
Route::getData() | Route::getData() | |||
); | ); | |||
$Hosts = $Hosts->hosts; | $Hosts = $Hosts->hosts; | |||
foreach ((array)$Hosts as &$Host) { | foreach ((array)$Hosts as &$Host) { | |||
$Image = $Host->image; | $Image = $Host->image; | |||
$imgID = $Image->id; | $imgID = $Image->id; | |||
$imgName = $Image->name; | $imgName = $Image->name; | |||
$imgDesc = $Image->description; | $imgDesc = $Image->description; | |||
unset($Image); | unset($Image); | |||
End of changes. 6 change blocks. | ||||
2 lines changed or deleted | 193 lines changed or added |