/** * Displays a list of blog posts from a specific team * * @since 4.0 * @access public * @param string * @return */ public function listings() { // Get the team id that is being accessed now $id = $this->input->get('id', 0, 'int'); $team = EB::table('TeamBlog'); $team->load($id); if (!$id || !$team->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID')); } // set meta tags for teamblog view EB::setMeta($id, META_TYPE_TEAM); $gid = EB::getUserGids(); $isMember = $team->isMember($this->my->id, $gid); $team->isMember = $isMember; $team->isActualMember = $team->isMember($this->my->id, $gid, false); // Add rss feed link if ($team->access == EBLOG_TEAMBLOG_ACCESS_EVERYONE || $team->isMember) { $this->doc->addHeadLink($team->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->doc->addHeadLink($team->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } // check if team description is emtpy or not. if yes, show default message. if (empty($team->description)) { $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION'); } // Set the breadcrumbs for this view $this->setViewBreadcrumb('teamblog'); $this->setPathway($team->getTitle()); $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_TEAMBLOGS)); // Retrieve the model $model = EB::model('TeamBlogs'); $posts = $model->getPosts($team->id, $limit); $posts = EB::formatter('list', $posts); // Get the pagination $pagination = $model->getPagination(); // Retrieve team's information $members = $model->getTeamMembers($team->id); // Determines if the team blog is featured $team->isFeatured = EB::isFeatured('teamblog', $team->id); // Set the page title $title = EB::getPageTitle($team->title); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Check if subscribed $isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email); // Get the current url $return = $team->getPermalink(); $this->set('return', $return); $this->set('team', $team); $this->set('members', $members); $this->set('pagination', $pagination->getPagesLinks()); $this->set('posts', $posts); $this->set('isTeamSubscribed', $isTeamSubscribed); parent::display('teamblogs/item'); }
public function execute() { if (!$this->items) { return $this->items; } // cache teamblogs EB::cache()->insertTeams($this->items); $teams = array(); // Load up the blogs model $model = EB::model('TeamBlogs'); // Get the current user's group id's $gid = EB::getUserGids(); foreach ($this->items as $item) { $team = EB::table('TeamBlog'); $team->load($item->id); // Check if the logged in user is a member of the group $team->isMember = $team->isMember($this->my->id, $gid); $team->isActualMember = $team->isMember($this->my->id, $gid, false); $team->members = $model->getAllMembers($team->id, 5); // total member count ( including actual members and users from asociated joomla group.) $team->memberCount = $team->getAllMembersCount(); // post count associated with this teamblog. $team->postCount = $team->getPostCount(); // Get the list of blog posts form this team $blogs = array(); if ($team->access != EBLOG_TEAMBLOG_ACCESS_MEMBER || $team->isMember || EB::isSiteAdmin()) { $blogs = $model->getPosts($team->id, EASYBLOG_TEAMBLOG_LISTING_NO_POST); $blogs = EB::formatter('list', $blogs); } $team->blogs = $blogs; // Get the list of tags // $team->tags = $team->getTags(); // Get categories used in this team // $team->categories = $team->getCategories(); // Determines if the team is featured if (isset($item->isfeatured)) { $team->isFeatured = $item->isfeatured; } else { $team->isFeatured = EB::isFeatured('teamblog', $team->id); } // check if team description is emtpy or not. if yes, show default message. if (empty($team->description)) { $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION'); } // Determines if the viewer is subscribed to this team $team->isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email); // If the user is subscribed, we need to get his subscription id $team->subscription_id = $team->isTeamSubscribed; $teams[] = $team; } return $teams; }
public function getDefaultCategoryId() { $db = EB::db(); $gid = EB::getUserGids(); $gids = ''; if (count($gid) > 0) { foreach ($gid as $id) { $gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id); } } $query = 'SELECT a.id'; $query .= ' FROM `#__easyblog_category` AS a'; $query .= ' WHERE a.`published` = ' . $db->Quote('1'); $query .= ' AND a.`default` = ' . $db->Quote('1'); $query .= ' and a.id not in ('; $query .= ' select id from `#__easyblog_category` as c'; $query .= ' where not exists ('; $query .= ' select b.category_id from `#__easyblog_category_acl` as b'; $query .= ' where b.category_id = c.id and b.`acl_id` = ' . $db->Quote(CATEGORY_ACL_ACTION_SELECT); $query .= ' and b.type = ' . $db->Quote('group'); $query .= ' and b.content_id IN (' . $gids . ')'; $query .= ' )'; $query .= ' and c.`private` = ' . $db->Quote(CATEGORY_PRIVACY_ACL); $query .= ' )'; $query .= ' AND a.`parent_id` NOT IN (SELECT `id` FROM `#__easyblog_category` AS e WHERE e.`published` = ' . $db->Quote('0') . ' AND e.`parent_id` = ' . $db->Quote('0') . ' )'; $query .= ' ORDER BY a.`lft` LIMIT 1'; $db->setQuery($query); $result = $db->loadResult(); return empty($result) ? '0' : $result; }
// Let the template know which header we want to use $templateForHeader = 'tag'; } // Filter blog posts by team blogs if ($filterType == 4 || $filterType == 'team') { $teamId = $params->get('tid'); // Ensure that the admin selected a team from the module settings if (!$teamId) { echo JText::_('MOD_LATESTBLOGS_SELECT_TEAM'); return; } // Load up the team blog table $team = EB::table('TeamBlog'); $team->load($teamId); // Determine if the current viewer is a member of the team $gids = EB::getUserGids(); $team->isMember = $team->isMember($my->id, $gids); // Default set empty posts unless they can view it $posts = array(); if ($team->access != 1 || $team->isMember) { $posts = modLatestBlogsHelper::getLatestPost($params, $teamId, 'team'); } // Let the template know what header we want to use $templateForHeader = 'team'; } // This will only get called when user is viewing the entry view of a blog post. if ($filterType == 5 || $filterType == 'entry') { // Get the current view of the page $view = $app->input->get('view', '', 'cmd'); // We need to have the id $id = $app->input->get('id', 0, 'int');
/** * Retrieves a list of filter attributes * * @since 5.0 * @access public * @param string * @return */ public static function getFilterAttributes() { $my = JFactory::getUser(); $gids = EB::getUserGids($my->id); $filter = ''; foreach ($gids as $gid) { $result = self::getFilterRule($gid); if ($result !== false) { $filter = $result; } } $atts = array(); if ($filter) { $atts = $filter->get('disallow_attributes'); $atts = strtolower($atts); $atts = explode(',', $atts); } return $atts; }
/** * Determines if the team's content is viewable * * @since 4.0 * @access public * @param string * @return */ public function viewable($userId = '') { $db = EB::db(); if (!$userId) { $my = JFactory::getUser(); } else { $my = JFactory::getUser($userId); } // For guests, we only allow them to view that is set to "Everyone" if (!$my->id && $this->access == 3 || $this->isMember($my->id)) { return true; } // Try to check against the user groups $userGroups = EB::getUserGids($my->id); // Something is weird because the user doesn't belong to any groups. if (!$userGroups) { return false; } // Get a list of groups associated with this team $groups = $this->getGroups(); if (in_array($userGroups, $groups)) { return true; } return false; }