mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 20:13:22 +01:00
[ticket/9684] Move currently existing GAs to a selectable forum while updating.
PHPBB3-9684
This commit is contained in:
parent
0b85dded29
commit
a9ad99302a
@ -177,6 +177,69 @@ $database_update_info = database_update_info();
|
||||
$error_ary = array();
|
||||
$errored = false;
|
||||
|
||||
$sql = 'SELECT topic_id
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE forum_id = 0
|
||||
AND topic_type = ' . POST_GLOBAL;
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$has_global = (int) $db->sql_fetchfield('topic_id');
|
||||
$db->sql_freeresult($result);
|
||||
$ga_forum_id = request_var('ga_forum_id', 0);
|
||||
|
||||
if ($has_global && !$ga_forum_id)
|
||||
{
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>" xml:lang="<?php echo $lang['USER_LANG']; ?>">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="content-language" content="<?php echo $lang['USER_LANG']; ?>" />
|
||||
<meta http-equiv="content-style-type" content="text/css" />
|
||||
<meta http-equiv="imagetoolbar" content="no" />
|
||||
|
||||
<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title>
|
||||
|
||||
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrap">
|
||||
<div id="page-header"> </div>
|
||||
|
||||
<div id="page-body">
|
||||
<div id="acp">
|
||||
<div class="panel">
|
||||
<span class="corners-top"><span></span></span>
|
||||
<div id="content">
|
||||
<div id="main" class="install-body">
|
||||
|
||||
<h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1>
|
||||
|
||||
<br />
|
||||
|
||||
<form action="" method="post" id="select_ga_forum_id">
|
||||
<?php
|
||||
if (isset($lang['SELECT_FORUM_GA']))
|
||||
{
|
||||
// Language string is available:
|
||||
echo $lang['SELECT_FORUM_GA'];
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):';
|
||||
}
|
||||
?>
|
||||
<select id="ga_forum_id" name="ga_forum_id"><?php echo make_forum_select(false, false, true, true) ?></select>
|
||||
|
||||
<input type="submit" name="post" value="<?php echo $lang['SUBMIT']; ?>" class="button1" />
|
||||
</form>
|
||||
<?php
|
||||
_print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8');
|
||||
|
||||
?>
|
||||
@ -1962,6 +2025,83 @@ function change_database_data(&$no_updates, $version)
|
||||
|
||||
_add_modules($modules_to_install);
|
||||
|
||||
// Localise Global Announcements
|
||||
$sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE forum_id = 0
|
||||
AND topic_type = ' . POST_GLOBAL;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$global_announcements = $update_lastpost_data = array();
|
||||
$update_lastpost_data['forum_last_post_time'] = 0;
|
||||
$update_forum_data = array(
|
||||
'forum_posts' => 0,
|
||||
'forum_topics' => 0,
|
||||
'forum_topics_real' => 0,
|
||||
);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$global_announcements[] = (int) $row['topic_id'];
|
||||
|
||||
$update_forum_data['forum_posts'] += (int) $row['topic_posts'];
|
||||
$update_forum_data['forum_topics_real']++;
|
||||
if ($row['topic_approved'])
|
||||
{
|
||||
$update_forum_data['forum_topics']++;
|
||||
}
|
||||
|
||||
if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
|
||||
{
|
||||
$update_lastpost_data = array(
|
||||
'forum_last_post_id' => (int) $row['topic_last_post_id'],
|
||||
'forum_last_post_subject' => $row['topic_last_post_subject'],
|
||||
'forum_last_post_time' => (int) $row['topic_last_post_time'],
|
||||
'forum_last_poster_id' => (int) $row['topic_last_poster_id'],
|
||||
'forum_last_poster_name' => $row['topic_last_poster_name'],
|
||||
'forum_last_poster_colour' => $row['topic_last_poster_colour'],
|
||||
);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!empty($global_announcements))
|
||||
{
|
||||
// Update the post/topic-count for the forum and the last-post if needed
|
||||
$ga_forum_id = request_var('ga_forum_id', 0);
|
||||
|
||||
$sql = 'SELECT forum_last_post_time
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE forum_id = ' . $ga_forum_id;
|
||||
$result = $db->sql_query($sql);
|
||||
$lastpost = (int) $db->sql_fetchfield('forum_last_post_time');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
|
||||
$sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
|
||||
$sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
|
||||
if ($lastpost < $update_lastpost_data['forum_last_post_time'])
|
||||
{
|
||||
$sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
SET ' . $sql_update . '
|
||||
WHERE forum_id = ' . $ga_forum_id;
|
||||
_sql($sql, $errored, $error_ary);
|
||||
|
||||
// Update some forum_ids
|
||||
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
|
||||
foreach ($table_ary as $table)
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET forum_id = $ga_forum_id
|
||||
WHERE " . $db->sql_in_set('topic_id', $global_announcements);
|
||||
_sql($sql, $errored, $error_ary);
|
||||
}
|
||||
unset($table_ary);
|
||||
}
|
||||
|
||||
$no_updates = false;
|
||||
break;
|
||||
}
|
||||
|
@ -323,6 +323,7 @@ $lang = array_merge($lang, array(
|
||||
'SERVER_CONFIG' => 'Server configuration',
|
||||
'SEARCH_INDEX_UNCONVERTED' => 'Search index was not converted',
|
||||
'SEARCH_INDEX_UNCONVERTED_EXPLAIN' => 'Your old search index was not converted. Searching will always yield an empty result. To create a new search index go to the Administration Control Panel, select Maintenance and then choose Search index from the submenu.',
|
||||
'SELECT_FORUM_GA' => 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):',
|
||||
'SOFTWARE' => 'Board software',
|
||||
'SPECIFY_OPTIONS' => 'Specify conversion options',
|
||||
'STAGE_ADMINISTRATOR' => 'Administrator details',
|
||||
|
Loading…
x
Reference in New Issue
Block a user