diff options
-rw-r--r-- | engine/lib/river.php | 36 | ||||
-rw-r--r-- | engine/lib/system_log.php | 19 |
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); } |