From 214e892a364d94e76253a2fc9c696130f4ee685f Mon Sep 17 00:00:00 2001 From: brettp Date: Sat, 19 Feb 2011 21:05:10 +0000 Subject: Installation loads 3 default widgets for the admin dashboard. git-svn-id: http://code.elgg.org/elgg/trunk@8347 36083f99-b078-4883-b0ff-0f9b5a30f544 --- install/ElggInstaller.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'install') diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php index 0bf04673f..2b8fd8324 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -28,6 +28,17 @@ class ElggInstaller { protected $autoLogin = FALSE; + /** + * @var array An array of widgets to add to the admin dashboard. + * + * @warning Columbus start on the right at 1. + * In the form column => array of handlers in order, top to bottom + */ + protected $adminWidgets = array( + 1 => array('content_stats'), + 2 => array('online_users', 'new_users'), + ); + /** * Constructor bootstraps the Elgg engine */ @@ -168,6 +179,8 @@ class ElggInstaller { if (!$this->createAdminAccount($params)) { throw new InstallationException(elgg_echo('install:admin:cannot_create')); } + + $this->addAdminWidgets(); } /** @@ -490,6 +503,7 @@ class ElggInstaller { * @return void */ protected function complete() { + $this->addAdminWidgets(); $params = array(); if ($this->autoLogin) { @@ -1345,6 +1359,39 @@ class ElggInstaller { } } + /** + * Adds default admin widgets to the admin dashboard. + * + * @return bool + */ + protected function addAdminWidgets() { + elgg_set_ignore_access(true); + // should only be one. + $users = elgg_get_entities(array( + 'type' => 'user', + 'limit' => 1, + )); + + if ($users) { + if ($users[0]->isAdmin()) { + $admin = $users[0]; + } + } else { + return false; + } + + foreach ($this->adminWidgets as $column => $handlers) { + foreach ($handlers as $position => $handler) { + $guid = elgg_create_widget($admin->getGUID(), $handler, 'admin'); + if ($guid) { + $widget = get_entity($guid); + $widget->move($column, $position); + } + } + } + elgg_set_ignore_access(false); + } + /** * Admin account support methods */ -- cgit v1.2.3