Ejemplo n.º 1
0
 function emptyTopic(&$post)
 {
     global $xoopsModule, $xoopsConfig;
     if (!is_object($post) || !$post->isTopic()) {
         return false;
     }
     $sql = sprintf("UPDATE %s SET post_text='[--DELETED--]', post_edit='' WHERE post_id = %u", $this->db->prefix("bb_posts_text"), $post->getVar('post_id'));
     if (!($result = $this->db->queryF($sql))) {
         newbb_message("Could not remove post text: " . $sql);
         return false;
     }
     $post->deleteAttachment();
     $sql = sprintf("UPDATE %s SET uid=0, attachment='', attachsig=0 WHERE post_id = %u", $this->db->prefix("bb_posts"), $post->getVar('post_id'));
     if (!($result = $this->db->queryF($sql))) {
         newbb_message("Could not remove post : " . $sql);
         return false;
     }
     $sql = sprintf("UPDATE %s SET topic_poster=0, topic_haspoll=0 WHERE topic_id = %u", $this->db->prefix("bb_topics"), $post->getVar('topic_id'));
     if (!($result = $this->db->queryF($sql))) {
         newbb_message("Could not update topic: " . $sql);
         return false;
     }
     if ($post->getVar('uid')) {
         $sql = sprintf("UPDATE %s SET posts=posts-1 WHERE uid = %u", $this->db->prefix("users"), $post->getVar('uid'));
         if (!($result = $this->db->queryF($sql))) {
             newbb_message("Could not update user posts: " . $sql);
         }
     }
     $topic_handler =& xoops_getmodulehandler('topic', 'newbb');
     $poll_id =& $topic_handler->get($post->getVar('topic_id'), "poll_id");
     if ($poll_id > 0) {
         if (is_dir(XOOPS_ROOT_PATH . "/modules/xoopspoll/")) {
             include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspoll.php";
             include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspolloption.php";
             include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspolllog.php";
             include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspollrenderer.php";
             $poll = new XoopsPoll($poll_id);
             if ($poll->delete() != false) {
                 XoopsPollOption::deleteByPollId($poll->getVar("poll_id"));
                 XoopsPollLog::deleteByPollId($poll->getVar("poll_id"));
                 xoops_comment_delete($xoopsModule->getVar('mid'), $poll->getVar('poll_id'));
             }
         }
     }
     $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $this->db->prefix("bb_votedata"), $post->getVar('topic_id'));
     if (!($result = $this->db->queryF($sql))) {
         newbb_message("Could not delete votedata: " . $sql);
     }
     return true;
 }
