/** * Validates the quick post submission * * @since 4.0 * @access public * @param string * @return */ public function validate() { $content = $this->input->get('content', '', 'default'); if (!$content) { return EB::exception('COM_EASYBLOG_MICROBLOG_ERROR_EMPTY_CONTENT', 'error'); } return true; }
/** * Validates the quick post submission * * @since 4.0 * @access public * @param string * @return */ public function validate() { $link = $this->input->get('link', '', 'default'); $title = $this->input->get('title', '', 'default'); if (!$link) { return EB::exception('COM_EASYBLOG_MICROBLOG_ERROR_EMPTY_LINK', 'error'); } if (!$title) { return EB::exception('COM_EASYBLOG_MICROBLOG_ERROR_EMPTY_TITLE', 'error'); } return true; }
/** * Initialize dimensions available * * @since 5.0 * @access public * @param string * @return */ public function initDimensions($imagePath, $size = null) { $images = array(); // Ensure that the image really exists on the site. $exists = JFile::exists($imagePath); if (!$exists) { return EB::exception('Invalid file path provided to generate imagesets.', EASYBLOG_MSG_ERROR); } // Get the original image resource $original = EB::simpleimage(); $original->load($imagePath); // Get the original image file name $fileName = basename($imagePath); // Get the original image containing folder $folder = dirname($imagePath); // Determines if we should generate a single size or multiple sizes $sizes = $this->sizes; if (!is_null($size)) { $sizes = array($size); } // Determines if there's a specific size to generate foreach ($sizes as $size) { // Clone the original image to avoid original image width and height being modified $image = clone $original; $data = new stdClass(); $data->width = $this->config->get('main_image_' . $size . '_width'); $data->height = $this->config->get('main_image_' . $size . '_height'); $data->quality = $this->config->get('main_image_' . $size . '_quality'); $data->path = $folder . '/' . EBLOG_SYSTEM_VARIATION_PREFIX . '_' . $size . '_' . $fileName; // Everything should be resized using "resize within" method $resizeMode = 'resizeWithin'; // Resize the image $image->{$resizeMode}($data->width, $data->height); // Save the image $image->write($data->path, $data->quality); unset($image); $images[$size] = $data; } unset($original); return $images; }
/** * Handles uploads from media manager. * * @since 4.0 * @access public * @param string * @return */ public function upload() { // Ensure that the user is logged in EB::requireLogin(); // Only allowed users who are allowed to upload images if (!$this->acl->get('upload_image')) { $this->output(EB::exception('COM_EASYBLOG_NOT_ALLOWED', EASYBLOG_MSG_ERROR)); } // Load up media manager $mm = EB::mediamanager(); // Get uri $key = $this->input->getRaw('key'); // Get the target folder $placeId = EBMM::getUri($key); // Get the file input $file = $this->input->files->get('file'); // Check if the file is really allowed to be uploaded to the site. $state = EB::image()->canUploadFile($file); if ($state instanceof Exception) { return $this->output($state); } // MM should check if the user really has access to upload to the target folder $allowed = EBMM::hasAccess($placeId); if ($allowed instanceof Exception) { return $this->output($allowed); } // Check the image name is it got contain space, if yes need to replace to '-' $fileName = $file['name']; $file['name'] = str_replace(' ', '-', $fileName); // Upload the file now $file = $mm->upload($file, $placeId); // Response object is intended to also include // other properties like status message and status code. // Right now it only inclues the media item. $response = new stdClass(); $response->media = EBMM::getMedia($file->uri); return $this->output($response); }
/** * Dispatches pending emails out * * @since 4.0 * @access public * @param string * @return */ public function dispatch($limit = null) { if (is_null($limit)) { $limit = (int) $this->config->get('main_mail_total'); } $model = EB::model('Mailer'); // Cleanup the mail pool $model->cleanup(); // Get pending emails $result = $model->getPendingEmails($limit); if (!$result) { return EB::exception('There are no pending emails that needs to be dispatched currently.', EASYBLOG_MSG_INFO); } foreach ($result as $row) { $table = EB::table('MailQueue'); $table->load($row->id); $table->status = true; $table->store(); $mailer = JFactory::getMailer(); $mailer->sendMail($table->mailfrom, $table->fromname, $table->recipient, $table->subject, $table->getBody(), true); } return EB::exception(JText::sprintf('Processed and sent %1$s emails', count($result)), EASYBLOG_MSG_INFO); }
/** * Allows uploading of an audio file to the server temporarily. * * @since 4.0 * @access public * @param string * @return */ public function uploadAudio() { // Check for request forgeries // EB::checkToken(); // Ensure that the user is logged in EB::requireLogin(); // Ensure that the user really has permissions to create blog posts on the site if (!$this->acl->get('add_entry')) { EB::exception('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG', EASYBLOG_MSG_ERROR)->setGlobal(); return $this->ajax->reject(); } $file = $this->input->files->get('file'); if (!isset($file['tmp_name']) || empty($file['tmp_name'])) { echo JText::_("COM_EASYBLOG_COMPOSER_UNABLE_TO_LOCATE_TEMPORARY_FILE"); exit; } // Upload this file into their respective images folder. $mm = EB::mediamanager(); $path = $mm->getAbsolutePath('/', 'user:'******'/', 'user:'******'user:' . $this->my->id); // Get the audio player which needs to be embedded on the composer. $player = EB::audio()->getPlayer($result->url); $obj = new stdClass(); $obj->title = $result->title; $obj->player = $player; $obj->file = $result->url; $obj->path = $result->path; echo json_encode($obj); exit; }
/** * Overrides the exception method so that we can silently fail * * @since 5.0 * @access public * @param string * @return */ protected function throwAPIException($result) { $e = new EasyBlogFacebookApiException($result); $message = $e->getMessage(); $exception = EB::exception($message); throw $exception; $this->error = $exception; }
/** * Saves a quick post item * * @since 4.0 * @access public * @param string * @return */ public function save() { // Get the quickpost type $type = $this->input->get('type', '', 'cmd'); // Test if microblogging is allowed if (!$this->config->get('main_microblog')) { $exception = EB::exception(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'), 'error'); return $this->ajax->reject($exception); } // Let's test if the user is a valid user. if (!$this->acl->get('add_entry') || $this->my->guest) { $exception = EB::exception(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'), 'error'); return $this->ajax->reject($exception); } // Ensure that the type is provided otherwise we wouldn't know how to process this if (!$type) { $exception = EB::exception(JText::_('COM_EASYBLOG_SPECIFY_POST_TYPE'), 'error'); return $this->ajax->reject($exception); } // Check if category is set $category = $this->input->get('category', '', 'int'); if (!$category) { $exception = EB::exception(JText::_('COM_EASYBLOG_SELECT_CATEGORY_FOR_POST'), 'error'); return $this->ajax->reject($exception); } // Get the quickpost object $quickpost = $this->getQuickpostObject($type); if ($quickpost === false) { $exception = EB::exception(JText::_('COM_EASYBLOG_INVALID_POST_TYPE'), 'error'); return $ajax->reject($exception); } // Type validations are done here $state = $quickpost->validate(); if ($state !== true) { return $this->ajax->reject($state); } // Load up the blog object $data = array(); $arrData = $this->input->getArray('post'); // need to prepare the data before binding with post lib for quick post item // quick post has limited property. we will just manually assign. $data['category_id'] = $arrData['category']; $data['categories'] = array($arrData['category']); $data['created'] = EB::date()->toSql(); $data['modified'] = EB::date()->toSql(); $data['publish_up'] = EB::date()->toSql(); $data['created_by'] = $this->my->id; $data['access'] = $this->acl->get('enable_privacy') ? $arrData['privacy'] : 0; $data['frontpage'] = $this->acl->get('contribute_frontpage') ? true : false; // If user does not have privilege to store, we need to mark as pending review if (!$this->acl->get('publish_entry')) { $data['published'] = EASYBLOG_POST_PENDING; } else { $data['published'] = EASYBLOG_POST_PUBLISHED; } // quick post is always a sitewide item $data['source_id'] = 0; $data['source_type'] = EASYBLOG_POST_SOURCE_SITEWIDE; // we need to set this as legacy post as the post did not go through composer. $data['doctype'] = EASYBLOG_POST_DOCTYPE_LEGACY; $data['tags'] = $arrData['tags']; // we will let the quickpost adapther to handle the title, content, intro text and . $data['title'] = isset($arrData['title']) ? $arrData['title'] : ''; $data['content'] = ''; $data['intro'] = ''; $data['posttype'] = ''; $data['allowcomment'] = 1; $saveOptions = array('applyDateOffset' => false, 'skipCustomFields' => true); $post = EB::post(); // Create post revision $post->create($saveOptions); // binding $post->bind($data); // process the content $quickpost->bind($post); try { $post->save($saveOptions); } catch (EasyBlogException $exception) { // Reject if there is an error while saving post return $this->ajax->reject($exception); } //save assets * for now only applied to link post if ($post->posttype == 'link') { $quickpost->saveAssets($post); } $message = $quickpost->getSuccessMessage(); if ($post->isPending()) { $message = JText::_('COM_EASYBLOG_DASHBOARD_QUICKPOST_SAVED_REQUIRE_MODERATION'); } return $this->ajax->resolve(EB::exception($message, 'success')); }
/** * Remove all image variations from the site * * @since 5.0 * @access public * @param string * @return */ public function deleteVariations($uri) { // Accepts uri or item. if (is_string($uri)) { $item = $this->getItem($uri); } else { $item = $uri; } $errors = array(); foreach ($item->variations as $key => $variation) { // Skip original variation if ($key == 'system/original') { continue; } // Get the variations path $file = EasyBlogMediaManager::getPath($variation->uri); if (!JFile::exists($file)) { $errors[] = $file; continue; } $state = JFile::delete($file); if (!$state) { $errors[] = $file; } } if (count($errors)) { // TODO: Language return EB::exception('Unable to remove the following image variations: ' . implode(', ', $errors) . '.'); } return true; }
/** * Imports blog posts from a specific email address * * @since 4.0 * @access public * @param string * @return */ public function execute() { // Check if the requirements are set $state = $this->checkRequirements(); if (!$state) { return $state; } // Get the interval for fetching items $nextrun = (int) $this->config->get('main_remotepublishing_mailbox_next_run'); $nextrun = EB::date($nextrun)->toUnix(); $now = EB::date()->toUnix(); // Ensure that the processing time is not elapsing if ($nextrun !== 0 && $now < $nextrun && !$this->debug) { $time = EB::date($nextrun)->format(JText::_('DATE_FORMAT_LC3')); // $this->setError('Email service interval is not up yet. Next service is at ' . $time); return EB::exception('Email service interval is not up yet. Next service is at ' . $time, EASYBLOG_MSG_INFO); } // Set the next run time $this->setNextRunTime(); // Get the mailbox lib $this->getMailbox(); // Get total emails $total = $this->mailbox->getMessageCount(); // Check if there are any emails if ($total < 1) { $this->mailbox->disconnect(); // TODO: Language return EB::exception('No emails found in mailbox. Skipping this.', EASYBLOG_MSG_INFO); } // Determines if we should fetch emails by specific title $criteria = $this->config->get('main_remotepublishing_mailbox_prefix'); // Search for messages $list = $this->search($criteria); // Go through each items and import them now $result = array(); $result['success'] = array(); $result['error'] = array(); if ($list === false) { // TODO: Language return EB::exception('No emails found in mailbox. Skipping this.', EASYBLOG_MSG_INFO); } $total = 0; foreach ($list as $index) { $state = $this->import($index); if ($state === true) { $total += 1; } } // Disconnect the mailbox when we are done $this->mailbox->disconnect(); if ($total > 0) { return EB::exception(JText::sprintf('%1$s emails fetched from mailbox.', $total), EASYBLOG_MSG_INFO); } return EB::exception(JText::_('No emails found in mailbox.'), EASYBLOG_MSG_INFO); }
/** * Executes during cron to import items from feeds * * @since 4.0 * @access public * @param string * @return */ public function cron() { if (!class_exists('DomDocument')) { return EB::exception('COM_EASYBLOG_FEEDS_DOMDOCUMENT_MISSING', EASYBLOG_MSG_ERROR); } // Get the feeds model $model = EB::model('Feeds'); $debug = $this->input->get('debug', false, 'bool'); // @TODO: Configurable limit $limit = 1; // Get a list of pending feeds $feeds = $model->getPendingFeeds($limit, $debug); if (!$feeds) { return EB::exception('COM_EASYBLOG_FEEDS_NO_FEEDS_TO_IMPORT', EASYBLOG_MSG_INFO); } // Determines the total number of feeds imported $total = 0; $results = array(); // Import them now foreach ($feeds as $feed) { // Update the flag first so that if another cron service is executed, it will not overlap $feed->flag = 0; $feed->last_import = EB::date()->toSql(); $feed->store(); // Import them now $results[] = $this->import($feed); } return $results; }
/** * Saves a blog post * * @since 5.0 * @access public * @param string * @return */ public function save() { try { $this->verifyAccess(); } catch (EasyBlogException $exception) { return $this->ajax->reject($exception); } // Get uid & data $uid = $this->input->get('uid'); $data = $this->input->getArray('post'); // Contents needs to be raw $data['content'] = $this->input->get('content', '', 'raw'); $data['document'] = $this->input->get('document', '', 'raw'); // Load up the post library $post = EB::post($uid); $post->bind($data, array()); // Default options $options = array(); // since this is a form submit and we knwo the date that submited already with the offset timezone. we need to reverse it. $options['applyDateOffset'] = true; // check if this is a 'Apply' action or not. $isApply = $this->input->get('isapply', false, 'bool'); // For autosave requests we do not want to run validation on it. $autosave = $this->input->get('autosave', false, 'bool'); if ($autosave) { $options['validateData'] = false; } // Notify that post is successfully $message = $isApply ? 'COM_EASYBLOG_POST_APPLIED_SUCCESS' : 'COM_EASYBLOG_POST_SAVED_SUCCESS'; $state = EASYBLOG_MSG_SUCCESS; if (!$post->isNew()) { $message = $isApply ? 'COM_EASYBLOG_POST_APPLIED_SUCCESS' : 'COM_EASYBLOG_POST_UPDATED_SUCCESS'; $state = EASYBLOG_MSG_INFO; } // Save post try { $post->save($options); } catch (EasyBlogException $exception) { // Reject if there is an error while saving post return $this->ajax->reject($exception); } // If this is being submitted for approval if ($post->isBeingSubmittedForApproval()) { $message = 'COM_EASYBLOG_POST_SUBMITTED_FOR_APPROVAL'; $state = EASYBLOG_MSG_WARNING; } // If this is a draft post. if ($post->isDraft()) { $message = 'COM_EASYBLOG_POST_SAVED_FOR_LATER_SUCCESS'; $state = EASYBLOG_MSG_INFO; } // For autosave if ($autosave) { $date = EB::date(); $date->setTimezone(); $message = JText::sprintf('COM_EASYBLOG_POST_AUTOMATICALLY_SAVED_AT', $date->format(JText::_('COM_EASYBLOG_COMPOSER_AUTOSAVE_TIME_FORMAT'), true)); $state = EASYBLOG_MSG_SUCCESS; } $exception = EB::exception($message, $state); // Resolve with post data $data = $post->toData(); // Reduces number of slashes. // TODO: Should this be part of toData(); $data->revision->content = json_decode($data->revision->content); // Determines if the current page load should be loading from block templates $postTemplate = EB::table('PostTemplate'); $postTemplate->load($this->input->get('block_template', 0, 'int')); if (!$postTemplate->id || $postTemplate->id == 1) { $postTemplate = false; } // Generate the revision status html codes $theme = EB::template(); $theme->set('post', $post); $theme->set('workingRevision', $post->getWorkingRevision()); $theme->set('revisions', $post->getRevisions()); $theme->set('postTemplate', $postTemplate); $revisionStatus = $theme->output('site/composer/panel/revisions/list'); // Get the post's edit url $editLink = $post->getEditLink(false); // Get the post's preview url $previewLink = $post->getPreviewLink(false); return $this->ajax->resolve($data, $exception, $revisionStatus, $editLink, $previewLink); }
/** * Processes the garbage collector on blank posts that already passed 3 days * * @since 4.0 * @access public * @param string * @return */ public function removeBlankPosts() { $db = EB::db(); $now = EB::date()->toMySQL(); // Define how long the file will be in database before it gets deleted. $days = 3; $query = 'delete a, b from ' . $db->qn('#__easyblog_post') . ' as a'; $query .= ' inner join ' . $db->qn('#__easyblog_revisions') . ' as b on a.' . $db->qn('id') . ' = b.' . $db->qn('post_id'); $query .= ' where a.' . $db->qn('published') . ' = ' . $db->Quote(EASYBLOG_POST_BLANK); $query .= ' and a.' . $db->qn('created') . ' <= DATE_SUB(' . $db->Quote($now) . ', INTERVAL ' . $days . ' DAY)'; $db->setQuery($query); $db->query(); return EB::exception('Blank posts removed', EASYBLOG_MSG_INFO); }
/** * Determines if the current user can view this post or not. * * @since 5.0 * @access public * @param string * @return */ public function checkView() { // If the blog post is already deleted, we shouldn't let it to be accessible at all. if ($this->isTrashed()) { return EB::exception('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND', 'error'); } // Check if the blog post is trashed if (!$this->isPublished() && $this->my->id != $this->created_by && !EB::isSiteAdmin()) { return EB::exception('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND', 'error'); } // Check if the user is allowed to view if (!$this->checkTeamPrivacy()) { return EB::exception('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY', 'error'); } // Check if the blog post is accessible. $accessible = $this->isAccessible(); if (!$accessible->allowed) { return EB::exception($accessible->error, 'error'); } return true; }
/** * Retrieves a list of revisions for the post * * @since 5.0 * @access public * @param string * @return */ public function getRevisions() { $uid = $this->input->get('uid'); // Load up the post $post = EB::post($uid); // Ensure that the user is allowed to edit and view revisions from this post if (!$post->canEdit()) { return $this->ajax->reject(EB::exception('You are not allowed to edit this post')); } $revisions = $post->getRevisions(); $theme = EB::template(); $theme->set('post', $post); $theme->set('revisions', $revisions); $output = $theme->output('site/composer/revisions/list'); return $this->ajax->resolve($output); }
/** * Allows caller to import posts from twitter * * @since 5.0 * @access public * @param string * @return */ public function import() { $key = $this->config->get('integrations_twitter_api_key'); $secret = $this->config->get('integrations_twitter_secret_key'); // Ensure that the settings is enabled if (!$this->config->get('integrations_twitter_microblog')) { // TODO: Turn this into language string. return EB::exception('Twitter import has been disabled.', EASYBLOG_MSG_ERROR); } // Get a list of hashtags $hashtags = $this->config->get('integrations_twitter_microblog_hashes'); // If there are no hashtags, skip this if (!$hashtags) { // TODO: Turn this into language string. return EB::exception('No hashtags provided to search. Skipping this.', EASYBLOG_MSG_INFO); } $hashtags = explode(',', $hashtags); $total = count($hashtags); // Get the list of accounts $model = EB::model('OAuth'); $accounts = $model->getTwitterAccounts(); if (!$accounts) { return EB::exception('No Twitter accounts associated on the site. Skipping this', EASYBLOG_MSG_INFO); } // Get the default category to save the tweets into $categoryId = $this->config->get('integrations_twitter_microblog_category'); // Default state of the post $published = $this->config->get('integrations_twitter_microblog_publish'); // Determines if the post should be available on the frontpage $frontpage = $this->config->get('integrations_twitter_microblog_frontpage'); // Determines the total number of items imported $total = 0; // Go through each twitter accounts and search for the tags foreach ($accounts as $account) { $params = EB::registry($account->params); $screen = $params->get('screen_name'); // If we can't get the screen name, do not try to process it. if (!$screen) { continue; } // Get the twitter consumer $consumer = EB::oauth()->getClient('Twitter'); $consumer->setAccess($account->access_token); // Get the last tweet that has been imported so we don't try to search for anything prior to that $lastImport = $model->getLastTweetImport($account->id); // Prepare the search params $tweets = $consumer->search($hashtags, $lastImport); if (!$tweets) { return EB::exception('No tweets found. Skipping this.', EASYBLOG_MSG_INFO); } foreach ($tweets as $tweet) { $data = array(); $data['title'] = JString::substr($tweet->text, 0, 20) . JText::_('COM_EASYBLOG_ELLIPSES'); $data['posttype'] = EBLOG_MICROBLOG_TWITTER; $data['created_by'] = $account->user_id; $data['created'] = EB::date()->toSql(); $data['modified'] = EB::date()->toSql(); $data['publish_up'] = EB::date()->toSql(); $data['intro'] = $tweet->text; $data['published'] = $published; $data['frontpage'] = $frontpage; $data['source_id'] = '0'; $data['source_type'] = EASYBLOG_POST_SOURCE_SITEWIDE; $data['category_id'] = $categoryId; $data['categories'] = array($categoryId); // we need to set this as legacy post as the post did not go through composer. $data['doctype'] = EASYBLOG_POST_DOCTYPE_LEGACY; $post = EB::post(); $createOption = array('overrideDoctType' => 'legacy', 'checkAcl' => false, 'overrideAuthorId' => $account->user_id); $post->create($createOption); // binding $post->bind($data); $saveOptions = array('applyDateOffset' => false, 'validateData' => false, 'useAuthorAsRevisionOwner' => true, 'checkAcl' => false, 'overrideAuthorId' => $account->user_id); // Save the post now try { $post->save($saveOptions); } catch (EasyBlogException $exception) { return $exception; } // We need to save some of these tweets $adapter = EB::quickpost()->getAdapter('twitter'); if ($adapter) { $adapter->saveAsset($post->id, 'screen_name', $tweet->user->screen_name); $adapter->saveAsset($post->id, 'created_at', $tweet->created_at); } // Create a new history record $history = EB::table('TwitterMicroBlog'); $history->id_str = $tweet->id_str; $history->post_id = $post->id; $history->oauth_id = $account->id; $history->created = $post->created; $history->tweet_author = $screen; $history->store(); $total++; } } return EB::exception(JText::sprintf('%1$s tweets retrieved from twitter', $total), EASYBLOG_MSG_SUCCESS); }
/** * Retrieves a list of available authors on the site for admin navigation * * @since 5.0 * @access public * @param string * @return */ public function users() { // Ensure that this user is really allowed here if (!EB::isSiteAdmin()) { return EB::exception('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION'); } // Get a list of authors on the site. $output = EBMM::renderUsers(); return $this->ajax->resolve($output); }
public function verifyAccess($allowGuest = false) { if (!JSession::checkToken('request')) { $this->reject(EB::exception('Invalid token')); $this->send(); } if (!$allowGuest) { $my = JFactory::getUser(); if ($my->guest) { $this->reject(EB::exception('You are not logged in!')); $this->send(); } } }
/** * Validates a quick post * * @since 4.0 * @access public * @param string * @return */ public function validate() { $dataType = $this->input->get('dataType', '', 'cmd'); $fileName = $this->input->get('fileName', '', 'default'); if (empty($fileName)) { $exception = EB::exception('COM_EASYBLOG_QUICKPOST_UPLOAD_PICTURE', 'error'); return $exception; } return true; }
/** * Determines if the user has access to a specific place * * @since 5.0 * @access public * @param string * @return */ public static function hasAccess($placeId) { $acl = (object) self::getPlaceAcl($placeId); if (!$acl->canUploadItem) { return EB::exception('COM_EASYBLOG_MM_NOT_ALLOWED_TO_UPLOAD_FILE', EASYBLOG_MSG_ERROR); } return true; }
/** * Saves a blog post template * * @since 4.0 * @access public * @param string * @return */ public function save() { // Check for request forgeries EB::checkToken(); // Ensure that the user is logged in EB::requireLogin(); // We want to get the document data $document = $this->input->get('document', '', 'raw'); $title = $this->input->get('template_title', '', 'default'); // If the caller passes us an id, we are assuming that they want to update the template $templateId = $this->input->get('template_id', 0, 'int'); $postTemplate = EB::table('PostTemplate'); // Default success message $message = 'COM_EASYBLOG_BLOG_TEMPLATE_SAVED_SUCCESS'; if ($templateId) { $postTemplate->load($templateId); $message = 'COM_EASYBLOG_BLOG_TEMPLATE_UPDATE_SUCCESS'; } else { $postTemplate->title = $title; $postTemplate->user_id = $this->my->id; $postTemplate->created = EB::date()->toSql(); $postTemplate->system = $this->input->get('system', 0, 'int'); } $postTemplate->data = $document; $postTemplate->store(); // Create an exportable object $export = $postTemplate->export(); return $this->ajax->resolve(EB::exception($message, EASYBLOG_MSG_SUCCESS), $export); }