Browse Source

Merge pull request #1297 from Arantor/release-2.1

More fixes
Arantor 10 years ago
parent
commit
fbfa680048

+ 1 - 1
Themes/default/languages/ManagePermissions.english.php

@@ -296,7 +296,7 @@ $txt['permission_settings_enable_postgroups'] = 'Enable permissions for post cou
 // Escape any single quotes in here twice.. 'it\'s' -> 'it\\\'s'.
 $txt['permission_disable_postgroups_warning'] = 'Disabling this setting will remove permissions currently set to post count based groups.';
 
-$txt['permissions_post_moderation_desc'] = 'Post Moderation is the situation where posts are "moderated", where the author and the moderation team can view posts and decide whether to permit them to be visible to other users or not. From this page you can easily change which groups have their posts moderated for a particular permissions profile.';
+$txt['permissions_post_moderation_desc'] = 'From this page, you can configure the ability to hold users\' posts before being visible to regular forum members, including which group or groups of users can approve them. Users whose posts are held for approval will still be able to see their posts, as well as replies from approvers, e.g. moderator feedback about making a post appropriate.';
 $txt['permissions_post_moderation_enable'] = 'Enable Post Moderation';
 $txt['permissions_post_moderation_deny_note'] = 'Note that while you have advanced permissions enabled you cannot apply the "deny" permission from this page. Please edit the permissions directly if you wish to apply a deny permission.';
 $txt['permissions_post_moderation_select'] = 'Select Profile';

+ 48 - 1
other/upgrade_2-1_mysql.sql

@@ -96,7 +96,7 @@ while (!$is_done)
 	$fileHash = '';
 
 	$request = upgrade_query("
-		SELECT id_attach, id_folder, filename, file_hash
+		SELECT id_attach, id_folder, filename, file_hash, mime_type
 		FROM {$db_prefix}attachments
 		WHERE attachment_type != 1
 		LIMIT $_GET[a], 100");
@@ -166,6 +166,22 @@ while (!$is_done)
 				UPDATE {$db_prefix}attachments
 				SET file_hash = '$fileHash'
 				WHERE id_attach = $row[id_attach]");
+
+		// While we're here, do we need to update the mime_type?
+		if (empty($row['mime_type']) && file_exists($newFile))
+		{
+			$size = @getimagesize($newFile);
+			if (!empty($size['mime']))
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}attachments
+					SET mime_type = {string:mime_type}
+					WHERE id_attach = {int:id_attach}',
+					array(
+						'id_attach' => $row['id_attach'],
+						'mime_type' => substr($size['mime'], 0, 20),
+					)
+				);
+		}
 	}
 	$smcFunc['db_free_result']($request);
 
@@ -177,6 +193,37 @@ unset($_GET['a']);
 ---}
 ---#
 
+---# Fixing invalid sizes on attachments
+---{
+$attachs = array();
+// If id_member = 0, then it's not an avatar
+// If attachment_type = 0, then it's also not a thumbnail
+// Theory says there shouldn't be *that* many of these
+$request = $smcFunc['db_query']('', '
+	SELECT id_attach, mime_type, width, height
+	FROM {db_prefix}attachments
+	WHERE id_member = 0
+		AND attachment_type = 0');
+while ($row = $smcFunc['db_fetch_assoc']($request))
+{
+	if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
+		$attachs[] = $row['id_attach'];
+}
+$smcFunc['db_free_result']($request);
+
+if (!empty($attachs))
+	$smcFunc['db_query']('', '
+		UPDATE {db_prefix}attachments
+		SET width = 0,
+			height = 0
+		WHERE id_attach IN ({array_int:attachs})',
+		array(
+			'attachs' => $attachs,
+		)
+	);
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for IPv6...
 /******************************************************************************/

+ 48 - 1
other/upgrade_2-1_postgresql.sql

@@ -98,7 +98,7 @@ while (!$is_done)
 	$fileHash = '';
 
 	$request = upgrade_query("
-		SELECT id_attach, id_folder, filename, file_hash
+		SELECT id_attach, id_folder, filename, file_hash, mime_type
 		FROM {$db_prefix}attachments
 		WHERE attachment_type != 1
 		LIMIT $_GET[a], 100");
@@ -168,6 +168,22 @@ while (!$is_done)
 				UPDATE {$db_prefix}attachments
 				SET file_hash = '$fileHash'
 				WHERE id_attach = $row[id_attach]");
+
+		// While we're here, do we need to update the mime_type?
+		if (empty($row['mime_type']) && file_exists($newFile))
+		{
+			$size = @getimagesize($newFile);
+			if (!empty($size['mime']))
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}attachments
+					SET mime_type = {string:mime_type}
+					WHERE id_attach = {int:id_attach}',
+					array(
+						'id_attach' => $row['id_attach'],
+						'mime_type' => substr($size['mime'], 0, 20),
+					)
+				);
+		}
 	}
 	$smcFunc['db_free_result']($request);
 
