From ebf60cee33beae4464704ea099837cd521506928 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 7 Nov 2019 22:02:34 -0500 Subject: [PATCH] Enable meta groups in Model\Group::getIdsByContactId - Don't return early if contact isn't part of any group in PermissionSet::get --- src/Model/Group.php | 10 ++++++++++ src/Model/PermissionSet.php | 9 ++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Model/Group.php b/src/Model/Group.php index c38e78000b..199ff1ebd7 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -117,6 +117,16 @@ class Group } DBA::close($stmt); + // Meta-groups + $contact = Contact::getById($cid, ['rel']); + if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) { + $return[] = self::FOLLOWERS; + } + + if ($contact['rel'] == Contact::FRIEND) { + $return[] = self::MUTUALS; + } + return $return; } diff --git a/src/Model/PermissionSet.php b/src/Model/PermissionSet.php index de943c977c..fbcc1738d7 100644 --- a/src/Model/PermissionSet.php +++ b/src/Model/PermissionSet.php @@ -82,14 +82,9 @@ class PermissionSet $groups = Group::getIdsByContactId($contact_id); } - if (empty($groups) || !is_array($groups)) { - return []; - } - $group_str = '<<>>'; // should be impossible to match - - foreach ($groups as $g) { - $group_str .= '|<' . intval($g) . '>'; + foreach ($groups as $group_id) { + $group_str .= '|<' . preg_quote($group_id) . '>'; } $contact_str = '<' . $contact_id . '>';