예제 #1
0
 function display($tpl = null)
 {
     // @rule: Test for user access if on 1.6 and above
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if (!JFactory::getUser()->authorise('easyblog.manage.user', 'com_easyblog')) {
             JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             JFactory::getApplication()->close();
         }
     }
     //initialise variables
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $config = EasyBlogHelper::getConfig();
     $id = JRequest::getInt('id');
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($id);
     $post = EasyBlogHelper::getSession('EASYBLOG_REGISTRATION_POST');
     $avatarIntegration = $config->get('layout_avatarIntegration', 'default');
     $user = JFactory::getUser($id);
     $isNew = $user->id == 0 ? true : false;
     if ($isNew && !empty($post)) {
         unset($post['id']);
         $pwd = $post['password'];
         unset($post['password']);
         unset($post['password2']);
         $user->bind($post);
         $post['password'] = $pwd;
         $blogger->bind($post);
     }
     jimport('joomla.html.pane');
     $feedburner = EasyBlogHelper::getTable('Feedburner', 'Table');
     $feedburner->load($id);
     JTable::addIncludePath(EBLOG_TABLES);
     //twitter
     $twitter = EasyBlogHelper::getTable('Oauth', 'Table');
     $twitter->loadByUser($user->id, EBLOG_OAUTH_TWITTER);
     //linkedin
     $linkedin = EasyBlogHelper::getTable('Oauth', 'Table');
     $linkedin->loadByUser($user->id, EBLOG_OAUTH_LINKEDIN);
     //facebook
     $facebook = EasyBlogHelper::getTable('Oauth', 'Table');
     $facebook->loadByUser($user->id, EBLOG_OAUTH_FACEBOOK);
     $adsense = EasyBlogHelper::getTable('Adsense', 'Table');
     $adsense->load($id);
     if ($isNew && !empty($post)) {
         $feedburner->url = $post['feedburner_url'];
         $twitter->message = $post['integrations_twitter_message'];
         $twitter->auto = $post['integrations_twitter_auto'];
         $linkedin->auto = $post['integrations_linkedin_auto'];
         $linkedin->private = isset($post['integrations_linkedin_private']) ? $post['integrations_linkedin_private'] : false;
         $facebook->auto = $post['integrations_facebook_auto'];
         $adsense->published = $post['adsense_published'];
         $adsense->code = $post['adsense_code'];
         $adsense->display = $post['adsense_display'];
     }
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_users' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'user.php';
         $jUserModel = new UsersModelUser();
         $form = $jUserModel->getForm();
         $form->setValue('password', null);
         $form->setValue('password2', null);
         $this->assignRef('form', $form);
     }
     $joomla_date = EasyBlogHelper::getJoomlaVersion() <= '1.5' ? '%Y-%m-%d %H:%M:%S' : 'Y-m-d H:i:s';
     $editor = JFactory::getEditor($config->get('layout_editor', 'tinymce'));
     $userParams = $user->getParameters(true);
     $bloggerRawParams = $blogger->getParams();
     if (is_array($bloggerRawParams)) {
         $bloggerRawParams = '';
     }
     $bloggerParams = EasyBlogHelper::getRegistry($bloggerRawParams);
     $this->assignRef('bloggerParams', $bloggerParams);
     $this->assignRef('editor', $editor);
     $this->assignRef('dateFormat', $joomla_date);
     $this->assignRef('config', $config);
     $this->assignRef('pane', $pane);
     $this->assignRef('feedburner', $feedburner);
     $this->assignRef('adsense', $adsense);
     $this->assignRef('twitter', $twitter);
     $this->assignRef('facebook', $facebook);
     $this->assignRef('linkedin', $linkedin);
     $this->assignRef('blogger', $blogger);
     $this->assignRef('user', $user);
     $this->assignRef('isNew', $isNew);
     $this->assignRef('params', $userParams);
     $this->assignRef('avatarIntegration', $avatarIntegration);
     $this->assignRef('post', $post);
     parent::display($tpl);
 }
