X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Finvite.php;h=5dcc836526317e7b124dd4c03ea2bca6606cdb2f;hb=03d31911e18f8ca0ba2f8425943b4c244114a066;hp=879264deb99d7276217e803cac9fcdcf862d3ec1;hpb=0357ea505dd8aba293a67f0bfa122c3bbd29e51b;p=quix0rs-gnu-social.git diff --git a/actions/invite.php b/actions/invite.php index 879264deb9..5dcc836526 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -1,7 +1,7 @@ send_invitations(); + $this->sendInvitations(); } else { - $this->show_form(); + $this->showForm(); } } - function send_invitations() + function sendInvitations() { - # CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. Try again, please.')); return; } @@ -63,101 +67,132 @@ class InviteAction extends Action foreach ($addresses as $email) { $email = trim($email); if (!Validate::email($email, true)) { - $this->show_form(sprintf(_('Invalid email address: %s'), $email)); + $this->showForm(sprintf(_('Invalid email address: %s'), $email)); return; } } - $already = array(); - $subbed = array(); + $this->already = array(); + $this->subbed = array(); foreach ($addresses as $email) { $email = common_canonical_email($email); $other = User::staticGet('email', $email); if ($other) { if ($user->isSubscribed($other)) { - $already[] = $other; + $this->already[] = $other; } else { subs_subscribe_to($user, $other); - $subbed[] = $other; + $this->subbed[] = $other; } } else { - $sent[] = $email; - $this->send_invitation($email, $user, $personal); + $this->sent[] = $email; + $this->sendInvitation($email, $user, $personal); } } - common_show_header(_('Invitation(s) sent')); - if ($already) { + $this->mode = 'sent'; + + $this->showPage(); + } + + function title() + { + if ($this->mode == 'sent') { + return _('Invitation(s) sent'); + } else { + return _('Invite new users'); + } + } + + function showContent() + { + if ($this->mode == 'sent') { + $this->showInvitationSuccess(); + } else { + $this->showInviteForm(); + } + } + + function showInvitationSuccess() + { + if ($this->already) { $this->element('p', null, _('You are already subscribed to these users:')); $this->elementStart('ul'); - foreach ($already as $other) { + foreach ($this->already as $other) { $this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); } $this->elementEnd('ul'); } - if ($subbed) { + if ($this->subbed) { $this->element('p', null, _('These people are already users and you were automatically subscribed to them:')); $this->elementStart('ul'); - foreach ($subbed as $other) { + foreach ($this->subbed as $other) { $this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); } $this->elementEnd('ul'); } - if ($sent) { + if ($this->sent) { $this->element('p', null, _('Invitation(s) sent to the following people:')); $this->elementStart('ul'); - foreach ($sent as $other) { + foreach ($this->sent as $other) { $this->element('li', null, $other); } $this->elementEnd('ul'); $this->element('p', null, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!')); } - common_show_footer(); } - function show_top($error=null) + function showPageNotice() { - if ($error) { - $this->element('p', 'error', $error); - } else { - $this->elementStart('div', 'instructions'); - $this->element('p', null, - _('Use this form to invite your friends and colleagues to use this service.')); - $this->elementEnd('div'); + if ($this->mode != 'sent') { + if ($this->error) { + $this->element('p', 'error', $this->error); + } else { + $this->elementStart('div', 'instructions'); + $this->element('p', null, + _('Use this form to invite your friends and colleagues to use this service.')); + $this->elementEnd('div'); + } } } - function show_form($error=null) + function showForm($error=null) { + $this->mode = 'form'; + $this->error = $error; + $this->showPage(); + } - global $config; - - common_show_header(_('Invite new users'), null, $error, array($this, 'show_top')); - + function showInviteForm() + { $this->elementStart('form', array('method' => 'post', - 'id' => 'invite', + 'id' => 'form_invite', + 'class' => 'form_settings', 'action' => common_local_url('invite'))); + $this->elementStart('fieldset'); + $this->element('legend', null, 'Send an invitation'); $this->hidden('token', common_session_token()); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); $this->textarea('addresses', _('Email addresses'), $this->trimmed('addresses'), _('Addresses of friends to invite (one per line)')); - + $this->elementEnd('li'); + $this->elementStart('li'); $this->textarea('personal', _('Personal message'), $this->trimmed('personal'), _('Optionally add a personal message to the invitation.')); - + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('send', _('Send')); - + $this->elementEnd('fieldset'); $this->elementEnd('form'); - - common_show_footer(); } - function send_invitation($email, $user, $personal) + function sendInvitation($email, $user, $personal) { - $profile = $user->getProfile(); $bestname = $profile->getBestName(); @@ -203,4 +238,9 @@ class InviteAction extends Action mail_send($recipients, $headers, $body); } + function showLocalNav() + { + $nav = new SubGroupNav($this, common_current_user()); + $nav->show(); + } }