mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/9684] Remove code for global announcement in root-files
PHPBB3-9684
This commit is contained in:
@@ -333,131 +333,22 @@ function change_topic_type($action, $topic_ids)
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
if ($new_topic_type != POST_GLOBAL)
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_type = $new_topic_type
|
||||
WHERE " . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids))
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_type = $new_topic_type
|
||||
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
|
||||
AND forum_id <> 0';
|
||||
// Delete topic shadows for global announcements
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Reset forum id if a global topic is within the array
|
||||
$to_forum_id = request_var('to_forum_id', 0);
|
||||
|
||||
if ($to_forum_id)
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_type = $new_topic_type, forum_id = $to_forum_id
|
||||
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
|
||||
AND forum_id = 0';
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Update forum_ids for all posts
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . "
|
||||
SET forum_id = $to_forum_id
|
||||
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
|
||||
AND forum_id = 0';
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Do a little forum sync stuff
|
||||
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
|
||||
$result = $db->sql_query($sql);
|
||||
$row_data = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sync_sql = array();
|
||||
|
||||
if ($row_data['topic_posts'])
|
||||
{
|
||||
$sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts'];
|
||||
}
|
||||
|
||||
if ($row_data['topics_authed'])
|
||||
{
|
||||
$sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed'];
|
||||
}
|
||||
|
||||
$sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids);
|
||||
|
||||
foreach ($sync_sql as $forum_id_key => $array)
|
||||
{
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
SET ' . implode(', ', $array) . '
|
||||
WHERE forum_id = ' . $forum_id_key;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
sync('forum', 'forum_id', $to_forum_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get away with those topics already being a global announcement by re-calculating $topic_ids
|
||||
$sql = 'SELECT topic_id
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
|
||||
AND forum_id <> 0';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$topic_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$topic_ids[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (sizeof($topic_ids))
|
||||
{
|
||||
// Delete topic shadows for global announcements
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_type = $new_topic_type, forum_id = 0
|
||||
WHERE " . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Update forum_ids for all posts
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET forum_id = 0
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Do a little forum sync stuff
|
||||
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
|
||||
$result = $db->sql_query($sql);
|
||||
$row_data = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sync_sql = array();
|
||||
|
||||
if ($row_data['topic_posts'])
|
||||
{
|
||||
$sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts'];
|
||||
}
|
||||
|
||||
if ($row_data['topics_authed'])
|
||||
{
|
||||
$sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed'];
|
||||
}
|
||||
|
||||
$sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids);
|
||||
|
||||
foreach ($sync_sql as $forum_id_key => $array)
|
||||
{
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
SET ' . implode(', ', $array) . '
|
||||
WHERE forum_id = ' . $forum_id_key;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
sync('forum', 'forum_id', $forum_id);
|
||||
}
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_type = $new_topic_type
|
||||
WHERE " . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
|
||||
@@ -474,41 +365,7 @@ function change_topic_type($action, $topic_ids)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Global topic involved?
|
||||
$global_involved = false;
|
||||
|
||||
if ($new_topic_type != POST_GLOBAL)
|
||||
{
|
||||
$sql = 'SELECT forum_id
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
|
||||
AND forum_id = 0';
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$global_involved = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($global_involved)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_FORUM_SELECT' => make_forum_select(request_var('f', $forum_id), false, false, true, true),
|
||||
'S_CAN_LEAVE_SHADOW' => false,
|
||||
'ADDITIONAL_MSG' => (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS'])
|
||||
);
|
||||
|
||||
confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html');
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));
|
||||
}
|
||||
confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));
|
||||
}
|
||||
|
||||
$redirect = request_var('redirect', "index.$phpEx");
|
||||
|
Reference in New Issue
Block a user