Browse Source

Merge branch 'release-2.1' of https://github.com/SimpleMachines/SMF2.1 into release-2.1

Conflicts:
	Sources/Profile-Modify.php
Peter Spicer 11 years ago
parent
commit
f26666a587

+ 10 - 7
Sources/Display.php

@@ -464,13 +464,16 @@ function Display()
 	);
 	);
 
 
 	// Figure out all the link to the next/prev/first/last/etc. for wireless mainly.
 	// Figure out all the link to the next/prev/first/last/etc. for wireless mainly.
-	$context['links'] = array(
-		'first' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.0' : '',
-		'prev' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] - $context['messages_per_page']) : '',
-		'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '',
-		'last' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . (floor($context['total_visible_posts'] / $context['messages_per_page']) * $context['messages_per_page']) : '',
-		'up' => $scripturl . '?board=' . $board . '.0'
-	);
+	if (WIRELESS || !($can_show_all && isset($_REQUEST['all'])))
+	{
+		$context['links'] = array(
+			'first' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.0' : '',
+			'prev' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] - $context['messages_per_page']) : '',
+			'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '',
+			'last' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . (floor($context['total_visible_posts'] / $context['messages_per_page']) * $context['messages_per_page']) : '',
+			'up' => $scripturl . '?board=' . $board . '.0'
+		);
+	}
 
 
 	// If they are viewing all the posts, show all the posts, otherwise limit the number.
 	// If they are viewing all the posts, show all the posts, otherwise limit the number.
 	if ($can_show_all)
 	if ($can_show_all)

+ 2 - 2
Sources/Load.php

@@ -1446,9 +1446,9 @@ function loadTheme($id_theme = 0, $initialize = true)
 	// If they have specified a particular theme to use with SSI allow it to be used.
 	// If they have specified a particular theme to use with SSI allow it to be used.
 	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
 	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
 		$id_theme = (int) $id_theme;
 		$id_theme = (int) $id_theme;
-	elseif (!empty($modSettings['knownThemes']) && !allowedTo('admin_forum'))
+	elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
 	{
 	{
-		$themes = explode(',', $modSettings['knownThemes']);
+		$themes = explode(',', $modSettings['enableThemes']);
 		if (!in_array($id_theme, $themes))
 		if (!in_array($id_theme, $themes))
 			$id_theme = $modSettings['theme_guests'];
 			$id_theme = $modSettings['theme_guests'];
 		else
 		else

+ 13 - 8
Sources/MessageIndex.php

@@ -90,20 +90,25 @@ function MessageIndex()
 	// Set a canonical URL for this page.
 	// Set a canonical URL for this page.
 	$context['canonical_url'] = $scripturl . '?board=' . $board . '.' . $context['start'];
 	$context['canonical_url'] = $scripturl . '?board=' . $board . '.' . $context['start'];
 
 
-	$context['links'] = array(
-		'first' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.0' : '',
-		'prev' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] - $context['topics_per_page']) : '',
-		'next' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] + $context['topics_per_page']) : '',
-		'last' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . (floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) * $context['topics_per_page']) : '',
-		'up' => $board_info['parent'] == 0 ? $scripturl . '?' : $scripturl . '?board=' . $board_info['parent'] . '.0'
-	);
+	$can_show_all = !empty($modSettings['enableAllMessages']) && $maxindex > $modSettings['enableAllMessages'];
+
+	if (WIRELESS || !($can_show_all && isset($_REQUEST['all'])))
+	{
+		$context['links'] = array(
+			'first' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.0' : '',
+			'prev' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] - $context['topics_per_page']) : '',
+			'next' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] + $context['topics_per_page']) : '',
+			'last' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . (floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) * $context['topics_per_page']) : '',
+			'up' => $board_info['parent'] == 0 ? $scripturl . '?' : $scripturl . '?board=' . $board_info['parent'] . '.0'
+		);
+	}
 
 
 	$context['page_info'] = array(
 	$context['page_info'] = array(
 		'current_page' => $_REQUEST['start'] / $context['topics_per_page'] + 1,
 		'current_page' => $_REQUEST['start'] / $context['topics_per_page'] + 1,
 		'num_pages' => floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) + 1
 		'num_pages' => floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) + 1
 	);
 	);
 
 
