本文整理汇总了PHP中moveTopics函数的典型用法代码示例。如果您正苦于以下问题:PHP moveTopics函数的具体用法?PHP moveTopics怎么用?PHP moveTopics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了moveTopics函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MoveTopic2
//.........这里部分代码省略.........
}
list($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Remember this for later.
$_SESSION['move_to_topic'] = $_POST['toboard'];
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
// Keep checking the length.
if ($smcFunc['strlen']($_POST['custom_subject']) > 100) {
$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
}
// If it's still valid move onwards and upwards.
if ($_POST['custom_subject'] != '') {
if (isset($_POST['enforce_subject'])) {
// Get a response prefix, but in the forum's default language.
if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) {
if ($language === $user_info['language']) {
$context['response_prefix'] = $txt['response_prefix'];
} else {
loadLanguage('index', $language, false);
$context['response_prefix'] = $txt['response_prefix'];
loadLanguage('index');
}
cache_put_data('response_prefix', $context['response_prefix'], 600);
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET subject = {string:subject}
WHERE id_topic = {int:current_topic}', array('current_topic' => $topic, 'subject' => $context['response_prefix'] . $_POST['custom_subject']));
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET subject = {string:custom_subject}
WHERE id_msg = {int:id_first_msg}', array('id_first_msg' => $id_first_msg, 'custom_subject' => $_POST['custom_subject']));
// Fix the subject cache.
updateStats('subject', $topic, $_POST['custom_subject']);
}
}
// Create a link to this in the old board.
//!!! Does this make sense if the topic was unapproved before? I'd just about say so.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
preparsecode($_POST['reason']);
// Add a URL onto the message.
$_POST['reason'] = strtr($_POST['reason'], array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $_POST['toboard'] . '.0]' . $board_name . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
$msgOptions = array('subject' => $txt['moved'] . ': ' . $subject, 'body' => $_POST['reason'], 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true);
$posterOptions = array('id' => $user_info['id'], 'update_post_count' => empty($pcounter));
createPost($msgOptions, $topicOptions, $posterOptions);
}
$request = $smcFunc['db_query']('', '
SELECT count_posts
FROM {db_prefix}boards
WHERE id_board = {int:current_board}
LIMIT 1', array('current_board' => $board));
list($pcounter_from) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if ($pcounter_from != $pcounter) {
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}messages
WHERE id_topic = {int:current_topic}
AND approved = {int:is_approved}', array('current_topic' => $topic, 'is_approved' => 1));
$posters = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (!isset($posters[$row['id_member']])) {
$posters[$row['id_member']] = 0;
}
$posters[$row['id_member']]++;
}
$smcFunc['db_free_result']($request);
foreach ($posters as $id_member => $posts) {
// The board we're moving from counted posts, but not to.
if (empty($pcounter_from)) {
updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
} else {
updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
}
}
}
// Do the move (includes statistics update needed for the redirect topic).
moveTopics($topic, $_POST['toboard']);
// Log that they moved this topic.
if (!allowedTo('move_own') || $id_member_started != $user_info['id']) {
logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
}
// Notify people that this topic has been moved?
sendNotifications($topic, 'move');
// Why not go back to the original board in case they want to keep moving?
if (!isset($_REQUEST['goback'])) {
redirectexit('board=' . $board . '.0');
} else {
redirectexit('topic=' . $topic . '.0');
}
}
示例2: COM_applyFilter
if (isset($_POST['hidden'])) {
$hidden = COM_applyFilter($_POST['hidden'], true);
}
$parent_id = '';
if (isset($_POST['parent_id'])) {
$parent_id = COM_applyFilter($_POST['parent_id']);
}
$sortnum = 0;
if (isset($_POST['sortnum'])) {
$sortnum = COM_applyFilter($_POST['sortnum'], true);
}
$display .= savetopic(COM_applyFilter($_POST['tid']), $_POST['topic_name'], $inherit, $hidden, $parent_id, $imageurl, $_POST['meta_description'], $_POST['meta_keywords'], $sortnum, COM_applyFilter($_POST['limitnews'], true), COM_applyFilter($_POST['owner_id'], true), COM_applyFilter($_POST['group_id'], true), $_POST['perm_owner'], $_POST['perm_group'], $_POST['perm_members'], $_POST['perm_anon'], $is_default, $is_archive);
} elseif ($mode == 'edit') {
$tid = '';
if (isset($_GET['tid'])) {
$tid = COM_applyFilter($_GET['tid']);
}
$display .= edittopic($tid);
$display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[1]));
} elseif ($mode == 'change_sortnum' && SEC_checkToken()) {
$display .= COM_showMessageFromParameter();
moveTopics(COM_applyFilter($_GET['tid']), COM_applyFilter($_GET['where']));
$display .= listTopics(SEC_createToken());
$display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[8]));
} else {
// 'cancel' or no mode at all
$display .= COM_showMessageFromParameter();
$display .= listTopics(SEC_createToken());
$display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[8]));
}
COM_output($display);
示例3: QuickModeration
//.........这里部分代码省略.........
}
// Move sucka! (this is, by the by, probably the most complicated part....)
if (!empty($moveCache[0])) {
// I know - I just KNOW you're trying to beat the system. Too bad for you... we CHECK :P.
$request = $smcFunc['db_query']('', '
SELECT t.id_topic, t.id_board, b.count_posts
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
WHERE t.id_topic IN ({array_int:move_topic_ids})' . (!empty($board) && !allowedTo('move_any') ? '
AND t.id_member_started = {int:current_member}' : '') . '
LIMIT ' . count($moveCache[0]), array('current_member' => $user_info['id'], 'move_topic_ids' => $moveCache[0]));
$moveTos = array();
$moveCache2 = array();
$countPosts = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$to = $moveCache[1][$row['id_topic']];
if (empty($to)) {
continue;
}
// Does this topic's board count the posts or not?
$countPosts[$row['id_topic']] = empty($row['count_posts']);
if (!isset($moveTos[$to])) {
$moveTos[$to] = array();
}
$moveTos[$to][] = $row['id_topic'];
// For reporting...
$moveCache2[] = array($row['id_topic'], $row['id_board'], $to);
}
$smcFunc['db_free_result']($request);
$moveCache = $moveCache2;
require_once $sourcedir . '/MoveTopic.php';
// Do the actual moves...
foreach ($moveTos as $to => $topics) {
moveTopics($topics, $to);
}
// Does the post counts need to be updated?
if (!empty($moveTos)) {
$topicRecounts = array();
$request = $smcFunc['db_query']('', '
SELECT id_board, count_posts
FROM {db_prefix}boards
WHERE id_board IN ({array_int:move_boards})', array('move_boards' => array_keys($moveTos)));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$cp = empty($row['count_posts']);
// Go through all the topics that are being moved to this board.
foreach ($moveTos[$row['id_board']] as $topic) {
// If both boards have the same value for post counting then no adjustment needs to be made.
if ($countPosts[$topic] != $cp) {
// If the board being moved to does count the posts then the other one doesn't so add to their post count.
$topicRecounts[$topic] = $cp ? '+' : '-';
}
}
}
$smcFunc['db_free_result']($request);
if (!empty($topicRecounts)) {
$members = array();
// Get all the members who have posted in the moved topics.
$request = $smcFunc['db_query']('', '
SELECT id_member, id_topic
FROM {db_prefix}messages
WHERE id_topic IN ({array_int:moved_topic_ids})', array('moved_topic_ids' => array_keys($topicRecounts)));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (!isset($members[$row['id_member']])) {
$members[$row['id_member']] = 0;
}
if ($topicRecounts[$row['id_topic']] === '+') {
示例4: MaintainMassMoveTopics
function MaintainMassMoveTopics()
{
global $smcFunc, $sourcedir, $context, $txt;
// Only admins.
isAllowedTo('admin_forum');
checkSession('request');
// Set up to the context.
$context['page_title'] = $txt['not_done_title'];
$context['continue_countdown'] = '3';
$context['continue_post_data'] = '';
$context['continue_get_data'] = '';
$context['sub_template'] = 'not_done';
$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
$context['start_time'] = time();
// First time we do this?
$id_board_from = isset($_POST['id_board_from']) ? (int) $_POST['id_board_from'] : (int) $_REQUEST['id_board_from'];
$id_board_to = isset($_POST['id_board_to']) ? (int) $_POST['id_board_to'] : (int) $_REQUEST['id_board_to'];
// No boards then this is your stop.
if (empty($id_board_from) || empty($id_board_to)) {
return;
}
// How many topics are we converting?
if (!isset($_REQUEST['totaltopics'])) {
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}topics
WHERE id_board = {int:id_board_from}', array('id_board_from' => $id_board_from));
list($total_topics) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
} else {
$total_topics = (int) $_REQUEST['totaltopics'];
}
// Seems like we need this here.
$context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
// We have topics to move so start the process.
if (!empty($total_topics)) {
while ($context['start'] <= $total_topics) {
// Lets get the topics.
$request = $smcFunc['db_query']('', '
SELECT id_topic
FROM {db_prefix}topics
WHERE id_board = {int:id_board_from}
LIMIT 10', array('id_board_from' => $id_board_from));
// Get the ids.
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$topics[] = $row['id_topic'];
}
// Just return if we don't have any topics left to move.
if (empty($topics)) {
cache_put_data('board-' . $id_board_from, null, 120);
cache_put_data('board-' . $id_board_to, null, 120);
redirectexit('action=admin;area=maintain;sa=topics;done=massmove');
}
// Lets move them.
require_once $sourcedir . '/MoveTopic.php';
moveTopics($topics, $id_board_to);
// We've done at least ten more topics.
$context['start'] += 10;
// Lets wait a while.
if (time() - $context['start_time'] > 3) {
// What's the percent?
$context['continue_percent'] = round(100 * ($context['start'] / $total_topics), 1);
$context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
// Let the template system do it's thang.
return;
}
}
}
// Don't confuse admins by having an out of date cache.
cache_put_data('board-' . $id_board_from, null, 120);
cache_put_data('board-' . $id_board_to, null, 120);
redirectexit('action=admin;area=maintain;sa=topics;done=massmove');
}
示例5: splitAttemptMove
/**
* If we are also moving the topic somewhere else, let's try do to it
* Includes checks for permissions move_own/any, etc.
*
* @param mixed[] $boards an array containing basic info of the origin and destination boards (from splitDestinationBoard)
* @param int $totopic id of the destination topic
*/
function splitAttemptMove($boards, $totopic)
{
global $board, $user_info;
$db = database();
// If the starting and final boards are different we have to check some permissions and stuff
if ($boards['destination']['id'] != $board) {
$doMove = false;
if (allowedTo('move_any')) {
$doMove = true;
} else {
$new_topic = getTopicInfo($totopic);
if ($new_topic['id_member_started'] == $user_info['id'] && allowedTo('move_own')) {
$doMove = true;
}
}
if ($doMove) {
// Update member statistics if needed
// @todo this should probably go into a function...
if ($boards['destination']['count_posts'] != $boards['current']['count_posts']) {
$request = $db->query('', '
SELECT id_member
FROM {db_prefix}messages
WHERE id_topic = {int:current_topic}
AND approved = {int:is_approved}', array('current_topic' => $totopic, 'is_approved' => 1));
$posters = array();
while ($row = $db->fetch_assoc($request)) {
if (!isset($posters[$row['id_member']])) {
$posters[$row['id_member']] = 0;
}
$posters[$row['id_member']]++;
}
$db->free_result($request);
foreach ($posters as $id_member => $posts) {
// The board we're moving from counted posts, but not to.
if (empty($boards['current']['count_posts'])) {
updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
} else {
updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
}
}
}
// And finally move it!
moveTopics($totopic, $boards['destination']['id']);
} else {
$boards['destination'] = $boards['current'];
}
}
}
示例6: RestoreTopic
//.........这里部分代码省略.........
// Load any previous topics to check they exist.
if (!empty($previous_topics)) {
$request = $smcFunc['db_query']('', '
SELECT t.id_topic, t.id_board, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_topic IN ({array_int:previous_topics})', array('previous_topics' => $previous_topics));
$previous_topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$previous_topics[$row['id_topic']] = array('board' => $row['id_board'], 'subject' => $row['subject']);
}
$smcFunc['db_free_result']($request);
}
// Restore each topic.
$messages = array();
foreach ($actioned_messages as $topic => $data) {
// If we have topics we are going to restore the whole lot ignore them.
if (in_array($topic, $topics_to_restore)) {
unset($actioned_messages[$topic]);
continue;
}
// Move the posts back then!
if (isset($previous_topics[$topic])) {
mergePosts(array_keys($data['msgs']), $data['current_topic'], $topic);
// Log em.
logAction('restore_posts', array('topic' => $topic, 'subject' => $previous_topics[$topic]['subject'], 'board' => empty($data['previous_board']) ? $data['possible_prev_board'] : $data['previous_board']));
$messages = array_merge(array_keys($data['msgs']), $messages);
} else {
foreach ($data['msgs'] as $msg) {
$unfound_messages[$msg['id']] = $msg['subject'];
}
}
}
// Put the icons back.
if (!empty($messages)) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET icon = {string:icon}
WHERE id_msg IN ({array_int:messages})', array('icon' => 'xx', 'messages' => $messages));
}
}
// Now any topics?
if (!empty($_REQUEST['topics'])) {
$topics = explode(',', $_REQUEST['topics']);
foreach ($topics as $key => $id) {
$topics_to_restore[] = (int) $id;
}
}
if (!empty($topics_to_restore)) {
// Lets get the data for these topics.
$request = $smcFunc['db_query']('', '
SELECT t.id_topic, t.id_previous_board, t.id_board, t.id_first_msg, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_topic IN ({array_int:topics})', array('topics' => $topics_to_restore));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
// We can only restore if the previous board is set.
if (empty($row['id_previous_board'])) {
$unfound_messages[$row['id_first_msg']] = $row['subject'];
continue;
}
// Ok we got here so me move them from here to there.
moveTopics($row['id_topic'], $row['id_previous_board']);
// Lets remove the recycled icon.
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET icon = {string:icon}
WHERE id_topic = {int:id_topic}', array('icon' => 'xx', 'id_topic' => $row['id_topic']));
// Lets see if the board that we are returning to has post count enabled.
$request2 = $smcFunc['db_query']('', '
SELECT count_posts
FROM {db_prefix}boards
WHERE id_board = {int:board}', array('board' => $row['id_previous_board']));
list($count_posts) = $smcFunc['db_fetch_row']($request2);
$smcFunc['db_free_result']($request2);
if (empty($count_posts)) {
// Lets get the members that need their post count restored.
$request2 = $smcFunc['db_query']('', '
SELECT id_member, COUNT(id_msg) AS post_count
FROM {db_prefix}messages
WHERE id_topic = {int:topic}
AND approved = {int:is_approved}
GROUP BY id_member', array('topic' => $row['id_topic'], 'is_approved' => 1));
while ($member = $smcFunc['db_fetch_assoc']($request2)) {
updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count']));
}
$smcFunc['db_free_result']($request2);
}
// Log it.
logAction('restore_topic', array('topic' => $row['id_topic'], 'board' => $row['id_board'], 'board_to' => $row['id_previous_board']));
}
$smcFunc['db_free_result']($request);
}
// Didn't find some things?
if (!empty($unfound_messages)) {
fatal_lang_error('restore_not_found', false, array(implode('<br />', $unfound_messages)));
}
// Just send them to the index if they get here.
redirectexit();
}
示例7: removeTopics
function removeTopics($topics, $decreasePostCount = true, $ignoreRecycling = false)
{
global $db_prefix, $sourcedir, $modSettings;
// Nothing to do?
if (empty($topics)) {
return;
} elseif (is_numeric($topics)) {
$condition = '= ' . $topics;
$topics = array($topics);
} elseif (count($topics) == 1) {
$condition = '= ' . $topics[0];
} else {
$condition = 'IN (' . implode(', ', $topics) . ')';
}
// Decrease the post counts.
if ($decreasePostCount) {
$requestMembers = db_query("\n\t\t\tSELECT m.ID_MEMBER, COUNT(*) AS posts\n\t\t\tFROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)\n\t\t\tWHERE m.ID_TOPIC {$condition}\n\t\t\t\tAND b.ID_BOARD = m.ID_BOARD\n\t\t\t\tAND m.icon != 'recycled'\n\t\t\t\tAND b.countPosts = 0\n\t\t\tGROUP BY m.ID_MEMBER", __FILE__, __LINE__);
if (mysql_num_rows($requestMembers) > 0) {
while ($rowMembers = mysql_fetch_assoc($requestMembers)) {
updateMemberData($rowMembers['ID_MEMBER'], array('posts' => 'posts - ' . $rowMembers['posts']));
}
}
mysql_free_result($requestMembers);
}
// Recycle topics that aren't in the recycle board...
if (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 && !$ignoreRecycling) {
$request = db_query("\n\t\t\tSELECT ID_TOPIC\n\t\t\tFROM {$db_prefix}topics\n\t\t\tWHERE ID_TOPIC {$condition}\n\t\t\t\tAND ID_BOARD != {$modSettings['recycle_board']}\n\t\t\tLIMIT " . count($topics), __FILE__, __LINE__);
if (mysql_num_rows($request) > 0) {
// Get topics that will be recycled.
$recycleTopics = array();
while ($row = mysql_fetch_assoc($request)) {
$recycleTopics[] = $row['ID_TOPIC'];
}
mysql_free_result($request);
// Mark recycled topics as recycled.
db_query("\n\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\tSET icon = 'recycled'\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $recycleTopics) . ")", __FILE__, __LINE__);
// De-sticky and unlock topics.
db_query("\n\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\tSET \n\t\t\t\t\tlocked = 0,\n\t\t\t\t\tisSticky = 0\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $recycleTopics) . ")", __FILE__, __LINE__);
// Move the topics to the recycle board.
require_once $sourcedir . '/MoveTopic.php';
moveTopics($recycleTopics, $modSettings['recycle_board']);
// Topics that were recycled don't need to be deleted, so subtract them.
$topics = array_diff($topics, $recycleTopics);
// Topic list has changed, so does the condition to select topics.
$condition = 'IN (' . implode(', ', $topics) . ')';
} else {
mysql_free_result($request);
}
}
// Still topics left to delete?
if (empty($topics)) {
return;
}
$adjustBoards = array();
// Find out how many posts we are deleting.
$request = db_query("\n\t\tSELECT ID_BOARD, COUNT(*) AS numTopics, SUM(numReplies) AS numReplies\n\t\tFROM {$db_prefix}topics\n\t\tWHERE ID_TOPIC {$condition}\n\t\tGROUP BY ID_BOARD", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request)) {
// The numReplies is only the *replies*. There're also the first posts in the topics.
$adjustBoards[] = array('numPosts' => $row['numReplies'] + $row['numTopics'], 'numTopics' => $row['numTopics'], 'ID_BOARD' => $row['ID_BOARD']);
}
mysql_free_result($request);
// Decrease the posts/topics...
foreach ($adjustBoards as $stats) {
db_query("\n\t\t\tUPDATE {$db_prefix}boards\n\t\t\tSET \n\t\t\t\tnumTopics = IF({$stats['numTopics']} > numTopics, 0, numTopics - {$stats['numTopics']}),\n\t\t\t\tnumPosts = IF ({$stats['numPosts']} > numPosts, 0, numPosts - {$stats['numPosts']})\n\t\t\tWHERE ID_BOARD = {$stats['ID_BOARD']}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
}
// Remove Polls.
$request = db_query("\n\t\tSELECT ID_POLL\n\t\tFROM {$db_prefix}topics\n\t\tWHERE ID_TOPIC {$condition}\n\t\t\tAND ID_POLL > 0\n\t\tLIMIT " . count($topics), __FILE__, __LINE__);
$polls = array();
while ($row = mysql_fetch_assoc($request)) {
$polls[] = $row['ID_POLL'];
}
mysql_free_result($request);
if (!empty($polls)) {
$pollCondition = count($polls) == 1 ? '= ' . $polls[0] : 'IN (' . implode(', ', $polls) . ')';
db_query("\n\t\t\tDELETE FROM {$db_prefix}polls\n\t\t\tWHERE ID_POLL {$pollCondition}\n\t\t\tLIMIT " . count($polls), __FILE__, __LINE__);
db_query("\n\t\t\tDELETE FROM {$db_prefix}poll_choices\n\t\t\tWHERE ID_POLL {$pollCondition}", __FILE__, __LINE__);
db_query("\n\t\t\tDELETE FROM {$db_prefix}log_polls\n\t\t\tWHERE ID_POLL {$pollCondition}", __FILE__, __LINE__);
}
// Get rid of the attachment, if it exists.
require_once $sourcedir . '/ManageAttachments.php';
removeAttachments('a.attachmentType = 0 AND m.ID_TOPIC ' . $condition, 'messages');
// Delete possible search index entries.
if (!empty($modSettings['search_custom_index_config'])) {
$customIndexSettings = unserialize($modSettings['search_custom_index_config']);
$words = array();
$messages = array();
$request = db_query("\n\t\t\tSELECT ID_MSG, body\n\t\t\tFROM {$db_prefix}messages\n\t\t\tWHERE ID_TOPIC {$condition}", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request)) {
$words = array_merge($words, text2words($row['body'], $customIndexSettings['bytes_per_word'], true));
$messages[] = $row['ID_MSG'];
}
mysql_free_result($request);
$words = array_unique($words);
if (!empty($words) && !empty($messages)) {
db_query("\n\t\t\t\tDELETE FROM {$db_prefix}log_search_words\n\t\t\t\tWHERE ID_WORD IN (" . implode(', ', $words) . ")\n\t\t\t\t\tAND ID_MSG IN (" . implode(', ', $messages) . ')', __FILE__, __LINE__);
}
}
// Delete anything related to the topic.
db_query("\n\t\tDELETE FROM {$db_prefix}messages\n\t\tWHERE ID_TOPIC {$condition}", __FILE__, __LINE__);
db_query("\n\t\tDELETE FROM {$db_prefix}calendar\n\t\tWHERE ID_TOPIC {$condition}", __FILE__, __LINE__);
//.........这里部分代码省略.........
示例8: action_movetopic2
//.........这里部分代码省略.........
checkSubmitOnce('check');
// Get the basic details on this topic
$topic_info = getTopicInfo($topic);
$context['is_approved'] = $topic_info['approved'];
// Can they see it?
if (!$context['is_approved']) {
isAllowedTo('approve_posts');
}
// Can they move topics on this board?
if (!allowedTo('move_any')) {
if ($topic_info['id_member_started'] == $user_info['id']) {
isAllowedTo('move_own');
} else {
isAllowedTo('move_any');
}
}
checkSession();
require_once SUBSDIR . '/Post.subs.php';
require_once SUBSDIR . '/Boards.subs.php';
// The destination board must be numeric.
$toboard = (int) $_POST['toboard'];
// Make sure they can see the board they are trying to move to (and get whether posts count in the target board).
$board_info = boardInfo($toboard, $topic);
if (empty($board_info)) {
fatal_lang_error('no_board');
}
// Remember this for later.
$_SESSION['move_to_topic'] = array('move_to' => $toboard);
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$custom_subject = strtr(Util::htmltrim(Util::htmlspecialchars($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
// Keep checking the length.
if (Util::strlen($custom_subject) > 100) {
$custom_subject = Util::substr($custom_subject, 0, 100);
}
// If it's still valid move onwards and upwards.
if ($custom_subject != '') {
$all_messages = isset($_POST['enforce_subject']);
if ($all_messages) {
// Get a response prefix, but in the forum's default language.
$context['response_prefix'] = response_prefix();
topicSubject($topic_info, $custom_subject, $context['response_prefix'], $all_messages);
} else {
topicSubject($topic_info, $custom_subject);
}
// Fix the subject cache.
updateStats('subject', $topic, $custom_subject);
}
}
// Create a link to this in the old board.
// @todo Does this make sense if the topic was unapproved before? I'd just about say so.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$reason = Util::htmlspecialchars($_POST['reason'], ENT_QUOTES);
preparsecode($reason);
// Add a URL onto the message.
$reason = strtr($reason, array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $toboard . '.0]' . $board_info['name'] . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
// Auto remove this MOVED redirection topic in the future?
$redirect_expires = !empty($_POST['redirect_expires']) ? (int) $_POST['redirect_expires'] : 0;
// Redirect to the MOVED topic from topic list?
$redirect_topic = isset($_POST['redirect_topic']) ? $topic : 0;
// And remember the last expiry period too.
$_SESSION['move_to_topic']['redirect_topic'] = $redirect_topic;
$_SESSION['move_to_topic']['redirect_expires'] = $redirect_expires;
$msgOptions = array('subject' => $txt['moved'] . ': ' . $board_info['subject'], 'body' => $reason, 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true, 'redirect_expires' => empty($redirect_expires) ? 0 : $redirect_expires * 60 + time(), 'redirect_topic' => $redirect_topic);
$posterOptions = array('id' => $user_info['id'], 'update_post_count' => empty($board_info['count_posts']));
createPost($msgOptions, $topicOptions, $posterOptions);
}
$board_from = boardInfo($board);
if ($board_from['count_posts'] != $board_info['count_posts']) {
$posters = postersCount($topic);
foreach ($posters as $id_member => $posts) {
// The board we're moving from counted posts, but not to.
if (empty($board_from['count_posts'])) {
updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
} else {
updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
}
}
}
// Do the move (includes statistics update needed for the redirect topic).
moveTopics($topic, $toboard);
// Log that they moved this topic.
if (!allowedTo('move_own') || $topic_info['id_member_started'] != $user_info['id']) {
logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $toboard));
}
// Notify people that this topic has been moved?
require_once SUBSDIR . '/Notification.subs.php';
sendNotifications($topic, 'move');
// Why not go back to the original board in case they want to keep moving?
if (!isset($_REQUEST['goback'])) {
redirectexit('board=' . $board . '.0');
} else {
redirectexit('topic=' . $topic . '.0');
}
}
示例9: MoveTopic2
function MoveTopic2()
{
global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context;
global $db_prefix, $ID_MEMBER, $board, $language, $user_info, $func;
// Make sure this form hasn't been submitted before.
checkSubmitOnce('check');
$request = db_query("\n\t\tSELECT ID_MEMBER_STARTED, ID_FIRST_MSG\n\t\tFROM {$db_prefix}topics\n\t\tWHERE ID_TOPIC = {$topic}\n\t\tLIMIT 1", __FILE__, __LINE__);
list($ID_MEMBER_STARTED, $ID_FIRST_MSG) = mysql_fetch_row($request);
mysql_free_result($request);
// Can they move topics on this board?
if (!allowedTo('move_any')) {
if ($ID_MEMBER_STARTED == $ID_MEMBER) {
isAllowedTo('move_own');
$boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any'));
} else {
isAllowedTo('move_any');
}
} else {
$boards = boardsAllowedTo('move_any');
}
checkSession();
require_once $sourcedir . '/Subs-Post.php';
// The destination board must be numeric.
$_POST['toboard'] = (int) $_POST['toboard'];
// !!!
/*if (!in_array($_POST['toboard'], $boards) && !in_array(0, $boards))
fatal_lang_error('smf232');*/
// Make sure they can see the board they are trying to move to (and get whether posts count in the target board).
$request = db_query("\n\t\tSELECT b.countPosts, b.name, m.subject\n\t\tFROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)\n\t\tWHERE {$user_info['query_see_board']}\n\t\t\tAND b.ID_BOARD = {$_POST['toboard']}\n\t\t\tAND t.ID_TOPIC = {$topic}\n\t\t\tAND m.ID_MSG = t.ID_FIRST_MSG\n\t\tLIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0) {
fatal_lang_error('smf232');
}
list($pcounter, $board_name, $subject) = mysql_fetch_row($request);
mysql_free_result($request);
// Remember this for later.
$_SESSION['move_to_topic'] = $_POST['toboard'];
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$_POST['custom_subject'] = $func['htmlspecialchars']($_POST['custom_subject']);
if (isset($_POST['enforce_subject'])) {
// Get a response prefix, but in the forum's default language.
if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) {
if ($language === $user_info['language']) {
$context['response_prefix'] = $txt['response_prefix'];
} else {
loadLanguage('index', $language, false);
$context['response_prefix'] = $txt['response_prefix'];
loadLanguage('index');
}
cache_put_data('response_prefix', $context['response_prefix'], 600);
}
db_query("\n\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\tSET subject = '{$context['response_prefix']}{$_POST['custom_subject']}'\n\t\t\t\tWHERE ID_TOPIC = {$topic}", __FILE__, __LINE__);
}
db_query("\n\t\t\tUPDATE {$db_prefix}messages\n\t\t\tSET subject = '{$_POST['custom_subject']}'\n\t\t\tWHERE ID_MSG = {$ID_FIRST_MSG}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
// Fix the subject cache.
updateStats('subject', $topic, $_POST['custom_subject']);
}
// Create a link to this in the old board.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$_POST['reason'] = $func['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
preparsecode($_POST['reason']);
// Add a URL onto the message.
$_POST['reason'] = strtr($_POST['reason'], array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $_POST['toboard'] . ']' . addslashes($board_name) . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
$msgOptions = array('subject' => addslashes($txt['smf56'] . ': ' . $subject), 'body' => $_POST['reason'], 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true);
$posterOptions = array('id' => $ID_MEMBER, 'update_post_count' => !empty($pcounter));
createPost($msgOptions, $topicOptions, $posterOptions);
}
$request = db_query("\n\t\tSELECT countPosts\n\t\tFROM {$db_prefix}boards\n\t\tWHERE ID_BOARD = {$board}\n\t\tLIMIT 1", __FILE__, __LINE__);
list($pcounter_from) = mysql_fetch_row($request);
mysql_free_result($request);
if ($pcounter_from != $pcounter) {
$request = db_query("\n\t\t\tSELECT ID_MEMBER\n\t\t\tFROM {$db_prefix}messages\n\t\t\tWHERE ID_TOPIC = {$topic}", __FILE__, __LINE__);
$posters = array();
while ($row = mysql_fetch_assoc($request)) {
$posters[] = $row['ID_MEMBER'];
}
mysql_free_result($request);
// The board we're moving from counted posts, but not to.
if (empty($pcounter_from)) {
updateMemberData($posters, array('posts' => '-'));
} else {
updateMemberData($posters, array('posts' => '+'));
}
}
// Do the move (includes statistics update needed for the redirect topic).
moveTopics($topic, $_POST['toboard']);
// Log that they moved this topic.
if (!allowedTo('move_own') || $ID_MEMBER_STARTED != $ID_MEMBER) {
logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
}
// Notify people that this topic has been moved?
sendNotifications($topic, 'move');
// Update the cache?
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] == 3) {
cache_put_data('topic_board-' . $topic, null, 120);
//.........这里部分代码省略.........
示例10: redirect_header
if (!$xoopsSecurity->check()) {
redirect_header('./topic.php?id=' . $posts, 2, __('Session token expired!', 'bxpress'));
die;
}
$post->setApproved($app);
if ($post->editText()) {
$post->setText($post->editText());
}
$post->setEditText('');
$post->save();
redirect_header('./topic.php?id=' . $post->topic(), 1, __('Operation completed!', 'bxpress'));
}
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
switch ($op) {
case 'move':
moveTopics();
break;
case 'close':
closeTopic(1);
break;
case 'open':
closeTopic(0);
break;
case 'sticky':
stickyTopic(1);
break;
case 'unsticky':
stickyTopic(0);
break;
case 'delete':
deleteTopics();
示例11: action_massmove_display
/**
* Moves topics from one board to another.
*
* @uses not_done template to pause the process.
*/
public function action_massmove_display()
{
global $context, $txt, $time_start;
// Only admins.
isAllowedTo('admin_forum');
// And valid requests
checkSession();
// Set up to the context.
$context['page_title'] = $txt['not_done_title'];
$context['continue_countdown'] = 3;
$context['continue_post_data'] = '';
$context['continue_get_data'] = '';
$context['sub_template'] = 'not_done';
$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
// First time we do this?
$id_board_from = isset($_POST['id_board_from']) ? (int) $_POST['id_board_from'] : (int) $_REQUEST['id_board_from'];
$id_board_to = isset($_POST['id_board_to']) ? (int) $_POST['id_board_to'] : (int) $_REQUEST['id_board_to'];
// No boards then this is your stop.
if (empty($id_board_from) || empty($id_board_to)) {
return;
}
// These will be needed
require_once SUBSDIR . '/Maintenance.subs.php';
require_once SUBSDIR . '/Topic.subs.php';
// How many topics are we moving?
if (!isset($_REQUEST['totaltopics'])) {
$total_topics = countTopicsFromBoard($id_board_from);
} else {
$total_topics = (int) $_REQUEST['totaltopics'];
validateToken('admin_movetopics');
}
// We have topics to move so start the process.
if (!empty($total_topics)) {
while ($context['start'] <= $total_topics) {
// Lets get the next 10 topics.
$topics = getTopicsToMove($id_board_from);
// Just return if we don't have any topics left to move.
if (empty($topics)) {
break;
}
// Lets move them.
moveTopics($topics, $id_board_to);
// Increase the counter
$context['start'] += 10;
// If this is really taking some time, show the pause screen
if (microtime(true) - $time_start > 3) {
createToken('admin_movetopics');
// What's the percent?
$context['continue_percent'] = round(100 * ($context['start'] / $total_topics), 1);
// Set up for the form
$context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';start=' . $context['start'];
$context['continue_post_data'] = '
<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
<input type="hidden" name="' . $context['admin_movetopics_token_var'] . '" value="' . $context['admin_movetopics_token'] . '" />';
// Let the template system do it's thang.
return;
}
}
}
// Don't confuse admins by having an out of date cache.
cache_put_data('board-' . $id_board_from, null, 120);
cache_put_data('board-' . $id_board_to, null, 120);
redirectexit('action=admin;area=maintain;sa=topics;done=massmove');
}