$post_handler->updateAll("pid", $topic_handler->getTopPostId($newtopic), $criteria, true); $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>";
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; }
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; }
} else { $poll->vote($_POST['option_id'], xoops_getenv('REMOTE_ADDR')); $poll->updateCount(); setcookie("voted_polls[{$poll_id}]", 1, 0); $msg = _PL_THANKSFORVOTE; } } } else { $msg = _PL_ALREADYVOTED; } } else { $msg = _PL_MUSTLOGIN; } } else { $msg = _PL_SORRYEXPIRED; if ($poll->getVar("mail_status") != POLL_MAILED) { $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/xoopspoll/language/" . $xoopsConfig['language'] . "/mail_template/"); $xoopsMailer->setTemplate("mail_results.tpl"); $author = new XoopsUser($poll->getVar("user_id")); $xoopsMailer->setToUsers($author); $xoopsMailer->assign("POLL_QUESTION", $poll->getVar("question")); $xoopsMailer->assign("POLL_START", formatTimestamp($poll->getVar("start_time"), "l", $author->timezone())); $xoopsMailer->assign("POLL_END", formatTimestamp($poll->getVar("end_time"), "l", $author->timezone())); $xoopsMailer->assign("POLL_VOTES", $poll->getVar("votes")); $xoopsMailer->assign("POLL_VOTERS", $poll->getVar("voters")); $xoopsMailer->assign("POLL_ID", $poll->getVar("poll_id")); $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']); $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']); $xoopsMailer->assign("SITEURL", $xoopsConfig['xoops_url'] . "/");
if ( !empty($end_time) ) { $end_time = userTimeToServerTime(strtotime($end_time), $xoopsUser->timezone()); $poll->setVar("end_time", $end_time); } else { $poll->setVar("end_time", time() + (86400 * 10)); } if ( $notify == 1 && $end_time > time() ) { // if notify, set mail status to "not mailed" $poll->setVar("mail_status", POLL_NOTMAILED); } else { // if not notify, set mail status to already "mailed" $poll->setVar("mail_status", POLL_MAILED); } if ( $reset == 1 ) { // reset all logs XoopsPollLog::deleteByPollId($poll->getVar("poll_id")); XoopsPollOption::resetCountByPollId($poll->getVar("poll_id")); } if (!$poll->store()) { echo $poll->getHtmlErrors(); exit(); } $poll->updateCount(); include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_clear_module_cache($xoopsModule->getVar('mid')); redirect_header("index.php",1,_AM_DBUPDATED); exit(); } if ( $op == "log" ) { xoops_cp_header();
$orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "ASC"; $poll = new XoopsPoll($poll_id); xoops_cp_header(); echo "<h4>" . _AM_POLLCONF . "</h4>"; echo "<h4 style='text-align:left;'>" . _AM_LOGSLIST . "</h4>"; // show brief descriptions of the question we are focusing echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>"; echo "<tr><td class='bg2'>"; echo "<table width='100%' border='0' cellpadding='4' cellspacing='1'>"; echo "<tr class='bg3'>"; echo "<td nowrap>" . _AM_POLLQUESTION . "</td><td nowrap>" . _AM_POLLDESC . "</td>"; echo "<td nowrap>" . _AM_VOTERS . "</td><td nowrap>" . _AM_VOTES . "</td>"; echo "<td nowrap>" . _AM_EXPIRATION . "</td>"; echo "</tr>"; echo "<tr class='bg1'>"; echo "<td>" . $poll->getVar('question') . "</td><td>" . $poll->getVar('description') . "</td>"; echo "<td align='center'>" . $poll->getVar('voters') . "</td><td align='center'>" . $poll->getVar('votes') . "</td>"; echo "<td>" . formatTimestamp($poll->getVar('end_time'), "l") . "</td>"; echo "</tr>"; echo "</table>"; echo "</td></tr>"; echo "</table>"; echo "<br>"; // show logs $logs_arr =& XoopsPollLog::getAllByPollId($poll_id, $orderby . " " . $orderdir); $logs_count = count($logs_arr); $arrow_up = XOOPS_URL . "/modules/xoopspoll/images/up.gif"; $arrow_down = XOOPS_URL . "/modules/xoopspoll/images/down.gif"; $sorthref = "index.php?op=log&poll_id=" . $poll_id . "&orderby="; if (is_array($logs_arr) && $logs_count > 0) { echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";