/** * Service Hook for explorer * * @since 1.2 * @access public * @param string * @return */ public function explorer() { // Check for request forgeries Foundry::checkToken(); // Require the user to be logged in Foundry::requireLogin(); // Get the current view $view = $this->getCurrentView(); // Get the group object $groupId = JRequest::getInt('uid'); $group = Foundry::group($groupId); // Determine if the viewer can really view items if (!$group->canViewItem()) { return $view->call(__FUNCTION__); } // Load up the explorer library $explorer = Foundry::explorer($group->id, SOCIAL_TYPE_GROUP); $hook = JRequest::getCmd('hook'); $result = $explorer->hook($hook); $exception = Foundry::exception('Folder retrieval successful', SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__, $exception, $result); }
/** * Retrieves list of albums * * @since 1.0 * @access public * @param string * @return */ public function getAlbums($uid = '', $type = '', $options = array()) { $config = FD::config(); $db = FD::db(); // Get the query object $sql = $db->sql(); $sql->select('#__social_albums', 'a'); $sql->column('a.*'); $excludeblocked = isset($options['excludeblocked']) ? $options['excludeblocked'] : 0; if ($config->get('users.blocking.enabled') && $excludeblocked && !JFactory::getUser()->guest) { $sql->leftjoin('#__social_block_users', 'bus'); $sql->on('a.user_id', 'bus.user_id'); $sql->on('bus.target_id', JFactory::getUser()->id); $sql->isnull('bus.id'); } if ($uid) { $sql->where('uid', $uid); } if ($type) { $sql->where('type', $type); } $exclusion = isset($options['exclusion']) ? $options['exclusion'] : ''; $privacy = isset($options['privacy']) ? $options['privacy'] : false; if ($exclusion) { $exclusion = FD::makeArray($exclusion); foreach ($exclusion as $excludeAlbumId) { $sql->where('id', $excludeAlbumId, '!='); } } // Determine if we should include the core albums $coreAlbums = isset($options['core']) ? $options['core'] : true; if (!$coreAlbums) { $sql->where('core', 0); } $coreAlbumsOnly = isset($options['coreAlbumsOnly']) ? $options['coreAlbumsOnly'] : ''; if ($coreAlbumsOnly) { $sql->where('core', 0, '>'); } $withCoversOnly = isset($options['withCovers']) ? $options['withCovers'] : ''; if ($withCoversOnly) { $sql->join('#__social_photos', 'b', 'INNER'); $sql->on('cover_id', 'b.id'); } $ordering = isset($options['order']) ? $options['order'] : ''; if ($ordering) { $direction = isset($options['direction']) ? $options['direction'] : 'desc'; $sql->order($ordering, $direction); } $pagination = isset($options['pagination']) ? $options['pagination'] : false; $result = array(); if ($pagination) { // Set the total number of items. $totalSql = $sql->getSql(); $this->setTotal($totalSql, true); $result = $this->getData($sql->getSql()); } else { $limit = isset($options['limit']) ? $options['limit'] : ''; if ($limit) { $sql->limit($limit); } $db->setQuery($sql); $result = $db->loadObjectList(); } if (!$result) { return $result; } $albums = array(); $privacyLib = FD::privacy(FD::user()->id); foreach ($result as $row) { $album = FD::table('Album'); $album->bind($row); $add = true; if ($privacy) { if ($album->type == SOCIAL_TYPE_USER) { $add = $privacyLib->validate('albums.view', $album->id, SOCIAL_TYPE_ALBUM, $album->user_id); } else { if ($album->type == SOCIAL_TYPE_GROUP) { $group = Foundry::group($album->uid); if ($group->isOpen()) { $add = true; } else { $add = $group->isMember() || FD::user()->isSiteAdmin(); } } } } if ($add) { $albums[] = $album; } } return $albums; }
/** * Prepares the upload avatar stream * * @since 1.0 * @access public * @param SocialStream * @return */ public function prepareGroupUpdateCoverStream(&$item, $privacy, $includePrivacy = true) { // Load the photo $photo = $this->getPhotoFromParams($item); // Load the group $group = Foundry::group($item->cluster_id); // Get the cover object for the group $cover = $group->getCoverData(); $this->set('cover', $cover); $this->set('photo', $photo); $this->set('actor', $item->actor); $this->set('group', $group); $item->title = parent::display('streams/group/upload.cover.title'); $item->content = parent::display('streams/group/upload.cover.content'); if ($includePrivacy) { $element = $item->context; $uid = $item->contextId; $item->privacy = $privacy->form($uid, $element, $item->actor->id, 'core.view', false, $item->uid); } }