Example #1
0
 public function __construct()
 {
     parent::__construct();
     $limit = EB::call('Pagination', 'getLimit');
     $limitstart = $this->input->get('limitstart', 0, 'int');
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     $mainframe = JFactory::getApplication();
     $limit = EB::call('Pagination', 'getLimit');
     $limitstart = $this->input->get('limitstart', '0', 'int');
     // In case limit has been changed, adjust it
     $limitstart = (int) ($limit != 0 ? floor($limitstart / $limit) * $limit : 0);
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
 }
Example #3
0
 /**
  * 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');
 }
Example #4
0
 public function getAssociationPosts($options = array())
 {
     $db = EB::db();
     $query = "select a.* from `#__easyblog_post` as a";
     $query .= " WHERE a." . $db->quoteName('published') . " = " . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= " AND a." . $db->quoteName('state') . " = " . $db->Quote(EASYBLOG_POST_NORMAL);
     if (isset($options['langcode']) && $options['langcode']) {
         $query .= " AND a." . $db->quoteName('language') . " = " . $db->Quote($options['langcode']);
     }
     if (isset($options['userid']) && $options['userid']) {
         $query .= " AND a." . $db->quoteName('created_by') . " = " . $db->Quote($options['userid']);
     }
     if (isset($options['search']) && $options['search']) {
         $query .= " AND a." . $db->quoteName('title') . " LIKE " . $db->Quote('%' . $options['search'] . '%');
     }
     // limits
     $limit = EB::call('Pagination', 'getLimit', array('listlength'));
     $limitstart = JRequest::getInt('limitstart', 0, 'REQUEST');
     // In case limit has been changed, adjust it
     $limitstart = (int) ($limit != 0 ? floor($limitstart / $limit) * $limit : 0);
     if ($limitstart < 0) {
         $limitstart = 0;
     }
     $queryLimit = " LIMIT " . $limitstart . "," . $limit;
     // total count
     $queryCnt = "SELECT COUNT(1) from (";
     $queryCnt .= $query;
     $queryCnt .= ") as x";
     $db->setQuery($queryCnt);
     $this->_total = $db->loadResult();
     $this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
     $query = $query . $queryLimit;
     $db->setQuery($query);
     $results = $db->loadObjectList();
     return $results;
 }
Example #5
0
 public function execute()
 {
     if (!$this->items) {
         return $this->items;
     }
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
     // lets cache these categories
     EB::cache()->insertCategories($this->items);
     $categories = array();
     // Get the category model
     $model = EB::model('Category');
     foreach ($this->items as $row) {
         // We want to load the table objects
         $category = EB::table('Category');
         $category->bind($row);
         // binding the extra info
         if (isset($row->cnt)) {
             $category->cnt = $row->cnt;
         }
         // Format the childs
         $category->childs = array();
         // Build childs list
         EB::buildNestedCategories($category->id, $category, false, true);
         // Parameterize initial subcategories to display. Ability to configure from backend.
         $nestedLinks = '';
         $subcategoryLimit = $this->app->getCfg('list_limit') == 0 ? 5 : $this->app->getCfg('list_limit');
         if (count($category->childs) > $subcategoryLimit) {
             $initialNestedLinks = '';
             $initialRow = new stdClass();
             $initialRow->childs = array_slice($category->childs, 0, $subcategoryLimit);
             EB::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', ');
             $moreNestedLinks = '';
             $moreRow = new stdClass();
             $moreRow->childs = array_slice($category->childs, $initialLimit);
             EB::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', ');
             // Hide more nested links until triggered
             $nestedLinks .= $initialNestedLinks;
             $nestedLinks .= '<span class="more-subcategories-toggle"> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript:void(0);" onclick="eblog.categories.loadMore( this );">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($row->childs) - $initialLimit) . '</a></span>';
             $nestedLinks .= '<span class="more-subcategories" style="display: none;">, ' . $moreNestedLinks . '</span>';
         } else {
             EB::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', ');
         }
         // Set the nested links
         $category->nestedLink = $nestedLinks;
         // Get a list of nested categories and itself.
         $filterCategories = array($category->id);
         EB::accessNestedCategoriesId($category, $filterCategories);
         // Get a list of blog posts from this category
         $blogs = array();
         if (EB::cache()->exists($category->id, 'cats')) {
             $data = EB::cache()->get($category->id, 'cats');
             if (isset($data['post'])) {
                 $blogs = $data['post'];
             }
         } else {
             $blogs = $model->getPosts($filterCategories, $limit);
         }
         // Format the blog posts
         $blogs = EB::formatter('list', $blogs);
         // Assign other attributes to the category object
         $category->blogs = $blogs;
         // Get the total number of posts in the category
         if (!isset($category->cnt)) {
             $category->cnt = $model->getTotalPostCount($filterCategories);
         }
         // Get a list of active authors within this category.
         $category->authors = $category->getActiveBloggers();
         // Check isCategorySubscribed
         $category->isCategorySubscribed = $model->isCategorySubscribedEmail($category->id, $this->my->email);
         $categories[] = $category;
     }
     return $categories;
 }
Example #6
0
 /**
  * Displays a list of blog posts on the site filtered by a category.
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function listings()
 {
     // Retrieve sorting options
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $id = $this->input->get('id', 0, 'int');
     // Try to load the category
     $category = EB::table('Category');
     $category->load($id);
     // If the category isn't found on the site throw an error.
     if (!$id || !$category->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_CATEGORY_NOT_FOUND'));
     }
     // Set the meta description for the category
     EB::setMeta($category->id, META_TYPE_CATEGORY);
     // Set a canonical link for the category page.
     $this->canonical($category->getExternalPermalink());
     // Get the privacy
     $privacy = $category->checkPrivacy();
     if ($privacy->allowed || EB::isSiteAdmin() || !$this->my->guest && $this->config->get('main_allowguestsubscribe')) {
         $this->doc->addHeadLink($category->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         $this->doc->addHeadLink($category->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
     }
     // Set views breadcrumbs
     $this->setViewBreadcrumb($this->getName());
     // Set the breadcrumb for this category
     if (!EBR::isCurrentActiveMenu('categories', $category->id)) {
         // Always add the final pathway to the category title.
         $this->setPathway($category->title, '');
     }
     //get the nested categories
     $category->childs = null;
     // Build nested childsets
     EB::buildNestedCategories($category->id, $category, false, true);
     // Parameterize initial subcategories to display. Ability to configure from backend.
     $nestedLinks = '';
     $initialLimit = $this->app->getCfg('list_limit') == 0 ? 5 : $this->app->getCfg('list_limit');
     if (count($category->childs) > $initialLimit) {
         $initialNestedLinks = '';
         $initialRow = new stdClass();
         $initialRow->childs = array_slice($category->childs, 0, $initialLimit);
         EB::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', ');
         $moreNestedLinks = '';
         $moreRow = new stdClass();
         $moreRow->childs = array_slice($category->childs, $initialLimit);
         EB::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', ');
         // Hide more nested links until triggered
         $nestedLinks .= $initialNestedLinks;
         $nestedLinks .= '<span class="more-subcategories-toggle" data-more-categories-link> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript:void(0);">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($category->childs) - $initialLimit) . '</a></span>';
         $nestedLinks .= '<span class="more-subcategories" style="display: none;" data-more-categories>, ' . $moreNestedLinks . '</span>';
     } else {
         EB::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', ');
     }
     $catIds = array();
     $catIds[] = $category->id;
     EB::accessNestedCategoriesId($category, $catIds);
     $category->nestedLink = $nestedLinks;
     // Get the category model
     $model = EB::model('Category');
     // Get total posts in this category
     $category->cnt = $model->getTotalPostCount($category->id);
     // Get teamblog posts count
     // $teamBlogCount = $model->getTeamBlogCount($category->id);
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
     // Get the posts in the category
     $data = $model->getPosts($catIds, $limit);
     // Get the pagination
     $pagination = $model->getPagination();
     // Get allowed categories
     $allowCat = $model->allowAclCategory($category->id);
     // Format the data that we need
     $posts = array();
     // Ensure that the user is really allowed to view the blogs
     if (!empty($data)) {
         $posts = EB::formatter('list', $data);
     }
     // Check isCategorySubscribed
     $isCategorySubscribed = $model->isCategorySubscribedEmail($category->id, $this->my->email);
     // If this category has a different theme, we need to output it differently
     if (!empty($category->theme)) {
         $this->setTheme($category->theme);
     }
     // Set the page title
     $title = EB::getPageTitle(JText::_($category->title));
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Set the return url
     $return = base64_encode($category->getExternalPermalink());
     // Get the pagination
     $pagination = $pagination->getPagesLinks();
     $this->set('allowCat', $allowCat);
     $this->set('category', $category);
     $this->set('sort', $sort);
     $this->set('posts', $posts);
     $this->set('return', $return);
     $this->set('pagination', $pagination);
     // $this->set('teamBlogCount', $teamBlogCount);
     $this->set('privacy', $privacy);
     $this->set('isCategorySubscribed', $isCategorySubscribed);
     parent::display('blogs/categories/item');
 }
Example #7
0
 public function preloadPosts($catIds)
 {
     $db = EB::db();
     $config = EB::config();
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
     // Determines if this is currently on blogger mode
     $isBloggerMode = EasyBlogRouter::isBloggerMode();
     $query = array();
     $i = 1;
     foreach ($catIds as $cid => $cIds) {
         $p = 'p' . $i;
         $a = 'a' . $i;
         $f = 'f' . $i;
         $isJSGrpPluginInstalled = false;
         $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog');
         $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog');
         $isJSInstalled = false;
         // need to check if the site installed jomsocial.
         if (EB::jomsocial()->exists()) {
             $isJSInstalled = true;
         }
         $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false;
         $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false;
         // contribution type sql
         $contributor = EB::contributor();
         $contributeSQL = " AND ( ({$p}.`source_type` = " . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ") ";
         if ($config->get('main_includeteamblogpost')) {
             $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, $p);
         }
         if ($includeJSEvent) {
             $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, $p);
         }
         if ($includeJSGrp) {
             $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, $p);
         }
         // Test if easysocial exists on the site
         if (EB::easysocial()->exists()) {
             $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, $p);
             $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, $p);
         }
         $contributeSQL .= ")";
         $tmp = "(select {$p}.*, " . $db->Quote($cid) . " as `category_id`, {$f}.`id` as `featured`";
         $tmp .= "\tfrom `#__easyblog_post` as {$p}";
         $tmp .= "\t\tinner join `#__easyblog_post_category` as {$a} on {$p}.`id` = {$a}.`post_id`";
         $tmp .= " LEFT JOIN `#__easyblog_featured` AS {$f}";
         $tmp .= " \tON {$p}.`id` = {$f}.`content_id` AND {$f}.`type` = " . $db->Quote('post');
         if (count($cIds) == 1) {
             $tmp .= " where {$a}.`category_id` = " . $db->Quote($cIds[0]);
         } else {
             $tmp .= " where {$a}.`category_id` IN (" . implode(',', $cIds) . ")";
         }
         $tmp .= " and {$p}.`published` = " . $db->Quote(EASYBLOG_POST_PUBLISHED);
         $tmp .= " and {$p}.`state` = " . $db->Quote(EASYBLOG_POST_NORMAL);
         if ($isBloggerMode !== false) {
             $tmp .= " AND {$p}." . $db->qn('created_by') . " = " . $db->Quote($isBloggerMode);
         } else {
             // Get the author id based on the category menu
             $authorId = EB::getCategoryMenuBloggerId();
             if ($authorId) {
                 $tmp .= " AND {$p}." . $db->qn('created_by') . " = " . $db->Quote($authorId);
             }
         }
         // If user is a guest, ensure that they can really view the blog post
         if ($this->my->guest) {
             $tmp .= " AND {$p}." . $db->qn('access') . " = " . $db->Quote(BLOG_PRIVACY_PUBLIC);
         }
         // Ensure that the blog posts is available site wide
         $tmp .= $contributeSQL;
         // $tmp .= " AND $p." . $db->qn('source_id') . " = " . $db->Quote("0");
         // Filter by language
         $language = EB::getCurrentLanguage();
         if ($language) {
             $tmp .= " AND ({$p}." . $db->qn('language') . "=" . $db->Quote($language) . " OR {$p}." . $db->qn('language') . "=" . $db->Quote('*') . " OR {$p}." . $db->qn('language') . "=" . $db->Quote('') . ")";
         }
         $tmp .= " order by {$p}.`created` desc";
         $tmp .= " limit " . $limit . ")";
         $query[] = $tmp;
         $i++;
     }
     $query = implode(' UNION ALL ', $query);
     // echo $query;exit;
     $db->setQuery($query);
     $results = $db->loadObjectList();
     $posts = array();
     if ($results) {
         foreach ($results as $row) {
             $posts[$row->category_id][] = $row;
         }
     }
     return $posts;
 }
Example #8
0
 /**
  * Get array of blogs defined by parameters
  *
  * @param	$type			str
  * @param	$typeId			int
  * @param	$sort			str
  * @param	$max			int
  * @param	$published		str
  * @param	$search			bool
  * @param	$frontpage		bool
  * @param	$excludeBlogs	array
  * @param	$pending		bool
  * @param	$dashboard		bool
  * @param	$protected		bool
  * @param	$excludeCats	array
  * @param	$includeCats	array
  *
  */
 public function getBlogsBy($type, $typeId = 0, $sort = '', $max = 0, $published = EBLOG_FILTER_PUBLISHED, $search = false, $frontpage = false, $excludeBlogs = array(), $pending = false, $dashboard = false, $protected = true, $excludeCats = array(), $includeCats = array(), $postType = null, $limitType = 'listlength', $pinFeatured = true)
 {
     $db = EB::db();
     $my = JFactory::getUser();
     $config = EB::config();
     $queryPagination = false;
     $queryWhere = '';
     $queryOrder = '';
     $queryLimit = '';
     $queryWhere = '';
     $queryExclude = '';
     $queryExcludePending = '';
     $queryExcludePrivateJSGrp = '';
     // use in generating category access sql
     $catAccess = array();
     // Get excluded categories
     $excludeCats = !empty($excludeCats) ? $excludeCats : array();
     // Determines if the user is viewing a blogger mode menu item
     $isBloggerMode = EasyBlogRouter::isBloggerMode();
     // What is this for?
     $teamBlogIds = '';
     // What?
     $customOrdering = '';
     if (!empty($sort) && is_array($sort)) {
         $customOrdering = isset($sort[1]) ? $sort[1] : '';
         $sort = isset($sort[0]) ? $sort[0] : '';
     }
     // Sorting options
     $sort = empty($sort) ? $config->get('layout_postorder', 'latest') : $sort;
     $isJSGrpPluginInstalled = false;
     $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog');
     $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog');
     $isJSInstalled = false;
     // need to check if the site installed jomsocial.
     $file = JPATH_ROOT . '/components/com_community/libraries/core.php';
     $exists = JFile::exists($file);
     if ($exists) {
         $isJSInstalled = true;
     }
     $includeJSGrp = $type != 'teamblog' && !$dashboard && $isJSGrpPluginInstalled && $isJSInstalled ? true : false;
     $includeJSEvent = $type != 'teamblog' && !$dashboard && $isEventPluginInstalled && $isJSInstalled ? true : false;
     $jsEventPostIds = '';
     $jsGrpPostIds = '';
     // contribution type sql
     $contributor = EB::contributor();
     $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
     if ($config->get('main_includeteamblogpost') || $type == 'teamblog' || $dashboard) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
     }
     if ($includeJSEvent) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a');
     }
     if ($includeJSGrp) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a');
     }
     // Only process the contribution sql for EasySocial if EasySocial really exists.
     if ($type != 'teamblog' && !$dashboard && EB::easysocial()->exists()) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a');
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a');
     }
     $contributeSQL .= ')';
     //get teamblogs id.
     $query = '';
     //check if the request come with statastic or not.
     $statType = JRequest::getString('stat', '');
     $statId = '';
     if (!empty($statType)) {
         $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', '');
     }
     if (!empty($excludeBlogs)) {
         $queryExclude .= ' AND a.`id` NOT IN (';
         for ($i = 0; $i < count($excludeBlogs); $i++) {
             $queryExclude .= $db->Quote($excludeBlogs[$i]);
             if (next($excludeBlogs) !== false) {
                 $queryExclude .= ',';
             }
         }
         $queryExclude .= ')';
     }
     // Exclude postings from specific categories
     if (!empty($excludeCats)) {
         $catAccess['exclude'] = $excludeCats;
     }
     $queryInclude = '';
     // Respect inclusion categories
     if (!empty($includeCats)) {
         $catAccess['include'] = $includeCats;
     }
     switch ($published) {
         case EBLOG_FILTER_PENDING:
             $queryWhere = ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PENDING);
             break;
         case EBLOG_FILTER_ALL:
             $queryWhere = ' WHERE (a.`published` = 1 OR a.`published`=0 OR a.`published`=2 OR a.`published`=3) ';
             $queryWhere .= ' AND a.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL);
             break;
         case EBLOG_FILTER_SCHEDULE:
             $queryWhere = ' WHERE a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_SCHEDULED);
             break;
         case EBLOG_FILTER_UNPUBLISHED:
             $queryWhere = ' WHERE a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_UNPUBLISHED);
             break;
         case EBLOG_FILTER_DRAFT:
             $queryWhere = ' WHERE a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_DRAFT);
             break;
         case EBLOG_FILTER_PUBLISHED:
         default:
             $queryWhere = ' WHERE a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED);
             $queryWhere .= ' AND a.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL);
             break;
     }
     //do not list out protected blog in rss
     if (JRequest::getCmd('format', '') == 'feed') {
         if ($config->get('main_password_protect', true)) {
             $queryWhere .= ' AND a.`blogpassword`="" ';
         }
     }
     // Blog privacy setting
     // @integrations: jomsocial privacy
     $file = JPATH_ROOT . '/components/com_community/libraries/core.php';
     $easysocial = EasyBlogHelper::getHelper('EasySocial');
     if ($config->get('integrations_easysocial_privacy') && $easysocial->exists() && !EasyBlogHelper::isSiteAdmin() && $type != 'teamblog' && !$dashboard) {
         $esPrivacyQuery = $easysocial->buildPrivacyQuery('a');
         $queryWhere .= $esPrivacyQuery;
     } else {
         if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin() && $type != 'teamblog' && !$dashboard) {
             require_once $file;
             $my = JFactory::getUser();
             $jsFriends = CFactory::getModel('Friends');
             $friends = $jsFriends->getFriendIds($my->id);
             array_push($friends, $my->id);
             // Insert query here.
             $queryWhere .= ' AND (';
             $queryWhere .= ' (a.`access`= 0 ) OR';
             $queryWhere .= ' ( (a.`access` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR';
             if (empty($friends)) {
                 $queryWhere .= ' ( (a.`access` = 30) AND ( 1 = 2 ) ) OR';
             } else {
                 $queryWhere .= ' ( (a.`access` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR';
             }
             $queryWhere .= ' ( (a.`access` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $my->id . ') )';
             $queryWhere .= ' )';
         } else {
             if ($my->id == 0) {
                 $queryWhere .= ' AND a.`access` = ' . $db->Quote(BLOG_PRIVACY_PUBLIC);
             }
         }
     }
     if ($isBloggerMode !== false) {
         $queryWhere .= ' AND a.`created_by` = ' . $db->Quote($isBloggerMode);
     }
     $contentId = '';
     $isIdArray = false;
     if (is_array($typeId)) {
         if (count($typeId) > 1) {
             for ($i = 0; $i < count($typeId); $i++) {
                 if ($typeId[$i]) {
                     $contentId .= $typeId[$i];
                     if ($i + 1 < count($typeId)) {
                         $contentId .= ',';
                     }
                 }
             }
             $isIdArray = true;
         } else {
             if (!empty($typeId)) {
                 $contentId = $typeId[0];
             }
         }
     } else {
         $contentId = $typeId;
     }
     if ($contentId) {
         switch ($type) {
             case 'category':
                 $catAccess['type'] = $typeId;
                 if ($isBloggerMode === false) {
                     $catBloggerId = EasyBlogHelper::getCategoryMenuBloggerId();
                     if (!empty($catBloggerId)) {
                         $queryWhere .= ' AND a.`created_by` = ' . $db->Quote($catBloggerId);
                     }
                 }
                 break;
             case 'blogger':
                 $queryWhere .= $isIdArray ? ' AND a.`created_by` IN (' . $contentId . ')' : ' AND a.`created_by` = ' . $db->Quote($contentId);
                 break;
             case 'teamblog':
                 $queryWhere .= ' AND (a.source_type = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM);
                 $queryWhere .= $isIdArray ? ' AND a.source_id IN (' . $contentId . ')' : ' AND a.`source_id` = ' . $db->Quote($contentId);
                 $queryWhere .= ')';
                 break;
             default:
                 break;
         }
     }
     // @rule: Filter for `source` column type.
     if (!is_null($postType)) {
         switch ($postType) {
             case 'microblog':
                 $queryWhere .= ' AND a.`posttype` != ' . $db->Quote('');
                 break;
             case 'posts':
                 $queryWhere .= ' AND a.`posttype` = ' . $db->Quote('');
                 break;
             case 'quote':
                 $queryWhere .= ' AND a.`posttype` = ' . $db->Quote('quote');
                 break;
             case 'link':
                 $queryWhere .= ' AND a.`posttype` = ' . $db->Quote('link');
                 break;
             case 'photo':
                 $queryWhere .= ' AND a.`posttype` = ' . $db->Quote('photo');
                 break;
             case 'video':
                 $queryWhere .= ' AND a.`posttype` = ' . $db->Quote('video');
                 break;
             case 'twitter':
                 $queryWhere .= ' AND a.`posttype` = ' . $db->Quote('twitter');
                 break;
         }
     }
     if ($type == 'blogger' || $type == 'teamblog') {
         if (!empty($statType)) {
             if ($statType == 'category') {
                 $catAccess['statType'] = $statId;
             } else {
                 $queryWhere .= ' AND t.`tag_id` = ' . $db->Quote($statId);
             }
         }
     }
     if ($search) {
         $queryWhere .= ' AND a.`title` LIKE ' . $db->Quote('%' . $search . '%');
     }
     if ($frontpage) {
         $queryWhere .= ' AND a.`frontpage` = ' . $db->Quote('1');
     }
     // @rule: When language filter is enabled, we need to detect the appropriate contents
     $filterLanguage = JFactory::getApplication()->getLanguageFilter();
     if ($filterLanguage) {
         $queryWhere .= EBR::getLanguageQuery('AND', 'a.language');
     }
     if ($protected == false) {
         $queryWhere .= ' AND a.`blogpassword` = ""';
     }
     // category access here
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess);
     $queryWhere .= ' AND (' . $catAccessSQL . ')';
     // get the default sorting.
     $defaultSorting = $customOrdering ? $customOrdering : $config->get('layout_postsort', 'desc');
     $queryOrder = ' ORDER BY ';
     $sortableItems = array('latest', 'published', 'popular', 'active', 'alphabet', 'modified', 'random');
     if ($frontpage && $pinFeatured) {
         $queryOrder .= ' f.`created` DESC ,';
     }
     switch ($sort) {
         case 'latest':
             $queryOrder .= ' a.`created` ' . $defaultSorting;
             break;
         case 'published':
             $queryOrder .= ' a.`publish_up` ' . $defaultSorting;
             break;
         case 'popular':
             $queryOrder .= ' a.`hits` ' . $defaultSorting;
             break;
         case 'active':
             $queryOrder .= ' a.`publish_down` ' . $defaultSorting;
             break;
         case 'alphabet':
             $queryOrder .= ' a.`title` ' . $defaultSorting;
             break;
         case 'modified':
             $queryOrder .= ' a.`modified` ' . $defaultSorting;
             break;
         case 'random':
             $queryOrder .= ' `random_id` ';
             break;
         default:
             break;
     }
     if ($max > 0) {
         $queryLimit = ' LIMIT ' . $max;
     } else {
         //set frontpage list length if it is detected to be the frontpage
         $view = JRequest::getCmd('view', '');
         $limit = EB::call('Pagination', 'getLimit', array($limitType));
         $limitstart = JRequest::getInt('limitstart', 0, 'REQUEST');
         // In case limit has been changed, adjust it
         $limitstart = (int) ($limit != 0 ? floor($limitstart / $limit) * $limit : 0);
         if ($limitstart < 0) {
             $limitstart = 0;
         }
         $queryLimit = ' LIMIT ' . $limitstart . ',' . $limit;
         $queryPagination = true;
     }
     if ($queryPagination) {
         $query = 'SELECT COUNT(1) FROM `#__easyblog_post` AS a';
         if (($type == 'blogger' || $type == 'teamblog') && $statType == 'tag') {
             $query .= ' LEFT JOIN `#__easyblog_post_tag` AS t ON a.id = t.post_id';
         }
         $query .= $queryWhere;
         $query .= $contributeSQL;
         $query .= $queryExclude;
         $query .= $queryInclude;
         // echo $query;exit;
         $db->setQuery($query);
         $this->_total = $db->loadResult();
         $this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
     }
     $query = 'SELECT a.`id` AS key1, a.*';
     $query .= ', ifnull(f.`id`, 0) as `featured`';
     if ($sort == 'random') {
         $query .= ', floor( 1 + rand() * rd.`rid` ) as `random_id`';
     }
     $query .= ' FROM `#__easyblog_post` AS a';
     // if ($frontpage && $pinFeatured) {
     $query .= ' LEFT JOIN `#__easyblog_featured` AS f';
     $query .= ' 	ON a.`id` = f.`content_id` AND f.`type` = ' . $db->Quote('post');
     // }
     if (($type == 'blogger' || $type == 'teamblog') && $statType == 'tag') {
         $query .= ' LEFT JOIN `#__easyblog_post_tag` AS t ON a.`id` = t.`post_id`';
         $query .= ' AND t.`tag_id` = ' . $db->Quote($statId);
     }
     if ($sort == 'random') {
         $query .= ', (select max(tmp.`id`) - 1 as `rid` from `#__easyblog_post` as tmp ) as rd';
     }
     $query .= $queryWhere;
     $query .= $contributeSQL;
     $query .= $queryExclude;
     $query .= $queryInclude;
     $query .= $queryOrder;
     $query .= $queryLimit;
     // // Debugging
     // echo str_ireplace( '#__' , 'jos_' , $query );
     // exit;
     $db->setQuery($query);
     if ($db->getErrorNum() > 0) {
         JError::raiseError($db->getErrorNum(), $db->getErrorMsg() . $db->stderr());
     }
     $result = $db->loadObjectList();
     return $result;
 }
