##############################################################
## MOD Title:		View or mark unread posts (upgrade from version 1.0.6 to 1.0.7)
## MOD Author: asinshesq < N/A > (Alan) N/A
## MOD Description:	Upgrades view or mark unread posts from version 1.0.6 to 1.0.7
##
## MOD Version:		1.0.7
##
## Installation Level:	Easy
## Installation Time:	5 Minutes
##
## Files To Edit:	includes/functions_privmsgs.php
##
## Included Files:	N/A
##
## License:			http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:	Important: this is just an upgrade mod.  To use it, you must have
##					view or mark unread posts version 1.0.6 already installed.
##					If you haven't already installed any version of view or mark unread posts,
##					you should install the latest version of view or mark unread posts or pms
##					directly in the most recent version of phpbb and you should not use this upgrade mod at all.
##
##					Note: the changes from version 1.0.6 to 1.0.7 that appear below were posted on the phpbb.com topic for
##					this mod on November 29, 2009.  If you have already made those changes you don't need to do anything more.
##
##############################################################
## MOD History: see mod history in the main install file
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_privmsgs.php

#
#-----[ FIND ]------------------------------------------
#
	switch ($mark_action)

#
#-----[ BEFORE, ADD ]------------------------------------------
#
	// start mod view or mark unread posts (and end mod too)...in next line,
	// we define a variable that will allow us to ignore $cur_folder_id constraint
	// in queries when we are talking about unreadbox (since that's not a real folder);
	// then, we use that variable rather than 'folder_id = $cur_folder_id' in the first three cases in the switch below.
	$cur_folder_sql = ($cur_folder_id != PRIVMSGS_UNREADBOX) ? "folder_id = $cur_folder_id AND" : '';

#
#-----[ FIND ]------------------------------------------
#
				WHERE folder_id = $cur_folder_id
					AND user_id = $user_id

#
#-----[ REPLACE WITH ]------------------------------------------
#
				WHERE $cur_folder_sql
					user_id = $user_id

#
#-----[ FIND ]------------------------------------------
#
			$db->sql_query($sql);

#
#-----[ AFTER, ADD ]------------------------------------------
#
			update_pm_counts();

#
#-----[ FIND ]------------------------------------------
#
				WHERE folder_id = $cur_folder_id
					AND user_id = $user_id

#
#-----[ REPLACE WITH ]------------------------------------------
#
				WHERE $cur_folder_sql
					user_id = $user_id

#
#-----[ FIND ]------------------------------------------
#
			$db->sql_query($sql);

#
#-----[ AFTER, ADD ]------------------------------------------
#
			update_pm_counts();

#
#-----[ FIND ]------------------------------------------
#
				WHERE folder_id = $cur_folder_id
					AND user_id = $user_id

#
#-----[ REPLACE WITH ]------------------------------------------
#
				WHERE $cur_folder_sql
					user_id = $user_id

#
#-----[ FIND ]------------------------------------------
#
	$folder_id	= (int) $folder_id;

#
#-----[ AFTER, ADD ]------------------------------------------
#
	// start mod view or mark unread posts (and end mod too)...in next line,
	// we define a variable that will allow us to ignore $folder_id constraint
	// in queries when we are talking about unreadbox (since that's not a real folder);
	// then, we use that variable rather than 'folder_id = $folder_id' in several queries below.
	$folder_sql = ($folder_id != PRIVMSGS_UNREADBOX) ? "AND folder_id = $folder_id" : '';

#
#-----[ FIND ]------------------------------------------
#
			AND folder_id = $folder_id

#
#-----[ REPLACE WITH ]------------------------------------------
#
			$folder_sql

#
#-----[ FIND ]------------------------------------------
#
				AND folder_id = $folder_id

#
#-----[ REPLACE WITH ]------------------------------------------
#
				$folder_sql

#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM