X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Finvite.php;h=89b7e83bf6d19a32899e05db5fe2b32ac1439cb3;hb=a1098fa1532f0abe04d006f54326158c6d6590fb;hp=0e3a878f2eb49792bfd198e1db7e9e72b6304a81;hpb=8597856b56ca728a2473b67f7f14e1aa3234220c;p=quix0rs-gnu-social.git diff --git a/actions/invite.php b/actions/invite.php index 0e3a878f2e..89b7e83bf6 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!defined('GNUSOCIAL')) { exit(1); } // @todo XXX: Add documentation. -class InviteAction extends CurrentUserDesignAction +class InviteAction extends Action { var $mode = null; var $error = null; @@ -60,7 +60,6 @@ class InviteAction extends CurrentUserDesignAction function sendInvitations() { if (Event::handle('StartSendInvitations', array(&$this))) { - // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { @@ -112,15 +111,22 @@ class InviteAction extends CurrentUserDesignAction foreach ($addresses as $email) { $email = common_canonical_email($email); - $other = User::staticGet('email', $email); - if ($other) { + try { + // If this user is already registered, subscribe to it! + $other = Profile::getByEmail($email); if ($user->isSubscribed($other)) { $this->already[] = $other; } else { - subs_subscribe_to($user, $other); - $this->subbed[] = $other; + try { + Subscription::ensureStart($profile, $other); + $this->subbed[] = $other; + } catch (Exception $e) { + // subscription failed, but keep working + common_debug('Invitation-based subscription failed: '.$e->getMessage()); + } } - } else { + } catch (NoSuchUserException $e) { + // If email was not known, let's send an invite! $this->sent[] = $email; $this->sendInvitation($email, $user, $personal); } @@ -162,7 +168,6 @@ class InviteAction extends CurrentUserDesignAction function showInvitationSuccess() { if (Event::handle('StartShowInvitationSuccess', array($this))) { - if ($this->already) { // TRANS: Message displayed inviting users to use a StatusNet site while the inviting user // TRANS: is already subscribed to one or more users with the given e-mail address(es).