aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install/database_update.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-04-11 00:04:19 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-04-11 00:04:19 -0400
commit716f514ee9717906e2d62c9c401b78cab80a2141 (patch)
tree9ad7f74cf0e2cd6bd81bed133995501d936e217e /phpBB/install/database_update.php
parent00a69b43723b89a90bc59763a1cdae9a7001a153 (diff)
parentad81637300bfbbb4f18d80cd87326fbc90dd38f8 (diff)
downloadforums-716f514ee9717906e2d62c9c401b78cab80a2141.tar
forums-716f514ee9717906e2d62c9c401b78cab80a2141.tar.gz
forums-716f514ee9717906e2d62c9c401b78cab80a2141.tar.bz2
forums-716f514ee9717906e2d62c9c401b78cab80a2141.tar.xz
forums-716f514ee9717906e2d62c9c401b78cab80a2141.zip
Merge branch 'ticket/nickvergessen/9684' into develop
* ticket/nickvergessen/9684: [ticket/9684] Also display forum-name in subsilver2 template [ticket/9684] Move currently existing GAs to a selectable forum while updating. [ticket/9684] View origin-forumname for GAs in topic-list [ticket/9684] Fix Forum/Topic-Tracking for global announcements [ticket/9684] Fix a SQL-Error in the posting.php [ticket/9684] Remove code in some more files especially includes/ [ticket/9684] Remove code for global announcement in root-files
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r--phpBB/install/database_update.php140
1 files changed, 140 insertions, 0 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index cf611ca951..0d3e96f342 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -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">&nbsp;</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;
}