Ejemplo n.º 1
0
 public function display($tpl = null)
 {
     $this->board = new QuipForumBoardInfo();
     $session =& JFactory::getSession();
     if (!($this->boardId = JRequest::getInt('id'))) {
         $this->boardId = $session->get('quipforum_board_id', '1');
     }
     # will need to change to first available published forum. Redirect??
     $this->userAccessLevel = $this->get('UserAccessLevel');
     $this->userData = JFactory::getUser();
     if (!$this->userAccessLevel) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     if (!$this->board->data[$this->boardId]->published) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     if ($this->userData->id) {
         $this->userPanel = "Welcome back, " . $this->userData->name;
         $this->settingsOptions = " <div class='qforum-index-settings'>\n\t\t\t\t<a href='" . JRoute::_('index.php?option=com_quipforum&view=settings') . "'><s> Settings</s></a>\n\t\t\t\t</div>";
         $userSettings = comQuipForumHelper::getUserSettings();
         if ($userSettings->flags->flag_unread) {
             $this->get('BoardRead');
             $this->get('PostsRead');
             $this->postReadClearOptions = " <div class='qforum-board-clear-unread'>\n\t\t\t\t\t\t<a href='" . JRoute::_('index.php?option=com_quipforum&view=board&task=clear_unread') . "'>Clear All Unread Flags</a>\n\t\t\t\t\t\t</div>";
         }
     }
     $this->preBoardMarkup = $this->get('PreBoardMarkup');
     $this->boardThreads = $this->get('BoardThreads');
     $this->threadMarkup = $this->get('ThreadMarkup');
     $this->pageNav = comQuipForumHelper::buildPageNav();
     $session->set('quipforum_board_id', $this->boardId);
     $document =& JFactory::getDocument();
     $document->addStyleSheet("components/com_quipforum/assets/css/board.css", 'text/css', "screen");
     $this->threadMarkup = comQuipForumHelper::icons($this->threadMarkup);
     $this->threadMarkup = comQuipForumHelper::smilies($this->threadMarkup);
     if ($this->userData->authorise('core.manage', 'com_quipforum') || $this->userAccessLevel > 3) {
         $this->adminOptions = "";
         // takes a long time for some reason.
         /*if($this->adminPostTrash = $this->get('PostTrashDB'))
         		{
         		
         			$this->adminOptions .= "There are deleted posts in the trash. Empty it.";
         		}*/
         $this->jsonLog = $this->get('JsonLog');
     }
     switch ($this->userAccessLevel) {
         case 1:
             $this->postOptions = " <div class='qforum-add-post'>\n\t        \t\tCannot Add New Post\n\t        \t\t</div>";
             break;
         case 2:
         case 3:
         case 4:
             $this->postOptions = " <div class='qforum-add-post'>\n\t        \t\t<a href='" . JRoute::_('index.php?option=com_quipforum&view=add') . "'>New Post</a>\n\t        \t\t</div>";
     }
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 protected function getUserSettingsDB()
 {
     $start = "";
     $limit = "";
     $where = "#__quipforum_user_settings.user_id = '" . $this->userData->id . "'";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_user_settings.*, " . "FROM #__quipforum_user_settings ", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->userSettings = $db->loadObject();
 }
Ejemplo n.º 3
0
 protected function getBoardsDataDB()
 {
     $start = "";
     $limit = "";
     $where = "";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_boards.* " . "FROM #__quipforum_boards", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->data = $db->loadObjectList('id');
 }
Ejemplo n.º 4
0
 protected function getForumObjectListDB($order = null)
 {
     $start = "";
     $limit = "";
     $where = "published = '1' ";
     if ($order == null) {
         $order = "#__quipforum_boards.ordering";
     }
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_boards.id, " . "#__quipforum_boards.topic, " . "#__quipforum_boards.description, " . "#__quipforum_boards.tag, " . "#__quipforum_boards.thread_count " . "FROM #__quipforum_boards", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->forumObjectList = $db->loadObjectList();
 }
Ejemplo n.º 5
0
 public function display($tpl = null)
 {
     $this->postData = $this->get('PostData');
     $this->boardData = $this->get('BoardData');
     $this->userAccessLevel = $this->get('UserAccessLevel');
     if (!$this->userAccessLevel) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $this->threadMarkup = $this->get('ThreadMarkup');
     $document =& JFactory::getDocument();
     $document->addStyleSheet("components/com_quipforum/assets/css/board.css", 'text/css', "screen");
     $document->addStyleSheet("components/com_quipforum/assets/css/post.css", 'text/css', "screen");
     $this->userData = JFactory::getUser();
     if ($this->userData->id == $this->postData->user_id && $this->userData->id) {
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=edit') . "'>Edit Post</a></li>";
     }
     if ($this->postData->id == $this->postData->thread_id && $this->userAccessLevel > 2 && $this->userData->id) {
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=request_sticky') . "'>Request Sticky</a></li>";
     }
     if ($this->userData->authorise('core.manage', 'com_quipforum') || $this->userAccessLevel > 3) {
         if ($this->postData->id == $this->postData->thread_id) {
             $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=toggle_sticky') . "'>Toggle Sticky</a></li>";
             $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=toggle_announcement') . "'>Toggle Announcement</a></li>";
         }
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=edit') . "'>Edit Post (as Admin)</a></li>";
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=delete') . "'>Delete Post</a></li>";
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=clear_all') . "'>Clear All Flags</a></li>";
         $this->jsonLog = $this->get('JsonLog');
     }
     if ($this->userData->id) {
         $userSettings = comQuipForumHelper::getUserSettings();
         if ($userSettings->flags->flag_unread) {
             $this->get('PostRead');
         }
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->thread_id . '&task=watch_thread&post_return_id=' . $this->postData->id) . "'>Toggle Thread Watch Status</a></li>";
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=favourite') . "'>Toggle Favourite</a></li>";
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=off_topic') . "'>Flag as Off-Topic</a></li>";
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=report_spam') . "'>Report as Spam</a></li>";
         $this->adminOptions .= "<li><a href='" . JRoute::_('index.php?option=com_quipforum&view=post&id=' . $this->postData->id . '&task=report_offensive') . "'>Report Offensive Material</a></li>";
     }
     if ($this->userAccessLevel > 1) {
         $this->adminOptions .= " <li><a href='#reply'> Reply</a></li>";
         $this->replyAllowed = 1;
     }
     if ($this->userAccessLevel > 3 || $this->userData->authorise('core.manage', 'com_quipforum')) {
         $this->adminLog = comQuipForumHelper::getLog($this->postData->id);
     }
     parent::display($tpl);
 }
