Esempio n. 1
0
 function geRawUnixTimeOld($str = '')
 {
     $tzoffset = EasyBlogDateHelper::getOffSet();
     $date = EasyBlogHelper::getDate($str);
     $newdate = mktime($date->toFormat('%H') - $tzoffset, $date->toFormat('%M'), $date->toFormat('%S'), $date->toFormat('%m'), $date->toFormat('%d'), $date->toFormat('%Y'));
     return $newdate;
 }
Esempio n. 2
0
 function getPost($postid, $username, $password)
 {
     global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;
     EasyBlogXMLRPCHelper::loginUser($username, $password);
     $my = JFactory::getUser($username);
     $acl = EasyBlogACLHelper::getRuleSet($my->id);
     if (empty($acl->rules->add_entry)) {
         return new xmlrpcresp(0, $xmlrpcerruser + 2, JText::_('ACCESS DENIED'));
     }
     jimport('joomla.application.component.model');
     // JTable::addIncludePath( JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'tables' );
     // JModel::addIncludePath( JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models' );
     // create a new blog jtable object
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($postid);
     if (empty($blog->title)) {
         return new xmlrpcresp(0, $xmlrpcerruser + 1, JText::_('Blog post not found.'));
     }
     $catId = empty($blog->category_id) ? '1' : $blog->category_id;
     $category = EasyBlogHelper::getTable('Category', 'Table');
     $category->load($catId);
     //publishing
     $publish = 'publish';
     switch ($blog->published) {
         case 1:
             $publish = 'publish';
             break;
         case 3:
             $publish = 'draft';
             break;
         case 2:
         default:
             $publish = 'pending';
     }
     //tags /* to do */
     $modelPT = EasyBlogHelper::getModel('PostTag');
     $blogTags = $modelPT->getBlogTags($blog->id);
     $arrBlogTags = array();
     $tagnames = '';
     if (!empty($blogTags)) {
         foreach ($blogTags as $bt) {
             $arrBlogTags[] = $bt->title;
         }
         $tagnames = implode(',', $arrBlogTags);
     }
     $tagnames = array(new xmlrpcval($tagnames, $xmlrpcString));
     $tzoffset = EasyBlogDateHelper::getOffSet();
     $dateCreated = EasyBlogHelper::getDate($blog->created, $tzoffset);
     $postURL = 'index.php?option=com_easyblog&view=entry&id=' . $blog->id;
     $articleLink = EasyBlogRouter::getRoutedURL($postURL, false, true);
     $struct = new xmlrpcval(array('link' => new xmlrpcval($articleLink), 'permaLink' => new xmlrpcval($articleLink), 'userid' => new xmlrpcval($my->id), 'title' => new xmlrpcval($blog->title), 'description' => new xmlrpcval($blog->intro), 'more_text' => new xmlrpcval($blog->content), 'mt_text_more' => new xmlrpcval($blog->content), 'dateCreated' => new xmlrpcval($dateCreated->toISO8601(), 'dateTime.iso8601'), 'categories' => new xmlrpcval(array(new xmlrpcval($category->title)), $xmlrpcArray), 'mt_excerpt' => new xmlrpcval($blog->intro), 'mt_text_more' => new xmlrpcval($blog->content), 'mt_allow_comments' => new xmlrpcval($blog->allowcomment), 'mt_allow_pings' => new xmlrpcval('0'), 'mt_keywords' => new xmlrpcval($tagnames, $xmlrpcArray), 'post_status' => new xmlrpcval($publish), 'postid' => new xmlrpcval($blog->id), 'date_created_gmt' => new xmlrpcval($dateCreated->toISO8601()), 'wp_slug' => new xmlrpcval($blog->permalink)), $xmlrpcStruct);
     return new xmlrpcresp($struct);
 }
