Elgg  Version 2.3
Namespaces | Functions | Variables
annotations.php File Reference

Go to the source code of this file.

Namespaces

 Elgg
 Save menu items.
 

Functions

 row_to_elggannotation ($row)
 Convert a database row to a new . More...
 
 elgg_get_annotation_from_id ($id)
 Get a specific annotation by its id. More...
 
 elgg_delete_annotation_by_id ($id)
 Deletes an annotation using its ID. More...
 
 create_annotation ($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=ACCESS_PRIVATE)
 Create a new annotation. More...
 
 update_annotation ($annotation_id, $name, $value, $value_type, $owner_guid, $access_id)
 Update an annotation. More...
 
 elgg_get_annotations (array $options=array())
 Returns annotations. More...
 
 elgg_list_annotations ($options)
 Returns a rendered list of annotations with pagination. More...
 
 elgg_delete_annotations (array $options)
 Deletes annotations based on $options. More...
 
 elgg_disable_annotations (array $options)
 Disables annotations based on $options. More...
 
 elgg_enable_annotations (array $options)
 Enables annotations based on $options. More...
 
 elgg_get_entities_from_annotations (array $options=array())
 Returns entities based upon annotations. More...
 
 elgg_list_entities_from_annotations ($options=array())
 Returns a viewable list of entities from annotations. More...
 
 elgg_get_entities_from_annotation_calculation ($options)
 Get entities ordered by a mathematical calculation on annotation values. More...
 
 elgg_list_entities_from_annotation_calculation ($options)
 List entities from an annotation calculation. More...
 
 elgg_annotation_exists ($entity_guid, $annotation_type, $owner_guid=null)
 Check to see if a user has already created an annotation on an object. More...
 
 _elgg_set_comment_url ($hook, $type, $url, $params)
 Set the URL for a comment when called from a plugin hook. More...
 
 _elgg_annotations_test ($hook, $type, $tests)
 Register annotation unit tests. More...
 
 _elgg_annotations_init ()
 Initialize the annotation library private. More...
 

Variables

return function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
 

Function Documentation

_elgg_annotations_init ( )

Initialize the annotation library private.

Definition at line 345 of file annotations.php.

_elgg_annotations_test (   $hook,
  $type,
  $tests 
)

Register annotation unit tests.

Parameters
string$hook
string$type
array$tests
Returns
array private

Definition at line 335 of file annotations.php.

_elgg_set_comment_url (   $hook,
  $type,
  $url,
  $params 
)

Set the URL for a comment when called from a plugin hook.

Parameters
string$hookHook name
string$typeHook type
string$urlURL string
array$paramsParameters of the hook
Returns
string private

Definition at line 315 of file annotations.php.

create_annotation (   $entity_guid,
  $name,
  $value,
  $value_type = '',
  $owner_guid = 0,
  $access_id = ACCESS_PRIVATE 
)

Create a new annotation.

Parameters
int$entity_guidGUID of entity to be annotated
string$nameName of annotation
string$valueValue of annotation
string$value_typeType of value (default is auto detection)
int$owner_guidOwner of annotation (default is logged in user)
int$access_idAccess level of annotation
Returns
int|bool id on success or false on failure

Definition at line 62 of file annotations.php.

elgg_annotation_exists (   $entity_guid,
  $annotation_type,
  $owner_guid = null 
)

Check to see if a user has already created an annotation on an object.

Parameters
int$entity_guidEntity guid
string$annotation_typeType of annotation
int$owner_guidDefaults to logged in user.
Returns
bool
Since
1.8.0

Definition at line 301 of file annotations.php.

elgg_delete_annotation_by_id (   $id)

Deletes an annotation using its ID.

Parameters
int$idThe annotation ID to delete.
Returns
bool

Definition at line 46 of file annotations.php.

elgg_delete_annotations ( array  $options)

Deletes annotations based on $options.

Warning
Unlike elgg_get_annotations() this will not accept an empty options array! This requires at least one constraint: annotation_owner_guid(s), annotation_name(s), annotation_value(s), or guid(s) must be set.
Parameters
array$optionsAn options array. elgg_get_annotations()
Returns
bool|null true on success, false on failure, null if no annotations to delete.
Since
1.8.0

Definition at line 149 of file annotations.php.

elgg_disable_annotations ( array  $options)

Disables annotations based on $options.

Warning
Unlike elgg_get_annotations() this will not accept an empty options array!
Parameters
array$optionsAn options array. elgg_get_annotations()
Returns
bool|null true on success, false on failure, null if no annotations disabled.
Since
1.8.0

Definition at line 162 of file annotations.php.

elgg_enable_annotations ( array  $options)

Enables annotations based on $options.

Warning
Unlike elgg_get_annotations() this will not accept an empty options array!
In order to enable annotations, you must first use access_show_hidden_entities().
Parameters
array$optionsAn options array. elgg_get_annotations()
Returns
bool|null true on success, false on failure, null if no metadata enabled.
Since
1.8.0

Definition at line 178 of file annotations.php.

elgg_get_annotation_from_id (   $id)

Get a specific annotation by its id.

If you want multiple annotation objects, use elgg_get_annotations().

Parameters
int$idThe id of the annotation object being retrieved.
Returns
|false

