aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/river.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-23 16:31:53 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-23 16:31:53 +0000
commitd98c0d4c6c56d015958bdc88baa00d6ca6bcb70d (patch)
tree3aa101d7d1364ec717e22225313dd0663018a433 /engine/lib/river.php
parente231b7079e97f4c4a7d48670a63176f3b62158b9 (diff)
downloadelgg-d98c0d4c6c56d015958bdc88baa00d6ca6bcb70d.tar.gz
elgg-d98c0d4c6c56d015958bdc88baa00d6ca6bcb70d.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Support for river entries git-svn-id: https://code.elgg.org/elgg/trunk@701 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/river.php')
-rw-r--r--engine/lib/river.php71
1 files changed, 70 insertions, 1 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index d1b55ad11..dd6da4801 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -11,5 +11,74 @@
* @link http://elgg.org/
*/
- // event listener
+ /**
+ * Extract a list of river events from the current system log.
+ * This function retrieves the objects from the system log and will attempt to render
+ * the view "river/CLASSNAME" where CLASSNAME is the class of the object the system event is referring to.
+ *
+ * This view will be passed the log entry (as 'log_entry') and the object (as 'object') which will be accessable
+ * through the $vars[] array.
+ *
+ * It returns an array of the result of each of these views.
+ *
+ * @param int $limit
+ * @param int $offset
+ * @return array
+ */
+ function get_river_entries($limit = 10, $offset = 0)
+ {
+ // set start limit and offset
+ $cnt = $limit;
+ $off = $offset;
+
+ $exit = false;
+
+ // River objects
+ $river = array();
+
+ do
+ {
+ $log_events = get_system_log("","", $cnt, $off);
+
+ if (!$log_events)
+ $exit = true;
+ else
+ {
+ foreach ($log_events as $log)
+ {
+ // See if we have access to the object we're talking about
+ $class = $log->object_class;
+ $tmp = new $class();
+ $object = $tmp->getObjectFromID($log->object_id);
+
+ // 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", array(
+ 'log_entry' => $log,
+ 'object' => $object
+ ));
+
+ if ($tam)
+ {
+ $river[] = $tam;
+ $off++;
+ $cnt--;
+ }
+ }
+ }
+ }
+
+ } while (
+ ($cnt > 0) &&
+ (!$exit)
+ );
+
+ return $river;
+ }
+
?> \ No newline at end of file