hosts_and_users.report.php (fogproject-1.5.7) | : | hosts_and_users.report.php (fogproject-1.5.8) | ||
---|---|---|---|---|
skipping to change at line 40 | skipping to change at line 40 | |||
$this->attributes | $this->attributes | |||
); | ); | |||
$this->templates = array( | $this->templates = array( | |||
'${field}', | '${field}', | |||
'${input}' | '${input}' | |||
); | ); | |||
$this->attributes = array( | $this->attributes = array( | |||
array('class' => 'col-xs-4'), | array('class' => 'col-xs-4'), | |||
array('class' => 'col-xs-8 form-group') | array('class' => 'col-xs-8 form-group') | |||
); | ); | |||
$fields = array(); | ||||
$groupNames = self::getSubObjectIDs( | $groupNames = self::getSubObjectIDs( | |||
'Group', | 'Group', | |||
'', | '', | |||
'name' | 'name' | |||
); | ); | |||
$groupNames = array_values( | if (is_array($groupNames) && count($groupNames) > 0) { | |||
array_filter( | $groupNames = array_values( | |||
array_unique( | array_filter( | |||
(array)$groupNames | array_unique( | |||
) | (array)$groupNames | |||
) | ) | |||
); | ) | |||
); | ||||
natcasesort($groupNames); | ||||
$groupSelForm = self::selectForm( | ||||
'groupsearch', | ||||
$groupNames | ||||
); | ||||
unset($groupNames); | ||||
$fields += array('<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>' => $groupSelForm | ||||
); | ||||
} | ||||
if (in_array('location', (array)self::$pluginsinstalled)) { | if (in_array('location', (array)self::$pluginsinstalled)) { | |||
$locationNames = self::getSubObjectIDs( | $locationNames = self::getSubObjectIDs( | |||
'Location', | 'Location', | |||
'', | '', | |||
'name' | 'name' | |||
); | ); | |||
natcasesort($locationNames); | if (is_array($locationNames) && count($locationNames) > 0) { | |||
if (count($locationNames) > 0) { | natcasesort($locationNames); | |||
$locationSelForm = self::selectForm( | $locationSelForm = self::selectForm( | |||
'locationsearch', | 'locationsearch', | |||
$locationNames | $locationNames | |||
); | ); | |||
unset($locationNames); | unset($locationNames); | |||
$fields += array('<label for="locationsearch">' | ||||
. _('Enter a location name to search for') | ||||
. '</label>' => $locationSelForm | ||||
); | ||||
} | } | |||
} | } | |||
if (in_array('site', (array)self::$pluginsinstalled)) { | if (in_array('site', (array)self::$pluginsinstalled)) { | |||
$siteNames = self::getSubObjectIDs( | $siteNames = self::getSubObjectIDs( | |||
'site', | 'site', | |||
'', | '', | |||
'name' | 'name' | |||
); | ); | |||
natcasesort($siteNames); | if (is_array($siteNames) && count($siteNames) > 0) { | |||
if (count($siteNames) > 0) { | natcasesort($siteNames); | |||
$siteSelForm = self::selectForm( | $siteSelForm = self::selectForm( | |||
'sitesearch', | 'sitesearch', | |||
$siteNames | $siteNames | |||
); | ); | |||
unset($siteNames); | unset($siteNames); | |||
} | $fields += array('<label for="sitesearch">' | |||
} | . _('Enter a site name to search for') | |||
natcasesort($groupNames); | . '</label>' => $siteSelForm | |||
if (count($groupNames) > 0) { | ||||
$groupSelForm = self::selectForm( | ||||
'groupsearch', | ||||
$groupNames | ||||
); | ); | |||
unset($groupNames); | } | |||
} | } | |||
$fields = array( | $fields += array('<label for="hostpattern">' | |||
'<label for="groupsearch">' | . _('Search pattern') . '</label>' | |||
. _('Enter a group name to search for') | => '<input type="text" name="hostpattern" placeholder="Search... lea | |||
. '</label>' => $groupSelForm, | ve empty for all elements" class="form-control" />' | |||
'<label for="performsearch">' | ) + array('<label for="performsearch">' | |||
. _('Perform search') | . _('Perform search') | |||
. '</label>' => '<button type="submit" name="performsearch" ' | . '</label>' => '<button type="submit" name="performsearch" ' | |||
. 'class="btn btn-info btn-block" id="performsearch">' | . 'class="btn btn-info btn-block" id="performsearch">' | |||
. _('Search') | . _('Search') | |||
. '</button>' | . '</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); | array_walk($fields, $this->fieldsToData); | |||
echo '<div class="col-xs-9">'; | echo '<div class="col-xs-9">'; | |||
echo '<div class="panel panel-info">'; | echo '<div class="panel panel-info">'; | |||
echo '<div class="panel-heading text-center">'; | echo '<div class="panel-heading text-center">'; | |||
echo '<h4 class="title">'; | echo '<h4 class="title">'; | |||
echo $this->title; | echo $this->title; | |||
echo '</h4>'; | echo '</h4>'; | |||
echo '</div>'; | echo '</div>'; | |||
echo '<div class="panel-body">'; | echo '<div class="panel-body">'; | |||
echo '<form class="form-horizontal" method="post" action="' | echo '<form class="form-horizontal" method="post" action="' | |||
skipping to change at line 157 | skipping to change at line 144 | |||
* | * | |||
* @return void | * @return void | |||
*/ | */ | |||
public function filePost() | public function filePost() | |||
{ | { | |||
$this->title =_('FOG Hosts and Users Login'); | $this->title =_('FOG Hosts and Users Login'); | |||
$groupsearch = filter_input( | $groupsearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'groupsearch' | 'groupsearch' | |||
); | ); | |||
if (!$groupsearch) { | ||||
$groupsearch = '%'; | ||||
} | ||||
$locationsearch = filter_input( | $locationsearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'locationsearch' | 'locationsearch' | |||
); | ); | |||
$sitesearch = filter_input( | $sitesearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'sitesearch' | 'sitesearch' | |||
); | ); | |||
$hostpattern = filter_input( | ||||
INPUT_POST, | ||||
'hostpattern' | ||||
); | ||||
if (!$hostpattern) { | ||||
$hostpattern = '%'; | ||||
} else { | ||||
$hostpattern = '%' . $hostpattern . '%'; | ||||
} | ||||
$csvHead = array( | $csvHead = array( | |||
_('Host ID') => 'id', | _('Host ID') => 'id', | |||
_('Host Name') => 'name', | _('Host Name') => 'name', | |||
_('Host Desc') => 'description', | _('Host Desc') => 'description', | |||
_('Host MAC') => 'mac', | _('Host MAC') => 'mac', | |||
_('Host Created') => 'createdTime', | _('Host Created') => 'createdTime', | |||
_('Image ID') => 'id', | _('Image ID') => 'id', | |||
_('Image Name') => 'name', | _('Image Name') => 'name', | |||
_('Image Desc') => 'description', | _('Image Desc') => 'description', | |||
skipping to change at line 205 | skipping to change at line 198 | |||
_('Image Name'), | _('Image Name'), | |||
_('Login Users') | _('Login Users') | |||
); | ); | |||
$this->templates = array( | $this->templates = array( | |||
'${host_name}', | '${host_name}', | |||
'${host_mac}', | '${host_mac}', | |||
'${image_name}', | '${image_name}', | |||
'${users}' | '${users}' | |||
); | ); | |||
$groupIDs = self::getSubObjectIDs( | $groupHostIDs = array(); | |||
'Group', | if ($groupsearch) { | |||
array('name' => $groupsearch), | $groupIDs = self::getSubObjectIDs( | |||
'id' | 'Group', | |||
); | array('name' => $groupsearch), | |||
'id' | ||||
$groupHostIDs = self::getSubObjectIDs( | ); | |||
'GroupAssociation', | $groupHostIDs = self::getSubObjectIDs( | |||
array('groupID' => $groupIDs), | 'GroupAssociation', | |||
'hostID' | array('groupID' => $groupIDs), | |||
); | 'hostID' | |||
); | ||||
} | ||||
if (in_array('location', (array)self::$pluginsinstalled) && $locationsea rch) { | if (in_array('location', (array)self::$pluginsinstalled) && $locationsea rch) { | |||
$locationIDs = self::getSubObjectIDs( | $locationIDs = self::getSubObjectIDs( | |||
'Location', | 'Location', | |||
array('name' => $locationsearch), | array('name' => $locationsearch), | |||
'id' | 'id' | |||
); | ); | |||
$locationHostIDs = self::getSubObjectIDs( | $locationHostIDs = self::getSubObjectIDs( | |||
'LocationAssociation', | 'LocationAssociation', | |||
array('locationID' => $locationIDs), | array('locationID' => $locationIDs), | |||
'hostID' | 'hostID' | |||
); | ); | |||
$groupHostIDs = array_intersect($locationHostIDs, $groupHostIDs); | $groupHostIDs = array_intersect($locationHostIDs, $groupHostIDs); | |||
} | } | |||
if (in_array('site', (array)self::$pluginsinstalled) && $sitesearch) { | if (in_array('site', (array)self::$pluginsinstalled) && $sitesearch) { | |||
$siteIDs = self::getSubObjectIDs( | $siteIDs = self::getSubObjectIDs( | |||
'Site', | 'Site', | |||
array('name' => $sitesearch), | array('name' => $sitesearch), | |||
'id' | 'id' | |||
); | ); | |||
$siteHostIDs = self::getSubObjectIDs( | $siteHostIDs = self::getSubObjectIDs( | |||
'SiteHostAssociation', | 'SiteHostAssociation', | |||
array('siteID' => $siteIDs), | array('siteID' => $siteIDs), | |||
'hostID' | 'hostID' | |||
); | ); | |||
$groupHostIDs = array_intersect($siteHostIDs, $groupHostIDs); | $groupHostIDs = array_intersect($siteHostIDs, $groupHostIDs); | |||
} | } | |||
Route::listem( | if ($groupsearch) { | |||
'host', | Route::listem( | |||
'name', | 'host', | |||
'false', | 'name', | |||
array( | 'false', | |||
'id' => $groupHostIDs | array( | |||
'id' => $groupHostIDs, | ||||
'name' => $hostpattern | ||||
) | ) | |||
); | ); | |||
} else { | ||||
Route::listem( | ||||
'host', | ||||
'name', | ||||
'false', | ||||
array('name' => $hostpattern) | ||||
); | ||||
} | ||||
$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; | |||
skipping to change at line 305 | skipping to change at line 310 | |||
case _('Login Users'): | case _('Login Users'): | |||
$this->ReportMaker->addCSVCell( | $this->ReportMaker->addCSVCell( | |||
implode( | implode( | |||
' ', | ' ', | |||
self::getSubObjectIDs( | self::getSubObjectIDs( | |||
'UserTracking', | 'UserTracking', | |||
array('hostID' => $Host->id), | array('hostID' => $Host->id), | |||
'username' | 'username' | |||
) | ) | |||
) | ) | |||
); | ||||
); | ||||
break; | break; | |||
default: | default: | |||
$this->ReportMaker->addCSVCell($Host->$classGet); | $this->ReportMaker->addCSVCell($Host->$classGet); | |||
break; | break; | |||
} | } | |||
unset($classGet); | unset($classGet); | |||
} | } | |||
unset($Host); | unset($Host); | |||
$this->ReportMaker->endCSVLine(); | $this->ReportMaker->endCSVLine(); | |||
} | } | |||
End of changes. 21 change blocks. | ||||
80 lines changed or deleted | 85 lines changed or added |