예제 #1
0
 public function __construct($connection, $user, $dbPrefix)
 {
     $this->connect = $connection;
     $this->user = $user;
     $this->dbPrefix = $dbPrefix;
     foreach ($connection->query("SELECT * FROM " . $this->dbPrefix . "forum_threads;") as $row) {
         $this->nrOfThreads += 1;
         $thread = new thread();
         $thread->setId($row['forumid']);
         $thread->setText($row['text']);
         $thread->setTimestamp($row['timestamp']);
         $thread->setTitle($row['title']);
         $thread->setUserId($row['userid']);
         $thread->setTopTopic($row['toptopic']);
         $thread->setThreadState($row['threadstate']);
         $thread->setEditCounter($row['editcounter']);
         if ($row['userid'] != -1) {
             $thread->setUsername(usertools::getUsernameById($row['userid'], $connection));
         } else {
             $thread->setUsername("Public", $connection);
         }
         array_push($this->threads, $thread);
     }
     foreach ($this->threads as $thread) {
         $thread->setSubThreadCounter($this->countSubThreads($thread->getId()));
     }
 }
예제 #2
0
 public function createNewThread($title, $text, $toptopic = -1)
 {
     $this->connect->exec("INSERT INTO `learncards`.`forum_threads` (`forumid`, `userid`, `title`, `text`, `timestamp`, `toptopic`) VALUES (NULL, '" . $this->user->getId() . "', '" . $title . "', '" . $text . "', CURRENT_TIMESTAMP, '" . $toptopic . "');");
     $this->nrOfThreads += 1;
     $thread = new thread();
     $thread->setId($this->connect->lastInsertId());
     $thread->setText($text);
     $thread->setTimestamp("");
     $thread->setTitle($title);
     $thread->setUserId($this->user->getId());
     $thread->setTopTopic($toptopic);
     $thread->setUsername(usertools::getUsernameById($this->user->getId(), $this->connect));
     array_push($this->threads, $thread);
     return $this->connect->lastInsertId();
 }