Elgg  Version 1.12
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_retrieve_cached_entity($item->subject_guid)) {
456  $guids[$item->subject_guid] = true;
457  }
458  if ($item->object_guid && !_elgg_retrieve_cached_entity($item->object_guid)) {
459  $guids[$item->object_guid] = true;
460  }
461  if ($item->target_guid && !_elgg_retrieve_cached_entity($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_retrieve_cached_entity($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()) {
513  global $autofeed;
514  $autofeed = true;
515 
516  $defaults = array(
517  'offset' => (int) max(get_input('offset', 0), 0),
518  'limit' => (int) max(get_input('limit', max(20, elgg_get_config('default_limit'))), 0),
519  'pagination' => true,
520  'list_class' => 'elgg-list-river',
521  'no_results' => '',
522  );
523 
524  $options = array_merge($defaults, $options);
525 
526  if (!$options["limit"] && !$options["offset"]) {
527  // no need for pagination if listing is unlimited
528  $options["pagination"] = false;
529  }
530 
531  $options['count'] = true;
533 
534  if ($count > 0) {
535  $options['count'] = false;
537  } else {
538  $items = array();
539  }
540 
541  $options['count'] = $count;
542  $options['items'] = $items;
543 
544  return elgg_view('page/components/list', $options);
545 }
546 
557  if (!($row instanceof \stdClass)) {
558  return null;
559  }
560 
561  return new \ElggRiverItem($row);
562 }
563 
580  // short circuit if nothing is requested
581  if (!$types && !$subtypes && !$pairs) {
582  return '';
583  }
584 
585  $wheres = array();
586  $types_wheres = array();
587  $subtypes_wheres = array();
588 
589  // if no pairs, use types and subtypes
590  if (!is_array($pairs)) {
591  if ($types) {
592  if (!is_array($types)) {
593  $types = array($types);
594  }
595  foreach ($types as $type) {
596  $type = sanitise_string($type);
597  $types_wheres[] = "({$table}.type = '$type')";
598  }
599  }
600 
601  if ($subtypes) {
602  if (!is_array($subtypes)) {
603  $subtypes = array($subtypes);
604  }
605  foreach ($subtypes as $subtype) {
606  $subtype = sanitise_string($subtype);
607  $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
608  }
609  }
610 
611  if (is_array($types_wheres) && count($types_wheres)) {
612  $types_wheres = array(implode(' OR ', $types_wheres));
613  }
614 
615  if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
616  $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')');
617  }
618 
619  $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
620 
621  } else {
622  // using type/subtype pairs
623  foreach ($pairs as $paired_type => $paired_subtypes) {
624  $paired_type = sanitise_string($paired_type);
625  if (is_array($paired_subtypes)) {
626  $paired_subtypes = array_map('sanitise_string', $paired_subtypes);
627  $paired_subtype_str = implode("','", $paired_subtypes);
628  if ($paired_subtype_str) {
629  $wheres[] = "({$table}.type = '$paired_type'"
630  . " AND {$table}.subtype IN ('$paired_subtype_str'))";
631  }
632  } else {
633  $paired_subtype = sanitise_string($paired_subtypes);
634  $wheres[] = "({$table}.type = '$paired_type'"
635  . " AND {$table}.subtype = '$paired_subtype')";
636  }
637  }
638  }
639 
640  if (is_array($wheres) && count($wheres)) {
641  $where = implode(' OR ', $wheres);
642  return "($where)";
643  }
644 
645  return '';
646 }
647 
658  if (!$types) {
659  return '';
660  }
661 
662  if (!is_array($types)) {
663  $types = sanitise_string($types);
664  return "(rv.action_type = '$types')";
665  }
666 
667  // sanitize types array
668  $types_sanitized = array();
669  foreach ($types as $type) {
670  $types_sanitized[] = sanitise_string($type);
671  }
672 
673  $type_str = implode("','", $types_sanitized);
674  return "(rv.action_type IN ('$type_str'))";
675 }
676 
687  if (!$views) {
688  return '';
689  }
690 
691  if (!is_array($views)) {
692  $views = sanitise_string($views);
693  return "(rv.view = '$views')";
694  }
695 
696  // sanitize views array
697  $views_sanitized = array();
698  foreach ($views as $view) {
699  $views_sanitized[] = sanitise_string($view);
700  }
701 
702  $view_str = implode("','", $views_sanitized);
703  return "(rv.view IN ('$view_str'))";
704 }
705 
714 function update_river_access_by_object($object_guid, $access_id) {
715  // Sanitise
716  $object_guid = (int) $object_guid;
717  $access_id = (int) $access_id;
718 
719  // Load config
720  global $CONFIG;
721 
722  $query = "UPDATE {$CONFIG->dbprefix}river
723  SET access_id = {$access_id}
724  WHERE object_guid = {$object_guid}";
725  return update_data($query);
726 }
727 
735 function _elgg_river_page_handler($page) {
736  global $CONFIG;
737 
739 
740  // make a URL segment available in page handler script
741  $page_type = elgg_extract(0, $page, 'all');
742  $page_type = preg_replace('[\W]', '', $page_type);
743  if ($page_type == 'owner') {
744  elgg_gatekeeper();
745  $page_username = elgg_extract(1, $page, '');
746  if ($page_username == elgg_get_logged_in_user_entity()->username) {
747  $page_type = 'mine';
748  } else {
749  set_input('subject_username', $page_username);
750  }
751  }
752  set_input('page_type', $page_type);
753 
754  require_once("{$CONFIG->path}pages/river.php");
755  return true;
756 }
757 
762 function _elgg_river_test($hook, $type, $value) {
763  global $CONFIG;
764  $value[] = $CONFIG->path . 'engine/tests/ElggCoreRiverAPITest.php';
765  return $value;
766 }
767 
777 function _elgg_river_disable($event, $type, $entity) {
778 
779  if (!elgg_instanceof($entity)) {
780  return true;
781  }
782 
783  $dbprefix = elgg_get_config('dbprefix');
784  $query = <<<QUERY
785  UPDATE {$dbprefix}river AS rv
786  SET rv.enabled = 'no'
787  WHERE (rv.subject_guid = {$entity->guid} OR rv.object_guid = {$entity->guid} OR rv.target_guid = {$entity->guid});
788 QUERY;
789 
790  update_data($query);
791  return true;
792 }
793 
794 
804 function _elgg_river_enable($event, $type, $entity) {
805 
806  if (!elgg_instanceof($entity)) {
807  return true;
808  }
809 
810  $dbprefix = elgg_get_config('dbprefix');
811  $query = <<<QUERY
812  UPDATE {$dbprefix}river AS rv
813  LEFT JOIN {$dbprefix}entities AS se ON se.guid = rv.subject_guid
814  LEFT JOIN {$dbprefix}entities AS oe ON oe.guid = rv.object_guid
815  LEFT JOIN {$dbprefix}entities AS te ON te.guid = rv.target_guid
816  SET rv.enabled = 'yes'
817  WHERE (
818  (se.enabled = 'yes' OR se.guid IS NULL) AND
819  (oe.enabled = 'yes' OR oe.guid IS NULL) AND
820  (te.enabled = 'yes' OR te.guid IS NULL)
821  )
822  AND (se.guid = {$entity->guid} OR oe.guid = {$entity->guid} OR te.guid = {$entity->guid});
823 QUERY;
824 
825  update_data($query);
826  return true;
827 }
828 
833 function _elgg_river_init() {
834  elgg_register_page_handler('activity', '_elgg_river_page_handler');
835  $item = new \ElggMenuItem('activity', elgg_echo('activity'), 'activity');
837 
838  elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
839 
840  elgg_register_action('river/delete', '', 'admin');
841 
842  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_river_test');
843 }
844 
845 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
846  $events->registerHandler('init', 'system', '_elgg_river_init');
847  $events->registerHandler('disable:after', 'all', '_elgg_river_disable');
848  $events->registerHandler('enable:after', 'all', '_elgg_river_enable');
849 };
elgg_list_river(array $options=array())
List river items.
Definition: river.php:512
_elgg_river_get_action_where_sql($types)
Get the where clause based on river action type strings.
Definition: river.php:657
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$view
Definition: crop.php:68
$dbprefix
Definition: index.php:13
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
get_data_row($query, $callback="")
Retrieve a single row from the database.
Definition: database.php:66
$subject
Definition: exceptions.php:25
_elgg_river_init()
Initialize river library private.
Definition: river.php:833
$table
Definition: cron.php:28
$page_type
Definition: river.php:10
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:686
_elgg_retrieve_cached_entity($guid)
Retrieve a entity from the cache.
Definition: entities.php:125
$object
Definition: upgrade.php:12
$defaults
_elgg_river_test($hook, $type, $value)
Register river unit tests private.
Definition: river.php:762
elgg_register_widget_type($handler, $name, $description, $context=array('all'), $multiple=false)
Register a widget type.
Definition: widgets.php:73
_elgg_get_guid_based_where_sql($column, $guids)
Returns SQL where clause for owner and containers.
Definition: entities.php:539
update_entity_last_action($guid, $posted=null)
Update the last_action column in the entities table for $guid.
Definition: entities.php:957
_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
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:304
set_input($variable, $value)
Sets an input value that may later be retrieved by get_input.
Definition: input.php:41
if(!$count) $offset
Definition: pagination.php:26
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:717
delete_data($query)
Remove a row from the database.
Definition: database.php:106
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:67
update_data($query)
Update a row in the database.
Definition: database.php:93
sanitize_string($string)
Sanitize a string for database use.
Definition: database.php:140
insert_data($query)
Insert a row into the database.
Definition: database.php:80
update_river_access_by_object($object_guid, $access_id)
Sets the access ID on river items for a particular object.
Definition: river.php:714
username
Definition: contents.php:36
$target
Definition: create.php:11
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
Definition: pagehandler.php:58
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
Definition: entities.php:926
$limit
Definition: userpicker.php:38
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
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:556
$item
Definition: item.php:12
global $CONFIG
elgg menu river
Definition: navigation.php:492
sanitise_string($string)
Wrapper function for alternate English spelling (.
Definition: database.php:150
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2006
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
Definition: entities.php:494
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:790
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
Definition: pagehandler.php:34
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.
Definition: elgglib.js:12
elgg_register_menu_item($menu_name, $menu_item)
Register an item for an Elgg menu.
Definition: navigation.php:92
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:340
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:172
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:1271
$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:804
$posted
Definition: comment.php:69
$guids
_elgg_river_disable($event, $type, $entity)
Disable river entries that reference a disabled entity as subject/object/target.
Definition: river.php:777
get_data($query, $callback="")
Retrieve rows from the database.
Definition: database.php:50
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
if(elgg_in_context('widget')) $count
Definition: pagination.php:21
$row
sanitise_int($int, $signed=true)
Sanitizes an integer for database use.
Definition: database.php:173
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32
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:1401
$entity
Definition: delete.php:10
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
Definition: access.php:216
_elgg_river_page_handler($page)
Page handler for activity.
Definition: river.php:735
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:584
$subtype
Definition: river.php:12
if(!$collection_name) $id
Definition: add.php:17
$options
Main activity stream list page.
Definition: river.php:6
$type
Definition: river.php:11
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:579
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:382