From e29500440b1848f192bc56a1bad89eac69408e7b Mon Sep 17 00:00:00 2001 From: benbro Date: Mon, 20 Jun 2011 08:43:09 +0300 Subject: added find_active_users hook --- engine/lib/users.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'engine/lib/users.php') diff --git a/engine/lib/users.php b/engine/lib/users.php index 59bfa1259..e7e1a57f0 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -625,31 +625,37 @@ function get_user_by_email($email) { /** * A function that returns a maximum of $limit users who have done something within the last - * $seconds seconds. + * $seconds seconds or the total count of active users. * * @param int $seconds Number of seconds (default 600 = 10min) * @param int $limit Limit, default 10. - * @param int $offset Offset, defualt 0. + * @param int $offset Offset, default 0. + * @param bool $count Count, default false. * * @return mixed */ -function find_active_users($seconds = 600, $limit = 10, $offset = 0) { - global $CONFIG; - +function find_active_users($seconds = 600, $limit = 10, $offset = 0, $count = false) { $seconds = (int)$seconds; $limit = (int)$limit; $offset = (int)$offset; + $params = array('seconds' => $seconds, 'limit' => $limit, 'offset' => $offset, 'count' => $count); + $data = elgg_trigger_plugin_hook('find_active_users', 'system', $params, NULL); + if (!$data) { + global $CONFIG; - $time = time() - $seconds; - - $access = get_access_sql_suffix("e"); - - $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} and $access - order by u.last_action desc limit {$offset}, {$limit}"; + $time = time() - $seconds; - return get_data($query, "entity_row_to_elggstar"); + $data = elgg_get_entities(array( + 'type' => 'user', + 'limit' => $limit, + 'offset' => $offset, + 'count' => $count, + 'joins' => array("join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid"), + 'wheres' => array("u.last_action >= {$time}"), + 'order_by' => "u.last_action desc" + )); + } + return $data; } /** -- cgit v1.2.3 From 7a163a886170aa436807f24590dd6c48503ed970 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 9 Jul 2011 12:06:05 -0400 Subject: fixed redirect for user avatars if we cannot get the user --- engine/lib/users.php | 5 ++++- pages/avatar/view.php | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'engine/lib/users.php') diff --git a/engine/lib/users.php b/engine/lib/users.php index e7e1a57f0..48f10f974 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1383,7 +1383,10 @@ function elgg_profile_fields_setup() { function elgg_avatar_page_handler($page) { global $CONFIG; - set_input('username', $page[1]); + $user = get_user_by_username($page[1]); + if ($user) { + elgg_set_page_owner_guid($user->getGUID()); + } if ($page[0] == 'edit') { require_once("{$CONFIG->path}pages/avatar/edit.php"); diff --git a/pages/avatar/view.php b/pages/avatar/view.php index 55ae00e16..eb2cd1010 100644 --- a/pages/avatar/view.php +++ b/pages/avatar/view.php @@ -13,9 +13,9 @@ if (!in_array($size, array('master', 'large', 'medium', 'small', 'tiny', 'topbar // If user doesn't exist, return default icon if (!$user) { - $path = elgg_view("icon/user/default/$size"); - header("Location: $path"); - exit; + $url = "_graphics/icons/user/default{$size}"; + $url = elgg_normalize_url($url); + forward($url); } // Try and get the icon @@ -31,9 +31,9 @@ if ($filehandler->open("read")) { } if (!$success) { - $path = elgg_view('icon/user/default/'.$size); - header("Location: {$path}"); - exit; + $url = "_graphics/icons/user/default{$size}"; + $url = elgg_normalize_url($url); + forward($url); } header("Content-type: image/jpeg"); -- cgit v1.2.3