diff options
Diffstat (limited to 'engine/classes/ElggAnnotation.php')
| -rw-r--r-- | engine/classes/ElggAnnotation.php | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/engine/classes/ElggAnnotation.php b/engine/classes/ElggAnnotation.php index 60a79bac9..175e7049d 100644 --- a/engine/classes/ElggAnnotation.php +++ b/engine/classes/ElggAnnotation.php @@ -11,9 +11,19 @@ * @package Elgg.Core * @subpackage DataModel.Annotations * @link http://docs.elgg.org/DataModel/Annotations + * + * @property string $value_type + * @property string $enabled */ class ElggAnnotation extends ElggExtender { + /** + * (non-PHPdoc) + * + * @see ElggData::initializeAttributes() + * + * @return void + */ protected function initializeAttributes() { parent::initializeAttributes(); @@ -21,26 +31,26 @@ class ElggAnnotation extends ElggExtender { } /** - * Construct a new annotation, optionally from a given id value or db object. + * Construct a new annotation object * - * @param mixed $id The annotation ID + * @param mixed $id The annotation ID or a database row as stdClass object */ function __construct($id = null) { $this->initializeAttributes(); if (!empty($id)) { + // Create from db row if ($id instanceof stdClass) { $annotation = $id; - } else { - $annotation = get_annotation($id); - } - if ($annotation) { $objarray = (array) $annotation; - foreach ($objarray as $key => $value) { $this->attributes[$key] = $value; } + } else { + // get an ElggAnnotation object and copy its attributes + $annotation = elgg_get_annotation_from_id($id); + $this->attributes = $annotation->attributes; } } } @@ -49,6 +59,8 @@ class ElggAnnotation extends ElggExtender { * Save this instance * * @return int an object id + * + * @throws IOException */ function save() { if ($this->id > 0) { @@ -71,7 +83,28 @@ class ElggAnnotation extends ElggExtender { * @return bool */ function delete() { - return delete_annotation($this->id); + elgg_delete_river(array('annotation_id' => $this->id)); + return elgg_delete_metastring_based_object_by_id($this->id, 'annotations'); + } + + /** + * Disable the annotation. + * + * @return bool + * @since 1.8 + */ + function disable() { + return elgg_set_metastring_based_object_enabled_by_id($this->id, 'no', 'annotations'); + } + + /** + * Enable the annotation. + * + * @return bool + * @since 1.8 + */ + function enable() { + return elgg_set_metastring_based_object_enabled_by_id($this->id, 'yes', 'annotations'); } /** @@ -95,6 +128,6 @@ class ElggAnnotation extends ElggExtender { * @return ElggAnnotation */ public function getObjectFromID($id) { - return get_annotation($id); + return elgg_get_annotation_from_id($id); } -}
\ No newline at end of file +} |
