/** * Get the subscriptions for this user for a specific feed/group */ private function getSubscriptions($userId, $feed, $forChildren = true) { $subscribedFeeds = $this->portal->getSubscriptions($userId); // collect feeds/groups to display $visibleFeeds = array(); if ($feed['type'] == 'group') { $children = $forChildren ? $this->feeds->listChildren($feed['id']) : array($feed); foreach ($children as $childFeed) { $childFeed['subscriptions'] = array(); foreach ($subscribedFeeds as $subscribedFeed) { $subscriptionPath = explode(',', $subscribedFeed['path']); if (in_array($childFeed['id'], $subscriptionPath)) { $childFeed['subscriptions'][] = $subscribedFeed; // TODO also should handle group subscription $visibleFeeds[$childFeed['id']] = $childFeed; } } } } else { $feed['subscriptions'] = array($feed); $visibleFeeds[$feed['id']] = $feed; } return $forChildren ? $visibleFeeds : $visibleFeeds[$feed['id']]; }