-	if (isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) && $maxindex > $modSettings['enableAllMessages'])
+	if (isset($_REQUEST['all']) && $can_show_all)
 	{
 	{
 		$maxindex = $modSettings['enableAllMessages'];
 		$maxindex = $modSettings['enableAllMessages'];
 		$_REQUEST['start'] = 0;
 		$_REQUEST['start'] = 0;

+ 41 - 30
Sources/Profile-Modify.php

@@ -1124,7 +1124,8 @@ function makeThemeChanges($memID, $id_theme)
 			);
 			);
 		}
 		}
 
 
-		$themes = explode(',', $modSettings['knownThemes']);
+		// Admins can choose any theme, even if it's not enabled...
+		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
 		foreach ($themes as $t)
 		foreach ($themes as $t)
 			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
 			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
 	}
 	}
@@ -1885,6 +1886,7 @@ function alert_configuration($memID)
 		),
 		),
 		'members' => array(
 		'members' => array(
 			'member_register' => array('alert' => 'yes', 'email' => 'yes', 'permission' => array('name' => 'moderate_forum', 'is_board' => false)),
 			'member_register' => array('alert' => 'yes', 'email' => 'yes', 'permission' => array('name' => 'moderate_forum', 'is_board' => false)),
+			'request_group' => array('alert' => 'yes', 'email' => 'yes'),
 			'warn_own' => array('alert' => 'yes', 'email' => 'yes'),
 			'warn_own' => array('alert' => 'yes', 'email' => 'yes'),
 			'warn_any' => array('alert' => 'yes', 'email' => 'yes', 'permission' => array('name' => 'issue_warning', 'is_board' => false)),
 			'warn_any' => array('alert' => 'yes', 'email' => 'yes', 'permission' => array('name' => 'issue_warning', 'is_board' => false)),
 		),
 		),
@@ -1943,6 +1945,27 @@ function alert_configuration($memID)
 		if (empty($alert_types[$group]))
 		if (empty($alert_types[$group]))
 			unset ($alert_types[$group]);
 			unset ($alert_types[$group]);
 	}
 	}
+	
+	// Slightly different for group requests
+	$request = $smcFunc['db_query']('', '
+		SELECT COUNT(*)
+		FROM {db_prefix}group_moderators
+		WHERE id_member = {int:memID}',
+		array(
+			'memID' => $memID,
+		)
+	);
+	
+	list($can_mod) = $smcFunc['db_fetch_row']($request);
+	
+	if (!isset($perms_cache['manage_membergroups']))
+	{
+		$members = membersAllowedTo('manage_membergroups');
+		$perms_cache['manage_membergroups'] = in_array($memID, $members);
+	}
+
+	if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
+		unset($alert_types['members']['request_group']);
 
 
 	// And finally, exporting it to be useful later.
 	// And finally, exporting it to be useful later.
 	$context['alert_types'] = $alert_types;
 	$context['alert_types'] = $alert_types;
@@ -3624,39 +3647,27 @@ function groupMembership2($profile_vars, $post_errors, $memID)
 
 
 		if (!empty($moderators))
 		if (!empty($moderators))
 		{
 		{
-			$request = $smcFunc['db_query']('', '
-				SELECT id_member, email_address, lngfile, member_name, mod_prefs
-				FROM {db_prefix}members
-				WHERE id_member IN ({array_int:moderator_list})
-					AND notify_types != {int:no_notifications}
-				ORDER BY lngfile',
-				array(
-					'moderator_list' => $moderators,
-					'no_notifications' => 4,
-				)
-			);
-			while ($row = $smcFunc['db_fetch_assoc']($request))
+			// Figure out who wants to be alerted/emailed about this
+			$data = array('alert' => array(), 'email' => array());
+
+			include_once($sourcedir . '/Subs-Notify.php');
+			$prefs = getNotifyPrefs($moderators, 'request_group');
+			
+			// Bitwise comparisons are fun...
+			foreach ($moderators as $mod)
 			{
 			{
-				// Check whether they are interested.
-				if (!empty($row['mod_prefs']))
+				if (!empty($prefs[$mod]))
 				{
 				{
-					list(,, $pref_binary) = explode('|', $row['mod_prefs']);
-					if (!($pref_binary & 4))
-						continue;
-				}
+					if ($prefs[$mod] & 0x01)
+						$data['alerts'][] = $mod;
 
 
-				$replacements = array(
-					'RECPNAME' => $row['member_name'],
-					'APPYNAME' => $old_profile['member_name'],
-					'GROUPNAME' => $group_name,
-					'REASON' => $_POST['reason'],
-					'MODLINK' => $scripturl . '?action=moderate;area=groups;sa=requests',
-				);
-
-				$emaildata = loadEmailTemplate('request_membership', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
-				sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, null, false, 2);
+					if ($prefs[$mod] & 0x02)
+						$data['email'][] = $mod;
+				}
 			}
 			}
-			$smcFunc['db_free_result']($request);
+
+			// Now we pass this off to our background task to handle
+			$smcFunc['db_insert']('', '{db_prefix}background_tasks', array('task_file' => 'string-255', 'task_class' => 'string-255', 'task_data' => 'string', 'claimed_time' => 'int'), array('GroupNotif-Task.php', 'GroupNotify', serialize($data), time()));
 		}
 		}
 
 
 		return $changeType;
 		return $changeType;

