Elgg  Version 6.1
ElggAnnotation.php
Go to the documentation of this file.
1 <?php
2 
10 
14  protected function initializeAttributes() {
15  parent::initializeAttributes();
16 
17  $this->attributes['type'] = 'annotation';
18  }
19 
25  public function __construct(stdClass $row = null) {
26  $this->initializeAttributes();
27 
28  if ($row) {
29  foreach ((array) $row as $key => $value) {
30  $this->$key = $value;
31  }
32  }
33  }
34 
40  public function save(): bool {
41  if (!isset($this->access_id)) {
42  $this->access_id = ACCESS_PRIVATE;
43  }
44 
45  if (!isset($this->owner_guid)) {
46  $this->owner_guid = _elgg_services()->session_manager->getLoggedInUserGuid();
47  }
48 
49  if ($this->id) {
50  return _elgg_services()->annotationsTable->update($this);
51  }
52 
53  if (!isset($this->entity_guid)) {
54  return false;
55  }
56 
57  $entity = get_entity($this->entity_guid);
58  if (!$entity) {
59  return false;
60  }
61 
62  if (_elgg_services()->annotationsTable->create($this, $entity)) {
63  return true;
64  }
65 
66  return false;
67  }
68 
74  public function delete(): bool {
75  return _elgg_services()->annotationsTable->delete($this);
76  }
77 
85  public function canEdit(int $user_guid = 0): bool {
86  return _elgg_services()->userCapabilities->canEditAnnotation($this->getEntity(), $user_guid, $this);
87  }
88 
92  public function getObjectFromID(int $id) {
93  return elgg_get_annotation_from_id($id);
94  }
95 }
__construct(stdClass $row=null)
Constructor.
getObjectFromID(int $id)
{}
save()
Save this instance and returns an annotation ID.
$user_guid
Definition: login_as.php:10
getEntity()
Get the entity this describes.
Entity Annotation.
canEdit(int $user_guid=0)
Determines whether or not the user can edit this annotation.
$value
Definition: generic.php:51
const ACCESS_PRIVATE
Definition: constants.php:10
$entity
Definition: reset.php:8
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:70
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
$comment access_id
Definition: save.php:55
elgg_get_annotation_from_id(int $id)
Elgg annotations Functions to manage object annotations.
Definition: annotations.php:16
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
$id
Generic annotation delete action.
Definition: delete.php:6