$sreg = $sreg_resp->contents();
}
- $user = $this->get_user($canonical);
+ $other = $this->get_user($canonical);
- if ($user) {
+ if ($other) {
$this->message(_t('This OpenID is already associated with user "') . $user->nickname . _t('"'));
} else {
- $user = common_current_user();
- if (!$this->connect_user($user, $display, $canonical)) {
+ $cur = common_current_user();
+ $result = oid_link_user($cur->id, $display, $canonical);
+ if (!$result) {
$this->message(_t('Error connecting user'));
return;
}
if ($sreg) {
- if (!$this->update_user($user, $sreg)) {
+ if (!$this->update_user($cur, $sreg)) {
$this->message(_t('Error updating profile'));
return;
}
return true;
}
-
- function connect_user($user, $display, $canonical) {
-
- $oid = new User_openid();
- $oid->display = $display;
- $oid->canonical = $canonical;
- $oid->user_id = $user->id;
- $oid->created = DB_DataObject_Cast::dateTime();
-
- common_debug('Saving ' . print_r($oid, TRUE), __FILE__);
-
- if (!$oid->insert()) {
- return false;
- }
- }
}