Esempio n. 3
0
 public function getArchivePostCountByMonth($month = '', $year = '', $showPrivate = true)
 {
     $db = EB::db();
     $user = JFactory::getUser();
     $privateBlog = $showPrivate ? '' : 'AND ' . $db->nameQuote('access') . ' = ' . $db->Quote('0');
     $tzoffset = EasyBlogDateHelper::getOffSet(true);
     $query = 'SELECT COUNT(1) as count, DAY( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS day,';
     $query .= ' MONTH( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS month,';
     $query .= ' YEAR( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS year ';
     $query .= ' FROM ' . $db->nameQuote('#__easyblog_post');
     $query .= ' WHERE ' . $db->nameQuote('published') . ' = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= ' AND ' . $db->nameQuote('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL);
     $query .= ' ' . $privateBlog;
     $query .= ' AND (' . $db->nameQuote('created') . ' > ' . $db->Quote($year . '-' . $month . '-01 00:00:00') . ' AND ' . $db->nameQuote('created') . ' < ' . $db->Quote($year . '-' . $month . '-31 23:59:59') . ')';
     $query .= ' GROUP BY day, year, month ';
     $query .= ' ORDER BY ' . $db->nameQuote('created') . ' ASC ';
     $db->setQuery($query);
     $row = $db->loadAssocList();
     $postCount = new stdClass();
     for ($i = 1; $i <= 31; $i++) {
         $postCount->{$year}->{$month}->{$i} = 0;
     }
     if (!empty($row)) {
         foreach ($row as $data) {
             $postCount->{$year}->{$month}->{$data['day']} = $data['count'];
         }
     }
     return $postCount;
 }