+ 1 - 2
Themes/default/MessageIndex.template.php

@@ -254,9 +254,8 @@ function template_main()
 								<span class="preview', $topic['is_sticky'] ? ' bold_text' : '', '" title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '">
 								<span class="preview', $topic['is_sticky'] ? ' bold_text' : '', '" title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '">
 									<span id="msg_', $topic['first_post']['id'], '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>
 									<span id="msg_', $topic['first_post']['id'], '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>
 								</span>
 								</span>
-								<br class="clear" />
+							', $topic['new'] && $context['user']['is_logged'] ? '<a href="' . $topic['new_href'] . '" id="newicon' . $topic['first_post']['id'] . '" style="display: inline-block; margin: 7px 0 5px 3px;"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '
 							</div>
 							</div>
-							', $topic['new'] && $context['user']['is_logged'] ? '<a href="' . $topic['new_href'] . '" class="floatleft" id="newicon' . $topic['first_post']['id'] . '" style="display: block; margin: 9px 0 0 3px;"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '
 							<br class="clear" />
 							<br class="clear" />
 							<p class="floatleft">', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
 							<p class="floatleft">', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
 								<small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
 								<small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>

+ 0 - 4
Themes/default/css/index.css

@@ -2002,10 +2002,6 @@ td#quick_actions {
 	padding: 4px 6px 2px 6px;
 	padding: 4px 6px 2px 6px;
 }
 }
 
 
-.message_index_title {
-	margin-bottom: -3px;
-}
-
 /* Styles for the display template (topic view).
 /* Styles for the display template (topic view).
 ---------------------------------------------------- */
 ---------------------------------------------------- */
 /* Events */
 /* Events */

+ 9 - 6
Themes/default/index.template.php

@@ -149,13 +149,16 @@ function template_html_above()
 
 
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
 	if (!empty($context['links']['next']))
 	if (!empty($context['links']['next']))
-		echo '<link rel="next" href="', $context['links']['next'], '" />';
-	else if (!empty($context['current_topic']))
-		echo '<link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';
+	{
+		echo '
+	<link rel="next" href="', $context['links']['next'], '" />';
+	}
+
 	if (!empty($context['links']['prev']))
 	if (!empty($context['links']['prev']))
-		echo '<link rel="prev" href="', $context['links']['prev'], '" />';
-	else if (!empty($context['current_topic']))
-		echo '<link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />';
+	{
+		echo '
+	<link rel="prev" href="', $context['links']['prev'], '" />';
+	}
 
 
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
 	if (!empty($context['current_board']))
 	if (!empty($context['current_board']))

+ 1 - 0
Themes/default/languages/Profile.english.php

@@ -147,6 +147,7 @@ $txt['alert_warn_own'] = 'If I receive a warning';
 $txt['alert_warn_any'] = 'When other members receive a warning';
 $txt['alert_warn_any'] = 'When other members receive a warning';
 $txt['alert_group_calendar'] = 'Calendar';
 $txt['alert_group_calendar'] = 'Calendar';
 $txt['alert_event_new'] = 'When a new event goes into the calendar';
 $txt['alert_event_new'] = 'When a new event goes into the calendar';
+$txt['alert_request_group'] = 'When someone requests to join a group I moderate';
 
 
 $txt['notifications_topics'] = 'Current Topic Notifications';
 $txt['notifications_topics'] = 'Current Topic Notifications';
 $txt['notifications_topics_list'] = 'You are being notified of replies to the following topics';
 $txt['notifications_topics_list'] = 'You are being notified of replies to the following topics';

+ 2 - 2
other/install_2-1_postgresql.sql

