public function Index() { $this->AddJsFile('settings.js'); $this->Title(Translate('Dashboard')); $this->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Routes.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Applications.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Plugins.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Themes.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Registration.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Applicants.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Roles.Manage'; $this->RequiredAdminPermissions[] = 'Garden.Users.Add'; $this->RequiredAdminPermissions[] = 'Garden.Users.Edit'; $this->RequiredAdminPermissions[] = 'Garden.Users.Delete'; $this->RequiredAdminPermissions[] = 'Garden.Users.Approve'; $this->FireEvent('DefineAdminPermissions'); $this->Permission($this->RequiredAdminPermissions, '', FALSE); $this->AddSideMenu('garden/settings'); $UserModel = Gdn::UserModel(); // Load some data to display on the dashboard $this->BuzzData = array(); // Get the number of users in the database $CountUsers = $UserModel->GetCountLike(); $this->AddDefinition('CountUsers', $CountUsers); $this->BuzzData[Translate('Users')] = number_format($CountUsers); // Get the number of new users in the last day $this->BuzzData[Translate('New users in the last day')] = number_format($UserModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 day'))))); // Get the number of new users in the last week $this->BuzzData[Translate('New users in the last week')] = number_format($UserModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 week'))))); // Get recently active users $this->ActiveUserData = $UserModel->GetActiveUsers(5); // Check to see if the application needs to phone-home for updates. Doing // this here because this method is always called when admin pages are // loaded regardless of the application loading them. $UpdateCheckDate = Gdn::Config('Garden.UpdateCheckDate', ''); if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) { $UpdateData = array(); // Grab all of the plugins & versions $PluginManager = Gdn::Factory('PluginManager'); $Plugins = $PluginManager->AvailablePlugins(); foreach ($Plugins as $Plugin => $Info) { $Name = ArrayValue('Name', $Info, $Plugin); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Plugin'); } } // Grab all of the applications & versions $ApplicationManager = Gdn::Factory('ApplicationManager'); $Applications = $ApplicationManager->AvailableApplications(); foreach ($Applications as $Application => $Info) { $Name = ArrayValue('Name', $Info, $Application); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Application'); } } // Grab all of the themes & versions $ThemeManager = new Gdn_ThemeManager(); $Themes = $ThemeManager->AvailableThemes(); foreach ($Themes as $Theme => $Info) { $Name = ArrayValue('Name', $Info, $Theme); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Theme'); } } // Dump the entire set of information into the definition list (jQuery // will pick it up and ping the VanillaForums.org server with this info). $this->AddDefinition('UpdateChecks', Format::Serialize($UpdateData)); } // Fire an event so other applications can add some data to be displayed $this->FireEvent('DashboardData'); $this->Render(); }
/** * Adds information to the definition list that causes the app to "phone * home" and see if there are upgrades available. Currently added to the * dashboard only. * Nothing renders with this method. It is public so it can be added by * plugins. */ public function AddUpdateCheck() { if (C('Garden.NoUpdateCheck')) { return; } // Check to see if the application needs to phone-home for updates. Doing // this here because this method is always called when admin pages are // loaded regardless of the application loading them. $UpdateCheckDate = Gdn::Config('Garden.UpdateCheckDate', ''); if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) { $UpdateData = array(); // Grab all of the plugins & versions $Plugins = Gdn::PluginManager()->AvailablePlugins(); foreach ($Plugins as $Plugin => $Info) { $Name = ArrayValue('Name', $Info, $Plugin); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Plugin'); } } // Grab all of the applications & versions $ApplicationManager = Gdn::Factory('ApplicationManager'); $Applications = $ApplicationManager->AvailableApplications(); foreach ($Applications as $Application => $Info) { $Name = ArrayValue('Name', $Info, $Application); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Application'); } } // Grab all of the themes & versions $ThemeManager = new Gdn_ThemeManager(); $Themes = $ThemeManager->AvailableThemes(); foreach ($Themes as $Theme => $Info) { $Name = ArrayValue('Name', $Info, $Theme); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Theme'); } } // Dump the entire set of information into the definition list (jQuery // will pick it up and ping the VanillaForums.org server with this info). $this->AddDefinition('UpdateChecks', Gdn_Format::Serialize($UpdateData)); } }
/** * Adds information to the definition list that causes the app to "phone * home" and see if there are upgrades available. * * Currently added to the dashboard only. Nothing renders with this method. * It is public so it can be added by plugins. */ public function addUpdateCheck() { if (c('Garden.NoUpdateCheck')) { return; } // Check to see if the application needs to phone-home for updates. Doing // this here because this method is always called when admin pages are // loaded regardless of the application loading them. $UpdateCheckDate = Gdn::config('Garden.UpdateCheckDate', ''); if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) { $UpdateData = array(); // Grab all of the available addons & versions. foreach ([Addon::TYPE_ADDON, Addon::TYPE_THEME] as $type) { $addons = Gdn::addonManager()->lookupAllByType($type); /* @var Addon $addon */ foreach ($addons as $addon) { $UpdateData[] = ['Name' => $addon->getRawKey(), 'Version' => $addon->getVersion(), 'Type' => $addon->getSpecial('oldType', $type)]; } } // Dump the entire set of information into the definition list. The client will ping the server for updates. $this->addDefinition('UpdateChecks', $UpdateData); } }