Пример #1
0
 public function editAction()
 {
     // action body
     $request = $this->getRequest();
     $postid = (int) $request->getParam('id');
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('posts/view/id/' . $postid);
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     $acl = new Model_Acl();
     if ($acl->isAllowed($identity['Role'], 'posts', 'edit')) {
         $postForm = new Form_Post();
         $postModel = new Model_DbTable_Posts();
         if ($this->getRequest()->isPost()) {
             if ($postForm->isValid($request->getPost())) {
                 $postModel->updatePost($postForm->getValues());
                 $this->_redirect('posts/view/id/' . $postid);
             }
         } else {
             $result = $postModel->getPost($postid);
             $postForm->populate($result);
         }
         $this->view->postForm = $postForm;
     } else {
         var_dump($identity['Role']);
         //$this->_redirect('posts/view/id/'.$postid);
     }
 }