public static function getElementFromCode($string)
 {
     if (strstr($string, "c")) {
         return Category::getByID(intval(str_replace("c", "", $string)));
     } else {
         if (strstr($string, "b")) {
             return Board::getByID(intval(str_replace("b", "", $string)));
         } else {
             if (strstr($string, "t")) {
                 return Thread::getByID(intval(str_replace("t", "", $string)));
             } else {
                 if (strstr($string, "p")) {
                     return Post::getByID(intval(str_replace("p", "", $string)));
                 }
             }
         }
     }
     return null;
 }
Beispiel #2
0
                         $thread = $board->createThread($currentUser, clean($_POST["title"], true), clean($_POST["editableContent"]), time(), $con);
                         $successes[] = "Created forum thread!";
                     } else {
                         if ($_POST["board_name"] || $_POST["editableContent"]) {
                             $board->createBoard($currentUser, clean($_POST["board_name"]), clean($_POST["editableContent"]))->save($con);
                         }
                     }
                 }
             }
         }
         $printContent .= $board->printNewThreadForm();
         $printContent .= $board->printBoardContent($currentUser, $con);
     }
 } else {
     if (strstr($_GET["p"], "t")) {
         $thread = Thread::getByID(intval(str_replace("t", "", $_GET["p"])));
         if ($thread != null) {
             if ($_GET["a"] == "new" && $_POST["editableContent"]) {
                 if ($currentUser != null) {
                     if ($currentUser->id > 0) {
                         $post = $thread->createPost(clean($_POST["editableContent"]), $currentUser, time(), $con);
                     }
                 }
             }
             $printContent .= $thread->printThreadContent($currentUser, $con, intval($_GET["page"]));
             $thread->view($currentUser, $con);
         }
     } else {
         if (strstr($_GET["p"], "c")) {
             $category = Category::getByID(intval(str_replace("c", "", $_GET["p"])));
             if ($category != null) {
Beispiel #3
0
 function __construct($user, $elementID, $data, $con)
 {
     parent::__construct($user, Thread::getByID(intval($elementID)), $data, $con);
 }
Beispiel #4
0
 /**
  * Prints out the board as a forum block.
  * @param ForumUser $user - The current user.
  * @return string To be printed.
  */
 public function printBoard($user)
 {
     global $posts_per_page, $permission;
     /**
      * Display the stats.
      */
     $stats = count($this->getPosts()) . " post(s) " . $this->getViews() . " view(s)";
     $printLatestPost = "No posts.";
     $latestPost = $this->getLatestPost();
     if ($latestPost != null) {
         $latestPostUser = getUserByID($latestPost->fields["User"]);
         $thread = Thread::getByID($latestPost->fields["Parent"]);
         if ($latestPostUser != null && $thread != null) {
             $printLatestPost = "Lastest: <a href='{$_SERVER['PHP_SELF']}?p=t" . $thread->getID() . "&page=" . ceil(count($thread->getPosts()) / $posts_per_page) . "#" . $latestPost->getID() . "'>" . limitString($latestPost->name) . "</a><br /> By: <b>" . limitString($latestPostUser->username, 20) . "</b>, " . $latestPost->getDate() . ".";
         }
     }
     $subBoards = "";
     foreach ($this->getChildren() as $child) {
         if ($child instanceof Board) {
             $subBoards .= "<li><a href='{$_SERVER['PHP_SELF']}?p=b{$child->getID()}'>{$child->name}</a></li>";
         }
     }
     if (!empty($subBoards)) {
         $subBoards = "<ul>Sub-Boards: " . $subBoards . "</ul>";
     }
     if ($user->hasPermission($permission['board_edit'], $this->getParent())) {
         $orderHTML = "<a href=\"{$_SERVER['PHP_SELF']}?&o=b{$this->getID()}\" class='btn_small btn_silver btn_flat'>&darr;</a>";
     }
     return "\r\n\t    \t<div class='board_box forum_element'>\r\n\t    \t\t<div class='two_third'>\r\n\t    \t\t\t<span class='" . ($this->isUnread($user) ? "icon_on" : "icon_off") . "'></span>\r\n\t    \t\t\t<div class='board_content'>\r\n\t    \t\t\t\t<h3 class='element_title'><a href='{$_SERVER['PHP_SELF']}?p=b{$this->getID()}'>{$this->name}</a> {$orderHTML}</h3>\r\n\t    \t\t\t\t<div class='element_text'>\r\n\t    \t\t\t\t\t<span>{$this->fields["Description"]}</span>\r\n\t    \t\t\t\t\t<div class='forum_element_info'>{$stats}</div>\r\n\t    \t\t\t\t</div>\r\n\t    \t\t\t</div>\r\n\t    \t\t</div>\r\n\t    \t\t<div class='board_info forum_element_info one_third column-last'>\r\n\t    \t\t\t<p>{$printLatestPost}</p>\r\n\t    \t\t\t<div class='sub_boards'>\r\n\t    \t\t\t\t{$subBoards}\r\n\t    \t\t\t\t<div class='clear'></div>\r\n\t    \t\t\t</div>\r\n\t    \t\t</div>\r\n                <div class='clear'></div>\r\n\t    \t</div>\r\n\t\t\t<div class='hrline_silver'></div>";
 }
Beispiel #5
0
 public function getParent()
 {
     return Thread::getByID($this->fields["Parent"]);
 }