45 if (empty($action_type)) {
94 'action_type' => $action_type,
95 'access_id' => $access_id,
97 'subject_guid' => $subject_guid,
98 'object_guid' => $object_guid,
99 'target_guid' => $target_guid,
100 'annotation_id' => $annotation_id,
106 if ($values ==
false) {
116 " SET type = '$type', " .
117 " subtype = '$subtype', " .
118 " action_type = '$action_type', " .
119 " access_id = $access_id, " .
120 " view = '$view', " .
121 " subject_guid = $subject_guid, " .
122 " object_guid = $object_guid, " .
123 " target_guid = $target_guid, " .
124 " annotation_id = $annotation_id, " .
125 " posted = $posted, " .
196 $singulars = array(
'id',
'subject_guid',
'object_guid',
'target_guid',
'annotation_id',
'action_type',
'view',
'type',
'subtype');
211 if (
$options[
'posted_time_lower'] && is_int(
$options[
'posted_time_lower'])) {
212 $wheres[] =
"rv.posted >= {$options['posted_time_lower']}";
215 if (
$options[
'posted_time_upper'] && is_int(
$options[
'posted_time_upper'])) {
216 $wheres[] =
"rv.posted <= {$options['posted_time_upper']}";
221 foreach ($wheres as $i => $where) {
222 if ($where ===
false) {
224 } elseif (empty($where)) {
230 $wheres = array_unique($wheres);
232 $query =
"DELETE rv.* FROM {$CONFIG->dbprefix}river rv ";
235 $joins = array_unique(
$options[
'joins']);
238 foreach ($joins as $j) {
245 foreach ($wheres as $w) {
246 $query .=
" $w AND ";
298 'relationship' => null,
299 'relationship_guid' => null,
300 'inverse_relationship' =>
false,
313 'order_by' =>
'rv.posted desc',
322 $singulars = array(
'id',
'subject_guid',
'object_guid',
'target_guid',
'annotation_id',
'action_type',
'type',
'subtype');
336 if (
$options[
'posted_time_lower'] && is_int(
$options[
'posted_time_lower'])) {
337 $wheres[] =
"rv.posted >= {$options['posted_time_lower']}";
340 if (
$options[
'posted_time_upper'] && is_int(
$options[
'posted_time_upper'])) {
341 $wheres[] =
"rv.posted <= {$options['posted_time_upper']}";
345 $wheres[] =
"rv.enabled = 'yes'";
351 $joins[] =
"JOIN {$dbprefix}entities oe ON rv.object_guid = oe.guid";
353 $joins[] =
"LEFT JOIN {$dbprefix}entities te ON rv.target_guid = te.guid";
355 if (
$options[
'relationship_guid']) {
362 $wheres = array_merge($wheres, $clauses[
'wheres']);
363 $joins = array_merge($joins, $clauses[
'joins']);
369 foreach ($wheres as $i => $where) {
370 if ($where ===
false) {
372 } elseif (empty($where)) {
378 $wheres = array_unique($wheres);
381 $query =
"SELECT DISTINCT rv.* FROM {$CONFIG->dbprefix}river rv ";
383 $query =
"SELECT COUNT(DISTINCT rv.id) AS total FROM {$CONFIG->dbprefix}river rv ";
387 foreach ($joins as $j) {
394 foreach ($wheres as $w) {
395 $query .=
" $w AND ";
405 $query .=
"$object_access_where AND ($target_access_where OR te.guid IS NULL) ";
410 $query .=
" GROUP BY {$options['group_by']}";
414 $query .=
" ORDER BY {$options['order_by']}";
419 $query .=
" LIMIT $offset, $limit";
422 $river_items =
get_data($query,
'_elgg_row_to_elgg_river_item');
428 return (
int)$total->total;
441 foreach ($river_items as
$item) {
443 $guids[$item->subject_guid] =
true;
446 $guids[$item->object_guid] =
true;
449 $guids[$item->target_guid] =
true;
458 'guids' => array_keys(
$guids),
465 foreach ($river_items as $item) {
466 $object = $item->getObjectEntity();
474 'guids' => array_keys(
$guids),
495 'offset' => (
int) max(
get_input(
'offset', 0), 0),
496 'limit' => (
int) max(
get_input(
'limit', 20), 0),
497 'pagination' =>
true,
498 'list_class' =>
'elgg-list-river',
535 if (!(
$row instanceof stdClass)) {
564 $types_wheres = array();
565 $subtypes_wheres = array();
568 if (!is_array($pairs)) {
570 if (!is_array($types)) {
571 $types = array($types);
573 foreach ($types as
$type) {
575 $types_wheres[] =
"({$table}.type = '$type')";
585 $subtypes_wheres[] =
"({$table}.subtype = '$subtype')";
589 if (is_array($types_wheres) && count($types_wheres)) {
590 $types_wheres = array(implode(
' OR ', $types_wheres));
593 if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
594 $subtypes_wheres = array(
'(' . implode(
' OR ', $subtypes_wheres) .
')');
597 $wheres = array(implode(
' AND ', array_merge($types_wheres, $subtypes_wheres)));
601 foreach ($pairs as $paired_type => $paired_subtypes) {
603 if (is_array($paired_subtypes)) {
604 $paired_subtypes = array_map(
'sanitise_string', $paired_subtypes);
605 $paired_subtype_str = implode(
"','", $paired_subtypes);
606 if ($paired_subtype_str) {
607 $wheres[] =
"({$table}.type = '$paired_type'" 608 .
" AND {$table}.subtype IN ('$paired_subtype_str'))";
612 $wheres[] =
"({$table}.type = '$paired_type'" 613 .
" AND {$table}.subtype = '$paired_subtype')";
618 if (is_array($wheres) && count($wheres)) {
619 $where = implode(
' OR ', $wheres);
640 if (!is_array($types)) {
642 return "(rv.action_type = '$types')";
646 $types_sanitized = array();
647 foreach ($types as
$type) {
651 $type_str = implode(
"','", $types_sanitized);
652 return "(rv.action_type IN ('$type_str'))";
669 if (!is_array($views)) {
671 return "(rv.view = '$views')";
675 $views_sanitized = array();
676 foreach ($views as
$view) {
680 $view_str = implode(
"','", $views_sanitized);
681 return "(rv.view IN ('$view_str'))";
694 $object_guid = (int) $object_guid;
695 $access_id = (int) $access_id;
700 $query =
"UPDATE {$CONFIG->dbprefix}river 701 SET access_id = {$access_id} 702 WHERE object_guid = {$object_guid}";
728 set_input(
'subject_username', $page_username);
733 require_once(
"{$CONFIG->path}pages/river.php");
743 $value[] = $CONFIG->path .
'engine/tests/ElggCoreRiverAPITest.php';
765 SET rv.enabled =
'no' 766 WHERE (rv.subject_guid = {$entity->guid} OR rv.object_guid = {$entity->guid} OR rv.target_guid = {$entity->guid});
792 LEFT JOIN {
$dbprefix}entities AS se ON se.guid = rv.subject_guid
793 LEFT JOIN {
$dbprefix}entities AS oe ON oe.guid = rv.object_guid
794 LEFT JOIN {
$dbprefix}entities AS te ON te.guid = rv.target_guid
795 SET rv.enabled =
'yes' 797 (se.enabled =
'yes' OR se.guid IS NULL) AND
798 (oe.enabled =
'yes' OR oe.guid IS NULL) AND
799 (te.enabled =
'yes' OR te.guid IS NULL)
801 AND (se.guid = {$entity->guid} OR oe.guid = {$entity->guid} OR te.guid = {$entity->guid});
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.
_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.
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 ElggEntity 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 ElggRiverItem.
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_admin_gatekeeper()
Used at the top of a page to mark it as admin only.
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.