47 public function get(
int $id) {
53 $qb->addClause($where);
55 $row = $this->db->getDataRow(
$qb);
57 return new \ElggAnnotation($row);
75 if (!$this->events->trigger(
'delete',
'annotation',
$annotation)) {
102 if ($annotation->id) {
103 return $this->
update($annotation);
106 if (is_null($annotation->owner_guid) || is_null($annotation->name) || is_null($annotation->value)) {
110 $annotation->entity_guid = $entity->guid;
119 if (!$this->events->triggerDeprecated(
'annotate', $entity->
getType(),
$entity,
"The 'annotate', '{$entity->getType()}' event is deprecated. Use the 'create', 'annotation' event instead.",
'4.3')) {
123 if (!$this->events->triggerBefore(
'create',
'annotation', $annotation)) {
135 'owner_guid' =>
$qb->param($annotation->owner_guid, ELGG_VALUE_INTEGER),
137 'access_id' =>
$qb->param($annotation->access_id, ELGG_VALUE_INTEGER),
148 if (!$this->events->trigger(
'create',
'annotation', $annotation)) {
154 $this->events->triggerAfter(
'create',
'annotation', $annotation);
173 if (is_null($annotation->owner_guid) || is_null($annotation->name) || is_null($annotation->value)) {
177 if (!$this->events->triggerBefore(
'update',
'annotation', $annotation)) {
184 ->
set(
'value_type',
$qb->param($annotation->value_type, ELGG_VALUE_STRING))
195 $this->events->trigger(
'update',
'annotation', $annotation);
196 $this->events->triggerAfter(
'update',
'annotation', $annotation);
210 if ($annotation->enabled ==
'no') {
222 if ($annotation->id) {
227 if (!$this->db->updateData(
$qb)) {
232 $annotation->enabled =
'no';
246 if ($annotation->enabled ==
'yes') {
258 if ($annotation->id) {
263 if (!$this->db->updateData(
$qb)) {
268 $annotation->enabled =
'yes';
283 $options[
'metastring_type'] =
'annotations';
308 $options[
'batch'] =
true;
309 $options[
'batch_size'] = 50;
310 $options[
'batch_inc_offset'] =
false;
313 $count = $annotations->count();
321 if ($annotation->delete()) {
326 return $success ==
$count;
344 $inc_offset =
_elgg_services()->session->getDisabledEntityVisibility();
346 $options[
'batch'] =
true;
347 $options[
'batch_size'] = 50;
348 $options[
'batch_inc_offset'] = $inc_offset;
351 $count = $annotations->count();
359 if ($annotation->disable()) {
364 return $success ==
$count;
380 $options[
'batch'] =
true;
381 $options[
'batch_size'] = 50;
384 $count = $annotations->count();
392 if ($annotation->enable()) {
397 return $success ==
$count;
410 'annotation_owner_guid',
'annotation_owner_guids',
411 'annotation_name',
'annotation_names',
412 'annotation_value',
'annotation_values',
417 if (isset($options[$key]) && !
elgg_is_empty($options[$key])) {
getType()
Return a type of extension.
disableAll(array $options)
Disables annotations based on $options.
enable(\ElggAnnotation $annotation)
Enable the annotation.
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
static table($table, $alias=null)
{}
isValidOptionsForBatchOperation(array $options)
Checks if there are some constraints on the options array for potentially dangerous operations...
const ELGG_VALUE_INTEGER
Value types.
elgg_delete_river(array $options=[])
Delete river items based on $options.
__construct(Database $db, EventsService $events)
Constructor.
Builds queries for matching annotations against their properties.
trait TimeUsing
Adds methods for setting the current time (for testing)
getCurrentTime($modifier= '')
Get the (cloned) time.
canEdit($user_guid=0)
Determines whether or not the user can edit this annotation.
static intoTable($table)
{}
disable(\ElggAnnotation $annotation)
Disable the annotation.
deleteAll(array $options)
Deletes annotations based on $options.
create(\ElggAnnotation $annotation,\ElggEntity $entity)
Create a new annotation and return its ID.
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($table, $alias=null)
{}
getType()
Returns the entity type.
_elgg_services()
Get the global service provider.
Interfaces with the database to perform CRUD operations on annotations.
enableAll(array $options)
Enables annotations based on $options.
$id
Generic annotation delete action.
static fromTable($table, $alias=null)
{}
elgg_delete_annotation_by_id(int $id)
Deletes an annotation using its ID.