diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-02 14:04:25 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-02 14:04:25 +0000 |
commit | e06d41575c5d9a00378e69355a3467143ac68456 (patch) | |
tree | 6ff77c9bbeb54275fda3c68902a99d1e6f374263 /engine/lib/objects.php | |
parent | 8773409b24653623fdd590e8be6d64b52b4a33a5 (diff) | |
download | elgg-e06d41575c5d9a00378e69355a3467143ac68456.tar.gz elgg-e06d41575c5d9a00378e69355a3467143ac68456.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Update and creates now handled separately, with the appropriate events triggered.
git-svn-id: https://code.elgg.org/elgg/trunk@772 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/objects.php')
-rw-r--r-- | engine/lib/objects.php | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/engine/lib/objects.php b/engine/lib/objects.php index e44a005ff..b14e984c0 100644 --- a/engine/lib/objects.php +++ b/engine/lib/objects.php @@ -217,22 +217,35 @@ $row = get_entity_as_row($guid);
if ($row)
- {
- // Exists and you have access to it
-
- // Delete any existing stuff
- delete_object_entity($guid);
-
- // Insert it
- $result = insert_data("INSERT into {$CONFIG->dbprefix}objects_entity (guid, title, description) values ($guid, '$title','$description')");
- if ($result!==false) {
- $entity = get_entity($guid);
- if (trigger_event('create',$entity->type,$entity)) {
- return true;
- } else {
- delete_entity($guid);
- }
+ { + // Core entities row exists and we have access to it + + $result = update_data("UPDATE {$CONFIG->dbprefix}objects_entity set title='$title', description='$description' where guid=$guid"); + if ($result!=false) + { + // Update succeeded, continue + $entity = get_entity($guid); + if (trigger_event('update',$entity->type,$entity)) { + return true; + } else { + delete_entity($guid); + } + } + else + { + + // Update failed, attempt an insert. + $result = insert_data("INSERT into {$CONFIG->dbprefix}objects_entity (guid, title, description) values ($guid, '$title','$description')"); + if ($result!==false) { + $entity = get_entity($guid); + if (trigger_event('create',$entity->type,$entity)) { + return true; + } else { + delete_entity($guid); + } + } }
+
}
return false;
|