/** * Class Constructor * * @since 3.7 * @access public */ public function __construct($sel_theme = null) { $config = EasyBlogHelper::getConfig(); $this->user_theme = $config->get('layout_theme'); // Default theme $theme = 'default'; if (empty($sel_theme)) { $theme = $config->get('layout_theme'); } elseif ($sel_theme == 'dashboard') { $theme = $config->get('layout_dashboard_theme'); $this->dashboard = true; } $this->_theme = $theme; $obj = new stdClass(); $obj->config = EasyBlogHelper::getConfig(); $obj->my = JFactory::getUser(); $obj->admin = EasyBlogHelper::isSiteAdmin(); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($obj->my->id); $profile->setUser($obj->my); $obj->profile = $profile; $currentTheme = $this->_theme; if (JRequest::getVar('theme', '') != '') { $currentTheme = JRequest::getVar('theme'); } // Legacy fix if ($currentTheme == 'hako - new') { $currentTheme = 'default'; } // @rule: Set the necessary parameters here. $rawParams = EBLOG_THEMES . DIRECTORY_SEPARATOR . $currentTheme . DIRECTORY_SEPARATOR . 'config.xml'; if (JFile::exists($rawParams) && !$this->dashboard) { $this->params = EasyBlogHelper::getRegistry(); // @task: Now we bind the default params $defaultParams = EBLOG_THEMES . DIRECTORY_SEPARATOR . $currentTheme . DIRECTORY_SEPARATOR . 'config.ini'; if (JFile::exists($defaultParams)) { $this->params->load(JFile::read($defaultParams)); } $themeConfig = $this->_getThemeConfig($currentTheme); // @task: Now we override it with the user saved params if (!empty($themeConfig->params)) { $extendObj = EasyBlogHelper::getRegistry($themeConfig->params); EasyBlogRegistryHelper::extend($this->params, $extendObj); } } //is blogger mode flag $obj->isBloggerMode = EasyBlogRouter::isBloggerMode(); $this->set('system', $obj); $this->acl = EasyBlogACLHelper::getRuleSet(); }
function getTeamBlogCount($catId) { $db = EasyBlogHelper::db(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $query = 'select count(1) from `#__easyblog_post` as a'; $query .= ' inner join `#__easyblog_category` as b'; $query .= ' on a.`category_id` = b.`id`'; $query .= ' and b.`id` = ' . $db->Quote($catId); $query .= ' inner join `#__easyblog_team_post` as c'; $query .= ' on a.`id` = c.`post_id`'; $query .= ' where a.`issitewide` = ' . $db->Quote('0'); if ($isBloggerMode !== false) { $query .= ' and a.`created_by` = ' . $db->Quote($isBloggerMode); } $db->setQuery($query); $result = $db->loadResult(); return empty($result) ? '0' : $result; }
/** * Retrieves a list of blog posts associated with a particular tag * * @since 5.0 * @access public * @param string * @return */ public function getTaggedBlogs($tagId = 0, $limit = false, $includeCatIds = '', $sorting = '') { if (!$tagId) { return false; } $my = JFactory::getUser(); $db = EB::db(); $config = EasyBlogHelper::getConfig(); $catAccess = array(); if ($limit === false) { if ($config->get('layout_listlength') == 0) { $limit = $this->getState('limit'); } else { $limit = $config->get('layout_listlength'); } } $limitstart = $this->getState('limitstart'); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $queryExclude = ''; $excludeCats = array(); $isJSGrpPluginInstalled = false; $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog'); $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog'); $isJSInstalled = false; if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php')) { $isJSInstalled = true; } $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false; $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false; $jsGrpPostIds = ''; $jsEventPostIds = ''; // contribution type sql $contributor = EB::contributor(); $contributeSQL = ' AND ( (b.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') '; if ($config->get('main_includeteamblogpost')) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'b'); } if ($includeJSEvent) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'b'); } if ($includeJSGrp) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'b'); } if (EB::easysocial()->exists()) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'b'); $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'b'); } $contributeSQL .= ')'; //get teamblogs id. $query = 'SELECT b.*'; $query .= ' FROM ' . $db->nameQuote('#__easyblog_post_tag') . ' AS a '; $query .= ' INNER JOIN ' . $db->nameQuote('#__easyblog_post') . ' AS b '; $query .= ' ON a.post_id=b.id '; $query .= ' WHERE a.' . $db->quoteName('tag_id') . ' = ' . $db->Quote($tagId); $query .= ' AND b.' . $db->quoteName('published') . ' = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query .= ' AND b.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL); $query .= $contributeSQL; // @rule: When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $query .= EBR::getLanguageQuery('AND', 'b.language'); } $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; //blog privacy setting if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) { require_once $file; $jsFriends = CFactory::getModel('Friends'); $friends = $jsFriends->getFriendIds($my->id); array_push($friends, $my->id); // Insert query here. $query .= ' AND ('; $query .= ' (b.`access`= 0 ) OR'; $query .= ' ( (b.`access` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR'; if (empty($friends)) { $query .= ' ( (b.`access` = 30) AND ( 1 = 2 ) ) OR'; } else { $query .= ' ( (b.`access` = 30) AND ( b.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $query .= ' ( (b.`access` = 40) AND ( b.' . $db->nameQuote('created_by') . '=' . $my->id . ') )'; $query .= ' )'; } else { if ($my->id == 0) { $query .= ' AND b.`access` = ' . $db->Quote(BLOG_PRIVACY_PUBLIC); } } if ($isBloggerMode !== false) { $query .= ' AND b.`created_by` = ' . $db->Quote($isBloggerMode); } $includeCats = array(); $includeCatIds = trim($includeCatIds); if (!empty($includeCatIds)) { $includeCats = explode(',', $includeCatIds); if (!empty($includeCats)) { $catAccess['include'] = $includeCats; } } // category access $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('b.`id`', $catAccess); $query .= ' AND (' . $catAccessSQL . ')'; $sort = $config->get('layout_postorder', 'latest'); $defaultSorting = $config->get('layout_postsort', 'desc'); if ($sorting) { $defaultSorting = $sorting; } switch ($sort) { case 'latest': $queryOrder = ' ORDER BY b.`created` ' . $defaultSorting; break; case 'published': $queryOrder = ' ORDER BY b.`publish_up` ' . $defaultSorting; break; case 'popular': $queryOrder = ' ORDER BY b.`hits` ' . $defaultSorting; break; case 'active': $queryOrder = ' ORDER BY b.`publish_down` ' . $defaultSorting; break; case 'alphabet': $queryOrder = ' ORDER BY b.`title` ' . $defaultSorting; break; case 'modified': $queryOrder = ' ORDER BY b.`modified` ' . $defaultSorting; break; case 'random': $queryOrder = ' ORDER BY RAND() '; break; default: break; } $query .= $queryOrder; //total tag's post sql $totalQuery = 'SELECT COUNT(1) FROM ('; $totalQuery .= $query; $totalQuery .= ') as x'; $query .= ' LIMIT ' . $limitstart . ',' . $limit; $db->setQuery($query); $rows = $db->loadObjectList(); $db->setQuery($totalQuery); $db->loadResult(); $this->_total = $db->loadResult(); jimport('joomla.html.pagination'); $this->_pagination = EB::pagination($this->_total, $limitstart, $limit); return $rows; }
public static function getBloggerTheme() { $id = EasyBlogRouter::isBloggerMode(); if (empty($id)) { return false; } $profile = EB::user($id); $userparams = EB::registry($profile->params); return $userparams->get('theme', false); }
function _buildQuery() { $db = EasyBlogHelper::db(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $where = array(); $where2 = array(); $text = JRequest::getVar('query'); $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false); $where[] = 'a.`title` LIKE ' . $word; $where[] = 'a.`content` LIKE ' . $word; $where[] = 'a.`intro` LIKE ' . $word; $where2[] = 't.title LIKE ' . $word; $wheres2[] = implode(' OR ', $where2); $wheres[] = implode(' OR ', $where); } $where = '(' . implode(') OR (', $wheres) . ')'; $where2 = '(' . implode(') OR (', $wheres2) . ')'; //get teamblogs id. $teamBlogIds = ''; $query = ''; if ($config->get('main_includeteamblogpost')) { $teamBlogIds = EasyBlogHelper::getViewableTeamIds(); if (count($teamBlogIds) > 0) { $teamBlogIds = implode(',', $teamBlogIds); } } // get all private categories id $excludeCats = EasyBlogHelper::getPrivateCategories(); if (!empty($excludeCats)) { $queryWhere .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')'; } $jsPostIds = self::getJomSocialPosts(); if ($config->get('main_includeteamblogpost') && !empty($teamBlogIds)) { if (!empty($jsPostIds)) { $tmpIds = implode(',', $jsPostIds); $queryWhere .= ' AND (u.team_id IN (' . $teamBlogIds . ') OR a.id IN (' . $tmpIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')'; } else { $queryWhere .= ' AND (u.team_id IN (' . $teamBlogIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')'; } } else { if (!empty($jsPostIds)) { $tmpIds = implode(',', $jsPostIds); $queryWhere .= ' AND (a.id IN (' . $tmpIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')'; } else { $queryWhere .= ' AND a.`issitewide` = ' . $db->Quote('1'); } } if ($isBloggerMode) { $queryWhere .= ' AND a.`created_by`=' . $db->Quote($isBloggerMode); } $query = 'SELECT a.*, b.`title` AS `category` , CONCAT(a.`content` , a.`intro`) AS text'; $query .= ' FROM `#__easyblog_post` as a USE INDEX (`easyblog_post_search`)'; if ($config->get('main_includeteamblogpost')) { $query .= ' LEFT JOIN `#__easyblog_team_post` AS u ON a.id = u.post_id'; } $query .= ' LEFT JOIN `#__easyblog_category` AS b'; $query .= ' ON a.category_id = b.id'; // Always inner join with jos_users and a.created_by so that only valid blogs are loaded $query .= ' INNER JOIN ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__users') . ' AS c ON a.`created_by`=c.`id`'; $query .= ' WHERE (' . $where; $query .= ' OR a.`id` IN( '; $query .= ' SELECT tp.`post_id` FROM `#__easyblog_tag` AS t '; $query .= ' INNER JOIN `#__easyblog_post_tag` AS tp ON tp.`tag_id` = t.`id` '; $query .= ' WHERE ' . $where2; $query .= ') )'; if ($my->id < 1) { //guest should only see public post. $query .= ' AND a.`private` = ' . $db->Quote('0'); } //do not show unpublished post $query .= ' AND a.`published` = ' . $db->Quote('1'); $query .= $queryWhere; $query .= ' ORDER BY a.`created` DESC'; // echo $query; return $query; }
public function getArchive($archiveYear, $archiveMonth, $archiveDay = '') { $db = EB::db(); $my = JFactory::getUser(); $config = EB::config(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $excludeCats = array(); $teamBlogIds = ''; $queryExclude = ''; $queryInclude = ''; $catAccess = array(); $modCid = JRequest::getVar('modCid', array()); //where $queryWhere = ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $queryWhere = ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL); $isJSGrpPluginInstalled = false; $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog'); $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog'); $isJSInstalled = false; // need to check if the site installed jomsocial. if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php')) { $isJSInstalled = true; } $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false; $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false; // contribution type sql $contributor = EB::contributor(); $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') '; if ($config->get('main_includeteamblogpost')) { $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'); } $contributeSQL .= ')'; $queryWhere .= $contributeSQL; //get teamblogs id. $query = ''; if (!empty($modCid)) { $catAccess['include'] = $modCid; } //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() && !EB::isSiteAdmin()) { $esPrivacyQuery = $easysocial->buildPrivacyQuery('a'); $queryWhere .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EB::isSiteAdmin()) { require_once $file; $my = JFactory::getUser(); $jsFriends = CFactory::getModel('Friends'); $friends = $jsFriends->getFriendIds($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 (empty($archiveDay)) { $fromDate = $archiveYear . '-' . $archiveMonth . '-01 00:00:00'; $toDate = $archiveYear . '-' . $archiveMonth . '-31 23:59:59'; } else { $fromDate = $archiveYear . '-' . $archiveMonth . '-' . $archiveDay . ' 00:00:00'; $toDate = $archiveYear . '-' . $archiveMonth . '-' . $archiveDay . ' 23:59:59'; } // When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $queryWhere .= EBR::getLanguageQuery('AND', 'a.language'); } $tzoffset = EB::date()->getOffSet(true); $queryWhere .= ' AND ( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) >= ' . $db->Quote($fromDate) . ' AND DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) <= ' . $db->Quote($toDate) . ' ) '; if ($isBloggerMode !== false) { $queryWhere .= ' AND a.`created_by` = ' . $db->Quote($isBloggerMode); } // category access here //category access $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess); $queryWhere .= ' AND (' . $catAccessSQL . ')'; //ordering $queryOrder = ' ORDER BY a.`created` DESC'; //limit $limit = $this->getState('limit'); $limitstart = $this->getState('limitstart'); $queryLimit = ' LIMIT ' . $limitstart . ',' . $limit; //set pagination $query = 'SELECT COUNT(1) FROM `#__easyblog_post` AS a'; $query .= $queryWhere; $db->setQuery($query); $this->_total = $db->loadResult(); jimport('joomla.html.pagination'); $this->_pagination = EB::pagination($this->_total, $limitstart, $limit); //get archive $query = 'SELECT a.*'; $query .= ' FROM `#__easyblog_post` AS a'; $query .= $queryWhere; $query .= $queryExclude; $query .= $queryInclude; $query .= $queryOrder; $query .= $queryLimit; $db->setQuery($query); if ($db->getErrorNum() > 0) { JError::raiseError($db->getErrorNum(), $db->getErrorMsg() . $db->stderr()); } $result = $db->loadObjectList(); return $result; }
/** * Retrieve a list of blog posts from a specific list of categories * * @since 4.0 * @access public * @param string * @return */ public function getPosts($categories, $limit = null) { $db = EB::db(); $my = JFactory::getUser(); $config = EB::config(); // Determines if this is currently on blogger mode $isBloggerMode = EasyBlogRouter::isBloggerMode(); // use in generating category access sql $catAccess = array(); $catAccess['include'] = $categories; $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 ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') '; if ($config->get('main_includeteamblogpost')) { $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'); } // Test if easysocial exists on the site if (EB::easysocial()->exists()) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a'); $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a'); } $contributeSQL .= ')'; $query = array(); $query[] = 'SELECT a.* FROM ' . $db->quoteName('#__easyblog_post') . ' AS a'; // Build the WHERE clauses $query[] = 'WHERE a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query[] = 'AND a.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL); // If this is on blogger mode, fetch items created by the current author only if ($isBloggerMode !== false) { $query[] = ' AND a.' . $db->quoteName('created_by') . '=' . $db->Quote($isBloggerMode); } else { // Get the author id based on the category menu $authorId = EB::getCategoryMenuBloggerId(); if ($authorId) { $query[] = ' AND a.' . $db->quoteName('created_by') . '=' . $db->Quote($authorId); } } //sql for blog contribution $query[] = $contributeSQL; // sql for category access $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess); $query[] = 'AND (' . $catAccessSQL . ')'; // If user is a guest, ensure that they can really view the blog post if ($this->my->guest) { $query[] = 'AND a.' . $db->quoteName('access') . '=' . $db->Quote(BLOG_PRIVACY_PUBLIC); } // Ensure that the blog posts is available site wide // $query[] = 'AND a.' . $db->quoteName('source_id') . '=' . $db->Quote('0'); // Filter by language $language = EB::getCurrentLanguage(); if ($language) { $query[] = 'AND (a.' . $db->quoteName('language') . '=' . $db->Quote($language) . ' OR a.' . $db->quoteName('language') . '=' . $db->Quote('*') . ' OR a.' . $db->quoteName('language') . '=' . $db->Quote('') . ')'; } // Ordering options $ordering = $config->get('layout_postsort', 'DESC'); // Order the posts $query[] = 'ORDER BY a.' . $db->quoteName('created') . ' ' . $ordering; // Set the pagination if (!is_null($limit)) { // Glue back the sql queries into a single string. $queryCount = implode(' ', $query); $queryCount = str_ireplace('SELECT a.*', 'SELECT COUNT(1)', $queryCount); $db->setQuery($queryCount); $count = $db->loadResult(); $limit = $limit == 0 ? $this->getState('limit') : $limit; $limitstart = $this->input->get('limitstart', $this->getState('limitstart'), 'int'); // Set the limit $query[] = 'LIMIT ' . $limitstart . ',' . $limit; $this->_pagination = EB::pagination($count, $limitstart, $limit); } // Glue back the sql queries into a single string. $query = implode(' ', $query); // Debug // 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; }
/** * ********************************************************************* * These part of codes will used in tag clod tags. * ********************************************************************* */ function getTagPrivateBlogCount($tagId) { $db = EasyBlogHelper::db(); $queryExclude = ''; $excludeCats = array(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); // get all private categories id $excludeCats = EasyBlogHelper::getPrivateCategories(); if (!empty($excludeCats)) { $queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')'; } $query = 'select count(1) from `#__easyblog_post` as a'; $query .= ' inner join `#__easyblog_post_tag` as b'; $query .= ' on a.`id` = b.`post_id`'; $query .= ' and b.`tag_id` = ' . $db->Quote($tagId); $query .= ' where a.`private` = ' . $db->Quote(BLOG_PRIVACY_PRIVATE); if ($isBloggerMode !== false) { $query .= ' and a.`created_by` = ' . $db->Quote($isBloggerMode); } $query .= $queryExclude; $db->setQuery($query); $result = $db->loadResult(); return empty($result) ? '0' : $result; }
public static function getBloggerTheme() { $id = EasyBlogRouter::isBloggerMode(); if (empty($id)) { return false; } $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($id); $userparams = EasyBlogHelper::getRegistry($profile->params); return $userparams->get('theme', false); }
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; }
function getArchivePostByMonth($month = '', $year = '', $showPrivate = false) { $db = EasyBlogHelper::db(); $user = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); if ($user->id == 0) { $showPrivate = false; } if (!$showPrivate) { $excludeCats = EasyBlogHelper::getPrivateCategories(); } //blog privacy setting // @integrations: jomsocial privacy $privateBlog = ''; $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_privacy') && $easysocial->exists() && !EasyBlogHelper::isSiteAdmin()) { $esPrivacyQuery = $easysocial->buildPrivacyQuery('a'); $privateBlog .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) { require_once $file; $jsFriends = CFactory::getModel('Friends'); $friends = $jsFriends->getFriendIds($user->id); // Insert query here. $privateBlog .= ' AND ('; $privateBlog .= ' (a.`private`= 0 ) OR'; $privateBlog .= ' ( (a.`private` = 20) AND (' . $db->Quote($user->id) . ' > 0 ) ) OR'; if (empty($friends)) { $privateBlog .= ' ( (a.`private` = 30) AND ( 1 = 2 ) ) OR'; } else { $privateBlog .= ' ( (a.`private` = 30) AND ( a.' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $privateBlog .= ' ( (a.`private` = 40) AND ( a.' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . '=' . $user->id . ') )'; $privateBlog .= ' )'; } else { if ($user->id == 0) { $privateBlog .= ' AND a.`private` = ' . $db->Quote(0); } } } $privateBlog = $showPrivate ? '' : $privateBlog; //get teamblogs id. $teamBlogIds = ''; $query = ''; if ($config->get('main_includeteamblogpost')) { $teamBlogIds = EasyBlogHelper::getViewableTeamIds(); if (count($teamBlogIds) > 0) { $teamBlogIds = implode(',', $teamBlogIds); } } if (!empty($excludeCats)) { $queryWhere .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')'; } $jsPostIds = self::getJomSocialPosts(); if ($config->get('main_includeteamblogpost') && !empty($teamBlogIds)) { if (!empty($jsPostIds)) { $tmpIds = implode(',', $jsPostIds); $queryWhere .= ' AND (u.team_id IN (' . $teamBlogIds . ') OR a.id IN (' . $tmpIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')'; } else { $queryWhere .= ' AND (u.team_id IN (' . $teamBlogIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')'; } } else { if (!empty($jsPostIds)) { $tmpIds = implode(',', $jsPostIds); $queryWhere .= ' AND (a.id IN (' . $tmpIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')'; } else { $queryWhere .= ' AND a.`issitewide` = ' . $db->Quote('1'); } } $extraSQL = ''; $blogger = EasyBlogRouter::isBloggerMode(); if ($blogger !== false) { $extraSQL = ' AND a.`created_by` = ' . $db->Quote($blogger); } $tzoffset = EasyBlogDateHelper::getOffSet(true); $query = 'SELECT *, DAY( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS day,'; $query .= ' MONTH( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS month,'; $query .= ' YEAR( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS year '; $query .= ' FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post') . ' as a'; if ($config->get('main_includeteamblogpost')) { $query .= ' LEFT JOIN `#__easyblog_team_post` AS u ON a.id = u.post_id'; } $query .= ' WHERE a.`published` = ' . $db->Quote(true) . ' '; $query .= $privateBlog . ' '; $query .= ' AND (a.`created` > ' . $db->Quote($year . '-' . $month . '-01 00:00:00') . ' AND a.`created` < ' . $db->Quote($year . '-' . $month . '-31 23:59:59') . ') '; $query .= $extraSQL . ' '; $query .= $queryWhere; $query .= ' ORDER BY a.`created` ASC '; $db->setQuery($query); $row = $db->loadObjectList(); $postCount = new EasyblogCalendarObject($month, $year); if (!empty($row)) { foreach ($row as $data) { if ($postCount->{$year}->{$month}->{$data->day} == 0) { $postCount->{$year}->{$month}->{$data->day} = array($data); } else { array_push($postCount->{$year}->{$month}->{$data->day}, $data); } } } return $postCount; }
public static function _($url, $xhtml = true, $ssl = null, $search = false, $isCanonical = false) { $mainframe = JFactory::getApplication(); $config = EasyBlogHelper::getConfig(); static $loaded = array(); static $eUri = array(); $useXHTML = (int) $xhtml . (int) $isCanonical; if (isset($loaded[$url . $useXHTML])) { return $loaded[$url . $useXHTML]; } $rawURL = $url; $blogger = JRequest::getVar('blogger', ''); if (!empty($blogger)) { $url .= '&blogger=' . $blogger; } //$jURL = JRoute::_($url, false); $jURL = $url; // convert the string to variable so that we can access it. parse_str($jURL, $post); $view = isset($post['view']) ? $post['view'] : 'latest'; $Itemid = isset($post['Itemid']) ? $post['Itemid'] : ''; $routingBehavior = $config->get('main_routing', 'currentactive'); $exItemid = ''; $findItemId = false; $dropSegment = false; if (($routingBehavior == 'currentactive' || $routingBehavior == 'menuitemid') && !$isCanonical) { $routingMenuItem = $config->get('main_routing_itemid', ''); if ($routingBehavior == 'menuitemid' && $routingMenuItem != '') { $exItemid = $routingMenuItem; } // @rule: If there is already an item id, try to use the explicitly set one. if (empty($exItemid)) { if ($view == 'entry') { $blogId = $post['id']; $blog = EasyBlogHelper::getTable('Blog', 'Table'); $blog->load($blogId); $author = $blog->created_by; if (!empty($author)) { $tmpItemid = EasyBlogRouter::getItemIdByBlogger($author); if (!empty($tmpItemid)) { $isBloggerMode = EasyBlogRouter::isMenuABloggerMode($tmpItemid); if ($isBloggerMode) { $exItemid = $tmpItemid; } } } } // @rule: If it is not a blogger mode, we just use the current one. if (!$mainframe->isAdmin()) { // Retrieve the active menu item. $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); if (isset($item->id)) { $isBloggerMode = EasyBlogRouter::isMenuABloggerMode($item->id); if (!$isBloggerMode) { $exItemid = $item->id; } } } } } else { switch ($view) { case 'entry': $routingOrder = EasyBlogRouter::getDefaultRoutingOrder(); $exItemid = ''; if (!empty($routingOrder)) { $blogId = $post['id']; $blog = EasyBlogHelper::getTable('Blog', 'Table'); $blog->load($blogId); $authorId = $blog->created_by; $categoryId = $blog->category_id; foreach ($routingOrder as $key => $val) { switch ($key) { case 'bloggerstandalone': $bloggerId = EasyBlogRouter::isBloggerMode(); if ($bloggerId !== false) { $exItemid = EasyBlogRouter::getItemIdByBlogger($bloggerId); } break; case 'entry': $exItemid = EasyBlogRouter::getItemIdByEntry($blogId); break; case 'category': $exItemid = EasyBlogRouter::getItemIdByCategories($categoryId); break; case 'blogger': $exItemid = EasyBlogRouter::getItemIdByBlogger($authorId); break; case 'teamblog': $teamId = $blog->getTeamContributed(); if (!empty($teamId)) { $exItemid = EasyBlogRouter::getItemIdByTeamBlog($teamId); } break; } if (!empty($exItemid)) { break; } } } if (empty($exItemid)) { $view = 'latest'; $findItemId = true; } break; case 'blogger': //if( isset( $post['layout'] ) && isset( $post['id'] ) ) if (isset($post['id'])) { $exItemid = EasyBlogRouter::getItemIdByBlogger($post['id']); if (!empty($exItemid)) { $dropSegment = true; } } if (empty($exItemid)) { $exItemid = EasyBlogRouter::getItemId('blogger', true); } if (empty($exItemid)) { $view = 'latest'; $findItemId = true; } break; case 'categories': //if( isset( $post['layout'] ) && isset( $post['id'] ) ) if (isset($post['id'])) { $exItemid = EasyBlogRouter::getItemIdByCategories($post['id']); if (!empty($exItemid)) { $dropSegment = true; } } if (empty($exItemid)) { $bloggerId = EasyBlogRouter::isBloggerMode(); if ($bloggerId !== false) { $exItemid = EasyBlogRouter::getItemIdByBlogger($bloggerId); } if (empty($exItemid)) { $exItemid = EasyBlogRouter::getItemId('categories', true); } if (empty($exItemid)) { $view = 'latest'; $findItemId = true; } } break; case 'teamblog': //if( isset( $post['layout'] ) && isset( $post['id'] ) ) if (isset($post['id'])) { $exItemid = EasyBlogRouter::getItemIdByTeamBlog($post['id']); if (!empty($exItemid)) { $dropSegment = true; } } if (empty($exItemid)) { $exItemid = EasyBlogRouter::getItemId('teamblog', true); } if (empty($exItemid)) { $view = 'latest'; $findItemId = true; } break; case 'tags': if (isset($post['layout']) && isset($post['id'])) { //now check the active menu whether a blogger isolation mode or not. $bloggerId = EasyBlogRouter::isBloggerMode(); if ($bloggerId !== false) { $exItemid = EasyBlogRouter::getItemIdByBlogger($bloggerId); } if (empty($exItemid)) { $exItemid = EasyBlogRouter::getItemIdByTag($post['id']); if (!empty($exItemid)) { $dropSegment = true; } } } else { $exItemid = EasyBlogRouter::getItemId('tags'); } if (empty($exItemid)) { $view = 'latest'; $findItemId = true; } break; case 'dashboard': if (isset($post['layout'])) { $exItemid = EasyBlogRouter::getItemIdByDashboardLayout($post['layout']); } if (empty($exItemid)) { $exItemid = EasyBlogRouter::getItemId('dashboard', true); } if (empty($exItemid)) { $findItemId = true; } break; case 'latest': $bloggerId = EasyBlogRouter::isBloggerMode(); if ($bloggerId !== false) { $exItemid = EasyBlogRouter::getItemIdByBlogger($bloggerId); } if (empty($exItemid)) { $exItemid = EasyBlogRouter::getItemId('latest'); } if (empty($exItemid)) { $findItemId = true; } break; default: break; } } if (!empty($exItemid)) { if (self::isSefEnabled() && $dropSegment) { $url = 'index.php?Itemid=' . $exItemid; $loaded[$rawURL . $useXHTML] = JRoute::_($url, $xhtml, $ssl); return $loaded[$rawURL . $useXHTML]; } //check if there is any anchor in the link or not. $pos = JString::strpos($url, '#'); // If item id is provided in the query itself, we do not need to append any item id. // otherwise the result would be &Itemid=1&Itemid=2 if (!$Itemid) { if ($pos === false) { $url .= '&Itemid=' . $exItemid; } else { $url = JString::str_ireplace('#', '&Itemid=' . $exItemid . '#', $url); } } $loaded[$rawURL . $useXHTML] = JRoute::_($url, $xhtml, $ssl); return $loaded[$rawURL . $useXHTML]; } //fall back to previous style if getting the Itemid if (empty($Itemid) && $findItemId) { $tmpId = ''; $useDefaultWay = false; if ($mainframe->isAdmin()) { //from backend. $useDefaultWay = true; } else { //from frontend. //lets try to get from the default itemId. $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); if (!$findItemId && isset($item->id) && $item->component == 'com_easyblog' && !$search) { $tmpId = $item->id; } else { $useDefaultWay = true; } } if ($useDefaultWay) { if (empty($eUri[$view])) { $tmpId = EasyBlogRouter::getItemId($view); $eUri[$view] = $tmpId; } else { $tmpId = $eUri[$view]; } } //check if there is any anchor in the link or not. $pos = JString::strpos($url, '#'); if ($pos === false) { $url .= '&Itemid=' . $tmpId; } else { $url = JString::str_ireplace('#', '&Itemid=' . $tmpId . '#', $url); } } $loaded[$rawURL . $useXHTML] = JRoute::_($url, $xhtml, $ssl); return $loaded[$rawURL . $useXHTML]; }
public function _buildQuery() { $db = EB::db(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $where = array(); $where2 = array(); $text = JRequest::getVar('query'); $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false); $where[] = 'a.`title` LIKE ' . $word; $where[] = 'a.`content` LIKE ' . $word; $where[] = 'a.`intro` LIKE ' . $word; $where2[] = 't.title LIKE ' . $word; $wheres2[] = implode(' OR ', $where2); $wheres[] = implode(' OR ', $where); } $where = '(' . implode(') OR (', $wheres) . ')'; $where2 = '(' . implode(') OR (', $wheres2) . ')'; $isJSGrpPluginInstalled = false; $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog'); $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog'); $isJSInstalled = false; // need to check if the site installed jomsocial. if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php')) { $isJSInstalled = true; } $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false; $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false; $query = ''; // contribution type sql $contributor = EB::contributor(); $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') '; if ($config->get('main_includeteamblogpost')) { $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'); } if (EB::easysocial()->exists()) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a'); $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a'); } $contributeSQL .= ')'; $queryWhere .= $contributeSQL; // category access here $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $queryWhere .= ' AND (' . $catAccessSQL . ')'; if ($isBloggerMode) { $queryWhere .= ' AND a.`created_by`=' . $db->Quote($isBloggerMode); } $query = 'SELECT a.*, CONCAT(a.`content` , a.`intro`) AS text'; $query .= ' FROM `#__easyblog_post` as a USE INDEX (`easyblog_post_searchnew`)'; // Always inner join with jos_users and a.created_by so that only valid blogs are loaded $query .= ' INNER JOIN ' . $db->nameQuote('#__users') . ' AS c ON a.`created_by`=c.`id`'; $query .= ' WHERE (' . $where; $query .= ' OR a.`id` IN( '; $query .= ' SELECT tp.`post_id` FROM `#__easyblog_tag` AS t '; $query .= ' INNER JOIN `#__easyblog_post_tag` AS tp ON tp.`tag_id` = t.`id` '; $query .= ' WHERE ' . $where2; $query .= ') )'; //blog privacy setting // @integrations: jomsocial privacy $privateBlog = ''; $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_privacy') && $easysocial->exists() && !EasyBlogHelper::isSiteAdmin()) { $esPrivacyQuery = $easysocial->buildPrivacyQuery('a'); $privateBlog .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) { require_once $file; $jsFriends = CFactory::getModel('Friends'); $friends = $jsFriends->getFriendIds($my->id); // Insert query here. $privateBlog .= ' AND ('; $privateBlog .= ' (a.`access`= 0 ) OR'; $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR'; if (empty($friends)) { $privateBlog .= ' ( (a.`access` = 30) AND ( 1 = 2 ) ) OR'; } else { $privateBlog .= ' ( (a.`access` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $privateBlog .= ' ( (a.`access` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $my->id . ') )'; $privateBlog .= ' )'; } else { if ($my->id == 0) { $privateBlog .= ' AND a.`access` = ' . $db->Quote(0); } } } if ($privateBlog) { $query .= $privateBlog; } //do not show unpublished post $query .= ' AND a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query .= ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL); $query .= $queryWhere; $query .= ' ORDER BY a.`created` DESC'; // echo $query; return $query; }
<?php /** * @package EasyBlog * @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved. * @license GNU/GPL, see LICENSE.php * EasyBlog is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Restricted access'); $acl = EasyBlogACLHelper::getRuleSet(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $itemid = JRequest::getVar('Itemid', ''); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getItem($itemid); $params = EasyBlogHelper::getRegistry(); if ($item) { $params->load($item->params); } if ($system->config->get('layout_responsive')) { ?> <script type="text/javascript"> EasyBlog.require() .script('layout/responsive') .done(function($){ $('#ezblog-head #ezblog-search').bind('focus', function(){ $(this).animate({ width: '170'} );
/** * ********************************************************************* * These part of codes will used in tag clod tags. * ********************************************************************* */ public function getTagPrivateBlogCount($tagId) { $db = EB::db(); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $query = 'select count(1) from `#__easyblog_post` as a'; $query .= ' inner join `#__easyblog_post_tag` as b'; $query .= ' on a.`id` = b.`post_id`'; $query .= ' and b.`tag_id` = ' . $db->Quote($tagId); $query .= ' where a.`access` = ' . $db->Quote(BLOG_PRIVACY_PRIVATE); if ($isBloggerMode !== false) { $query .= ' and a.`created_by` = ' . $db->Quote($isBloggerMode); } // category access here $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $query .= ' AND (' . $catAccessSQL . ')'; $db->setQuery($query); $result = $db->loadResult(); return empty($result) ? '0' : $result; }
/** * Method to retrieve blog posts based on the given tag id. * * @access public * @param int $tagId The tag id. * @return array $rows An array of blog objects. */ function getTaggedBlogs($tagId = 0, $limit = false, $includeCatIds = '') { if ($tagId == 0) { return false; } $my = JFactory::getUser(); $db = EasyBlogHelper::db(); $config = EasyBlogHelper::getConfig(); if ($limit === false) { if ($config->get('layout_listlength') == 0) { $limit = $this->getState('limit'); } else { $limit = $config->get('layout_listlength'); } } $limitstart = $this->getState('limitstart'); $isBloggerMode = EasyBlogRouter::isBloggerMode(); $queryExclude = ''; $excludeCats = array(); $isJSGrpPluginInstalled = false; $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog'); $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog'); $isJSInstalled = false; // need to check if the site installed jomsocial. if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php')) { $isJSInstalled = true; } $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false; $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false; $jsGrpPostIds = ''; $jsEventPostIds = ''; if ($includeJSEvent) { $queryEvent = 'SELECT ' . EasyBlogHelper::getHelper('SQL')->nameQuote('post_id') . ' FROM'; $queryEvent .= ' ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_external') . ' AS ' . EasyBlogHelper::getHelper('SQL')->nameQuote('a'); $queryEvent .= ' INNER JOIN' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__community_events') . ' AS ' . EasyBlogHelper::getHelper('SQL')->nameQuote('b'); $queryEvent .= ' ON ' . EasyBlogHelper::getHelper('SQL')->nameQuote('a') . '.uid = ' . EasyBlogHelper::getHelper('SQL')->nameQuote('b') . '.id'; $queryEvent .= ' AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('a') . '.' . EasyBlogHelper::getHelper('SQL')->nameQuote('source') . '=' . $db->Quote('jomsocial.event'); $queryEvent .= ' WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('b') . '.' . EasyBlogHelper::getHelper('SQL')->nameQuote('permission') . '=' . $db->Quote(0); $db->setQuery($queryEvent); $jsEventPostIds = $db->loadResultArray(); if (!empty($excludeBlogs) && !empty($jsEventPostIds)) { $jsEventPostIds = array_diff($jsEventPostIds, $excludeBlogs); } } if ($includeJSGrp) { $queryJSGrp = 'select `post_id` from `#__easyblog_external_groups` as exg inner join `#__community_groups` as jsg'; $queryJSGrp .= ' on exg.group_id = jsg.id '; $queryJSGrp .= ' where jsg.`approvals` = 0'; $db->setQuery($queryJSGrp); $jsGrpPostIds = $db->loadResultArray(); if (!empty($excludeBlogs) && !empty($jsGrpPostIds)) { $jsGrpPostIds = array_diff($jsGrpPostIds, $excludeBlogs); } } //get teamblogs id. if ($config->get('main_includeteamblogpost')) { $teamBlogIds = EasyBlogHelper::getViewableTeamIds(); if (count($teamBlogIds) > 0) { $teamBlogIds = implode(',', $teamBlogIds); } } // get all private categories id $excludeCats = EasyBlogHelper::getPrivateCategories(); if (!empty($excludeCats)) { $queryExclude .= ' AND b.`category_id` NOT IN (' . implode(',', $excludeCats) . ')'; } $query = 'SELECT b.*, c.`title` as `category`'; if ($config->get('main_includeteamblogpost') && !empty($teamBlogIds)) { $query .= ' ,u.`team_id`'; } $query .= ' FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post_tag') . ' AS a '; $query .= ' INNER JOIN ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post') . ' AS b '; $query .= ' ON a.post_id=b.id '; $query .= ' LEFT JOIN `#__easyblog_category` AS c'; $query .= ' ON b.category_id = c.id'; if ($config->get('main_includeteamblogpost') && !empty($teamBlogIds)) { $query .= ' LEFT JOIN `#__easyblog_team_post` AS u ON b.id = u.post_id'; } $query .= ' WHERE a.tag_id = ' . $db->Quote($tagId); $query .= ' AND b.`published` = ' . $db->Quote('1'); if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { // @rule: When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $query .= ' AND ('; $query .= ' b.`language`=' . $db->Quote(JFactory::getLanguage()->getTag()); $query .= ' OR b.`language`=' . $db->Quote(''); $query .= ' OR b.`language`=' . $db->Quote('*'); $query .= ' )'; } } $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; //blog privacy setting if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) { require_once $file; $jsFriends = CFactory::getModel('Friends'); $friends = $jsFriends->getFriendIds($my->id); array_push($friends, $my->id); // Insert query here. $query .= ' AND ('; $query .= ' (b.`private`= 0 ) OR'; $query .= ' ( (b.`private` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR'; if (empty($friends)) { $query .= ' ( (b.`private` = 30) AND ( 1 = 2 ) ) OR'; } else { $query .= ' ( (b.`private` = 30) AND ( b.' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $query .= ' ( (b.`private` = 40) AND ( b.' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . '=' . $my->id . ') )'; $query .= ' )'; } else { if ($my->id == 0) { $query .= ' AND b.`private` = ' . $db->Quote(BLOG_PRIVACY_PUBLIC); } } if ($isBloggerMode !== false) { $query .= ' AND b.`created_by` = ' . $db->Quote($isBloggerMode); } // if( !empty( $jsGrpPostIds ) ) // { // $tmpIds = implode( ',', $jsGrpPostIds); // $query .= ' AND ( b.id IN (' . $tmpIds . ') OR b.`issitewide` = ' . $db->Quote('1') . ')'; // } $jsTmpIds = array(); if ($jsGrpPostIds) { $jsTmpIds = array_merge($jsGrpPostIds, $jsTmpIds); } if ($jsEventPostIds) { $jsTmpIds = array_merge($jsEventPostIds, $jsTmpIds); } if ($jsTmpIds) { $jsTmpIds = array_unique($jsTmpIds); $extmpIds = implode(',', $jsTmpIds); $query .= ' AND ( b.id IN (' . $extmpIds . ') OR b.`issitewide` = ' . $db->Quote('1') . ')'; } if ($config->get('main_includeteamblogpost') && (!empty($teamBlogIds) || !empty($jsTmpIds))) { $query .= ' AND ('; if (!empty($teamBlogIds)) { $query .= ' u.`team_id` IN (' . $teamBlogIds . ')'; } if ($jsTmpIds) { $extmpIds = implode(',', $jsTmpIds); $query .= $teamBlogIds ? ' OR' : ''; $query .= ' b.`id` IN(' . $extmpIds . ')'; } $query .= ' OR b.`issitewide`=' . $db->Quote(1); $query .= ')'; } else { $query .= ' AND b.`issitewide` = ' . $db->Quote('1'); } $includeCats = array(); $includeCatIds = trim($includeCatIds); if (!empty($includeCatIds)) { $includeCats = explode(',', $includeCatIds); if (!empty($excludeCats)) { $includeCats = array_diff($includeCats, $excludeCats); } if (!empty($includeCats)) { $query .= ' AND b.`category_id` IN (' . implode(',', $includeCats) . ')'; } } $query .= $queryExclude; //$query .= ' ORDER BY `created` DESC'; $sort = $config->get('layout_postorder', 'latest'); $defaultSorting = $config->get('layout_postsort', 'desc'); switch ($sort) { case 'latest': $queryOrder = ' ORDER BY b.`created` ' . $defaultSorting; break; case 'published': $queryOrder = ' ORDER BY b.`publish_up` ' . $defaultSorting; break; case 'popular': $queryOrder = ' ORDER BY b.`hits` ' . $defaultSorting; break; case 'active': $queryOrder = ' ORDER BY b.`publish_down` ' . $defaultSorting; break; case 'alphabet': $queryOrder = ' ORDER BY b.`title` ' . $defaultSorting; break; case 'modified': $queryOrder = ' ORDER BY b.`modified` ' . $defaultSorting; break; case 'random': $queryOrder = ' ORDER BY RAND() '; break; default: break; } $query .= $queryOrder; //total tag's post sql $totalQuery = 'SELECT COUNT(1) FROM ('; $totalQuery .= $query; $totalQuery .= ') as x'; $query .= ' LIMIT ' . $limitstart . ',' . $limit; $db->setQuery($query); $rows = $db->loadObjectList(); $db->setQuery($totalQuery); $db->loadResult(); $this->_total = $db->loadResult(); jimport('joomla.html.pagination'); $this->_pagination = EasyBlogHelper::getPagination($this->_total, $limitstart, $limit); return $rows; }