Exemple #1
0
 function acceptPost($post_id)
 {
     $db =& JFactory::getDBO();
     // set WFM to 0 and published to 1
     $sql = "UPDATE " . $db->nameQuote('#__discussions_messages') . " SET wfm = '0'" . "," . " published = '1'" . " WHERE id = '" . $post_id . "'";
     $db->setQuery($sql);
     $db->query();
     // update the stats now
     // get user id of this post
     $sql = "SELECT user_id FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post_id . "'";
     $db->setQuery($sql);
     $_user_id = $db->loadResult();
     // get thread id of this post
     $sql = "SELECT thread FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post_id . "'";
     $db->setQuery($sql);
     $_thread_id = $db->loadResult();
     // get category id of this post
     $sql = "SELECT cat_id FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post_id . "'";
     $db->setQuery($sql);
     $_cat_id = $db->loadResult();
     // set user post counter ++
     $result = $this->increaseUserPostCounter($_user_id);
     // todo check if user is no rookie any more
     $postUser = new CofiUser($_user_id);
     // get Rookie Mode setting from com_discussions parameters
     $params = JComponentHelper::getParams('com_discussions');
     $rookie = $params->get('rookie', '0');
     if ($postUser->isRookie()) {
         // check if he is now no rookie any more
         if ($postUser->getPosts() >= $rookie) {
             $postUser->setRookie(0);
         }
     }
     // update thread stats
     $result = $this->updateThreadStats($_thread_id);
     // update category stats
     $result = $this->updateCategoryStats($_cat_id);
     return 0;
 }