64 function delete(
$id) {
94 $owner_guid = $this->session->getLoggedInUserGuid();
97 $access_id = (int)$access_id;
115 $result = $this->db->insertData(
"INSERT INTO {$this->db->prefix}annotations 116 (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES 117 ($entity_guid, $name_id, $value_id, '$value_type', $owner_guid, $time, $access_id)");
121 if ($this->events->trigger(
'create',
'annotation', $obj)) {
149 $annotation_id = (int)$annotation_id;
164 $owner_guid = $this->session->getLoggedInUserGuid();
167 $access_id = (int)$access_id;
179 $result = $this->db->updateData(
"UPDATE {$this->db->prefix}annotations 180 SET name_id = $name_id, value_id = $value_id, value_type = '$value_type', 181 access_id = $access_id, owner_guid = $owner_guid 182 WHERE id = $annotation_id");
186 $obj = $this->
get($annotation_id);
187 $this->events->trigger(
'update',
'annotation', $obj);
225 $options[
'annotation_calculation'] =
'count';
229 $options[
'metastring_type'] =
'annotations';
248 $options[
'metastring_type'] =
'annotations';
269 $options[
'metastring_type'] =
'annotations';
285 if (!$options || !is_array($options)) {
289 $options[
'metastring_type'] =
'annotations';
331 'annotation_name_value_pairs_operator' =>
'AND',
332 'annotation_case_sensitive' =>
true,
333 'order_by_annotation' => array(),
343 $singulars = array(
'annotation_name',
'annotation_value',
344 'annotation_name_value_pair',
'annotation_owner_guid');
355 if (isset(
$options[
'order_by']) && preg_match(
'~\bmaxtime\b~i',
$options[
'order_by'])) {
360 if (!is_array($selects)) {
361 $selects = array($selects);
364 foreach ($selects as
$select) {
365 if (preg_match(
'~\bmaxtime\b~i',
$options[
'order_by'])) {
376 .
" by maxtime, you must provide that column via \$options['selects']. See" 377 .
" https://github.com/Elgg/Elgg/issues/6638#issuecomment-41562034",
"1.10");
379 $options[
'selects'][] =
"MAX(n_table.time_created) AS maxtime";
380 $options[
'group_by'] =
'n_table.entity_guid';
385 $options[
'annotation_created_time_lower']);
388 $options[
'wheres'][] = $time_wheres;
434 'calculation' =>
'sum',
435 'order_by' =>
'annotation_calculation desc' 444 $options[
'selects'][] =
"$function(CAST(a_msv.string AS signed)) AS annotation_calculation";
448 $options[
'joins'][] =
"JOIN {$db_prefix}metastrings a_msv ON n_table.value_id = a_msv.id";
451 $options[
'group_by'] =
'n_table.entity_guid';
455 $options[
'callback'] =
'entity_row_to_elggstar';
481 $sql =
"SELECT a.id FROM {$this->db->prefix}annotations a" .
482 " JOIN {$this->db->prefix}metastrings m ON a.name_id = m.id" .
483 " WHERE a.owner_guid = $owner_guid AND a.entity_guid = $entity_guid" .
484 " AND m.string = '$annotation_type'";
486 if ($this->db->getDataRow($sql)) {
getEntities(array $options=array())
Returns entities based upon annotations.
_elgg_is_valid_options_for_batch_operation($options, $type)
Checks if there are some constraints on the options array for potentially dangerous operations...
$annotation
Elgg default annotation view.
deleteAll(array $options)
Deletes annotations based on $options.
if($guid==elgg_get_logged_in_user_guid()) $name
__construct(\Elgg\Database $db,\ElggSession $session,\Elgg\EventsService $events)
Constructor.
elgg_get_entities_from_annotations(array $options=array())
Returns entities based upon annotations.
_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.
create($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=ACCESS_PRIVATE)
Create a new annotation.
static detectValueType($value, $value_type="")
Detect the value_type for a value to be stored as metadata or an annotation.
getCurrentTime($modifier= '')
Get the (cloned) time.
disableAll(array $options)
Disables annotations based on $options.
sanitize_string($string)
Sanitizes a string for use in a query.
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
exists($entity_guid, $annotation_type, $owner_guid=null)
Check to see if a user has already created an annotation on an object.
getEntitiesFromCalculation($options)
Get entities ordered by a mathematical calculation on annotation values.
elgg_delete_annotation_by_id($id)
Deletes an annotation using its ID.
const ELGG_ENTITIES_ANY_VALUE
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
find(array $options=array())
Returns annotations.
access_get_show_hidden_status()
Return current status of showing disabled entities.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_get_annotations(array $options=array())
Returns annotations.
update($annotation_id, $name, $value, $value_type, $owner_guid, $access_id)
Update an annotation.
trait TimeUsing
Adds methods for setting the current time (for testing)
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
sanitize_int($int, $signed=true)
Sanitizes an integer for database use.
if(!$collection_name) $id
if(!$num_display) $db_prefix
get_entity($guid)
Loads and returns an entity object from a guid.
enableAll(array $options)
Enables annotations based on $options.