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!'); }
public function getPostRead() { $this->getBoardRead(); if (strtotime($this->boardRead) > strtotime($this->postData->post_date)) { return; } $userData = JFactory::getUser(); $start = ""; $limit = ""; $where = "#__quipforum_posts_read.user_id = '" . $userData->id . "'" . " AND #__quipforum_posts_read.post_id = '" . JRequest::getInt('id') . "' "; $order = ""; $query = comQuipForumHelper::buildQuery("SELECT #__quipforum_posts_read.id " . "FROM #__quipforum_posts_read ", $start, $limit, $where, $order); $db =& JFactory::getDBO(); $db->setQuery($query); if (!@$db->loadObjectList()) { $start = ""; $limit = ""; $where = ""; $order = ""; $query = comQuipForumHelper::buildQuery("INSERT INTO #__quipforum_posts_read " . "(post_id, user_id, datetime) " . "VALUES ('" . JRequest::getInt('id') . "', '" . $userData->id . "', '" . comQuipForumHelper::sqlDateTime() . "') ", $start, $limit, $where, $order); $db =& JFactory::getDBO(); $db->setQuery($query); $result = @$db->loadObjectList(); // hmm need to figure out the warnings here } }