Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | List of all members
Elgg\Database\Annotations Class Reference

Public Member Functions

 __construct ()
 Constructor. More...
 
 get ($id)
 Get a specific annotation by its id. More...
 
 delete ($id)
 Deletes an annotation using its ID. More...
 
 create ($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=ACCESS_PRIVATE)
 Create a new annotation. More...
 
 update ($annotation_id, $name, $value, $value_type, $owner_guid, $access_id)
 Update an annotation. More...
 
 find (array $options=array())
 Returns annotations. More...
 
 deleteAll (array $options)
 Deletes annotations based on $options. More...
 
 disableAll (array $options)
 Disables annotations based on $options. More...
 
 enableAll (array $options)
 Enables annotations based on $options. More...
 
 getEntities (array $options=array())
 Returns entities based upon annotations. More...
 
 getEntitiesFromCalculation ($options)
 Get entities ordered by a mathematical calculation on annotation values. More...
 
 exists ($entity_guid, $annotation_type, $owner_guid=null)
 Check to see if a user has already created an annotation on an object. More...
 

Detailed Description

Definition at line 13 of file Annotations.php.

Constructor & Destructor Documentation

Elgg\Database\Annotations::__construct ( )

Constructor.

Definition at line 24 of file Annotations.php.

Member Function Documentation

Elgg\Database\Annotations::create (   $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 68 of file Annotations.php.

Elgg\Database\Annotations::delete (   $id)

Deletes an annotation using its ID.

Parameters
int$idThe annotation ID to delete.
Returns
bool

Definition at line 48 of file Annotations.php.

Elgg\Database\Annotations::deleteAll ( 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.

Definition at line 227 of file Annotations.php.

Elgg\Database\Annotations::disableAll ( 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.

Definition at line 244 of file Annotations.php.

Elgg\Database\Annotations::enableAll ( 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.

Definition at line 268 of file Annotations.php.

Elgg\Database\Annotations::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

Definition at line 454 of file Annotations.php.

Elgg\Database\Annotations::find ( 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

Definition at line 205 of file Annotations.php.

Elgg\Database\Annotations::get (   $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 38 of file Annotations.php.

Elgg\Database\Annotations::getEntities ( array  $options = array())

Returns entities based upon annotations.

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

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.

Definition at line 309 of file Annotations.php.

Elgg\Database\Annotations::getEntitiesFromCalculation (   $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 410 of file Annotations.php.

Elgg\Database\Annotations::update (   $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.


The documentation for this class was generated from the following file: