Esempio n. 1
0
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('user');
     $mainframe = JFactory::getApplication();
     $db = EasyBlogHelper::db();
     $my = JFactory::getUser();
     $acl = JFactory::getACL();
     $config = EasyBlogHelper::getConfig();
     // Create a new JUser object
     $user = JFactory::getUser(JRequest::getVar('id', 0, 'post', 'int'));
     $original_gid = $user->get('gid');
     $post = JRequest::get('post');
     $post['username'] = JRequest::getVar('username', '', 'post', 'username');
     $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         $jformPost = JRequest::getVar('jform', array(), 'post', 'array');
         $post['params'] = $jformPost['params'];
     }
     if (!$user->bind($post)) {
         EasyBlogHelper::storeSession($post, 'EASYBLOG_REGISTRATION_POST');
         $mainframe->enqueueMessage($user->getError(), 'error');
         $this->_saveError($user->id);
     }
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if ($user->get('id') == $my->get('id') && $user->get('block') == 1) {
             $mainframe->enqueueMessage(JText::_('You cannot block Yourself!'), 'error');
             $this->_saveError($user->id);
         } else {
             if ($user->authorise('core.admin') && $user->get('block') == 1) {
                 $mainframe->enqueueMessage(JText::_('You cannot block a Super User'), 'error');
                 $this->_saveError($user->id);
             } else {
                 if ($user->authorise('core.admin') && !$my->authorise('core.admin')) {
                     $mainframe->enqueueMessage(JText::_('You cannot edit a Super User account'), 'message');
                     $this->_saveError($user->id);
                 }
             }
         }
         //replacing thr group name with group id so it is save correctly into the Joomla group table.
         $jformPost = JRequest::getVar('jform', array(), 'post', 'array');
         if (!empty($jformPost['groups'])) {
             $user->groups = array();
             foreach ($jformPost['groups'] as $groupid) {
                 $user->groups[$groupid] = $groupid;
             }
         }
     } else {
         $objectID = $acl->get_object_id('users', $user->get('id'), 'ARO');
         $groups = $acl->get_object_groups($objectID, 'ARO');
         $this_group = strtolower($acl->get_group_name($groups[0], 'ARO'));
         if ($user->get('id') == $my->get('id') && $user->get('block') == 1) {
             $mainframe->enqueueMessage(JText::_('You cannot block Yourself!'), 'error');
             $this->_saveError($user->id);
         } else {
             if ($this_group == 'super administrator' && $user->get('block') == 1) {
                 $mainframe->enqueueMessage(JText::_('You cannot block a Super Administrator'), 'error');
                 $this->_saveError($user->id);
             } else {
                 if ($this_group == 'administrator' && $my->get('gid') == 24 && $user->get('block') == 1) {
                     $mainframe->enqueueMessage(JText::_('WARNBLOCK'), 'error');
                     $this->_saveError($user->id);
                 } else {
                     if ($this_group == 'super administrator' && $my->get('gid') != 25) {
                         $mainframe->enqueueMessage(JText::_('You cannot edit a super administrator account'), 'message');
                         $this->_saveError($user->id);
                     }
                 }
             }
         }
     }
     // Are we dealing with a new user which we need to create?
     $isNew = $user->get('id') < 1;
     if (EasyBlogHelper::getJoomlaVersion() <= '1.5') {
         // do this step only for J1.5
         if (!$isNew) {
             // if group has been changed and where original group was a Super Admin
             if ($user->get('gid') != $original_gid && $original_gid == 25) {
                 // count number of active super admins
                 $query = 'SELECT COUNT( id )' . ' FROM #__users' . ' WHERE gid = 25' . ' AND block = 0';
                 $db->setQuery($query);
                 $count = $db->loadResult();
                 if ($count <= 1) {
                     // disallow change if only one Super Admin exists
                     $this->setRedirect('index.php?option=com_users', JText::_('WARN_ONLY_SUPER'));
                     return false;
                 }
             }
         }
     }
     if (!$user->save()) {
         $mainframe->enqueueMessage($user->getError(), 'error');
         return $this->execute('edit');
     }
     // If updating self, load the new user object into the session
     if (EasyBlogHelper::getJoomlaVersion() <= '1.5') {
         if ($user->get('id') == $my->get('id')) {
             // Get an ACL object
             $acl = JFactory::getACL();
             // Get the user group from the ACL
             $grp = $acl->getAroGroup($user->get('id'));
             // Mark the user as logged in
             $user->set('guest', 0);
             $user->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                 $user->set('aid', 2);
             }
             // Set the usertype based on the ACL group name
             $user->set('usertype', $grp->name);
             $session = JFactory::getSession();
             $session->set('user', $user);
         }
     } else {
         // Update session data if the current user was updated
         if ($user->get('id') == $my->get('id')) {
             $session = JFactory::getSession();
             $session->set('user', $user);
             // Force load from database
         }
     }
     $post = JRequest::get('post');
     if ($isNew) {
         unset($post['id']);
     }
     $post['permalink'] = $post['user_permalink'];
     unset($post['user_permalink']);
     if (EasyBlogHelper::isSiteAdmin()) {
         $post['description'] = JRequest::getVar('description', '', 'POST', '', JREQUEST_ALLOWRAW);
         $post['biography'] = JRequest::getVar('biography', '', 'POST', '', JREQUEST_ALLOWRAW);
     }
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($user->id);
     $blogger->bind($post);
     $file = JRequest::getVar('Filedata', '', 'Files', 'array');
     if (!empty($file['name'])) {
         $newAvatar = EasyBlogHelper::uploadAvatar($blogger, true);
         $blogger->avatar = $newAvatar;
     }
     //save params
     $userparams = EasyBlogHelper::getRegistry('');
     // @rule: Save google profile url
     if (isset($post['google_profile_url'])) {
         $userparams->set('google_profile_url', $post['google_profile_url']);
     }
     if (isset($post['show_google_profile_url'])) {
         $userparams->set('show_google_profile_url', $post['show_google_profile_url']);
     }
     $blogger->params = $userparams->toString();
     $blogger->store();
     JTable::addIncludePath(EBLOG_TABLES);
     //save twitter info.
     $twitter = EasyBlogHelper::getTable('Oauth', 'Table');
     $twitter->loadByUser($user->id, EBLOG_OAUTH_TWITTER);
     $twitter->auto = JRequest::getVar('integrations_twitter_auto');
     $twitter->message = JRequest::getVar('integrations_twitter_message');
     if (!$twitter->store()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_TWITTER_ERROR'), 'error');
     }
     // Map linkedin items
     $linkedin = EasyBlogHelper::getTable('Oauth', 'Table');
     $linkedin->loadByUser($user->id, EBLOG_OAUTH_LINKEDIN);
     $linkedin->auto = JRequest::getVar('integrations_linkedin_auto');
     $linkedin->message = JRequest::getVar('integrations_linkedin_message');
     $linkedin->private = JRequest::getVar('integrations_linkedin_private');
     if (!$linkedin->store()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_LINKEDIN_ERROR'), 'error');
     }
     // store faebook info
     $facebook = EasyBlogHelper::getTable('Oauth', 'Table');
     $facebook->loadByUser($user->id, EBLOG_OAUTH_FACEBOOK);
     $facebook->auto = JRequest::getVar('integrations_facebook_auto');
     $facebook->message = '';
     if (!$facebook->store()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_FACEBOOK_FAILED_UPDATE_INFO_ERROR'), 'error');
     }
     if ($config->get('integration_google_adsense_enable')) {
         // Store adsense data
         $adsense = EasyBlogHelper::getTable('Adsense', 'Table');
         $adsense->load($user->id);
         $adsense->code = $post['adsense_code'];
         $adsense->display = $post['adsense_display'];
         $adsense->published = $post['adsense_published'];
         $adsense->store();
     }
     // Store feedburner data
     $feedburner = EasyBlogHelper::getTable('Feedburner', 'Table');
     $feedburner->load($user->id);
     $feedburner->url = $post['feedburner_url'];
     $feedburner->store();
     $this->_saveSuccess($user->id);
 }
