示例#1
0
 /**
  *
  */
 private function startThread()
 {
     $threads = new Threads();
     $posts = new Posts();
     $category = $_POST['category'];
     if ($category === null) {
         $category = '';
     }
     if (isset($_POST['important']) && UserHelper::isAdmin()) {
         $res = $threads->insert(["title" => $_POST['title'], "board_id" => $_POST['board_id'], "userid" => $_SESSION['user']->userid, "category" => $category, "important" => $_POST['important']]);
     } else {
         $res = $threads->insert(["title" => $_POST['title'], "board_id" => $_POST['board_id'], "userid" => $_SESSION['user']->userid, "category" => $category, "important" => 0]);
     }
     $view = new View(false);
     if ($res !== false) {
         $postRes = $posts->post(["content" => $_POST['content'], "thread_id" => $res, "userid" => $_SESSION['user']->userid]);
         $view->setStatus($postRes !== false);
         $view->addData(["id" => $res]);
     }
     $view->sendResponse();
 }