Ejemplo n.º 2
0
         $post_handler->updateAll("topic_id", $newtopic, $criteria_topic, true);
         $topic_views = $topic_obj->getVar("topic_views") + $newtopic_obj->getVar("topic_views");
         $criteria_newtopic = new Criteria("topic_id", $newtopic);
         $topic_handler->updateAll("topic_views", $topic_views, $criteria_newtopic, true);
         $topic_handler->synchronization($newtopic);
         $poll_id = $topic_handler->get($tid, "poll_id");
         if ($poll_id > 0) {
             if (is_dir(XOOPS_ROOT_PATH . "/modules/xoopspoll/")) {
                 include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspoll.php";
                 include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspolloption.php";
                 include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspolllog.php";
                 include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspollrenderer.php";
                 $poll = new XoopsPoll($poll_id);
                 if ($poll->delete() != false) {
                     XoopsPollOption::deleteByPollId($poll->getVar("poll_id"));
                     XoopsPollLog::deleteByPollId($poll->getVar("poll_id"));
                     xoops_comment_delete($xoopsModule->getVar('mid'), $poll->getVar('poll_id'));
                 }
             }
         }
         $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $tid);
         $result = $xoopsDB->queryF($sql);
         $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $xoopsDB->prefix("bb_votedata"), $tid);
         $result = $xoopsDB->queryF($sql);
         $sql = sprintf("UPDATE %s SET forum_topics = forum_topics-1 WHERE forum_id = %u", $xoopsDB->prefix("bb_forums"), $forum);
         $result = $xoopsDB->queryF($sql);
         $topic_obj->loadFilters("delete");
         $newtopic_obj->loadFilters("update");
     }
     echo $action[$mode]['msg'] . "<p><a href='viewtopic.php?topic_id={$newtopic}'>" . _MD_VIEWTHETOPIC . "</a></p>" . "<p><a href='viewforum.php?forum={$forum}'>" . _MD_RETURNTOTHEFORUM . "</a></p>" . "<p><a href='index.php'>" . _MD_RETURNFORUMINDEX . "</a></p>";
 } elseif ('move' == $mode) {
Ejemplo n.º 3
0
 function _delete(&$post, $force = false)
 {
     global $xoopsModule;
     if (!is_object($post) || $post->getVar('post_id') == 0) {
         return false;
     }
     /* Set active post as deleted */
     if ($post->getVar("approved") > 0 && empty($force)) {
         $sql = "UPDATE " . $this->db->prefix("bb_posts") . " SET approved = -1 WHERE post_id = " . $post->getVar("post_id");
         if (!($result = $this->db->queryF($sql))) {
         }
         /* delete pending post directly */
     } else {
         $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("bb_posts"), $post->getVar('post_id'));
         if (!($result = $this->db->queryF($sql))) {
             $post->setErrors("delte post error: " . $sql);
             return false;
         }
         $post->deleteAttachment();
         $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("bb_posts_text"), $post->getVar('post_id'));
         if (!($result = $this->db->queryF($sql))) {
             $post->setErrors("Could not remove post text: " . $sql);
             return false;
         }
     }
     if ($post->isTopic()) {
         $topic_handler =& xoops_getmodulehandler('topic', 'newbb');
         $topic_obj =& $topic_handler->get($post->getVar('topic_id'));
         if (is_object($topic_obj) && $topic_obj->getVar("approved") > 0 && empty($force)) {
             $topiccount_toupdate = 1;
             $topic_obj->setVar("approved", -1);
             $topic_handler->insert($topic_obj);
             xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
         } else {
             if (is_object($topic_obj)) {
                 if ($topic_obj->getVar("approved") > 0) {
                     xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
                 }
                 $poll_id = $topic_obj->getVar("poll_id");
                 if ($poll_id > 0) {
                     if (is_dir(XOOPS_ROOT_PATH . "/modules/xoopspoll/")) {
                         include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspoll.php";
                         include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspolloption.php";
                         include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspolllog.php";
                         include_once XOOPS_ROOT_PATH . "/modules/xoopspoll/class/xoopspollrenderer.php";
                         $poll = new XoopsPoll($poll_id);
                         if ($poll->delete() != false) {
                             XoopsPollOption::deleteByPollId($poll->getVar("poll_id"));
                             XoopsPollLog::deleteByPollId($poll->getVar("poll_id"));
                             xoops_comment_delete($xoopsModule->getVar('mid'), $poll->getVar('poll_id'));
                         }
                     }
                 }
             }
             $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $this->db->prefix("bb_topics"), $post->getVar('topic_id'));
             if (!($result = $this->db->queryF($sql))) {
                 //xoops_error($this->db->error());
             }
             $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $this->db->prefix("bb_votedata"), $post->getVar('topic_id'));
             if (!($result = $this->db->queryF($sql))) {
                 //xoops_error($this->db->error());
             }
         }
     } else {
         $sql = "UPDATE " . $this->db->prefix("bb_topics") . " t\r\n            \t\t\t\tLEFT JOIN " . $this->db->prefix("bb_posts") . " p ON p.topic_id = t.topic_id\r\n            \t\t\t\tSET t.topic_last_post_id = p.post_id\r\n            \t\t\t\tWHERE t.topic_last_post_id = " . $post->getVar('post_id') . "\r\n            \t\t\t\t\t\tAND p.post_id = (SELECT MAX(post_id) FROM " . $this->db->prefix("bb_posts") . " WHERE topic_id=t.topic_id)";
         if (!($result = $this->db->queryF($sql))) {
         }
     }
     $postcount_toupdate = $post->getVar("approved");
     if ($postcount_toupdate > 0) {
         // Update user stats
         if ($post->getVar('uid') > 0) {
             $member_handler =& xoops_gethandler('member');
             $poster =& $member_handler->getUser($post->getVar('uid'));
             if (is_object($poster) && $post->getVar('uid') == $poster->getVar("uid")) {
                 $poster->setVar('posts', $poster->getVar('posts') - 1);
                 $res = $member_handler->insertUser($poster, true);
                 unset($poster);
             }
         }
         $sql = "UPDATE " . $this->db->prefix("bb_posts") . " SET pid = " . $post->getVar('pid') . " WHERE pid=" . $post->getVar('post_id');
         if (!($result = $this->db->queryF($sql))) {
             //xoops_error($this->db->error());
         }
     }
     return true;
 }