Ejemplo n.º 1
1
 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;
 }
Ejemplo n.º 2
0
 /**
  * Determines whether the blogger is a featured blogger
  **/
 function isFeatured()
 {
     return EasyBlogHelper::isFeatured('blogger', $this->id);
 }
Ejemplo n.º 3
0
            echo $contributionDisplay;
            ?>
		</td>
		<td align="center">
			<a href="javascript:void(0);" onclick="return listItemTask('cb<?php 
            echo $i;
            ?>
','<?php 
            echo EasyBlogHelper::isFeatured(EBLOG_FEATURED_BLOG, $row->id) ? 'unfeature' : 'feature';
            ?>
')">
				<img src="<?php 
            echo JURI::root();
            ?>
administrator/components/com_easyblog/assets/images/<?php 
            echo EasyBlogHelper::isFeatured(EBLOG_FEATURED_BLOG, $row->id) ? 'default.png' : 'nodefault.png';
            ?>
" width="16" height="16" border="0" />
			</a>
		</td>
		<td align="center">
		    <?php 
            if ($row->published == 2) {
                ?>
		    <img src="<?php 
                echo JURI::base() . 'components/com_easyblog/assets/images/schedule.png';
                ?>
" border="0" alt="<?php 
                echo JText::_('COM_EASYBLOG_SCHEDULED');
                ?>
" />
Ejemplo n.º 4
0
 /**
  * Responsible to format the blog posts and append neccessary data.
  *
  * @access	public
  * @param	Array	$data			An array of blog posts.
  * @param	boolean	$loadComments	Determines whether or not to load the comments into the object.
  * @param	boolean $removeFeaturedImage	Determines whether or not to remove featured image from the content.
  * @param	boolean	$loadVideo		If true, video codes will be processed.
  * @param	boolean	$frontpage		Determines whether this is for the front page or not.
  * @return	Array	An array of formatted blog posts.
  */
 public static function formatBlog($data, $loadComments = false, $removeFeaturedImage = true, $loadVideo = true, $frontpage = false, $loadGallery = true)
 {
     $app = JFactory::getApplication();
     $params = $app->getParams('com_easyblog');
     $model = EasyBlogHelper::getModel('Blog');
     $config = EasyBlogHelper::getConfig();
     // @rule: If nothing is supplied, just return the empty data.
     if (empty($data)) {
         return $data;
     }
     // @task: Get the tags relations model.
     $modelPT = EasyBlogHelper::getModel('PostTag');
     // @task : Resultset data
     $result = array();
     for ($i = 0; $i < count($data); $i++) {
         $row =& $data[$i];
         $blog = EasyBlogHelper::getTable('Blog');
         $blog->bind($row);
         // @task: Since the $blog object does not contain 'team_id', we need to set this here.
         if (isset($row->team_id)) {
             $blog->team_id = $row->team_id;
         }
         // @task: Since the $blog object does not contain 'category', we need to set this here.
         $blog->category = $row->category;
         $blog->featuredImage = isset($row->featuredImage) ? $row->featuredImage : '';
         $profile = EasyBlogHelper::getTable('Profile', 'Table');
         $profile->load($blog->created_by);
         // @legacy The following variables are no longer used in 3.5
         // @since 3.5
         $blog->avatar = $profile->getAvatar();
         $blog->avatarLink = $profile->getProfileLink();
         $blog->displayName = $profile->getName();
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $blog->author = $profile;
         $blog->blogger = $profile;
         $blog->isFeatured = EasyBlogHelper::isFeatured('post', $blog->id);
         $blog->category = empty($blog->category) ? JText::_('COM_EASYBLOG_UNCATEGORIZED') : JText::_($blog->category);
         // @task: Detect password protections.
         $requireVerification = false;
         $tmpTitle = $blog->title;
         if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
             $blog->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $blog->title);
             $requireVerification = true;
         }
         // @rule: If user already authenticated with the correct password, we will hide the password
         if ($requireVerification && EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) {
             $blog->title = $tmpTitle;
             $blog->blogpassword = '';
         }
         // @rule: Initialize all variables
         $blog->videos = array();
         $blog->galleries = array();
         $blog->albums = array();
         $blog->audios = array();
         // @rule: Before anything get's processed we need to format all the microblog posts first.
         if (!empty($blog->source)) {
             self::formatMicroblog($blog);
         }
         // @rule: Detect if the content requires a read more link.
         $blog->readmore = EasyBlogHelper::requireReadmore($blog);
         // @rule: Remove any adsense codes from the content.
         $blog->intro = EasyBlogGoogleAdsense::stripAdsenseCode($blog->intro);
         $blog->content = EasyBlogGoogleAdsense::stripAdsenseCode($blog->content);
         // @rule: Content truncations.
         EasyBlogHelper::truncateContent($blog, $loadVideo, $frontpage, $loadGallery);
         // @task: Legacy fix for blog posts prior to 3.5
         // Remove first image from featured post
         if ($removeFeaturedImage && $blog->isFeatured) {
             $blog->text = EasyBlogHelper::removeFeaturedImage($blog->text);
         }
         // @rule: Add nofollow tags if necessary
         if ($config->get('main_anchor_nofollow')) {
             $blog->text = self::addNoFollow($blog->text);
         }
         // @rule: $limitstart variable is required by content plugins.
         $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
         // @trigger: onEasyBlogPrepareContent
         JPluginHelper::importPlugin('easyblog');
         EasyBlogHelper::triggerEvent('easyblog.prepareContent', $blog, $params, $limitstart);
         $blog->introtext = $blog->intro;
         // @trigger: onPrepareContent / onContentPrepare
         EasyBlogHelper::triggerEvent('prepareContent', $blog, $params, $limitstart);
         $blog->excerpt = $blog->introtext;
         $blog->content = $blog->text;
         //onPrepareContent trigger end
         // @rule: Assign tags to the custom properties.
         $blog->tags = $modelPT->getBlogTags($blog->id);
         // @rule: Assign total comments in this blog post.
         $blog->totalComments = EasyBlogHelper::getHelper('Comment')->getCommentCount($blog);
         $blog->comments = array();
         if ($loadComments) {
             $blog->comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($blog->id, $config->get('layout_showcommentcount', 3), 'desc', true);
         }
         $blog->event = new stdClass();
         // @trigger: onContentAfterTitle / onAfterDisplayTitle
         $results = EasyBlogHelper::triggerEvent('afterDisplayTitle', $blog, $params, $limitstart);
         $blog->event->afterDisplayTitle = JString::trim(implode("\n", $results));
         // @trigger: onContentAfterTitle / onAfterDisplayTitle
         $results = EasyBlogHelper::triggerEvent('beforeDisplayContent', $blog, $params, $limitstart);
         $blog->event->beforeDisplayContent = JString::trim(implode("\n", $results));
         // @trigger: onContentAfterTitle / onAfterDisplayTitle
         $results = EasyBlogHelper::triggerEvent('afterDisplayContent', $blog, $params, $limitstart);
         $blog->event->afterDisplayContent = JString::trim(implode("\n", $results));
         // Facebook Like integrations
         require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'facebook.php';
         $facebookLike = EasyBlogFacebookLikes::getLikeHTML($blog);
         $blog->facebookLike = $facebookLike;
         $result[] = $blog;
     }
     return $result;
 }
Ejemplo n.º 5
0
 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');
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
            ?>
						<?php 
        }
        ?>
					</td>

					<td class="nowrap hidden-phone center">
						<a class="btn btn-micro jgrid" onclick="return listItemTask('cb<?php 
        echo $i;
        ?>
','<?php 
        echo EasyBlogHelper::isFeatured(EBLOG_FEATURED_BLOG, $row->id) ? 'unfeature' : 'feature';
        ?>
')">
						<?php 
        if (EasyBlogHelper::isFeatured(EBLOG_FEATURED_BLOG, $row->id)) {
            ?>
							<i class="icon-star"></i>
						<?php 
        } else {
            ?>
							<i class="icon-star-empty"></i>
						<?php 
        }
        ?>
						</a>
					</td>

					<td class="nowrap hidden-phone center">
						<a onclick="return listItemTask('cb<?php 
        echo $i;