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);
     }
 }
Beispiel #2
0
 /**
  * Create new post
  */
 public function newAction()
 {
     $currentUser = Zend_Auth::getInstance()->getStorage()->read();
     $form = new Form_Post();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $postData = $form->getValues();
         $postData['id'] = Post::fetchNextId();
         $postData['userId'] = $currentUser['id'];
         // save post
         $post = new Post($postData['id']);
         $post->setValue($postData);
         $userPosts = new UserPosts($currentUser['id']);
         $userPosts->add($postData['id']);
         // save post in the follower feeds
         $followers = new Followers($currentUser['id']);
         foreach ($followers as $followerId) {
             $feed = new Feed($followerId);
             $feed->prepend($postData['id']);
         }
         $this->_redirect('/post/my');
     }
     $this->view->form = $form;
 }
Beispiel #3
0
 public function updatepostAction()
 {
     global $mySession;
     $db = new Db();
     $postid = $this->getRequest()->getParam('post_id');
     $this->view->postid = $postid;
     $this->view->pageTitle = "Edit Color";
     //echo $postid; die;
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $myform = new Form_Post($postid);
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $myObj = new Post();
             $Result = $myObj->UpdateBlog($dataForm, $postid);
             if ($Result == 1) {
                 $mySession->errorMsg = "Details updated successfully.";
                 $this->_redirect('post/index');
             } else {
             }
         } else {
             $this->view->myform = $myform;
             $this->render('editpost');
         }
     } else {
         $this->_redirect('post/editpost/postid/' . $postid);
     }
 }