Esempio n. 2
0
 function savePublish()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('blog');
     $mainframe = JFactory::getApplication();
     $config = EasyBlogHelper::getConfig();
     $message = '';
     $type = 'message';
     $saveNew = JRequest::getInt('savenew', 0);
     $authorId = JRequest::getVar('authorId');
     $user = JFactory::getUser($authorId);
     $joomlaVersion = EasyBlogHelper::getJoomlaVersion();
     if (JRequest::getMethod() == 'GET') {
         echo JText::_('COM_EASYBLOG_NOT_ALLOWED');
         return;
     }
     $acl = EasyBlogACLHelper::getRuleSet();
     if (empty($acl->rules->add_entry)) {
         $message = JText::_('COM_EASYBLOG_BLOGS_BLOG_NO_PERMISSION_TO_CREATE_BLOG');
         $mainframe->enqueueMessage($message, 'error');
         $this->setRedirect('index.php?option=com_easyblog&view=blogs');
     }
     // get data from form post.
     $post = JRequest::get('post');
     // @rule: Check for invalid title
     $postTitle = trim($post['title']);
     if (empty($postTitle)) {
         $post['write_content'] = JRequest::getVar('write_content_hidden', '', 'post', 'string', JREQUEST_ALLOWRAW);
         EasyBlogHelper::storeSession($post, 'tmpBlogData');
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_TITLE_ERROR'), 'error');
         $mainframe->redirect('index.php?option=com_easyblog&view=blog');
         $mainframe->close();
     }
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $blog = EasyBlogHelper::getTable('blog', 'Table');
     $id = JRequest::getInt('blogid');
     $blog->load($id);
     $isNew = $blog->id == 0 ? true : false;
     $draftId = JRequest::getInt('draft_id');
     $under_approval = JRequest::getInt('under_approval');
     $contributionSource = isset($post['blog_contribute_source']) ? $post['blog_contribute_source'] : '';
     // If contribution source is empty, we should assume that it's for EasyBlog but it shouldn't be empty in the first place.
     if (!$contributionSource) {
         $contributionSource = 'easyblog';
     }
     //override the isnew variable
     if (!$isNew) {
         // if this is blog edit, then we should see the column isnew to determine
         // whether we should send any notification
         $isNew = $blog->isnew;
     }
     // @task: Get the offset
     $txOffset = EasyBlogDateHelper::getOffSet();
     // we do not proccess this on draft
     if ($post['published'] != POST_ID_DRAFT) {
         // we check the publishing date here
         // if user set the future date then we will automatically change
         // the status to Schedule
         $today = EasyBlogHelper::getDate();
         if ($post['published'] == POST_ID_PUBLISHED) {
             $publishing = EasyBlogHelper::getDate($post['publish_up'], $txOffset);
             if ($publishing->toUnix() > $today->toUnix()) {
                 $post['published'] = POST_ID_SCHEDULED;
             }
         }
         //end if
     }
     if (empty($post['publish_down'])) {
         $post['publish_down'] = '0000-00-00 00:00:00';
     }
     // set author
     $post['created_by'] = $authorId;
     // Some other elements might use name="language", so we need to remap this
     $language = JRequest::getVar('eb_language');
     $post['language'] = $language;
     $blog->bind($post, true);
     /**
      * check here if user do not have the 'Publish Entry' acl, send this post for pending approval.
      */
     if (empty($draftId) && empty($acl->rules->publish_entry)) {
         $this->_saveDraft();
         return;
     }
     //check if user have permission to enable privacy.
     $aclBlogPrivacy = $acl->rules->enable_privacy;
     $blog->private = empty($aclBlogPrivacy) ? '0' : $blog->private;
     //check if user have permission to contribute the blog post to eblog frontpage
     $blog->frontpage = empty($acl->rules->contribute_frontpage) ? '0' : $blog->frontpage;
     $blog->isnew = $isNew && $blog->published != 1 ? '1' : '0';
     //now we need to check the blog contribution
     $blogContribution = array();
     $issitewide = '1';
     if (isset($post['blog_contribute'])) {
         $myContribution = $post['blog_contribute'];
         //reset the value
         $issitewide = '0';
         if ($myContribution == '0') {
             $issitewide = '1';
         } else {
             $blogContribution[] = $myContribution;
         }
     }
     $blog->issitewide = $issitewide;
     if ($under_approval) {
         $blog->under_approval = true;
     }
     if (!$blog->store()) {
         $post['write_content'] = JRequest::getVar('write_content_hidden', '', 'post', 'string', JREQUEST_ALLOWRAW);
         EasyBlogHelper::storeSession($post, 'tmpBlogData');
         $mainframe->enqueueMessage($blog->getError(), 'error');
         $mainframe->redirect('index.php?option=com_easyblog&view=blog');
         $mainframe->close();
     }
     // @task: now we update the blog contribution
     if ($contributionSource == 'easyblog') {
         $blog->updateBlogContribution($blogContribution);
     } else {
         $blog->updateBlogContribution($blogContribution, $contributionSource);
     }
     // @task: Notify the world that someone created a blog post.
     if ($blog->published == POST_ID_PUBLISHED && $isNew && !$blog->private) {
         $blog->notify($under_approval);
     }
     if ($blog->published == POST_ID_PUBLISHED && $user->id == $authorId && !$blog->ispending && $contributionSource != 'easyblog') {
         EasyBlogHelper::getHelper('Groups')->addStream($blog, $isNew, $blogContribution, $contributionSource);
     }
     $blogId = $blog->id;
     //meta post info
     $metaId = JRequest::getVar('metaid', '');
     $metapost = array();
     $metapost['keywords'] = JRequest::getVar('keywords', '');
     $metapost['description'] = JRequest::getVar('description', '');
     $metapost['content_id'] = $blogId;
     $metapost['type'] = META_TYPE_POST;
     // save meta tag for post
     $meta = EasyBlogHelper::getTable('Meta', 'Table');
     $meta->load($metaId);
     $meta->bind($metapost);
     $meta->store();
     $author = EasyBlogHelper::getTable('Profile', 'Table');
     $author->setUser($user);
     // @task: Store trackbacks into the trackback table for tracking purposes.
     $trackbacks = JRequest::getVar('trackback', '', 'POST');
     if (!empty($acl->rules->add_trackback) && !empty($trackbacks)) {
         $blog->storeTrackbacks($trackbacks);
         $blog->processTrackbacks();
     }
     // @rule: Process the tags after the blog is stored.
     $tags = JRequest::getVar('tags', '', 'POST');
     $blog->processTags($tags);
     if (!empty($draftId)) {
         // @task: Cleanup any messages
         $postreject = EasyBlogHelper::getTable('PostReject', 'Table');
         $postreject->clear($draftId);
         $draft = EasyBlogHelper::getTable('Draft', 'Table');
         $draft->load($draftId);
         $draft->delete();
     }
     // @rule: Autoposting to social network sites.
     if ($blog->published == POST_ID_PUBLISHED) {
         $autopost = JRequest::getVar('socialshare', '');
         $centralized = JRequest::getVar('centralized', '');
         $blog->autopost($autopost, $centralized);
     }
     //not ready.
     $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_BLOGS_BLOG_SAVE_POST_SAVED'));
     // Redirect to new form again if necessary
     if ($saveNew) {
         $this->setRedirect('index.php?option=com_easyblog&view=blog');
         return;
     }
     if ($this->getTask() == 'saveApply') {
         $this->setRedirect('index.php?option=com_easyblog&view=blog&blogid=' . $blog->id);
         return;
     }
     $this->setRedirect('index.php?option=com_easyblog&view=blogs');
 }
