/** * Determines if the user is allowed to view this post if this post is associated with a team. * * @since 4.0 * @access public * @param string * @return */ public function checkTeamPrivacy(EasyBlogPost &$blog) { $id = $blog->getTeamAssociation(); // This post is not associated with any team, so we do not need to check anything on the privacy if (!$id) { return true; } $team = EB::table('TeamBlog'); $team->load($id); // If the team access is restricted to members only if ($team->access == EBLOG_TEAMBLOG_ACCESS_MEMBER && !$team->isMember($this->my->id) && !EB::isSiteAdmin()) { return false; } // If the team access is restricted to registered users, ensure that they are logged in. if ($team->access == EBLOG_TEAMBLOG_ACCESS_REGISTERED && $this->my->guest) { echo EB::showLogin(); return false; } return true; }
/** * Retrieves the next post in line * * @since 5.0 * @access public * @param string * @return */ public function getPostNavigation(EasyBlogPost $post, $navigationType) { $db = EB::db(); $my = JFactory::getUser(); $config = EB::config(); $keys = array('prev', 'next'); $nav = new stdClass(); // Get the active menu $active = JFactory::getApplication()->getMenu()->getActive(); $catAccess = array(); $queryInclude = ''; $teamId = $post->getTeamAssociation(); $author = $post->getAuthor(); // // If there is an active menu for EasyBlog, check if there's any filtering by categories // if ($active) { // $cats = EB::getCategoryInclusion($active->params->get('inclusion')); // if ($cats && !is_array($cats)) { // $cats = array($cats); // } // $catAccess['include'] = $cats; // } // // sql for category access // $catLib = EB::category(); // $catAccessSQL = $catLib->genAccessSQL( 'a.`id`', $catAccess); foreach ($keys as $key) { $query = array(); $query[] = 'SELECT a.`id`, a.`title`'; $query[] = ' FROM `#__easyblog_post` AS `a`'; $query[] = ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query[] = ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL); // EasySocial integrations $query[] = EB::easysocial()->buildPrivacyQuery('a'); // Jomsocial integrations $query[] = EB::jomsocial()->buildPrivacyQuery(); // Blog privacy settings if ($my->guest) { $query[] = 'AND a.' . $db->qn('access') . '=' . $db->Quote(BLOG_PRIVACY_PUBLIC); } // Exclude private categories // $query[] = 'AND (' . $catAccessSQL . ')'; // If the current menu is blogger mode, we need to respect this by only loading author related items $isBloggerMode = EBR::isBloggerMode(); if ($isBloggerMode !== false) { $query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($isBloggerMode); $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // Filter the next / previous link by team if ($navigationType == 'team' && $teamId) { $query[] = 'AND (a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' AND a.' . $db->qn('source_id') . '=' . $db->Quote($teamId) . ')'; } // Filter the next / previous by author if ($navigationType == 'author') { $query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($author->id); $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // Filter the next / previous post items from site wide if ($navigationType == 'site') { $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $query[] = EBR::getLanguageQuery('AND', 'a.language'); } if ($key == 'prev') { $query[] = ' AND a.`created` < ' . $db->Quote($post->created); $query[] = ' ORDER BY a.`created` DESC'; } if ($key == 'next') { $query[] = ' AND a.`created` > ' . $db->Quote($post->created); $query[] = ' ORDER BY a.`created` ASC'; } $query[] = 'LIMIT 1'; $query = implode(' ', $query); $db->setQuery($query); $result = $db->loadObject(); $nav->{$key} = $result; } return $nav; }