aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-05-20 00:08:50 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-05-20 00:08:50 +0000
commit2ada5cbb1cb5311ec52446f1b4e9b19d1f47f2d9 (patch)
treee33b3547ca0287cfb724b2f10f1a5dfd6d0ab331 /engine
parent8342ead0d181b784f9eb2550d21dc374d8fbd5eb (diff)
downloadelgg-2ada5cbb1cb5311ec52446f1b4e9b19d1f47f2d9.tar.gz
elgg-2ada5cbb1cb5311ec52446f1b4e9b19d1f47f2d9.tar.bz2
Fixes #3300 adds a created,river event
git-svn-id: http://code.elgg.org/elgg/trunk@9104 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/river.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 49b070082..c467a351c 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -18,7 +18,7 @@
* @param int $posted The UNIX epoch timestamp of the river item (default: now)
* @param int $annotation_id The annotation ID associated with this river entry
*
- * @return bool Depending on success
+ * @return int/bool River ID or false on failure
*/
function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "",
$posted = 0, $annotation_id = 0) {
@@ -71,7 +71,7 @@ $posted = 0, $annotation_id = 0) {
extract($params);
// Attempt to save river item; return success status
- $insert_data = insert_data("insert into {$CONFIG->dbprefix}river " .
+ $id = insert_data("insert into {$CONFIG->dbprefix}river " .
" set type = '$type', " .
" subtype = '$subtype', " .
" action_type = '$action_type', " .
@@ -84,9 +84,16 @@ $posted = 0, $annotation_id = 0) {
// update the entities which had the action carried out on it
// @todo shouldn't this be down elsewhere? Like when an annotation is saved?
- if ($insert_data) {
+ if ($id) {
update_entity_last_action($object_guid, $posted);
- return $insert_data;
+
+ $river_items = elgg_get_river(array('id' => $id));
+ if ($river_items) {
+ elgg_trigger_event('created', 'river', $river_items[0]);
+ }
+ return $id;
+ } else {
+ return false;
}
}
@@ -166,6 +173,7 @@ function remove_from_river_by_id($id) {
* Get river items
*
* @param array $options
+ * ids => INT|ARR River item id(s)
* subject_guids => INT|ARR Subject guid(s)
* object_guids => INT|ARR Object guid(s)
* annotation_ids => INT|ARR The identifier of the annotation(s)
@@ -195,6 +203,8 @@ function elgg_get_river(array $options = array()) {
global $CONFIG;
$defaults = array(
+ 'ids' => ELGG_ENTITIES_ANY_VALUE,
+
'subject_guids' => ELGG_ENTITIES_ANY_VALUE,
'object_guids' => ELGG_ENTITIES_ANY_VALUE,
'annotation_ids' => ELGG_ENTITIES_ANY_VALUE,
@@ -224,11 +234,12 @@ function elgg_get_river(array $options = array()) {
$options = array_merge($defaults, $options);
- $singulars = array('subject_guid', 'object_guid', 'annotation_id', 'action_type', 'type', 'subtype');
+ $singulars = array('id', 'subject_guid', 'object_guid', 'annotation_id', 'action_type', 'type', 'subtype');
$options = elgg_normalise_plural_options_array($options, $singulars);
$wheres = $options['wheres'];
+ $wheres[] = elgg_get_guid_based_where_sql('rv.id', $options['ids']);
$wheres[] = elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']);
$wheres[] = elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']);
$wheres[] = elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']);