Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
river.php
Go to the documentation of this file.
1 <?php
37 function elgg_create_river_item(array $options = array()) {
38  $view = elgg_extract('view', $options);
39  // use default viewtype for when called from web services api
40  if (empty($view) || !(elgg_view_exists($view, 'default'))) {
41  return false;
42  }
43 
44  $action_type = elgg_extract('action_type', $options);
45  if (empty($action_type)) {
46  return false;
47  }
48 
49  $subject_guid = elgg_extract('subject_guid', $options, 0);
50  if (!($subject = get_entity($subject_guid))) {
51  return false;
52  }
53 
54  $object_guid = elgg_extract('object_guid', $options, 0);
55  if (!($object = get_entity($object_guid))) {
56  return false;
57  }
58 
59  $target_guid = elgg_extract('target_guid', $options, 0);
60  if ($target_guid) {
61  // target_guid is not a required parameter so check
62  // it only if it is included in the parameters
63  if (!($target = get_entity($target_guid))) {
64  return false;
65  }
66  }
67 
68  $access_id = elgg_extract('access_id', $options, $object->access_id);
69 
70  $posted = elgg_extract('posted', $options, time());
71 
72  $annotation_id = elgg_extract('annotation_id', $options, 0);
73  if ($annotation_id) {
74  if (!elgg_get_annotation_from_id($annotation_id)) {
75  return false;
76  }
77  }
78 
79  $values = array(
80  'type' => $object->getType(),
81  'subtype' => $object->getSubtype(),
82  'action_type' => $action_type,
83  'access_id' => $access_id,
84  'view' => $view,
85  'subject_guid' => $subject_guid,
86  'object_guid' => $object_guid,
87  'target_guid' => $target_guid,
88  'annotation_id' => $annotation_id,
89  'posted' => $posted,
90  );
91  $col_types = array(
92  'type' => 'string',
93  'subtype' => 'string',
94  'action_type' => 'string',
95  'access_id' => 'int',
96  'view' => 'string',
97  'subject_guid' => 'int',
98  'object_guid' => 'int',
99  'target_guid' => 'int',
100  'annotation_id' => 'int',
101  'posted' => 'int',
102  );
103 
104  // return false to stop insert
105  $values = elgg_trigger_plugin_hook('creating', 'river', null, $values);
106  if ($values == false) {
107  // inserting did not fail - it was just prevented
108  return true;
109  }
110 
111  $dbprefix = elgg_get_config('dbprefix');
112 
113  // escape values array and build INSERT assignments
114  $assignments = array();
115  foreach ($col_types as $name => $type) {
116  $values[$name] = ($type === 'int') ? (int)$values[$name] : sanitize_string($values[$name]);
117  $assignments[] = "$name = '{$values[$name]}'";
118  }
119 
120  $id = insert_data("INSERT INTO {$dbprefix}river SET " . implode(',', $assignments));
121 
122  // update the entities which had the action carried out on it
123  // @todo shouldn't this be done elsewhere? Like when an annotation is saved?
124  if ($id) {
125  update_entity_last_action($values['object_guid'], $values['posted']);
126 
127  $river_items = elgg_get_river(array('id' => $id));
128  if ($river_items) {
129  elgg_trigger_event('created', 'river', $river_items[0]);
130  }
131  return $id;
132  } else {
133  return false;
134  }
135 }
136 
162 function elgg_delete_river(array $options = array()) {
163  global $CONFIG;
164 
165  $defaults = array(
166  'ids' => ELGG_ENTITIES_ANY_VALUE,
167 
168  'subject_guids' => ELGG_ENTITIES_ANY_VALUE,
169  'object_guids' => ELGG_ENTITIES_ANY_VALUE,
170  'target_guids' => ELGG_ENTITIES_ANY_VALUE,
171  'annotation_ids' => ELGG_ENTITIES_ANY_VALUE,
172 
173  'views' => ELGG_ENTITIES_ANY_VALUE,
174  'action_types' => ELGG_ENTITIES_ANY_VALUE,
175 
176  'types' => ELGG_ENTITIES_ANY_VALUE,
177  'subtypes' => ELGG_ENTITIES_ANY_VALUE,
178  'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE,
179 
180  'posted_time_lower' => ELGG_ENTITIES_ANY_VALUE,
181  'posted_time_upper' => ELGG_ENTITIES_ANY_VALUE,
182 
183  'wheres' => array(),
184  'joins' => array(),
185 
186  );
187 
188  $options = array_merge($defaults, $options);
189 
190  $singulars = array('id', 'subject_guid', 'object_guid', 'target_guid', 'annotation_id', 'action_type', 'view', 'type', 'subtype');
192 
193  $wheres = $options['wheres'];
194 
195  $wheres[] = _elgg_get_guid_based_where_sql('rv.id', $options['ids']);
196  $wheres[] = _elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']);
197  $wheres[] = _elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']);
198  $wheres[] = _elgg_get_guid_based_where_sql('rv.target_guid', $options['target_guids']);
199  $wheres[] = _elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']);
200  $wheres[] = _elgg_river_get_action_where_sql($options['action_types']);
201  $wheres[] = _elgg_river_get_view_where_sql($options['views']);
202  $wheres[] = _elgg_get_river_type_subtype_where_sql('rv', $options['types'],
203  $options['subtypes'], $options['type_subtype_pairs']);
204 
205  if ($options['posted_time_lower'] && is_int($options['posted_time_lower'])) {
206  $wheres[] = "rv.posted >= {$options['posted_time_lower']}";
207  }
208 
209  if ($options['posted_time_upper'] && is_int($options['posted_time_upper'])) {
210  $wheres[] = "rv.posted <= {$options['posted_time_upper']}";
211  }
212 
213  // see if any functions failed
214  // remove empty strings on successful functions
215  foreach ($wheres as $i => $where) {
216  if ($where === false) {
217  return false;
218  } elseif (empty($where)) {
219  unset($wheres[$i]);
220  }
221  }
222 
223  // remove identical where clauses
224  $wheres = array_unique($wheres);
225 
226  $query = "DELETE rv.* FROM {$CONFIG->dbprefix}river rv ";
227 
228  // remove identical join clauses
229  $joins = array_unique($options['joins']);
230 
231  // add joins
232  foreach ($joins as $j) {
233  $query .= " $j ";
234  }
235 
236  // add wheres
237  $query .= ' WHERE ';
238 
239  foreach ($wheres as $w) {
240  $query .= " $w AND ";
241  }
242  $query .= "1=1";
243 
244  return delete_data($query);
245 }
246 
286 function elgg_get_river(array $options = array()) {
287  global $CONFIG;
288 
289  $defaults = array(
290  'ids' => ELGG_ENTITIES_ANY_VALUE,
291 
292  'subject_guids' => ELGG_ENTITIES_ANY_VALUE,
293  'object_guids' => ELGG_ENTITIES_ANY_VALUE,
294  'target_guids' => ELGG_ENTITIES_ANY_VALUE,
295  'annotation_ids' => ELGG_ENTITIES_ANY_VALUE,
296  'action_types' => ELGG_ENTITIES_ANY_VALUE,
297 
298  'relationship' => null,
299  'relationship_guid' => null,
300  'inverse_relationship' => false,
301 
302  'types' => ELGG_ENTITIES_ANY_VALUE,
303  'subtypes' => ELGG_ENTITIES_ANY_VALUE,
304  'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE,
305 
306  'posted_time_lower' => ELGG_ENTITIES_ANY_VALUE,
307  'posted_time_upper' => ELGG_ENTITIES_ANY_VALUE,
308 
309  'limit' => 20,
310  'offset' => 0,
311  'count' => false,
312  'distinct' => true,
313 
314  'order_by' => 'rv.posted desc',
315  'group_by' => ELGG_ENTITIES_ANY_VALUE,
316 
317  'wheres' => array(),
318  'joins' => array(),
319  );
320 
321  $options = array_merge($defaults, $options);
322 
323  $singulars = array('id', 'subject_guid', 'object_guid', 'target_guid', 'annotation_id', 'action_type', 'type', 'subtype');
325 
326  $wheres = $options['wheres'];
327 
328  $wheres[] = _elgg_get_guid_based_where_sql('rv.id', $options['ids']);
329  $wheres[] = _elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']);
330  $wheres[] = _elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']);
331  $wheres[] = _elgg_get_guid_based_where_sql('rv.target_guid', $options['target_guids']);
332  $wheres[] = _elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']);
333  $wheres[] = _elgg_river_get_action_where_sql($options['action_types']);
334  $wheres[] = _elgg_get_river_type_subtype_where_sql('rv', $options['types'],
335  $options['subtypes'], $options['type_subtype_pairs']);
336 
337  if ($options['posted_time_lower'] && is_int($options['posted_time_lower'])) {
338  $wheres[] = "rv.posted >= {$options['posted_time_lower']}";
339  }
340 
341  if ($options['posted_time_upper'] && is_int($options['posted_time_upper'])) {
342  $wheres[] = "rv.posted <= {$options['posted_time_upper']}";
343  }
344 
346  $wheres[] = "rv.enabled = 'yes'";
347  }
348 
349  $joins = $options['joins'];
350 
351  $dbprefix = elgg_get_config('dbprefix');
352 
353  // joins
354  $joins = array();
355  $joins[] = "JOIN {$dbprefix}entities oe ON rv.object_guid = oe.guid";
356 
357  // LEFT JOIN is used because all river items do not necessarily have target
358  $joins[] = "LEFT JOIN {$dbprefix}entities te ON rv.target_guid = te.guid";
359 
360  if ($options['relationship_guid']) {
362  'rv.subject_guid',
363  $options['relationship'],
364  $options['relationship_guid'],
365  $options['inverse_relationship']);
366  if ($clauses) {
367  $wheres = array_merge($wheres, $clauses['wheres']);
368  $joins = array_merge($joins, $clauses['joins']);
369  }
370  }
371 
372  // add optional joins
373  $joins = array_merge($joins, $options['joins']);
374 
375  // see if any functions failed
376  // remove empty strings on successful functions
377  foreach ($wheres as $i => $where) {
378  if ($where === false) {
379  return false;
380  } elseif (empty($where)) {
381  unset($wheres[$i]);
382  }
383  }
384 
385  // remove identical where clauses
386  $wheres = array_unique($wheres);
387 
388  if (!$options['count']) {
389  $distinct = $options['distinct'] ? "DISTINCT" : "";
390 
391  $query = "SELECT $distinct rv.* FROM {$CONFIG->dbprefix}river rv ";
392  } else {
393  // note: when DISTINCT unneeded, it's slightly faster to compute COUNT(*) than IDs
394  $count_expr = $options['distinct'] ? "DISTINCT rv.id" : "*";
395 
396  $query = "SELECT COUNT($count_expr) as total FROM {$CONFIG->dbprefix}river rv ";
397  }
398 
399  // add joins
400  foreach ($joins as $j) {
401  $query .= " $j ";
402  }
403 
404  // add wheres
405  $query .= ' WHERE ';
406 
407  foreach ($wheres as $w) {
408  $query .= " $w AND ";
409  }
410 
411  // Make sure that user has access to all the entities referenced by each river item
412  $object_access_where = _elgg_get_access_where_sql(array('table_alias' => 'oe'));
413  $target_access_where = _elgg_get_access_where_sql(array('table_alias' => 'te'));
414 
415  // We use LEFT JOIN with entities table but the WHERE clauses are used
416  // regardless if a JOIN is successfully made. The "te.guid IS NULL" is
417  // needed because of this.
418  $query .= "$object_access_where AND ($target_access_where OR te.guid IS NULL) ";
419 
420  if (!$options['count']) {
421  $options['group_by'] = sanitise_string($options['group_by']);
422  if ($options['group_by']) {
423  $query .= " GROUP BY {$options['group_by']}";
424  }
425 
426  $options['order_by'] = sanitise_string($options['order_by']);
427  $query .= " ORDER BY {$options['order_by']}";
428 
429  if ($options['limit']) {
430  $limit = sanitise_int($options['limit']);
431  $offset = sanitise_int($options['offset'], false);
432  $query .= " LIMIT $offset, $limit";
433  }
434 
435  $river_items = get_data($query, '_elgg_row_to_elgg_river_item');
436  _elgg_prefetch_river_entities($river_items);
437 
438  return $river_items;
439  } else {
440  $total = get_data_row($query);
441  return (int)$total->total;
442  }
443 }
444 
451 function _elgg_prefetch_river_entities(array $river_items) {
452  // prefetch objects, subjects and targets
453  $guids = array();
454  foreach ($river_items as $item) {
455  if ($item->subject_guid && !_elgg_services()->entityCache->get($item->subject_guid)) {
456  $guids[$item->subject_guid] = true;
457  }
458  if ($item->object_guid && !_elgg_services()->entityCache->get($item->object_guid)) {
459  $guids[$item->object_guid] = true;
460  }
461  if ($item->target_guid && !_elgg_services()->entityCache->get($item->target_guid)) {
462  $guids[$item->target_guid] = true;
463  }
464  }
465  if ($guids) {
466  // The entity cache only holds 256. We don't want to bump out any plugins.
467  $guids = array_slice($guids, 0, 200, true);
468  // return value unneeded, just priming cache
469  elgg_get_entities(array(
470  'guids' => array_keys($guids),
471  'limit' => 0,
472  'distinct' => false,
473  ));
474  }
475 
476  // prefetch object containers, in case they were not in the targets
477  $guids = array();
478  foreach ($river_items as $item) {
479  $object = $item->getObjectEntity();
480  if ($object->container_guid && !_elgg_services()->entityCache->get($object->container_guid)) {
481  $guids[$object->container_guid] = true;
482  }
483  }
484  if ($guids) {
485  $guids = array_slice($guids, 0, 200, true);
486  elgg_get_entities(array(
487  'guids' => array_keys($guids),
488  'limit' => 0,
489  'distinct' => false,
490 
491  // Why specify? user containers are likely already loaded via the owners, and
492  // specifying groups allows ege() to auto-join the groups_entity table
493  'type' => 'group',
494  ));
495  }
496 
497  // Note: We've tried combining the above ege() calls into one (pulling containers at the same time).
498  // Although it seems like it would reduce queries, it added some. o_O
499 }
500 
512 function elgg_list_river(array $options = array()) {
514 
515  $defaults = array(
516  'offset' => (int) max(get_input('offset', 0), 0),
517  'limit' => (int) max(get_input('limit', max(20, elgg_get_config('default_limit'))), 0),
518  'pagination' => true,
519  'list_class' => 'elgg-list-river',
520  'no_results' => '',
521  );
522 
523  $options = array_merge($defaults, $options);
524 
525  if (!$options["limit"] && !$options["offset"]) {
526  // no need for pagination if listing is unlimited
527  $options["pagination"] = false;
528  }
529 
530  $options['count'] = true;
532 
533  if ($count > 0) {
534  $options['count'] = false;
536  } else {
537  $items = array();
538  }
539 
540  $options['count'] = $count;
541  $options['items'] = $items;
542 
543  return elgg_view('page/components/list', $options);
544 }
545 
556  if (!($row instanceof \stdClass)) {
557  return null;
558  }
559 
560  return new \ElggRiverItem($row);
561 }
562 
579  // short circuit if nothing is requested
580  if (!$types && !$subtypes && !$pairs) {
581  return '';
582  }
583 
584  $wheres = array();
585  $types_wheres = array();
586  $subtypes_wheres = array();
587 
588  // if no pairs, use types and subtypes
589  if (!is_array($pairs)) {
590  if ($types) {
591  if (!is_array($types)) {
592  $types = array($types);
593  }
594  foreach ($types as $type) {
595  $type = sanitise_string($type);
596  $types_wheres[] = "({$table}.type = '$type')";
597  }
598  }
599 
600  if ($subtypes) {
601  if (!is_array($subtypes)) {
602  $subtypes = array($subtypes);
603  }
604  foreach ($subtypes as $subtype) {
605  $subtype = sanitise_string($subtype);
606  $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
607  }
608  }
609 
610  if (is_array($types_wheres) && count($types_wheres)) {
611  $types_wheres = array(implode(' OR ', $types_wheres));
612  }
613 
614  if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
615  $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')');
616  }
617 
618  $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
619 
620  } else {
621  // using type/subtype pairs
622  foreach ($pairs as $paired_type => $paired_subtypes) {
623  $paired_type = sanitise_string($paired_type);
624  if (is_array($paired_subtypes)) {
625  $paired_subtypes = array_map('sanitise_string', $paired_subtypes);
626  $paired_subtype_str = implode("','", $paired_subtypes);
627  if ($paired_subtype_str) {
628  $wheres[] = "({$table}.type = '$paired_type'"
629  . " AND {$table}.subtype IN ('$paired_subtype_str'))";
630  }
631  } else {
632  $paired_subtype = sanitise_string($paired_subtypes);
633  $wheres[] = "({$table}.type = '$paired_type'"
634  . " AND {$table}.subtype = '$paired_subtype')";
635  }
636  }
637  }
638 
639  if (is_array($wheres) && count($wheres)) {
640  $where = implode(' OR ', $wheres);
641  return "($where)";
642  }
643 
644  return '';
645 }
646 
657  if (!$types) {
658  return '';
659  }
660 
661  if (!is_array($types)) {
662  $types = sanitise_string($types);
663  return "(rv.action_type = '$types')";
664  }
665 
666  // sanitize types array
667  $types_sanitized = array();
668  foreach ($types as $type) {
669  $types_sanitized[] = sanitise_string($type);
670  }
671 
672  $type_str = implode("','", $types_sanitized);
673  return "(rv.action_type IN ('$type_str'))";
674 }
675 
686  if (!$views) {
687  return '';
688  }
689 
690  if (!is_array($views)) {
691  $views = sanitise_string($views);
692  return "(rv.view = '$views')";
693  }
694 
695  // sanitize views array
696  $views_sanitized = array();
697  foreach ($views as $view) {
698  $views_sanitized[] = sanitise_string($view);
699  }
700 
701  $view_str = implode("','", $views_sanitized);
702  return "(rv.view IN ('$view_str'))";
703 }
704 
713 function update_river_access_by_object($object_guid, $access_id) {
714  // Sanitise
715  $object_guid = (int) $object_guid;
716  $access_id = (int) $access_id;
717 
718  // Load config
719  global $CONFIG;
720 
721  $query = "UPDATE {$CONFIG->dbprefix}river
722  SET access_id = {$access_id}
723  WHERE object_guid = {$object_guid}";
724  return update_data($query);
725 }
726 
734 function _elgg_river_page_handler($page) {
736 
737  // make a URL segment available in page handler script
738  $page_type = elgg_extract(0, $page, 'all');
739  $page_type = preg_replace('[\W]', '', $page_type);
740 
741  if ($page_type == 'owner') {
742  elgg_gatekeeper();
743  $page_username = elgg_extract(1, $page, '');
744  if ($page_username == elgg_get_logged_in_user_entity()->username) {
745  $page_type = 'mine';
746  } else {
747  $vars['subject_username'] = $page_username;
748  }
749  }
750 
751  $vars['page_type'] = $page_type;
752 
753  echo elgg_view_resource("river", $vars);
754  return true;
755 }
756 
761 function _elgg_river_test($hook, $type, $value) {
762  global $CONFIG;
763  $value[] = $CONFIG->path . 'engine/tests/ElggCoreRiverAPITest.php';
764  return $value;
765 }
766 
776 function _elgg_river_disable($event, $type, $entity) {
777 
778  if (!elgg_instanceof($entity)) {
779  return true;
780  }
781 
782  $dbprefix = elgg_get_config('dbprefix');
783  $query = <<<QUERY
784  UPDATE {$dbprefix}river AS rv
785  SET rv.enabled = 'no'
786  WHERE (rv.subject_guid = {$entity->guid} OR rv.object_guid = {$entity->guid} OR rv.target_guid = {$entity->guid});
787 QUERY;
788 
789  update_data($query);
790  return true;
791 }
792 
793 
803 function _elgg_river_enable($event, $type, $entity) {
804 
805  if (!elgg_instanceof($entity)) {
806  return true;
807  }
808 
809  $dbprefix = elgg_get_config('dbprefix');
810  $query = <<<QUERY
811  UPDATE {$dbprefix}river AS rv
812  LEFT JOIN {$dbprefix}entities AS se ON se.guid = rv.subject_guid
813  LEFT JOIN {$dbprefix}entities AS oe ON oe.guid = rv.object_guid
814  LEFT JOIN {$dbprefix}entities AS te ON te.guid = rv.target_guid
815  SET rv.enabled = 'yes'
816  WHERE (
817  (se.enabled = 'yes' OR se.guid IS NULL) AND
818  (oe.enabled = 'yes' OR oe.guid IS NULL) AND
819  (te.enabled = 'yes' OR te.guid IS NULL)
820  )
821  AND (se.guid = {$entity->guid} OR oe.guid = {$entity->guid} OR te.guid = {$entity->guid});
822 QUERY;
823 
824  update_data($query);
825  return true;
826 }
827 
832 function _elgg_river_init() {
833  elgg_register_page_handler('activity', '_elgg_river_page_handler');
834  $item = new \ElggMenuItem('activity', elgg_echo('activity'), 'activity');
836 
837  elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
838 
839  elgg_register_action('river/delete', '', 'admin');
840 
841  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_river_test');
842 
843  // For BC, we want required AMD modules to be loaded even if plugins
844  // overwrite these views
845  elgg_extend_view('core/river/filter', 'core/river/filter_deps');
846  elgg_extend_view('forms/comment/save', 'forms/comment/save_deps');
847 
848 }
849 
850 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
851  $events->registerHandler('init', 'system', '_elgg_river_init');
852  $events->registerHandler('disable:after', 'all', '_elgg_river_disable', 600);
853  $events->registerHandler('enable:after', 'all', '_elgg_river_enable', 600);
854 };
insert_data($query, array $params=[])
Insert a row into the database.
Definition: database.php:87
elgg_list_river(array $options=array())
List river items.
Definition: river.php:512
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:299
$object
These two snippets demonstrates triggering an event and how to register for that event.
Definition: trigger.php:7
_elgg_river_get_action_where_sql($types)
Get the where clause based on river action type strings.
Definition: river.php:656
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$view
Definition: crop.php:34
$subject
Definition: exceptions.php:25
_elgg_river_init()
Initialize river library private.
Definition: river.php:832
$table
Definition: cron.php:34
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
_elgg_river_get_view_where_sql($views)
Get the where clause based on river view strings.
Definition: river.php:685
delete_data($query, array $params=[])
Remove a row from the database.
Definition: database.php:116
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_resource($name, array $vars=[])
Render a resource view.
Definition: views.php:500
$defaults
_elgg_river_test($hook, $type, $value)
Register river unit tests private.
Definition: river.php:761
_elgg_get_guid_based_where_sql($column, $guids)
Returns SQL where clause for owner and containers.
Definition: entities.php:331
update_entity_last_action($guid, $posted=null)
Update the last_action column in the entities table for $guid.
Definition: entities.php:747
_elgg_prefetch_river_entities(array $river_items)
Prefetch entities that will be displayed in the river.
Definition: river.php:451
$value
Definition: longtext.php:26
if(!$count) $offset
Definition: pagination.php:26
$subtype
Definition: river.php:12
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:715
$vars['entity']
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:72
sanitize_string($string)
Sanitizes a string for use in a query.
Definition: database.php:153
update_river_access_by_object($object_guid, $access_id)
Sets the access ID on river items for a particular object.
Definition: river.php:713
$options
Main activity stream list page.
Definition: river.php:6
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
Definition: entities.php:716
$limit
Definition: userpicker.php:38
get_data_row($query, $callback=null, array $params=[])
Retrieve a single row from the database.
Definition: database.php:72
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
if(!($comment instanceof\ElggComment)||!$comment->canEdit()) $target
Definition: edit.php:17
elgg_create_river_item(array $options=array())
Adds an item to the river.
Definition: river.php:37
_elgg_row_to_elgg_river_item($row)
Convert a database row to a new .
Definition: river.php:555
update_data($query, array $params=[], $get_num_rows=false)
Update a row in the database.
Definition: database.php:102
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$item
Definition: item.php:12
global $CONFIG
sanitise_string($string)
Alias of sanitize_string.
Definition: database.php:166
$dbprefix
Definition: index.php:13
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2001
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
Definition: entities.php:316
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:801
elgg_get_entity_relationship_where_sql($column, $relationship=null, $relationship_guid=null, $inverse_relationship=false)
Returns SQL appropriate for relationship joins and wheres.
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
Definition: database.php:55
elgg_extend_view($view, $view_extension, $priority=501)
Extends a view with another view.
Definition: views.php:386
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:170
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1310
$items
Definition: list.php:11
_elgg_river_enable($event, $type, $entity)
Enable river entries that reference a re-enabled entity as subject/object/target. ...
Definition: river.php:803
$type
Definition: river.php:11
$posted
Definition: comment.php:83
$guids
_elgg_river_disable($event, $type, $entity)
Disable river entries that reference a disabled entity as subject/object/target.
Definition: river.php:776
elgg_get_river(array $options=array())
Get river items.
Definition: river.php:286
$subtypes
elgg_delete_river(array $options=array())
Delete river items.
Definition: river.php:162
$entity
Definition: delete.php:7
username
Definition: contents.php:36
if(elgg_in_context('widget')) $count
Definition: pagination.php:21
$row
sanitise_int($int, $signed=true)
Alias of sanitize_int.
Definition: database.php:194
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32
$page_type
Definition: river.php:10
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
Definition: actions.php:85
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
Definition: elgglib.php:1440
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
Definition: access.php:214
_elgg_river_page_handler($page)
Page handler for activity.
Definition: river.php:734
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:589
if(!$collection_name) $id
Definition: add.php:17
elgg_register_widget_type($handler, $name=null, $description=null, $context=array('all'), $multiple=false)
Register a widget type.
Definition: widgets.php:74
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:42
_elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs)
Returns SQL where clause for type and subtype on river table.
Definition: river.php:578
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204
elgg_register_rss_link()
Include the RSS icon link and link element in the head.
Definition: views.php:1483