예제 #2
0
파일: view.html.php 프로젝트: Tommar/vino2
 function write()
 {
     $document = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $mainframe = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $siteAdmin = EasyBlogHelper::isSiteAdmin();
     $my = JFactory::getUser();
     // set the editor title based on operation
     $editorTitle = '';
     // just to inform the view that this is edit operation
     $showDraftStatus = true;
     $isEdit = false;
     if (!EasyBlogHelper::isLoggedIn()) {
         EasyBlogHelper::showLogin();
         return;
     }
     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_WRITE_BREADCRUMB'));
     if (!$acl->rules->add_entry) {
         $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard', false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
         $mainframe->close();
     }
     // enable datetime picker
     EasyBlogDateHelper::enableDateTimePicker();
     // Add the Calendar includes to the document <head> section
     JHTML::_('behavior.calendar');
     // Add modal behavior
     JHTML::_('behavior.modal');
     // Load the JEditor object
     if ($config->get('layout_editor_author')) {
         // Get user's parameters
         $userParams = EasyBlogHelper::getRegistry($my->params);
         $editorType = $userParams->get('editor', $config->get('layout_editor'));
         $editor = JFactory::getEditor($editorType);
     } else {
         $editor = JFactory::getEditor($config->get('layout_editor'));
     }
     $user = EasyBlogHelper::getTable('Profile', 'Table');
     $user->setUser($my);
     $model = $this->getModel('Blog');
     $categoriesModel = $this->getModel('Categories');
     $publishedOnly = true;
     $categoryItems = $categoriesModel->getParentCategories('', 'all', $publishedOnly, true);
     $categories = array();
     if ($categoryItems) {
         foreach ($categoryItems as $categoryItem) {
             $category = EasyBlogHelper::getTable('Category');
             $category->bind($categoryItem);
             $categories[] = $category;
         }
     }
     $trackbacksModel = $this->getModel('TrackbackSent');
     $blogContributed = '';
     $trackbacks = '';
     $external = '';
     $extGroupId = '';
     // @task: See if there's any uid in the query string.
     // @since 3.5
     $source = JRequest::getVar('source');
     $uid = JRequest::getInt('uid');
     // get blogid if exists
     $blogId = JRequest::getVar('blogid', '');
     // Test if draft id exists
     $draftId = JRequest::getVar('draft_id', '');
     // test if this is a under approval post or not.
     $underApproval = JRequest::getVar('approval', '');
     // Load blog table
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($blogId);
     // Test if this blog belongs to the team and the current browser is the team admin.
     $teamblogModel = $this->getModel('TeamBlogs');
     $teamContribution = $teamblogModel->getBlogContributed($blog->id);
     // Check if the person has access to create a new blog post
     if ($blog->id && $blog->created_by != $my->id && !$siteAdmin && empty($acl->rules->moderate_entry) && !$teamContribution) {
         $url = 'index.php?option=com_easyblog&view=dashboard';
         $mainframe->redirect(EasyBlogRouter::_($url, false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
     }
     // This will be the team blog checking
     $isCurrentTeamAdmin = false;
     if ($teamContribution && !$siteAdmin && empty($acl->rules->moderate_entry)) {
         $isCurrentTeamAdmin = $teamblogModel->checkIsTeamAdmin($my->id, $teamContribution->team_id);
         // Test if the user has access to this team posting.
         if (!$isCurrentTeamAdmin && $blog->created_by != $my->id) {
             $url = 'index.php?option=com_easyblog&view=dashboard';
             $mainframe->redirect(EasyBlogRouter::_($url, false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
         }
     }
     $tmpBlogData = EasyBlogHelper::getSession('tmpBlogData');
     $loadFromSession = false;
     $blogSource = '';
     if (isset($tmpBlogData)) {
         $loadFromSession = true;
         $blog->bind($tmpBlogData);
         // reprocess the date offset here.
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($blog->created)) {
             $date = EasyBlogHelper::getDate($blog->created, $tzoffset);
             $blog->created = $date->toMySQL();
         }
         if (!empty($blog->publish_up) && $blog->publish_up != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_up, $tzoffset);
             $blog->publish_up = $date->toMySQL();
         }
         if (!empty($blog->publish_down) && $blog->publish_down != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_down, $tzoffset);
             $blog->publish_down = $date->toMySQL();
         }
         //bind the content from previous form
         $blog->content = $tmpBlogData['write_content'];
         $blog->tags = array();
         if (isset($tmpBlogData['tags'])) {
             $blog->tags = $this->bindTags($tmpBlogData['tags']);
         }
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = isset($tmpBlogData['keywords']) ? $tmpBlogData['keywords'] : '';
         $meta->description = isset($tmpBlogData['description']) ? $tmpBlogData['description'] : '';
         if (isset($tmpBlogData['blog_contribute'])) {
             $blogContributed = $this->bindContribute($tmpBlogData['blog_contribute']);
         }
         $contributionSource = isset($tmpBlogData['blog_contribute_source']) ? $tmpBlogData['blog_contribute_source'] : '';
         if (!empty($contributionSource) && $contributionSource != 'easyblog' && !$uid) {
             $external = true;
             $extGroupId = $tmpBlogData['blog_contribute'];
             $blogSource = 'group';
         }
         if (!empty($contributionSource) && $contributionSource != 'easyblog' && $uid && $source == 'jomsocial.event') {
             $external = true;
             $uid = $tmpBlogData['blog_contribute'];
             $blogSource = 'event';
         }
     }
     // Check if this is an edited post and if it has draft.
     $draft = EasyBlogHelper::getTable('Draft', 'Table');
     $isDraft = false;
     if (!empty($draftId)) {
         $draft->load($draftId);
         $blog->load($draft->entry_id);
         $blog->bind($draft);
         $blog->tags = empty($draft->tags) ? array() : $this->bindTags(explode(',', $draft->tags));
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = $draft->metakey;
         $meta->description = $draft->metadesc;
         if (!empty($draft->trackbacks)) {
             $blog->unsaveTrackbacks = $draft->trackbacks;
         }
         if ($draft->blog_contribute) {
             $blogContributed = $this->bindContribute($draft->blog_contribute);
         }
         $blog->tags = array();
         if (!empty($draft->tags)) {
             $blog->tags = $this->bindTags(explode(',', $draft->tags));
         }
         $blog->set('id', $draft->entry_id);
         $blogId = $blog->id;
         $isDraft = true;
     } else {
         // We only want to load drafts that has a blog id.
         if ($blog->id) {
             $draft->loadByEntry($blog->id);
         }
     }
     // set page title
     if (!empty($blogId)) {
         $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_EDIT_POST'));
         // @task: Set the page title
         parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend'));
         $editorTitle = JText::_('COM_EASYBLOG_DASHBOARD_EDIT_POST');
         // check if previous status is not Draft
         if ($blog->published == POST_ID_DRAFT) {
             $showDraftStatus = true;
         }
         $isEdit = true;
         //perform some title string formatting
         $blog->title = $this->escape($blog->title);
     } else {
         $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_WRITE_POST'));
         // @task: Set the page title
         parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend'));
         $editorTitle = JText::_('COM_EASYBLOG_DASHBOARD_WRITE_POST');
         // set the default publishing status only if it is a brand new creation page.
         if (!$loadFromSession && !$isDraft) {
             // by default, all new post MUST BE set to draft
             $blog->published = $config->get('main_blogpublishing', '3');
         }
     }
     //get all tags ever created.
     $newTagsModel = $this->getModel('Tags');
     $blog->newtags = $newTagsModel->getTags();
     //prepare initial blog settings.
     $isPrivate = $config->get('main_blogprivacy', '0');
     $allowComment = $config->get('main_comment', 1);
     $allowSubscribe = $config->get('main_subscription', 1);
     $showFrontpage = $config->get('main_newblogonfrontpage', 0);
     $sendEmails = $config->get('main_sendemailnotifications', 1);
     $isSiteWide = isset($blog->issitewide) ? $blog->issitewide : '1';
     $teamblogModel = $this->getModel('TeamBlogs');
     $teams = !empty($blog->created_by) ? $teamblogModel->getTeamJoined($blog->created_by) : $teamblogModel->getTeamJoined($my->id);
     if (!empty($blog->id)) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $config->get('main_subscription') ? $blog->subscription : 0;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
         //get user teamblog
         $teams = $teamblogModel->getTeamJoined($blog->created_by);
         //@task: List all trackbacks
         $trackbacks = $trackbacksModel->getSentTrackbacks($blogId);
     }
     if ($loadFromSession || $isDraft) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
     }
     $author = null;
     //if site admin then get get blog creator and include a javascript function to change author.
     if ($siteAdmin || !empty($acl->rules->moderate_entry) || isset($teamContribution) && $isCurrentTeamAdmin) {
         if (!empty($blog->created_by)) {
             $creator = JFactory::getUser($blog->created_by);
             $author = EasyBlogHelper::getTable('Profile', 'Table');
             $author->setUser($creator);
             unset($creator);
         }
     }
     //check if can upload image or not.
     $useImageManager = $config->get('main_media_manager', 1);
     if (!isset($meta)) {
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = '';
         $meta->description = '';
     }
     if (empty($blog->created_by) || $blog->created_by == $my->id || $siteAdmin || !empty($acl->rules->moderate_entry) || $teamContribution) {
         $blog->tags = isset($blog->tags) && !empty($blog->tags) ? $blog->tags : array();
         if (!$loadFromSession && !$isDraft) {
             // get the tag only if it is not loaded from the session value
             if ($blogId) {
                 $tagsModel = $this->getModel('PostTag');
                 $blog->tags = $tagsModel->getBlogTags($blogId);
                 // get meta tags
                 $metaModel = $this->getModel('Metas');
                 $meta = $metaModel->getPostMeta($blogId);
             }
         }
         $onlyPublished = empty($blogId) ? true : false;
         $isFrontendWrite = true;
         $nestedCategories = '';
         $defaultCategory = JRequest::getInt('categoryId');
         $menu = JFactory::getApplication()->getMenu()->getActive();
         if ($menu && isset($menu->params)) {
             $param = EasyBlogHelper::getRegistry();
             $param->load($menu->params);
             $catId = $param->get('categoryId');
             if ($catId) {
                 $defaultCategory = $catId;
             }
         }
         // @task: If blog is being edited, it should contain a category_id property.
         $defaultCategory = empty($blog->category_id) ? $defaultCategory : $blog->category_id;
         if ($config->get('layout_dashboardcategoryselect') == 'select') {
             $nestedCategories = EasyBlogHelper::populateCategories('', '', 'select', 'category_id', $defaultCategory, true, $onlyPublished, $isFrontendWrite);
         }
         echo $this->showToolbar(__FUNCTION__, $user);
         $tpl = new CodeThemes('dashboard');
         $blogger_id = !isset($blog->created_by) ? $user->id : $blog->created_by;
         $content = $blog->intro;
         // Append the readmore if necessary
         if (!empty($blog->intro) && !empty($blog->content)) {
             $content .= '<hr id="system-readmore" />';
         }
         $content .= $blog->content;
         $defaultCategoryName = '';
         if (empty($defaultCategory)) {
             //get default category if configured.
             $defaultCategory = EasyBlogHelper::getDefaultCategoryId();
         }
         if (!empty($defaultCategory)) {
             $categoryTbl = EasyBlogHelper::getTable('Category');
             $categoryTbl->load($defaultCategory);
             $defaultCategoryName = $categoryTbl->title;
         }
         if ($draft->id != 0 && $isDraft) {
             if (!empty($draft->external_source)) {
                 $external = true;
                 $extGroupId = $draft->external_group_id;
             }
         } else {
             if (!$loadFromSession) {
                 // If writing is for an external source, we need to tell the editor to strip down some unwanted features
                 $external = JRequest::getVar('external', false);
                 //check if this is a external group contribution.
                 $extGroupId = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id);
                 if (!empty($extGroupId)) {
                     $external = $extGroupId;
                     $blogSource = 'group';
                 }
                 if (!empty($uid)) {
                     $external = $uid;
                     $blogSource = 'event';
                 }
                 $externalEventId = EasyBlogHelper::getHelper('Event')->getContribution($blog->id);
                 if (!empty($externalEventId)) {
                     $external = $externalEventId;
                     $blogSource = 'event';
                 }
             }
         }
         // If there's a tag (maybe from the draft area, we need to add the tags data back)
         if ($isDraft && !empty($blog->tags)) {
             $blog->newtags = array_merge($blog->newtags, $blog->tags);
         }
         // Add the breadcrumbs
         $breadcrumbs = array($editorTitle => '');
         $tpl->set('teamContribution', $teamContribution);
         $tpl->set('isCurrentTeamAdmin', $isCurrentTeamAdmin);
         $tpl->set('breadcrumbs', $breadcrumbs);
         $tpl->set('external', $external);
         $tpl->set('extGroupId', $extGroupId);
         $tpl->set('defaultCategory', $defaultCategory);
         $tpl->set('defaultCategoryName', $defaultCategoryName);
         $tpl->set('content', $content);
         $tpl->set('blogger_id', $blogger_id);
         $tpl->set('draft', $draft);
         $tpl->set('isDraft', $isDraft);
         $tpl->set('isPending', $underApproval);
         $tpl->set('isEdit', $isEdit);
         $tpl->set('showDraftStatus', $showDraftStatus);
         $tpl->set('editorTitle', $editorTitle);
         $tpl->set('meta', $meta);
         $tpl->set('editor', $editor);
         $tpl->set('trackbacks', $trackbacks);
         $tpl->set('categories', $categories);
         $tpl->set('blog', $blog);
         $tpl->set('user', $user);
         $tpl->set('isPrivate', $isPrivate);
         $tpl->set('allowComment', $allowComment);
         $tpl->set('subscription', $allowSubscribe);
         $tpl->set('trackbacks', $trackbacks);
         $tpl->set('frontpage', $showFrontpage);
         $tpl->set('author', $author);
         $tpl->set('useImageManager', $useImageManager);
         $tpl->set('nestedCategories', $nestedCategories);
         $tpl->set('teams', $teams);
         $tpl->set('isSiteWide', $isSiteWide);
         $tpl->set('send_notification_emails', $sendEmails);
         // @since: 3.5
         // The unique external source and id.
         $tpl->set('blogSource', $blogSource);
         $tpl->set('source', $source);
         $tpl->set('uid', $uid);
         // @since: 3.6
         // Media manager options
         $tpl->set('session', JFactory::getSession());
         // Load media manager and get info about the files.
         require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
         $mediamanager = new EasyBlogMediaManager();
         $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
         $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
         $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
         $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
         $tpl->set('userFolders', $userFolders);
         $tpl->set('userFiles', $userFiles);
         $tpl->set('sharedFolders', $sharedFolders);
         $tpl->set('sharedFiles', $sharedFiles);
         // @rule: Test if the user is already associated with Flickr
         $oauth = EasyBlogHelper::getTable('Oauth');
         $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
         $tpl->set('flickrAssociated', $associated);
         echo $tpl->fetch('dashboard.write.php');
     } else {
         $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard', false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG'), 'error');
     }
 }
