Esempio n. 1
0
 public static function getLink($type, $id)
 {
     if (empty($type) || empty($id)) {
         return false;
     }
     //prevent jtable is not loading incase overwritten by other component.
     JTable::addIncludePath(EBLOG_TABLES);
     $oauth = EB::table('Oauth');
     $oauth->loadByUser($id, $type);
     $param = EB::registry($oauth->params);
     $screenName = $param->get('screen_name', '');
     $acl = EB::acl($id);
     $rule = 'update_' . $type;
     if (!$acl->get($rule)) {
         return false;
     }
     switch ($type) {
         case 'twitter':
             $link = empty($screenName) ? '' : 'http://twitter.com/' . $screenName;
             break;
         case 'facebook':
             $link = '';
             break;
         case 'linkedin':
             $link = '';
             break;
     }
     return $link;
 }
Esempio n. 2
0
 public function __construct()
 {
     $this->my = JFactory::getUser();
     $this->app = JFactory::getApplication();
     $this->input = EB::request();
     $this->acl = EB::acl();
     $this->config = EB::config();
     // Set the user project
     $this->user = EB::user($this->my->id);
 }
Esempio n. 3
0
 /**
  * Pushes to the oauth site
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function push(EasyBlogPost &$post)
 {
     // When there is no access token set on this oauth record, we shouldn't do anything
     if (!$this->access_token) {
         $this->setError(JText::sprintf('No access token available for autoposting on %1$s', $this->type));
         return false;
     }
     $config = EB::config();
     // Determines if this user is really allowed to auto post
     $author = $post->getAuthor();
     // Check the author's acl
     $acl = EB::acl($author->id);
     $rule = 'update_' . $this->type;
     if (!$acl->get($rule) && !EB::isSiteAdmin($post->created_by)) {
         $this->setError(JText::sprintf('No access to autopost on %1$s', $this->type));
         return false;
     }
     // we only check if the autopost on blog edit is disabled.
     if (!$config->get('integrations_' . $this->type . '_centralized_send_updates')) {
         // Check if the blog post was shared before.
         if ($this->isShared($post->id)) {
             $this->setError(JText::sprintf('Post %1$s has been shared to %2$s before.', $post->id, $this->type));
             return false;
         }
     }
     // Ensure that the oauth data has been set correctly
     $config = EB::config();
     $key = $config->get('integrations_' . $this->type . '_api_key');
     $secret = $config->get('integrations_' . $this->type . '_secret_key');
     // If either of this is empty, skip this
     if (!$key || !$secret) {
         return false;
     }
     // Set the callback URL
     $callback = JURI::base() . 'index.php?option=com_easyblog&task=oauth.grant&type=' . $this->type;
     // Now we do the real thing. Get the library and push
     $lib = EB::oauth()->getClient($this->type, $key, $secret, $callback);
     $lib->setAccess($this->access_token);
     // Try to share the post now
     $state = $lib->share($post, $this);
     if ($state === true) {
         $history = EB::table('OAuthPost');
         $history->load(array('oauth_id' => $this->id, 'post_id' => $post->id));
         $history->post_id = $post->id;
         $history->oauth_id = $this->id;
         $history->created = EB::date()->toSql();
         $history->modified = EB::date()->toSql();
         $history->sent = EB::date()->toSql();
         $history->store();
         return true;
     }
     return false;
 }
Esempio n. 4
0
 public function __construct($config = array())
 {
     $this->doc = JFactory::getDocument();
     $this->app = JFactory::getApplication();
     $this->acl = EB::acl();
     $this->my = JFactory::getUser();
     $this->info = EB::info();
     $this->config = EB::config();
     if ($this->doc->getType() == 'ajax') {
         $this->ajax = EB::ajax();
     }
     parent::__construct($config);
     $this->input = EB::request();
 }
Esempio n. 5
0
 public function __construct()
 {
     $this->doc = JFactory::getDocument();
     $this->app = JFactory::getApplication();
     $this->my = JFactory::getUser();
     $this->config = EB::config();
     $this->info = EB::info();
     $this->jconfig = EB::jconfig();
     $this->acl = EB::acl();
     // If this is a dashboard theme, we need to let the theme object know
     $options = array('paramsPrefix' => $this->paramsPrefix);
     // If this is an ajax document, we should pass the $ajax library to the client
     if ($this->doc->getType() == 'ajax') {
         //we need to load frontend language from here incase it was called from backend.
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $this->ajax = EB::ajax();
     }
     // Create an instance of the theme so child can start setting variables to it.
     $this->theme = EB::template(null, $options);
     // Set the input object
     $this->input = EB::request();
 }
Esempio n. 6
0
 public function updateComment()
 {
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $acl = EB::acl();
     $id = JRequest::getInt('commentId');
     $post = JRequest::get('POST');
     //add here so that other component with the same comment.php jtable file will not get reference.
     JTable::addIncludePath(EBLOG_TABLES);
     $comment = EB::table('Comment');
     $comment->load($id);
     $redirect = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, false);
     if (($my->id != $comment->created_by || !$acl->get('delete_comment')) && !EasyBlogHelper::isSiteAdmin() && !$acl->get('manage_comment') || $my->id == 0) {
         EB::info()->set(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_UPDATE_COMMENT'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     $comment->bindPost($post);
     if (!$comment->validate('title')) {
         EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_TITLE_IS_EMPTY'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     if (!$comment->validate('comment')) {
         EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_IS_EMPTY'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     $comment->modified = EB::date()->toMySQL();
     if (!$comment->store()) {
         EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_FAILED_TO_SAVE'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_UPDATED_SUCCESS'), 'success');
     $mainframe->redirect($redirect);
     $mainframe->close();
 }
Esempio n. 7
0
 /**
  * Displays blog posts created by specific users
  *
  * @since	4.0
  * @access	public
  */
 public function listings()
 {
     // Get sorting options
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $id = $this->input->get('id', 0, 'int');
     // Load the author object
     $author = EB::user($id);
     // Disallow all users from being viewed
     if (!$this->config->get('main_nonblogger_profile') && !EB::isBlogger($author->id) || !$author->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_INVALID_AUTHOR_ID_PROVIDED'));
     }
     // Get the authors acl
     $acl = EB::acl($author->id);
     // Set meta tags for the author if allowed to
     if ($acl->get('allow_seo')) {
         EB::setMeta($author->id, META_TYPE_BLOGGER, true);
     }
     // Set the breadcrumbs
     if (!EBR::isCurrentActiveMenu('blogger', $author->id) && !EBR::isCurrentActiveMenu('blogger')) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger'));
         $this->setPathway($author->getName());
     }
     // Get the current active menu
     $active = $this->app->getMenu()->getActive();
     // Excluded categories
     $excludeCats = array();
     if (isset($active->params)) {
         $excludeCats = $active->params->get('exclusion');
         // Ensure that this is an array
         if (!is_array($excludeCats) && $excludeCats) {
             $excludeCats = array($excludeCats);
         }
     }
     // Get the blogs model now to retrieve our blog posts
     $model = EB::model('Blog');
     // Get blog posts
     $posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, '', false, false, '', false, false, false, $excludeCats);
     $pagination = $model->getPagination();
     // Format the blogs with our standard formatter
     $posts = EB::formatter('list', $posts);
     // Add canonical urls
     $this->canonical('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id);
     // Add authors rss links on the header
     if ($this->config->get('main_rss')) {
         if ($this->config->get('main_feedburner') && $this->config->get('main_feedburnerblogger')) {
             $this->doc->addHeadLink(EB::string()->escape($author->getRssLink()), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         } else {
             // Add rss feed link
             $this->doc->addHeadLink($author->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
             $this->doc->addHeadLink($author->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
         }
     }
     // Set the title of the page
     $title = EB::getPageTitle($author->getName());
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Check if subscribed
     $bloggerModel = EB::model('Blogger');
     $isBloggerSubscribed = $bloggerModel->isBloggerSubscribedEmail($author->id, $this->my->email);
     $return = base64_encode($author->getPermalink());
     $this->set('return', $return);
     $this->set('author', $author);
     $this->set('posts', $posts);
     $this->set('sort', $sort);
     $this->set('isBloggerSubscribed', $isBloggerSubscribed);
     parent::display('authors/item');
 }
Esempio n. 8
0
 /**
  * Remove an item as featured
  *
  * @param	string	$type	The type of this item
  * @param	int		$postId	The unique id of the item
  *
  * @return	string	Json string
  **/
 function removeFeaturedx($type, $postId)
 {
     $ajax = new Ejax();
     $acl = EB::acl();
     EasyBlogHelper::removeFeatured($type, $postId);
     $idName = '';
     $message = '';
     switch ($type) {
         case 'blogger':
             $idName = '#blogger_title_' . $postId;
             $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED');
             break;
         case 'teamblog':
             $idName = '#teamblog_title_' . $postId;
             $message = JText::_('COM_EASYBLOG_TEAMBLOG_UNFEATURED');
             break;
         case 'post':
         default:
             $idName = '#title_' . $postId;
             $message = JText::_('COM_EASYBLOG_BLOG_UNFEATURED');
             break;
     }
     $ajax->script('$("' . $idName . '").removeClass("featured-item");');
     $ajax->alert($message, JText::_('COM_EASYBLOG_INFO'), '450', 'auto');
     $ajax->send();
     return;
 }
Esempio n. 9
0
        echo JText::_('MOD_EASYSOCIAL_MENU_ACTIVITY_LOG');
        ?>
</span>
				</a>
			</li>
			<?php 
    }
    ?>


			<!-- EasyBlog Integrations -->
			<?php 
    if ($params->get('integrate_easyblog', true) && $eblogExists) {
        ?>
				<?php 
        if (EB::acl()->get('add_entry')) {
            ?>
					<li>
						<a href="<?php 
            echo EBR::_('index.php?option=com_easyblog&view=dashboard&layout=write&Itemid=' . EBR::getItemId('dashboard'));
            ?>
">
							<i class="ies-plus-2 ies-small"></i>
							<span><?php 
            echo JText::_('MOD_EASYSOCIAL_MENU_EASYBLOG_WRITE_NEW');
            ?>
</span>
						</a>
					</li>
					<li>
						<a href="<?php 
Esempio n. 10
0
 /**
  * Allow current user to remove their own profile picture.
  *
  */
 public function removePicture()
 {
     $mainframe = JFactory::getApplication();
     $acl = EB::acl();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     if (!$config->get('layout_avatar') || !$acl->get('upload_avatar')) {
         EB::info()->set(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_DELETE_PROFILE_PICTURE'), 'error');
         $mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
         $mainframe->close();
     }
     JTable::addIncludePath(EBLOG_TABLES);
     $profile = EB::user($my->id);
     $avatar_config_path = $config->get('main_avatarpath');
     $avatar_config_path = rtrim($avatar_config_path, '/');
     $avatar_config_path = str_replace('/', DIRECTORY_SEPARATOR, $avatar_config_path);
     $path = JPATH_ROOT . DIRECTORY_SEPARATOR . $avatar_config_path . DIRECTORY_SEPARATOR . $profile->avatar;
     if (!JFile::delete($path)) {
         EB::info()->set(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_DELETE_PROFILE_PICTURE'), 'error');
         $mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
         $mainframe->close();
     }
     // @rule: Update avatar in database
     $profile->avatar = '';
     $profile->store();
     EB::info()->set(JText::_('COM_EASYBLOG_PROFILE_PICTURE_REMOVED'));
     $mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
     $mainframe->close();
 }
Esempio n. 11
0
 /**
  * Retrieves author's acl
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAcl()
 {
     $acl = EB::acl($this->id);
     return $acl;
 }
Esempio n. 12
0
 /**
  * Uploads a user avatar
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function upload($fileData, $userId = false)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // Check if the user is allowed to upload avatar
     $acl = EB::acl();
     // Ensure that the user really has access to upload avatar
     if (!$acl->get('upload_avatar')) {
         $this->setError('COM_EASYBLOG_NO_PERMISSION_TO_UPLOAD_AVATAR');
         return false;
     }
     // Get the current user
     $user = JFactory::getUser();
     // If there is userId passed, means this is from backend.
     // We cannot get the current logged in user because it will always be the admin.
     if ($userId) {
         $user = JFactory::getUser($userId);
     }
     $app = JFactory::getApplication();
     $config = EB::config();
     $path = $config->get('main_avatarpath');
     $path = rtrim($path, '/');
     $relativePath = $path;
     $absolutePath = JPATH_ROOT . '/' . $path;
     // If the absolute path does not exist, create it first
     if (!JFolder::exists($absolutePath)) {
         JFolder::create($absolutePath);
         // Copy the index.html file over to this new folder
         JFile::copy(JPATH_ROOT . '/components/com_easyblog/index.html', $absolutePath . '/index.html');
     }
     // The file data should have a name
     if (!isset($fileData['name'])) {
         return false;
     }
     // Generate a better name for the file
     $fileData['name'] = $user->id . '_' . JFile::makeSafe($fileData['name']);
     // Get the relative path
     $relativeFile = $relativePath . '/' . $fileData['name'];
     // Get the absolute file path
     $absoluteFile = $absolutePath . '/' . $fileData['name'];
     // Test if the file is upload-able
     $message = '';
     if (!EB::image()->canUpload($fileData, $message)) {
         $this->setError($message);
         return false;
     }
     // Determines if the web server is generating errors
     if ($fileData['error'] != 0) {
         $this->setError($fileData['error']);
         return false;
     }
     // We need to delete the old avatar
     $profile = EB::user($user->id);
     // Get the old avatar
     $oldAvatar = $profile->avatar;
     $isNew = false;
     // Delete the old avatar first
     if ($oldAvatar != 'default.png' && $oldAvatar != 'default_blogger.png') {
         $session = JFactory::getSession();
         $sessionId = $session->getToken();
         $oldAvatarPath = $absolutePath . '/' . $oldAvatar;
         if (JFile::exists($oldAvatarPath)) {
             JFile::delete($oldAvatarPath);
         }
     } else {
         $isNew = true;
     }
     $width = EBLOG_AVATAR_LARGE_WIDTH;
     $height = EBLOG_AVATAR_LARGE_HEIGHT;
     $image = EB::simpleimage();
     $image->load($fileData['tmp_name']);
     $image->resizeToFill($width, $height);
     $image->save($absoluteFile, $image->type);
     if ($isNew && $config->get('main_jomsocial_userpoint')) {
         EB::jomsocial()->assignPoints('com_easyblog.avatar.upload', $user->id);
     }
     return $fileData['name'];
 }
Esempio n. 13
0
 public static function isBlogger($userId)
 {
     if (empty($userId)) {
         return false;
     }
     $acl = EB::acl($userId);
     if ($acl->get('add_entry')) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 14
0
 public function updateBlogSubscriptionEmail($sid, $userid, $email)
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EB::acl();
     $my = JFactory::getUser();
     if ($acl->get('allow_subscription') || empty($my->id) && $config->get('main_allowguestsubscribe')) {
         $subscriber = EB::table('Subscriptions');
         $subscriber->load($sid);
         $subscriber->user_id = $userid;
         $subscriber->email = $email;
         $subscriber->store();
     }
 }
Esempio n. 15
0
 public function __construct($uid = null, $userId = null)
 {
     // Load site's language file
     EB::loadLanguages();
     // This will call EasyBlog class to construct $config, $doc, $app, $input, $my.
     parent::__construct();
     // Globals
     $this->uid = $uid;
     // The author of this item
     $this->user = EB::user($userId);
     // The acl of the author
     $this->acl = EB::acl($this->user->id);
     // If this is a new post, we want to create a new workbench
     if (!$uid) {
         $this->createNewWorkbench();
     } else {
         $this->load($uid);
     }
     // Set the post object to the router so that they can easily retrieve it.
     EBR::setPost($this);
 }
Esempio n. 16
0
 /**
  * Class Constructor
  *
  * @since	3.7
  * @access	public
  */
 public function __construct($overrideTheme = null, $options = array())
 {
     parent::__construct();
     // Determine if this is an admin location
     if (isset($options['admin']) && $options['admin']) {
         $this->admin = true;
     }
     // Determine the configured theme
     $theme = $this->config->get('layout_theme', $overrideTheme);
     // If a view is provided into the theme, the theme files could call methods from a view
     if (isset($options['view']) && is_object($options['view'])) {
         $this->view = $options['view'];
     }
     $this->theme = $theme;
     $obj = new stdClass();
     $obj->config = EB::config();
     $obj->my = JFactory::getUser();
     $obj->admin = EB::isSiteAdmin();
     $obj->profile = EB::user();
     // If it's development mode, allow user to invoke in the url to change theme.
     $invokeTheme = $this->input->get('theme', '', 'word');
     if ($invokeTheme) {
         $this->theme = $invokeTheme;
     }
     // If this is entry view, or category view, we need to respect the theme's category
     $this->menu = $this->app->getMenu()->getActive();
     $this->params = new JRegistry();
     if ($this->menu) {
         $this->params = $this->menu->params;
         // we will just set it here from the menu when this class first get instantiate. the corresponding view will have to do their own assignment if the view's templates need to access this entryParams
         $this->entryParams = $this->menu->params;
     }
     //is blogger mode flag
     $obj->isBloggerMode = EBR::isBloggerMode();
     $this->my = $obj->my;
     // Assign the acl
     $this->acl = EB::acl();
 }
Esempio n. 17
0
 public function post()
 {
     $app = JFactory::getApplication();
     $my = $this->plugin->getUser();
     $config = EasyBlogHelper::getConfig();
     //$acl = EasyBlogACLHelper::getRuleSet();
     $acl = EB::acl();
     $post = $app->input->post->getArray();
     if (empty($acl->rules->allow_comment) && (empty($my->id) && !$config->get('main_allowguestcomment'))) {
         $this->plugin->setResponse($this->getErrorResponse(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_POST_COMMENT')));
     }
     $isModerated = false;
     $parentId = isset($post['parent_id']) ? $post['parent_id'] : 0;
     $commentDepth = isset($post['comment_depth']) ? $post['comment_depth'] : 0;
     $blogId = isset($post['id']) ? $post['id'] : 0;
     $subscribeBlog = isset($post['subscribe-to-blog']) ? true : false;
     if (!$blogId) {
         $this->plugin->setResponse($this->getErrorResponse(404, 'Invalid Blog'));
     }
     // @task: Cleanup posted values.
     array_walk($post, array($this, '_trim'));
     array_walk($post, array($this, '_revertValue'));
     if (!$config->get('comment_require_email') && !isset($post['esemail'])) {
         $post['esemail'] = '';
     }
     // @task: Run some validation tests on the posted values.
     if (!$this->_validateFields($post)) {
         $this->plugin->setResponse($this->getErrorResponse(500, $this->err[0]));
     }
     // @task: Akismet detection service.
     if ($config->get('comment_akismet')) {
         $data = array('author' => $post['esname'], 'email' => $post['esname'], 'website' => JURI::root(), 'body' => $post['comment'], 'permalink' => EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $post['id']));
         if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) {
             $this->plugin->setResponse($this->getErrorResponse(500, JText::_('COM_EASYBLOG_SPAM_DETECTED_IN_COMMENT')));
         }
     }
     // @task: Retrieve the comments model
     $model = EasyBlogHelper::getModel('Comment');
     // @task: Retrieve the comment's table
     $comment = EasyBlogHelper::table('Comment');
     // We need to rename the esname and esemail back to name and email.
     $post['post_id'] = $post['id'];
     $post['name'] = $post['esname'];
     $post['email'] = $post['esemail'];
     unset($post['id']);
     unset($post['esname']);
     unset($post['esemail']);
     // @task: Bind posted values into the table.
     $comment->bindPost($post);
     // @task: Process registrations
     $registerUser = isset($post['esregister']) ? true : false;
     $fullname = isset($post['name']) ? $post['name'] : '';
     $username = isset($post['esusername']) ? $post['esusername'] : '';
     $email = $post['email'];
     $message = '';
     $newUserId = 0;
     // @task: Process registrations if necessary
     if ($registerUser && $my->id <= 0) {
         $state = $this->processRegistrations($post, $username, $email, $ajax);
         if (!is_numeric($state)) {
             $this->plugin->setResponse($this->getErrorResponse(500, $state));
         }
         $newUserId = $state;
     }
     $totalComments = empty($post['totalComment']) ? 1 : $post['totalComment'];
     //$date 	= EasyBlogHelper::getDate();
     $date = EasyBlogDate::getDate();
     $comment->set('created', $date->toMySQL());
     $comment->set('modified', $date->toMySQL());
     $comment->set('published', 1);
     $comment->set('parent_id', $parentId);
     $comment->set('sent', 0);
     $comment->set('created_by', $my->id);
     // @rule: Update the user's id if they have just registered earlier.
     if ($newUserId != 0) {
         $comment->set('created_by', $newUserId);
     }
     // @rule: Update publish status if the comment requires moderation
     if ($config->get('comment_moderatecomment') == 1 || $my->id == 0 && $config->get('comment_moderateguestcomment') == 1) {
         $comment->set('published', EBLOG_COMMENT_STATUS_MODERATED);
         $isModerated = true;
     }
     $blog = EasyBlogHelper::table('Blog');
     $blog->load($blogId);
     // 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 == $my->id) {
         $comment->set('published', 1);
         $isModerated = false;
     }
     if (!$comment->store()) {
         $this->plugin->setResponse($this->getErrorResponse(500, 'There was a problem saving the comment'));
     }
     // @rule: Process subscription for blog automatically when the user submits a new comment and wants to subscribe to the blog.
     if ($subscribeBlog && $config->get('main_subscription') && $blog->subscription) {
         $isSubscribed = false;
         $userId = $my->id;
         $blogModel = EasyblogHelper::getModel('Blog');
         if ($userId == 0) {
             $sid = $blogModel->isBlogSubscribedEmail($blog->id, $email);
             if (empty($sid)) {
                 $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, '', $fullname);
             }
         } else {
             $sid = $blogModel->isBlogSubscribedUser($blog->id, $userId, $email);
             if (!empty($sid)) {
                 // @task: User found, update the email address
                 $blogModel->updateBlogSubscriptionEmail($sid, $userId, $email);
             } else {
                 $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, $userId, $fullname);
             }
         }
     }
     $row = $comment;
     $creator = EasyBlogHelper::table('Profile');
     $creator->load($my->id);
     $row->poster = $creator;
     $row->comment = nl2br($row->comment);
     $row->comment = EasyBlogComment::parseBBCode($row->comment);
     $row->depth = is_null($commentDepth) ? '0' : $commentDepth;
     $row->likesAuthor = '';
     // @rule: Process notifications
     $comment->processEmails($isModerated, $blog);
     //update the sent flag to sent
     $comment->updateSent();
     // @TODO - Move this to a map comment function
     $item = new CommentSimpleSchema();
     $item->commentid = $comment->id;
     $item->postid = $comment->post_id;
     $item->title = $comment->title;
     $item->text = EasyBlogComment::parseBBCode($comment->comment);
     $item->textplain = strip_tags(EasyBlogComment::parseBBCode($comment->comment));
     $item->created_date = $comment->created;
     $item->created_date_elapsed = EasyBlogDate::getLapsedTime($comment->created);
     $item->updated_date = $comment->modified;
     // Author
     $item->author->name = isset($comment->poster->nickname) ? $comment->poster->nickname : $comment->name;
     $item->author->photo = isset($comment->poster->avatar) ? $comment->poster->avatar : 'default_blogger.png';
     $item->author->photo = JURI::root() . 'components/com_easyblog/assets/images/' . $item->author->photo;
     $item->author->email = $comment->email;
     $item->author->website = isset($comment->poster->url) ? $comment->poster->url : $comment->url;
     $this->plugin->setResponse($item);
 }
Esempio n. 18
0
 public function editComment($id)
 {
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $ajax = new Ejax();
     $acl = EB::acl();
     JTable::addIncludePath(EBLOG_TABLES);
     $comment = EB::table('Comment');
     $comment->load($id);
     $tpl = EB::template();
     $tpl->set('comment', $comment);
     $options = new stdClass();
     $options->title = JText::_('COM_EASYBLOG_DASHBOARD_EDIT_COMMENT');
     $options->content = $tpl->output('site/comments/dialog.edit');
     $ajax->dialog($options);
     $ajax->send();
 }
Esempio n. 19
0
 /**
  * Displays a list of blog posts created on the site
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function entries()
 {
     // Only allow logged in users on this page
     EB::requireLogin();
     // Ensure that the user has access to this section
     $this->checkAcl('add_entry');
     // Get the user group acl
     $aclLib = EB::acl();
     //check if this is coming from write layout or not.
     $isWrite = $this->getLayout() == 'write' ? 1 : 0;
     // Get the page title
     $title = EB::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_ENTRIES_PAGE_TITLE'));
     $this->setPageTitle($title, false, $this->config->get('main_pagetitle_autoappend'));
     // Set the breadcrumbs
     $this->setViewBreadcrumb('dashboard');
     $this->setPathway(JText::_('COM_EASYBLOG_DASHBOARD_ENTRIES_BREADCRUMB'), '');
     // Determines if the user is filtering posts by states
     $state = $this->input->get('filter', 'all', 'default');
     if ($state != 'all') {
         $state = (int) $state;
     }
     // Determines if the user is searching for post
     $search = $this->input->get('post-search', '', 'string');
     // Determines if the blog posts should be filtered by specific category
     $categoryFilter = $this->input->get('category', 0, 'int');
     // Get limit
     $limit = $this->config->get('layout_pagination_dashboard_post_per_page');
     // Retrieve the posts
     $model = EB::model('Dashboard');
     $userId = $this->my->id;
     // if the user have moderation entry permission, so it will show all the blog post on blog entries dashboard page.
     if ($aclLib->get('moderate_entry')) {
         $userId = '';
     }
     $result = $model->getEntries($userId, array('category' => $categoryFilter, 'state' => $state, 'search' => $search, 'limit' => $limit));
     // Get pagination
     $pagination = $model->getPagination();
     $pagination->setAdditionalUrlParam('view', 'dashboard');
     $pagination->setAdditionalUrlParam('layout', 'entries');
     if ($categoryFilter) {
         $pagination->setAdditionalUrlParam('category', $categoryFilter);
     }
     if ($state) {
         $pagination->setAdditionalUrlParam('filter', $state);
     }
     if ($search) {
         $pagination->setAdditionalUrlParam('post-search', $search);
     }
     // Format the posts
     $posts = EB::formatter('list', $result);
     // Get oauth clients
     $clients = array('twitter', 'facebook', 'linkedin');
     $oauthClients = array();
     foreach ($clients as $client) {
         $oauth = EB::table('OAuth');
         $exists = $oauth->load(array('user_id' => $userId, 'type' => $client));
         if ($exists && $this->acl->get("update_" . $client) && $this->config->get('integrations_' . $client . '_centralized_and_own')) {
             $oauthClients[] = $oauth;
         }
     }
     // Get a list of categories on the site
     $categoryModel = EB::model('Categories');
     $rows = $categoryModel->getCategoriesUsedByBlogger($userId);
     $categories = array();
     if (count($rows) > 0) {
         foreach ($rows as $row) {
             $category = EB::table('Category');
             $category->bind($row);
             $categories[] = $category;
         }
     }
     $revisionModel = EB::model('Revisions');
     // lets preload the revisions count.
     if ($posts) {
         $pIds = array();
         foreach ($posts as $post) {
             $pIds[] = $post->id;
         }
         $revisionModel->getRevisionCount($pIds, 'cache');
     }
     // Get revisions for the post
     foreach ($posts as $post) {
         $versions = $revisionModel->getAllRevisions($post->id);
         $post->versions = $versions;
     }
     $this->set('pagination', $pagination);
     $this->set('posts', $posts);
     $this->set('search', $search);
     $this->set('categoryFilter', $categoryFilter);
     $this->set('categories', $categories);
     $this->set('oauthClients', $oauthClients);
     $this->set('state', $state);
     $this->set('isWrite', $isWrite);
     echo parent::display('dashboard/entries/default');
 }
Esempio n. 20
0
 /**
  * Stores the media object that is sent from the xmlrpc client
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function uploadMedia($blogid, $username, $password, $file)
 {
     global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;
     // Login the user
     $state = self::login($username, $password);
     if ($state !== true) {
         return $state;
     }
     // Get the config
     $config = EB::config();
     // Get the user's acl
     $acl = EB::acl();
     // Get the current user
     $my = JFactory::getUser();
     // Check if user has permissions to upload images
     if (!$acl->get('upload_image')) {
         return new xmlrpcresp(0, $xmlrpcerruser + 2, JText::_('You do not have permissions to upload files to the site.'));
     }
     // Get the main image storage path
     $path = rtrim($config->get('main_image_path'), '/');
     $relativePath = $path . '/' . $my->id;
     $absolutePath = JPATH_ROOT . '/' . $path . '/' . $my->id;
     $absolutePath = JPath::clean($absolutePath);
     $absoluteUri = rtrim(JURI::root(), '/') . '/' . str_ireplace('\\', '/', $relativePath) . '/' . $my->id;
     // If the user's folder doesn't exist yet, create it first.
     if (!JFolder::exists($absolutePath)) {
         JFolder::create($absolutePath);
     }
     // Set the temporary folder
     $tmp = JPATH_ROOT . '/tmp';
     $mediamanager = EB::mediamanager();
     // Normalize the file name
     $file['name'] = $mediamanager->normalizeFileName($file['name']);
     // Write the file to the
     $tmpFile = $tmp . '/' . $file['name'];
     JFile::write($tmpFile, $file['bits']);
     // Enter some dummy data so we can run some sanity checks on the file
     $file['tmp_name'] = $tmpFile;
     $file['size'] = 0;
     $error = '';
     $allowed = EB::image()->canUploadFile($file, $error);
     // If file uploads aren't allowed for some reasons, we need to revert
     if ($allowed !== true) {
         JFile::delete($file['tmp_name']);
         return new xmlrpcresp(0, $xmlrpcerruser + 1, $error);
     }
     // Ensure that the image goes through the media manager resizing format
     $result = $mediamanager->upload($file);
     // Once it's gone through media manager, delete the temporary file
     JFile::delete($file['tmp_name']);
     // Build the url for the xmlrpc client so that they can replace the links accordingly within the content
     $url = rtrim(JURI::root(), '/') . '/' . $relativePath . '/' . $file['name'];
     return new xmlrpcresp(new xmlrpcval(array('url' => new xmlrpcval($url)), 'struct'));
 }
Esempio n. 21
0
 /**
  * determine if current user can use this block or not in composer.
  *
  * @since   5.0
  * @access  public
  * @param
  * @return boolean
  */
 public function canUse()
 {
     $acl = EB::acl();
     return $acl->get('upload_image');
 }
Esempio n. 22
0
 /**
  * Uploads a team avatar
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function uploadAvatar($file)
 {
     $config = EB::config();
     $acl = EB::acl();
     // Default avatar file name
     $default = 'default_team.png';
     // Construct the storage path of the avatar
     $path = rtrim($config->get('main_teamavatarpath'), '/');
     // Set the relative path
     $relativePath = $path;
     // Set the absolute path
     $absolutePath = JPATH_ROOT . '/' . $path;
     // Check if the folder exists
     EB::makeFolder($absolutePath);
     // Generate a proper file name for the file
     $fileName = md5($file['name'] . JFactory::getDate()->toSql());
     $fileName .= EB::image()->getExtension($file['tmp_name']);
     // Reassign the image name
     $file['name'] = $fileName;
     if (!isset($file['name'])) {
         return $default;
     }
     // Check if the file upload itself contains errors.
     if ($file['error'] != 0) {
         $this->setError($file['error']);
         return false;
     }
     // Construct the relative and absolute file paths
     $relativeFile = $relativePath . '/' . $file['name'];
     $absoluteFile = $absolutePath . '/' . $file['name'];
     // Determine if the user can really upload this file
     $error = '';
     $state = EB::image()->canUpload($file, $error);
     // If user is not allowed to upload image, return proper error
     if (!$state) {
         $this->setError($err);
         return false;
     }
     // Get the old avatar first
     $oldAvatar = $this->avatar;
     $width = EBLOG_AVATAR_LARGE_WIDTH;
     $height = EBLOG_AVATAR_LARGE_HEIGHT;
     // Load up the simple image library
     $image = EB::simpleimage();
     $image->load($file['tmp_name']);
     // Resize the avatar to our specified width / height
     $image->resizeToFill($width, $height);
     // Store the file now
     $image->save($absoluteFile, $image->image_type);
     $this->avatar = $file['name'];
     // Save the team again
     $state = $this->store();
     // If the team has avatar already, remove it
     if ($oldAvatar && $oldAvatar != $default) {
         $existingAbsolutePath = $absolutePath . '/' . $oldAvatar;
         // Test if the file exists before deleting it
         $exists = JFile::exists($existingAbsolutePath);
         if ($exists) {
             JFile::delete($existingAbsolutePath);
         }
     }
     return $state;
 }
Esempio n. 23
0
 /**
  * Saves an author object
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     // Check for acl rules.
     $this->checkAccess('user');
     // Create a new JUser object
     $id = $this->input->get('id', 0, 'int');
     $user = JFactory::getUser($id);
     // Get the user group's id
     $gid = $user->get('gid');
     // Get the posted data
     $post = $this->input->getArray('post');
     // Retrieve the username and password of the user
     $post['username'] = $this->input->get('username', '', 'default');
     $post['password'] = $this->input->get('password', '', 'default');
     $post['password2'] = $this->input->get('password2', '', 'default');
     // Get the data from Joomla's form
     if (isset($post['jform']['params'])) {
         $post['params'] = $post['jform']['params'];
         unset($post['jform']);
     }
     // Bind the post request on the user's object
     $state = $user->bind($post);
     // Default redirection url
     $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id;
     if (!$state) {
         $this->info->set($user->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Get the user's id
     if ($user->id == $this->my->id && $user->block) {
         $this->info->set(JText::_('You are not allowed to block yourself.'), 'error');
         return $this->app->redirect($redirect);
     }
     if ($user->authorise('core.admin') && $user->block) {
         $this->info->set(JText::_('You are not allowed to block a super administrator.'), 'error');
         return $this->app->redirect($redirect);
     }
     if ($user->authorise('core.admin') && !$this->my->authorise('core.admin')) {
         $this->info->set(JText::_('You cannot edit a Super User account.'), 'error');
         return $this->app->redirect($redirect);
     }
     $gid = $post['gid'];
     if (!empty($gid)) {
         $user->groups = array();
         foreach ($gid as $groupid) {
             $user->groups[$groupid] = $groupid;
         }
     }
     // Are we dealing with a new user which we need to create?
     $isNew = $user->id < 1;
     // Try to save the user now
     $state = $user->save();
     if (!$state) {
         $this->info->set($user->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Update the user's session data if the current user is being edited to ensure that
     // the current user's data is correct
     if ($user->id == $this->my->id) {
         $session = JFactory::getSession();
         $session->set('user', $user);
     }
     // If this is a new record, ensure that the id is not set
     if ($isNew) {
         unset($post['id']);
     }
     // Set the proper permalink
     if (isset($post['user_permalink'])) {
         $post['permalink'] = $post['user_permalink'];
         unset($post['user_permalink']);
     }
     // Only allow site admins to add html codes for the description and biography
     if (EB::isSiteAdmin()) {
         $post['description'] = $this->input->get('description', '', 'html');
         $post['biography'] = $this->input->get('biography', '', 'html');
     }
     // After the user record is stored, we also want to update EasyBlog's records.
     $author = EB::user($user->id);
     // Bind the posted data
     $author->bind($post);
     // Get the file data
     $file = $this->input->files->get('avatar', '');
     if (isset($file['tmp_name']) && !empty($file['tmp_name'])) {
         $author->bindAvatar($file, EB::acl());
     }
     // Save other user parameters
     $registry = EB::registry();
     // Save google profile url
     if (isset($post['google_profile_url'])) {
         $registry->set('google_profile_url', $post['google_profile_url']);
     }
     if (isset($post['show_google_profile_url'])) {
         $registry->set('show_google_profile_url', $post['show_google_profile_url']);
     }
     $author->params = $registry->toString();
     // Try to save the author object now
     $author->store();
     // Save the social settings
     $twitter = EB::table('OAuth');
     $twitter->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_TWITTER));
     $twitter->auto = $this->input->get('integrations_twitter_auto');
     $twitter->message = $this->input->get('integrations_twitter_message', '', 'default');
     // Try to save the twitter oauth object now
     $state = $twitter->store();
     if (!$state) {
         $this->info->set($twitter->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Try to save the linked in oauth object
     $linkedin = EB::table('OAuth');
     $linkedin->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_LINKEDIN));
     $linkedin->auto = $this->input->get('integrations_linkedin_auto', '', 'bool');
     $linkedin->message = $this->input->get('integrations_linkedin_message', '', 'default');
     $linkedin->private = $this->input->get('integrations_linkedin_private', '', 'bool');
     // Save the oauth object now
     $state = $linkedin->store();
     if (!$state) {
         $this->info->set($linkedin->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Store the Facebook oauth object now
     $facebook = EB::table('OAuth');
     $facebook->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_FACEBOOK));
     $facebook->auto = $this->input->get('integrations_facebook_auto', '', 'bool');
     $facebook->message = '';
     // Save the facebook object now
     $state = $facebook->store();
     if (!$state) {
         $this->info->set($facebook->getError(), 'error');
         return $this->app->redirect($redirect);
     }
     // Save google adsense codes now
     if ($this->config->get('integration_google_adsense_enable')) {
         $adsense = EB::table('Adsense');
         $adsense->load($user->id);
         $adsense->code = $post['adsense_code'];
         $adsense->display = $post['adsense_display'];
         $adsense->published = $post['adsense_published'];
         $adsense->store();
     }
     // Store Feedburner's data
     $feedburner = EB::table('Feedburner');
     $feedburner->load($user->id);
     $feedburner->url = $post['feedburner_url'];
     $feedburner->store();
     // Get the current task
     $task = $this->getTask();
     $this->info->set('COM_EASYBLOG_BLOGGER_SAVED', 'success');
     if ($task == 'apply') {
         $redirect = 'index.php?option=com_easyblog&view=bloggers&layout=form&id=' . $user->id;
         return $this->app->redirect($redirect);
     }
     return $this->app->redirect('index.php?option=com_easyblog&view=bloggers');
 }
Esempio n. 24
0
 /**
  * Method to store tags for a blog post.
  *
  * @access	private
  * @param	TableBlog	$blog 	The blog's database row.
  */
 public function saveTags($tags)
 {
     // If there's no tags, just skip the whole block
     if (!$tags) {
         return false;
     }
     $config = EasyBlogHelper::getConfig();
     $acl = EB::acl();
     // @rule: Needed to add points for each tag creation
     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;
         }
     }
     if (!is_array($tags)) {
         $tags = array($tags);
     }
     $model = EB::model('PostTag');
     foreach ($tags as $title) {
         // Skip this if the tag is invalid.
         if (empty($title)) {
             continue;
         }
         $tag = EB::table('Tag');
         $tag->load($title, true);
         if (!$tag->exists($title) && $acl->get('create_tag')) {
             $tag->created_by = JFactory::getUser()->id;
             $tag->title = $title;
             $tag->created = EB::date()->toMySQL();
             $tag->store();
         }
         // Add the association for the tag.
         $model->add($tag->id, $blog->id, EB::date()->toMySQL());
     }
     return true;
 }
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
jimport('joomla.filesystem.file');
$engine = JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php';
if (!JFile::exists($engine)) {
    return;
}
require_once $engine;
require_once __DIR__ . '/helper.php';
// This module will require the main script file since composer needs to be loaded
EB::init('site');
// Ensure that all script are loaded in the site.
EB::init('module');
// Attach modules stylesheet
EB::stylesheet('module')->attach();
// Get the current user.
$my = JFactory::getUser();
// Get the return url
$return = modEasyBlogWelcomeHelper::getReturnURL($params);
// Get the blogger object
$author = EB::user($my->id);
// Get available options
$config = EB::config();
$acl = EB::acl();
// Determines if we should allow registration
$usersConfig = JComponentHelper::getParams('com_users');
$allowRegistration = $usersConfig->get('allowUserRegistration');
require JModuleHelper::getLayoutPath('mod_easyblogwelcome');
Esempio n. 26
0
 function updateTeamSubscriptionEmail($sid, $userId, $email)
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EB::acl();
     $my = JFactory::getUser();
     $subscriber = EB::table('Subscriptions');
     $subscriber->load($sid);
     $teamTbl = EB::table('Teamblog');
     $teamTbl->load($subscriber->uid);
     $gid = EasyBlogHelper::getUserGids($userId);
     $isMember = $teamTbl->isMember($userId, $gid);
     if ($teamTbl->allowSubscription($teamTbl->access, $userId, $isMember, $acl->get('allow_subscription'))) {
         $subscriber->user_id = $userId;
         $subscriber->email = $email;
         $subscriber->store();
     }
 }