Esempio n. 4
0
 public function processCommentMailbox()
 {
     /*
      * Check enabled
      */
     $config = EasyBlogHelper::getConfig();
     $debug = JRequest::getBool('debug', false);
     if (!$config->get('main_comment_email')) {
         return;
     }
     $interval = (int) $config->get('main_remotepublishing_mailbox_run_interval');
     $nextrun = (int) $config->get('main_remotepublishing_mailbox_next_run');
     $nextrun = EasyBlogHelper::getDate($nextrun)->toUnix();
     $timenow = EasyBlogHelper::getDate()->toUnix();
     if ($nextrun !== 0 && $timenow < $nextrun) {
         if (!$debug) {
             echo 'time now: ' . EasyBlogHelper::getDate($timenow)->toMySQL() . "<br />\n";
             echo 'next email run: ' . EasyBlogHelper::getDate($nextrun)->toMySQL() . "<br />\n";
             return;
         }
     }
     $txOffset = EasyBlogDateHelper::getOffSet();
     $newnextrun = EasyBlogHelper::getDate('+ ' . $interval . ' minutes', $txOffset)->toUnix();
     // use $configTable to avoid variable name conflict
     $configTable = EasyBlogHelper::getTable('configs');
     $configTable->load('config');
     $parameters = new JParameter($configTable->params);
     $parameters->set('main_remotepublishing_mailbox_next_run', $newnextrun);
     $configTable->params = $parameters->toString('ini');
     $configTable->store();
     /*
      * Connect to mailbox
      */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_easyblog' . DS . 'classes' . DS . 'mailbox.php';
     $mailbox = new EasyblogMailbox();
     if (!$mailbox->connect()) {
         $mailbox->disconnect();
         echo 'Comment Mailbox: Could not connect to mailbox.';
         return false;
     }
     $total = 0;
     /*
      * Get data from mailbox
      */
     $total_mails = $mailbox->getMessageCount();
     if ($total_mails < 1) {
         // No mails in mailbox
         $mailbox->disconnect();
         echo 'Comment Mailbox: No emails found.';
         return false;
     }
     // Let's get the correct mails
     $messages = $mailbox->searchMessages('UNSEEN');
     if ($messages) {
         $prefix = '/\\[\\#(.*)\\]/is';
         $filter = JFilterInput::getInstance();
         $db = EasyBlogHelper::db();
         foreach ($messages as $messageSequence) {
             $info = $mailbox->getMessageInfo($messageSequence);
             $from = $info->fromemail;
             $senderName = $info->from[0]->personal;
             $subject = $filter->clean($info->subject);
             // @rule: Detect if this is actually a reply.
             preg_match('/\\[\\#(.*)\\]/is', $subject, $matches);
             // If the title doesn't match the comment specific title, just continue the block.
             if (empty($matches)) {
                 continue;
             }
             $query = 'SELECT ' . $db->nameQuote('id') . ' FROM ' . $db->nameQuote('#__users') . ' ' . 'WHERE ' . $db->nameQuote('email') . '=' . $db->Quote($from);
             $db->setQuery($query);
             $userId = $db->loadResult();
             $commentId = $matches[1];
             $refComment = EasyBlogHelper::getTable('Comment');
             $refComment->load($commentId);
             // Get the message contents.
             $message = new EasyblogMailboxMessage($mailbox->stream, $messageSequence);
             $message->getMessage();
             $content = $message->getPlain();
             // If guest commenting is not allowed, and user's email does not exist in system, pass this.
             if (!$config->get('main_allowguestcomment') && !$userId) {
                 continue;
             }
             // Apply akismet filtering
             if ($config->get('comment_akismet')) {
                 $data = array('author' => $senderName, 'email' => $from, 'website' => JURI::root(), 'body' => $content, 'permalink' => EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $refComment->post_id));
                 if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) {
                     continue;
                 }
             }
             $model = EasyBlogHelper::getModel('Comment');
             $comment = EasyBlogHelper::getTable('Comment');
             $comment->name = $senderName;
             $comment->email = $from;
             $comment->comment = $content;
             $comment->post_id = $refComment->post_id;
             $date = EasyBlogHelper::getDate();
             $comment->created = $date->toMySQL();
             $comment->modified = $date->toMySQL();
             $comment->published = 1;
             if ($userId) {
                 $comment->created_by = $userId;
             }
             $comment->sent = 0;
             $isModerated = false;
             // Update publish status if the comment requires moderation
             if ($config->get('comment_moderatecomment') == 1 || !$userId && $config->get('comment_moderateguestcomment') == 1) {
                 $comment->set('published', EBLOG_COMMENT_STATUS_MODERATED);
                 $isModerated = true;
             }
             $blog = EasyBlogHelper::getTable('Blog');
             $blog->load($comment->post_id);
             // If moderation for author is disabled, ensure that the comment is published.
             // If the author is the owner of the blog, it should never be moderated.
             if (!$config->get('comment_moderateauthorcomment') && $blog->created_by == $userId) {
                 $comment->set('published', 1);
                 $isModerated = false;
             }
             if (!$comment->store()) {
                 echo 'Error storing comment: ' . $comment->getError();
                 return;
             }
             echo '* Added comment for post <strong>' . $blog->title . '</strong><br />';
             // @rule: Process notifications
             $comment->processEmails($isModerated, $blog);
             // Update the sent flag
             $comment->updateSent();
             $total++;
         }
     }
     /*
      * Disconnect from mailbox
      */
     $mailbox->disconnect();
     /*
      * Generate report
      */
     echo JText::sprintf('Comment Mailbox: %1s comments fetched from mailbox: ' . $config->get('main_remotepublishing_mailbox_remotesystemname') . '.', $total);
 }
Esempio n. 5
0
 /**
  * Must only be bind when using POST data
  **/
 function bind($data, $post = false)
 {
     parent::bind($data);
     if ($post) {
         $acl = EasyBlogACLHelper::getRuleSet();
         $my = JFactory::getUser();
         // Some properties needs to be overriden.
         $content = JRequest::getVar('write_content_hidden', '', 'post', 'string', JREQUEST_ALLOWRAW);
         if ($this->id == 0) {
             // this is to check if superadmin assign blog author during blog creation.
             if (empty($this->created_by)) {
                 $this->created_by = $my->id;
             }
         }
         //remove unclean editor code.
         $pattern = array('/<p><br _mce_bogus="1"><\\/p>/i', '/<p><br mce_bogus="1"><\\/p>/i', '/<br _mce_bogus="1">/i', '/<br mce_bogus="1">/i', '/<p><br><\\/p>/i');
         $replace = array('', '', '', '', '');
         $content = preg_replace($pattern, $replace, $content);
         // Search for readmore tags using Joomla's mechanism
         $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
         $pos = preg_match($pattern, $content);
         if ($pos == 0) {
             $this->intro = $content;
             // @rule: Since someone might update this post, we need to clear out the content
             // if it doesn't contain anything.
             $this->content = '';
         } else {
             list($intro, $main) = preg_split($pattern, $content, 2);
             $this->intro = $intro;
             $this->content = $main;
         }
         $publish_up = '';
         $publish_down = '';
         $created_date = '';
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($this->created)) {
             $date = EasyBlogHelper::getDate($this->created, $tzoffset);
             $created_date = $date->toMySQL();
         }
         if ($this->publish_down == '0000-00-00 00:00:00') {
             $publish_down = $this->publish_down;
         } else {
             if (!empty($this->publish_down)) {
                 $date = EasyBlogHelper::getDate($this->publish_down, $tzoffset);
                 $publish_down = $date->toMySQL();
             }
         }
         if (!empty($this->publish_up)) {
             $date = EasyBlogHelper::getDate($this->publish_up, $tzoffset);
             $publish_up = $date->toMySQL();
         }
         //default joomla date obj
         $date = EasyBlogHelper::getDate();
         $this->created = !empty($created_date) ? $created_date : $date->toMySQL();
         $this->modified = $date->toMySQL();
         $this->publish_up = !empty($publish_up) ? $publish_up : $date->toMySQL();
         $this->publish_down = empty($publish_down) ? '0000-00-00 00:00:00' : $publish_down;
         $this->ispending = empty($acl->rules->publish_entry) ? 1 : 0;
         $this->title = trim($this->title);
         $this->permalink = trim($this->permalink);
     }
     return true;
 }
Esempio n. 6
0
 /**
  * Must only be bind when using POST data
  **/
 function bind($data, $post = false)
 {
     if (!$post) {
         return parent::bind($data);
     }
     parent::bind($data);
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     // Some properties needs to be overriden.
     $content = $this->content;
     //remove unclean editor code.
     $pattern = array('/<p><br _mce_bogus="1"><\\/p>/i', '/<p><br mce_bogus="1"><\\/p>/i', '/<br _mce_bogus="1">/i', '/<br mce_bogus="1">/i', '/<p><br><\\/p>/i');
     $replace = array('', '', '', '', '');
     $content = preg_replace($pattern, $replace, $content);
     // Search for readmore tags using Joomla's mechanism
     $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
     $pos = preg_match($pattern, $content);
     if ($pos == 0) {
         $this->intro = $content;
         $this->content = '';
     } else {
         list($intro, $main) = preg_split($pattern, $content, 2);
         $this->intro = $intro;
         $this->content = $main;
     }
     $intro = $this->intro;
     $content = $this->content;
     $publish_up = '';
     $publish_down = '';
     $created_date = '';
     $tzoffset = EasyBlogDateHelper::getOffSet();
     if (!empty($this->created)) {
         $date = EasyBlogHelper::getDate($this->created, $tzoffset);
         $created_date = $date->toMySQL();
     }
     if ($this->publish_down == '0000-00-00 00:00:00') {
         $publish_down = $this->publish_down;
     } else {
         if (!empty($this->publish_down)) {
             $date = EasyBlogHelper::getDate($this->publish_down, $tzoffset);
             $publish_down = $date->toMySQL();
         }
     }
     if (!empty($this->publish_up)) {
         $date = EasyBlogHelper::getDate($this->publish_up, $tzoffset);
         $publish_up = $date->toMySQL();
     }
     //default joomla date obj
     $date = EasyBlogHelper::getDate();
     $this->created = !empty($created_date) ? $created_date : $date->toMySQL();
     $this->intro = $intro;
     $this->content = $content;
     $this->modified = $date->toMySQL();
     $this->publish_up = !empty($publish_up) ? $publish_up : $date->toMySQL();
     $this->publish_down = empty($publish_down) ? '0000-00-00 00:00:00' : $publish_down;
     $this->ispending = empty($acl->rules->publish_entry) ? 1 : 0;
     $this->issitewide = empty($this->blog_contribute) ? 1 : 0;
     // Bind necessary stuffs for the next load
     if (isset($data['tags']) && !empty($data['tags']) && is_array($data['tags'])) {
         $this->set('tags', implode(',', $data['tags']));
     }
     if (isset($data['keywords']) && !empty($data['keywords'])) {
         $this->set('metakey', $data['keywords']);
     }
     if (isset($data['description']) && !empty($data['description'])) {
         $this->set('metadesc', $data['description']);
     }
     if (isset($data['trackback']) && !empty($data['trackback'])) {
         $this->set('trackbacks', $data['trackback']);
     }
     if (isset($data['blogpassword']) && !empty($data['blogpassword'])) {
         $this->set('blogpassword', $data['blogpassword']);
     }
     // @task: Try to detect autoposting for centralized sites
     if (isset($data['centralized']) && !empty($data['centralized'])) {
         $this->set('autopost_centralized', implode(',', $data['centralized']));
     }
     if (isset($data['socialshare']) && !empty($data['socialshare'])) {
         $this->set('autopost', implode(',', $data['socialshare']));
     }
     if (isset($data['blog_contribute_source']) && $data['blog_contribute_source'] != 'easyblog') {
         $this->set('external_source', $data['blog_contribute_source']);
         $this->set('external_group_id', $data['blog_contribute']);
     }
     if (isset($data['image']) && $data['image']) {
         $this->set('image', $data['image']);
     }
     return true;
 }
Esempio n. 7
0
 function getArchivePostByMonth($month = '', $year = '', $showPrivate = false)
 {
     $db = EasyBlogHelper::db();
     $user = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     // used for privacy
     $queryWhere = '';
     $queryExclude = '';
     $queryExcludePending = '';
     $excludeCats = array();
     if ($user->id == 0) {
         $showPrivate = false;
     }
     if (!$showPrivate) {
         $excludeCats = EasyBlogHelper::getPrivateCategories();
     }
     //blog privacy setting
     // @integrations: jomsocial privacy
     $privateBlog = '';
     $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
     $easysocial = EasyBlogHelper::getHelper('EasySocial');
     if ($config->get('integrations_easysocial_privacy') && $easysocial->exists() && !EasyBlogHelper::isSiteAdmin()) {
         $esPrivacyQuery = $easysocial->buildPrivacyQuery('a');
         $privateBlog .= $esPrivacyQuery;
     } else {
         if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) {
             require_once $file;
             $jsFriends = CFactory::getModel('Friends');
             $friends = $jsFriends->getFriendIds($user->id);
             // Insert query here.
             $privateBlog .= ' AND (';
             $privateBlog .= ' (a.`private`= 0 ) OR';
             $privateBlog .= ' ( (a.`private` = 20) AND (' . $db->Quote($user->id) . ' > 0 ) ) OR';
             if (empty($friends)) {
                 $privateBlog .= ' ( (a.`private` = 30) AND ( 1 = 2 ) ) OR';
             } else {
                 $privateBlog .= ' ( (a.`private` = 30) AND ( a.' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR';
             }
             $privateBlog .= ' ( (a.`private` = 40) AND ( a.' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . '=' . $user->id . ') )';
             $privateBlog .= ' )';
         } else {
             if ($user->id == 0) {
                 $privateBlog .= ' AND a.`private` = ' . $db->Quote(0);
             }
         }
     }
     $privateBlog = $showPrivate ? '' : $privateBlog;
     //get teamblogs id.
     $teamBlogIds = '';
     $query = '';
     if ($config->get('main_includeteamblogpost')) {
         $teamBlogIds = EasyBlogHelper::getViewableTeamIds();
         if (count($teamBlogIds) > 0) {
             $teamBlogIds = implode(',', $teamBlogIds);
         }
     }
     if (!empty($excludeCats)) {
         $queryWhere .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     $jsPostIds = self::getJomSocialPosts();
     if ($config->get('main_includeteamblogpost') && !empty($teamBlogIds)) {
         if (!empty($jsPostIds)) {
             $tmpIds = implode(',', $jsPostIds);
             $queryWhere .= ' AND (u.team_id IN (' . $teamBlogIds . ') OR a.id IN (' . $tmpIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')';
         } else {
             $queryWhere .= ' AND (u.team_id IN (' . $teamBlogIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')';
         }
     } else {
         if (!empty($jsPostIds)) {
             $tmpIds = implode(',', $jsPostIds);
             $queryWhere .= ' AND (a.id IN (' . $tmpIds . ') OR a.`issitewide` = ' . $db->Quote('1') . ')';
         } else {
             $queryWhere .= ' AND a.`issitewide` = ' . $db->Quote('1');
         }
     }
     $extraSQL = '';
     $blogger = EasyBlogRouter::isBloggerMode();
     if ($blogger !== false) {
         $extraSQL = ' AND a.`created_by` = ' . $db->Quote($blogger);
     }
     $tzoffset = EasyBlogDateHelper::getOffSet(true);
     $query = 'SELECT *, DAY( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS day,';
     $query .= ' MONTH( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS month,';
     $query .= ' YEAR( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS year ';
     $query .= ' FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post') . ' as a';
     if ($config->get('main_includeteamblogpost')) {
         $query .= ' LEFT JOIN `#__easyblog_team_post` AS u ON a.id = u.post_id';
     }
     $query .= ' WHERE a.`published` = ' . $db->Quote(true) . ' ';
     $query .= $privateBlog . ' ';
     $query .= ' AND (a.`created` > ' . $db->Quote($year . '-' . $month . '-01 00:00:00') . ' AND a.`created` < ' . $db->Quote($year . '-' . $month . '-31 23:59:59') . ') ';
     $query .= $extraSQL . ' ';
     $query .= $queryWhere;
     $query .= ' ORDER BY a.`created` ASC ';
     $db->setQuery($query);
     $row = $db->loadObjectList();
     $postCount = new EasyblogCalendarObject($month, $year);
     if (!empty($row)) {
         foreach ($row as $data) {
             if ($postCount->{$year}->{$month}->{$data->day} == 0) {
                 $postCount->{$year}->{$month}->{$data->day} = array($data);
             } else {
                 array_push($postCount->{$year}->{$month}->{$data->day}, $data);
             }
         }
     }
     return $postCount;
 }
