Exemplo n.º 1
0
 public function restPostComment()
 {
     $postData = $this->params()->fromPost();
     $form = new Form\CommentCreateForm();
     $form->useSubFormGroup()->bind($postData);
     $callback = $this->params()->fromPost('callback');
     if ($form->isValid()) {
         $postData = $form->getData();
         $itemModel = Api::_()->getModel('Blog\\Model\\Comment');
         $postId = $itemModel->setItem($postData)->createComment();
         $this->redirect()->toUrl($callback);
     } else {
     }
     return array('form' => $form, 'post' => $postData);
 }
Exemplo n.º 2
0
 public function restPostComment()
 {
     $postData = $this->params()->fromPost();
     $form = new Form\CommentCreateForm();
     $form->useSubFormGroup()->bind($postData);
     if ($form->isValid()) {
         $postData = $form->getData();
         $itemModel = Api::_()->getModel('Blog\\Model\\Comment');
         $user = \Core\Auth::getLoginUser('Auth_Admin');
         if (!$postData['user_id']) {
             $postData['user_id'] = $user['id'];
         }
         if (!$postData['user_name']) {
             $postData['user_name'] = $user['userName'];
         }
         $itemId = $itemModel->setItem($postData)->createComment();
         $this->redirect()->toUrl('/admin/blog/comment/' . $itemId);
     } else {
     }
     return array('form' => $form, 'item' => $postData);
 }