aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/entities.php5
-rw-r--r--engine/lib/extender.php5
-rw-r--r--engine/lib/relationships.php5
-rw-r--r--engine/lib/river.php54
-rw-r--r--engine/lib/system_log.php13
5 files changed, 60 insertions, 22 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 3d206f783..f08c58383 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -557,6 +557,11 @@
* This is useful for checking access permissions etc on objects.
*/
public function getObjectFromID($id) { return get_entity($id); }
+
+ /**
+ * Return the GUID of the owner of this object.
+ */
+ public function getObjectOwnerGUID() { return $this->owner_guid; }
// ITERATOR INTERFACE //////////////////////////////////////////////////////////////
/*
diff --git a/engine/lib/extender.php b/engine/lib/extender.php
index 8221124af..e8bb54880 100644
--- a/engine/lib/extender.php
+++ b/engine/lib/extender.php
@@ -146,6 +146,11 @@
*/
public function getClassName() { return get_class($this); }
+ /**
+ * Return the GUID of the owner of this object.
+ */
+ public function getObjectOwnerGUID() { return $this->owner_guid; }
+
// ITERATOR INTERFACE //////////////////////////////////////////////////////////////
/*
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 3f053460a..e60e19fdf 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -191,6 +191,11 @@
*/
public function getObjectFromID($id) { return get_relationship($id); }
+ /**
+ * Return the GUID of the owner of this object.
+ */
+ public function getObjectOwnerGUID() { return $this->owner_guid; }
+
// ITERATOR INTERFACE //////////////////////////////////////////////////////////////
/*
* This lets an entity's attributes be displayed using foreach as a normal array.
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 545309abf..32fa74516 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -23,16 +23,22 @@
* It returns an array of the result of each of these views.
*
* \TODO: Limit to just one user or just one user's friends
+ * \TODO: Make this more efficient / reduce DB queries.
*
- * @param int $limit
- * @param int $offset
+ * @param int $by_user The user who initiated the event.
+ * @param string $relationship Limit return results to only those users who $by_user has $relationship with.
+ * @param int $limit Maximum number of events to show
+ * @param int $offset An offset
* @return array
*/
- function get_river_entries($limit = 10, $offset = 0)
+ function get_river_entries($by_user = "", $relationship = "", $limit = 10, $offset = 0)
{
// set start limit and offset
- $cnt = $limit;
- $off = $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);
$exit = false;
@@ -41,7 +47,7 @@
do
{
- $log_events = get_system_log("","", $cnt, $off);
+ $log_events = get_system_log($by_user, "","", $cnt, $off);
if (!$log_events)
$exit = true;
@@ -59,20 +65,30 @@
// Exists and we have access to it
if (is_a($object, $class))
{
- // See if anything can handle it
- $tam = "";
-
- // test if view exist and if so
- $tam = elgg_view("river/$class/$event", array(
- 'performed_by' => get_entity($log->performed_by_guid),
- 'log_entry' => $log,
- 'object' => $object
- ));
-
- if ($tam)
+ // If no relationship defined or it matches $relationship
+ if (
+ (!$relationship) ||
+ (
+ ($relationship) &&
+ (check_entity_relationship($by_user, $relationship, $log->getObjectOwnerGUID()))
+ )
+ )
{
- $river[] = $tam;
- $cnt--;
+ // See if anything can handle it
+ $tam = "";
+
+ // test if view exist and if so
+ $tam = elgg_view("river/$class/$event", array(
+ 'performed_by' => ($by_user_obj instanceof ElggUser) ? $by_user_obj : get_entity($log->performed_by_guid),
+ 'log_entry' => $log,
+ 'object' => $object
+ ));
+
+ if ($tam)
+ {
+ $river[] = $tam;
+ $cnt--;
+ }
}
}
diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php
index fbb9f9d96..a9d0bfb38 100644
--- a/engine/lib/system_log.php
+++ b/engine/lib/system_log.php
@@ -44,29 +44,36 @@
* This is useful for checking access permissions etc on objects.
*/
public function getObjectFromID($id);
+
+ /**
+ * Return the GUID of the owner of this object.
+ */
+ public function getObjectOwnerGUID();
}
/**
* Retrieve the system log based on a number of parameters.
*
+ * @param int $by_user The user who initiated the event.
* @param string $event The event you are searching on.
* @param string $class The class of object it effects.
* @param int $limit Maximum number of responses to return.
* @param int $offset Offset of where to start.
*/
- function get_system_log($event = "", $class = "", $limit = 10, $offset = 0)
+ function get_system_log($by_user = "", $event = "", $class = "", $limit = 10, $offset = 0)
{
global $CONFIG;
+ $by_user = (int)$by_user;
$event = sanitise_string($event);
$class = sanitise_string($class);
$limit = (int)$limit;
$offset = (int)$offset;
- $access = get_access_list();
-
$where = array();
+ if ($by_user != "")
+ $where[] = "performed_by_guid=$by_user";
if ($event != "")
$where[] = "event='$event'";
if ($class!=="")