Ejemplo n.º 6
0
 protected function getPostDataDB($id = null)
 {
     if (!$id) {
         JError::raiseError('404', JText::_('Post not found'));
     }
     $start = "";
     $limit = "";
     $where = "#__quipforum_posts.id = '" . $id . "'";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_posts.* " . "FROM #__quipforum_posts ", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->postData = $db->loadObject();
     // Now for the board ID code(s) #plural after singular works..
     $start = "";
     $limit = "";
     $where = "#__quipforum_post_references.id = '" . $id . "'";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_post_references.board_id " . "FROM #__quipforum_post_references ", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->postData->board_id = $db->loadObject()->board_id;
     return $this->postData;
 }
Ejemplo n.º 7
0
 public function display($tpl = null)
 {
     $session =& JFactory::getSession();
     $this->userData =& JFactory::getUser();
     $this->boardId = $session->get('quipforum_board_id', '1');
     $this->userAccessLevel = comQuipForumHelper::getUserAccessLevel($this->boardId);
     if (!$this->userAccessLevel) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     if (JRequest::getVar("id")) {
         $this->postData = $this->get('PostData');
         if (!$this->userData->id) {
             return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         }
         if ($this->postData->user_id != $this->userData->id && !$this->userData->authorise('core.manage', 'com_quipforum') && $this->userAccessLevel < 4) {
             return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } else {
         $this->postData =& JTable::getInstance('posts', 'Table');
         $this->postData->load();
     }
     $this->boardData = $this->get('BoardData');
     parent::display($tpl);
 }
Ejemplo n.º 8
0
 public static function getLog($post_id)
 {
     $log = null;
     $start = "";
     $limit = "";
     $where = "post_id = '" . $post_id . "' ";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_post_logs.log " . "FROM #__quipforum_post_logs ", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $logs = $db->loadObjectList();
     foreach ((array) $logs as $k => $v) {
         $log .= " <li>" . $v->log . "</li>";
     }
     $log = "<h3>Post activity log</h3> <ul>" . $log . "</ul>";
     return $log;
 }
Ejemplo n.º 9
0
 protected function getBlobConversionDB()
 {
     $start = "";
     $limit = "15000";
     $where = "#__text_duplicate.checked = '0'";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__text_duplicate.body, " . "#__text_duplicate.id, " . "#__text_duplicate.checked, " . "#__text_duplicate.compressed, " . "#__text_duplicate.bodyblob " . "FROM #__text_duplicate ", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->boardData = $db->loadObjectList();
 }
Ejemplo n.º 10
0
 public function save()
 {
     $option = JRequest::getCmd('option');
     $userData = JFactory::getUser();
     $userAccessLevel = comQuipForumHelper::getUserAccessLevel(JRequest::getVar('board_id'));
     if ($userAccessLevel < 2) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     JRequest::checkToken() or jexit('Invalid Token');
     $rowPost =& JTable::getInstance('posts', 'Table');
     if (!$rowPost->bind(JRequest::get('post'))) {
         JError::raiseError(500, $rowPost->getError());
     }
     if ($userAccessLevel == 2 && !$rowPost->thread_id) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $rowPost->ip_address = $_SERVER['REMOTE_ADDR'];
     $rowPost->post_date = comQuipForumHelper::sqlDateTime();
     if (!trim(strip_tags($rowPost->body))) {
         $rowPost->no_text = 1;
     }
     if (!$rowPost->id) {
         $status = "created";
     } else {
         $status = "edited";
     }
     if (!$rowPost->store()) {
         JError::raiseError(500, $rowPost->getError());
     }
     $urls = array();
     if ($urls = comQuipForumHelper::parseUrlsFromText($rowPost->body)) {
         $noTextTester = $rowPost->body;
         foreach ((array) $urls as $key => $value) {
             $noTextTester = str_replace($value, "", $noTextTester);
             $rowLinks =& JTable::getInstance('links', 'Table');
             $rowLinks->url = $value;
             $rowLinks->post_id = $rowPost->id;
             $rowLinks->user_id = $rowPost->user_id;
             if (!$rowLinks->store()) {
                 JError::raiseError(500, $rowLinks->getError());
             }
             $rowPost->links++;
         }
         if (!trim(strip_tags($noTextTester))) {
             $rowPost->no_text = 1;
         }
         # update with # of links
         if (!$rowPost->store()) {
             JError::raiseError(500, $rowPost->getError());
         }
     }
     if (!($parent_id = JRequest::getVar('parent_id'))) {
         $rowPost->thread_id = $rowPost->id;
         $rowPostRefs =& JTable::getInstance('postreferences', 'Table');
         $rowPostRefs->load($rowPost->reference_key_id);
         $rowPostRefs->board_id = JRequest::getVar('board_id');
         $rowPostRefs->id = $rowPost->id;
         if (!$rowPostRefs->store()) {
             JError::raiseError(500, $rowPostRefs->getError());
         }
         $rowPost->reference_key_id = $rowPostRefs->key_id;
         if (!$rowPost->store()) {
             JError::raiseError(500, $rowPost->getError());
         }
     }
     $threadWeaver = new QuipForumThreadWeaver();
     $threadWeaver->weaveThread($rowPost->thread_id);
     if ($userData->id) {
         comQuipForumHelper::logIt(" <span class='qforum-log-post-" . $status . "'>Post " . $status . " by " . $userData->name . "(" . $userData->id . ") at " . $rowPost->post_date . ".</span>", $rowPost->id);
     } else {
         comQuipForumHelper::logIt(" <span class='qforum-log-post-" . $status . "'>Post " . $status . " by " . $rowPost->user_alt_name . "(guest from IP: " . $rowPost->ip_address . ") at " . $rowPost->post_date . ".</span>", $rowPost->id);
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $option . '&view=post&id=' . $rowPost->id), 'Post saved, here it is!');
 }
