public function addComment() { if ($this->request->is('post')) { $this->autoRender = false; $data = array('post_id' => $this->request->data['post_id'], 'user_id' => $this->Session->read('Auth.User.id'), 'content' => $this->request->data['content'], 'created' => myTools::dateTimeNow(), 'created_ip' => $this->request->clientIp(), 'modified' => myTools::dateTimeNow(), 'modified_ip' => $this->request->clientIp()); if (!empty($_FILES['file'])) { $file = $_FILES['file']; } $this->PostsComment->set($data); if ($this->PostsComment->save()) { if (isset($file)) { $this->addCommentFile($this->PostsComment->id, $file); } $response['success'] = true; } else { $response['success'] = false; } echo json_encode($response); } else { $this->redirect(FULL_BASE_PATH); } }