Esempio n. 8
0
 public function store($updateNulls = false)
 {
     if (!empty($this->created)) {
         $offset = EasyBlogDateHelper::getOffSet();
         $newDate = EasyBlogHelper::getDate($this->created, $offset);
         $this->created = $newDate->toMySQL();
     } else {
         $newDate = EasyBlogHelper::getDate();
         $this->created = $newDate->toMySQL();
     }
     $my = JFactory::getUser();
     // Add point integrations for new categories
     if ($this->id == 0 && $my->id > 0) {
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $config = EasyBlogHelper::getConfig();
         // @rule: Integrations with EasyDiscuss
         EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_CATEGORY', $this->title));
         EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.category', $my->id);
         EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.category', $my->id);
         // @since 1.2
         // AlphaUserPoints
         if (EasyBlogHelper::isAUPEnabled()) {
             AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_category', '', 'easyblog_add_category_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_CATEGORY_CREATED', $this->title));
         }
         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.category.add', $my->id);
             }
         }
         // Assign EasySocial points
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         $easysocial->assignPoints('category.create', $my->id);
     }
     // Figure out the proper nested set model
     if ($this->id == 0 && $this->lft == 0) {
         // No parent id, we use the current lft,rgt
         if ($this->parent_id) {
             $left = $this->getLeft($this->parent_id);
             $this->lft = $left;
             $this->rgt = $this->lft + 1;
             // Update parent's right
             $this->updateRight($left);
             $this->updateLeft($left);
         } else {
             $this->lft = $this->getLeft() + 1;
             $this->rgt = $this->lft + 1;
         }
     }
     $isNew = empty($this->id) ? true : false;
     $return = parent::store();
     //activity logging.
     $activity = new stdClass();
     $activity->actor_id = $my->id;
     $activity->target_id = '0';
     $activity->context_type = 'category';
     $activity->context_id = $this->id;
     $activity->verb = $isNew ? 'add' : 'update';
     $activity->uuid = $this->title;
     EasyBlogHelper::activityLog($activity);
     return $return;
 }
Esempio n. 9
0
 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');
     }
 }