Ejemplo n.º 11
0
 protected function getPostLinksDB($id)
 {
     $start = "";
     $limit = "";
     $where = "#__quipforum_links.post_id = '" . $id . "'";
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_links.id, " . "#__quipforum_links.url " . "FROM #__quipforum_links", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Ejemplo n.º 12
0
 protected function getThreadDB()
 {
     $query = comQuipForumHelper::buildQuery("SELECT " . "#__quipforum_threads.thread_cache " . "FROM #__quipforum_threads " . "WHERE #__quipforum_threads.id = '" . $this->postData->thread_id . "'");
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->threadData = $db->loadObjectList();
 }
Ejemplo n.º 13
0
 protected function getPreBoardDB()
 {
     $admin_where = "";
     $userData = JFactory::getUser();
     if ($userData->authorise('core.manage', 'com_quipforum')) {
         $admin_where = "";
     } else {
         $admin_where = " AND (#__quipforum_flagged_posts.type = 'sticky' OR #__quipforum_flagged_posts.type = 'announcement') ";
     }
     $start = "";
     $limit = "";
     $where = "#__quipforum_flagged_posts.board_id = '" . JRequest::getInt('id') . "'" . $admin_where;
     $order = "";
     $query = comQuipForumHelper::buildQuery("SELECT " . "#__quipforum_flagged_posts.*, " . "#__quipforum_posts.* " . "FROM #__quipforum_flagged_posts " . "LEFT JOIN #__quipforum_posts " . "ON #__quipforum_posts.id = " . "#__quipforum_flagged_posts.post_id ", $start, $limit, $where, $order);
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $this->preBoardData = $db->loadObjectList();
 }