aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/objects.php43
-rw-r--r--engine/lib/sites.php36
-rw-r--r--engine/lib/users.php42
3 files changed, 78 insertions, 43 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;
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index dbe6d13b1..1c75fdff6 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -253,19 +253,29 @@
if ($row)
{
// Exists and you have access to it
-
- // Delete any existing stuff
- delete_site_entity($guid);
-
- // Insert it
- $result = insert_data("INSERT into {$CONFIG->dbprefix}sites_entity (guid, name, description, url) values ($guid, '$name','$description','$url')");
- if ($result!==false) {
- get_entity($guid);
- if (trigger_event('create',$entity->type,$entity)) {
- return true;
- } else {
- delete_entity($guid);
- }
+ $result = update_data("UPDATE {$CONFIG->dbprefix}sites_entity set name='$name', description='$description', url='$url' 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}sites_entity (guid, name, description, url) values ($guid, '$name','$description','$url')");
+ if ($result!==false) {
+ $entity = get_entity($guid);
+ if (trigger_event('create',$entity->type,$entity)) {
+ return true;
+ } else {
+ delete_entity($guid);
+ }
+ }
}
}
diff --git a/engine/lib/users.php b/engine/lib/users.php
index ffa39570a..a4a9bded4 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -345,21 +345,33 @@
if ($row)
{
- // Exists and you have access to it
-
- // Delete any existing stuff
- delete_user_entity($guid);
-
- // Insert it
- $result = insert_data("INSERT into {$CONFIG->dbprefix}users_entity (guid, name, username, password, email, language, code) values ($guid, '$name', '$username', '$password', '$email', '$language', '$code')");
- if ($result!==false) {
- $entity = get_entity($guid);
- if (trigger_event('create',$entity->type,$entity)) {
- return true;
- } else {
- delete_entity($guid);
- }
- }
+ // Exists and you have access to it
+
+ $result = update_data("UPDATE {$CONFIG->dbprefix}users_entity set name='$name', username='$username', password='$password', email='$email', language='$language', code='$code' 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}users_entity (guid, name, username, password, email, language, code) values ($guid, '$name', '$username', '$password', '$email', '$language', '$code')");
+ if ($result!==false) {
+ $entity = get_entity($guid);
+ if (trigger_event('create',$entity->type,$entity)) {
+ return true;
+ } else {
+ delete_entity($guid);
+ }
+ }
+ }
+
}
return false;