예제 #3
0
파일: view.html.php 프로젝트: Tommar/vino2
 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;
 }
예제 #4
0
 function display($tpl = null)
 {
     // @rule: Test for user access if on 1.6 and above
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if (!JFactory::getUser()->authorise('easyblog.manage.blog', 'com_easyblog')) {
             JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             JFactory::getApplication()->close();
         }
     }
     // Load the front end language file.
     $lang = JFactory::getLanguage();
     $lang->load('com_easyblog', JPATH_ROOT);
     // Initial variables.
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $config = EasyBlogHelper::getConfig();
     // Load the JEditor object
     $editor = JFactory::getEditor($config->get('layout_editor', 'tinymce'));
     // Enable datetime picker
     EasyBlogDateHelper::enableDateTimePicker();
     // required variable initiation.
     $meta = null;
     $blogContributed = array();
     $tags = null;
     $external = '';
     $extGroupId = '';
     // Event id state.
     $externalEventId = '';
     //Load blog table
     $blogId = JRequest::getVar('blogid', '');
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($blogId);
     $tmpBlogData = EasyBlogHelper::getSession('tmpBlogData');
     $loadFromSession = false;
     // Initialize default tags.
     $blog->tags = array();
     if (isset($tmpBlogData)) {
         $loadFromSession = true;
         $blog->bind($tmpBlogData);
         // reprocess the date offset here.
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($blog->created)) {
             $date = EasyBlogHelper::getDate($blog->created, $tzoffset);
             $blog->created = $date->toMySQL();
         }
         if (!empty($blog->publish_up) && $blog->publish_up != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_up, $tzoffset);
             $blog->publish_up = $date->toMySQL();
         }
         if (!empty($blog->publish_down) && $blog->publish_down != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_down, $tzoffset);
             $blog->publish_down = $date->toMySQL();
         }
         //bind the content from previous form
         $blog->content = $tmpBlogData['write_content'];
         if (isset($tmpBlogData['tags'])) {
             $blog->tags = $this->bindTags($tmpBlogData['tags']);
         }
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = isset($tmpBlogData['keywords']) ? $tmpBlogData['keywords'] : '';
         $meta->description = isset($tmpBlogData['description']) ? $tmpBlogData['description'] : '';
         if (isset($tmpBlogData['blog_contribute'])) {
             $blogContributed = $this->bindContribute($tmpBlogData['blog_contribute']);
         }
         $contributionSource = isset($tmpBlogData['blog_contribute_source']) ? $tmpBlogData['blog_contribute_source'] : '';
         if (!empty($contributionSource) && $contributionSource != 'easyblog') {
             $external = true;
             $extGroupId = $tmpBlogData['blog_contribute'];
             $externalEventId = $tmpBlogData['blog_contribute'];
         }
         $blog->unsaveTrackbacks = '';
         if (!empty($tmpBlogData['trackback'])) {
             $blog->unsaveTrackbacks = $tmpBlogData['trackback'];
         }
     }
     $draft = EasyBlogHelper::getTable('Draft', 'Table');
     $draft_id = JRequest::getVar('draft_id', '');
     $isDraft = false;
     $pending_approval = JRequest::getVar('approval', '');
     if (!empty($draft_id)) {
         //first check if the logged in user have the required acl or not.
         if (empty($acl->rules->add_entry) || empty($acl->rules->publish_entry) || empty($acl->rules->manage_pending)) {
             $message = JText::_('COM_EASYBLOG_BLOGS_BLOG_NO_PERMISSION_TO_CREATE_BLOG');
             $app->enqueueMessage($message, 'error');
             $app->redirect(JRoute::_('index.php?option=com_easyblog&view=blogs', false));
         }
         $draft->load($draft_id);
         $blog->load($draft->entry_id);
         $blog->bind($draft);
         $blog->tags = $this->bindTags(explode(',', $draft->tags));
         $blog->newtags = $blog->tags;
         $tags = $blog->tags;
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = $draft->metakey;
         $meta->description = $draft->metadesc;
         $blog->unsaveTrackbacks = '';
         if (!empty($draft->trackbacks)) {
             $blog->unsaveTrackbacks = $draft->trackbacks;
         }
         if ($draft->blog_contribute) {
             $blogContributed = $this->bindContribute($draft->blog_contribute);
         }
         $blog->set('id', $draft->entry_id);
         $blogId = $blog->id;
         $isDraft = true;
     }
     // set page title
     if (!empty($blogId)) {
         $doc->setTitle(JText::_('COM_EASYBLOG_BLOGS_EDIT_POST') . ' - ' . $config->get('main_title'));
         $editorTitle = JText::_('COM_EASYBLOG_BLOGS_EDIT_POST');
         // check if previous status is not Draft
         if ($blog->published != POST_ID_DRAFT) {
             $isEdit = true;
         }
     } else {
         $doc->setTitle(JText::_('COM_EASYBLOG_BLOGS_NEW_POST'));
         $editorTitle = JText::_('COM_EASYBLOG_BLOGS_NEW_POST');
         if (!$loadFromSession && !$isDraft) {
             // set to 'publish' for new blog in backend.
             $blog->published = $config->get('main_blogpublishing', '1');
         }
     }
     $author = null;
     if (!empty($blog->created_by)) {
         $creator = JFactory::getUser($blog->created_by);
         $author = EasyBlogHelper::getTable('Profile', 'Table');
         $author->setUser($creator);
         unset($creator);
     } else {
         $creator = JFactory::getUser($my->id);
         $author = EasyBlogHelper::getTable('Profile', 'Table');
         $author->setUser($creator);
         unset($creator);
     }
     //Get tag
     if (!$loadFromSession && !$isDraft) {
         $tagModel = EasyBlogHelper::getModel('PostTag', true);
         $tags = $tagModel->getBlogTags($blogId);
     }
     $tagsArray = array();
     if ($tags) {
         foreach ($tags as $data) {
             $tagsArray[] = $data->title;
         }
         $tagsString = implode(",", $tagsArray);
     }
     //prepare initial blog settings.
     $isPrivate = $config->get('main_blogprivacy', '0');
     $allowComment = $config->get('main_comment', 1);
     $allowSubscribe = $config->get('main_subscription', 1);
     $showFrontpage = $config->get('main_newblogonfrontpage', 0);
     $sendEmails = $config->get('main_sendemailnotifications', 0);
     $isSiteWide = isset($blog->issitewide) ? $blog->issitewide : '1';
     $tbModel = EasyBlogHelper::getModel('TeamBlogs', true);
     $teamBlogJoined = $tbModel->getTeamJoined($author->id);
     if (!empty($blog->id)) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
         //get user teamblog
         $teamBlogJoined = $tbModel->getTeamJoined($blog->created_by);
         if (!$isDraft) {
             $blogContributed = $tbModel->getBlogContributed($blog->id);
         }
     }
     if ($loadFromSession || $isDraft) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
     }
     if (count($blogContributed) > 0 && $blogContributed) {
         for ($i = 0; $i < count($teamBlogJoined); $i++) {
             $joined = $teamBlogJoined[$i];
             if ($joined->team_id == $blogContributed->team_id) {
                 $joined->selected = 1;
                 continue;
             }
         }
     }
     //get all tags ever created.
     $newTagsModel = EasyBlogHelper::getModel('Tags');
     if (isset($blog->newtags)) {
         $blog->newtags = array_merge($blog->newtags, $newTagsModel->getTags());
     } else {
         $blog->newtags = $newTagsModel->getTags();
     }
     //get tags used in this blog post
     if (!$loadFromSession && !$isDraft && $blogId) {
         $tagsModel = EasyBlogHelper::getModel('PostTag');
         $blog->tags = $tagsModel->getBlogTags($blogId);
     }
     //@task: List all trackbacks
     $trackbacksModel = EasyBlogHelper::getModel('TrackbackSent');
     $trackbacks = $trackbacksModel->getSentTrackbacks($blogId);
     // get meta tags
     if (!$loadFromSession && !$isDraft) {
         $metaModel = EasyBlogHelper::getModel('Metas');
         $meta = $metaModel->getPostMeta($blogId);
     }
     //perform some title string formatting
     $blog->title = $this->escape($blog->title);
     $blogger_id = !isset($blog->created_by) ? $my->id : $blog->created_by;
     $defaultCategory = empty($blog->category_id) ? EasyBlogHelper::getDefaultCategoryId() : $blog->category_id;
     $category = EasyBlogHelper::getTable('Category');
     $category->load($defaultCategory);
     $content = $blog->intro;
     // Append the readmore if necessary
     if (!empty($blog->intro) && !empty($blog->content)) {
         $content .= '<hr id="system-readmore" />';
     }
     $content .= $blog->content;
     //check if this is a external group contribution.
     $blog_contribute_source = 'easyblog';
     $external = false;
     $extGroupId = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id);
     $externalEventId = EasyBlogHelper::getHelper('Event')->getContribution($blog->id);
     $extGroupName = '';
     if (!empty($extGroupId)) {
         $external = $extGroupId;
         $blog_contribute_source = EasyBlogHelper::getHelper('Groups')->getGroupSourceType();
         $extGroupName = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id, $blog_contribute_source, 'name');
     }
     if (!empty($externalEventId)) {
         $external = $externalEventId;
         $blog_contribute_source = EasyBlogHelper::getHelper('Event')->getSourceType();
     }
     //site wide or team contribution
     $teamblogModel = EasyBlogHelper::getModel('TeamBlogs');
     $teams = !empty($blog->created_by) ? $teamblogModel->getTeamJoined($blog->created_by) : $teamblogModel->getTeamJoined($my->id);
     $this->assignRef('teams', $teams);
     $this->assignRef('isDraft', $isDraft);
     $joomlaVersion = EasyBlogHelper::getJoomlaVersion();
     $my = JFactory::getUser();
     $blogger_id = $my->id;
     $nestedCategories = '';
     $categoryselecttype = $config->get('layout_dashboardcategoryselect') == 'multitier' ? 'select' : $config->get('layout_dashboardcategoryselect');
     if ($categoryselecttype == 'select') {
         $nestedCategories = EasyBlogHelper::populateCategories('', '', 'select', 'category_id', $blog->category_id, true, true, false);
     }
     // Load media manager and get info about the files.
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
     $mediamanager = new EasyBlogMediaManager();
     $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
     $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
     $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
     $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
     // @rule: Test if the user is already associated with Flickr
     $oauth = EasyBlogHelper::getTable('Oauth');
     $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
     $jConfig = EasyBlogHelper::getJConfig();
     $this->set('flickrAssociated', $associated);
     $this->assignRef('userFolders', $userFolders);
     $this->assignRef('userFiles', $userFiles);
     $this->assignRef('sharedFolders', $sharedFolders);
     $this->assignRef('sharedFiles', $sharedFiles);
     $this->assignRef('jConfig', $jConfig);
     $this->assignRef('my', $my);
     $this->assignRef('content', $content);
     $this->assignRef('category', $category);
     $this->assignRef('blogger_id', $blogger_id);
     $this->assignRef('joomlaversion', $joomlaVersion);
     $this->assignRef('isEdit', $isEdit);
     $this->assignRef('editorTitle', $editorTitle);
     $this->assignRef('blog', $blog);
     $this->assignRef('meta', $meta);
     $this->assignRef('editor', $editor);
     $this->assignRef('tagsString', $tagsString);
     $this->assignRef('acl', $acl);
     $this->assignRef('isPrivate', $isPrivate);
     $this->assignRef('allowComment', $allowComment);
     $this->assignRef('subscription', $allowSubscribe);
     $this->assignRef('frontpage', $showFrontpage);
     $this->assignRef('trackbacks', $trackbacks);
     $this->assignRef('author', $author);
     $this->assignRef('nestedCategories', $nestedCategories);
     $this->assignRef('teamBlogJoined', $teamBlogJoined);
     $this->assignRef('isSiteWide', $isSiteWide);
     $this->assignRef('draft', $draft);
     $this->assignRef('config', $config);
     $this->assignRef('pending_approval', $pending_approval);
     $this->assignRef('external', $external);
     $this->assignRef('extGroupId', $extGroupId);
     $this->assignRef('externalEventId', $externalEventId);
     $this->assignRef('extGroupName', $extGroupName);
     $this->assignRef('blog_contribute_source', $blog_contribute_source);
     $this->assignRef('categoryselecttype', $categoryselecttype);
     $this->assignRef('send_notification_emails', $sendEmails);
     parent::display($tpl);
 }