コード例 #1
0
 /**
  * Cria uma nova postagem utilizando os dados recebidos via Post
  * @return boolean true caso a postagem tenha sido salva ou false caso contrário
  */
 public function newPostAction()
 {
     $this->view->disable();
     $post_date_create = date("Y-m-d H:i:s");
     $post_date_posted = $this->dateFormat($this->request->getPost('post_date_posted'), 1);
     $post_date_changed = date("Y-m-d H:i:s");
     $post_author = $this->request->getPost('post_author');
     $post_editor = $this->request->getPost('post_author');
     $post_title = $this->request->getPost('post_title');
     $post_content = htmlentities($this->request->getPost('post_content'));
     //print_r($post_content); die();
     $post_status_id = $this->request->getPost('post_status_id');
     $categories = explode(", ", $this->request->getPost('list_categories'));
     $post_id = Posts::createNewPost($post_date_create, $post_date_posted, $post_date_changed, $post_author, $post_editor, $post_title, $post_content, $post_status_id);
     if ($post_id > 0) {
         $data['success'] = $this->insertPostCategories($categories, $post_id);
     }
     echo json_encode($data);
 }