]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
use updateKeys() for updating the user
authorEvan Prodromou <evan@controlezvous.ca>
Sun, 22 Jun 2008 15:16:11 +0000 (11:16 -0400)
committerEvan Prodromou <evan@controlezvous.ca>
Sun, 22 Jun 2008 15:16:11 +0000 (11:16 -0400)
darcs-hash:20080622151611-34904-1d952df08b5247ab391bb76fd50d7b90498f0c96.gz

actions/confirmemail.php
actions/profilesettings.php
classes/User.php

index e69cc6fff8d2105c94cc71a1e3dc9bf640a1a8ed..72b42c2a7b4c1fcbafc46e26e18f5d3184c060fd 100644 (file)
@@ -51,11 +51,13 @@ class ConfirmemailAction extends Action {
         $cur->query('BEGIN');
                
         $orig_user = clone($cur);
+               
         $cur->email = $confirm_email->email;
-        $result = $cur->update($orig_user);
+        $result = $cur->updateKeys($orig_user);
                
         if (!$result) {
                        common_log_db_error($cur, 'UPDATE', __FILE__);
+            $this->server_error(_t('Couldn\'t update user.'));
             return;
         }
                
@@ -63,6 +65,7 @@ class ConfirmemailAction extends Action {
                
         if (!$result) {
                        common_log_db_error($confirm_email, 'DELETE', __FILE__);
+            $this->server_error(_t('Couldn\'t delete email confirmation.'));
             return;
         }
                
index 1b7c75d47991366b1997dc0a8459e7bca2777ce7..bca86a85f314fe93b4d0ff16bda67689fe5d3959 100644 (file)
@@ -113,20 +113,23 @@ class ProfilesettingsAction extends SettingsAction {
                assert(!is_null($user)); # should already be checked
 
                $user->query('BEGIN');
-               
-               $original = clone($user);
-
-               $user->nickname = $nickname;
 
-               $result = $user->update($original);
-               
-               if (!$result) {
-                       common_log_db_error($user, 'UPDATE', __FILE__);
-                       common_server_error(_t('Couldnt update user.'));
-                       return;
+               if ($user->nickname != $nickname) {
+                       
+                       $original = clone($user);
+                       
+                       $user->nickname = $nickname;
+                       
+                       $result = $user->updateKeys($original);
+                       
+                       if (!$result) {
+                               common_log_db_error($user, 'UPDATE', __FILE__);
+                               common_server_error(_t('Couldnt update user.'));
+                               return;
+                       }
                }
 
-               if ($email != $original->email) {
+               if ($email != $user->email) {
                        
                        $confirm = new Confirm_email();
                        $confirm->code = common_good_rand(16);
@@ -134,6 +137,7 @@ class ProfilesettingsAction extends SettingsAction {
                        $confirm->email = $email;
                        
                        $result = $confirm->insert();
+                       
                        if (!$result) {
                                common_log_db_error($confirm, 'INSERT', __FILE__);
                                common_server_error(_t('Couldnt confirm email.'));
index e8667d6975febd0fb51a087b82a8fdbfd686f3fc..94240392ed33438543a5b4990dc0ac6ccdeb071a 100644 (file)
@@ -68,12 +68,12 @@ class User extends DB_DataObject
                $parts = array();
                foreach (array('nickname', 'email') as $k) {
                        if ($this->$k != $orig->$k) {
-                               $parts[] = $k . '=' . $this->_quote($this->$k);
+                               $parts[] = $k . ' = ' . $this->_quote($this->$k);
                        }
                }
                if (count($parts) == 0) {
                        # No changes
-                       return;
+                       return true;
                }
                $toupdate = implode(', ', $parts);
                $qry = 'UPDATE ' . $this->tableName() . ' SET ' . $toupdate .