public function getForumStatistics($pagesize = null, $page = null) { $statistic = array(); $threads = array(); $conditionalStatement = "forum_id = {$this->id} AND is_active = 1 AND status+0 < 16"; $conditionalStatement_sticky = "forum_id = {$this->id} AND is_active = 1 AND status+0 >= 16"; $orderby = " created_at"; $sort = "DESC"; $stickies = PaForumThread::listPaForumThread($conditionalStatement_sticky, $orderby, $sort); $threads = PaForumThread::listPaForumThread($conditionalStatement, $orderby, $sort); $threads = array_merge($stickies, $threads); $statistics['nb_threads'] = count($threads); $nb_posts = 0; $last_post = null; $last_post_date = 0; $statistics['last_thread'] = !empty($threads[0]) ? $threads[0] : null; foreach ($threads as &$thread) { $thread->statistics = $thread->getThreadStatistics(); $statistics['threads'][] = $thread; $nb_posts += $thread->statistics['posts']; if (is_object($thread->statistics['last_post'])) { $__obj = $thread->statistics['last_post']; $__obj->thread = $thread; $__post_date = strtotime($__obj->get_created_at()); if ($__post_date > $last_post_date) { $last_post = $__obj; $last_post_date = $__post_date; } } } if (!is_null($page)) { $this->pagination = new MemoryPagging(@$statistics['threads'], $pagesize, $page); $statistics['threads'] = $this->pagination->getPageItems(); } $statistics['nb_posts'] = $nb_posts; $statistics['last_post'] = $last_post; return $statistics; }
/** * Retrieved list of objects base on a given parameters - dynamic method: list_PaForumThread() * * * Generated with the DalClassGenerator created by: * Zoran Hron <*****@*****.**> * * @param conditionalStatement = null * @param orderby = null * @param sort = null * @param limit = 0 * @param fetchmode = DB_FETCHMODE_OBJECT * @result array of objects: PaForumThread **/ public function list_PaForumThread($conditionalStatement = null, $orderby = null, $sort = null, $limit = 0, $fetchmode = DB_FETCHMODE_OBJECT) { $this->initialize($conditionalStatement, $orderby, $sort); // build MySQL query $sql = "SELECT * FROM { pa_forum_thread } "; if ($conditionalStatement) { $sql .= "WHERE {$conditionalStatement}"; } if ($orderby) { $sql .= " ORDER BY {$orderby}"; } if ($sort) { $sql .= " {$sort}"; } if ($limit) { $sql .= " LIMIT {$limit}"; } $sql .= ";"; // execute query $res = Dal::query($sql); $objects = array(); // data found? if ($res->numRows() > 0) { // retrieve data objects while ($row = $res->fetchRow($fetchmode)) { if ($fetchmode == DB_FETCHMODE_OBJECT) { $obj = new PaForumThread(); $obj->populateFromObject($row); $objects[] = $obj; } else { $objects[] = $row; } } } return $objects; }
/** * Delete an existing record - dynamic method: delete_PaForumsUsers() * * * Generated with the DalClassGenerator created by: * Zoran Hron <*****@*****.**> * * @param user_id * @result void **/ public function delete_PaForumsUsers($user_id) { PaForumBoard::delete_UserBoards($user_id); PaForumThread::delete_ThreadsForUser($user_id); PaForumPost::delete_PostsForUser($user_id); // sql query $sql = "UPDATE { pa_forums_users } SET is_active = 0 WHERE user_id = ?;"; $params = array($user_id); // performs deletion of data $res = Dal::query($sql, $params); }
private function setThread($thread_id, $request_data, $render = true) { $posts = array(); $current_page = !empty($request_data['page']) ? $request_data['page'] : 0; $current_post = !empty($request_data['post_id']) ? $request_data['post_id'] : null; $thread_status = null; $thread = PaForumThread::getPaForumThread($thread_id); if ($thread) { $this->thread = $thread; $this->current_post = $current_post; $board = $thread->getBoard(); $this->setupBoard($board); $this->user_status = $this->checkUser($request_data); $posts_pagging = $this->board_settings['posts_per_page']; $avatar_size = $this->board->getAvatarSize(); $created_by = new User(); $created_by->load((int) $thread->get_user_id()); if ($current_post) { $posts = $thread->getPosts($posts_pagging, null, $current_post); } else { $posts = $thread->getPosts($posts_pagging, $current_page); } $this->current_page = $thread->get_current_page(); $this->thread_status = $thread->get_status(); } if ($render && $this->thread) { $viewed = $this->thread->get_viewed(); $this->thread->set_viewed($viewed + 1); $this->thread->save_PaForumThread(); $this->set_inner_template('cnmodule_content_forum_posts.php'); $this->inner_HTML = $this->generate_inner_html(array('page_id' => $this->page_id, 'thread' => $this->thread, 'created_by' => $created_by, 'posts' => $posts, 'current_post' => $this->current_post, 'current_page' => $this->current_page, 'forums_url' => $this->forums_url, 'theme_url' => $this->theme_url, 'user_status' => $this->user_status, 'thread_status' => $this->thread_status, 'message' => $this->message, 'avatar_size' => $avatar_size, 'board' => $this->board, 'board_settings' => $this->board_settings)); } }