]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #3238 #3246 anootations needed the same fixes as metadata
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 19:09:28 +0000 (19:09 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 19:09:28 +0000 (19:09 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8852 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggAnnotation.php
engine/classes/ElggMetadata.php
engine/lib/annotations.php

index 30d9c4245f2dbcaf19134c05063828bd94f64a2f..78d29ee7f7efb22dfec7ebde2b32aa5a75abb1d7 100644 (file)
@@ -28,26 +28,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 = elgg_get_annotation_from_id($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;
                        }
                }
        }
index 135c170281393985b0e14f42ef0a479696cab34d..ed3f8614fde3b85bd6bdf605bac0194578df3ce2 100644 (file)
@@ -16,9 +16,9 @@ class ElggMetadata extends ElggExtender {
        }
 
        /**
-        * Construct a new site object, optionally from a given id value or row.
+        * Construct a metadata object
         *
-        * @param mixed $id ID of metadata from DB
+        * @param mixed $id ID of metadata or a database row as stdClass object
         *
         * @return void
         */
index 0e446c94984f628da85d7df622f487d727b78b3a..1178a079f23e58489b921b88436944c8647619d0 100644 (file)
@@ -158,8 +158,8 @@ function update_annotation($annotation_id, $name, $value, $value_type, $owner_gu
 
        // If ok then add it
        $result = update_data("UPDATE {$CONFIG->dbprefix}annotations
-               set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid
-               where id=$annotation_id and name_id='$name' and $access");
+               set name_id='$name', value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid
+               where id=$annotation_id and $access");
 
        if ($result !== false) {
                $obj = elgg_get_annotation_from_id($annotation_id);