aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/annotations.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/annotations.php')
-rw-r--r--engine/lib/annotations.php88
1 files changed, 18 insertions, 70 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index b0e01ad31..26664757a 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -11,18 +11,15 @@
* @link http://elgg.org/
*/
+ require_once('extender.php'); // include the superclass
+
/**
* @class ElggAnnotation
* An annotation is similar to metadata each entity can contain more than one of each annotation.
* @author Marcus Povey <marcus@dushka.co.uk>
*/
- class ElggAnnotation implements Exportable
+ class ElggAnnotation extends ElggExtender
{
- /**
- * This contains the site's main properties (id, etc)
- * @var array
- */
- private $attributes;
/**
* Construct a new site object, optionally from a given id value or db row.
@@ -49,40 +46,11 @@
}
function __get($name) {
- if (isset($this->attributes[$name])) {
-
- // Sanitise outputs if required
- if ($name=='value')
- {
- switch ($this->attributes['value_type'])
- {
- case 'integer' : return (int)$this->attributes['value'];
- case 'tag' :
- case 'text' :
- case 'file' : return sanitise_string($this->attributes['value']);
-
- default : throw new InstallationException("Type {$this->attributes['value_type']} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.");
- }
- }
-
- return $this->attributes[$name];
- }
- return null;
+ return $this->get($name);
}
function __set($name, $value) {
- $this->attributes[$name] = $value;
- return true;
- }
-
- /**
- * Return the owner of this annotation.
- *
- * @return mixed
- */
- function getOwner()
- {
- return get_user($this->owner_guid);
+ return $this->set($name, $value);
}
function save()
@@ -104,14 +72,7 @@
{
return delete_annotation($this->id);
}
-
- public function export()
- {
- $tmp = new stdClass;
- $tmp->attributes = $this->attributes;
- $tmp->attributes['owner_uuid'] = guid_to_uuid($this->owner_guid);
- return $tmp;
- }
+
}
/**
@@ -452,42 +413,29 @@
/**
* Handler called by trigger_plugin_hook on the "export" event.
*/
- function export_annotations_plugin_hook($hook, $entity_type, $returnvalue, $params)
+ function export_annotation_plugin_hook($hook, $entity_type, $returnvalue, $params)
{
- global $CONFIG;
-
// Sanity check values
if ((!is_array($params)) && (!isset($params['guid'])))
throw new InvalidParameterException("GUID has not been specified during export, this should never happen.");
if (!is_array($returnvalue))
throw new InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
-
- $guid = (int)$params['guid'];
- $access = get_access_list();
- $where = array();
-
- if ($guid != 0)
- $where[] = "a.entity_guid=$guid";
-
- $query = "SELECT a.*, n.string as name, v.string as value from {$CONFIG->dbprefix}annotations a JOIN {$CONFIG->dbprefix}entities e on a.entity_guid = e.guid JOIN {$CONFIG->dbprefix}metastrings v on a.value_id=v.id JOIN {$CONFIG->dbprefix}metastrings n on a.name_id = n.id where ";
- foreach ($where as $w)
- $query .= " $w and ";
- $query .= " (a.access_id in {$access} or (a.access_id = 0 and a.owner_guid = {$_SESSION['id']}))"; // Add access controls
- $query .= " order by a.time_created"; // Add order and limit
- error_log($query);
- $annotations = get_data($query, "row_to_elggannotation");
+ $guid = (int)$params['guid'];
+ $name = $params['name'];
- if ($annotations)
+ $result = get_annotations($guid);
+
+ if ($result)
{
- foreach ($annotations as $a)
- $returnvalue[] = $a;
- }
-
+ foreach ($result as $r)
+ $returnvalue[] = $r;
+ }
+
return $returnvalue;
}
- /** Register the hook, ensuring entities are serialised first */
- register_plugin_hook("export", "all", "export_annotations_plugin_hook", 2);
+ /** Register the hook */
+ register_plugin_hook("export", "all", "export_annotation_plugin_hook", 2);
?> \ No newline at end of file