aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-02 14:04:25 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-02 14:04:25 +0000
commite06d41575c5d9a00378e69355a3467143ac68456 (patch)
tree6ff77c9bbeb54275fda3c68902a99d1e6f374263 /engine/lib/users.php
parent8773409b24653623fdd590e8be6d64b52b4a33a5 (diff)
downloadelgg-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/users.php')
-rw-r--r--engine/lib/users.php42
1 files changed, 27 insertions, 15 deletions
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;