Esempio n. 27
0
 /**
  * Gets the ACL for the specific place
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function getPlaceAcl($placeId)
 {
     $my = JFactory::getUser();
     $aclLib = EB::acl();
     $allowedUpload = EB::isSiteAdmin() || $aclLib->get('upload_image');
     // TODO: I'm not sure if specific user, e.g. user 128 viewing user 64,
     // needs to be processed here. But I really like to get rid of user
     // folders altogether.
     if (self::isUserPlace($placeId)) {
         $acl = array_merge(self::$acl, array('canCreateFolder' => $allowedUpload, 'canUploadItem' => $allowedUpload, 'canRenameItem' => true, 'canMoveItem' => true, 'canRemoveItem' => true, 'canCreateVariation' => true, 'canDeleteVariation' => true));
     }
     // Article place
     if (self::isPostPlace($placeId)) {
         $id = explode(':', $placeId);
         $post = EB::table('Blog');
         $post->load($id[1]);
         $allowed = $my->id == $post->created_by || EB::isSiteAdmin() || $aclLib->get('moderate_entry');
         // Get the article
         $acl = array_merge(self::$acl, array('canCreateFolder' => $allowedUpload, 'canUploadItem' => $allowedUpload, 'canRenameItem' => $allowedUpload, 'canMoveItem' => $allowedUpload, 'canRemoveItem' => $allowedUpload, 'canCreateVariation' => $allowed, 'canDeleteVariation' => $allowed));
     }
     // Shared
     if (self::isSharedPlace($placeId)) {
         $allowed = EB::isSiteAdmin() || $aclLib->get('media_places_shared');
         $acl = array_merge(self::$acl, array('canCreateFolder' => $allowedUpload, 'canUploadItem' => $allowedUpload, 'canRenameItem' => $allowedUpload, 'canMoveItem' => $allowedUpload, 'canRemoveItem' => $allowedUpload, 'canCreateVariation' => $allowed, 'canDeleteVariation' => $allowed));
     }
     // If there's no acl defined, we should use the default acl
     if (!isset($acl)) {
         $acl = self::$acl;
     }
     return (object) $acl;
 }
Esempio n. 28
0
 public function import($index)
 {
     // Get the data from the mailbox
     $data = $this->mailbox->getMessageInfo($index);
     if ($data === false) {
         return JText::_('Unable to get message data for index <b>' . $index . '</b>');
     }
     // Get the properties from the mail
     $uid = $data->message_id;
     $udate = $data->udate;
     $size = $data->Size;
     $mailDate = $data->MailDate;
     // Try to get the sender data
     $from = $this->getSender($data);
     // Map the sender's email to the user on this site.
     if ($this->config->get('main_remotepublishing_mailbox_syncuser')) {
         $model = EB::model('Users');
         // Get the user's id
         $authorId = $model->getUserIdByEmail($from);
         if (!$authorId) {
             return JText::sprintf('Unable to detect the user based on the email <b>%1$s</b>.', $from);
         }
         // Ensure that the user has privilege to submit new blog posts
         if ($authorId) {
             $acl = EB::acl($authorId);
             if (!$acl->get('add_entry')) {
                 return JText::sprintf('User <b>%1$s</b> does not have permissions to post new blog post.', $id);
             }
         }
     } else {
         $authorId = $this->config->get('main_remotepublishing_mailbox_userid');
         if (!$authorId) {
             return JText::sprintf('Invalid configured user for mapping blog post into user <b>%1$s</b>.', $id);
         }
     }
     // Get the author
     $author = JFactory::getUser($authorId);
     // Get the subject of the email
     $subject = JString::str_ireplace($this->config->get('main_remotepublishing_mailbox_prefix'), '', $data->subject);
     $filter = JFilterInput::getInstance();
     $subject = $filter->clean($subject, 'string');
     if (!$subject) {
         $subject = JText::sprintf('COM_EASYBLOG_REMOTE_PUBLISHING_DEFAULT_EMAIL', EB::date()->toSql());
     }
     // Test if the sender email address is allowed
     if (!$this->isSenderAllowed($from)) {
         return false;
     }
     // Get the mail contents now
     $message = $this->getMessage($index);
     // Get the contents
     $contents = $this->getMessageContents($message, $this->config->get('main_remotepublishing_mailbox_format'));
     // Set the content target
     $contentTarget = $this->config->get('main_remotepublishing_mailbox_type');
     // Bind our result to the post lib
     $data = array();
     $post = EB::post(null, $author->id);
     $post->create(array('overrideDoctType' => EASYBLOG_POST_DOCTYPE_LEGACY));
     // now let get the uid
     $data['uid'] = $post->uid;
     $data['revision_id'] = $post->revision->id;
     $data['title'] = $subject;
     $data['posttype'] = EBLOG_MICROBLOG_EMAIL;
     $data['created_by'] = $author->id;
     $data['created'] = EB::date()->toSql();
     $data['modified'] = EB::date()->toSql();
     $data['publish_up'] = EB::date()->toSql();
     //always set as siteside item
     $data['source_id'] = 0;
     $data['source_type'] = EASYBLOG_POST_SOURCE_SITEWIDE;
     // Set the privacy status for this post
     $data['access'] = $this->config->get('main_remotepublishing_mailbox_privacy');
     // Set the publish status
     $data['published'] = $this->config->get('main_remotepublishing_mailbox_publish');
     // Set the frontpage status
     $data['frontpage'] = $this->config->get('main_remotepublishing_mailbox_frontpage');
     // Determines if notification should be sent
     $data['send_notification_emails'] = $this->config->get('main_remotepublishing_mailbox_publish');
     // Set the primary category for this post
     $data['category_id'] = $this->config->get('main_remotepublishing_mailbox_categoryid');
     $data['categories'] = array($this->config->get('main_remotepublishing_mailbox_categoryid'));
     // we need to set this as legacy post as the post did not go through composer.
     // $data['doctype'] = EASYBLOG_POST_DOCTYPE_LEGACY;
     // lets do the binding here 1st. the rest we will manually assign.
     $post->bind($data, array());
     // Process attachments for this mail
     $attachments = array();
     if ($this->config->get('main_remotepublishing_mailbox_image_attachment')) {
         $attachments = $this->getMessageAttachments($message, $post, $contents->body, $authorId);
     }
     // After processing everything, assign the contents
     $post->{$contentTarget} = $contents->body;
     // Try to save the blog post now
     // Save the post now
     try {
         $saveOptions = array('applyDateOffset' => false, 'validateData' => true, 'useAuthorAsRevisionOwner' => true);
         $post->save($saveOptions);
     } catch (EasyBlogException $exception) {
         // Reject if there is an error while saving post
         return $exception;
     }
     // Delete the message once completed
     $this->markAsRead($index);
     return true;
 }