Elgg  Version 1.9
metastrings.php
Go to the documentation of this file.
1 <?php
16 $METASTRINGS_CACHE = array();
17 
18 
34 function elgg_get_metastring_id($string, $case_sensitive = true) {
36 
37  // caching doesn't work for case insensitive requests
38  if ($case_sensitive) {
39  $result = array_search($string, $METASTRINGS_CACHE, true);
40 
41  if ($result !== false) {
42  return $result;
43  }
44 
45  // Experimental memcache
46  $msfc = null;
47  static $metastrings_memcache;
48  if ((!$metastrings_memcache) && (is_memcache_available())) {
49  $metastrings_memcache = new ElggMemcache('metastrings_memcache');
50  }
51  if ($metastrings_memcache) {
52  $msfc = $metastrings_memcache->load($string);
53  }
54  if ($msfc) {
55  return $msfc;
56  }
57  }
58 
59  $escaped_string = sanitise_string($string);
60  if ($case_sensitive) {
61  $query = "SELECT * FROM {$CONFIG->dbprefix}metastrings WHERE string = BINARY '$escaped_string' LIMIT 1";
62  } else {
63  $query = "SELECT * FROM {$CONFIG->dbprefix}metastrings WHERE string = '$escaped_string'";
64  }
65 
66  $id = false;
67  $results = get_data($query);
68  if (is_array($results)) {
69  if (!$case_sensitive) {
70  $ids = array();
71  foreach ($results as $result) {
72  $ids[] = $result->id;
73  }
74  // return immediately because we don't want to cache case insensitive results
75  return $ids;
76  } else if (isset($results[0])) {
77  $id = $results[0]->id;
78  }
79  }
80 
81  if (!$id) {
83  }
84 
85  $METASTRINGS_CACHE[$id] = $string;
86 
87  if ($metastrings_memcache) {
88  $metastrings_memcache->save($string, $id);
89  }
90 
91  return $id;
92 }
93 
103  global $CONFIG;
104 
105  $escaped_string = sanitise_string($string);
106 
107  return insert_data("INSERT INTO {$CONFIG->dbprefix}metastrings (string) VALUES ('$escaped_string')");
108 }
109 
117  global $CONFIG;
118 
119  // If memcache is enabled then we need to flush it of deleted values
120  if (is_memcache_available()) {
121  $select_query = "
122  SELECT * FROM {$CONFIG->dbprefix}metastrings WHERE
123  (
124  (id NOT IN (SELECT name_id FROM {$CONFIG->dbprefix}metadata)) AND
125  (id NOT IN (SELECT value_id FROM {$CONFIG->dbprefix}metadata)) AND
126  (id NOT IN (SELECT name_id FROM {$CONFIG->dbprefix}annotations)) AND
127  (id NOT IN (SELECT value_id FROM {$CONFIG->dbprefix}annotations))
128  )";
129 
130  $dead = get_data($select_query);
131  if ($dead) {
132  static $metastrings_memcache;
133  if (!$metastrings_memcache) {
134  $metastrings_memcache = new ElggMemcache('metastrings_memcache');
135  }
136 
137  foreach ($dead as $d) {
138  $metastrings_memcache->delete($d->string);
139  }
140  }
141  }
142 
143  $query = "
144  DELETE FROM {$CONFIG->dbprefix}metastrings WHERE
145  (
146  (id NOT IN (SELECT name_id FROM {$CONFIG->dbprefix}metadata)) AND
147  (id NOT IN (SELECT value_id FROM {$CONFIG->dbprefix}metadata)) AND
148  (id NOT IN (SELECT name_id FROM {$CONFIG->dbprefix}annotations)) AND
149  (id NOT IN (SELECT value_id FROM {$CONFIG->dbprefix}annotations))
150  )";
151 
152  return delete_data($query);
153 }
154 
192 
193  switch ($options['metastring_type']) {
194  case 'metadata':
195  $type = 'metadata';
196  $callback = 'row_to_elggmetadata';
197  break;
198 
199  case 'annotations':
200  case 'annotation':
201  $type = 'annotations';
202  $callback = 'row_to_elggannotation';
203  break;
204 
205  default:
206  return false;
207  }
208 
209  $defaults = array(
210  // entities
211  'types' => ELGG_ENTITIES_ANY_VALUE,
212  'subtypes' => ELGG_ENTITIES_ANY_VALUE,
213  'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE,
214 
215  'guids' => ELGG_ENTITIES_ANY_VALUE,
216  'owner_guids' => ELGG_ENTITIES_ANY_VALUE,
217  'container_guids' => ELGG_ENTITIES_ANY_VALUE,
218  'site_guids' => get_config('site_guid'),
219 
220  'modified_time_lower' => ELGG_ENTITIES_ANY_VALUE,
221  'modified_time_upper' => ELGG_ENTITIES_ANY_VALUE,
222  'created_time_lower' => ELGG_ENTITIES_ANY_VALUE,
223  'created_time_upper' => ELGG_ENTITIES_ANY_VALUE,
224 
225  // options are normalized to the plural in case we ever add support for them.
226  'metastring_names' => ELGG_ENTITIES_ANY_VALUE,
227  'metastring_values' => ELGG_ENTITIES_ANY_VALUE,
228  //'metastring_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE,
229  //'metastring_name_value_pairs_operator' => 'AND',
230 
231  'metastring_case_sensitive' => true,
232  //'order_by_metastring' => array(),
233  'metastring_calculation' => ELGG_ENTITIES_NO_VALUE,
234 
235  'metastring_created_time_lower' => ELGG_ENTITIES_ANY_VALUE,
236  'metastring_created_time_upper' => ELGG_ENTITIES_ANY_VALUE,
237 
238  'metastring_owner_guids' => ELGG_ENTITIES_ANY_VALUE,
239 
240  'metastring_ids' => ELGG_ENTITIES_ANY_VALUE,
241 
242  // sql
243  'order_by' => 'n_table.time_created asc',
244  'limit' => 10,
245  'offset' => 0,
246  'count' => false,
247  'selects' => array(),
248  'wheres' => array(),
249  'joins' => array(),
250 
251  'callback' => $callback,
252  );
253 
254  // @todo Ignore site_guid right now because of #2910
255  $options['site_guid'] = ELGG_ENTITIES_ANY_VALUE;
256 
257  $options = array_merge($defaults, $options);
258 
259  // can't use helper function with type_subtype_pair because
260  // it's already an array...just need to merge it
261  if (isset($options['type_subtype_pair'])) {
262  if (isset($options['type_subtype_pairs'])) {
263  $options['type_subtype_pairs'] = array_merge($options['type_subtype_pairs'],
264  $options['type_subtype_pair']);
265  } else {
266  $options['type_subtype_pairs'] = $options['type_subtype_pair'];
267  }
268  }
269 
270  $singulars = array(
271  'type', 'subtype', 'type_subtype_pair',
272  'guid', 'owner_guid', 'container_guid', 'site_guid',
273  'metastring_name', 'metastring_value',
274  'metastring_owner_guid', 'metastring_id',
275  'select', 'where', 'join'
276  );
277 
279 
280  if (!$options) {
281  return false;
282  }
283 
284  $db_prefix = elgg_get_config('dbprefix');
285 
286  // evaluate where clauses
287  if (!is_array($options['wheres'])) {
288  $options['wheres'] = array($options['wheres']);
289  }
290 
291  $wheres = $options['wheres'];
292 
293  // entities
294  $wheres[] = _elgg_get_entity_type_subtype_where_sql('e', $options['types'],
295  $options['subtypes'], $options['type_subtype_pairs']);
296 
297  $wheres[] = _elgg_get_guid_based_where_sql('e.guid', $options['guids']);
298  $wheres[] = _elgg_get_guid_based_where_sql('e.owner_guid', $options['owner_guids']);
299  $wheres[] = _elgg_get_guid_based_where_sql('e.container_guid', $options['container_guids']);
300  $wheres[] = _elgg_get_guid_based_where_sql('e.site_guid', $options['site_guids']);
301 
302  $wheres[] = _elgg_get_entity_time_where_sql('e', $options['created_time_upper'],
303  $options['created_time_lower'], $options['modified_time_upper'], $options['modified_time_lower']);
304 
305 
306  $wheres[] = _elgg_get_entity_time_where_sql('n_table', $options['metastring_created_time_upper'],
307  $options['metastring_created_time_lower'], null, null);
308 
309  $wheres[] = _elgg_get_guid_based_where_sql('n_table.owner_guid',
310  $options['metastring_owner_guids']);
311 
312  // see if any functions failed
313  // remove empty strings on successful functions
314  foreach ($wheres as $i => $where) {
315  if ($where === false) {
316  return false;
317  } elseif (empty($where)) {
318  unset($wheres[$i]);
319  }
320  }
321 
322  // remove identical where clauses
323  $wheres = array_unique($wheres);
324 
325  // evaluate join clauses
326  if (!is_array($options['joins'])) {
327  $options['joins'] = array($options['joins']);
328  }
329 
330  $joins = $options['joins'];
331  $joins[] = "JOIN {$db_prefix}entities e ON n_table.entity_guid = e.guid";
332 
333  // evaluate selects
334  if (!is_array($options['selects'])) {
335  $options['selects'] = array($options['selects']);
336  }
337 
338  $selects = $options['selects'];
339 
340  // For performance reasons we don't want the joins required for metadata / annotations
341  // unless we're going through one of their callbacks.
342  // this means we expect the functions passing different callbacks to pass their required joins.
343  // If we're doing a calculation
344  $custom_callback = ($options['callback'] == 'row_to_elggmetadata'
345  || $options['callback'] == 'row_to_elggannotation');
346  $is_calculation = $options['metastring_calculation'] ? true : false;
347 
348  if ($custom_callback || $is_calculation) {
349  $joins[] = "JOIN {$db_prefix}metastrings n on n_table.name_id = n.id";
350  $joins[] = "JOIN {$db_prefix}metastrings v on n_table.value_id = v.id";
351 
352  $selects[] = 'n.string as name';
353  $selects[] = 'v.string as value';
354  }
355 
356  foreach ($joins as $i => $join) {
357  if ($join === false) {
358  return false;
359  } elseif (empty($join)) {
360  unset($joins[$i]);
361  }
362  }
363 
364  // metastrings
365  $metastring_clauses = _elgg_get_metastring_sql('n_table', $options['metastring_names'],
366  $options['metastring_values'], null, $options['metastring_ids'],
367  $options['metastring_case_sensitive']);
368 
369  if ($metastring_clauses) {
370  $wheres = array_merge($wheres, $metastring_clauses['wheres']);
371  $joins = array_merge($joins, $metastring_clauses['joins']);
372  } else {
373  $wheres[] = _elgg_get_access_where_sql(array('table_alias' => 'n_table'));
374  }
375 
376  if ($options['metastring_calculation'] === ELGG_ENTITIES_NO_VALUE && !$options['count']) {
377  $selects = array_unique($selects);
378  // evalutate selects
379  $select_str = '';
380  if ($selects) {
381  foreach ($selects as $select) {
382  $select_str .= ", $select";
383  }
384  }
385 
386  $query = "SELECT DISTINCT n_table.*{$select_str} FROM {$db_prefix}$type n_table";
387  } elseif ($options['count']) {
388  // count is over the entities
389  $query = "SELECT count(DISTINCT e.guid) as calculation FROM {$db_prefix}$type n_table";
390  } else {
391  $query = "SELECT {$options['metastring_calculation']}(v.string) as calculation FROM {$db_prefix}$type n_table";
392  }
393 
394  // remove identical join clauses
395  $joins = array_unique($joins);
396 
397  // add joins
398  foreach ($joins as $j) {
399  $query .= " $j ";
400  }
401 
402  // add wheres
403  $query .= ' WHERE ';
404 
405  foreach ($wheres as $w) {
406  $query .= " $w AND ";
407  }
408 
409  // Add access controls
410  $query .= _elgg_get_access_where_sql(array('table_alias' => 'e'));
411 
412  // reverse order by
413  if (isset($options['reverse_order_by']) && $options['reverse_order_by']) {
414  $options['order_by'] = _elgg_sql_reverse_order_by_clause($options['order_by']);
415  }
416 
417  if ($options['metastring_calculation'] === ELGG_ENTITIES_NO_VALUE && !$options['count']) {
418  if (isset($options['group_by'])) {
419  $options['group_by'] = sanitise_string($options['group_by']);
420  $query .= " GROUP BY {$options['group_by']}";
421  }
422 
423  if (isset($options['order_by']) && $options['order_by']) {
424  $options['order_by'] = sanitise_string($options['order_by']);
425  $query .= " ORDER BY {$options['order_by']}, n_table.id";
426  }
427 
428  if ($options['limit']) {
429  $limit = sanitise_int($options['limit']);
430  $offset = sanitise_int($options['offset'], false);
431  $query .= " LIMIT $offset, $limit";
432  }
433 
434  $dt = get_data($query, $options['callback']);
435  return $dt;
436  } else {
437  $result = get_data_row($query);
438  return $result->calculation;
439  }
440 }
441 
457 function _elgg_get_metastring_sql($table, $names = null, $values = null,
458  $pairs = null, $ids = null, $case_sensitive = false) {
459 
460  if ((!$names && $names !== 0)
461  && (!$values && $values !== 0)
462  && !$ids
463  && (!$pairs && $pairs !== 0)) {
464 
465  return array();
466  }
467 
468  $db_prefix = elgg_get_config('dbprefix');
469 
470  // binary forces byte-to-byte comparision of strings, making
471  // it case- and diacritical-mark- sensitive.
472  // only supported on values.
473  $binary = ($case_sensitive) ? ' BINARY ' : '';
474 
475  $return = array (
476  'joins' => array (),
477  'wheres' => array()
478  );
479 
480  $wheres = array();
481 
482  // get names wheres and joins
483  $names_where = '';
484  if ($names !== null) {
485  if (!is_array($names)) {
486  $names = array($names);
487  }
488 
489  $sanitised_names = array();
490  foreach ($names as $name) {
491  // normalise to 0.
492  if (!$name) {
493  $name = '0';
494  }
495  $sanitised_names[] = '\'' . sanitise_string($name) . '\'';
496  }
497 
498  if ($names_str = implode(',', $sanitised_names)) {
499  $return['joins'][] = "JOIN {$db_prefix}metastrings msn on $table.name_id = msn.id";
500  $names_where = "(msn.string IN ($names_str))";
501  }
502  }
503 
504  // get values wheres and joins
505  $values_where = '';
506  if ($values !== null) {
507  if (!is_array($values)) {
508  $values = array($values);
509  }
510 
511  $sanitised_values = array();
512  foreach ($values as $value) {
513  // normalize to 0
514  if (!$value) {
515  $value = 0;
516  }
517  $sanitised_values[] = '\'' . sanitise_string($value) . '\'';
518  }
519 
520  if ($values_str = implode(',', $sanitised_values)) {
521  $return['joins'][] = "JOIN {$db_prefix}metastrings msv on $table.value_id = msv.id";
522  $values_where = "({$binary}msv.string IN ($values_str))";
523  }
524  }
525 
526  if ($ids !== null) {
527  if (!is_array($ids)) {
528  $ids = array($ids);
529  }
530 
531  $ids_str = implode(',', $ids);
532 
533  if ($ids_str) {
534  $wheres[] = "n_table.id IN ($ids_str)";
535  }
536  }
537 
538  if ($names_where && $values_where) {
539  $wheres[] = "($names_where AND $values_where)";
540  } elseif ($names_where) {
541  $wheres[] = $names_where;
542  } elseif ($values_where) {
543  $wheres[] = $values_where;
544  }
545 
546  $wheres[] = _elgg_get_access_where_sql(array('table_alias' => $table));
547 
548  if ($where = implode(' AND ', $wheres)) {
549  $return['wheres'][] = "($where)";
550  }
551 
552  return $return;
553 }
554 
563 
564  // support either metastrings_type or metastring_type
565  // because I've made this mistake many times and hunting it down is a pain...
566  $type = elgg_extract('metastring_type', $options, null);
567  $type = elgg_extract('metastrings_type', $options, $type);
568 
569  $options['metastring_type'] = $type;
570 
571  // support annotation_ and annotations_ because they're way too easy to confuse
572  $prefixes = array('metadata_', 'annotation_', 'annotations_');
573 
574  // map the metadata_* options to metastring_* options
575  $map = array(
576  'names' => 'metastring_names',
577  'values' => 'metastring_values',
578  'case_sensitive' => 'metastring_case_sensitive',
579  'owner_guids' => 'metastring_owner_guids',
580  'created_time_lower' => 'metastring_created_time_lower',
581  'created_time_upper' => 'metastring_created_time_upper',
582  'calculation' => 'metastring_calculation',
583  'ids' => 'metastring_ids',
584  );
585 
586  foreach ($prefixes as $prefix) {
587  $singulars = array("{$prefix}name", "{$prefix}value", "{$prefix}owner_guid", "{$prefix}id");
589 
590  foreach ($map as $specific => $normalized) {
591  $key = $prefix . $specific;
592  if (isset($options[$key])) {
593  $options[$normalized] = $options[$key];
594  }
595  }
596  }
597 
598  return $options;
599 }
600 
616  $id = (int)$id;
617  $db_prefix = elgg_get_config('dbprefix');
618 
620 
621  switch ($type) {
622  case 'annotation':
623  case 'annotations':
624  $type = 'annotation';
625  $table = "{$db_prefix}annotations";
626  break;
627 
628  case 'metadata':
629  $table = "{$db_prefix}metadata";
630  break;
631  }
632 
633  if ($enabled === 'yes' || $enabled === 1 || $enabled === true) {
634  $enabled = 'yes';
635  $event = 'enable';
636  } elseif ($enabled === 'no' || $enabled === 0 || $enabled === false) {
637  $enabled = 'no';
638  $event = 'disable';
639  } else {
640  return false;
641  }
642 
643  $return = false;
644 
645  if ($object) {
646  // don't set it if it's already set.
647  if ($object->enabled == $enabled) {
648  $return = false;
649  } elseif ($object->canEdit() && (elgg_trigger_event($event, $type, $object))) {
650  $return = update_data("UPDATE $table SET enabled = '$enabled' where id = $id");
651  }
652  }
653 
654  return $return;
655 }
656 
672 function _elgg_batch_metastring_based_objects(array $options, $callback, $inc_offset = true) {
673  if (!$options || !is_array($options)) {
674  return false;
675  }
676 
677  $batch = new ElggBatch('_elgg_get_metastring_based_objects', $options, $callback, 50, $inc_offset);
678  return $batch->callbackResult;
679 }
680 
690  $id = (int)$id;
691  if (!$id) {
692  return false;
693  }
694 
695  $options = array(
696  'metastring_type' => $type,
697  'metastring_id' => $id,
698  );
699 
701 
702  if ($obj && count($obj) == 1) {
703  return $obj[0];
704  }
705 
706  return false;
707 }
708 
718  $id = (int)$id;
719  $db_prefix = elgg_get_config('dbprefix');
720 
721  switch ($type) {
722  case 'annotations':
723  case 'annotation':
724  $table = $db_prefix . 'annotations';
725  $type = 'annotation';
726  break;
727 
728  case 'metadata':
729  $table = $db_prefix . 'metadata';
730  $type = 'metadata';
731  break;
732 
733  default:
734  return false;
735  }
736 
738 
739  if ($obj) {
740  // Tidy up if memcache is enabled.
741  // @todo only metadata is supported
742  if ($type == 'metadata') {
743  static $metabyname_memcache;
744  if ((!$metabyname_memcache) && (is_memcache_available())) {
745  $metabyname_memcache = new ElggMemcache('metabyname_memcache');
746  }
747 
748  if ($metabyname_memcache) {
749  // @todo why name_id? is that even populated?
750  $metabyname_memcache->delete("{$obj->entity_guid}:{$obj->name_id}");
751  }
752  }
753 
754  if ($obj->canEdit()) {
755  // bc code for when we triggered 'delete', 'annotations' #4770
756  $result = true;
757  if ($type == "annotation") {
758  $result = elgg_trigger_event('delete', 'annotations', $obj);
759  if ($result === false) {
760  elgg_deprecated_notice("Use the event 'delete', 'annotation'", 1.9);
761  }
762  }
763 
764  if (elgg_trigger_event('delete', $type, $obj) && $result) {
765  return (bool)delete_data("DELETE FROM $table WHERE id = $id");
766  }
767  }
768  }
769 
770  return false;
771 }
772 
783  $valid_types = array('metadata', 'annotation');
784  if (!in_array($type, $valid_types)) {
785  return false;
786  }
787 
788  // the options for annotations are singular (annotation_name) but the table
789  // is plural (elgg_annotations) so rewrite for the table name.
790  $n_table = ($type == 'annotation') ? 'annotations' : $type;
791 
792  $singulars = array("{$type}_name", "{$type}_value",
793  "{$type}_name_value_pair", "{$type}_owner_guid");
795 
796  $clauses = _elgg_get_entity_metadata_where_sql('e', $n_table, $options["{$type}_names"],
797  $options["{$type}_values"], $options["{$type}_name_value_pairs"],
798  $options["{$type}_name_value_pairs_operator"], $options["{$type}_case_sensitive"],
799  $options["order_by_{$type}"], $options["{$type}_owner_guids"]);
800 
801  if ($clauses) {
802  // merge wheres to pass to elgg_get_entities()
803  if (isset($options['wheres']) && !is_array($options['wheres'])) {
804  $options['wheres'] = array($options['wheres']);
805  } elseif (!isset($options['wheres'])) {
806  $options['wheres'] = array();
807  }
808 
809  $options['wheres'] = array_merge($options['wheres'], $clauses['wheres']);
810 
811  // merge joins to pass to elgg_get_entities()
812  if (isset($options['joins']) && !is_array($options['joins'])) {
813  $options['joins'] = array($options['joins']);
814  } elseif (!isset($options['joins'])) {
815  $options['joins'] = array();
816  }
817 
818  $options['joins'] = array_merge($options['joins'], $clauses['joins']);
819 
820  if ($clauses['orders']) {
821  $order_by_metadata = implode(", ", $clauses['orders']);
822  if (isset($options['order_by']) && $options['order_by']) {
823  $options['order_by'] = "$order_by_metadata, {$options['order_by']}";
824  } else {
825  $options['order_by'] = "$order_by_metadata, e.time_created DESC";
826  }
827  }
828  }
829 
830  return $options;
831 }
832 
844  global $CONFIG;
845  $value[] = $CONFIG->path . 'engine/tests/ElggCoreMetastringsTest.php';
846  return $value;
847 }
848 
849 elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_metastrings_test');
_elgg_entities_get_metastrings_options($type, $options)
Returns options to pass to elgg_get_entities() for metastrings operations.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
_elgg_batch_metastring_based_objects(array $options, $callback, $inc_offset=true)
Runs metastrings-based objects found using $options through $callback.
elgg_get_metastring_id($string, $case_sensitive=true)
Gets the metastring identifier for a value.
Definition: metastrings.php:34
get_data_row($query, $callback="")
Retrieve a single row from the database.
Definition: database.php:66
$table
Definition: cron.php:28
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
$object
Definition: upgrade.php:12
const ELGG_ENTITIES_NO_VALUE
Definition: elgglib.php:2143
_elgg_get_guid_based_where_sql($column, $guids)
Returns SQL where clause for owner and containers.
Definition: entities.php:1238
if(elgg_in_context('widget')) $offset
Definition: pagination.php:20
get_config($name, $site_guid=0)
Gets a configuration value.
_elgg_get_entity_time_where_sql($table, $time_created_upper=null, $time_created_lower=null, $time_updated_upper=null, $time_updated_lower=null)
Returns SQL where clause for entity time limits.
Definition: entities.php:1287
$value
Definition: longtext.php:29
$return
Definition: opendd.php:15
global $METASTRINGS_CACHE
Definition: metastrings.php:15
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1464
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
Definition: elgglib.php:853
delete_data($query)
Remove a row from the database.
Definition: database.php:106
_elgg_get_metastring_sql($table, $names=null, $values=null, $pairs=null, $ids=null, $case_sensitive=false)
Returns an array of joins and wheres for use in metastrings.
_elgg_sql_reverse_order_by_clause($order_by)
Reverses the ordering in an ORDER BY clause.
Definition: elgglib.php:1809
update_data($query)
Update a row in the database.
Definition: database.php:93
$string
insert_data($query)
Insert a row into the database.
Definition: database.php:80
$options
Definition: index.php:14
_elgg_get_entity_metadata_where_sql($e_table, $n_table, $names=null, $values=null, $pairs=null, $pair_operator= 'AND', $case_sensitive=true, $order_by_metadata=null, $owner_guids=null)
Returns metadata name and value SQL where for entities.
Definition: metadata.php:495
$limit
Definition: userpicker.php:33
$key
Definition: summary.php:34
_elgg_delete_metastring_based_object_by_id($id, $type)
Deletes a metastring-based object by its id.
_elgg_get_metastring_based_object_from_id($id, $type)
Returns a singular metastring-based object by its ID.
global $CONFIG
$enabled
Sample cli installer script.
sanitise_string($string)
Wrapper function for alternate English spelling (.
Definition: database.php:150
_elgg_get_metastring_based_objects($options)
Returns an array of either ElggAnnotation or ElggMetadata objects.
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2134
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1171
elgg global
Pointer to the global context.
Definition: elgglib.js:12
$type
Definition: add.php:8
get_data($query, $callback="")
Retrieve rows from the database.
Definition: database.php:50
_elgg_delete_orphaned_metastrings()
Delete any orphaned entries in metastrings.
_elgg_get_entity_type_subtype_where_sql($table, $types, $subtypes, $pairs)
Returns SQL where clause for type and subtype on main entity table.
Definition: entities.php:1069
_elgg_normalize_metastrings_options(array $options=array())
Normalizes metadata / annotation option names to their corresponding metastrings name.
sanitise_int($int, $signed=true)
Sanitizes an integer for database use.
Definition: database.php:173
_elgg_metastrings_test($hook, $type, $value)
Metastring unit tests.
is_memcache_available()
Return true if memcache is available and configured.
Definition: memcache.php:16
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
Definition: elgglib.php:1594
$defaults
Definition: access.php:19
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
Definition: access.php:343
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
Definition: elgglib.php:720
_elgg_set_metastring_based_object_enabled_by_id($id, $enabled, $type)
Enables or disables a metastrings-based object by its id.
if(!$collection_name) $id
Definition: add.php:17
if(!$num_display) $db_prefix
Definition: content.php:12
_elgg_add_metastring($string)
Add a metastring.