From b5d785ab9ad049b9db1b4ee1d50cc385a40eafa7 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 7 Jul 2008 19:56:56 +0000 Subject: Administration tweaks; fixed users online functions, as well as last_action functions, and the 'make admin' functionality git-svn-id: https://code.elgg.org/elgg/trunk@1326 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/admin/user/makeadmin.php | 2 +- engine/lib/admin.php | 3 ++- engine/lib/entities.php | 2 +- engine/lib/metadata.php | 2 +- engine/lib/sessions.php | 2 +- engine/lib/users.php | 17 +++++++++++++++-- views/default/admin/statistics_opt/numentities.php | 2 -- views/default/admin/statistics_opt/online.php | 6 ++++-- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/actions/admin/user/makeadmin.php b/actions/admin/user/makeadmin.php index b81f24b9d..6e537446f 100644 --- a/actions/admin/user/makeadmin.php +++ b/actions/admin/user/makeadmin.php @@ -32,5 +32,5 @@ system_message(elgg_echo('admin:user:makeadmin:no')); forward($_SERVER['HTTP_REFERER']); - exit; + ?> \ No newline at end of file diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 47704a4be..974f6b35d 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -47,7 +47,8 @@ register_action('admin/user/ban', false, "", true); register_action('admin/user/delete', false, "", true); - register_action('admin/user/resetpassword', false, "", true); + register_action('admin/user/resetpassword', false, "", true); + register_action('admin/user/makeadmin', false, "", true); // Register some actions register_action('admin/site/update_basic', false, "", true); // Register basic site admin action diff --git a/engine/lib/entities.php b/engine/lib/entities.php index abbd67bab..47ff916f8 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1357,7 +1357,7 @@ if ($entity = get_entity($entity_guid)) { $return = can_edit_entity($entity_guid, $user_guid); - $return = trigger_plugin_hook('permissions_check:metadata',$entity->type,null,$return); + $return = trigger_plugin_hook('permissions_check:metadata',$entity->type,array('entity' => $entity, 'user' => $user),$return); return $return; } else { return false; diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 130749bdd..1a8c58a2e 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -118,7 +118,7 @@ */ public function getObjectFromID($id) { return get_metadata($id); } } - + /** * Convert a database row to a new ElggMetadata * diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index 3116f500d..320813289 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -204,7 +204,7 @@ } } if ($_SESSION['id'] > 0) { - // set_last_action($_SESSION['id']); + set_last_action($_SESSION['id']); } register_action("login",true); diff --git a/engine/lib/users.php b/engine/lib/users.php index cec5c87c7..229735960 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -769,8 +769,7 @@ $time = time() - $seconds; - //$query = "SELECT * from {$CONFIG->dbprefix}entities where type='user' and time_updated>=$time order by time_updated desc limit $offset, $limit"; - $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}system_log s on e.guid=s.performed_by_guid where e.type='user' and s.time_created>=$time order by s.time_created desc limit $offset,$limit"; + $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid where u.last_action >= {$time} order by u.last_action desc limit {$offset},{$limit}"; return get_data($query, "entity_row_to_elggstar"); } @@ -939,6 +938,20 @@ require_once(dirname(dirname(dirname(__FILE__))) . "/friends/of.php"); } + + /** + * Sets the last action time of the given user to right now. + * + * @param int $user_guid The user GUID + */ + function set_last_action($user_guid) { + + $user_guid = (int) $user_guid; + global $CONFIG; + $time = time(); + update_data("update {$CONFIG->dbprefix}users_entity set prev_last_action = last_action, last_action = {$time} where guid = {$user_guid}"); + + } /** * Users initialisation function, which establishes the page handler diff --git a/views/default/admin/statistics_opt/numentities.php b/views/default/admin/statistics_opt/numentities.php index 0c7b39fb8..a424b78cf 100644 --- a/views/default/admin/statistics_opt/numentities.php +++ b/views/default/admin/statistics_opt/numentities.php @@ -20,7 +20,6 @@ $entry) { - echo ""; foreach ($entry as $a => $b) { if ($a == "__base__") @@ -34,7 +33,6 @@ END; } - echo "
"; } ?> diff --git a/views/default/admin/statistics_opt/online.php b/views/default/admin/statistics_opt/online.php index 50a207c03..f8721f3c3 100644 --- a/views/default/admin/statistics_opt/online.php +++ b/views/default/admin/statistics_opt/online.php @@ -10,8 +10,10 @@ * @link http://elgg.org/ */ - // users online - $users_online = get_online_users(); + // users online + get_context('search'); + $users_online = get_online_users(); + get_context('admin'); ?>
-- cgit v1.2.3