X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Finvite.php;h=b6e0ba8dd17dffb23151548219844316c90f29d1;hb=e8d1bb25469fe1ef0cbcb32c3022010997aca4b0;hp=75800aa8585430854c4dd92425cf4d62f32e4b02;hpb=7a9777df053a9007b5eaa71f5437584065b615a5;p=quix0rs-gnu-social.git diff --git a/actions/invite.php b/actions/invite.php index 75800aa858..b6e0ba8dd1 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -17,7 +17,7 @@ * 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 Action @@ -33,12 +33,12 @@ class InviteAction extends Action return; } - function isReadOnly($args) + function isReadOnly(array $args=array()) { return false; } - function handle($args) + function handle(array $args=array()) { parent::handle($args); if (!common_config('invite', 'enabled')) { @@ -74,6 +74,7 @@ class InviteAction extends Action $bestname = $profile->getBestName(); $sitename = common_config('site', 'name'); $personal = $this->trimmed('personal'); + $language = $this->trimmed('language'); $addresses = explode("\n", $this->trimmed('addresses')); foreach ($addresses as $email) { @@ -111,17 +112,24 @@ class InviteAction extends Action 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::start($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); + $this->sendInvitation($email, $user, $personal, $language); } } @@ -241,7 +249,7 @@ class InviteAction extends Action } } - function sendInvitation($email, $user, $personal) + function sendInvitation($email, $user, $personal, $language) { $profile = $user->getProfile(); $bestname = $profile->getBestName(); @@ -277,7 +285,7 @@ class InviteAction extends Action $title = (empty($personal)) ? 'invite' : 'invitepersonal'; // @todo FIXME: i18n issue. - $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths()); + $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths(), $language); $body = $inviteTemplate->toHTML(array('inviter' => $bestname, 'inviterurl' => $profile->profileurl,