예제 #1
0
 public function getSCategory()
 {
     if (!$this->category) {
         $sCategoryManager = new SCategoryManager($this->db);
         $this->sCategory = $sCategoryManager->findById($this->id_scategory);
     }
     return $this->sCategory;
 }
예제 #2
0
                 exit;
             } catch (Exception $e) {
                 $errors = $e->getMessage();
             }
         } else {
             throw new Exception("Categorie inéxistance");
         }
     }
 } else {
     if ($action == 'updateSCategory') {
         if (isset($_POST['title'], $_POST['content'])) {
             $manager = new CategoryManager($db);
             $category = $manager->findById($_GET['id']);
             $idCategory = $category['id'];
             if (isset($idCategory)) {
                 $manager = new SCategoryManager($db);
                 $sCategory = $manager->findById($_GET['id']);
                 if ($category->getIdAuthor() == $currentUser->getId()) {
                     $id = intval($_GET['id']);
                     $sCategory->setTitle($_POST['title']);
                     $sCategory->setContent($_POST['content']);
                     $retour->{$manager}->update($sCategory);
                 } else {
                     $user = $retour;
                     header('Location : index.php?page=home');
                     exit;
                 }
             }
         }
     }
 }
예제 #3
0
<?php

$sCategoryManager = new SCategoryManager($db);
$sCategorys = $sCategoryManager->getList($category->getId());
$topicManager = new TopicManager($db);
$postManager = new PostManager($db);
$a = 0;
$b = count($sCategorys);
while ($a < $b) {
    $sCategory = $sCategorys[$a];
    $topic = $topicManager->getList($sCategory->getId());
    $nTopic = count($topic);
    $post = $postManager->getListSCat($sCategory->getId());
    $nPost = count($post);
    if ($nPost !== 0) {
        $lastPost = $postManager->getLastBySCat($sCategory->getId());
        $userLastPost = $userManager->findById($lastPost->getIdAuthor());
    }
    require 'views/forum/sCategorys.phtml';
    $a++;
}