$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;
}
if (!$result) {
common_log_db_error($confirm_email, 'DELETE', __FILE__);
+ $this->server_error(_t('Couldn\'t delete email confirmation.'));
return;
}
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);
$confirm->email = $email;
$result = $confirm->insert();
+
if (!$result) {
common_log_db_error($confirm, 'INSERT', __FILE__);
common_server_error(_t('Couldnt confirm email.'));
$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 .