$cur->smsemail = $carrier->toEmailAddress($cur->sms);
}
- $result = $cur->updateKeys($orig_user);
+ $result = $cur->updateWithKeys($orig_user);
if (!$result) {
common_log_db_error($cur, 'UPDATE', __FILE__);
$user->email = null;
- $result = $user->updateKeys($original);
+ $result = $user->updateWithKeys($original);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
$user->incomingemail = null;
$user->emailpost = 0;
- if (!$user->updateKeys($orig)) {
+ if (!$user->updateWithKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error removing incoming e-mail address.
$this->serverError(_('Could not update user record.'));
$user->incomingemail = mail_new_incoming_address();
$user->emailpost = 1;
- if (!$user->updateKeys($orig)) {
+ if (!$user->updateWithKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error adding incoming e-mail address.
$this->serverError(_('Could not update user record.'));
if (!$user->email) {
$orig = clone($user);
$user->email = $email;
- $result = $user->updateKeys($orig);
+ $result = $user->updateWithKeys($orig);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error displayed when updating a user's e-mail address in the database fails while recovering a password.
$user->carrier = null;
$user->smsemail = null;
- $result = $user->updateKeys($original);
+ $result = $user->updateWithKeys($original);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error thrown on database error removing a registered SMS phone number.
$user->incomingemail = null;
- if (!$user->updateKeys($orig)) {
+ if (!$user->updateWithKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error displayed when the user could not be updated in SMS settings.
$this->serverError(_('Could not update user record.'));
$user->incomingemail = mail_new_incoming_address();
- if (!$user->updateKeys($orig)) {
+ if (!$user->updateWithKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
// TRANS: Server error displayed when the user could not be updated in SMS settings.
$this->serverError(_('Could not update user record.'));
}
// 'update' won't write key columns, so we have to do it ourselves.
- public function updateKeys(&$orig)
+ // This also automatically calls "update" _before_ it sets the keys.
+ public function updateWithKeys(&$orig)
{
if (!$orig instanceof $this) {
throw new ServerException('Tried updating a DataObject with a different class than itself.');
}
- $this->_connect();
+ // Update non-keys first, if necessary.
+ $this->update($orig);
+
$parts = array();
foreach ($this->keys() as $k) {
if (strcmp($this->$k, $orig->$k) != 0) {
common_debug("Updating User ({$this->id}) nickname from {$dataObject->nickname} to {$this->nickname}");
$origuser = clone($local);
$local->nickname = $this->nickname;
- $result = $local->updateKeys($origuser);
+ $result = $local->updateWithKeys($origuser);
if ($result === false) {
common_log_db_error($local, 'UPDATE', __FILE__);
// TRANS: Server error thrown when user profile settings could not be updated.
$this->user->email = $this->confirm->address;
- $this->user->updateKeys($orig);
+ $this->user->updateWithKeys($orig);
$this->user->emailChanged();
} else {
$original = clone($user);
$user->jabber = null;
- $result = $user->updateKeys($original);
+ $result = $user->updateWithKeys($original);
}
echo "\n";
} else if (!$user) {
$user->email = $email;
- if (!$user->updateKeys($orig)) {
+ if (!$user->updateWithKeys($orig)) {
print "Failed!\n";
throw new Exception("Can't update email address.");
}