]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2402 adds 'add' 'river' plugin hook
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 13 Jan 2011 02:57:43 +0000 (02:57 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 13 Jan 2011 02:57:43 +0000 (02:57 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7877 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/river.php

index f098c0c9ee74bc77fe014b7e09902f435c702ef9..38197e387f7322c3e306b09bb633710f289d27e0 100644 (file)
@@ -47,20 +47,41 @@ $posted = 0, $annotation_id = 0) {
        $subtype = $object->getSubtype();
        $action_type = sanitise_string($action_type);
 
+       $params = array(
+               'type' => $type,
+               'subtype' => $subtype,
+               'action_type' => $action_type,
+               'access_id' => $access_id,
+               'view' => $view,
+               'subject_guid' => $subject_guid,
+               'object_guid' => $object_guid,
+               'annotation_id' => $annotation_id,
+               'posted' => $posted,
+       );
+
+       // return false to stop insert
+       $params = elgg_trigger_plugin_hook('add', 'river', null, $params);
+       if ($params == false) {
+               // inserting did not fail - it was just prevented
+               return true;
+       }
+
+       extract($params);
+
        // Load config
        global $CONFIG;
 
        // Attempt to save river item; return success status
        $insert_data = insert_data("insert into {$CONFIG->dbprefix}river " .
-               " set type = '{$type}', " .
-               " subtype = '{$subtype}', " .
-               " action_type = '{$action_type}', " .
-               " access_id = {$access_id}, " .
-               " view = '{$view}', " .
-               " subject_guid = {$subject_guid}, " .
-               " object_guid = {$object_guid}, " .
-               " annotation_id = {$annotation_id}, " .
-               " posted = {$posted} ");
+               " set type = '$type', " .
+               " subtype = '$subtype', " .
+               " action_type = '$action_type', " .
+               " access_id = $access_id, " .
+               " view = '$view', " .
+               " subject_guid = $subject_guid, " .
+               " object_guid = $object_guid, " .
+               " annotation_id = $annotation_id, " .
+               " posted = $posted");
 
        //update the entities which had the action carried out on it
        if ($insert_data) {