From b610d4e82d2d6fcb368493dd89ad7c6dde0a3ffd Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 24 Dec 2019 16:44:43 -0500 Subject: [PATCH 1/2] Remove group management restrictions on pending and blocked in Module\Group --- src/Module/Group.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Module/Group.php b/src/Module/Group.php index 4c7672c01a..5699d2d30b 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -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: From 6501acf0bcffaa07fc3c2abe165d271985ea47b9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 24 Dec 2019 16:45:08 -0500 Subject: [PATCH 2/2] Stop automatically remove newly blocked contacts from their groups --- src/Model/Contact.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 534c99d465..6c0436eea2 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -406,11 +406,6 @@ class Contact extends BaseObject } DBA::update('user-contact', ['blocked' => $blocked], ['cid' => $cdata['public'], 'uid' => $uid], true); - - if ($blocked) { - // Blocked contact can't be in any group - self::removeFromGroups($cid); - } } /**