Exemple #1
0
 $action = $_GET['page'];
 if ($action == 'addTopic') {
     if (isset($_POST['title'], $_POST['content'])) {
         $manager = new SCategoryManager($db);
         $sCategory = $manager->findById($_GET['id']);
         $idSCategory = $sCategory->getId();
         if (isset($idSCategory)) {
             $managerTopic = new TopicManager($db);
             $idAuthor = $_SESSION['id'];
             try {
                 $retour = $managerTopic->create($_POST['title'], $idAuthor, $sCategory);
             } catch (Exception $e) {
                 $errors = $e->getMessage();
             }
             $managerPost = new PostManager($db);
             $lastTopic = $managerTopic->getLast();
             $lastTopicIdSCategory = $lastTopic->getIdSCategory();
             $manager = new SCategoryManager($db);
             $sCategory = $manager->findById($lastTopicIdSCategory);
             try {
                 $retour = $managerPost->create($_POST['content'], $idAuthor, $lastTopic, $sCategory);
             } catch (Exception $e) {
                 $errors = $e->getMessage();
             }
             $managerUser = new UserManager($db);
             try {
                 $retour = $managerUser->addTopicUser($lastTopic);
                 header('Location: index.php?page=XtopicX&id=' . $lastTopic->getId() . '');
                 exit;
             } catch (Exception $e) {
                 $errors = $e->getMessage();