Ejemplo n.º 1
0
 public function savepostAction()
 {
     if (isset($_POST['user']) && $_POST['user'] != '' && isset($_POST['postText']) && $_POST['postText'] != '' && isset($_POST['postTitle']) && $_POST['postTitle'] != '') {
         $userId = intval($_POST['user']);
         $blog = Blogs\Blog::touchByGroup(1);
         $blog->addPost($userId, $_POST['postTitle'], $_POST['postText']);
     }
     $this->view->redirect('/adm/blogs/');
 }
Ejemplo n.º 2
0
 public function addAjaxActionAuth(Param\AjaxString $title, Param\AjaxSafeHTML $text, Param\AjaxString $tags = null)
 {
     $userId = Difra\Auth::getInstance()->getEmail();
     if ($group = Blogs\Group::current()) {
         if (!$group->hasUser($userId)) {
             \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('blogs/notifies/add_post_denied'), true);
             $this->view->redirect('/');
         }
         $blog = Blogs\Blog::touchByGroup($group->getId());
     } else {
         $blog = Blogs\Blog::touchByUser($userId);
     }
     if ($post = $blog->addPost($userId, $title->val(), $text->val())) {
         $post = $blog->getPost($post->getId());
         if (class_exists('Difra\\Plugins\\Tags')) {
             $tagsArray = Difra\Plugins\Tags::getInstance()->tagsFromString($tags);
             Difra\Plugins\Tags::getInstance()->update('posts', $post->getId(), $tagsArray);
         }
         $this->ajax->redirect($post->getUrl());
     } else {
         $this->ajax->error(\Difra\Locales::getInstance()->getXPath('blogs/notifies/add_post_failed'));
     }
 }