45 $qb->addClause($where);
47 $row = $this->db->getDataRow(
$qb);
48 return !empty($row) ? new \ElggAnnotation($row) : null;
63 if (!$this->events->trigger(
'delete',
'annotation',
$annotation)) {
90 if ($annotation->id) {
91 return $this->
update($annotation);
94 if (is_null($annotation->owner_guid) || is_null($annotation->name) || is_null($annotation->value)) {
98 $annotation->entity_guid = $entity->guid;
107 if (!$this->events->triggerBefore(
'create',
'annotation', $annotation)) {
119 'owner_guid' =>
$qb->param($annotation->owner_guid, ELGG_VALUE_INTEGER),
121 'access_id' =>
$qb->param($annotation->access_id, ELGG_VALUE_INTEGER),
132 if (!$this->events->trigger(
'create',
'annotation', $annotation)) {
138 $this->events->triggerAfter(
'create',
'annotation', $annotation);
157 if (is_null($annotation->owner_guid) || is_null($annotation->name) || is_null($annotation->value)) {
161 if (!$this->events->triggerBefore(
'update',
'annotation', $annotation)) {
168 ->
set(
'value_type',
$qb->param($annotation->value_type, ELGG_VALUE_STRING))
179 $this->events->trigger(
'update',
'annotation', $annotation);
180 $this->events->triggerAfter(
'update',
'annotation', $annotation);
195 $options[
'metastring_type'] =
'annotations';
220 $options[
'batch'] =
true;
221 $options[
'batch_size'] = 50;
222 $options[
'batch_inc_offset'] =
false;
225 $count = $annotations->count();
233 if ($annotation->delete()) {
238 return $success ===
$count;
251 'annotation_owner_guid',
'annotation_owner_guids',
252 'annotation_name',
'annotation_names',
253 'annotation_value',
'annotation_values',
258 if (isset($options[$key]) && !
elgg_is_empty($options[$key])) {
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
exists(int $entity_guid, string $name, int $owner_guid)
Check to see if a user has already created an annotation on an object.
static find(array $options=[])
Build and execute a new query from an array of legacy options.
if(!$user||!$user->canDelete()) $name
isValidOptionsForBatchOperation(array $options)
Checks if there are some constraints on the options array for potentially dangerous operations...
if(!$user instanceof\ElggUser) $time_created
const ELGG_VALUE_INTEGER
Value types.
elgg_delete_river(array $options=[])
Delete river items based on $options.
Builds queries for matching annotations against their properties.
canEdit(int $user_guid=0)
Determines whether or not the user can edit this annotation.
trait TimeUsing
Adds methods for setting the current time (for testing)
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
getCurrentTime($modifier= '')
Get the (cloned) time.
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
__construct(protected Database $db, protected EventsService $events)
Constructor.
deleteAll(array $options)
Deletes annotations based on $options.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
create(\ElggAnnotation $annotation,\ElggEntity $entity)
Create a new annotation and return its ID.
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
update(\ElggAnnotation $annotation)
Store updated annotation in the database.
find(array $options=[])
Returns annotations.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
static fromTable(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
Interfaces with the database to perform CRUD operations on annotations.
$id
Generic annotation delete action.
elgg_delete_annotation_by_id(int $id)
Deletes an annotation using its ID.