/** * Grid of Displays * @return */ function DisplayGrid() { // validate displays so we get a realistic view of the table Display::ValidateDisplays(); $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); // Filter by Name $filter_display = Kit::GetParam('filter_display', _POST, _STRING); setSession('display', 'filter_display', $filter_display); // Filter by Name $filterMacAddress = Kit::GetParam('filterMacAddress', _POST, _STRING); setSession('display', 'filterMacAddress', $filterMacAddress); // Display Group $filter_displaygroupid = Kit::GetParam('filter_displaygroup', _POST, _INT); setSession('display', 'filter_displaygroup', $filter_displaygroupid); // Thumbnail? $filter_showView = Kit::GetParam('filter_showView', _REQUEST, _INT); setSession('display', 'filter_showView', $filter_showView); $filterVersion = Kit::GetParam('filterVersion', _REQUEST, _STRING); setSession('display', 'filterVersion', $filterVersion); // filter_autoRefresh? $filter_autoRefresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0); setSession('display', 'filter_autoRefresh', $filter_autoRefresh); // Pinned option? setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); $displays = $user->DisplayList(array('displayid'), array('displaygroupid' => $filter_displaygroupid, 'display' => $filter_display, 'macAddress' => $filterMacAddress, 'clientVersion' => $filterVersion)); if (!is_array($displays)) { trigger_error($db->error()); trigger_error(__('Unable to get list of displays'), E_USER_ERROR); } // Do we want to make a VNC link out of the display name? $vncTemplate = Config::GetSetting('SHOW_DISPLAY_AS_VNCLINK'); $linkTarget = Kit::ValidateParam(Config::GetSetting('SHOW_DISPLAY_AS_VNC_TGT'), _STRING); $cols = array(array('name' => 'displayid', 'title' => __('ID')), array('name' => 'displayWithLink', 'title' => __('Display')), array('name' => 'status', 'title' => __('Status'), 'icons' => true, 'iconDescription' => 'statusDescription'), array('name' => 'licensed', 'title' => __('License'), 'icons' => true), array('name' => 'currentLayout', 'title' => __('Current Layout'), 'hidden' => $filter_showView != 3), array('name' => 'storageAvailableSpaceFormatted', 'title' => __('Storage Available'), 'hidden' => $filter_showView != 3), array('name' => 'storageTotalSpaceFormatted', 'title' => __('Storage Total'), 'hidden' => $filter_showView != 3), array('name' => 'storagePercentage', 'title' => __('Storage Free %'), 'hidden' => $filter_showView != 3), array('name' => 'description', 'title' => __('Description'), 'hidden' => $filter_showView != 4), array('name' => 'layout', 'title' => __('Default Layout'), 'hidden' => $filter_showView != 0), array('name' => 'inc_schedule', 'title' => __('Interleave Default'), 'icons' => true, 'hidden' => $filter_showView == 1 || $filter_showView == 2), array('name' => 'email_alert', 'title' => __('Email Alert'), 'icons' => true, 'hidden' => $filter_showView != 0), array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true), array('name' => 'lastaccessed', 'title' => __('Last Accessed')), array('name' => 'clientVersionCombined', 'title' => __('Version'), 'hidden' => $filter_showView != 3), array('name' => 'clientaddress', 'title' => __('IP Address'), 'hidden' => $filter_showView == 1), array('name' => 'macaddress', 'title' => __('Mac Address'), 'hidden' => $filter_showView == 1), array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true, 'hidden' => $filter_showView != 1 && $filter_showView != 2), array('name' => 'thumbnail', 'title' => __('Thumbnail'), 'hidden' => $filter_showView != 1 && $filter_showView != 2)); Theme::Set('table_cols', $cols); Theme::Set('rowClass', 'rowColor'); $rows = array(); foreach ($displays as $row) { // VNC Template as display name? if ($vncTemplate != '' && $row['clientaddress'] != '') { if ($linkTarget == '') { $linkTarget = '_top'; } $row['displayWithLink'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . Theme::Prepare($row['display']) . '</a>', $row['clientaddress']); } else { $row['displayWithLink'] = $row['display']; } // Format last accessed $row['lastaccessed'] = DateManager::getLocalDate($row['lastaccessed']); // Create some login lights $row['rowColor'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'danger' : 'warning'); // Set some text for the display status switch ($row['mediainventorystatus']) { case 1: $row['statusDescription'] = __('Display is up to date'); break; case 2: $row['statusDescription'] = __('Display is downloading new files'); break; case 3: $row['statusDescription'] = __('Display is out of date but has not yet checked in with the server'); break; default: $row['statusDescription'] = __('Unknown Display Status'); } $row['status'] = $row['mediainventorystatus'] == 1 ? 1 : ($row['mediainventorystatus'] == 2 ? 0 : -1); // Thumbnail $row['thumbnail'] = ''; // If we aren't logged in, and we are showThumbnail == 2, then show a circle if ($filter_showView == 2 && $row['loggedin'] == 0) { $row['thumbnail'] = '<i class="fa fa-times-circle"></i>'; } else { if ($filter_showView != 0 && file_exists(Config::GetSetting('LIBRARY_LOCATION') . 'screenshots/' . $row['displayid'] . '_screenshot.jpg')) { $row['thumbnail'] = '<a data-toggle="lightbox" data-type="image" href="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '"><img class="display-screenshot" src="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '&' . Kit::uniqueId() . '" /></a>'; } } // Version $row['clientVersionCombined'] = $row['client_type'] . ' / ' . $row['client_version']; // Format the storage available / total space $row['storageAvailableSpaceFormatted'] = Kit::formatBytes($row['storageAvailableSpace']); $row['storageTotalSpaceFormatted'] = Kit::formatBytes($row['storageTotalSpace']); $row['storagePercentage'] = $row['storageTotalSpace'] == 0 ? 100 : round($row['storageAvailableSpace'] / $row['storageTotalSpace'] * 100.0, 2); // Edit and Delete buttons first if ($row['edit'] == 1) { // Edit $row['buttons'][] = array('id' => 'display_button_edit', 'url' => 'index.php?p=display&q=displayForm&displayid=' . $row['displayid'], 'text' => __('Edit')); } // Delete if ($row['del'] == 1) { $row['buttons'][] = array('id' => 'display_button_delete', 'url' => 'index.php?p=display&q=DeleteForm&displayid=' . $row['displayid'], 'text' => __('Delete')); } if ($row['edit'] == 1 || $row['del'] == 1) { $row['buttons'][] = array('linkType' => 'divider'); } // Schedule Now if ($row['edit'] == 1 || Config::GetSetting('SCHEDULE_WITH_VIEW_PERMISSION') == 'Yes') { $row['buttons'][] = array('id' => 'display_button_schedulenow', 'url' => 'index.php?p=schedule&q=ScheduleNowForm&displayGroupId=' . $row['displaygroupid'], 'text' => __('Schedule Now')); } if ($row['edit'] == 1) { // Default Layout $row['buttons'][] = array('id' => 'display_button_defaultlayout', 'url' => 'index.php?p=display&q=DefaultLayoutForm&DisplayId=' . $row['displayid'], 'text' => __('Default Layout')); // File Associations $row['buttons'][] = array('id' => 'displaygroup_button_fileassociations', 'url' => 'index.php?p=displaygroup&q=FileAssociations&DisplayGroupID=' . $row['displaygroupid'], 'text' => __('Assign Files')); // Screen Shot $row['buttons'][] = array('id' => 'display_button_requestScreenShot', 'url' => 'index.php?p=display&q=RequestScreenShotForm&displayId=' . $row['displayid'], 'text' => __('Request Screen Shot'), 'multi-select' => true, 'dataAttributes' => array(array('name' => 'multiselectlink', 'value' => 'index.php?p=display&q=RequestScreenShot'), array('name' => 'rowtitle', 'value' => $row['display']), array('name' => 'displayId', 'value' => $row['displayid']))); $row['buttons'][] = array('linkType' => 'divider'); } // Media Inventory $row['buttons'][] = array('id' => 'display_button_mediainventory', 'url' => 'index.php?p=display&q=MediaInventory&DisplayId=' . $row['displayid'], 'text' => __('Media Inventory')); if ($row['edit'] == 1) { // Logs $row['buttons'][] = array('id' => 'displaygroup_button_logs', 'url' => 'index.php?p=log&q=LastHundredForDisplay&displayid=' . $row['displayid'], 'text' => __('Recent Log')); $row['buttons'][] = array('linkType' => 'divider'); } if ($row['modifypermissions'] == 1) { // Display Groups $row['buttons'][] = array('id' => 'display_button_group_membership', 'url' => 'index.php?p=display&q=MemberOfForm&DisplayID=' . $row['displayid'], 'text' => __('Display Groups')); // Permissions $row['buttons'][] = array('id' => 'display_button_group_membership', 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'], 'text' => __('Permissions')); // Version Information $row['buttons'][] = array('id' => 'display_button_version_instructions', 'url' => 'index.php?p=displaygroup&q=VersionInstructionsForm&displaygroupid=' . $row['displaygroupid'] . '&displayid=' . $row['displayid'], 'text' => __('Version Information')); $row['buttons'][] = array('linkType' => 'divider'); } if ($row['edit'] == 1) { // Wake On LAN $row['buttons'][] = array('id' => 'display_button_wol', 'url' => 'index.php?p=display&q=WakeOnLanForm&DisplayId=' . $row['displayid'], 'text' => __('Wake on LAN')); } // Assign this to the table row $rows[] = $row; } Theme::Set('table_rows', $rows); $output = Theme::RenderReturn('table_render'); $response->SetGridResponse($output); $response->refresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0); $response->Respond(); }
public function tidyLibraryForm() { $response = new ResponseManager(); Theme::Set('form_id', 'TidyLibraryForm'); Theme::Set('form_action', 'index.php?p=content&q=tidyLibrary'); $formFields = array(); $formFields[] = FormManager::AddMessage(__('Tidying your Library will delete any media that is not currently in use.')); // Work out how many files there are $media = Media::entriesUnusedForUser($this->user->userid); $formFields[] = FormManager::AddMessage(sprintf(__('There is %s of data stored in %d files . Are you sure you want to proceed?', Kit::formatBytes(array_sum(array_map(function ($element) { return $element['fileSize']; }, $media))), count($media)))); Theme::Set('form_fields', $formFields); $response->SetFormRequestResponse(NULL, __('Tidy Library'), '350px', '275px'); $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Content', 'TidyLibrary') . '")'); $response->AddButton(__('No'), 'XiboDialogClose()'); $response->AddButton(__('Yes'), '$("#TidyLibraryForm").submit()'); $response->Respond(); }
/** * Group Grid * Called by AJAX * @return */ function Grid() { $db =& $this->db; $user =& $this->user; $filter_name = Kit::GetParam('filter_name', _POST, _STRING); setSession('usergroup', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); setSession('usergroup', 'filter_name', $filter_name); $SQL = <<<END \t\tSELECT \tgroup.group, \t\t\t\tgroup.groupID, \t\t\t\tgroup.libraryQuota \t\tFROM `group` \t\tWHERE IsUserSpecific = 0 AND IsEveryone = 0 END; if ($filter_name != '') { $SQL .= sprintf(" AND group.group LIKE '%%%s%%' ", $db->escape_string($filter_name)); } $SQL .= " ORDER BY group.group "; //Debug::LogEntry('audit', $SQL); if (!($results = $db->query($SQL))) { trigger_error($db->error()); trigger_error(__("Can not get group information."), E_USER_ERROR); } $cols = array(array('name' => 'usergroup', 'title' => __('User Group')), array('name' => 'libraryQuotaText', 'title' => __('Library Quota'))); Theme::Set('table_cols', $cols); $rows = array(); while ($row = $db->get_assoc_row($results)) { $groupid = Kit::ValidateParam($row['groupID'], _INT); $group = Kit::ValidateParam($row['group'], _STRING); $row['usergroup'] = $group; $row['libraryQuota'] = Kit::ValidateParam($row['libraryQuota'], _INT); $row['libraryQuotaText'] = $row['libraryQuota'] == 0 ? '' : Kit::formatBytes($row['libraryQuota'] * 1024); // we only want to show certain buttons, depending on the user logged in if ($user->GetUserTypeID() == 1) { // Edit $row['buttons'][] = array('id' => 'usergroup_button_edit', 'url' => 'index.php?p=group&q=GroupForm&groupid=' . $groupid, 'text' => __('Edit')); // Delete $row['buttons'][] = array('id' => 'usergroup_button_delete', 'url' => 'index.php?p=group&q=DeleteForm&groupid=' . $groupid, 'text' => __('Delete')); // Members $row['buttons'][] = array('id' => 'usergroup_button_members', 'url' => 'index.php?p=group&q=MembersForm&groupid=' . $groupid, 'text' => __('Members')); // Page Security $row['buttons'][] = array('id' => 'usergroup_button_page_security', 'url' => 'index.php?p=group&q=PageSecurityForm&groupid=' . $groupid, 'text' => __('Page Security')); // Menu Security $row['buttons'][] = array('id' => 'usergroup_button_menu_security', 'url' => 'index.php?p=group&q=MenuItemSecurityForm&groupid=' . $groupid, 'text' => __('Menu Security')); // User Quota $row['buttons'][] = array('id' => 'usergroup_button_quota', 'url' => 'index.php?p=group&q=quotaForm&groupid=' . $groupid, 'text' => __('Set User Quota')); } $rows[] = $row; } Theme::Set('table_rows', $rows); $output = Theme::RenderReturn('table_render'); $response = new ResponseManager(); $response->SetGridResponse($output); $response->Respond(); }
/** * Prints the user information in a table based on a check box selection * */ function UserGrid() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); // Capture the filter options // User ID $filter_username = Kit::GetParam('filter_username', _POST, _STRING); setSession('user_admin', 'filter_username', $filter_username); // User Type ID $filter_usertypeid = Kit::GetParam('filter_usertypeid', _POST, _INT); setSession('user_admin', 'filter_usertypeid', $filter_usertypeid); $filterRetired = Kit::GetParam('filterRetired', _POST, _INT); setSession('user_admin', 'filterRetired', $filterRetired); // Pinned option? setSession('user_admin', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); // Filter our users? $filterBy = array(); // Filter on User Type if ($filter_usertypeid != 0) { $filterBy['userTypeId'] = $filter_usertypeid; } // Filter on User Name if ($filter_username != '') { $filterBy['userName'] = $filter_username; } $filterBy['retired'] = $filterRetired; // Load results into an array $users = $user->userList(array('userName'), $filterBy); if (!is_array($users)) { trigger_error(__('Error getting list of users'), E_USER_ERROR); } $cols = array(array('name' => 'username', 'title' => __('Name')), array('name' => 'homepage', 'title' => __('Homepage')), array('name' => 'email', 'title' => __('Email')), array('name' => 'libraryQuotaText', 'title' => __('Library Quota')), array('name' => 'retired', 'title' => __('Retired?'), 'icons' => true)); Theme::Set('table_cols', $cols); $rows = array(); foreach ($users as $row) { $row['libraryQuotaText'] = $row['object']->libraryQuota == 0 ? '' : Kit::formatBytes($row['object']->libraryQuota * 1024); // Super admins have some buttons if ($user->usertypeid == 1) { // Edit $row['buttons'][] = array('id' => 'user_button_edit', 'url' => 'index.php?p=user&q=DisplayForm&userID=' . $row['userid'], 'text' => __('Edit')); // Delete $row['buttons'][] = array('id' => 'user_button_delete', 'url' => 'index.php?p=user&q=DeleteForm&userID=' . $row['userid'], 'text' => __('Delete')); // Page Security $row['buttons'][] = array('id' => 'user_button_page_security', 'url' => 'index.php?p=group&q=PageSecurityForm&groupid=' . $row['object']->groupId, 'text' => __('Page Security')); // Menu Security $row['buttons'][] = array('id' => 'user_button_menu_security', 'url' => 'index.php?p=group&q=MenuItemSecurityForm&groupid=' . $row['object']->groupId, 'text' => __('Menu Security')); // Applications $row['buttons'][] = array('id' => 'user_button_applications', 'url' => 'index.php?p=oauth&q=UserTokens&userID=' . $row['userid'], 'text' => __('Applications')); // Set Home Page $row['buttons'][] = array('id' => 'user_button_homepage', 'url' => 'index.php?p=user&q=SetUserHomePageForm&userid=' . $row['userid'], 'text' => __('Set Homepage')); // Set Password $row['buttons'][] = array('id' => 'user_button_delete', 'url' => 'index.php?p=user&q=SetPasswordForm&userid=' . $row['userid'], 'text' => __('Set Password')); // User Quota $row['buttons'][] = array('id' => 'usergroup_button_quota', 'url' => 'index.php?p=group&q=quotaForm&groupid=' . $row['object']->groupId, 'text' => __('Set User Quota')); } $rows[] = $row; } Theme::Set('table_rows', $rows); $table = Theme::RenderReturn('table_render'); $response->SetGridResponse($table); $response->Respond(); }
function displayPage() { // Set up some suffixes $suffixes = array('bytes', 'k', 'M', 'G', 'T'); // Get some data for a bandwidth chart try { $dbh = PDOConnect::init(); $sth = $dbh->prepare('SELECT FROM_UNIXTIME(month) AS month, IFNULL(SUM(Size), 0) AS size FROM `bandwidth` WHERE month > :month GROUP BY FROM_UNIXTIME(month) ORDER BY MIN(month);'); $sth->execute(array('month' => time() - 86400 * 365)); $results = $sth->fetchAll(); // Monthly bandwidth - optionally tested against limits $xmdsLimit = Config::GetSetting('MONTHLY_XMDS_TRANSFER_LIMIT_KB'); $maxSize = 0; foreach ($results as $row) { $maxSize = $row['size'] > $maxSize ? $row['size'] : $maxSize; } // Decide what our units are going to be, based on the size $base = $maxSize == 0 ? 0 : floor(log($maxSize) / log(1024)); if ($xmdsLimit > 0) { // Convert to appropriate size (xmds limit is in KB) $xmdsLimit = $xmdsLimit * 1024 / pow(1024, $base); Theme::Set('xmdsLimit', $xmdsLimit . ' ' . $suffixes[$base]); } $output = array(); foreach ($results as $row) { $size = (double) $row['size'] / pow(1024, $base); $remaining = $xmdsLimit - $size; $output[] = array('label' => DateManager::getLocalDate(DateManager::getDateFromGregorianString($row['month']), 'F'), 'value' => round($size, 2), 'limit' => round($remaining, 2)); } // What if we are empty? if (count($output) == 0) { $output[] = array('label' => DateManager::getLocalDate(null, 'F'), 'value' => 0, 'limit' => 0); } // Set the data Theme::Set('xmdsLimitSet', $xmdsLimit > 0); Theme::Set('bandwidthSuffix', $suffixes[$base]); Theme::Set('bandwidthWidget', json_encode($output)); // We would also like a library usage pie chart! $libraryLimit = Config::GetSetting('LIBRARY_SIZE_LIMIT_KB'); $libraryLimit = $libraryLimit * 1024; // Library Size in Bytes $sth = $dbh->prepare('SELECT IFNULL(SUM(FileSize), 0) AS SumSize, type FROM media GROUP BY type;'); $sth->execute(); $results = $sth->fetchAll(); // Do we base the units on the maximum size or the library limit $maxSize = 0; if ($libraryLimit > 0) { $maxSize = $libraryLimit; } else { // Find the maximum sized chunk of the items in the library foreach ($results as $library) { $maxSize = $library['SumSize'] > $maxSize ? $library['SumSize'] : $maxSize; } } // Decide what our units are going to be, based on the size $base = $maxSize == 0 ? 0 : floor(log($maxSize) / log(1024)); $output = array(); $totalSize = 0; foreach ($results as $library) { $output[] = array('value' => round((double) $library['SumSize'] / pow(1024, $base), 2), 'label' => ucfirst($library['type'])); $totalSize = $totalSize + $library['SumSize']; } // Do we need to add the library remaining? if ($libraryLimit > 0) { $remaining = round(($libraryLimit - $totalSize) / pow(1024, $base), 2); $output[] = array('value' => $remaining, 'label' => __('Free')); } // What if we are empty? if (count($output) == 0) { $output[] = array('label' => __('Empty'), 'value' => 0); } Theme::Set('libraryLimitSet', $libraryLimit); Theme::Set('libraryLimit', round((double) $libraryLimit / pow(1024, $base), 2) . ' ' . $suffixes[$base]); Theme::Set('librarySize', Kit::formatBytes($totalSize, 1)); Theme::Set('librarySuffix', $suffixes[$base]); Theme::Set('libraryWidget', json_encode($output)); // Also a display widget $sort_order = array('display'); $displays = $this->user->DisplayList($sort_order); $rows = array(); if (is_array($displays) && count($displays) > 0) { // Output a table showing the displays foreach ($displays as $row) { $row['mediainventorystatus'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'danger' : 'warning'); // Assign this to the table row $rows[] = $row; } } Theme::Set('display-widget-rows', $rows); // Get a count of users $sth = $dbh->prepare('SELECT IFNULL(COUNT(*), 0) AS count_users FROM `user`'); $sth->execute(); Theme::Set('countUsers', $sth->fetchColumn(0)); // Get a count of active layouts $sth = $dbh->prepare('SELECT IFNULL(COUNT(*), 0) AS count_scheduled FROM `schedule_detail` WHERE :now BETWEEN FromDT AND ToDT'); $sth->execute(array('now' => time())); Theme::Set('nowShowing', $sth->fetchColumn(0)); // Latest news if (Config::GetSetting('DASHBOARD_LATEST_NEWS_ENABLED') == 1) { // Make sure we have the cache location configured Kit::ClassLoader('file'); $file = new File($this->db); File::EnsureLibraryExists(); // Use SimplePie to get the feed include_once '3rdparty/simplepie/autoloader.php'; $feed = new SimplePie(); $feed->set_cache_location($file->GetLibraryCacheUri()); $feed->set_feed_url(Theme::GetConfig('latest_news_url')); $feed->set_cache_duration(86400); $feed->handle_content_type(); $feed->init(); $latestNews = array(); if ($feed->error()) { Debug::LogEntry('audit', 'Feed Error: ' . $feed->error(), get_class(), __FUNCTION__); } else { // Store our formatted items foreach ($feed->get_items() as $item) { $latestNews[] = array('title' => $item->get_title(), 'description' => $item->get_description(), 'link' => $item->get_link()); } } Theme::Set('latestNews', $latestNews); } else { Theme::Set('latestNews', array(array('title' => __('Latest news not enabled.'), 'description' => '', 'link' => ''))); } } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage()); // Show the error in place of the bandwidth chart Theme::Set('widget-error', 'Unable to get widget details'); } // Do we have an embedded widget? Theme::Set('embedded-widget', html_entity_decode(Config::GetSetting('EMBEDDED_STATUS_WIDGET'))); // Render the Theme and output Theme::Render('status_dashboard'); }