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;
463 'guids' => array_keys(
$guids),
471 foreach ($river_items as $item) {
472 $object = $item->getObjectEntity();
480 'guids' => array_keys(
$guids),
510 'offset' => (
int) max(
get_input(
'offset', 0), 0),
512 'pagination' =>
true,
513 'list_class' =>
'elgg-list-river',
550 if (!(
$row instanceof \stdClass)) {
554 return new \ElggRiverItem(
$row);
579 $types_wheres = array();
580 $subtypes_wheres = array();
583 if (!is_array($pairs)) {
585 if (!is_array($types)) {
586 $types = array($types);
588 foreach ($types as
$type) {
590 $types_wheres[] =
"({$table}.type = '$type')";
600 $subtypes_wheres[] =
"({$table}.subtype = '$subtype')";
604 if (is_array($types_wheres) && count($types_wheres)) {
605 $types_wheres = array(implode(
' OR ', $types_wheres));
608 if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
609 $subtypes_wheres = array(
'(' . implode(
' OR ', $subtypes_wheres) .
')');
612 $wheres = array(implode(
' AND ', array_merge($types_wheres, $subtypes_wheres)));
616 foreach ($pairs as $paired_type => $paired_subtypes) {
618 if (is_array($paired_subtypes)) {
619 $paired_subtypes = array_map(
'sanitise_string', $paired_subtypes);
620 $paired_subtype_str = implode(
"','", $paired_subtypes);
621 if ($paired_subtype_str) {
622 $wheres[] =
"({$table}.type = '$paired_type'" 623 .
" AND {$table}.subtype IN ('$paired_subtype_str'))";
627 $wheres[] =
"({$table}.type = '$paired_type'" 628 .
" AND {$table}.subtype = '$paired_subtype')";
633 if (is_array($wheres) && count($wheres)) {
634 $where = implode(
' OR ', $wheres);
655 if (!is_array($types)) {
657 return "(rv.action_type = '$types')";
661 $types_sanitized = array();
662 foreach ($types as
$type) {
666 $type_str = implode(
"','", $types_sanitized);
667 return "(rv.action_type IN ('$type_str'))";
684 if (!is_array($views)) {
686 return "(rv.view = '$views')";
690 $views_sanitized = array();
691 foreach ($views as
$view) {
695 $view_str = implode(
"','", $views_sanitized);
696 return "(rv.view IN ('$view_str'))";
709 $object_guid = (int) $object_guid;
710 $access_id = (int) $access_id;
715 $query =
"UPDATE {$CONFIG->dbprefix}river 716 SET access_id = {$access_id} 717 WHERE object_guid = {$object_guid}";
742 set_input(
'subject_username', $page_username);
747 require_once(
"{$CONFIG->path}pages/river.php");
757 $value[] = $CONFIG->path .
'engine/tests/ElggCoreRiverAPITest.php';
779 SET rv.enabled =
'no' 780 WHERE (rv.subject_guid = {$entity->guid} OR rv.object_guid = {$entity->guid} OR rv.target_guid = {$entity->guid});
806 LEFT JOIN {
$dbprefix}entities AS se ON se.guid = rv.subject_guid
807 LEFT JOIN {
$dbprefix}entities AS oe ON oe.guid = rv.object_guid
808 LEFT JOIN {
$dbprefix}entities AS te ON te.guid = rv.target_guid
809 SET rv.enabled =
'yes' 811 (se.enabled =
'yes' OR se.guid IS NULL) AND
812 (oe.enabled =
'yes' OR oe.guid IS NULL) AND
813 (te.enabled =
'yes' OR te.guid IS NULL)
815 AND (se.guid = {$entity->guid} OR oe.guid = {$entity->guid} OR te.guid = {$entity->guid});
828 $item = new \ElggMenuItem(
'activity',
elgg_echo(
'activity'),
'activity');
839 $events->registerHandler(
'init',
'system',
'_elgg_river_init');
840 $events->registerHandler(
'disable:after',
'all',
'_elgg_river_disable');
841 $events->registerHandler(
'enable:after',
'all',
'_elgg_river_enable');
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)
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)
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_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)
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.