]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Invite.php
Use rawContent for Special Options to avoid a protected options() method
[friendica.git] / src / Module / Invite.php
index 82b8c604a900939319dd5a718a8ee8c493b4ae0c..1ce9700697c6ae7e67b64fa44f1d2dbe9db24028 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -35,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.'));
@@ -58,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;
@@ -67,7 +67,7 @@ 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();
                        }
                }
@@ -82,11 +82,11 @@ class Invite extends BaseModule
                                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);
@@ -124,7 +124,7 @@ class Invite extends BaseModule
                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.'));
@@ -138,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'));
                        }
                }