@@ -179,6 +195,37 @@ unset($_GET['a']);
 ---}
 ---#
 
+---# Fixing invalid sizes on attachments
+---{
+$attachs = array();
+// If id_member = 0, then it's not an avatar
+// If attachment_type = 0, then it's also not a thumbnail
+// Theory says there shouldn't be *that* many of these
+$request = $smcFunc['db_query']('', '
+	SELECT id_attach, mime_type, width, height
+	FROM {db_prefix}attachments
+	WHERE id_member = 0
+		AND attachment_type = 0');
+while ($row = $smcFunc['db_fetch_assoc']($request))
+{
+	if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
+		$attachs[] = $row['id_attach'];
+}
+$smcFunc['db_free_result']($request);
+
+if (!empty($attachs))
+	$smcFunc['db_query']('', '
+		UPDATE {db_prefix}attachments
+		SET width = 0,
+			height = 0
+		WHERE id_attach IN ({array_int:attachs})',
+		array(
+			'attachs' => $attachs,
+		)
+	);
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for IPv6...
 /******************************************************************************/

+ 48 - 1
other/upgrade_2-1_sqlite.sql

@@ -96,7 +96,7 @@ while (!$is_done)
 	$fileHash = '';
 
 	$request = upgrade_query("
-		SELECT id_attach, id_folder, filename, file_hash
+		SELECT id_attach, id_folder, filename, file_hash, mime_type
 		FROM {$db_prefix}attachments
 		WHERE attachment_type != 1
 		LIMIT $_GET[a], 100");
@@ -166,6 +166,22 @@ while (!$is_done)
 				UPDATE {$db_prefix}attachments
 				SET file_hash = '$fileHash'
 				WHERE id_attach = $row[id_attach]");
+
+		// While we're here, do we need to update the mime_type?
+		if (empty($row['mime_type']) && file_exists($newFile))
+		{
+			$size = @getimagesize($newFile);
+			if (!empty($size['mime']))
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}attachments
+					SET mime_type = {string:mime_type}
+					WHERE id_attach = {int:id_attach}',
+					array(
+						'id_attach' => $row['id_attach'],
+						'mime_type' => substr($size['mime'], 0, 20),
+					)
+				);
+		}
 	}
 	$smcFunc['db_free_result']($request);
 
@@ -177,6 +193,37 @@ unset($_GET['a']);
 ---}
 ---#
 
+---# Fixing invalid sizes on attachments
+---{
+$attachs = array();
+// If id_member = 0, then it's not an avatar
+// If attachment_type = 0, then it's also not a thumbnail
+// Theory says there shouldn't be *that* many of these
+$request = $smcFunc['db_query']('', '
+	SELECT id_attach, mime_type, width, height
+	FROM {db_prefix}attachments
+	WHERE id_member = 0
+		AND attachment_type = 0');
+while ($row = $smcFunc['db_fetch_assoc']($request))
+{
+	if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
+		$attachs[] = $row['id_attach'];
+}
+$smcFunc['db_free_result']($request);
+
+if (!empty($attachs))
+	$smcFunc['db_query']('', '
+		UPDATE {db_prefix}attachments
+		SET width = 0,
+			height = 0
+		WHERE id_attach IN ({array_int:attachs})',
+		array(
+			'attachs' => $attachs,
+		)
+	);
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for IPv6...
 /******************************************************************************/