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); } }
public function indexAction() { // action body /* * Get new posts and paginate */ $posts = new Model_DbTable_Posts(); $result = $posts->getPosts(); $page = $this->_getParam('page', 1); $paginator = Zend_Paginator::factory($result); $paginator->setItemCountPerPage(2); $paginator->setCurrentPageNumber($page); $this->view->paginator = $paginator; }
public function indexAction() { $table = new Model_DbTable_Posts(); $this->view->row = $table->fetchRow(); }