/**
  * This method store a post by user.
  */
 public function storePost()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $content = $this->input->getString('content');
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $content = JString::trim(strip_tags($content));
     $content = JHtmlString::truncate($content, 140);
     if (!$userId) {
         $app->close();
     }
     $userTimeZone = !$user->getParam('timezone') ? null : $user->getParam('timezone');
     try {
         $date = new JDate('now', $userTimeZone);
         $entity = new Socialcommunity\Wall\User\Post(JFactory::getDbo());
         $entity->setUserId($userId);
         $entity->setContent($content);
         $entity->setCreated($date->toSql(true));
         $entity->store();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     $params = JComponentHelper::getParams('com_socialcommunity');
     $filesystemHelper = new Prism\Filesystem\Helper($params);
     $mediaFolder = $filesystemHelper->getMediaFolderUri($userId);
     $profile = new Socialcommunity\Profile\Profile(JFactory::getDbo());
     $profile->load(['user_id' => $userId]);
     $displayData = new stdClass();
     $displayData->id = $entity->getId();
     $displayData->profileLink = JRoute::_(SocialCommunityHelperRoute::getProfileRoute($profile->getSlug()), false);
     $displayData->name = htmlentities($profile->getName(), ENT_QUOTES, 'utf-8');
     $displayData->alias = htmlentities($profile->getAlias(), ENT_QUOTES, 'utf-8');
     $displayData->imageSquare = $mediaFolder . '/' . $profile->getImageSquare();
     $displayData->imageAlt = $displayData->name;
     $displayData->content = $entity->getContent();
     $displayData->created = JHtml::_('socialcommunity.created', $entity->getCreated(), $userTimeZone);
     $layout = new JLayoutFile('wall_post');
     echo $layout->render($displayData);
     $app->close();
 }