Exemplo n.º 1
0
 public function executeSettag(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     $post = Doctrine::getTable('Post')->find(array($request->getParameter('id')));
     $this->forward404Unless($post, $this->getUser()->getGuardUser());
     $tags = split("[,;:]", str_replace("*", "", str_replace("#", "", trim($request->getParameter('tag')))));
     if ($post->getUser() == $this->getUser()->getGuardUser() || $this->getUser()->getGuardUser()->getIsSuperAdmin()) {
         $post->deleteBlogs();
     }
     foreach ($tags as $tag) {
         $tag = trim($tag);
         $blog = Blog::getOrCreateByTag($tag, $this->getUser()->getGuardUser());
         if ($blog) {
             $bp = new BlogPost();
             $bp->setBlogId($blog->getId());
             $bp->setPostId($post->getId());
             $bp->save();
         }
     }
     return $this->renderPartial('post/post', array('post' => $post));
 }