diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-03 15:54:45 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-04-03 15:54:45 +0000 |
commit | 54f7543b0445c40ee14dc9fbf5694f849a43c50c (patch) | |
tree | f62224d1556c9696789ef0bbb4b33b572b078568 | |
parent | 8a000372bdfed83edf4e62b284433b8c05bc47d5 (diff) | |
download | elgg-54f7543b0445c40ee14dc9fbf5694f849a43c50c.tar.gz elgg-54f7543b0445c40ee14dc9fbf5694f849a43c50c.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Annotations and metadata now imported
git-svn-id: https://code.elgg.org/elgg/trunk@393 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/entities.php | 7 | ||||
-rw-r--r-- | engine/lib/extender.php | 31 | ||||
-rw-r--r-- | engine/lib/metadata.php | 8 |
3 files changed, 29 insertions, 17 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 4b9473b7e..ad668591d 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -342,6 +342,7 @@ switch ($name) { + case 'owner_guid' : $this->attributes['owner_guid'] = $_SESSION['id']; break; case 'uuid' : $uuid = $text; break; default : $this->attributes[$name] = $text; } @@ -353,10 +354,10 @@ // See if this entity has already been imported, if so we don't need to create a new element $entity = get_entity_from_uuid($uuid); - if ($entity) + if ($entity) $this->attributes['guid'] = $entity->guid; - else - $this->attributes['guid'] = false; + else + $this->attributes['guid'] = false; // save $result = $this->save(); diff --git a/engine/lib/extender.php b/engine/lib/extender.php index f15aaa1ee..4f588acdd 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -75,6 +75,7 @@ $tmp = new stdClass; $tmp->attributes = $this->attributes; $tmp->attributes['owner_uuid'] = guid_to_uuid($this->owner_guid); + $tmp->attributes['entity_uuid'] = guid_to_uuid($this->entity_guid); return $tmp; } @@ -92,20 +93,30 @@ switch ($name) { + case 'id' : break; case 'entity_uuid' : $entity_uuid = $text; break; default : $this->attributes[$name] = $text; } - - // See if this entity has already been imported, if so then we need to link to it - $entity = get_entity_from_uuid($entity_uuid); - if (!$entity) - throw new ImportException("Sorry $entity_uuid was not found. Could not import annotation."); - - // Set owner ID - $this->attributes['owner_guid'] = $entity->getGUID(); - - return $this; + } + // See if this entity has already been imported, if so then we need to link to it + $entity = get_entity_from_uuid($entity_uuid); + if (!$entity) + throw new ImportException("Sorry $entity_uuid was not found. Could not import annotation."); + + // Set the item ID + $this->attributes['entity_guid'] = $entity->getGUID(); + + // Set owner + $this->attributes[$name] = $entity->getOwner(); + + // save + $result = $this->save(); + if (!$result) + throw new ImportException("There was a problem saving the ElggExtender"); + + return $this; + } else throw new ImportException("Unsupported version ($version) passed to ElggAnnotation::import()"); diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index f8a448f14..fe38e48c8 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -305,8 +305,8 @@ { global $CONFIG; - $meta_name = get_metastring_id($meta_name); - $meta_value = get_metastring_id($meta_value); + $meta_n = get_metastring_id($meta_name); + $meta_v = get_metastring_id($meta_value); $entity_type = sanitise_string($entity_type); $entity_subtype = get_subtype_id($entity_type, $entity_subtype); @@ -323,9 +323,9 @@ if ($entity_subtype) $where[] = "e.subtype=$entity_subtype"; if ($meta_name!="") - $where[] = "m.name_id='$meta_name'"; + $where[] = "m.name_id='$meta_n'"; if ($meta_value!="") - $where[] = "m.value_id='$meta_value'"; + $where[] = "m.value_id='$meta_v'"; $query = "SELECT * from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid where"; foreach ($where as $w) |