45 if (empty($action_type)) {
81 'subtype' =>
$object->getSubtype(),
82 'action_type' => $action_type,
83 'access_id' => $access_id,
85 'subject_guid' => $subject_guid,
86 'object_guid' => $object_guid,
87 'target_guid' => $target_guid,
88 'annotation_id' => $annotation_id,
93 'subtype' =>
'string',
94 'action_type' =>
'string',
97 'subject_guid' =>
'int',
98 'object_guid' =>
'int',
99 'target_guid' =>
'int',
100 'annotation_id' =>
'int',
106 if ($values ==
false) {
114 $assignments = array();
117 $assignments[] =
"$name = '{$values[$name]}'";
120 $id =
insert_data(
"INSERT INTO {$dbprefix}river SET " . implode(
',', $assignments));
190 $singulars = array(
'id',
'subject_guid',
'object_guid',
'target_guid',
'annotation_id',
'action_type',
'view',
'type',
'subtype');
205 if (
$options[
'posted_time_lower'] && is_int(
$options[
'posted_time_lower'])) {
206 $wheres[] =
"rv.posted >= {$options['posted_time_lower']}";
209 if (
$options[
'posted_time_upper'] && is_int(
$options[
'posted_time_upper'])) {
210 $wheres[] =
"rv.posted <= {$options['posted_time_upper']}";
215 foreach ($wheres as $i => $where) {
216 if ($where ===
false) {
218 } elseif (empty($where)) {
224 $wheres = array_unique($wheres);
226 $query =
"DELETE rv.* FROM {$CONFIG->dbprefix}river rv ";
229 $joins = array_unique(
$options[
'joins']);
232 foreach ($joins as $j) {
239 foreach ($wheres as $w) {
240 $query .=
" $w AND ";
298 'relationship' => null,
299 'relationship_guid' => null,
300 'inverse_relationship' =>
false,
314 'order_by' =>
'rv.posted desc',
323 $singulars = array(
'id',
'subject_guid',
'object_guid',
'target_guid',
'annotation_id',
'action_type',
'type',
'subtype');
337 if (
$options[
'posted_time_lower'] && is_int(
$options[
'posted_time_lower'])) {
338 $wheres[] =
"rv.posted >= {$options['posted_time_lower']}";
341 if (
$options[
'posted_time_upper'] && is_int(
$options[
'posted_time_upper'])) {
342 $wheres[] =
"rv.posted <= {$options['posted_time_upper']}";
346 $wheres[] =
"rv.enabled = 'yes'";
352 $joins[] =
"JOIN {$dbprefix}entities oe ON rv.object_guid = oe.guid";
354 $joins[] =
"LEFT JOIN {$dbprefix}entities te ON rv.target_guid = te.guid";
356 if (
$options[
'relationship_guid']) {
363 $wheres = array_merge($wheres, $clauses[
'wheres']);
364 $joins = array_merge($joins, $clauses[
'joins']);
370 foreach ($wheres as $i => $where) {
371 if ($where ===
false) {
373 } elseif (empty($where)) {
379 $wheres = array_unique($wheres);
382 $distinct =
$options[
'distinct'] ?
"DISTINCT" :
"";
384 $query =
"SELECT $distinct rv.* FROM {$CONFIG->dbprefix}river rv ";
387 $count_expr =
$options[
'distinct'] ?
"DISTINCT rv.id" :
"*";
389 $query =
"SELECT COUNT($count_expr) as total FROM {$CONFIG->dbprefix}river rv ";
393 foreach ($joins as $j) {
400 foreach ($wheres as $w) {
401 $query .=
" $w AND ";
411 $query .=
"$object_access_where AND ($target_access_where OR te.guid IS NULL) ";
416 $query .=
" GROUP BY {$options['group_by']}";
420 $query .=
" ORDER BY {$options['order_by']}";
425 $query .=
" LIMIT $offset, $limit";
428 $river_items =
get_data($query,
'_elgg_row_to_elgg_river_item');
434 return (
int)$total->total;
447 foreach ($river_items as
$item) {
449 $guids[$item->subject_guid] =
true;
452 $guids[$item->object_guid] =
true;
455 $guids[$item->target_guid] =
true;
464 'guids' => array_keys(
$guids),
472 foreach ($river_items as $item) {
473 $object = $item->getObjectEntity();
481 'guids' => array_keys(
$guids),
503 'offset' => (
int) max(
get_input(
'offset', 0), 0),
505 'pagination' =>
true,
506 'list_class' =>
'elgg-list-river',
543 if (!(
$row instanceof \stdClass)) {
547 return new \ElggRiverItem(
$row);
572 $types_wheres = array();
573 $subtypes_wheres = array();
576 if (!is_array($pairs)) {
578 if (!is_array($types)) {
579 $types = array($types);
581 foreach ($types as
$type) {
583 $types_wheres[] =
"({$table}.type = '$type')";
593 $subtypes_wheres[] =
"({$table}.subtype = '$subtype')";
597 if (is_array($types_wheres) && count($types_wheres)) {
598 $types_wheres = array(implode(
' OR ', $types_wheres));
601 if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
602 $subtypes_wheres = array(
'(' . implode(
' OR ', $subtypes_wheres) .
')');
605 $wheres = array(implode(
' AND ', array_merge($types_wheres, $subtypes_wheres)));
609 foreach ($pairs as $paired_type => $paired_subtypes) {
611 if (is_array($paired_subtypes)) {
612 $paired_subtypes = array_map(
'sanitise_string', $paired_subtypes);
613 $paired_subtype_str = implode(
"','", $paired_subtypes);
614 if ($paired_subtype_str) {
615 $wheres[] =
"({$table}.type = '$paired_type'" 616 .
" AND {$table}.subtype IN ('$paired_subtype_str'))";
620 $wheres[] =
"({$table}.type = '$paired_type'" 621 .
" AND {$table}.subtype = '$paired_subtype')";
626 if (is_array($wheres) && count($wheres)) {
627 $where = implode(
' OR ', $wheres);
648 if (!is_array($types)) {
650 return "(rv.action_type = '$types')";
654 $types_sanitized = array();
655 foreach ($types as
$type) {
659 $type_str = implode(
"','", $types_sanitized);
660 return "(rv.action_type IN ('$type_str'))";
677 if (!is_array($views)) {
679 return "(rv.view = '$views')";
683 $views_sanitized = array();
684 foreach ($views as
$view) {
688 $view_str = implode(
"','", $views_sanitized);
689 return "(rv.view IN ('$view_str'))";
702 $object_guid = (int) $object_guid;
703 $access_id = (int) $access_id;
708 $query =
"UPDATE {$CONFIG->dbprefix}river 709 SET access_id = {$access_id} 710 WHERE object_guid = {$object_guid}";
735 set_input(
'subject_username', $page_username);
740 require_once(
"{$CONFIG->path}pages/river.php");
750 $value[] = $CONFIG->path .
'engine/tests/ElggCoreRiverAPITest.php';
772 SET rv.enabled =
'no' 773 WHERE (rv.subject_guid = {$entity->guid} OR rv.object_guid = {$entity->guid} OR rv.target_guid = {$entity->guid});
799 LEFT JOIN {
$dbprefix}entities AS se ON se.guid = rv.subject_guid
800 LEFT JOIN {
$dbprefix}entities AS oe ON oe.guid = rv.object_guid
801 LEFT JOIN {
$dbprefix}entities AS te ON te.guid = rv.target_guid
802 SET rv.enabled =
'yes' 804 (se.enabled =
'yes' OR se.guid IS NULL) AND
805 (oe.enabled =
'yes' OR oe.guid IS NULL) AND
806 (te.enabled =
'yes' OR te.guid IS NULL)
808 AND (se.guid = {$entity->guid} OR oe.guid = {$entity->guid} OR te.guid = {$entity->guid});
821 $item = new \ElggMenuItem(
'activity',
elgg_echo(
'activity'),
'activity');
elgg_list_river(array $options=array())
List river items.
_elgg_river_get_action_where_sql($types)
Get the where clause based on river action type strings.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
get_data_row($query, $callback="")
Retrieve a single row from the database.
_elgg_river_init()
Initialize river library private.
if($guid==elgg_get_logged_in_user_guid()) $name
_elgg_river_get_view_where_sql($views)
Get the where clause based on river view strings.
_elgg_retrieve_cached_entity($guid)
Retrieve a entity from the cache.
_elgg_river_test($hook, $type, $value)
Register river unit tests private.
_elgg_get_guid_based_where_sql($column, $guids)
Returns SQL where clause for owner and containers.
update_entity_last_action($guid, $posted=null)
Update the last_action column in the entities table for $guid.
_elgg_prefetch_river_entities(array $river_items)
Prefetch entities that will be displayed in the river.
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
delete_data($query)
Remove a row from the database.
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
update_data($query)
Update a row in the database.
sanitize_string($string)
Sanitize a string for database use.
insert_data($query)
Insert a row into the database.
update_river_access_by_object($object_guid, $access_id)
Sets the access ID on river items for a particular object.
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
elgg_create_river_item(array $options=array())
Adds an item to the river.
_elgg_row_to_elgg_river_item($row)
Convert a database row to a new .
sanitise_string($string)
Wrapper function for alternate English spelling (.
const ELGG_ENTITIES_ANY_VALUE
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
elgg_get_entity_relationship_where_sql($column, $relationship=null, $relationship_guid=null, $inverse_relationship=false)
Returns SQL appropriate for relationship joins and wheres.
elgg global
Pointer to the global context.
elgg_register_menu_item($menu_name, $menu_item)
Register an item for an Elgg menu.
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
access_get_show_hidden_status()
Return current status of showing disabled entities.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
_elgg_river_enable($event, $type, $entity)
Enable river entries that reference a re-enabled entity as subject/object/target. ...
_elgg_river_disable($event, $type, $entity)
Disable river entries that reference a disabled entity as subject/object/target.
get_data($query, $callback="")
Retrieve rows from the database.
elgg_get_river(array $options=array())
Get river items.
elgg_delete_river(array $options=array())
Delete river items.
sanitise_int($int, $signed=true)
Sanitizes an integer for database use.
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
_elgg_river_page_handler($page)
Page handler for activity.
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
if(!$collection_name) $id
$options
Main activity stream list page.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
_elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs)
Returns SQL where clause for type and subtype on river table.
get_entity($guid)
Loads and returns an entity object from a guid.