@@ -238,7 +238,7 @@ CREATE TABLE {$db_prefix}background_tasks (
   task_file varchar(255) NOT NULL default '',
   task_file varchar(255) NOT NULL default '',
   task_class varchar(255) NOT NULL default '',
   task_class varchar(255) NOT NULL default '',
   task_data text NOT NULL,
   task_data text NOT NULL,
-  claimed_time int unsigned NOT NULL default '0',
+  claimed_time int NOT NULL default '0',
   PRIMARY KEY (id_task)
   PRIMARY KEY (id_task)
 );
 );
 
 
@@ -2684,7 +2684,7 @@ CREATE INDEX {$db_prefix}user_alerts_alert_time ON {$db_prefix}user_alerts (aler
 CREATE TABLE {$db_prefix}user_alerts_prefs (
 CREATE TABLE {$db_prefix}user_alerts_prefs (
   id_member int NOT NULL default '0',
   id_member int NOT NULL default '0',
   alert_pref varchar(32) NOT NULL default '',
   alert_pref varchar(32) NOT NULL default '',
-  alert_value smallint(3) NOT NULL default '0',
+  alert_value smallint NOT NULL default '0',
   PRIMARY KEY (id_member, alert_pref)
   PRIMARY KEY (id_member, alert_pref)
 );
 );
 
 

+ 12 - 19
other/upgrade_2-1_mysql.sql

@@ -327,6 +327,18 @@ VALUES
 	('enableThemes', '1');
 	('enableThemes', '1');
 ---#
 ---#
 
 
+---# Setting "default" as the default...
+UPDATE {$db_prefix}settings
+SET value = '1'
+WHERE variable = 'theme_guests';
+
+UPDATE {$db_prefix}boards
+SET id_theme = 0;
+
+UPDATE {$db_prefix}members
+SET id_theme = 0;
+---#
+
 /******************************************************************************/
 /******************************************************************************/
 --- Cleaning up after old themes...
 --- Cleaning up after old themes...
 /******************************************************************************/
 /******************************************************************************/
@@ -367,25 +379,6 @@ if (file_exists($GLOBALS['boarddir'] . '/Themes/core'))
 		upgrade_query("
 		upgrade_query("
 			DELETE FROM {$db_prefix}themes
 			DELETE FROM {$db_prefix}themes
 			WHERE id_theme = $id_theme");
 			WHERE id_theme = $id_theme");
-
-		// Set any members or boards using this theme to the default
-		upgrade_query("
-			UPDATE {$db_prefix}members
-			SET id_theme = 0
-			WHERE id_theme = $id_theme");
-
-		upgrade_query("
-			UPDATE {$db_prefix}boards
-			SET id_theme = 0
-			WHERE id_theme = $id_theme");
-
-		if ($modSettings['theme_guests'] == $id_theme)
-		{
-			upgrade_query("
-				REPLACE INTO {$db_prefix}settings
-				(variable, value)
-				VALUES('theme_guests', 0)");
-		}
 	}
 	}
 }
 }
 ---}
 ---}

+ 46 - 40
other/upgrade_2-1_postgresql.sql

@@ -1,4 +1,4 @@
-/* ATTENTION: You don't need to run or use this file!  The upgrade.php script does everything for you! */
+/* ATTENTION: You don't need to run or use this file! The upgrade.php script does everything for you! */
 
 
 /******************************************************************************/
 /******************************************************************************/
 --- Adding new settings...
 --- Adding new settings...
@@ -9,9 +9,9 @@ CREATE SEQUENCE {$db_prefix}member_logins_seq;
 ---#
 ---#
 
 
 ---# Creating login history table.
 ---# Creating login history table.