Esempio n. 10
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);
 }
Esempio n. 11
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. 12
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));
 }
Esempio n. 13
0
    function checkPublishStatus($status, $unpublishDate)
    {
        $ajax = new Ejax();
        $txOffset = EasyBlogDateHelper::getOffSet();
        $today = EasyBlogHelper::getDate();
        $unpublishing = EasyBlogHelper::getDate(empty($unpublishDate) ? '' : $unpublishDate, $txOffset);
        if ($unpublishing->toUnix() <= $today->toUnix() && $status == POST_ID_PUBLISHED) {
            $options = new stdClass();
            $options->title = JText::_('COM_EASYBLOG_CONFIRMATION');
            ob_start();
            ?>

			<?php 
            echo JText::_('COM_EASYBLOG_DASHBOARD_SAVE_BLOG_EXPIRED');
            ?>

			<div class="dialog-actions">
				<input type="button" value="<?php 
            echo JText::_('COM_EASYBLOG_CANCEL');
            ?>
" class="button" id="edialog-cancel" name="edialog-cancel" onclick="eblog.editor.cancelSubmit();" />
				<input type="button" value="<?php 
            echo JText::_('COM_EASYBLOG_YES');
            ?>
" class="button" id="edialog-submit" name="edialog-submit" onclick="eblog.editor.postSubmit();" />
			</div>

			<?php 
            $options->content = ob_get_contents();
            ob_end_clean();
            $ajax->dialog($options);
        } else {
            $ajax->script("eblog.editor.postSubmit();");
        }
        $ajax->send();
        return;
    }
Esempio n. 14
0
 public function store($updateNulls = false)
 {
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     // @rule: Check for empty title
     if (empty($this->title)) {
         $this->setError(JText::_('COM_EASYBLOG_INVALID_TAG'));
         return false;
     }
     // @rule: Check if such tag exists.
     if ($this->exists($this->title, !$this->id)) {
         $this->setError(JText::_('COM_EASYBLOG_TAG_ALREADY_EXISTS'));
         return false;
     }
     // @task: If alias is null, we need to generate them here.
     jimport('joomla.filesystem.filter.filteroutput');
     $i = 1;
     while ($this->aliasExists() || empty($this->alias)) {
         $this->alias = empty($this->alias) ? $this->title : $this->alias . '-' . $i;
         $i++;
     }
     $this->alias = EasyBlogRouter::generatePermalink($this->alias);
     if (!empty($this->created)) {
         $offset = EasyBlogDateHelper::getOffSet();
         $newDate = EasyBlogHelper::getDate($this->created, $offset);
         $this->created = $newDate->toMySQL();
     } else {
         $newDate = EasyBlogHelper::getDate();
         $this->created = $newDate->toMySQL();
     }
     $isNew = !$this->id;
     $state = parent::store();
     $my = JFactory::getUser();
     if ($isNew && $my->id != 0) {
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $config = EasyBlogHelper::getConfig();
         // @rule: Integrations with EasyDiscuss
         EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.tag', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_TAG', $this->title));
         EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.tag', $my->id);
         EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.tag', $my->id);
         // Assign EasySocial points
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         $easysocial->assignPoints('tag.create', $my->id);
         if ($config->get('main_jomsocial_userpoint')) {
             $jsUserPoint = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php';
             if (JFile::exists($jsUserPoint)) {
                 require_once $jsUserPoint;
                 CUserPoints::assignPoint('com_easyblog.tag.add', $my->id);
             }
         }
         // AlphaUserPoints
         // since 1.2
         if (EasyBlogHelper::isAUPEnabled()) {
             AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_tag', '', 'easyblog_add_tag_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_TAG_ADDED', $this->title));
         }
     }
     if ($state) {
         //activity logging.
         $activity = new stdClass();
         $activity->actor_id = $my->id;
         $activity->target_id = '0';
         $activity->context_type = 'tag';
         $activity->context_id = $this->id;
         $activity->verb = $isNew ? 'add' : 'update';
         $activity->uuid = $this->title;
         EasyBlogHelper::activityLog($activity);
     }
     return $state;
 }