Esempio n. 3
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');
 }
Esempio n. 4
0
 function save()
 {
     $mainframe = JFactory::getApplication();
     $config = EasyBlogHelper::getConfig();
     $message = '';
     $type = 'message';
     $my = JFactory::getUser();
     $acl = EasyBlogACLHelper::getRuleSet();
     $joomlaVersion = EasyBlogHelper::getJoomlaVersion();
     $returnRaw = JRequest::getVar('return');
     $return = '';
     if (!empty($returnRaw)) {
         $return = base64_decode($returnRaw);
         // Set the raw return value in case there's any errors
         $external = JRequest::getInt('external');
         $uid = JRequest::getInt('uid');
         $source = JRequest::getVar('source');
         $returnRaw = '&return=' . $returnRaw;
         if ($external) {
             $returnRaw .= '&external=' . $external;
         }
         if ($uid) {
             $returnRaw .= '&uid=' . $uid;
         }
         if ($source) {
             $returnRaw .= '&source=' . $source;
         }
     } else {
         // We don't want to have any values for built in writing
         $returnRaw = '';
     }
     if (empty($acl->rules->add_entry)) {
         EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'), 'warning');
         $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard' . $returnRaw, false));
         return;
     }
     if ($my->id == 0) {
         EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_YOU_ARE_NOT_LOGIN'), 'error');
         $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog' . $returnRaw, false));
     }
     if (JRequest::getMethod() != 'POST') {
         EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_INVALID_METHOD'), 'error');
         $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog' . $returnRaw, false));
     }
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $blog = EasyBlogHelper::getTable('blog', 'Table');
     $post = JRequest::get('post');
     $id = JRequest::getInt('id');
     $contributionSource = JRequest::getVar('blog_contribute_source', 'easyblog');
     $isNew = $blog->load($id) ? false : true;
     // There seems to be a bug in Joomla 1.6 where the load always return true
     // when invalid id is submitted
     if ($blog->id == 0) {
         $isNew = true;
     }
     if (!$isNew) {
         // if this is blog edit, then we should see the column isnew to determine
         // whether we should send any notification
         $isNew = $blog->isnew;
     }
     $under_approval = false;
     if (isset($post['under_approval'])) {
         $under_approval = true;
     }
     // we do not proccess this on draft
     if ($post['published'] != POST_ID_DRAFT) {
         $txOffset = EasyBlogDateHelper::getOffSet();
         $today = EasyBlogHelper::getDate();
         if ($post['published'] == POST_ID_PUBLISHED) {
             // we check the publishing date here
             // if user set the future date then we will automatically change
             // the status to Schedule
             $publishing = EasyBlogHelper::getDate(!isset($post['publish_up']) ? '' : $post['publish_up'], $txOffset);
             if ($publishing->toUnix() > $today->toUnix()) {
                 $post['published'] = POST_ID_SCHEDULED;
             }
         }
     }
     // Initialize some variables here.
     $post['publish_down'] = JRequest::getVar('publish_down', '0000-00-00 00:00:00');
     // Some other elements might use name="language", so we need to remap this
     $language = JRequest::getVar('eb_language');
     $post['language'] = $language;
     // @task: Map the request.
     $blog->bind($post, true);
     // @rule: If user does not have permissions to publish entry, then we need to submit this for approvals.
     if (empty($acl->rules->publish_entry)) {
         $this->savepending();
         return;
     }
     // If privacy overrides are disabled, do not let them to force their way in
     if (!$config->get('main_blogprivacy_override')) {
         $blog->private = $config->get('main_blogprivacy');
     }
     //check if user have permission to enable privacy.
     $blog->private = empty($acl->rules->enable_privacy) ? 0 : $blog->private;
     //check if user have permission to contribute the blog post to eblog frontpage
     $blog->frontpage = empty($acl->rules->contribute_frontpage) ? '0' : $blog->frontpage;
     $blog->isnew = $isNew && $blog->published != 1 ? '1' : '0';
     //now we need to check the blog contribution
     $blog->issitewide = isset($post['blog_contribute']) && $post['blog_contribute'] != 0 ? false : true;
     $blogContribution = array();
     $issitewide = '1';
     if (isset($post['blog_contribute']) && $post['blog_contribute'] == '0') {
         $blog->issitewide = true;
     } else {
         $blog->issitewide = false;
         $blogContribution[] = $post['blog_contribute'];
     }
     // @task: When a new post is saved, we need to clear the drafts first.
     if (isset($post['draft_id']) && !empty($post['draft_id'])) {
         $draft = EasyBlogHelper::getTable('Draft', 'Table');
         $draft->load($post['draft_id']);
         // @rule: Only delete the draft when the owner really owns the draft.
         if ($draft->created_by == $my->id || EasyBlogHelper::isSiteAdmin() || $under_approval) {
             if ($under_approval) {
                 // @task: Cleanup any messages
                 $postreject = EasyBlogHelper::getTable('PostReject', 'Table');
                 $postreject->clear($draft->id);
             }
             $draft->delete();
         }
     }
     if ($under_approval) {
         $blog->under_approval = true;
     }
     if (!$blog->store()) {
         $post['write_content'] = JRequest::getVar('write_content_hidden', '', 'post', 'string', JREQUEST_ALLOWRAW);
         // Restore the contents
         EasyBlogHelper::storeSession($post, 'tmpBlogData');
         EasyBlogHelper::setMessageQueue($blog->getError(), 'error');
         $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=write' . $returnRaw, false));
     }
     // @task: Update the contribution linkage between the blog post and the respective team
     $blog->updateBlogContribution($blogContribution, $contributionSource);
     // @task: Notify the world that someone created a blog post.
     //if( $blog->published == POST_ID_PUBLISHED && $isNew && !$blog->private )
     // Do not send out emails when the post is scheduled to post in future
     if ($isNew && !$blog->private && $blog->published != POST_ID_SCHEDULED) {
         $blog->notify($under_approval, $blog->published);
     }
     $message = JText::_('COM_EASYBLOG_DASHBOARD_ENTRIES_SAVED');
     JTable::addIncludePath(EBLOG_TABLES);
     $author = EasyBlogHelper::getTable('Profile', 'Table');
     $author->load($blog->created_by);
     if ($blog->published == POST_ID_PUBLISHED && $my->id == $blog->created_by && !$blog->ispending && $contributionSource != 'easyblog') {
         // @since 3.5
         // Event integrations.
         switch ($contributionSource) {
             case 'jomsocial.event':
                 EasyBlogHelper::getHelper('Event')->addStream($blog, $isNew, $blogContribution, $contributionSource);
                 EasyBlogHelper::getHelper('Event')->sendNotifications($blog, $isNew, $blogContribution, $contributionSource, $author);
                 break;
             default:
                 EasyBlogHelper::getHelper('Groups')->addStream($blog, $isNew, $blogContribution, $contributionSource);
                 EasyBlogHelper::getHelper('Groups')->sendNotifications($blog, $isNew, $blogContribution, $contributionSource, $author);
                 break;
         }
     }
     // @task: Update or initialize meta table.
     $blog->createMeta(JRequest::getVar('keywords', ''), JRequest::getVar('description', ''));
     // @task: Store trackbacks into the trackback table for tracking purposes.
     $trackbacks = JRequest::getVar('trackback', '', 'POST');
     // Store trackbacks if necessary
     if (!empty($acl->rules->add_trackback) && !empty($trackbacks)) {
         $blog->storeTrackbacks($trackbacks);
     }
     // @task: Save any tags associated with the blog entry.
     $tags = JRequest::getVar('tags', '', 'POST');
     $date = EasyBlogHelper::getDate();
     // @rule: Process the tags after the blog is stored.
     $blog->processTags($tags, $isNew);
     // @rule: Autoposting to social network sites.
     if ($blog->published == POST_ID_PUBLISHED) {
         $autopost = JRequest::getVar('socialshare', '');
         $centralized = JRequest::getVar('centralized', '');
         $blog->autopost($autopost, $centralized);
     }
     // @rule: Process trackbacks
     $blog->processTrackbacks();
     $message = JText::_('COM_EASYBLOG_DASHBOARD_SAVE_SUCCESS');
     if (!empty($return)) {
         $this->setRedirect(JRoute::_($return, false), $message);
         return;
     }
     $isApply = JRequest::getBool('apply');
     if ($isApply) {
         $message = JText::_('COM_EASYBLOG_DASHBOARD_APPLY_SUCCESS');
         EasyBlogHelper::setMessageQueue($message, 'success');
         $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=write&blogid=' . $blog->id, false));
         return;
     }
     EasyBlogHelper::setMessageQueue($message, 'success');
     $this->setRedirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=entries', false));
 }