Elgg  Version 3.0
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() {
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->getLoggedInUserGuid();
47  }
48 
49  if ($this->id) {
50  return _elgg_services()->annotationsTable->update($this);
51  }
52 
53  $entity = get_entity($this->entity_guid);
54  if (!$entity) {
55  return false;
56  }
57 
58  if (_elgg_services()->annotationsTable->create($this, $entity)) {
59  return $this->id;
60  }
61 
62  return false;
63  }
64 
70  public function delete() {
71  return _elgg_services()->annotationsTable->delete($this);
72  }
73 
80  public function disable() {
81  return _elgg_services()->annotationsTable->disable($this);
82  }
83 
90  public function enable() {
91  return _elgg_services()->annotationsTable->enable($this);
92  }
93 
102  public function canEdit($user_guid = 0) {
103  $entity = $this->getEntity();
104 
105  return _elgg_services()->userCapabilities->canEditAnnotation($entity, $user_guid, $this);
106  }
107 
111  public function getObjectFromID($id) {
113  }
114 }
disable()
Disable the annotation.
__construct(stdClass $row=null)
Constructor.
save()
Save this instance and returns an annotation ID.
getEntity()
Get the entity this describes.
$user_guid
Validate a user.
Definition: validate.php:6
canEdit($user_guid=0)
Determines whether or not the user can edit this annotation.
$id
River item delete action.
Definition: delete.php:6
elgg_get_annotation_from_id($id)
Elgg annotations Functions to manage object annotations.
Definition: annotations.php:16
const ACCESS_PRIVATE
Definition: constants.php:12
$entity
Definition: reset.php:8
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$comment access_id
Definition: save.php:47
$value
Definition: debugging.php:7
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
getObjectFromID($id)
{}
enable()
Enable the annotation.
$comment owner_guid
Definition: save.php:45
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87