Elgg  Version 1.9
Namespaces | Functions
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 ElggAnnotation. 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...
 

Function Documentation

_elgg_annotations_init ( )

Initialize the annotation library private.

Definition at line 548 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 537 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 517 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 66 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 484 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 255 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 273 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 298 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
ElggAnnotation|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 ElggAnnotation objects. See the docs for elgg_get_entities_from_annotation_calculation() for the proper use of the "calculation" option.

Returns
ElggAnnotation[]|mixed
Since
1.8.0

Definition at line 206 of file annotations.php.

elgg_get_entities_from_annotation_calculation (   $options)

Get entities ordered by a mathematical calculation on annotation values.

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.

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

Definition at line 424 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 343 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 232 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 464 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 399 of file annotations.php.

row_to_elggannotation (   $row)

Convert a database row to a new ElggAnnotation.

Parameters
stdClass$rowDb row result object
Returns
ElggAnnotation 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 130 of file annotations.php.