+ /**
+ * Returns the ACL list of contacts for a given user id
+ *
+ * @param int $user_id
+ * @return array
+ * @throws \Exception
+ */
+ public static function getContactListByUserId(int $user_id)
+ {
+ $fields = ['id', 'name', 'addr', 'micro'];
+ $params = ['order' => ['name']];
+ $acl_contacts = Contact::selectToArray($fields,
+ ['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false,
+ 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]], $params
+ );
+
+ $acl_forums = Contact::selectToArray($fields,
+ ['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false,
+ 'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params
+ );
+
+ $acl_contacts = array_merge($acl_forums, $acl_contacts);
+
+ array_walk($acl_contacts, function (&$value) {
+ $value['type'] = 'contact';
+ });
+
+ return $acl_contacts;
+ }
+
+ /**
+ * Returns the ACL list of groups (including meta-groups) for a given user id
+ *
+ * @param int $user_id
+ * @return array
+ */
+ public static function getGroupListByUserId(int $user_id)
+ {
+ $acl_groups = [
+ [
+ 'id' => Group::FOLLOWERS,
+ 'name' => L10n::t('Followers'),
+ 'addr' => '',
+ 'micro' => 'images/twopeople.png',
+ 'type' => 'group',
+ ],
+ [
+ 'id' => Group::MUTUALS,
+ 'name' => L10n::t('Mutuals'),
+ 'addr' => '',
+ 'micro' => 'images/twopeople.png',
+ 'type' => 'group',
+ ]
+ ];
+ foreach (Group::getByUserId($user_id) as $group) {
+ $acl_groups[] = [
+ 'id' => $group['id'],
+ 'name' => $group['name'],
+ 'addr' => '',
+ 'micro' => 'images/twopeople.png',
+ 'type' => 'group',
+ ];
+ }
+
+ return $acl_groups;
+ }
+