static function hasOpenID($user_id) { $oid = new User_openid(); $oid->user_id = $user_id; $cnt = $oid->find(); return $cnt > 0; }
/** * 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; }
/** * Show the form for OpenID management * * We have one form with a few different submit buttons to do different things. * * @return void */ function showContent() { $user = common_current_user(); if (!common_config('openid', 'trusted_provider')) { $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_openid_add', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset', array('id' => 'settings_openid_add')); // TRANS: Fieldset legend. $this->element('legend', null, _m('LEGEND', 'Add OpenID')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', _m('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), _m('OpenID URL')); $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); $this->elementEnd('li'); $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', 'id' => 'settings_openid_add_action-submit', 'name' => 'add', 'class' => 'submit', 'value' => _m('BUTTON', 'Add'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); } $oid = new User_openid(); $oid->user_id = $user->id; $cnt = $oid->find(); if ($cnt > 0) { // TRANS: Header on OpenID settings page. $this->element('h2', null, _m('HEADER', 'Remove OpenID')); if ($cnt == 1 && !$user->password) { $this->element('p', 'form_guide', _m('Removing your only OpenID ' . 'would make it impossible to log in! ' . 'If you need to remove it, ' . 'add another OpenID first.')); if ($oid->fetch()) { $this->elementStart('p'); $this->element('a', array('href' => $oid->canonical), $oid->display); $this->elementEnd('p'); } } else { $this->element('p', 'form_guide', _m('You can remove an OpenID from your account ' . 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { $this->elementStart('form', array('method' => 'POST', 'id' => 'form_settings_openid_delete' . $idx, 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), $oid->display); $this->element('input', array('type' => 'hidden', 'id' => 'openid_url' . $idx, 'name' => 'openid_url', 'value' => $oid->canonical)); $this->element('input', array('type' => 'submit', 'id' => 'remove' . $idx, 'name' => 'remove', 'class' => 'submit remove', 'value' => _m('BUTTON', 'Remove'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); $idx++; } } } $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_openid_trustroots', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset', array('id' => 'settings_openid_trustroots')); // TRANS: Fieldset legend. $this->element('legend', null, _m('OpenID Trusted Sites')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', _m('The following sites are allowed to access your ' . 'identity and log you in. You can remove a site from ' . 'this list to deny it access to your OpenID.')); $this->elementStart('ul', 'form_data'); $user_openid_trustroot = new User_openid_trustroot(); $user_openid_trustroot->user_id = $user->id; if ($user_openid_trustroot->find()) { while ($user_openid_trustroot->fetch()) { $this->elementStart('li'); $this->element('input', array('name' => 'openid_trustroot[]', 'type' => 'checkbox', 'class' => 'checkbox', 'value' => $user_openid_trustroot->trustroot, 'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot))); $this->element('label', array('class' => 'checkbox', 'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)), $user_openid_trustroot->trustroot); $this->elementEnd('li'); } } $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', 'id' => 'settings_openid_trustroots_action-submit', 'name' => 'remove_trustroots', 'class' => 'submit', 'value' => _m('BUTTON', 'Remove'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
/** * 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; }
/** * Show the form for OpenID management * * We have one form with a few different submit buttons to do different things. * * @return void */ function showContent() { if (!common_config('openid', 'trusted_provider')) { $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_openid_add', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset', array('id' => 'settings_openid_add')); // TRANS: Fieldset legend. $this->element('legend', null, _m('LEGEND', 'Add OpenID')); $this->hidden('token', common_session_token()); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); // TRANS: Field label. $this->input('openid_url', _m('OpenID URL'), null, _m('An OpenID URL which identifies you.'), null, true, array('placeholder' => 'https://example.com/you')); $this->elementEnd('li'); $this->elementEnd('ul'); // TRANS: Button text for adding an OpenID URL. $this->submit('settings_openid_add_action-submit', _m('BUTTON', 'Add'), 'submit', 'add'); $this->elementEnd('fieldset'); $this->elementEnd('form'); } $oid = new User_openid(); $oid->user_id = $this->scoped->getID(); $cnt = $oid->find(); if ($cnt > 0) { // TRANS: Header on OpenID settings page. $this->element('h2', null, _m('HEADER', 'Remove OpenID')); if ($cnt == 1 && !$this->scoped->hasPassword()) { $this->element('p', 'form_guide', _m('Removing your only OpenID ' . 'would make it impossible to log in! ' . 'If you need to remove it, ' . 'add another OpenID first.')); if ($oid->fetch()) { $this->elementStart('p'); $this->element('a', array('href' => $oid->canonical), $oid->display); $this->elementEnd('p'); } } else { $this->element('p', 'form_guide', _m('You can remove an OpenID from your account ' . 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { $this->elementStart('form', array('method' => 'POST', 'id' => 'form_settings_openid_delete' . $idx, 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), $oid->display); $this->hidden("openid_url{$idx}", $oid->canonical, 'openid_url'); // TRANS: Button text to remove an OpenID. $this->submit("remove{$idx}", _m('BUTTON', 'Remove'), 'submit remove', 'remove'); $this->elementEnd('fieldset'); $this->elementEnd('form'); $idx++; } } } $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_openid_trustroots', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset', array('id' => 'settings_openid_trustroots')); // TRANS: Fieldset legend. $this->element('legend', null, _m('OpenID Trusted Sites')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', _m('The following sites are allowed to access your ' . 'identity and log you in. You can remove a site from ' . 'this list to deny it access to your OpenID.')); $this->elementStart('ul', 'form_data'); $user_openid_trustroot = new User_openid_trustroot(); $user_openid_trustroot->user_id = $this->scoped->getID(); if ($user_openid_trustroot->find()) { while ($user_openid_trustroot->fetch()) { $this->elementStart('li'); $this->element('input', array('name' => 'openid_trustroot[]', 'type' => 'checkbox', 'class' => 'checkbox', 'value' => $user_openid_trustroot->trustroot, 'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot))); $this->element('label', array('class' => 'checkbox', 'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)), $user_openid_trustroot->trustroot); $this->elementEnd('li'); } } $this->elementEnd('ul'); // TRANS: Button text to remove an OpenID trustroot. $this->submit('settings_openid_trustroots_action-submit', _m('BUTTON', 'Remove'), 'submit', 'remove_trustroots'); $this->elementEnd('fieldset'); $prefs = User_openid_prefs::getKV('user_id', $this->scoped->getID()); $this->elementStart('fieldset'); $this->element('legend', null, _m('LEGEND', 'Preferences')); $this->elementStart('ul', 'form_data'); $this->checkbox('hide_profile_link', "Hide OpenID links from my profile", !empty($prefs) && $prefs->hide_profile_link); // TRANS: Button text to save OpenID prefs $this->submit('settings_openid_prefs_save', _m('BUTTON', 'Save'), 'submit', 'save_prefs'); $this->elementEnd('ul'); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
/** * Show the form for OpenID management * * We have one form with a few different submit buttons to do different things. * * @return void */ function showContent() { $user = common_current_user(); $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_openid_add', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset', array('id' => 'settings_openid_add')); $this->element('legend', null, _('Add OpenID')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); $this->elementEnd('li'); $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', 'id' => 'settings_openid_add_action-submit', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); $oid = new User_openid(); $oid->user_id = $user->id; $cnt = $oid->find(); if ($cnt > 0) { $this->element('h2', null, _('Remove OpenID')); if ($cnt == 1 && !$user->password) { $this->element('p', 'form_guide', _('Removing your only OpenID ' . 'would make it impossible to log in! ' . 'If you need to remove it, ' . 'add another OpenID first.')); if ($oid->fetch()) { $this->elementStart('p'); $this->element('a', array('href' => $oid->canonical), $oid->display); $this->elementEnd('p'); } } else { $this->element('p', 'form_guide', _('You can remove an OpenID from your account ' . 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { $this->elementStart('form', array('method' => 'POST', 'id' => 'form_settings_openid_delete' . $idx, 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), $oid->display); $this->element('input', array('type' => 'hidden', 'id' => 'openid_url' . $idx, 'name' => 'openid_url', 'value' => $oid->canonical)); $this->element('input', array('type' => 'submit', 'id' => 'remove' . $idx, 'name' => 'remove', 'class' => 'submit remove', 'value' => _('Remove'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); $idx++; } } } }
function hasOpenID() { $oid = new User_openid(); $oid->user_id = $this->id; $cnt = $oid->find(); return $cnt > 0; }