static function hasOpenID($user_id) { $oid = new User_openid(); $oid->user_id = $user_id; $cnt = $oid->find(); return $cnt > 0; }
function oid_get_user($openid_url) { $user = null; $oid = User_openid::staticGet('canonical', $openid_url); if ($oid) { $user = User::staticGet('id', $oid->user_id); } return $user; }
/** * Redirect to OpenID login if they have an OpenID * * @param Action $action Action being executed * @param User $user User doing the action * * @return boolean whether to continue */ function onRedirectToLogin($action, $user) { if ($this->openidOnly || !empty($user) && User_openid::hasOpenID($user->id)) { common_redirect(common_local_url('openidlogin'), 303); return false; } return true; }
/** * Override for RequireValidatedEmail plugin. If we have a user who's * not validated an e-mail, but did come from a trusted provider, * we'll consider them ok. * * @param User $user User to check * * @return bool true if user has a trusted OpenID. */ function hasTrustedOpenID($user) { if ($this->trustedOpenIDs && class_exists('User_openid')) { foreach ($this->trustedOpenIDs as $regex) { $oid = new User_openid(); $oid->user_id = $user->id; $oid->find(); while ($oid->fetch()) { if (preg_match($regex, $oid->canonical)) { return true; } } } } return false; }
/** * Handles a request to remove an OpenID from the user's account * * Validates input and, if everything is OK, deletes the OpenID. * Reloads the form with a success or error notification. * * @return void */ function removeOpenid() { $openid_url = $this->trimmed('openid_url'); $oid = User_openid::staticGet('canonical', $openid_url); if (!$oid) { // TRANS: Form validation error for a non-existing OpenID. $this->showForm(_m('No such OpenID.')); return; } $cur = common_current_user(); if (!$cur || $oid->user_id != $cur->id) { // TRANS: Form validation error if OpenID is connected to another user. $this->showForm(_m('That OpenID does not belong to you.')); return; } $oid->delete(); // TRANS: Success message after removing an OpenID. $this->showForm(_m('OpenID removed.'), true); return; }
/** * Handles a request to remove an OpenID from the user's account * * Validates input and, if everything is OK, deletes the OpenID. * Reloads the form with a success or error notification. * * @return void */ function removeOpenid() { $openid_url = $this->trimmed('openid_url'); $oid = User_openid::staticGet('canonical', $openid_url); if (!$oid) { $this->showForm(_m('No such OpenID.')); return; } $cur = common_current_user(); if (!$cur || $oid->user_id != $cur->id) { $this->showForm(_m('That OpenID does not belong to you.')); return; } $oid->delete(); $this->showForm(_m('OpenID removed.'), true); return; }
/** * Redirect to OpenID login if they have an OpenID * * @param Action $action Action being executed * @param User $user User doing the action * * @return boolean whether to continue */ function onRedirectToLogin($action, $user) { if (common_config('site', 'openid_only') || !empty($user) && User_openid::hasOpenID($user->id)) { common_redirect(common_local_url('openidlogin'), 303); return false; } return true; }
/** * Add links in the user's profile block to their OpenID URLs. * * @param Profile $profile The profile being shown * @param Array &$links Writeable array of arrays (href, text, image). * * @return boolean hook value (true) */ function onOtherAccountProfiles($profile, &$links) { $prefs = User_openid_prefs::getKV('user_id', $profile->id); if (empty($prefs) || !$prefs->hide_profile_link) { $oid = new User_openid(); $oid->user_id = $profile->id; if ($oid->find()) { while ($oid->fetch()) { $links[] = array('href' => $oid->display, 'text' => _('OpenID'), 'image' => $this->path("icons/openid-16x16.gif")); } } } return true; }
/** * Handles a request to remove an OpenID from the user's account * * Validates input and, if everything is OK, deletes the OpenID. * Reloads the form with a success or error notification. * * @return void */ function removeOpenid() { $oid = User_openid::getKV('canonical', $this->trimmed('openid_url')); if (!$oid instanceof User_openid) { // TRANS: Form validation error for a non-existing OpenID. throw new ClientException(_m('No such OpenID.')); } if ($this->scoped->getID() !== $oid->user_id) { // TRANS: Form validation error if OpenID is connected to another user. throw new ClientException(_m('That OpenID does not belong to you.')); } $oid->delete(); // TRANS: Success message after removing an OpenID. return _m('OpenID removed.'); }
function hasOpenID() { $oid = new User_openid(); $oid->user_id = $this->id; $cnt = $oid->find(); return $cnt > 0; }