/** * Saves a new rating item * * @since 5.0 * @access public * @param string * @return */ public function store($updateNulls = false) { $config = EB::config(); $state = parent::store(); if ($this->type == 'entry' && $this->created_by) { // Load the post item $post = EB::post($this->uid); // Get the author of the post $author = $post->getAuthor(); // Get the link to the post $link = $post->getExternalPermalink(); // Notify EasySocial users that someone rated their post EB::easysocial()->notifySubscribers($post, 'ratings.add'); // Assign EasySocial points EB::easysocial()->assignPoints('blog.rate'); EB::easysocial()->assignPoints('blog.rated', $post->created_by); // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EB::easysocial()->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG')); // Assign points for AUP EB::aup()->assign('plgaup_easyblog_rate_blog', '', 'easyblog_rating', JText::_('COM_EASYBLOG_AUP_BLOG_RATED')); // Add notifications for EasyDiscuss // Add notifications // EB::jomsocial()->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', str_replace("administrator/","", $author->getProfileLink()), $author->getName() , $link , $blog->title), 'easyblog_new_blog' , $target , $author , $link); // Add notifications for easydiscuss if ($config->get('integrations_jomsocial_notification_rating')) { $target = array($post->created_by); EB::easydiscuss()->addNotification($post, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_RATING_FOR_YOUR_BLOG', $author->getName(), $post->title), EBLOG_NOTIFICATIONS_TYPE_RATING, array($post->created_by), $this->created_by, $link); } } return $state; }
public function getPermalink() { if (!EB::easysocial()->exists()) { return; } return $this->group->getPermalink(); }
/** * Determines if EasySocial integrations are available. * * @since 5.0 * @access public * @param string * @return */ public function exists() { $exists = EB::easysocial()->exists(); if ($exists) { return true; } return false; }
/** * Retrieves the profile link * * @since 5.0 * @access public * @param string * @return */ public function getLink() { if (!EB::easysocial()->exists()) { return parent::getLink(); } $user = FD::user($this->profile->id); $link = $user->getPermalink(); return $link; }
public function getAvatar($profile) { $easysocial = EB::easysocial(); if (!$easysocial->exists()) { return false; } // Load the user $user = Foundry::user($profile->id); return $user->getAvatar(); }
/** * Renders the output of the followers link * * @since 5.0 * @access public * @param string * @return */ public function html(EasyBlogTableProfile $profile) { // Initialize the scripts EB::easysocial()->init(); $user = FD::user($profile->id); $theme = EB::template(); $theme->set('user', $user); $html = $theme->output('site/easysocial/followers'); return $html; }
/** * Renders the html output for achievements * * @since 1.4 * @access public * @param string * @return */ public function html(EasyBlogTableProfile $profile) { // Ensure that EasySocial is initialized EB::easysocial()->init(); $user = FD::user($profile->id); $achievements = $user->getBadges(); $theme = EB::template(); $theme->set('achievements', $achievements); $html = $theme->output('site/easysocial/achievements'); return $html; }
/** * Displays the friend link for the author * * @since 5.0 * @access public * @param string * @return */ public function html(EasyBlogTableProfile $author) { // Do not display the link if the user is trying to view his own post if ($author->id == $this->my->id) { return; } if ($this->config->get('integrations_easysocial_friends')) { return EB::easysocial()->getFriendsHtml($author->id); } if ($this->config->get('main_jomsocial_friends')) { return EB::jomsocial()->getFriendsHtml($author->id); } return; }
/** * Displays the html code for sending a message to a friend * * @since 5.0 * @access public * @param string * @return */ public function html(EasyBlogTableProfile $author) { // Why would they want to send a message to themselves. if ($this->my->id == $author->id) { return; } // Ensure that JomSocial really exists if ($this->config->get('main_jomsocial_messaging') && EB::jomsocial()->exists()) { return EB::jomsocial()->getMessagingHtml($author->id); } // Ensure that JomSocial really exists if ($this->config->get('integrations_easysocial_conversations') && EB::easysocial()->exists()) { return EB::easysocial()->getMessagingHtml($author->id); } }
public function getHTML($bloggerid = "") { $config = EB::config(); $html = ''; $easysocial = EB::easysocial(); if ($config->get('integrations_easysocial_badges') && $easysocial->exists()) { $easysocial->init(); $user = Foundry::user($bloggerid); $badges = $user->getBadges(); $theme = EB::template(); $theme->set('badges', $badges); $html = $theme->output('site/easysocial/achievements'); } return $html; }
public function getResult($text, $phrase, $ordering) { $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $db = EasyBlogHelper::db(); $where = array(); $where2 = array(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); switch ($phrase) { case 'exact': $where[] = 'a.`title` LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false); $where[] = 'a.`content` LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false); $where[] = 'a.`intro` LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false); $where2 = '( t.title LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false) . ')'; $where = '(' . implode(') OR (', $where) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); $where2 = array(); $wheres2 = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->escape($word, true) . '%', false); $where[] = 'a.`title` LIKE ' . $word; $where[] = 'a.`content` LIKE ' . $word; $where[] = 'a.`intro` LIKE ' . $word; $where2[] = 't.title LIKE ' . $word; $wheres[] = implode(' OR ', $where); $wheres2[] = implode(' OR ', $where2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; $where2 = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres2) . ')'; break; } $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; //get teamblogs id. $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 . ')'; $query = 'SELECT a.*, CONCAT(a.`content` , a.`intro`) AS text , "2" as browsernav'; $query .= ' FROM `#__easyblog_post` as a USE INDEX (`easyblog_post_searchnew`) '; $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 .= '))'; $my = JFactory::getUser(); if ($my->id == 0) { //guest should only see public post. $query .= ' AND a.`access` = ' . $db->Quote('0'); } //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; switch ($ordering) { case 'oldest': $query .= ' ORDER BY a.`created` ASC'; break; case 'newest': $query .= ' ORDER BY a.`created` DESC'; break; } $db->setQuery($query); return $db->loadObjectList(); }
/** * Retrieve a list of places on the site. * * @since 5.0 * @access public * @param string * @return */ public static function getPlaces($user = null, EasyBlogPost $post = null) { $config = EB::config(); $acl = EB::acl(); // Get the current logged in user $my = JFactory::getUser($user); $places = array(); // Get the current post's folder $places[] = self::getPlace('post'); // All articles created by the author or admin $places[] = self::getPlace('posts'); // My Media $places[] = self::getPlace('user:'******'main_media_manager_place_shared_media') && $acl->get('media_places_shared')) { $places[] = self::getPlace('shared'); } // Flickr Integrations if ($config->get('layout_media_flickr') && $config->get('integrations_flickr_api_key') != '' && $config->get('integrations_flickr_secret_key') && $acl->get('media_places_flickr')) { $places[] = self::getPlace('flickr'); } // EasySocial if ($config->get('integrations_easysocial_album') && $acl->get('media_places_album') && EB::easysocial()->exists()) { $places[] = self::getPlace('easysocial'); } // JomSocial if ($config->get('integrations_jomsocial_album') && $acl->get('media_places_album') && EB::jomsocial()->exists()) { $places[] = self::getPlace('jomsocial'); } // If the user is allowed if (EB::isSiteAdmin()) { // All Users $places[] = self::getPlace('users'); } return $places; }
/** * Override parent's implementation of store * * @since 4.0 * @access public * @param string * @return */ public function store($updateNulls = false) { if (!$this->created) { $this->created = EB::date()->toSql(); } // Generate an alias if alias is empty if (!$this->alias) { $this->alias = EBR::normalizePermalink($this->title); } $my = JFactory::getUser(); // Add point integrations for new categories if ($this->id == 0 && $my->id > 0) { EB::loadLanguages(); // Integrations with EasyDiscuss EB::easydiscuss()->log('easyblog.new.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_CATEGORY', $this->title)); EB::easydiscuss()->addPoint('easyblog.new.category', $my->id); EB::easydiscuss()->addBadge('easyblog.new.category', $my->id); // AlphaUserPoints EB::aup()->assign('plgaup_easyblog_add_category', '', 'easyblog_add_category_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_CATEGORY_CREATED', $this->title)); // JomSocial integrations EB::jomsocial()->assignPoints('com_easyblog.category.add', $my->id); // Assign EasySocial points EB::easysocial()->assignPoints('category.create', $my->id); } // Figure out the proper nested set model if ($this->id == 0 && $this->lft == 0) { // No parent id, we use the current lft,rgt if ($this->parent_id) { $left = $this->getLeft($this->parent_id); $this->lft = $left; $this->rgt = $this->lft + 1; // Update parent's right $this->updateRight($left); $this->updateLeft($left); } else { $this->lft = $this->getLeft() + 1; $this->rgt = $this->lft + 1; } } if ($this->id == 0) { // new cats. we need to store the ordering. $this->ordering = $this->getOrdering($this->parent_id) + 1; } $isNew = !$this->id ? true : false; $state = parent::store(); return $state; }
/** * Retrieves the next post in line * * @since 5.0 * @access public * @param string * @return */ public function getPostNavigation(EasyBlogPost $post, $navigationType) { $db = EB::db(); $my = JFactory::getUser(); $config = EB::config(); $keys = array('prev', 'next'); $nav = new stdClass(); // Get the active menu $active = JFactory::getApplication()->getMenu()->getActive(); $catAccess = array(); $queryInclude = ''; $teamId = $post->getTeamAssociation(); $author = $post->getAuthor(); // // If there is an active menu for EasyBlog, check if there's any filtering by categories // if ($active) { // $cats = EB::getCategoryInclusion($active->params->get('inclusion')); // if ($cats && !is_array($cats)) { // $cats = array($cats); // } // $catAccess['include'] = $cats; // } // // sql for category access // $catLib = EB::category(); // $catAccessSQL = $catLib->genAccessSQL( 'a.`id`', $catAccess); foreach ($keys as $key) { $query = array(); $query[] = 'SELECT a.`id`, a.`title`'; $query[] = ' FROM `#__easyblog_post` AS `a`'; $query[] = ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query[] = ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL); // EasySocial integrations $query[] = EB::easysocial()->buildPrivacyQuery('a'); // Jomsocial integrations $query[] = EB::jomsocial()->buildPrivacyQuery(); // Blog privacy settings if ($my->guest) { $query[] = 'AND a.' . $db->qn('access') . '=' . $db->Quote(BLOG_PRIVACY_PUBLIC); } // Exclude private categories // $query[] = 'AND (' . $catAccessSQL . ')'; // If the current menu is blogger mode, we need to respect this by only loading author related items $isBloggerMode = EBR::isBloggerMode(); if ($isBloggerMode !== false) { $query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($isBloggerMode); $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // Filter the next / previous link by team if ($navigationType == 'team' && $teamId) { $query[] = 'AND (a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' AND a.' . $db->qn('source_id') . '=' . $db->Quote($teamId) . ')'; } // Filter the next / previous by author if ($navigationType == 'author') { $query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($author->id); $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // Filter the next / previous post items from site wide if ($navigationType == 'site') { $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $query[] = EBR::getLanguageQuery('AND', 'a.language'); } if ($key == 'prev') { $query[] = ' AND a.`created` < ' . $db->Quote($post->created); $query[] = ' ORDER BY a.`created` DESC'; } if ($key == 'next') { $query[] = ' AND a.`created` > ' . $db->Quote($post->created); $query[] = ' ORDER BY a.`created` ASC'; } $query[] = 'LIMIT 1'; $query = implode(' ', $query); $db->setQuery($query); $result = $db->loadObject(); $nav->{$key} = $result; } return $nav; }
/** * Overrides the parent's delete method * * @since 4.0 * @access public * @param string * @return */ public function delete($pk = null) { // Try to delete the comment item first $state = parent::delete($pk); // Get the current logged in user $my = JFactory::getUser(); // Remove comment's stream $this->removeStream(); if ($this->created_by != 0 && $this->published == '1') { // Get the blog post $post = $this->getBlog(); // Load language EB::loadLanguages(); $config = EB::config(); // Integrations with EasyDiscuss EB::easydiscuss()->log('easyblog.delete.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_COMMENT', $post->title)); EB::easydiscuss()->addPoint('easyblog.delete.comment', $this->created_by); EB::easydiscuss()->addBadge('easyblog.delete.comment', $this->created_by); // AlphaUserPoints EB::aup()->assign('plgaup_easyblog_delete_comment', $this->created_by, JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED')); // Assign EasySocial points EB::easysocial()->assignPoints('comments.remove', $this->created_by); // Deduct points from the comment author EB::jomsocial()->assignPoints('com_easyblog.comments.remove', $this->created_by); // Deduct points from the blog post author if ($my->id != $post->created_by) { // Deduct EasySocial points EB::easysocial()->assignPoints('comments.remove.author', $post->created_by); // JomSocial EB::jomsocial()->assignPoints('com_easyblog.comments.removeblogger', $post->created_by); // AUP EB::aup()->assignPoints('plgaup_easyblog_delete_comment_blogger', $post->created_by, JText::sprintf('COM_EASYBLOG_AUP_COMMENT_DELETED_BLOGGER', $url, $post->title)); } } return $state; }
/** * Retrieves a list of blog posts by specific month * * @since 5.0 * @access public * @param string * @return */ public function getArchivePostByMonth($month = '', $year = '', $showPrivate = false) { $db = EB::db(); $user = JFactory::getUser(); $config = EB::config(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); if ($user->id == 0) { $showPrivate = false; } // Blog privacy setting // @integrations: jomsocial privacy $privateBlog = ''; if (EB::easysocial()->exists() && $config->get('integrations_easysocial_privacy') && !EB::isSiteAdmin()) { $esPrivacyQuery = EB::easysocial()->buildPrivacyQuery('a'); $privateBlog .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && EB::jomsocial()->exists() && !EB::isSiteAdmin()) { $friendsModel = CFactory::getModel('Friends'); $friends = $friendsModel->getFriendIds($user->id); // Insert query here. $privateBlog .= ' AND ('; $privateBlog .= ' (a.`access`= 0 ) OR'; $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($user->id) . ' > 0 ) ) OR'; if (!$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') . '=' . $user->id . ') )'; $privateBlog .= ' )'; } else { if ($user->id == 0) { $privateBlog .= ' AND a.`access` = ' . $db->Quote(0); } } } // Join the query ? $privateBlog = $showPrivate ? '' : $privateBlog; $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'); } 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; //get teamblogs id. $query = ''; $extraSQL = ''; // If this is on blogger mode, we need to only pick items from the blogger. $blogger = EBR::isBloggerMode(); if ($blogger !== false) { $extraSQL = ' AND a.`created_by` = ' . $db->Quote($blogger); } $tzoffset = EB::date()->getOffSet(true); $query = 'SELECT a.*, 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 ' . $db->nameQuote('#__easyblog_post') . ' as a'; $query .= ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' '; $query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL) . ' '; $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') . ') '; // If do not display private posts, we need to append additional queries here. if (!$showPrivate) { // sql for category access $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $query .= ' AND (' . $catAccessSQL . ')'; } $query .= $extraSQL . ' '; $query .= $queryWhere; $query .= ' ORDER BY a.`created` ASC '; // echo $query;exit; $db->setQuery($query); $result = $db->loadObjectList(); $postCount = new EasyblogCalendarObject($month, $year); if (!empty($result)) { foreach ($result as $row) { $post = EB::post($row->id); // $post->bind($row); $post = EB::formatter('entry', $post); // var_dump($row);exit; if ($postCount->{$year}->{$month}->{$row->day} == 0) { $postCount->{$year}->{$month}->{$row->day} = array($post); } else { array_push($postCount->{$year}->{$month}->{$row->day}, $post); } } } return $postCount; }
/** * 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; }
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; }
/** * Renders a list of associates the author has to the site * * @since 5.0 * @access public * @param string * @return */ public function listAssociates() { // Associates may compromise of teams, groups, events etc. $associates = array('teams' => array(), 'events' => array(), 'groups' => array()); // @TODO: Check if the user is really allowed to use this if (!$this->my->id) { return $this->ajax->reject(JText::_('COM_EASYBLOG_NOT_ALLOWED')); } // Get a list of selected items $source_id = $this->input->get('source_id', 0, 'int'); $source_type = $this->input->get('source_type', '', 'default'); // List teams the user joined on the site $model = EB::model('TeamBlogs'); $teams = $model->getTeamJoined($this->my->id); if ($teams) { foreach ($teams as $team) { $obj = new stdClass(); $obj->title = $team->title; $obj->source_id = $team->id; $obj->source_type = EASYBLOG_POST_SOURCE_TEAM; $obj->type = 'team'; $obj->avatar = $team->getAvatar(); $associates['teams'][] = $obj; } } // EasySocial groups $groups = EB::easysocial()->getGroups(); $events = EB::easysocial()->getEvents(); // List groups the user joined on the site $groups = array_merge($groups, EB::jomsocial()->getGroups()); $events = array_merge($events, EB::jomsocial()->getEvents()); // Assign them into the main object. $associates['groups'] = $groups; $associates['events'] = $events; $template = EB::template(); $template->set('source_id', $source_id); $template->set('source_type', $source_type); $template->set('associates', $associates); $output = $template->output('site/composer/form/associates'); return $this->ajax->resolve($output); }
/** * Retrieves the comment block * * @since 4.0 * @access public * @param string * @return */ public function getCommentHTML(EasyBlogPost &$blog, $comments = array(), $pagination = '') { // Determines if multiple comment sources should be allowed $multiple = $this->config->get('main_comment_multiple'); // Define default comment systems $types = array(); // Facebook comments if ($this->config->get('comment_facebook')) { $types['FACEBOOK'] = $this->getAdapter('facebook')->html($blog); // If the system is configured to only display a single comment source if (!$multiple) { return $types['FACEBOOK']; } } // EasySocial comments if ($this->config->get('comment_easysocial') && EB::easysocial()->exists()) { // Initialize EasySocial's library EB::easysocial()->init(); $easysocial = EB::easysocial()->getCommentHTML($blog); // Check whether easysocial plugin is enabled or not. if ($easysocial) { $types['EASYSOCIAL'] = $easysocial; } if (!$multiple) { return $types['EASYSOCIAL']; } } // Compojoom comments if ($this->config->get('comment_compojoom')) { $types['COMPOJOOM'] = $this->getAdapter('CjComment')->html($blog); if (!$multiple) { return $types['COMPOJOOM']; } } // Intensedebate if ($this->config->get('comment_intensedebate')) { $types['INTENSEDEBATE'] = $this->getAdapter('IntenseDebate')->html($blog); if (!$multiple) { return $types['INTENSEDEBATE']; } } // Disqus comments if ($this->config->get('comment_disqus')) { $types['DISQUS'] = $this->getAdapter('Disqus')->html($blog); if (!$multiple) { return $types['DISQUS']; } } // HyperComments comments if ($this->config->get('comment_hypercomments')) { $types['HYPERCOMMENTS'] = $this->getAdapter('HyperComments')->html($blog); if (!$multiple) { return $types['HYPERCOMMENTS']; } } // Livefyre if ($this->config->get('comment_livefyre')) { $types['LIVEFYRE'] = $this->getAdapter('Livefyre')->html($blog); if (!$multiple) { return $types['LIVEFYRE']; } } // JComments if ($this->config->get('comment_jcomments')) { $types['JCOMMENTS'] = $this->getAdapter('jcomments')->html($blog); if (!$multiple) { return $types['JCOMMENTS']; } } // RSComments if ($this->config->get('comment_rscomments')) { $types['RSCOMMENTS'] = $this->getAdapter('rscomments')->html($blog); if (!$multiple) { return $types['RSCOMMENTS']; } } // EasyDiscuss if ($this->config->get('comment_easydiscuss')) { $easydiscuss = $this->getAdapter('easyDiscuss')->html($blog); // Check whether easydiscuss plugin is enabled or not. if ($easydiscuss) { $types['EASYDISCUSS'] = $easydiscuss; } if (!$multiple) { return $types['EASYDISCUSS']; } } // Komento integrations if ($this->config->get('comment_komento')) { $types['KOMENTO'] = $this->getAdapter('komento')->html($blog); if (!$multiple) { return $types['KOMENTO']; } } // Built in comments if ($this->config->get('comment_easyblog', 1)) { $types['EASYBLOGCOMMENTS'] = $this->getAdapter('easyblog')->html($blog, $comments, $pagination); if (!$multiple) { return $types['EASYBLOGCOMMENTS']; } } // If there's 1 system only, there's no point loading the tabs. if (count($types) == 1) { return $types[key($types)]; } // Reverse the comment systems array so that easyblog comments are always the first item. $types = array_reverse($types); $template = EB::template(); $template->set('types', $types); $output = $template->output('site/comments/multiple'); return $output; }
/** * Sets this post as a featured post * * @since 5.0 * @access public * @param string * @return */ public function setFeatured() { $model = EB::model('Featured'); $state = $model->makeFeatured(EBLOG_FEATURED_BLOG, $this->id); if (!$state) { return false; } // @EasySocial Integrations EB::easysocial()->createFeaturedBlogStream($this); // @JomSocial Integrations EB::jomsocial()->createFeaturedBlogStream($this); // Notify author of the blog post that their blog post is featured on the site $this->notify(false, 0, true); return true; }
/** * Determines if Komento exists on the site * * @since 5.0 * @access public * @param string * @return */ public function exists() { $lib = EB::easysocial(); return $lib->exists(); }
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; }