-CREATE TABLE IF NOT EXISTS {$db_prefix}member_logins (
+CREATE TABLE {$db_prefix}member_logins (
 	id_login int NOT NULL default nextval('{$db_prefix}member_logins_seq'),
 	id_login int NOT NULL default nextval('{$db_prefix}member_logins_seq'),
-	id_member mediumint NOT NULL,
+	id_member int NOT NULL,
 	time int NOT NULL,
 	time int NOT NULL,
 	ip varchar(255) NOT NULL default '',
 	ip varchar(255) NOT NULL default '',
 	ip2 varchar(255) NOT NULL default '',
 	ip2 varchar(255) NOT NULL default '',
@@ -42,7 +42,7 @@ if (!isset($modSettings['allow_no_censored']))
 	");
 	");
 	
 	
 	// Is it set for either "default" or the one they've set as default?
 	// Is it set for either "default" or the one they've set as default?
-	while ($row = mysql_fetch_assoc($request))
+	while ($row = $smcFunc['db_fetch_assoc']($request))
 	{
 	{
 		if ($row['value'] == 1)
 		if ($row['value'] == 1)
 		{
 		{
@@ -266,12 +266,12 @@ CREATE SEQUENCE {$db_prefix}background_tasks_seq;
 ---#
 ---#
 
 
 ---# Adding the table
 ---# Adding the table
-CREATE TABLE IF NOT EXISTS {$db_prefix}background_tasks (
+CREATE TABLE {$db_prefix}background_tasks (
   id_task int default nextval('{$db_prefix}background_tasks_seq'),
   id_task int default nextval('{$db_prefix}background_tasks_seq'),
   task_file varchar(255) NOT NULL default '',
   task_file varchar(255) NOT NULL default '',
   task_class varchar(255) NOT NULL default '',
   task_class varchar(255) NOT NULL default '',
   task_data text NOT NULL,
   task_data text NOT NULL,
-  claimed_time int unsigned NOT NULL default '0',
+  claimed_time int NOT NULL default '0',
   PRIMARY KEY (id_task)
   PRIMARY KEY (id_task)
 );
 );
 ---#
 ---#
@@ -281,7 +281,7 @@ CREATE TABLE IF NOT EXISTS {$db_prefix}background_tasks (
 /******************************************************************************/
 /******************************************************************************/
 ---# Modifying the "msn" column...
 ---# Modifying the "msn" column...
 ALTER TABLE {$db_prefix}members
 ALTER TABLE {$db_prefix}members
-CHANGE msn skype varchar(255) NOT NULL DEFAULT '';
+RENAME msn TO skype;
 ---#
 ---#
 
 
 /******************************************************************************/
 /******************************************************************************/
@@ -300,9 +300,18 @@ upgrade_query("
 /******************************************************************************/
 /******************************************************************************/
 ---# Adding new columns to categories...
 ---# Adding new columns to categories...
 ---{
 ---{
+// Sadly, PostgreSQL whines if we add a NOT NULL column without a default value to an existing table...
+upgrade_query("
+	ALTER TABLE {$db_prefix}categories
+	ADD COLUMN description text");
+
+upgrade_query("
+	UPDATE {$db_prefix}categories
+	SET description = ''");
+
 upgrade_query("
 upgrade_query("
 	ALTER TABLE {$db_prefix}categories
 	ALTER TABLE {$db_prefix}categories
-	ADD COLUMN description text NOT NULL;");
+	ALTER COLUMN description SET NOT NULL");
 ---}
 ---}
 ---#
 ---#
 
 
@@ -317,7 +326,7 @@ ADD COLUMN alerts int NOT NULL default '0';
 ---# Adding the new table for alerts.
 ---# Adding the new table for alerts.
 CREATE SEQUENCE {$db_prefix}user_alerts_seq;
 CREATE SEQUENCE {$db_prefix}user_alerts_seq;
 
 
-CREATE TABLE IF NOT EXISTS {$db_prefix}user_alerts (
+CREATE TABLE {$db_prefix}user_alerts (
   id_alert int default nextval('{$db_prefix}user_alerts_seq'),
   id_alert int default nextval('{$db_prefix}user_alerts_seq'),
   alert_time int NOT NULL default '0',
   alert_time int NOT NULL default '0',
   id_member int NOT NULL default '0',
   id_member int NOT NULL default '0',
@@ -336,10 +345,10 @@ CREATE INDEX {$db_prefix}user_alerts_alert_time ON {$db_prefix}user_alerts (aler
 ---#
 ---#
 
 
 ---# Adding alert preferences.
 ---# Adding alert preferences.
-CREATE TABLE IF NOT EXISTS {$db_prefix}user_alerts_prefs (
+CREATE TABLE {$db_prefix}user_alerts_prefs (
   id_member int NOT NULL default '0',
   id_member int NOT NULL default '0',
   alert_pref varchar(32) NOT NULL default '',
   alert_pref varchar(32) NOT NULL default '',
-  alert_value smallint(3) NOT NULL default '0',
+  alert_value smallint NOT NULL default '0',
   PRIMARY KEY (id_member, alert_pref)
   PRIMARY KEY (id_member, alert_pref)
 );
 );
 ---#
 ---#
@@ -367,7 +376,7 @@ VALUES
 ---{
 ---{
 upgrade_query("
 upgrade_query("
 	ALTER TABLE {$db_prefix}log_topics
 	ALTER TABLE {$db_prefix}log_topics
-	CHANGE COLUMN disregarded unwatched tinyint(3) NOT NULL DEFAULT '0';");
+	RENAME disregarded TO unwatched");
 ---}
 ---}
 ---#
 ---#
 
 
@@ -378,7 +387,7 @@ upgrade_query("
 ---{
 ---{
 upgrade_query("
 upgrade_query("
 	ALTER TABLE {$db_prefix}membergroups
 	ALTER TABLE {$db_prefix}membergroups
-	CHANGE `stars` `icons` varchar(255) NOT NULL DEFAULT ''");
+	RENAME stars TO icons");
 ---}
 ---}
 ---#
 ---#
 
 
@@ -395,6 +404,18 @@ VALUES
 	('enableThemes', '1');
 	('enableThemes', '1');
 ---#
 ---#
 
 
+---# Setting "default" as the default...
+UPDATE {$db_prefix}settings
+SET value = '1'
+WHERE variable = 'theme_guests';
+
+UPDATE {$db_prefix}boards
+SET id_theme = 0;
+
+UPDATE {$db_prefix}members
+SET id_theme = 0;
+---#
+
 /******************************************************************************/
 /******************************************************************************/
 --- Cleaning up after old themes...
 --- Cleaning up after old themes...
 /******************************************************************************/
 /******************************************************************************/
@@ -434,25 +455,6 @@ if (file_exists($GLOBALS['boarddir'] . '/Themes/core'))
 		upgrade_query("
 		upgrade_query("
 			DELETE FROM {$db_prefix}themes
 			DELETE FROM {$db_prefix}themes
 			WHERE id_theme = $id_theme");
 			WHERE id_theme = $id_theme");
-
-		// Set any members or boards using this theme to the default
-		upgrade_query("
-			UPDATE {$db_prefix}members
-			SET id_theme = 0
-			WHERE id_theme = $id_theme");
-
-		upgrade_query("
-			UPDATE {$db_prefix}boards
-			SET id_theme = 0
-			WHERE id_theme = $id_theme");
-
-		if ($modSettings['theme_guests'] == $id_theme)
-		{
-			upgrade_query("
-				UPDATE {$db_prefix}settings
-				SET value = 0
-				WHERE variable = 'theme_guests'");
-		}
 	}
 	}
 }
 }
 ---}
 ---}
@@ -462,8 +464,10 @@ if (file_exists($GLOBALS['boarddir'] . '/Themes/core'))
 --- Adding support for drafts
 --- Adding support for drafts
 /******************************************************************************/
 /******************************************************************************/
 ---# Creating drafts table.
 ---# Creating drafts table.
-CREATE TABLE IF NOT EXISTS {$db_prefix}user_drafts (
-	id_draft int NOT NULL auto_increment,
+CREATE SEQUENCE {$db_prefix}user_drafts_seq;
+
+CREATE TABLE {$db_prefix}user_drafts (
+	id_draft int NOT NULL default nextval('{$db_prefix}user_drafts_seq'),
 	id_topic int NOT NULL default '0',
 	id_topic int NOT NULL default '0',
 	id_board smallint NOT NULL default '0',
 	id_board smallint NOT NULL default '0',
 	id_reply int NOT NULL default '0',
 	id_reply int NOT NULL default '0',
@@ -549,7 +553,7 @@ INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_
 --- Adding support for likes
 --- Adding support for likes
 /******************************************************************************/
 /******************************************************************************/
 ---# Creating likes table.
 ---# Creating likes table.
-CREATE TABLE IF NOT EXISTS {$db_prefix}user_likes (
+CREATE TABLE {$db_prefix}user_likes (
   id_member int NOT NULL default '0',
   id_member int NOT NULL default '0',
   content_type char(6) default '',
   content_type char(6) default '',
   content_id int NOT NULL default '0',
   content_id int NOT NULL default '0',
@@ -570,7 +574,7 @@ ADD COLUMN likes smallint NOT NULL default '0';
 --- Adding support for group-based board moderation
 --- Adding support for group-based board moderation
 /******************************************************************************/
 /******************************************************************************/
 ---# Creating moderator_groups table
 ---# Creating moderator_groups table
-CREATE TABLE IF NOT EXISTS {$db_prefix}moderator_groups (
+CREATE TABLE {$db_prefix}moderator_groups (
   id_board smallint NOT NULL default '0',
   id_board smallint NOT NULL default '0',
   id_group smallint NOT NULL default '0',
   id_group smallint NOT NULL default '0',
   PRIMARY KEY (id_board, id_group)
   PRIMARY KEY (id_board, id_group)
@@ -606,8 +610,10 @@ WHERE filename = 'latest-packages.js'
 --- Upgrading "verification questions" feature
 --- Upgrading "verification questions" feature
 /******************************************************************************/
 /******************************************************************************/
 ---# Creating qanda table
 ---# Creating qanda table
-CREATE TABLE IF NOT EXISTS {$db_prefix}qanda (
-  id_question smallint(5) unsigned NOT NULL auto_increment,
+CREATE SEQUENCE {$db_prefix}qanda_seq;
+
+CREATE TABLE {$db_prefix}qanda (
+  id_question smallint NOT NULL default nextval('{$db_prefix}qanda_seq'),
   lngfile varchar(255) NOT NULL default '',
   lngfile varchar(255) NOT NULL default '',
   question varchar(255) NOT NULL default '',
   question varchar(255) NOT NULL default '',
   answers text NOT NULL,
   answers text NOT NULL,
@@ -755,7 +761,7 @@ CREATE SEQUENCE {$db_prefix}pm_labels_sequence;
 ---#
 ---#
 
 
 ---# Adding pm_labels table...
 ---# Adding pm_labels table...
-CREATE TABLE IF NOT EXISTS {$db_prefix}pm_labels (
+CREATE TABLE {$db_prefix}pm_labels (
   id_label int NOT NULL default nextval('{$db_prefix}pm_labels_seq'),
   id_label int NOT NULL default nextval('{$db_prefix}pm_labels_seq'),
   id_member int NOT NULL default '0',
   id_member int NOT NULL default '0',
   name varchar(30) NOT NULL default '',
   name varchar(30) NOT NULL default '',
@@ -764,7 +770,7 @@ CREATE TABLE IF NOT EXISTS {$db_prefix}pm_labels (
 ---#
 ---#
 
 
 ---# Adding pm_labeled_messages table...
 ---# Adding pm_labeled_messages table...
-CREATE TABLE IF NOT EXISTS {$db_prefix}pm_labeled_messages (
+CREATE TABLE {$db_prefix}pm_labeled_messages (
   id_label int NOT NULL default '0',
   id_label int NOT NULL default '0',
   id_pm int NOT NULL default '0',
   id_pm int NOT NULL default '0',
   PRIMARY KEY (id_label, id_pm)
   PRIMARY KEY (id_label, id_pm)

+ 12 - 19
other/upgrade_2-1_sqlite.sql

@@ -399,6 +399,18 @@ VALUES
 	('enableThemes', '1');
 	('enableThemes', '1');
 ---#
 ---#
 
 
+---# Setting "default" as the default...
+UPDATE {$db_prefix}settings
+SET value = '1'
+WHERE variable = 'theme_guests';
+
+UPDATE {$db_prefix}boards
+SET id_theme = 0;
+
+UPDATE {$db_prefix}members
+SET id_theme = 0;
+---#
+
 /******************************************************************************/
 /******************************************************************************/
 --- Cleaning up after old themes...
 --- Cleaning up after old themes...
 /******************************************************************************/
 /******************************************************************************/
@@ -438,25 +450,6 @@ if (file_exists($GLOBALS['boarddir'] . '/Themes/core'))
 		upgrade_query("
 		upgrade_query("
 			DELETE FROM {$db_prefix}themes
 			DELETE FROM {$db_prefix}themes
 			WHERE id_theme = $id_theme");
 			WHERE id_theme = $id_theme");
-
-		// Set any members or boards using this theme to the default
-		upgrade_query("
-			UPDATE {$db_prefix}members
-			SET id_theme = 0
-			WHERE id_theme = $id_theme");
-
-		upgrade_query("
-			UPDATE {$db_prefix}boards
-			SET id_theme = 0
-			WHERE id_theme = $id_theme");
-
-		if ($modSettings['theme_guests'] == $id_theme)
-		{
-			upgrade_query("
-				UPDATE {$db_prefix}settings
-				SET value = 0
-				WHERE variable = 'theme_guests'");
-		}
 	}
 	}
 }
 }