X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FGroup.php;h=5699d2d30bf87d586477ec66b33e79520cc95bf2;hb=65c0418807d493d653938cc7051a07d6aa783f87;hp=eb1389d799e33d5c27d2d15f1264306ba0dd5cba;hpb=07ba1b200c67ce4e4104ff1902c901c0abe8b4f8;p=friendica.git diff --git a/src/Module/Group.php b/src/Module/Group.php index eb1389d799..5699d2d30b 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -19,7 +19,7 @@ require_once 'boot.php'; class Group extends BaseModule { - public static function post() + public static function post(array $parameters = []) { $a = self::getApp(); @@ -87,34 +87,28 @@ class Group extends BaseModule throw new \Exception(L10n::t('Unknown group.'), 404); } - $contact = DBA::selectFirst('contact', ['pending', 'blocked', 'deleted'], ['id' => $contact_id, 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['deleted'], ['id' => $contact_id, 'uid' => local_user()]); if (!DBA::isResult($contact)) { throw new \Exception(L10n::t('Contact not found.'), 404); } - if ($contact['pending']) { - throw new \Exception(L10n::t('Contact is unavailable.'), 400); - } - if ($contact['deleted']) { throw new \Exception(L10n::t('Contact is deleted.'), 410); } switch($command) { case 'add': - if ($contact['blocked']) { - throw new \Exception(L10n::t('Contact is blocked, unable to add it to a group.'), 400); - } - if (!Model\Group::addMember($group_id, $contact_id)) { throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500); } + $message = L10n::t('Contact successfully added to group.'); break; case 'remove': if (!Model\Group::removeMember($group_id, $contact_id)) { throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500); } + $message = L10n::t('Contact successfully removed from group.'); break; default: @@ -132,12 +126,12 @@ class Group extends BaseModule } } - public static function content() + public static function content(array $parameters = []) { $change = false; if (!local_user()) { - System::httpExit(403); + throw new \Friendica\Network\HTTPException\ForbiddenException(); } $a = self::getApp(); @@ -176,7 +170,9 @@ class Group extends BaseModule $nogroup = false; - if (($a->argc == 2) && ($a->argv[1] === 'none')) { + // @TODO: Replace with parameter from router + if (($a->argc == 2) && ($a->argv[1] === 'none') || + ($a->argc == 1) && ($a->argv[0] === 'nogroup')) { $id = -1; $nogroup = true; $group = [ @@ -276,7 +272,7 @@ class Group extends BaseModule } if (!isset($group)) { - System::httpExit(400); + throw new \Friendica\Network\HTTPException\BadRequestException(); } $groupeditor = [