本文整理汇总了PHP中Invitation::staticGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Invitation::staticGet方法的具体用法?PHP Invitation::staticGet怎么用?PHP Invitation::staticGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invitation
的用法示例。
在下文中一共展示了Invitation::staticGet方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNewUser
function createNewUser()
{
# FIXME: save invite code before redirect, and check here
if (common_config('site', 'closed')) {
// TRANS: OpenID plugin message. No new user registration is allowed on the site.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = null;
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
// TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and none was provided.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
// TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and the one provided was not valid.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
}
$nickname = $this->trimmed('newname');
if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => NICKNAME_FMT))) {
// TRANS: OpenID plugin message. The entered new user name did not conform to the requirements.
$this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
}
if (!User::allowed_nickname($nickname)) {
// TRANS: OpenID plugin message. The entered new user name is blacklisted.
$this->showForm(_m('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
// TRANS: OpenID plugin message. The entered new user name is already used.
$this->showForm(_m('Nickname already in use. Try another one.'));
return;
}
list($display, $canonical, $sreg) = $this->getSavedValues();
if (!$display || !$canonical) {
// TRANS: OpenID plugin server error. A stored OpenID cannot be retrieved.
$this->serverError(_m('Stored OpenID not found.'));
return;
}
# Possible race condition... let's be paranoid
$other = oid_get_user($canonical);
if ($other) {
// TRANS: OpenID plugin server error.
$this->serverError(_m('Creating new account for OpenID that already has a user.'));
return;
}
Event::handle('StartOpenIDCreateNewUser', array($canonical, &$sreg));
$location = '';
if (!empty($sreg['country'])) {
if ($sreg['postcode']) {
# XXX: use postcode to get city and region
# XXX: also, store postcode somewhere -- it's valuable!
$location = $sreg['postcode'] . ', ' . $sreg['country'];
} else {
$location = $sreg['country'];
}
}
if (!empty($sreg['fullname']) && mb_strlen($sreg['fullname']) <= 255) {
$fullname = $sreg['fullname'];
} else {
$fullname = '';
}
if (!empty($sreg['email']) && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
$email = $sreg['email'];
} else {
$email = '';
}
# XXX: add language
# XXX: add timezone
$args = array('nickname' => $nickname, 'email' => $email, 'fullname' => $fullname, 'location' => $location);
if (!empty($invite)) {
$args['code'] = $invite->code;
}
$user = User::register($args);
$result = oid_link_user($user->id, $canonical, $display);
Event::handle('EndOpenIDCreateNewUser', array($user, $canonical, $sreg));
oid_set_last($display);
common_set_user($user);
common_real_login(true);
if (isset($_SESSION['openid_rememberme']) && $_SESSION['openid_rememberme']) {
common_rememberme($user);
}
unset($_SESSION['openid_rememberme']);
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
}
示例2: createNewUser
function createNewUser()
{
if (!Event::handle('StartRegistrationTry', array($this))) {
return;
}
if (common_config('site', 'closed')) {
// TRANS: Client error trying to register with registrations not allowed.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = null;
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
// TRANS: Client error trying to register with registrations 'invite only'.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
// TRANS: Client error trying to register with an invalid invitation code.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
}
try {
$nickname = Nickname::normalize($this->trimmed('newname'));
} catch (NicknameException $e) {
$this->showForm($e->getMessage());
return;
}
if (!User::allowed_nickname($nickname)) {
// TRANS: Form validation error displayed when picking a nickname that is not allowed.
$this->showForm(_m('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
// TRANS: Form validation error displayed when picking a nickname that is already in use.
$this->showForm(_m('Nickname already in use. Try another one.'));
return;
}
$args = array('nickname' => $nickname, 'fullname' => $this->fbuser->name, 'homepage' => $this->fbuser->website, 'location' => $this->fbuser->location->name);
// It's possible that the email address is already in our
// DB. It's a unique key, so we need to check
if ($this->isNewEmail($this->fbuser->email)) {
$args['email'] = $this->fbuser->email;
if (isset($this->fuser->verified) && $this->fuser->verified == true) {
$args['email_confirmed'] = true;
}
}
if (!empty($invite)) {
$args['code'] = $invite->code;
}
$user = User::register($args);
$result = $this->flinkUser($user->id, $this->fbuid);
if (!$result) {
// TRANS: Server error displayed when connecting to Facebook fails.
$this->serverError(_m('Error connecting user to Facebook.'));
return;
}
// Add a Foreign_user record
Facebookclient::addFacebookUser($this->fbuser);
$this->setAvatar($user);
common_set_user($user);
common_real_login(true);
common_log(LOG_INFO, sprintf('Registered new user %s (%d) from Facebook user %s, (fbuid %d)', $user->nickname, $user->id, $this->fbuser->name, $this->fbuid), __FILE__);
Event::handle('EndRegistrationTry', array($this));
$this->goHome($user->nickname);
}
示例3: showFormContent
/**
* Show the registration form
*
* @return void
*/
function showFormContent()
{
$code = $this->trimmed('code');
$invite = null;
if ($code) {
$invite = Invitation::staticGet($code);
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
$this->clientError(_('Sorry, only invited people can register.'));
return;
}
$this->elementStart('form', array('method' => 'post', 'id' => 'form_register', 'class' => 'form_settings', 'action' => common_local_url('register')));
$this->elementStart('fieldset');
$this->element('legend', null, 'Account settings');
$this->hidden('token', common_session_token());
if ($this->code) {
$this->hidden('code', $this->code);
}
$this->elementStart('ul', 'form_data');
if (Event::handle('StartRegistrationFormData', array($this))) {
$this->elementStart('li');
$this->input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, no punctuation or spaces.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('password', _('Password'), _('6 or more characters.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('confirm', _('Confirm'), _('Same as password above.'));
$this->elementEnd('li');
$this->elementStart('li');
if ($this->invite && $this->invite->address_type == 'email') {
$this->input('email', _('Email'), $this->invite->address, _('Used only for updates, announcements, ' . 'and password recovery.'));
} else {
$this->input('email', _('Email'), $this->trimmed('email'), _('Used only for updates, announcements, ' . 'and password recovery.'));
}
$this->elementEnd('li');
$this->elementStart('li');
$this->input('fullname', _('Full name'), $this->trimmed('fullname'), _('Longer name, preferably your "real" name.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->input('homepage', _('Homepage'), $this->trimmed('homepage'), _('URL of your homepage, blog, ' . 'or profile on another site.'));
$this->elementEnd('li');
$this->elementStart('li');
$maxBio = Profile::maxBio();
if ($maxBio > 0) {
// TRANS: Tooltip for field label in form for profile settings. Plural
// TRANS: is decided by the number of characters available for the
// TRANS: biography (%d).
$bioInstr = sprintf(_m('Describe yourself and your interests in %d character', 'Describe yourself and your interests in %d characters', $maxBio), $maxBio);
} else {
$bioInstr = _('Describe yourself and your interests');
}
$this->textarea('bio', _('Bio'), $this->trimmed('bio'), $bioInstr);
$this->elementEnd('li');
$this->elementStart('li');
$this->input('location', _('Location'), $this->trimmed('location'), _('Where you are, like "City, ' . 'State (or Region), Country".'));
$this->elementEnd('li');
Event::handle('EndRegistrationFormData', array($this));
$this->elementStart('li', array('id' => 'settings_rememberme'));
$this->checkbox('rememberme', _('Remember me'), $this->boolean('rememberme'), _('Automatically login in the future; ' . 'not for shared computers!'));
$this->elementEnd('li');
$attrs = array('type' => 'checkbox', 'id' => 'license', 'class' => 'checkbox', 'name' => 'license', 'value' => 'true');
if ($this->boolean('license')) {
$attrs['checked'] = 'checked';
}
$this->elementStart('li');
$this->element('input', $attrs);
$this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
$this->raw($this->licenseCheckbox());
$this->elementEnd('label');
$this->elementEnd('li');
}
$this->elementEnd('ul');
$this->submit('submit', _('Register'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
示例4: createNewUser
function createNewUser()
{
if (!Event::handle('StartRegistrationTry', array($this))) {
return;
}
if (common_config('site', 'closed')) {
// TRANS: Client error displayed when trying to create a new user while creating new users is not allowed.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = null;
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
// TRANS: Client error displayed when trying to create a new user while creating new users is not allowed.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
// TRANS: Client error displayed when trying to create a new user with an invalid invitation code.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
}
try {
$nickname = Nickname::normalize($this->trimmed('newname'));
} catch (NicknameException $e) {
$this->showForm($e->getMessage());
return;
}
if (!User::allowed_nickname($nickname)) {
// TRANS: Client error displayed when trying to create a new user with an invalid username.
$this->showForm(_m('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
// TRANS: Client error displayed when trying to create a new user with a username that is already in use.
$this->showForm(_m('Nickname already in use. Try another one.'));
return;
}
$fullname = trim($this->tw_fields['fullname']);
$args = array('nickname' => $nickname, 'fullname' => $fullname);
if (!empty($invite)) {
$args['code'] = $invite->code;
}
$email = $this->getEmail();
if (!empty($email)) {
$args['email'] = $email;
}
$user = User::register($args);
if (empty($user)) {
// TRANS: Server error displayed when creating a new user has failed.
$this->serverError(_m('Error registering user.'));
return;
}
$result = $this->saveForeignLink($user->id, $this->twuid, $this->access_token);
save_twitter_user($this->twuid, $this->tw_fields['screen_name']);
if (!$result) {
// TRANS: Server error displayed when connecting a user to a Twitter user has failed.
$this->serverError(_m('Error connecting user to Twitter.'));
return;
}
common_set_user($user);
common_real_login(true);
common_debug('TwitterBridge Plugin - ' . "Registered new user {$user->id} from Twitter user {$this->twuid}");
Event::handle('EndRegistrationTry', array($this));
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
}
示例5: register
/**
* Register a new user account and profile and set up default subscriptions.
* If a new-user welcome message is configured, this will be sent.
*
* @param array $fields associative array of optional properties
* string 'bio'
* string 'email'
* bool 'email_confirmed' pass true to mark email as pre-confirmed
* string 'fullname'
* string 'homepage'
* string 'location' informal string description of geolocation
* float 'lat' decimal latitude for geolocation
* float 'lon' decimal longitude for geolocation
* int 'location_id' geoname identifier
* int 'location_ns' geoname namespace to interpret location_id
* string 'nickname' REQUIRED
* string 'password' (may be missing for eg OpenID registrations)
* string 'code' invite code
* ?string 'uri' permalink to notice; defaults to local notice URL
* @return mixed User object or false on failure
*/
static function register($fields)
{
// MAGICALLY put fields into current scope
extract($fields);
$profile = new Profile();
if (!empty($email)) {
$email = common_canonical_email($email);
}
$nickname = common_canonical_nickname($nickname);
$profile->nickname = $nickname;
if (!User::allowed_nickname($nickname)) {
common_log(LOG_WARNING, sprintf("Attempted to register a nickname that is not allowed: %s", $profile->nickname), __FILE__);
return false;
}
$profile->profileurl = common_profile_url($nickname);
if (!empty($fullname)) {
$profile->fullname = $fullname;
}
if (!empty($homepage)) {
$profile->homepage = $homepage;
}
if (!empty($bio)) {
$profile->bio = $bio;
}
if (!empty($location)) {
$profile->location = $location;
$loc = Location::fromName($location);
if (!empty($loc)) {
$profile->lat = $loc->lat;
$profile->lon = $loc->lon;
$profile->location_id = $loc->location_id;
$profile->location_ns = $loc->location_ns;
}
}
$profile->created = common_sql_now();
$user = new User();
$user->nickname = $nickname;
// Users who respond to invite email have proven their ownership of that address
if (!empty($code)) {
$invite = Invitation::staticGet($code);
if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address;
}
}
if (isset($email_confirmed) && $email_confirmed) {
$user->email = $email;
}
// This flag is ignored but still set to 1
$user->inboxed = 1;
// Set default-on options here, otherwise they'll be disabled
// initially for sites using caching, since the initial encache
// doesn't know about the defaults in the database.
$user->emailnotifysub = 1;
$user->emailnotifyfav = 1;
$user->emailnotifynudge = 1;
$user->emailnotifymsg = 1;
$user->emailnotifyattn = 1;
$user->emailmicroid = 1;
$user->emailpost = 1;
$user->jabbermicroid = 1;
$user->viewdesigns = 1;
$user->created = common_sql_now();
if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
$profile->query('BEGIN');
$id = $profile->insert();
if (empty($id)) {
common_log_db_error($profile, 'INSERT', __FILE__);
return false;
}
$user->id = $id;
if (!empty($uri)) {
$user->uri = $uri;
} else {
$user->uri = common_user_uri($user);
}
if (!empty($password)) {
// may not have a password for OpenID users
$user->password = common_munge_password($password, $id);
}
//.........这里部分代码省略.........
示例6: createNewUser
function createNewUser()
{
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
return;
}
$invite = null;
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
$this->clientError(_('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
$this->clientError(_('Not a valid invitation code.'));
return;
}
}
$nickname = $this->trimmed('newname');
if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
$this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
}
if (!User::allowed_nickname($nickname)) {
$this->showForm(_('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
$this->showForm(_('Nickname already in use. Try another one.'));
return;
}
$fullname = trim($this->fb_fields['firstname'] . ' ' . $this->fb_fields['lastname']);
$args = array('nickname' => $nickname, 'fullname' => $fullname);
if (!empty($invite)) {
$args['code'] = $invite->code;
}
$user = User::register($args);
$result = $this->flinkUser($user->id, $this->fbuid);
if (!$result) {
$this->serverError(_('Error connecting user to Facebook.'));
return;
}
common_set_user($user);
common_real_login(true);
common_debug("Registered new user {$user->id} from Facebook user {$this->fbuid}");
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
}
示例7: createNewUser
function createNewUser()
{
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
return;
}
$invite = null;
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
$this->clientError(_('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
$this->clientError(_('Not a valid invitation code.'));
return;
}
}
$nickname = $this->trimmed('newname');
if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => NICKNAME_FMT))) {
$this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
}
if (!User::allowed_nickname($nickname)) {
$this->showForm(_('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
$this->showForm(_('Nickname already in use. Try another one.'));
return;
}
$fullname = trim($this->tw_fields['name']);
$args = array('nickname' => $nickname, 'fullname' => $fullname);
if (!empty($invite)) {
$args['code'] = $invite->code;
}
$user = User::register($args);
if (empty($user)) {
$this->serverError(_('Error registering user.'));
return;
}
$result = $this->saveForeignLink($user->id, $this->twuid, $this->access_token);
save_twitter_user($this->twuid, $this->tw_fields['screen_name']);
if (!$result) {
$this->serverError(_('Error connecting user to Twitter.'));
return;
}
common_set_user($user);
common_real_login(true);
common_debug('TwitterBridge Plugin - ' . "Registered new user {$user->id} from Twitter user {$this->twuid}");
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
}
示例8: showFormContent
/**
* Show the registration form
*
* @return void
*/
function showFormContent()
{
$code = $this->trimmed('code');
$invite = null;
if ($code) {
$invite = Invitation::staticGet($code);
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
// TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
$this->clientError(_('Sorry, only invited people can register.'));
return;
}
$this->elementStart('form', array('method' => 'post', 'id' => 'form_register', 'class' => 'form_settings', 'action' => common_local_url('register')));
$this->elementStart('fieldset');
// TRANS: Fieldset legend on accout registration page.
$this->element('legend', null, 'Account settings');
$this->hidden('token', common_session_token());
if ($this->code) {
$this->hidden('code', $this->code);
}
$this->elementStart('ul', 'form_data');
if (Event::handle('StartRegistrationFormData', array($this))) {
$this->elementStart('li');
// TRANS: Field label on account registration page.
$this->input('nickname', _('Nickname') . ' *', $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, no punctuation or spaces.'));
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label on account registration page.
$this->password('password', _('Password') . ' *', _('6 or more characters.'));
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label on account registration page. In this field the password has to be entered a second time.
$this->password('confirm', _('Confirm') . ' *', _('Same as password above.'));
$this->elementEnd('li');
$this->elementStart('li');
if ($this->invite && $this->invite->address_type == 'email') {
// TRANS: Field label on account registration page.
$this->input('email', _('Email') . ' *', $this->invite->address, _('Used only for updates, announcements, ' . 'and password recovery.'));
} else {
// TRANS: Field label on account registration page.
$this->input('email', _('Email') . ' *', $this->trimmed('email'), _('Used only for updates, announcements, ' . 'and password recovery.'));
}
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label on account registration page.
$this->input('fullname', _('Full name'), $this->trimmed('fullname'), _('Longer name, preferably your "real" name.'));
$this->elementEnd('li');
$this->elementStart('li', array('id' => 'phone'));
// TRANS: Field label on account registration page.
$this->input('phoneLbl', _('Phone'), $this->trimmed('phone'));
$this->elementEnd('li');
Event::handle('EndRegistrationFormData', array($this));
$attrs = array('type' => 'checkbox', 'id' => 'license', 'class' => 'checkbox', 'name' => 'license', 'value' => 'true');
if ($this->boolean('license')) {
$attrs['checked'] = 'checked';
}
$this->elementStart('li');
$this->element('input', $attrs);
$this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
$this->raw($this->licenseCheckbox());
$this->elementEnd('label');
$this->elementEnd('li');
// CAPTCHA
$this->elementStart('li');
$publickey = "6LfbNe0SAAAAAMcGjQh8HLN75YZ4Agckygg0bLcV";
$this->raw(recaptcha_get_html($publickey));
$this->elementEnd('li');
}
$this->elementEnd('ul');
// TRANS: Button text to register a user on account registration page.
$this->submit('submit', _('Registrarse'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
示例9: showFormContent
/**
* Show the registration form
*
* @return void
*/
function showFormContent()
{
$code = $this->trimmed('code');
if ($code) {
$invite = Invitation::staticGet($code);
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
$this->clientError(_('Sorry, only invited people can register.'));
return;
}
$this->elementStart('form', array('method' => 'post', 'id' => 'form_register', 'class' => 'form_settings', 'action' => common_local_url('register')));
$this->elementStart('fieldset');
$this->element('legend', null, 'Account settings');
$this->hidden('token', common_session_token());
if ($code) {
$this->hidden('code', $code);
}
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, ' . 'no punctuation or spaces. Required.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('password', _('Password'), _('6 or more characters. Required.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('confirm', _('Confirm'), _('Same as password above. Required.'));
$this->elementEnd('li');
$this->elementStart('li');
if ($invite && $invite->address_type == 'email') {
$this->input('email', _('Email'), $invite->address, _('Used only for updates, announcements, ' . 'and password recovery'));
} else {
$this->input('email', _('Email'), $this->trimmed('email'), _('Used only for updates, announcements, ' . 'and password recovery'));
}
$this->elementEnd('li');
$this->elementStart('li');
$this->input('fullname', _('Full name'), $this->trimmed('fullname'), _('Longer name, preferably your "real" name'));
$this->elementEnd('li');
$this->elementStart('li');
$this->input('homepage', _('Homepage'), $this->trimmed('homepage'), _('URL of your homepage, blog, ' . 'or profile on another site'));
$this->elementEnd('li');
$this->elementStart('li');
$this->textarea('bio', _('Bio'), $this->trimmed('bio'), _('Describe yourself and your ' . 'interests in 140 chars'));
$this->elementEnd('li');
$this->elementStart('li');
$this->input('location', _('Location'), $this->trimmed('location'), _('Where you are, like "City, ' . 'State (or Region), Country"'));
$this->elementEnd('li');
$this->elementStart('li', array('id' => 'settings_rememberme'));
$this->checkbox('rememberme', _('Remember me'), $this->boolean('rememberme'), _('Automatically login in the future; ' . 'not for shared computers!'));
$this->elementEnd('li');
$attrs = array('type' => 'checkbox', 'id' => 'license', 'class' => 'checkbox', 'name' => 'license', 'value' => 'true');
if ($this->boolean('license')) {
$attrs['checked'] = 'checked';
}
$this->elementStart('li');
$this->element('input', $attrs);
$this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
$this->text(_('My text and files are available under '));
$this->element('a', array('href' => common_config('license', 'url')), common_config('license', 'title'), _("Creative Commons Attribution 3.0"));
$this->text(_(' except this private data: password, ' . 'email address, IM address, and phone number.'));
$this->elementEnd('label');
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('submit', _('Register'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
示例10: prepare
function prepare($argarray)
{
parent::prepare($argarray);
if (common_config('site', 'closed')) {
// TRANS: Client exception trown when registration by e-mail is not allowed.
throw new ClientException(_m('Registration not allowed.'), 403);
}
if ($this->isPost()) {
$this->checkSessionToken();
$this->email = $this->trimmed('email');
if (!empty($this->email)) {
if (common_config('site', 'inviteonly')) {
// TRANS: Client exception trown when trying to register without an invitation.
throw new ClientException(_m('Sorry, only invited people can register.'), 403);
}
$this->email = common_canonical_email($this->email);
$this->state = self::NEWEMAIL;
} else {
$this->state = self::SETPASSWORD;
$this->code = $this->trimmed('code');
if (empty($this->code)) {
// TRANS: Client exception thrown when no confirmation code was provided.
throw new ClientException(_m('No confirmation code.'));
}
$this->invitation = Invitation::staticGet('code', $this->code);
if (!empty($this->invitation)) {
if (!empty($this->invitation->registered_user_id)) {
// TRANS: Client exception trown when using an invitation multiple times.
throw new ClientException(_m('Invitation already used.'), 403);
}
} else {
$this->confirmation = Confirm_address::staticGet('code', $this->code);
if (empty($this->confirmation)) {
// TRANS: Client exception thrown when given confirmation code was not issued.
throw new ClientException(_m('No such confirmation code.'), 403);
}
}
$this->password1 = $this->trimmed('password1');
$this->password2 = $this->trimmed('password2');
$this->tos = $this->boolean('tos');
}
} else {
// GET
$this->code = $this->trimmed('code');
if (empty($this->code)) {
if (common_config('site', 'inviteonly')) {
// TRANS: Client exception trown when trying to register without an invitation.
throw new ClientException(_m('Sorry, only invited people can register.'), 403);
}
$this->state = self::NEWREGISTER;
} else {
$this->invitation = Invitation::staticGet('code', $this->code);
if (!empty($this->invitation)) {
if (!empty($this->invitation->registered_user_id)) {
// TRANS: Client exception trown when using an invitation multiple times.
throw new ClientException(_m('Invitation already used.'), 403);
}
$this->state = self::CONFIRMINVITE;
} else {
$this->state = self::CONFIRMREGISTER;
$this->confirmation = Confirm_address::staticGet('code', $this->code);
if (empty($this->confirmation)) {
// TRANS: Client exception thrown when given confirmation code was not issued.
throw new ClientException(_m('No such confirmation code.'), 405);
}
}
}
}
return true;
}
示例11: register
static function register($fields)
{
# MAGICALLY put fields into current scope
extract($fields);
$profile = new Profile();
$profile->query('BEGIN');
$profile->nickname = $nickname;
$profile->profileurl = common_profile_url($nickname);
if (!empty($fullname)) {
$profile->fullname = $fullname;
}
if (!empty($homepage)) {
$profile->homepage = $homepage;
}
if (!empty($bio)) {
$profile->bio = $bio;
}
if (!empty($location)) {
$profile->location = $location;
}
$profile->created = common_sql_now();
$id = $profile->insert();
if (empty($id)) {
common_log_db_error($profile, 'INSERT', __FILE__);
return false;
}
$user = new User();
$user->id = $id;
$user->nickname = $nickname;
if (!empty($password)) {
# may not have a password for OpenID users
$user->password = common_munge_password($password, $id);
}
# Users who respond to invite email have proven their ownership of that address
if (!empty($code)) {
$invite = Invitation::staticGet($code);
if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address;
}
}
$inboxes = common_config('inboxes', 'enabled');
if ($inboxes === true || $inboxes == 'transitional') {
$user->inboxed = 1;
}
$user->created = common_sql_now();
$user->uri = common_user_uri($user);
$result = $user->insert();
if (!$result) {
common_log_db_error($user, 'INSERT', __FILE__);
return false;
}
# Everyone is subscribed to themself
$subscription = new Subscription();
$subscription->subscriber = $user->id;
$subscription->subscribed = $user->id;
$subscription->created = $user->created;
$result = $subscription->insert();
if (!$result) {
common_log_db_error($subscription, 'INSERT', __FILE__);
return false;
}
if (!empty($email) && !$user->email) {
$confirm = new Confirm_address();
$confirm->code = common_confirmation_code(128);
$confirm->user_id = $user->id;
$confirm->address = $email;
$confirm->address_type = 'email';
$result = $confirm->insert();
if (!$result) {
common_log_db_error($confirm, 'INSERT', __FILE__);
return false;
}
}
if (!empty($code) && $user->email) {
$user->emailChanged();
}
$profile->query('COMMIT');
if ($email && !$user->email) {
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
}
return $user;
}