aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/river.php
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/river.php
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/river.php')
-rw-r--r--engine/lib/river.php36
1 files changed, 30 insertions, 6 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