Featured post
Can't delete posts in forum. (CakePHP) -
i'm using cupcake forum plugin within cakephp. there's form selecting desired posts, , submitting form delete posts. form data apparently being sent 'moderate' function within 'topics' controller using post , methods simultaneously. function first checks see if data sent in post. however, when data received, shows it's get. fellow programmer , don't want change else's internal code, can't figure out how data being sent both methods , being received get. code plugin below:
--------------moderate.ctp (view)---------------------
<?php echo $form->create('post', array('url' => array('controller' => 'topics', 'action' => 'moderate', $topic['topic']['slug']))); ?>
-------------topics_controller.php (controller)-------
public function moderate($id) { if ($this->requesthandler->isget()){ $this->log('is get!'); } $user_id = $this->auth->user('id'); $topic = $this->topic->gettopicforviewing($id, $user_id, 'id'); // access $this->toolbar->verifyaccess(array( 'exists' => $topic, 'permission' => $topic['forumcategory']['accessread'], 'moderate' => $topic['topic']['forum_category_id'] )); $this->log('id: '.$id.'\n'); if ($this->requesthandler->ispost()){ $this->log('is post!'); } if ($this->requesthandler->isget()){ $this->log('is get!'); } $this->log($this->requesthandler->getreferer()); $this->log(serialize($this->data)); // processing if ($this->requesthandler->ispost()) { $this->log('inside post!'); if (!empty($this->data['post']['items'])) { $items = $this->data['post']['items']; $action = $this->data['post']['action']; foreach ($items $post_id) { $this->log('action: '.$action.'\n'); $this->log('postid: '.$post_id.'\n'); if (is_numeric($post_id)) { if ($action == 'delete') { $this->topic->post->destroy($post_id); $this->session->setflash(sprintf(__d('forum', 'a total of %d post(s) have been permanently deleted', true), count($items))); } } } } }
we added log checks, show result of 'is get!' in cake's log file. since method get, statement 'if ($this->requesthandler->ispost())' never true; therefore, submitted posts aren't deleted. missing?
try changing moderate.ctp
to
<?php echo $form->create('post', array( 'url' => array( 'controller' => 'topics', 'action' => 'moderate', $topic['topic']['slug'], ), 'type' => 'post', )); ?>
- Get link
- X
- Other Apps
Comments
Post a Comment