X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FInvite.php;h=1ce9700697c6ae7e67b64fa44f1d2dbe9db24028;hb=6dbbd081795fa1c8fe57db2248ac162efeeada88;hp=fc8b4abf90671fdd99b4e4a78d95605750939ffb;hpb=3f57e16a1a49326a0c13a88a10c7a6bfb87c4878;p=friendica.git diff --git a/src/Module/Invite.php b/src/Module/Invite.php index fc8b4abf90..1ce9700697 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Module; @@ -6,6 +25,7 @@ use Friendica\BaseModule; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model; +use Friendica\Model\User; use Friendica\Network\HTTPException; use Friendica\Protocol\Email; use Friendica\Util\Strings; @@ -15,7 +35,7 @@ use Friendica\Util\Strings; */ class Invite extends BaseModule { - public static function post(array $parameters = []) + protected function post(array $request = []) { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -38,7 +58,7 @@ class Invite extends BaseModule $recipients = !empty($_POST['recipients']) ? explode("\n", $_POST['recipients']) : []; - $message = !empty($_POST['message']) ? Strings::escapeTags(trim($_POST['message'])) : ''; + $message = !empty($_POST['message']) ? Strings::escapeHtml(trim($_POST['message'])) : ''; $total = 0; $invitation_only = false; @@ -47,24 +67,26 @@ class Invite extends BaseModule if ($config->get('system', 'invitation_only')) { $invitation_only = true; $invites_remaining = DI::pConfig()->get(local_user(), 'system', 'invites_remaining'); - if ((!$invites_remaining) && (!is_site_admin())) { + if ((!$invites_remaining) && (!$app->isSiteAdmin())) { throw new HTTPException\ForbiddenException(); } } + $user = User::getById(local_user()); + foreach ($recipients as $recipient) { $recipient = trim($recipient); if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) { - notice(DI::l10n()->t('%s : Not a valid email address.', $recipient) . EOL); + notice(DI::l10n()->t('%s : Not a valid email address.', $recipient)); continue; } - if ($invitation_only && ($invites_remaining || is_site_admin())) { + if ($invitation_only && ($invites_remaining || $app->isSiteAdmin())) { $code = Model\Register::createForInvitation(); $nmessage = str_replace('$invite_code', $code, $message); - if (!is_site_admin()) { + if (!$app->isSiteAdmin()) { $invites_remaining--; if ($invites_remaining >= 0) { DI::pConfig()->set(local_user(), 'system', 'invites_remaining', $invites_remaining); @@ -76,8 +98,7 @@ class Invite extends BaseModule $nmessage = $message; } - $additional_headers = 'From: ' . $app->user['email'] . "\n" - . 'Sender: ' . DI::emailer()->getSiteEmailAddress() . "\n" + $additional_headers = 'From: "' . $user['email'] . '" <' . DI::emailer()->getSiteEmailAddress() . ">\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit'; @@ -92,18 +113,18 @@ class Invite extends BaseModule $current_invites++; DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites); if ($current_invites > $max_invites) { - notice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.') . EOL); + notice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.')); return; } } else { - notice(DI::l10n()->t('%s : Message delivery failed.', $recipient) . EOL); + notice(DI::l10n()->t('%s : Message delivery failed.', $recipient)); } } - notice(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total) . EOL); + info(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total)); } - public static function content(array $parameters = []) + protected function content(array $request = []): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -117,7 +138,7 @@ class Invite extends BaseModule if ($config->get('system', 'invitation_only')) { $inviteOnly = true; $x = DI::pConfig()->get(local_user(), 'system', 'invites_remaining'); - if ((!$x) && (!is_site_admin())) { + if ((!$x) && (!$app->isSiteAdmin())) { throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available')); } } @@ -150,7 +171,7 @@ class Invite extends BaseModule DI::l10n()->t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" . $linkTxt . "\r\n" . "\r\n" . (($inviteOnly) ? DI::l10n()->t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . DI::l10n()->t('Once you have registered, please connect with me via my profile page at:') - . "\r\n" . "\r\n" . DI::baseUrl()->get() . '/profile/' . $app->user['nickname'] + . "\r\n" . "\r\n" . DI::baseUrl()->get() . '/profile/' . $app->getLoggedInUserNickname() . "\r\n" . "\r\n" . DI::l10n()->t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n", ], '$submit' => DI::l10n()->t('Submit')