aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-25 14:55:05 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-25 14:55:05 +0000
commit7d49e67a72a814f6261712390521531dfd7d0a33 (patch)
treee5a37e74cf5cfa5b3def71d5213acf441b0e7bc4 /engine/lib
parent223e5d08b3333dc93519676580b6d892ff7e19c3 (diff)
downloadelgg-7d49e67a72a814f6261712390521531dfd7d0a33.tar.gz
elgg-7d49e67a72a814f6261712390521531dfd7d0a33.tar.bz2
Made the friends river entities functions loads more efficient.
git-svn-id: https://code.elgg.org/elgg/trunk@1126 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/river.php36
-rw-r--r--engine/lib/system_log.php19
2 files changed, 44 insertions, 11 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 8e88c4c32..a6c29a9d6 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -35,11 +35,16 @@
{
// set start limit and offset
$cnt = $limit; // Didn' cast to int here deliberately
- $off = $offset; // here too
- $by_user = (int)$by_user;
- if ($by_user)
- $by_user_obj = get_entity($by_user);
-
+ $off = $offset; // here too
+
+ if (is_array($by_user) && sizeof($by_user) > 0) {
+ foreach($by_user as $key => $val) {
+ $by_user[$key] = (int) $val;
+ }
+ } else {
+ $by_user = (int)$by_user;
+ }
+
$exit = false;
// River objects
@@ -129,6 +134,25 @@
);
return $river;
+ }
+
+ /**
+ * Extract a list of river events from the current system log, from a given user's friends.
+ *
+ * @seeget_river_entries
+ * @param int $by_user The user whose friends we're checking for.
+ * @param int $limit Maximum number of events to show
+ * @param int $offset An offset
+ * @return array of river entities rendered with the appropriate view.
+ */
+ function get_river_entries_friends($by_user, $limit = 10, $offset = 0) {
+ if ($friends = get_user_friends($by_user)) {
+ $friendsarray = array();
+ foreach($friends as $friend) {
+ $friendsarray[] = $friend->getGUID();
+ }
+ }
+ return get_river_entries($friendsarray,"",$limit,$offset);
}
/**
@@ -154,6 +178,6 @@
*/
function elgg_view_friend_river($guid, $limit = 10, $offset = 0, $view = 'river/dashboard')
{
- return elgg_view($view, array('river' => get_river_entries($guid,"friend", $limit, $offset)));
+ return elgg_view($view, array('river' => get_river_entries_friends($guid, $limit, $offset)));
}
?> \ No newline at end of file
diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php
index 52ec6bee0..fbf0b073a 100644
--- a/engine/lib/system_log.php
+++ b/engine/lib/system_log.php
@@ -63,8 +63,14 @@
function get_system_log($by_user = "", $event = "", $class = "", $limit = 10, $offset = 0)
{
global $CONFIG;
-
- $by_user = (int)$by_user;
+
+ if (is_array($by_user) && sizeof($by_user) > 0) {
+ foreach($by_user as $key => $val) {
+ $by_user[$key] = (int) $val;
+ }
+ } else {
+ $by_user = (int)$by_user;
+ }
$event = sanitise_string($event);
$class = sanitise_string($class);
$limit = (int)$limit;
@@ -72,8 +78,11 @@
$where = array();
- if ($by_user != "")
- $where[] = "performed_by_guid=$by_user";
+ if (is_int($by_user) && $by_user > 0) {
+ $where[] = "performed_by_guid=$by_user";
+ } else if (is_array($by_user)) {
+ $where [] = "performed_by_guid in (". implode(",",$by_user) .")";
+ }
if ($event != "")
$where[] = "event='$event'";
if ($class!=="")
@@ -84,7 +93,7 @@
$query .= " and $w";
$query .= " order by time_created desc";
- $query .= " limit $offset, $limit"; // Add order and limit
+ $query .= " limit $offset, $limit"; // Add order and limit
return get_data($query);
}