use query method to do some transactions
darcs-hash:20080619033619-84dde-e4fcc00f5d86cb0d11feff5f88f719ea72d3318e.gz
This commit is contained in:
parent
4aedce6864
commit
7258969cd4
@ -57,7 +57,21 @@ class FinishaddopenidAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cur =& common_current_user();
|
$cur =& common_current_user();
|
||||||
common_debug('cur = ' .print_r($cur, TRUE), __FILE__);
|
$other = $this->get_user($canonical);
|
||||||
|
|
||||||
|
if ($other) {
|
||||||
|
if ($other->id == $cur->id) {
|
||||||
|
$this->message(_t('You already have this OpenID!'));
|
||||||
|
} else {
|
||||||
|
$this->message(_t('Someone else already has this OpenID.'));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# start a transaction
|
||||||
|
|
||||||
|
$cur->query('BEGIN');
|
||||||
|
|
||||||
$result = oid_link_user($cur->id, $display, $canonical);
|
$result = oid_link_user($cur->id, $display, $canonical);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -70,7 +84,11 @@ class FinishaddopenidAction extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# success!
|
# success!
|
||||||
|
|
||||||
|
$cur->query('COMMIT');
|
||||||
|
|
||||||
common_redirect(common_local_url('openidsettings'));
|
common_redirect(common_local_url('openidsettings'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,16 +112,13 @@ class ProfilesettingsAction extends SettingsAction {
|
|||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
assert(!is_null($user)); # should already be checked
|
assert(!is_null($user)); # should already be checked
|
||||||
|
|
||||||
# FIXME: transaction!
|
$user->query('BEGIN');
|
||||||
|
|
||||||
$original = clone($user);
|
$original = clone($user);
|
||||||
|
|
||||||
$user->nickname = $nickname;
|
$user->nickname = $nickname;
|
||||||
$user->email = $email;
|
$user->email = $email;
|
||||||
|
|
||||||
common_debug('Updating, nickname ="'.$user->nickname.'" and email ="'.$user->email.'"');
|
|
||||||
common_debug('Original, nickname ="'.$original->nickname.'" and email ="'.$original->email.'"');
|
|
||||||
|
|
||||||
$result = $user->update($original);
|
$result = $user->update($original);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -57,10 +57,6 @@ function oid_link_user($id, $canonical, $display) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
# For some reason, autocommit is turned off
|
|
||||||
|
|
||||||
$oid->query('COMMIT');
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user