aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-11-05 16:21:49 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-11-05 16:21:49 +0000
commitbddb9abb6b16c0fe89deb87a614c5a4435ec2e3d (patch)
treef9f140f296b6228fc7fdd311ffc64ab3cd3a8aec /engine/lib
parent33d366eb02ad272ec2167e1ea8d44ececa46fd9b (diff)
downloadelgg-bddb9abb6b16c0fe89deb87a614c5a4435ec2e3d.tar.gz
elgg-bddb9abb6b16c0fe89deb87a614c5a4435ec2e3d.tar.bz2
Slight rejig in the way the river works
git-svn-id: https://code.elgg.org/elgg/trunk@2406 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/river.php78
1 files changed, 53 insertions, 25 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 22f1b6c26..e6a6e12dc 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -230,6 +230,56 @@
}
/**
+ * Construct a river statement out of an entry in the system log.
+ *
+ * @param stdClass $log_entry
+ * @return mixed Either an ElggRiverStatement or false
+ */
+ function construct_riverstatement_from_log($log_entry)
+ {
+ if (!($log_entry instanceof stdClass)) return false;
+
+ $log = $log_entry;
+
+ // See if we have access to the object we're talking about
+ $event = $log->event;
+ $class = $log->object_class;
+ $type = $log->object_type;
+ $subtype = $log->object_subtype;
+ $tmp = new $class();
+ $object = $tmp->getObjectFromID($log->object_id);
+ $by_user_obj = get_entity($log->performed_by_guid);
+
+ if ( ($object) && ($object instanceof $class))
+ {
+ // Construct the statement
+ $statement_object = $object; // Simple object, we don't need to do more
+
+ // This is a relationship, slighty more complicated
+ if ($object instanceof ElggRelationship) {
+
+ $statement_object = array(
+ 'subject' => get_entity($object->guid_one),
+ 'relationship' => $object->relationship,// Didn' cast to int here deliberately
+ 'object' => get_entity($object->guid_two)
+ );
+
+ // Metadata or annotations, also slightly more complicated
+ } else if ($object instanceof ElggExtender) {
+ $statement_object = array(
+ 'subject' => $object,
+ 'object' => get_entity($object->entity_guid)
+ );
+ }
+
+ // Put together a river statement
+ return new ElggRiverStatement($by_user_obj, $event, $statement_object);
+ }
+
+ return false;
+ }
+
+ /**
* 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/EVENT" where CLASSNAME is the class of the object the system event is referring to,
@@ -275,7 +325,8 @@
{
foreach ($log_data as $log)
{
- // See if we have access to the object we're talking about
+ $statement = construct_riverstatement_from_log($log);
+
$event = $log->event;
$class = $log->object_class;
$type = $log->object_type;
@@ -285,33 +336,10 @@
$by_user_obj = get_entity($log->performed_by_guid);
// Belts and braces
- if ($object instanceof $class)
+ if ($statement)
{
$tam = "";
- // Construct the statement
- $statement_object = $object; // Simple object, we don't need to do more
-
- // This is a relationship, slighty more complicated
- if ($object instanceof ElggRelationship) {
-
- $statement_object = array(
- 'subject' => get_entity($object->guid_one),
- 'relationship' => $object->relationship,// Didn' cast to int here deliberately
- 'object' => get_entity($object->guid_two)
- );
-
- // Metadata or annotations, also slightly more complicated
- } else if ($object instanceof ElggExtender) {
- $statement_object = array(
- 'subject' => $object,
- 'object' => get_entity($object->entity_guid)
- );
- }
-
- // Put together a river statement
- $statement = new ElggRiverStatement($by_user_obj, $event, $statement_object);
-
// Now construct and call the appropriate views
if ($subtype == "widget") { // Special case for widgets