X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FInvite.php;h=1ce9700697c6ae7e67b64fa44f1d2dbe9db24028;hb=d4f97f8a4be8e2e1b1eceaa552f382c0a2528403;hp=98668bf71da02777e7d56aa93db8e29ca3cd8ffa;hpb=8293d5ed0af78ae6cc5629bb1f982a7b29794d32;p=friendica.git diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 98668bf71d..1ce9700697 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -1,6 +1,6 @@ t('Permission denied.')); @@ -57,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; @@ -66,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); @@ -95,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'; @@ -111,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.')); @@ -136,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')); } } @@ -169,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')