Example #9
0
 /**
  * Formats a date.
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function formatDate($format, $dateString)
 {
     $date = EB::call('Date', 'dateWithOffSet', array($dateString));
     return $date->format($format);
 }
Example #10
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     $category = EasyBlogHelper::table('Category', 'Table');
     $id = $input->get('id', null, 'INT');
     $search = $input->get('search', null, 'STRING');
     $posts = array();
     if (!isset($id)) {
         $categoriesmodel = EasyBlogHelper::getModel('Categories');
         $categories = $categoriesmodel->getCategoryTree('ordering');
         $this->plugin->setResponse($categories);
         return;
     }
     $category->load($id);
     // private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$category->id || !$privacy->allowed) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Category not found'));
         return;
     }
     //new code
     $category = EB::table('Category');
     $category->load($id);
     //get the nested categories
     $category->childs = null;
     // Build nested childsets
     EB::buildNestedCategories($category->id, $category, false, true);
     $catIds = array();
     $catIds[] = $category->id;
     EB::accessNestedCategoriesId($category, $catIds);
     // Get the category model
     $model = EB::model('Category');
     // Get total posts in this category
     $category->cnt = $model->getTotalPostCount($category->id);
     // Get teamblog posts count
     // $teamBlogCount = $model->getTeamBlogCount($category->id);
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
     // Get the posts in the category
     $data = $model->getPosts($catIds, $limit);
     $rows = EB::formatter('list', $data);
     //end
     foreach ($rows as $k => $v) {
         //$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
         $scm_obj = new EasyBlogSimpleSchema_plg();
         $item = $scm_obj->mapPost($v, '', 100, array('text'));
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         if ($v->blogpassword != '') {
             $item->ispassword = true;
         } else {
             $item->ispassword = false;
         }
         $item->blogpassword = $v->blogpassword;
         $model = EasyBlogHelper::getModel('Ratings');
         $ratingValue = $model->getRatingValues($item->postid, 'entry');
         $item->rate = $ratingValue;
         $item->isVoted = $model->hasVoted($item->postid, 'entry', $this->plugin->get('user')->id);
         if ($item->rate->ratings == 0) {
             $item->rate->ratings = -2;
         }
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }
Example #11
0
 /**
  * Displays the all bloggers
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tmpl = null)
 {
     // Set meta tags for bloggers
     EB::setMeta(META_ID_BLOGGERS, META_TYPE_VIEW);
     // Set the breadcrumbs only when necessary
     if (!EBR::isCurrentActiveMenu('blogger')) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), '');
     }
     // Retrieve the current sorting options
     $sort = $this->input->get('sort', '', 'cmd');
     $sortHTML = $this->getSorting($sort);
     // Retrieve the current filtering options.
     $filter = $this->input->get('filter', 'showallblogger', 'cmd');
     if ($this->config->get('main_bloggerlistingoption')) {
         $filter = $this->input->get('filter', 'showbloggerwithpost', 'cmd');
     }
     // Get the filter html codes
     $filterHTML = $this->getFilter($filter);
     // Retrieve search values
     $search = $this->input->get('search', '', 'string');
     // Retrieve the models.
     $bloggerModel = EB::model('Blogger');
     $blogModel = EB::model('Blog');
     $postTagModel = EB::model('PostTag');
     // Get limit
     $limit = $this->config->get('layout_pagination_bloggers_per_page');
     if (!$sort) {
         // Retrieve default sort from setting
         $sort = $this->config->get('layout_bloggerorder', 'latest');
     }
     // Retrieve the bloggers to show on the page.
     $results = $bloggerModel->getBloggers($sort, $limit, $filter, $search);
     $pagination = $bloggerModel->getPagination();
     // Determine the current page if there's pagination
     $limitstart = $this->input->get('limitstart', 0, 'int');
     // Set the title of the page
     $title = JText::_('COM_EASYBLOG_BLOGGERS_PAGE_TITLE');
     $this->setPageTitle($title, $pagination, true);
     // Add canonical urls
     $this->canonical('index.php?option=com_easyblog&view=blogger');
     // Determine the default ordering for the posts
     $postsOrdering = $this->config->get('layout_postorder');
     $postsLimit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_BLOGGERS));
     // Format the blogger listing.
     $authors = array();
     if (!empty($results)) {
         //preload users
         $ids = array();
         foreach ($results as $row) {
             $ids[] = $row->id;
         }
         EB::user($ids);
         // lets cache the bloggers
         EB::cache()->insertBloggers($results);
         // lets group the posts for posts caching first
         $tobeCached = array();
         $bloggerPosts = array();
         foreach ($results as $row) {
             $bloggerId = $row->id;
             $items = $blogModel->getBlogsBy('blogger', $row->id, $postsOrdering, $postsLimit, EBLOG_FILTER_PUBLISHED);
             $bloggerPosts[$bloggerId] = $items;
             if ($items) {
                 $tobeCached = array_merge($tobeCached, $items);
             }
         }
         // now we can cache the posts.
         if ($tobeCached) {
             EB::cache()->insert($tobeCached);
         }
         foreach ($results as $row) {
             // Load the author object
             $author = EB::user($row->id);
             // Retrieve blog posts from this user.
             $posts = $bloggerPosts[$row->id];
             $author->blogs = EB::formatter('list', $posts, false);
             // Get tags that are used by this author
             $tmpTags = $bloggerModel->getTagUsed($row->id);
             $tags = array();
             if ($tmpTags) {
                 foreach ($tmpTags as $tagRow) {
                     $tag = EB::table('Tag');
                     $tag->bind($tagRow);
                     $tags[] = $tag;
                 }
             }
             $author->tags = $tags;
             // Get categories that are used by this author
             $author->categories = $bloggerModel->getCategoryUsed($row->id);
             // Get the twitter link for this author.
             $author->twitter = EB::socialshare()->getLink('twitter', $row->id);
             // Get total posts created by the author.
             $author->blogCount = $row->totalPost;
             // Get total posts created by the author.
             $author->featured = $row->featured ? 1 : 0;
             $author->isBloggerSubscribed = $bloggerModel->isBloggerSubscribedEmail($author->id, $this->my->email);
             // Messaging integrations
             $author->messaging = EB::messaging()->html($author);
             $authors[] = $author;
         }
     }
     // Format the pagination
     $pagination = $pagination->getPagesLinks();
     $this->set('authors', $authors);
     $this->set('search', $search);
     $this->set('sort', $sort);
     $this->set('pagination', $pagination);
     $this->set('sortHTML', $sortHTML);
     $this->set('filterHTML', $filterHTML);
     parent::display('authors/default');
 }