Elgg  Version 1.11
metadata.php
Go to the documentation of this file.
1 <?php
19  if (!($row instanceof \stdClass)) {
20  return $row;
21  }
22 
23  return new \ElggMetadata($row);
24 }
25 
36  return _elgg_services()->metadataTable->get($id);
37 }
38 
46  return _elgg_services()->metadataTable->delete($id);
47 }
48 
65 function create_metadata($entity_guid, $name, $value, $value_type = '', $owner_guid = 0,
66  $access_id = ACCESS_PRIVATE, $allow_multiple = false) {
67 
68  return _elgg_services()->metadataTable->create($entity_guid, $name, $value,
69  $value_type, $owner_guid, $access_id, $allow_multiple);
70 }
71 
84 function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id) {
85  return _elgg_services()->metadataTable->update($id, $name, $value,
86  $value_type, $owner_guid, $access_id);
87 }
88 
105 function create_metadata_from_array($entity_guid, array $name_and_values, $value_type, $owner_guid,
106  $access_id = ACCESS_PRIVATE, $allow_multiple = false) {
107 
108  return _elgg_services()->metadataTable->createFromArray($entity_guid, $name_and_values,
109  $value_type, $owner_guid, $access_id, $allow_multiple);
110 
111 }
112 
143 function elgg_get_metadata(array $options = array()) {
144  return _elgg_services()->metadataTable->getAll($options);
145 }
146 
159  return _elgg_services()->metadataTable->deleteAll($options);
160 }
161 
172  return _elgg_services()->metadataTable->disableAll($options);
173 }
174 
188  return _elgg_services()->metadataTable->enableAll($options);
189 }
190 
255 function elgg_get_entities_from_metadata(array $options = array()) {
256  return _elgg_services()->metadataTable->getEntities($options);
257 }
258 
270  return elgg_list_entities($options, 'elgg_get_entities_from_metadata');
271 }
272 
296 function _elgg_get_entity_metadata_where_sql($e_table, $n_table, $names = null, $values = null,
297  $pairs = null, $pair_operator = 'AND', $case_sensitive = true, $order_by_metadata = null,
298  $owner_guids = null) {
299  return _elgg_services()->metadataTable->getEntityMetadataWhereSql($e_table, $n_table, $names,
300  $values, $pairs, $pair_operator, $case_sensitive, $order_by_metadata, $owner_guids);
301 }
302 
311 function metadata_array_to_values($array) {
312  $valuearray = array();
313 
314  if (is_array($array)) {
315  foreach ($array as $element) {
316  $valuearray[] = $element->value;
317  }
318  }
319 
320  return $valuearray;
321 }
322 
333  return _elgg_services()->metadataTable->getUrl($id);
334 }
335 
346  _elgg_services()->metadataTable->registerMetadataAsIndependent($type, $subtype);
347 }
348 
359  return _elgg_services()->metadataTable->isMetadataIndependent($type, $subtype);
360 }
361 
372 function metadata_update($event, $object_type, $object) {
373  return _elgg_services()->metadataTable->handleUpdate($event, $object_type, $object);
374 }
375 
386  _elgg_services()->metadataCache->invalidateByOptions($options);
387 }
388 
401  global $CONFIG;
402  $value[] = $CONFIG->path . 'engine/tests/ElggCoreMetadataAPITest.php';
403  $value[] = $CONFIG->path . 'engine/tests/ElggCoreMetadataCacheTest.php';
404  return $value;
405 }
406 
407 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
409  $events->registerHandler('update', 'all', 'metadata_update');
410 
411  $hooks->registerHandler('unit_test', 'system', '_elgg_metadata_test');
412 };
elgg_delete_metadata_by_id($id)
Deletes metadata using its ID.
Definition: metadata.php:45
update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)
Update a specific piece of metadata.
Definition: metadata.php:84
get_metadata_url($id)
Get the URL for this metadata.
Definition: metadata.php:332
elgg_get_entities_from_metadata(array $options=array())
interfaces
Definition: metadata.php:255
elgg_disable_metadata(array $options)
Disables metadata based on $options.
Definition: metadata.php:171
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
register_metadata_as_independent($type, $subtype= '*')
Mark entities with a particular type and subtype as having access permissions that can be changed ind...
Definition: metadata.php:345
$object
Definition: upgrade.php:12
$value
Definition: longtext.php:26
elgg_list_entities_from_metadata($options)
Returns a list of entities filtered by provided metadata.
Definition: metadata.php:269
row_to_elggmetadata($row)
Convert a database row to a new .
Definition: metadata.php:18
elgg_get_metadata_from_id($id)
Get a specific metadata object by its id.
Definition: metadata.php:35
$action
$params
Definition: login.php:72
$entity_guid
Definition: save.php:9
$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:296
$owner_guid
metadata_array_to_values($array)
Takes a metadata array (which has all kinds of properties) and turns it into a simple array of string...
Definition: metadata.php:311
is_metadata_independent($type, $subtype)
Determines whether entities of a given type and subtype should not change their metadata in line with...
Definition: metadata.php:358
elgg_enable_metadata(array $options)
Enables metadata based on $options.
Definition: metadata.php:187
_elgg_services()
Definition: autoloader.php:14
global $CONFIG
create_metadata($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=ACCESS_PRIVATE, $allow_multiple=false)
Create a new metadata object, or update an existing one.
Definition: metadata.php:65
const ACCESS_PRIVATE
Definition: elgglib.php:1954
elgg global
Pointer to the global context.
Definition: elgglib.js:12
$type
Definition: add.php:8
metadata_update($event, $object_type, $object)
When an entity is updated, resets the access ID on all of its child metadata.
Definition: metadata.php:372
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:586
elgg_delete_metadata(array $options)
Deletes metadata based on $options.
Definition: metadata.php:158
elgg_get_metadata(array $options=array())
Returns metadata.
Definition: metadata.php:143
$row
create_metadata_from_array($entity_guid, array $name_and_values, $value_type, $owner_guid, $access_id=ACCESS_PRIVATE, $allow_multiple=false)
This function creates metadata from an associative array of "key => value" pairs. ...
Definition: metadata.php:105
_elgg_metadata_test($hook, $type, $value, $params)
Metadata unit test.
Definition: metadata.php:400
$subtype
Definition: river.php:12
if(!$collection_name) $id
Definition: add.php:17
_elgg_invalidate_metadata_cache($action, array $options)
Invalidate the metadata cache based on options passed to various *_metadata functions.
Definition: metadata.php:385