47 $qb->addClause($where);
49 $row = $this->db->getDataRow(
$qb);
50 return !empty($row) ? new \ElggAnnotation($row) : null;
65 if (!$this->events->trigger(
'delete',
'annotation',
$annotation)) {
92 if ($annotation->id) {
93 return $this->
update($annotation);
96 if (is_null($annotation->owner_guid) || is_null($annotation->name) || is_null($annotation->value)) {
100 $annotation->entity_guid = $entity->guid;
109 if (!$this->events->triggerBefore(
'create',
'annotation', $annotation)) {
121 'owner_guid' =>
$qb->param($annotation->owner_guid, ELGG_VALUE_INTEGER),
123 'access_id' =>
$qb->param($annotation->access_id, ELGG_VALUE_INTEGER),
134 if (!$this->events->trigger(
'create',
'annotation', $annotation)) {
140 $this->events->triggerAfter(
'create',
'annotation', $annotation);
159 if (is_null($annotation->owner_guid) || is_null($annotation->name) || is_null($annotation->value)) {
163 if (!$this->events->triggerBefore(
'update',
'annotation', $annotation)) {
170 ->
set(
'value_type',
$qb->param($annotation->value_type, ELGG_VALUE_STRING))
181 $this->events->trigger(
'update',
'annotation', $annotation);
182 $this->events->triggerAfter(
'update',
'annotation', $annotation);
196 if ($annotation->enabled ===
'no') {
208 if ($annotation->id) {
213 if (!$this->db->updateData(
$qb)) {
218 $annotation->enabled =
'no';
232 if ($annotation->enabled ==
'yes') {
244 if ($annotation->id) {
249 if (!$this->db->updateData(
$qb)) {
254 $annotation->enabled =
'yes';
269 $options[
'metastring_type'] =
'annotations';
294 $options[
'batch'] =
true;
295 $options[
'batch_size'] = 50;
296 $options[
'batch_inc_offset'] =
false;
299 $count = $annotations->count();
307 if ($annotation->delete()) {
312 return $success ===
$count;
330 $inc_offset =
_elgg_services()->session_manager->getDisabledEntityVisibility();
332 $options[
'batch'] =
true;
333 $options[
'batch_size'] = 50;
334 $options[
'batch_inc_offset'] = $inc_offset;
337 $count = $annotations->count();
345 if ($annotation->disable()) {
350 return $success ===
$count;
366 $options[
'batch'] =
true;
367 $options[
'batch_size'] = 50;
370 $count = $annotations->count();
378 if ($annotation->enable()) {
383 return $success ===
$count;
396 'annotation_owner_guid',
'annotation_owner_guids',
397 'annotation_name',
'annotation_names',
398 'annotation_value',
'annotation_values',
403 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...
if(!$user instanceof\ElggUser) $time_created
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.
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)
getCurrentTime($modifier= '')
Get the (cloned) time.
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)
{}
_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.