public function store($log = true) { // @rule: Load language file from the front end. JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); $under_approval = false; if (isset($this->under_approval)) { $under_approval = true; // now we need to reset this variable from the blog object. unset($this->under_approval); } // @trigger: onBeforeSave $this->triggerBeforeSave(); // @rule: Determine if this record is new or not. if (empty($this->isnew)) { $isNew = empty($this->id) ? true : false; } else { $isNew = true; } // @rule: Get the rulesets for this user. $acl = EasyBlogACLHelper::getRuleSet(); // @rule: Process badword filters for title here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->title); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_TITLE_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Check for minimum words in the content if required. if ($config->get('main_post_min')) { $minimum = $config->get('main_post_length'); $total = JString::strlen(strip_tags($this->intro . $this->content)); if ($total < $minimum) { $this->setError(JText::sprintf('COM_EASYBLOG_CONTENT_LESS_THAN_MIN_LENGTH', $minimum)); return false; } } // @rule: Check for invalid title if (empty($this->title) || $this->title == JText::_('COM_EASYBLOG_DASHBOARD_WRITE_DEFAULT_TITLE')) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_TITLE_ERROR')); return false; } // @rule: For edited blogs, ensure that they have permissions to edit it. if (!$isNew && $this->created_by != JFactory::getUser()->id && !EasyBlogHelper::isSiteAdmin() && empty($acl->rules->moderate_entry)) { if (!class_exists('EasyBlogModelTeamBlogs')) { jimport('joomla.application.component.model'); JLoader::import('blog', EBLOG_ROOT . DIRECTORY_SEPARATOR . 'models'); } // @task: Only throw error when this blog post is not a team blog post and it's not owned by the current logged in user. JModel::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models'); $model = JModel::getInstance('TeamBlogs', 'EasyBlogModel'); $contribution = $model->getBlogContributed($this->id); if (!$contribution || !$model->checkIsTeamAdmin(JFactory::getUser()->id, $contribution->team_id)) { $this->setError(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG')); return false; } } // @rule: Every blog post must be assigned to a category if (empty($this->category_id)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_CATEGORY_ERROR')); return false; } // Filter / strip contents that are not allowed $filterTags = EasyBlogHelper::getHelper('Acl')->getFilterTags(); $filterAttributes = EasyBlogHelper::getHelper('Acl')->getFilterAttributes(); // @rule: Apply filtering on contents jimport('joomla.filter.filterinput'); $inputFilter = JFilterInput::getInstance($filterTags, $filterAttributes, 1, 1, 0); $inputFilter->tagBlacklist = $filterTags; $inputFilter->attrBlacklist = $filterAttributes; if (count($filterTags) > 0 && !empty($filterTags[0]) || count($filterAttributes) > 0 && !empty($filterAttributes[0])) { $this->intro = $inputFilter->clean($this->intro); $this->content = $inputFilter->clean($this->content); } // @rule: Process badword filters for content here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->intro . $this->content); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_POST_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Test for the empty-ness if (empty($this->intro) && empty($this->content)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_CONTENT_ERROR')); } // alway set this to false no matter what! TODO: remove this column. $this->ispending = '0'; $state = parent::store(); $source = JRequest::getVar('blog_contribute_source', 'easyblog'); // @trigger: onBeforeSave $this->triggerAfterSave(); // if this is blog edit, then we should see the column isnew to determine // whether the post is really new or not. if (!$isNew) { $isNew = $this->isnew; } // @task: If auto featured is enabled, we need to feature the blog post automatically since the blogger is featured. if ($config->get('main_autofeatured', 0) && EasyBlogHelper::isFeatured('blogger', $this->created_by) && !EasyBlogHelper::isFeatured('post', $this->id)) { EasyBlogHelper::makeFeatured('post', $this->id); } // @task: This is when the blog is either created or updated. if ($source == 'easyblog' && $state && $this->published == POST_ID_PUBLISHED && $log) { // @rule: Add new stream item in jomsocial EasyBlogHelper::addJomSocialActivityBlog($this, $isNew); // @rule: Log new stream item into EasyBlog $activity = new stdClass(); $activity->actor_id = $this->created_by; $activity->target_id = '0'; $activity->context_type = 'post'; $activity->context_id = $this->id; $activity->verb = $isNew ? 'add' : 'update'; $activity->uuid = $this->title; EasyBlogHelper::activityLog($activity); } if ($source == 'easyblog' && $state && $this->published == POST_ID_PUBLISHED && $isNew && $log) { // @rule: Send email notifications out to subscribers. $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); // @rule: Ping pingomatic if ($config->get('main_pingomatic')) { if (!EasyBlogHelper::getHelper('Pingomatic')->ping($this->title, EasyBlogHelper::getExternalLink('index.php?option=com_easyblog&view=entry&id=' . $this->id, true))) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_PINGOMATIC_ERROR'), 'error'); } } // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('blog.create', $this->created_by); // @rule: Add userpoints for jomsocial if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.blog.add', $this->created_by); } } $link = $this->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $this->id); // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_BLOG', $author->getName(), $link, $this->title), 'easyblog_new_blog', $target, $this->created_by, $link); } // @rule: Mighty Touch karma points EasyBlogHelper::getHelper('MightyTouch')->setKarma($this->created_by, 'new_blog'); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $this->created_by); // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_BLOG_POST')); if ($config->get('integrations_easydiscuss_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($this, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_BLOG', $author->getName(), $this->title), EBLOG_NOTIFICATIONS_TYPE_BLOG, $target, $this->created_by, $link); } $my = JFactory::getUser(); // @rule: Add points for AlphaUserPoints if ($my->id == $this->created_by && EasyBlogHelper::isAUPEnabled()) { // get blog post URL $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $this->id); $aupid = AlphaUserPointsHelper::getAnyUserReferreID($this->created_by); AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_blog', $aupid, 'easyblog_add_blog_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_BLOG_CREATED', $url, $this->title)); } // @rule: Process trackbacks $this->processTrackbacks(); // Update the isnew column so that if user edits this entry again, it doesn't send any notifications the second time. $this->isnew = 0; $this->store(false); } return $state; }
private function jomsocialForm($external, $groupId = '0', $blogSource = '', $isPending = 0) { $my = JFactory::getUser(); $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; //extra checking incase somewhere still passing empty blogSource. $blogSource = empty($blogSource) ? 'group' : $blogSource; if (!JFile::exists($file)) { return false; } require_once $file; $model = CFactory::getModel('groups'); if (EasyBlogHelper::isSiteAdmin() && $isPending) { $rows = $model->getAllGroups(); } else { $rows = $model->getGroups($my->id, null, false); } $groups = array(); JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'tables'); foreach ($rows as $row) { $group = JTable::getInstance('Group', 'CTable'); $group->load($row->id); $data = new stdClass(); $data->id = $group->id; $data->title = $group->name; $data->avatar = $group->getAvatar(); $groups[] = $data; } $theme = EB::template(); $theme->set('blogSource', $blogSource); $theme->set('external', $external); $theme->set('groups', $groups); $theme->set('groupId', $groupId); return $theme->output('site/jomsocial/groups'); }
/** * Remove an item as featured * * @param string $type The type of this item * @param int $postId The unique id of the item * * @return string Json string **/ function removeFeatured($type, $postId) { $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleset(); // Only super admins can feature items if (!EasyBlogHelper::isSiteAdmin() && !$acl->rules->feature_entry) { $ajax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), '', '450'); $ajax->send(); return; } EasyBlogHelper::removeFeatured($type, $postId); $idName = ''; $message = ''; switch ($type) { case 'blogger': $idName = '#blogger_title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED'); break; case 'teamblog': $idName = '#teamblog_title_' . $postId; $message = JText::_('COM_EASYBLOG_TEAMBLOG_UNFEATURED'); break; case 'post': default: $idName = '#title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOG_UNFEATURED'); break; } $ajax->script('$("' . $idName . '").removeClass("featured-item");'); $ajax->alert($message, JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); $ajax->send(); return; }
/** * Displays the files and folders that are in the media manager. */ public function display($tpl = null) { $config = EasyBlogHelper::getConfig(); $document = JFactory::getDocument(); $my = JFactory::getUser(); $app = JFactory::getApplication(); $profile = EasyBlogHelper::getTable('Profile'); $profile->load($my->id); if ($my->id <= 0) { echo JText::_('COM_EASYBLOG_NOT_ALLOWED'); exit; } $user = JFactory::getUser(); $document->setTitle(JText::_('COM_EASYBLOG_MEDIA_MANAGER')); // Only allow admin to impersonate anyone. if (EasyBlogHelper::isSiteAdmin()) { $user = JFactory::getUser(JRequest::getVar('blogger_id', $my->id)); } $debug = $config->get('debug_javascript') || JRequest::getVar('ebjsdebug') == 1 ? 'true' : 'false'; $theme = new CodeThemes(true); $theme->set('debug', $debug); $theme->set('session', JFactory::getSession()); $theme->set('blogger_id', $user->id); // @rule: Test if the user is already associated with Flickr $oauth = EasyBlogHelper::getTable('Oauth'); $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR); $theme->set('flickrAssociated', $associated); echo $theme->fetch('media.php'); }
/** * 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 display($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); if (!EasyBlogRouter::isCurrentActiveMenu('featured')) { $this->setPathway(JText::_('COM_EASYBLOG_FEATURED_BREADCRUMB')); } // set meta tags for featured view EasyBlogHelper::setMeta(META_ID_FEATURED, META_TYPE_VIEW); EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=featured'); $model = $this->getModel('Featured'); $data = $model->getFeaturedBlog(); $pagination = $model->getPagination(); $params = $mainframe->getParams('com_easyblog'); $data = EasyBlogHelper::formatBlog($data); $blogModel = $this->getModel('Blog'); $pageNumber = $pagination->get('pages.current'); $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber); $document->setTitle(EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_FEATURED_PAGE_TITLE') . $pageText)); if ($config->get('layout_showcomment', false)) { for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $maxComment = $config->get('layout_showcommentcount', 3); $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc'); $comments = EasyBlogHelper::formatBlogCommentsLite($comments); $row->comments = $comments; } } $theme = new CodeThemes(); $theme->set('data', $data); $theme->set('pagination', $pagination->getPagesLinks()); $theme->set('currentURL', 'index.php?option=com_easyblog&view=featured'); $theme->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $theme->set('config', $config); $theme->set('acl', $acl); echo $theme->fetch('blog.featured.php'); }
public function updateComment() { $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $acl = EB::acl(); $id = JRequest::getInt('commentId'); $post = JRequest::get('POST'); //add here so that other component with the same comment.php jtable file will not get reference. JTable::addIncludePath(EBLOG_TABLES); $comment = EB::table('Comment'); $comment->load($id); $redirect = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, false); if (($my->id != $comment->created_by || !$acl->get('delete_comment')) && !EasyBlogHelper::isSiteAdmin() && !$acl->get('manage_comment') || $my->id == 0) { EB::info()->set(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_UPDATE_COMMENT'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } $comment->bindPost($post); if (!$comment->validate('title')) { EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_TITLE_IS_EMPTY'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } if (!$comment->validate('comment')) { EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_IS_EMPTY'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } $comment->modified = EB::date()->toMySQL(); if (!$comment->store()) { EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_FAILED_TO_SAVE'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_UPDATED_SUCCESS'), 'success'); $mainframe->redirect($redirect); $mainframe->close(); }
function getTotalRequest() { $my = JFactory::getUser(); $userId = EasyBlogHelper::isSiteAdmin() ? '' : $my->id; return count($this->getTeamBlogRequest($userId, false)); }
public function deleteComment($id) { $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleSet(); JTable::addIncludePath(EBLOG_TABLES); $comment = EasyBlogHelper::getTable('Comment', 'Table'); $comment->load($id); if (($my->id == 0 || $my->id != $comment->created_by || !$acl->rules->delete_comment) && !EasyBlogHelper::isSiteAdmin()) { $ajax->alert(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_COMMENT'), JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); return $ajax->send(); } $tpl = new CodeThemes(); $tpl->set('comment', $comment); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_DASHBOARD_DELETE_COMMENT'); $options->content = $tpl->fetch('ajax.dialog.comments.delete.php'); $ajax->dialog($options); $ajax->send(); }
public static function getBlogNavigation($blogId, $creationDate, $typeId = '0', $type = 'sitewide') { $db = EasyBlogHelper::db(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $keys = array('prev', 'next'); $nav = array(); $nav['prev'] = null; $nav['next'] = null; $isBloggerMode = EasyBlogRouter::isBloggerMode(); $menus = JFactory::getApplication()->getMenu(); $menu = $menus->getActive(); $queryInclude = ''; if (is_object($menu)) { $params = EasyBlogHelper::getRegistry(); $params->load($menu->params); $cats = EasyBlogHelper::getCategoryInclusion($params->get('inclusion')); if ($cats) { if (!is_array($cats)) { $cats = array($cats); } $queryInclude = ' AND a.`category_id` IN ('; foreach ($cats as $allowedCat) { $queryInclude .= $db->Quote($allowedCat); if (next($cats) !== false) { $queryInclude .= ','; } } $queryInclude .= ')'; } } // get all private categories id $excludeCats = EasyBlogHelper::getPrivateCategories(); $queryExclude = ''; if (!empty($excludeCats)) { $queryExclude .= ' AND a.`category_id` NOT IN ('; for ($i = 0; $i < count($excludeCats); $i++) { $queryExclude .= $db->Quote($excludeCats[$i]); if (next($excludeCats) !== false) { $queryExclude .= ','; } } $queryExclude .= ')'; } foreach ($keys as $key) { $query = 'SELECT a.`id`, a.`title`'; $query .= ' FROM `#__easyblog_post` AS `a`'; if ($type == 'team' && !empty($typeId)) { $query .= ' INNER JOIN `#__easyblog_team_post` AS `b`'; $query .= ' ON a.`id` = b.`post_id`'; } $query .= ' WHERE a.`published` = ' . $db->Quote('1'); $query .= ' AND a.`ispending` = ' . $db->Quote('0'); //blog privacy setting // @integrations: jomsocial privacy $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'); $query .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) { require_once $file; $my = JFactory::getUser(); $jsFriends = CFactory::getModel('Friends'); $friends = $jsFriends->getFriendIds($my->id); // Insert query here. $query .= ' AND ('; $query .= ' (a.`private`= 0 ) OR'; $query .= ' ( (a.`private` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR'; if (empty($friends)) { $query .= ' ( (a.`private` = 30) AND ( 1 = 2 ) ) OR'; } else { $query .= ' ( (a.`private` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $query .= ' ( (a.`private` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $my->id . ') )'; $query .= ' )'; } else { //blog privacy setting if ($my->id == 0) { $query .= ' AND a.`private` = ' . $db->Quote(BLOG_PRIVACY_PUBLIC); } } } //include categories if (!empty($queryInclude)) { $query .= $queryInclude; } //exclude private categories $query .= $queryExclude; if ($isBloggerMode !== false) { $query .= ' AND a.`created_by` = ' . $db->Quote($isBloggerMode); } if ($type == 'team' && !empty($typeId)) { $query .= ' AND b.`team_id` = ' . $db->Quote($typeId); } else { $query .= ' AND a.`issitewide` = ' . $db->Quote('1'); } //language filtering 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 .= ' a.`language`=' . $db->Quote(JFactory::getLanguage()->getTag()); $query .= ' OR a.`language`=' . $db->Quote(''); $query .= ' OR a.`language`=' . $db->Quote('*'); $query .= ' )'; } } if ($key == 'prev') { $query .= ' AND a.`created` < ' . $db->Quote($creationDate); $query .= ' ORDER BY a.`created` DESC'; } else { if ($key == 'next') { $query .= ' AND a.`created` > ' . $db->Quote($creationDate); $query .= ' ORDER BY a.`created` ASC'; } } $query .= ' LIMIT 1'; $db->setQuery($query); $result = $db->loadObjectList(); $nav[$key] = $result; } return $nav; }
function statistic() { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); $sort = JRequest::getCmd('sort', 'latest'); $id = JRequest::getInt('id', 0); //setting pathway $pathway = $mainframe->getPathway(); $this->setPathway(JText::_('COM_EASYBLOG_TEAMBLOG'), EasyBlogRouter::_('index.php?option=com_easyblog&view=teamblog')); $id = JRequest::getInt('id', 0); if ($id == 0) { echo JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID'); return; } // set meta tags for teamblog view EasyBlogHelper::setMeta($id, META_TYPE_TEAM); //stats type $statType = JRequest::getString('stat', ''); $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', ''); $statObject = null; if ($statType == 'category') { $statObject = EasyBlogHelper::getTable('Category', 'Table'); $statObject->load($statId); } else { $statObject = EasyBlogHelper::getTable('Tag', 'Table'); $statObject->load($statId); } $team = EasyBlogHelper::getTable('TeamBlog', 'Table'); $team->load($id); $team->avatar = $team->getAvatar(); $gid = EasyBlogHelper::getUserGids(); $isMember = $team->isMember($my->id, $gid); //check if the logged in user a teammember when the team set to member only. if ($team->access == EBLOG_TEAMBLOG_ACCESS_MEMBER) { $isMember = $team->isMember($my->id, $gid); } $team->isMember = $isMember; // 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'); } //add the pathway for teamblog $this->setPathway($team->title, ''); $tbModel = $this->getModel('TeamBlogs'); $model = $this->getModel('Blog'); $blogs = $model->getBlogsBy('teamblog', $team->id); $blogs = EasyBlogHelper::formatBlog($blogs); $pagination = $model->getPagination(); //now get the teams info $members = $tbModel->getTeamMembers($team->id); $teamMembers = EasyBlogHelper::formatTeamMembers($members); $isFeatured = EasyBlogHelper::isFeatured('teamblog', $team->id); $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $pageNumber = $pagination->get('pages.current'); $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber); $document->setTitle($team->title . $pageText . $pageTitle); EasyBlogHelper::storeSession($team->id, 'EASYBLOG_TEAMBLOG_ID'); //var_dump($blogs);exit; $tpl = new CodeThemes(); $tpl->set('team', $team); $tpl->set('teamMembers', $teamMembers); $tpl->set('data', $blogs); $tpl->set('isFeatured', $isFeatured); $tpl->set('pagination', $pagination->getPagesLinks()); $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $tpl->set('config', $config); $tpl->set('my', $my); $tpl->set('acl', $acl); $tpl->set('statType', $statType); $tpl->set('statObject', $statObject); echo $tpl->fetch('blog.teamblogs.php'); }
public static function isSiteAdmin($user) { return EasyBlogHelper::isSiteAdmin($user->id); }
</div> </div> </div><!--end: .profile-sidebar--> <?php } // end stat ?> <?php if ($this->getParam('show_teamblogstatsitem')) { ?> <div class="profile-main"> <?php if ($row->access == EBLOG_TEAMBLOG_ACCESS_MEMBER && !$row->isMember && !EasyBlogHelper::isSiteAdmin()) { ?> <div class="eblog-message warning mtm"> <?php echo JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY'); ?> <?php echo $system->my->id != 0 ? JText::sprintf('COM_EASYBLOG_TEAMBLOG_CLICK_TO_JOIN', 'eblog.teamblog.join(' . $row->id . ')') : ''; ?> </div> <?php } else { ?> <?php if (empty($row->blogs)) { ?>
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; }
<td class="key"> <label for="url"><?php echo JText::_('COM_EASYBLOG_BLOGGERS_EDIT_WEBSITE'); ?> </label> </td> <td class="paramlist_value"> <input type="text" name="url" id="url" value="<?php echo $this->escape($this->blogger->url); ?> " size="40" style="width: 350px;" /> </td> </tr> <?php if (EasyBlogHelper::isSiteAdmin()) { ?> <tr> <td class="key"> <label for="url"><?php echo JText::_('COM_EASYBLOG_BLOGGERS_EDIT_PERMALINK'); ?> </label> </td> <td class="paramlist_value"> <input type="text" name="user_permalink" id="user_permalink" value="<?php echo $this->escape($this->blogger->permalink); ?> " size="40" style="width: 350px;" /> <div class="small"><?php echo JText::_('COM_EASYBLOG_BLOGGERS_EDIT_PERMALINK_USAGE');
function calendar($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); //setting pathway $pathway = $mainframe->getPathway(); if (!EasyBlogRouter::isCurrentActiveMenu('archive')) { $pathway->addItem(JText::_('COM_EASYBLOG_ARCHIVE_BREADCRUMB'), ''); } EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=archive'); $menuParams = $mainframe->getParams(); $defaultYear = $menuParams->get('es_archieve_year', 0); $defaultMonth = $menuParams->get('es_archieve_month', 0); $archiveYear = JRequest::getVar('archiveyear', $defaultYear, 'REQUEST'); $archiveMonth = JRequest::getVar('archivemonth', $defaultMonth, 'REQUEST'); $archiveDay = JRequest::getVar('archiveday', 0, 'REQUEST'); $itemId = JRequest::getInt('Itemid', 0); if (empty($archiveYear) || empty($archiveMonth)) { // @task: Set the page title $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE')); parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend')); $tpl = new CodeThemes(); $tpl->set('itemId', $itemId); echo $tpl->fetch('calendar.php'); return; } $date = EasyBlogHelper::getDate(); $sort = 'latest'; $model = $this->getModel('Archive'); $year = $model->getArchiveMinMaxYear(); $data = $model->getArchive($archiveYear, $archiveMonth, $archiveDay); $pagination = $model->getPagination(); $params = $mainframe->getParams('com_easyblog'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $data = EasyBlogHelper::formatBlog($data); //if day is empty if (empty($archiveDay)) { $archiveDay = '01'; $dateformat = '%B %Y'; $emptyPostMsg = JText::_('COM_EASYBLOG_ARCHIVE_NO_ENTRIES_ON_MONTH'); } else { $dateformat = '%d %B %Y'; $emptyPostMsg = JText::_('COM_EASYBLOG_ARCHIVE_NO_ENTRIES_ON_DAY'); } $archiveDay = strlen($archiveDay) < 2 ? '0' . $archiveDay : $archiveDay; $viewDate = EasyBlogHelper::getDate($archiveYear . '-' . $archiveMonth . '-' . $archiveDay); $formatedDate = $viewDate->toFormat($dateformat); $archiveTitle = JText::sprintf('COM_EASYBLOG_ARCHIVE_HEADING_TITLE', $formatedDate); // @task: Set the page title $title = EasyBlogHelper::getPageTitle(JText::sprintf('COM_EASYBLOG_ARCHIVE_HEADING_TITLE', $formatedDate)); parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend')); // set meta tags for featured view EasyBlogHelper::setMeta(META_ID_ARCHIVE, META_TYPE_VIEW, JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE') . ' - ' . $formatedDate); // set meta tags for featured view EasyBlogHelper::setMeta(META_ID_ARCHIVE, META_TYPE_VIEW, JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE') . ' - ' . $formatedDate); $tpl = new CodeThemes(); $tpl->set('data', $data); $tpl->set('pagination', $pagination->getPagesLinks()); $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $tpl->set('archiveYear', $archiveYear); $tpl->set('archiveMonth', $archiveMonth); $tpl->set('archiveDay', $archiveDay); $tpl->set('config', $config); $tpl->set('my', $my); $tpl->set('acl', $acl); $tpl->set('archiveTitle', $archiveTitle); $tpl->set('emptyPostMsg', $emptyPostMsg); echo $tpl->fetch('blog.archive.php'); }
/** * Shares a story through 3rd party oauth clients * * @param TableBlog $blog A blog table object * @param string $type The type of oauth client * * @return boolean True on success and false otherwise. **/ public function share($blog, $type, $useCentralized = false) { JTable::addIncludePath(EBLOG_TABLES); $oauth = EasyBlogHelper::getTable('Oauth', 'Table'); $oauths = array(); $config = EasyBlogHelper::getConfig(); // @rule: Process centralized notifications, be it a page or an account update if ($useCentralized) { $userId = $config->get('integrations_' . strtolower($type) . '_centralized_userid'); $message = $config->get('integrations_' . JString::strtolower($type) . '_centralized_auto_post'); $auto = $config->get('integrations_' . JString::strtolower($type) . '_centralized_auto_post'); $oauth->loadByUser($userId, $type); // For legacy fix prior to 3.0, we need to set system=1 if ($oauth->id && !$oauth->system) { $oauth->system = 1; $oauth->store(); } // @task: Now we try to load the real object $oauth->loadSystemByType($type); if ($oauth->id) { $oauths[] = $oauth; } } else { if ($config->get('integrations_' . JString::strtolower($type) . '_centralized_and_own')) { JTable::addIncludePath(EBLOG_TABLES); $oauth = EasyBlogHelper::getTable('Oauth', 'Table'); $oauth->loadByUser($blog->created_by, $type); $oauths[] = $oauth; } } $key = $config->get('integrations_' . $type . '_api_key'); $secret = $config->get('integrations_' . $type . '_secret_key'); // @rule: Set callback URLs $callback = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&controller=oauth&task=grant&type=' . $type, false, true); if ($oauths) { foreach ($oauths as $oauth) { // Skip processing anything that does not have an access token if (!$oauth->access_token) { continue; } $acl = EasyBlogACLHelper::getRuleSet($blog->created_by); $rule = 'update_' . $type; // @task: If entry is already shared or automatic postings is disabled do not share this entry. if ($oauth->isShared($blog->id, $useCentralized) || !$acl->rules->{$rule} && !EasyBlogHelper::isSiteAdmin()) { continue; } // @rule: Retrieve the consumer object for this oauth client. $consumer = EasyBlogOauthHelper::getConsumer($type, $key, $secret, $callback); $consumer->setAccess($oauth->access_token); if ($consumer->share($blog, $oauth->message, $oauth, $useCentralized)) { // @task: mark this as sent! $oauthPost = EasyBlogHelper::getTable('OauthPost', 'Table'); $oauthPost->loadByOauthId($blog->id, $oauth->id); $date = EasyBlogHelper::getDate(); $oauthPost->post_id = $blog->id; $oauthPost->oauth_id = $oauth->id; $oauthPost->created = $date->toMySQL(); $oauthPost->modified = $date->toMySQL(); $oauthPost->sent = $date->toMySQL(); $oauthPost->store(); } } } return true; }
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; }
public function deleteAllDrafts() { $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=drafts', false); if ($my->id == 0 && !EasyBlogHelper::isSiteAdmin()) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_DELETE_DRAFTS'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } $model = $this->getModel('Drafts'); if (!$model->discard($my->id)) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_DRAFTS_DISCARDED_ERROR'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_DRAFTS_DISCARDED_SUCCESSFULLY'), 'info'); $mainframe->redirect($redirect); $mainframe->close(); }
function teamblogs() { $mainframe = JFactory::getApplication(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); $document = JFactory::getDocument(); $my = JFactory::getUser(); $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_TEAMBLOG_PAGE_TITLE')); // @task: Set the page title parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend')); if (!EasyBlogRouter::isCurrentActiveMenu('dashboard')) { $this->setPathway(JText::_('COM_EASYBLOG_DASHBOARD_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard')); } $this->setPathway(JText::_('COM_EASYBLOG_DASHBOARD_TEAMBLOG_BREADCRUMB'), ''); if (!EasyBlogHelper::isLoggedIn()) { EasyBlogHelper::showLogin(); return; } if (!EasyBlogHelper::isTeamAdmin()) { EasyBlogHelper::showAccessDenied(); return; } // get all the team request that this user assigned as admin. $tbRequest = $this->getModel('TeamBlogs'); $myId = EasyBlogHelper::isSiteAdmin() ? '' : $my->id; $requests = $tbRequest->getTeamBlogRequest($myId); $pagination = $tbRequest->getPagination(); // Add the breadcrumbs $breadcrumbs = array(JText::_('COM_EASYBLOG_DASHBOARD_BREADCRUMB_TEAM_REQUEST') => ''); $user = EasyBlogHelper::getTable('Profile', 'Table'); $user->load($my->id); echo $this->showToolbar(__FUNCTION__, $user); $tpl = new CodeThemes('dashboard'); $tpl->set('user', $user); $tpl->set('requests', $requests); $tpl->set('pagination', $pagination); $tpl->set('breadcrumbs', $breadcrumbs); echo $tpl->fetch('dashboard.teamblog.request.php'); }
function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('user'); $mainframe = JFactory::getApplication(); $db = EasyBlogHelper::db(); $my = JFactory::getUser(); $acl = JFactory::getACL(); $config = EasyBlogHelper::getConfig(); // Create a new JUser object $user = JFactory::getUser(JRequest::getVar('id', 0, 'post', 'int')); $original_gid = $user->get('gid'); $post = JRequest::get('post'); $post['username'] = JRequest::getVar('username', '', 'post', 'username'); $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW); if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $jformPost = JRequest::getVar('jform', array(), 'post', 'array'); $post['params'] = $jformPost['params']; } if (!$user->bind($post)) { EasyBlogHelper::storeSession($post, 'EASYBLOG_REGISTRATION_POST'); $mainframe->enqueueMessage($user->getError(), 'error'); $this->_saveError($user->id); } if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { if ($user->get('id') == $my->get('id') && $user->get('block') == 1) { $mainframe->enqueueMessage(JText::_('You cannot block Yourself!'), 'error'); $this->_saveError($user->id); } else { if ($user->authorise('core.admin') && $user->get('block') == 1) { $mainframe->enqueueMessage(JText::_('You cannot block a Super User'), 'error'); $this->_saveError($user->id); } else { if ($user->authorise('core.admin') && !$my->authorise('core.admin')) { $mainframe->enqueueMessage(JText::_('You cannot edit a Super User account'), 'message'); $this->_saveError($user->id); } } } //replacing thr group name with group id so it is save correctly into the Joomla group table. $jformPost = JRequest::getVar('jform', array(), 'post', 'array'); if (!empty($jformPost['groups'])) { $user->groups = array(); foreach ($jformPost['groups'] as $groupid) { $user->groups[$groupid] = $groupid; } } } else { $objectID = $acl->get_object_id('users', $user->get('id'), 'ARO'); $groups = $acl->get_object_groups($objectID, 'ARO'); $this_group = strtolower($acl->get_group_name($groups[0], 'ARO')); if ($user->get('id') == $my->get('id') && $user->get('block') == 1) { $mainframe->enqueueMessage(JText::_('You cannot block Yourself!'), 'error'); $this->_saveError($user->id); } else { if ($this_group == 'super administrator' && $user->get('block') == 1) { $mainframe->enqueueMessage(JText::_('You cannot block a Super Administrator'), 'error'); $this->_saveError($user->id); } else { if ($this_group == 'administrator' && $my->get('gid') == 24 && $user->get('block') == 1) { $mainframe->enqueueMessage(JText::_('WARNBLOCK'), 'error'); $this->_saveError($user->id); } else { if ($this_group == 'super administrator' && $my->get('gid') != 25) { $mainframe->enqueueMessage(JText::_('You cannot edit a super administrator account'), 'message'); $this->_saveError($user->id); } } } } } // Are we dealing with a new user which we need to create? $isNew = $user->get('id') < 1; if (EasyBlogHelper::getJoomlaVersion() <= '1.5') { // do this step only for J1.5 if (!$isNew) { // if group has been changed and where original group was a Super Admin if ($user->get('gid') != $original_gid && $original_gid == 25) { // count number of active super admins $query = 'SELECT COUNT( id )' . ' FROM #__users' . ' WHERE gid = 25' . ' AND block = 0'; $db->setQuery($query); $count = $db->loadResult(); if ($count <= 1) { // disallow change if only one Super Admin exists $this->setRedirect('index.php?option=com_users', JText::_('WARN_ONLY_SUPER')); return false; } } } } if (!$user->save()) { $mainframe->enqueueMessage($user->getError(), 'error'); return $this->execute('edit'); } // If updating self, load the new user object into the session if (EasyBlogHelper::getJoomlaVersion() <= '1.5') { if ($user->get('id') == $my->get('id')) { // Get an ACL object $acl = JFactory::getACL(); // Get the user group from the ACL $grp = $acl->getAroGroup($user->get('id')); // Mark the user as logged in $user->set('guest', 0); $user->set('aid', 1); // Fudge Authors, Editors, Publishers and Super Administrators into the special access group if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) { $user->set('aid', 2); } // Set the usertype based on the ACL group name $user->set('usertype', $grp->name); $session = JFactory::getSession(); $session->set('user', $user); } } else { // Update session data if the current user was updated if ($user->get('id') == $my->get('id')) { $session = JFactory::getSession(); $session->set('user', $user); // Force load from database } } $post = JRequest::get('post'); if ($isNew) { unset($post['id']); } $post['permalink'] = $post['user_permalink']; unset($post['user_permalink']); if (EasyBlogHelper::isSiteAdmin()) { $post['description'] = JRequest::getVar('description', '', 'POST', '', JREQUEST_ALLOWRAW); $post['biography'] = JRequest::getVar('biography', '', 'POST', '', JREQUEST_ALLOWRAW); } $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($user->id); $blogger->bind($post); $file = JRequest::getVar('Filedata', '', 'Files', 'array'); if (!empty($file['name'])) { $newAvatar = EasyBlogHelper::uploadAvatar($blogger, true); $blogger->avatar = $newAvatar; } //save params $userparams = EasyBlogHelper::getRegistry(''); // @rule: Save google profile url if (isset($post['google_profile_url'])) { $userparams->set('google_profile_url', $post['google_profile_url']); } if (isset($post['show_google_profile_url'])) { $userparams->set('show_google_profile_url', $post['show_google_profile_url']); } $blogger->params = $userparams->toString(); $blogger->store(); JTable::addIncludePath(EBLOG_TABLES); //save twitter info. $twitter = EasyBlogHelper::getTable('Oauth', 'Table'); $twitter->loadByUser($user->id, EBLOG_OAUTH_TWITTER); $twitter->auto = JRequest::getVar('integrations_twitter_auto'); $twitter->message = JRequest::getVar('integrations_twitter_message'); if (!$twitter->store()) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_TWITTER_ERROR'), 'error'); } // Map linkedin items $linkedin = EasyBlogHelper::getTable('Oauth', 'Table'); $linkedin->loadByUser($user->id, EBLOG_OAUTH_LINKEDIN); $linkedin->auto = JRequest::getVar('integrations_linkedin_auto'); $linkedin->message = JRequest::getVar('integrations_linkedin_message'); $linkedin->private = JRequest::getVar('integrations_linkedin_private'); if (!$linkedin->store()) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_LINKEDIN_ERROR'), 'error'); } // store faebook info $facebook = EasyBlogHelper::getTable('Oauth', 'Table'); $facebook->loadByUser($user->id, EBLOG_OAUTH_FACEBOOK); $facebook->auto = JRequest::getVar('integrations_facebook_auto'); $facebook->message = ''; if (!$facebook->store()) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_FACEBOOK_FAILED_UPDATE_INFO_ERROR'), 'error'); } if ($config->get('integration_google_adsense_enable')) { // Store adsense data $adsense = EasyBlogHelper::getTable('Adsense', 'Table'); $adsense->load($user->id); $adsense->code = $post['adsense_code']; $adsense->display = $post['adsense_display']; $adsense->published = $post['adsense_published']; $adsense->store(); } // Store feedburner data $feedburner = EasyBlogHelper::getTable('Feedburner', 'Table'); $feedburner->load($user->id); $feedburner->url = $post['feedburner_url']; $feedburner->store(); $this->_saveSuccess($user->id); }
public function deleteComment() { $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); $id = JRequest::getInt('commentId'); $post = JRequest::get('POST'); //add here so that other component with the same comment.php jtable file will not get reference. JTable::addIncludePath(EBLOG_TABLES); $comment = EasyBlogHelper::getTable('Comment', 'Table'); $comment->load($id); $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, false); if (($my->id == 0 || $my->id != $comment->created_by || !$acl->rules->delete_comment) && !EasyBlogHelper::isSiteAdmin()) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_UPDATE_COMMENT'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } if (!$comment->delete()) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_COMMENT_FAILED_TO_SAVE'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_COMMENT_DELETED_SUCCESS'), 'success'); $mainframe->redirect($redirect); $mainframe->close(); }
public function getArchivePostCounts($yearStart = '', $yearStop = '0', $excludeCats = '', $includeCats = '', $filter = '', $filterId = '') { $db = EB::db(); $user = JFactory::getUser(); $config = EB::config(); $catAccess = array(); if (empty($yearStart)) { $year = $this->getArchiveMinMaxYear(); $yearStart = $year['maxyear']; } if (!empty($yearStop)) { $fr = $yearStart - 1; $to = $yearStop + 1; } else { $fr = $yearStart - 1; $to = $yearStart + 1; } if (!is_array($excludeCats) && !empty($excludeCats)) { $excludeCats = explode(',', $excludeCats); } else { if (!is_array($excludeCats) && empty($excludeCats)) { $excludeCats = array(); } } if (!is_array($includeCats) && !empty($includeCats)) { $includeCats = explode(',', $includeCats); } else { if (!is_array($includeCats) && empty($includeCats)) { $includeCats = array(); } } $includeCats = array_diff($includeCats, $excludeCats); if (!empty($excludeCats) && count($excludeCats) >= 1) { $catAccess['exclude'] = $excludeCats; } if (!empty($includeCats) && count($includeCats) >= 1) { $catAccess['include'] = $includeCats; } //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.`access`= 0 ) OR'; $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($user->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') . '=' . $user->id . ') )'; $privateBlog .= ' )'; } else { if ($user->id == 0) { $privateBlog .= ' AND a.`access` = ' . $db->Quote(0); } } } $joinTeam = ''; $FilterSQL = ''; if ($filter != '') { $FilterSQL = ''; switch ($filter) { case 'blogger': $FilterSQL = 'AND a.' . $db->nameQuote('created_by') . ' = ' . $db->Quote($filterId); break; case 'team': $FilterSQL = 'AND (a.' . $db->quoteName('source_type') . ' = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' and a.' . $db->quoteName('source_id') . ' = ' . $db->Quote($filterId) . ')'; break; default: break; } } $languageFilterSQL = ''; // @rule: When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $languageFilterSQL .= EBR::getLanguageQuery('AND', 'a.language'); } $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess); $query = 'SELECT COUNT(1) as count, MONTH( a.' . $db->nameQuote('created') . ' ) AS month, YEAR( a.' . $db->nameQuote('created') . ' ) AS year ' . 'FROM ' . $db->nameQuote('#__easyblog_post') . ' AS a ' . $joinTeam . ' ' . 'WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' ' . 'AND a.' . $db->nameQuote('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL) . ' ' . $privateBlog . ' ' . $languageFilterSQL . ' ' . $FilterSQL . ' ' . 'AND ( a.' . $db->nameQuote('created') . ' > ' . $db->Quote($fr . '-12-31 23:59:59') . ' AND a.' . $db->nameQuote('created') . ' < ' . $db->Quote($to . '-01-01 00:00:00') . ') ' . 'AND (' . $catAccessSQL . ') ' . 'GROUP BY year, month DESC ' . 'ORDER BY a.' . $db->nameQuote('created') . ' DESC '; $db->setQuery($query); $row = $db->loadAssocList(); if (empty($row)) { return false; } $postCount = new stdClass(); foreach ($row as $data) { if (!isset($postCount->{$data['year']})) { $postCount->{$data['year']} = new stdClass(); } $postCount->{$data['year']}->{$data['month']} = $data['count']; } return $postCount; }
function rejectItem($id) { // @task: Check for acl rules. $this->checkAccess('blog'); $mainframe = JFactory::getApplication(); $redirect = base64_decode(JRequest::getVar('redirect', '')); $redirect = empty($redirect) ? EasyBlogRouter::_('index.php?option=com_easyblog&view=pending', false) : EasyBlogRouter::_($redirect, false); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); $message = JRequest::getVar('message', ''); if (empty($id)) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } if (!EasyBlogHelper::isSiteAdmin() && empty($acl->rules->manage_pending)) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } JTable::addIncludePath(EBLOG_TABLES); $draft = EasyBlogHelper::getTable('Draft', 'Table'); $draft->load($id); if ($draft->pending_approval != 1) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); $mainframe->close(); } // If the draft is rejected, revert draft status and create a note for the rejected draft. $draft->set('pending_approval', 0); $draft->store(); // Create the message $postreject = EasyBlogHelper::getTable('PostReject', 'Table'); $postreject->draft_id = $draft->id; $postreject->message = $message; $postreject->created_by = $my->id; $postreject->created = EasyBlogHelper::getDate()->toMySQL(); $postreject->store(); }
/** * 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; }
function display($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $notice = ''; //for trigger $params = $mainframe->getParams('com_easyblog'); $limitstart = JRequest::getInt('limitstart', 0, ''); $blogId = JRequest::getVar('id'); if (JRequest::getInt('print') == 1) { // Add noindex for print view by default. $document->setMetadata('robots', 'noindex,follow'); } if (empty($blogId)) { $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false), JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); $mainframe->close(); } if ($my->id <= 0 && $config->get('main_login_read')) { $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blogId . '&layout=login', false)); $mainframe->close(); } $team = JRequest::getVar('team', ''); if (empty($team)) { //try get from session. $team = EasyBlogHelper::getSession('EASYBLOG_TEAMBLOG_ID'); } // set meta tags for post EasyBlogHelper::setMeta($blogId, META_TYPE_POST); $print = JRequest::getBool('print'); if ($print) { $document->setMetaData('robots', 'noindex, nofollow'); } $my = JFactory::getUser(); $blog = EasyBlogHelper::getTable('Blog', 'Table'); if (!$blog->load($blogId)) { $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false), JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); $mainframe->close(); } if (!empty($blog->robots)) { $document->setMetaData('robots', $blog->robots); } if (!empty($blog->copyrights)) { $document->setMetaData('rights', $blog->copyrights); } //assign the teamid here. $checkIsPrivate = false; //check if blog is password protected. if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) { if (!EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) { $errmsg = ''; $jSession = JFactory::getSession(); if ($jSession->has('PROTECTEDBLOG_' . $blog->id, 'EASYBLOG')) { $errmsg = JText::_('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_INVALID_PASSWORD'); } $theme = new CodeThemes(); $theme->set('id', $blog->id); $theme->set('return', base64_encode(JURI::getInstance()->toString())); $theme->set('errmsg', $errmsg); echo $theme->fetch('blog.protected.php'); return false; } } //if team id provided, then we need to check if the user belong to the team or not. if ($blog->issitewide) { $checkIsPrivate = true; } else { if (empty($team)) { // blog post is not sitewide and teamid is empty? this is not so right. need to check this post contributed to which team one more time. $team = $blog->getTeamContributed(); } /* * if teamblog access set to 'member only' | 'registered user', team blog will supersede blog permision * if teamblog access set to 'everyone' then blog's permission will supersede teamblog access (logged user vs guest) */ if (!empty($team)) { $teamblog = EasyBlogHelper::getTable('TeamBlog', 'Table'); $teamblog->load($team); if ($teamblog->access == '1') { if (!EasyBlogHelper::isTeamBlogJoined($my->id, $team)) { //show error. EasyBlogHelper::showAccessDenied('teamblog', $teamblog->access); return; } } else { if ($teamblog->access == '2') { if (!EasyBlogHelper::isLoggedIn()) { EasyBlogHelper::showLogin(); return; } } else { // if teamblog the access set to 'everyone' then blog permission will supersede teamblog access $checkIsPrivate = true; } } } else { $checkIsPrivate = true; } } $blog->team_id = $team; //check if the blog permission set to private or public. if private, we //need to check if the user has login or not. if ($checkIsPrivate) { $privacy = $blog->isAccessible(); if (!$privacy->allowed) { echo $privacy->error; return; } } // added checking for other statuses switch ($blog->published) { case 0: case 2: case 3: // Unpublished post // Only Admin and blog owner can view this post if ($my->id == $blog->created_by) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER'); } elseif (EasyBlogHelper::isSiteAdmin()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN'); } else { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false)); } break; case 5: // Trashed posts. EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false)); break; case 1: default: break; } //update the hits $blog->hit(); $acl = EasyBlogACLHelper::getRuleSet(); $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); if (empty($pageTitle)) { $document->setTitle($blog->title); } else { $document->setTitle($blog->title . ' - ' . $pageTitle); } // There is a possibility that the intro is hidden in the entry view, so we need to get this data. $rawIntroText = $blog->intro; // @rule: Process microblog post if ($blog->source) { EasyBlogHelper::formatMicroBlog($blog); } // process the video here if nessary $blog->intro = EasyBlogHelper::getHelper('Videos')->processVideos($blog->intro); $blog->content = EasyBlogHelper::getHelper('Videos')->processVideos($blog->content); // @rule: Process audio files. $blog->intro = EasyBlogHelper::getHelper('Audio')->process($blog->intro); $blog->content = EasyBlogHelper::getHelper('Audio')->process($blog->content); // @rule: Process adsense codes. $blog->intro = EasyBlogGoogleAdsense::processsAdsenseCode($blog->intro, $blog->created_by); $blog->content = EasyBlogGoogleAdsense::processsAdsenseCode($blog->content, $blog->created_by); // @trigger: onEasyBlogPrepareContent EasyBlogHelper::triggerEvent('easyblog.prepareContent', $blog, $params, $limitstart); // @rule: Hide introtext if necessary if ($config->get('main_hideintro_entryview') && !empty($blog->content)) { $blog->intro = ''; } //onPrepareContent trigger start $blog->introtext = $blog->intro; $blog->text = $blog->intro . $blog->content; // @trigger: onEasyBlogPrepareContent EasyBlogHelper::triggerEvent('prepareContent', $blog, $params, $limitstart); $blog->intro = $blog->introtext; $blog->content = $blog->text; // @legacy: since 3.5 has blog images, we can remove this in the future. // Remove first image for featured blogs if ($blog->isFeatured()) { $blog->content = EasyBlogHelper::removeFeaturedImage($blog->content); } $isFeatured = EasyBlogHelper::isFeatured('post', $blog->id); /* Post Tags */ $modelPT = $this->getModel('PostTag'); $tags = $modelPT->getBlogTags($blog->id); //page setup $blogHtml = ''; $commentHtml = ''; $blogHeader = ''; $blogFooter = ''; $adsenseHtml = ''; $trackbackHtml = ''; $blogger = null; if ($blog->created_by != 0) { $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($blog->created_by); } // @rule: Set the author object into the table. $blog->author = $blogger; $blog->blogger = $blogger; // @rule: Before any trigger happens, try to replace the gallery first and append it at the bottom. $blog->intro = EasyBlogHelper::getHelper('Gallery')->process($blog->intro, $blog->created_by); $blog->content = EasyBlogHelper::getHelper('Gallery')->process($blog->content, $blog->created_by); $blog->intro = EasyBlogHelper::getHelper('Album')->process($blog->intro, $blog->created_by); $blog->content = EasyBlogHelper::getHelper('Album')->process($blog->content, $blog->created_by); //onAfterDisplayTitle, onBeforeDisplayContent, onAfterDisplayContent trigger start $blog->event = new stdClass(); $blog->introtext = $blog->intro; $blog->text = $blog->content; // @trigger: onAfterDisplayTitle / onContentAfterTitle $results = EasyBlogHelper::triggerEvent('afterDisplayTitle', $blog, $params, $limitstart); $blog->event->afterDisplayTitle = JString::trim(implode("\n", $results)); // @trigger: onBeforeDisplayContent / onContentBeforeDisplay $results = EasyBlogHelper::triggerEvent('beforeDisplayContent', $blog, $params, $limitstart); $blog->event->beforeDisplayContent = JString::trim(implode("\n", $results)); // @trigger: onAfterDisplayContent / onContentAfterDisplay $results = EasyBlogHelper::triggerEvent('afterDisplayContent', $blog, $params, $limitstart); $blog->event->afterDisplayContent = JString::trim(implode("\n", $results)); $blog->intro = $blog->introtext; $blog->content = $blog->text; unset($blog->introtext); unset($blog->text); if ($print) { $theme = new CodeThemes(); $theme->set('blog', $blog); $theme->set('tags', $tags); $theme->set('config', $config); $theme->set('blogger', $blogger); echo $theme->fetch('blog.read.print.php'); return; } if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id) && $config->get('layout_blogger_breadcrumb')) { $this->setPathway($blogger->getName(), $blogger->getLink()); } if (!EasyBlogRouter::isCurrentActiveMenu('entry', $blog->id)) { $this->setPathway($blog->title, ''); } $blogModel = $this->getModel('Blog'); $theme = new CodeThemes(); // add checking if comment system disabled by site owner if ($config->get('main_comment') && $blog->allowcomment) { // getting blog comments $commentModel = $this->getModel('Comment'); $blogComments = EasyBlogHelper::getHelper('Comment')->getBlogComment($blogId); $commtPagination = EasyBlogHelper::getHelper('Comment')->pagination; $comments = array(); if (!empty($blogComments)) { foreach ($blogComments as $comment) { $row = $comment; $row->comment = EasyBlogCommentHelper::parseBBCode($row->comment); if ($config->get('comment_likes')) { $row->likesAuthor = EasyBlogHelper::getLikesAuthors($row->id, 'comment', $my->id); $row->isLike = $commentModel->isLikeComment($row->id, $my->id); } else { $row->likesAuthor = ''; $row->isLike = 0; } $comments[] = $row; } } // compliant with the #comments at blog.item.comment.php $commentHtml = $config->get('comment_jcomments') ? '' : '<a id="comments"></a>'; $commentHtml .= EasyBlogCommentHelper::getCommentHTML($blog, $comments, $commtPagination); } $blog->totalComments = EasyBlogHelper::getHelper('Comment')->getCommentCount($blog); //get related blog post $blogRelatedPost = ''; if ($config->get('main_relatedpost', true)) { $blogRelatedPost = $blogModel->getRelatedBlog($blogId); } //get author's recent posts. $authorRecentPosts = ''; if ($config->get('main_showauthorinfo') && $config->get('main_showauthorposts')) { $authorPostLimit = $config->get('main_showauthorpostscount'); $authorRecentPosts = $blogModel->getBlogsBy('blogger', $blog->created_by, 'latest', $authorPostLimit); } // Facebook Like integrations require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'facebook.php'; $facebookLike = EasyBlogFacebookLikes::getLikeHTML($blog, $rawIntroText); $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); // @rule: Add opengraph tags if required. if ($config->get('main_facebook_opengraph')) { EasyBlogFacebookLikes::addOpenGraphTags($blog, $rawIntroText); } // Add Twitter card details on page. EasyBlogHelper::getHelper('Twitter')->addCard($blog, $rawIntroText); // @task: Add canonical URLs. if ($config->get('main_canonical_entry')) { $canonicalUrl = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true, true); $document->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '"/>'); } // @task: Add rel="nofollow" if necessary. if ($config->get('main_anchor_nofollow')) { $blog->content = EasyBlogHelper::addNoFollow($blog->content); } $prevLink = array(); $nextLink = array(); // construct prev & next link //get blog navigation object if ($config->get('layout_navigation')) { $blogNav = EasyBlogHelper::getBlogNavigation($blogId, $blog->created, $team, 'team'); //$team $prevLink = array(); if (!empty($blogNav['prev'])) { $prevLink['id'] = $blogNav['prev'][0]->id; $prevLink['title'] = JString::strlen($blogNav['prev'][0]->title) > 50 ? JString::substr($blogNav['prev'][0]->title, 0, 50) . '...' : $blogNav['prev'][0]->title; } $nextLink = array(); if (!empty($blogNav['next'])) { $nextLink['id'] = $blogNav['next'][0]->id; $nextLink['title'] = JString::strlen($blogNav['next'][0]->title) > 50 ? JString::substr($blogNav['next'][0]->title, 0, 50) . '...' : $blogNav['next'][0]->title; } } // @rule: Mark notifications item in EasyDiscuss when the blog entry is viewed if ($config->get('integrations_easydiscuss_notification_blog')) { EasyBlogHelper::getHelper('EasyDiscuss')->readNotification($blog->id, EBLOG_NOTIFICATIONS_TYPE_BLOG); } if ($config->get('integrations_easydiscuss_notification_comment')) { EasyBlogHelper::getHelper('EasyDiscuss')->readNotification($blog->id, EBLOG_NOTIFICATIONS_TYPE_COMMENT); } if ($config->get('integrations_easydiscuss_notification_rating')) { EasyBlogHelper::getHelper('EasyDiscuss')->readNotification($blog->id, EBLOG_NOTIFICATIONS_TYPE_RATING); } //get social bookmark provider. require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'bookmark.php'; $bookmark = EasyBlogBookmark::getHTML(); // @task: As we are standardizing the admin tools, we fix the necessary properties here. $blog->isFeatured = $isFeatured; $theme->set('currentURL', EasyBlogRouter::_('index.php?option=com_easyblog&view=latest')); $theme->set('facebookLike', $facebookLike); $theme->set('notice', $notice); $theme->set('team', $team); $theme->set('blog', $blog); $theme->set('tags', $tags); $theme->set('blogger', $blogger); $theme->set('prevLink', $prevLink); $theme->set('nextLink', $nextLink); $theme->set('blogRelatedPost', $blogRelatedPost); $theme->set('authorRecentPosts', $authorRecentPosts); $theme->set('isFeatured', $isFeatured); $theme->set('isMineBlog', EasyBlogHelper::isMineBlog($blog->created_by, $my->id)); $theme->set('acl', $acl); $theme->set('url', $url); $theme->set('commentHTML', $commentHtml); $theme->set('bookmark', $bookmark); $theme->set('pdfLinkProperties', EasyBlogHelper::getPDFlinkProperties()); $theme->set('ispreview', false); // @task: trackbacks $trackbacks = $blogModel->getTrackback($blogId); $theme->set('trackbackURL', EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=trackback&post_id=' . $blog->id, true, true)); $theme->set('trackbacks', $trackbacks); //google adsense $adsense = EasyBlogGoogleAdsense::getHTML($blogger->id); $blogHeader = $adsense->header; $blogFooter = $adsense->footer; $theme->set('adsenseHTML', $adsense->beforecomments); $blogHtml = $theme->fetch('blog.read' . EasyBlogHelper::getHelper('Sources')->getTemplateFile($blog->source) . '.php'); echo $blogHeader; echo $blogHtml; echo $blogFooter; }
public function checkPrivacy($blog) { $obj = new stdClass(); $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->message = ''; // If it is public or site amdin, always allow browser to access. if (!$blog->access || EasyBlogHelper::isSiteAdmin()) { $obj->allowed = true; return $obj; } $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $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()) { switch ($blog->access) { case '10': $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->error = $obj->allowed ? '' : $this->getErrorHTML(); break; case '30': // if user is the blog author, we always allow. $obj->allowed = $my->id == $blog->created_by ? true : false; if (!$obj->allowed) { $obj->allowed = Foundry::user($my->id)->isFriends($blog->created_by); } $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.friends'); break; case '40': $obj->allowed = $my->id == $blog->created_by; $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.owner'); break; } return $obj; } else { if ($config->get('main_jomsocial_privacy') && JFile::exists($file)) { switch ($blog->access) { case '20': $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->error = $obj->allowed ? '' : $this->getErrorHTML(); break; case '30': require_once $file; $obj->allowed = CFactory::getUser($my->id)->isFriendWith($blog->created_by); $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.friends'); break; case '40': $obj->allowed = $my->id == $blog->created_by; $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.owner'); break; } return $obj; } } if ($blog->access) { $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->error = $obj->allowed ? '' : $this->getErrorHTML(); } // If not integrated with any privacy providers, we assume that the blog // is private. return $obj; }
/** * Stores the blog post * * @since 5.0 * @access public * @param string * @return */ public function store($log = true) { // Load language file from the front end. EB::loadLanguages(); // Whenever the blog post is stored, we need to clear the cache. $cache = EB::getCache(); $cache->clean('com_easyblog'); $cache->clean('_system'); $cache->clean('page'); // Get easyblog's config $config = EB::config(); // Get the current logged in user. $my = JFactory::getUser(); // @rule: no guest allowed to create blog post. if (JRequest::getVar('task', '') != 'cron' && JRequest::getVar('task', '') != 'cronfeed' && empty($my->id)) { $this->setError(JText::_('COM_EASYBLOG_YOU_ARE_NOT_LOGIN')); return false; } $under_approval = false; if (isset($this->under_approval)) { $under_approval = true; // now we need to reset this variable from the blog object. unset($this->under_approval); } // @trigger: onBeforeSave $this->triggerBeforeSave(); // @rule: Determine if this record is new or not. if (empty($this->isnew)) { $isNew = empty($this->id) ? true : false; } else { $isNew = true; } // @rule: Get the rulesets for this user. $acl = EB::acl(); // @rule: Process badword filters for title here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->title); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_TITLE_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Check for minimum words in the content if required. if ($config->get('main_post_min') && $this->_checkLength) { $minimum = $config->get('main_post_length'); $total = JString::strlen(strip_tags($this->intro . $this->content)); if ($total < $minimum) { $this->setError(JText::sprintf('COM_EASYBLOG_CONTENT_LESS_THAN_MIN_LENGTH', $minimum)); return false; } } // @rule: Check for invalid title if (empty($this->title) || $this->title == JText::_('COM_EASYBLOG_DASHBOARD_WRITE_DEFAULT_TITLE')) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_TITLE_ERROR')); return false; } // @rule: For edited blogs, ensure that they have permissions to edit it. if (!$isNew && $this->created_by != JFactory::getUser()->id && !EasyBlogHelper::isSiteAdmin() && !$acl->get('moderate_entry')) { // @task: Only throw error when this blog post is not a team blog post and it's not owned by the current logged in user. $model = EB::model('TeamBlogs'); $contribution = $model->getBlogContributed($this->id); if (!$contribution || !$model->checkIsTeamAdmin(JFactory::getUser()->id, $contribution->team_id)) { $this->setError(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG')); return false; } } // Filter / strip contents that are not allowed $filterTags = EasyBlogHelper::getHelper('Acl')->getFilterTags(); $filterAttributes = EasyBlogHelper::getHelper('Acl')->getFilterAttributes(); // @rule: Apply filtering on contents jimport('joomla.filter.filterinput'); $inputFilter = JFilterInput::getInstance($filterTags, $filterAttributes, 1, 1, 0); $inputFilter->tagBlacklist = $filterTags; $inputFilter->attrBlacklist = $filterAttributes; $filterTpe = EasyBlogHelper::getJoomlaVersion() >= '1.6' ? 'html' : 'string'; if (count($filterTags) > 0 && !empty($filterTags[0]) || count($filterAttributes) > 0 && !empty($filterAttributes[0])) { $this->intro = $inputFilter->clean($this->intro, $filterTpe); $this->content = $inputFilter->clean($this->content, $filterTpe); } // @rule: Process badword filters for content here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->intro . $this->content); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_POST_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Test for the empty-ness if (empty($this->intro) && empty($this->content)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_CONTENT_ERROR')); } $state = parent::store(); $source = JRequest::getVar('blog_contribute_source', 'easyblog'); // if this is blog edit, then we should see the column isnew to determine // whether the post is really new or not. if (!$isNew) { $isNew = $this->isnew; } // this one is needed for the trigger to work properly. $this->isnew = $isNew; // @trigger: onAfterSave $this->triggerAfterSave(); // @task: If auto featured is enabled, we need to feature the blog post automatically since the blogger is featured. if ($config->get('main_autofeatured', 0) && EB::isFeatured('blogger', $this->created_by) && !EB::isFeatured('post', $this->id)) { // just call the model file will do as we do not want to create stream on featured action at this migration. $modelF = EB::model('Featured'); $modelF->makeFeatured('post', $this->id); } // @task: This is when the blog is either created or updated. if ($source == 'easyblog' && $state && $this->published == EASYBLOG_POST_PUBLISHED && $log) { $category = EB::table('Category'); $category->load($this->category_id); $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($category->private == 0) { // @rule: Add new stream item in jomsocial EB::jomsocial()->addBlogActivity($this, $isNew); } // @rule: Add stream for easysocial if ($config->get('integrations_easysocial_stream_newpost') && $easysocial->exists() && $isNew) { $easysocial->createBlogStream($this, $isNew); } // update privacy in easysocial. if ($config->get('integrations_easysocial_privacy') && $easysocial->exists()) { $easysocial->updateBlogPrivacy($this); } } if ($source == 'easyblog' && $state && $this->published == EASYBLOG_POST_PUBLISHED && $isNew && $log) { // @rule: Send email notifications out to subscribers. $author = EB::user($this->created_by); // Ping pingomatic EB::pingomatic()->ping($this); // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($easysocial->exists()) { $easysocial->assignPoints('blog.create', $this->created_by); } // @rule: Add userpoints for jomsocial if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.blog.add', $this->created_by); } } $link = $this->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $this->id); // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_BLOG', str_replace("administrator/", "", $author->getProfileLink()), $author->getName(), $link, $this->title), 'easyblog_new_blog', $target, $author, $link); } // Get list of users who subscribed to this blog. // @rule: Add notifications for easysocial if ($config->get('integrations_easysocial_notifications_newpost') && $easysocial->exists()) { $easysocial->notifySubscribers($this, 'new.post'); } // @rule: Add indexer for easysocial if ($config->get('integrations_easysocial_indexer_newpost') && $easysocial->exists()) { $easysocial->addIndexerNewBlog($this); } // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $this->created_by); // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_BLOG_POST')); if ($config->get('integrations_easydiscuss_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($this, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_BLOG', $author->getName(), $this->title), EBLOG_NOTIFICATIONS_TYPE_BLOG, $target, $this->created_by, $link); } // AUP EB::aup()->assignPoints('plgaup_easyblog_add_blog', $this->created_by, JText::sprintf('COM_EASYBLOG_AUP_NEW_BLOG_CREATED', $this->getPermalink(), $this->title)); // Update the isnew column so that if user edits this entry again, it doesn't send any notifications the second time. $this->isnew = $this->published && $this->isnew ? 0 : 1; $this->store(false); } return $state; }
function statistic() { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); // Add noindex for tags view by default. $document->setMetadata('robots', 'noindex,follow'); $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $bId = JRequest::getCmd('id', '0'); //stats type $statType = JRequest::getString('stat', ''); $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', ''); $statObject = null; if ($statType == 'category') { $statObject = EasyBlogHelper::getTable('Category', 'Table'); $statObject->load($statId); } else { JTable::addIncludePath(EBLOG_TABLES); $statObject = EasyBlogHelper::getTable('Tag', 'Table'); $statObject->load($statId); } $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($bId); // set meta tags for blogger if ($acl->rules->allow_seo) { EasyBlogHelper::setMeta($blogger->id, META_TYPE_BLOGGER, true); } if (!EasyBlogRouter::isCurrentActiveMenu('blogger')) { $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger')); } if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) { $this->setPathway($blogger->getName()); } $model = $this->getModel('Blog'); $data = $model->getBlogsBy('blogger', $blogger->id, $sort); $pagination = $model->getPagination(); $data = EasyBlogHelper::formatBlog($data); $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss'); if ($config->get('layout_showcomment', false)) { for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $maxComment = $config->get('layout_showcommentcount', 3); $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc'); $comments = EasyBlogHelper::formatBlogCommentsLite($comments); $row->comments = $comments; } } $twitterFollowMelink = EasyBlogSocialShareHelper::getLink('twitter', $blogger->id); if ($config->get('main_rss')) { if ($config->get('main_feedburner') && $config->get('main_feedburnerblogger')) { $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); } else { // Add rss feed link $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $document->addHeadLink($blogger->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } } $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $pageNumber = $pagination->get('pages.current'); $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber); $statTitle = ''; if (isset($statType)) { if ($statType == 'tag') { $statTitle = ' - ' . JText::sprintf('COM_EASYBLOG_BLOGGER_STAT_TAG', $statObject->title); } else { $statTitle = ' - ' . JText::sprintf('COM_EASYBLOG_BLOGGER_STAT_CATEGORY', $statObject->title); } } $document->setTitle($blogger->getName() . $statTitle . $pageText . $pageTitle); $tpl = new CodeThemes(); $tpl->set('blogger', $blogger); $tpl->set('sort', $sort); $tpl->set('blogs', $data); $tpl->set('config', $config); $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin()); $tpl->set('pagination', $pagination->getPagesLinks()); $tpl->set('twitterFollowMelink', $twitterFollowMelink); $tpl->set('my', $my); $tpl->set('acl', $acl); $tpl->set('currentURL', ltrim('/', JRequest::getURI())); $tpl->set('statType', $statType); $tpl->set('statObject', $statObject); echo $tpl->fetch('blog.blogger.php'); }
<h2> <?php echo $statType == 'tag' ? JText::sprintf('COM_EASYBLOG_TEAMBLOG_STAT_TAG', $team->title, $statObject->title) : JText::sprintf('COM_EASYBLOG_TEAMBLOG_STAT_CATEGORY', $team->title, $statObject->title); ?> </h2> </div> <?php } ?> <?php echo EasyBlogHelper::renderModule('easyblog-after-team-header'); ?> <?php if ($team->access == EBLOG_TEAMBLOG_ACCESS_MEMBER && empty($team->isMember) && !EasyBlogHelper::isSiteAdmin()) { ?> <div class="eblog-message warning mtm"> <?php echo JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY'); ?> <?php echo $system->my->id != 0 ? JText::sprintf('COM_EASYBLOG_TEAMBLOG_CLICK_TO_JOIN', 'eblog.teamblog.join(' . $team->id . ')') : ''; ?> </div> <?php } else { if ($data) { ?> <div id="ezblog-posts" class="forTeamBlog">