Definition at line 36 of file annotations.php.

elgg_get_annotations ( array  $options = array())

Returns annotations.

Accepts all elgg_get_entities() options for entity restraints.

See also
elgg_get_entities
Parameters
array$optionsArray in format:

annotation_names => null|ARR Annotation names annotation_values => null|ARR Annotation values annotation_ids => null|ARR annotation ids annotation_case_sensitive => BOOL Overall Case sensitive annotation_owner_guids => null|ARR guids for annotation owners annotation_created_time_lower => INT Lower limit for created time. annotation_created_time_upper => INT Upper limit for created time. annotation_calculation => STR Perform the MySQL function on the annotation values returned. Do not confuse this "annotation_calculation" option with the "calculation" option to elgg_get_entities_from_annotation_calculation(). The "annotation_calculation" option causes this function to return the result of performing a mathematical calculation on all annotations that match the query instead of objects. See the docs for elgg_get_entities_from_annotation_calculation() for the proper use of the "calculation" option.

Returns
[]|mixed
Since
1.8.0

Definition at line 113 of file annotations.php.

elgg_get_entities_from_annotation_calculation (   $options)

Get entities ordered by a mathematical calculation on annotation values.

Note that this function uses elgg_get_annotations() to return a list of entities ordered by a mathematical calculation on annotation values, and elgg_get_entities_from_annotations() to return a count of entities if $options['count'] is set to a truthy value

Parameters
array$optionsAn options array: 'calculation' => The calculation to use. Must be a valid MySQL function. Defaults to sum. Result selected as 'annotation_calculation'. Don't confuse this "calculation" option with the "annotation_calculation" option to elgg_get_annotations(). This "calculation" option is applied to each entity's set of annotations and is selected as annotation_calculation for that row. See the docs for elgg_get_annotations() for proper use of the "annotation_calculation" option. 'order_by' => The order for the sorting. Defaults to 'annotation_calculation desc'. 'annotation_names' => The names of annotations on the entity. 'annotation_values' => The values of annotations on the entity.

'metadata_names' => The name of metadata on the entity. 'metadata_values' => The value of metadata on the entitiy. 'callback' => Callback function to pass each row through. This function is different from other ege* functions, as it uses a metastring-based getter function elgg_get_annotations(), therefore the callback function should be a derivative of entity_row_to_elggstar() and not of row_to_annotation()

Returns
[]|int An array or a count of entities
See also
elgg_get_annotations()
elgg_get_entities_from_annotations()

Definition at line 268 of file annotations.php.

elgg_get_entities_from_annotations ( array  $options = array())

Returns entities based upon annotations.

Also accepts all options available to elgg_get_entities() and elgg_get_entities_from_metadata().

Entity creation time is selected as maxtime. To sort based upon this, pass 'order_by' => 'maxtime asc' || 'maxtime desc'

See also
elgg_get_entities
elgg_get_entities_from_metadata
Parameters
array$optionsArray in format:
annotation_names => null|ARR annotations names

annotation_values => null|ARR annotations values

annotation_name_value_pairs => null|ARR (name = 'name', value => 'value',
'operator' => '=', 'case_sensitive' => true) entries.
Currently if multiple values are sent via an array (value => array('value1', 'value2')
the pair's operator will be forced to "IN".

annotation_name_value_pairs_operator => null|STR The operator to use for combining
(name = value) OPERATOR (name = value); default AND

annotation_case_sensitive => BOOL Overall Case sensitive

order_by_annotation => null|ARR (array('name' => 'annotation_text1', 'direction' => ASC|DESC, 'as' => text|integer),

Also supports array('name' => 'annotation_text1')

annotation_owner_guids => null|ARR guids for annotaiton owners

Returns
mixed If count, int. If not count, array. false on errors.
Since
1.7.0

Definition at line 218 of file annotations.php.

elgg_list_annotations (   $options)

Returns a rendered list of annotations with pagination.

Parameters
array$optionsAnnotation getter and display options. elgg_get_annotations() and elgg_list_entities().
Returns
string The list of entities
Since
1.8.0

Definition at line 126 of file annotations.php.

elgg_list_entities_from_annotation_calculation (   $options)

List entities from an annotation calculation.

See also
elgg_get_entities_from_annotation_calculation()
Parameters
array$optionsAn options array.
Returns
string

Definition at line 281 of file annotations.php.

elgg_list_entities_from_annotations (   $options = array())

Returns a viewable list of entities from annotations.

Parameters
array$optionsOptions array
See also
elgg_get_entities_from_annotations()
elgg_list_entities()
Returns
string

Definition at line 232 of file annotations.php.

row_to_elggannotation (   $row)

Convert a database row to a new .

Parameters
\stdClass$rowDb row result object
Returns
private

Definition at line 18 of file annotations.php.

update_annotation (   $annotation_id,
  $name,
  $value,
  $value_type,
  $owner_guid,
  $access_id 
)

Update an annotation.

Parameters
int$annotation_idAnnotation ID
string$nameName of annotation
string$valueValue of annotation
string$value_typeType of value
int$owner_guidOwner of annotation
int$access_idAccess level of annotation
Returns
bool

Definition at line 80 of file annotations.php.

Variable Documentation

Definition at line 350 of file annotations.php.