<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="./contrib/xsl/modx.prosilver.en.xsl"?>
<!-- 
	NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.
-->
<!--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/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.5.xsd">
	<header>
		<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
		<title lang="en">Prime Topic Move</title>
		<description lang="en">Provides the ability to enter a reason for moving a topic, the ability to display information about the move, and the ability to undo the move.</description>
	    <author-notes lang="en">The option to select where the movement information should be placed is found in the "Board features" section of the "Administration Control Panel".

Support is given for both prosilver and subsilver2 templates. If you are using other templates then you will need to modify the template instructions to fit your templates.

Creating, maintaining, and updating MODs requires a lot of time and effort, so if you like this MOD and have the desire to express your thanks through donations, that would be greatly appreciated. My Paypal ID is primehalo@gmail.com, or contact me for my mailing address. The suggested donation amount for this MOD is $10.00 (but any amount will help).</author-notes>
		<author-group>
			<author>
				<realname>Ken F. Innes IV</realname>
				<email>primehalo@gmail.com</email>
				<username>primehalo</username>
				<homepage><![CDATA[http://www.absoluteanime.com/admin/mods.htm#topic_move]]></homepage>
			</author>
		</author-group>
		<mod-version>1.2.2c</mod-version>
		<installation>
			<level>easy</level>
			<time>300</time>
			<target-version>3.0.6</target-version>
		</installation>
		<history>
			<entry>
				<date>2007-08-17</date>
				<rev-version>0.0.0</rev-version>
				<changelog lang="en">
					<change>Initial test release</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-17</date>
				<rev-version>0.1.0</rev-version>
				<changelog lang="en">
					<change>Added the ability to select where the topic movement details should be placed, if at all.</change>
					<change>Moved a chunk of the code into a separate include file.</change>
					<change>Fixed a bug that caused the ID of the last post in the thread at the time of a move to not be stored in the database.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-18</date>
				<rev-version>0.1.1</rev-version>
				<changelog lang="en">
					<change>Enabled compatibility with another MOD, Prime Recycle Bin.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-22</date>
				<rev-version>0.1.2</rev-version>
				<changelog lang="en">
					<change>Added the ability to display the moved topic information with the shadow link (if one exists) on the forum list.</change>
					<change>Split the ACP options from a dropdown box to separate checkboxes to give more flexibility.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-28</date>
				<rev-version>0.1.2a</rev-version>
				<changelog lang="en">
					<change>Provided the SQL statement to initialize the columns that are added to the topics table.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-22</date>
				<rev-version>0.1.2b</rev-version>
				<changelog lang="en">
					<change>Repackaged.</change>
					<change>Confirmed compatibility with phpBB3.0.RC7.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-11-07</date>
				<rev-version>0.1.3</rev-version>
				<changelog lang="en">
					<change>Fixed an error message that could occur on the confirmation page.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-11-08</date>
				<rev-version>0.1.4</rev-version>
				<changelog lang="en">
					<change>Remove the reason entry field from the confirmation page when copying a message.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-11-09</date>
				<rev-version>0.1.5</rev-version>
				<changelog lang="en">
					<change>Fixed: forgot to label a couple variables as global, which would cause an improper link to be displayed on the moved topic information.</change>
					<change>Fixed: a line of code was attempting to free an SQL query result variable that didn't exist.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-04-26</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en">
					<change>Shortened the name of the MOD to "Prime Topic Moved".</change>
					<change>Moved some of the ACP code into the included PHP file.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-05-03</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="en">
					<change>Fixed a bug that would prevent ACP pages from submitting.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-06-07</date>
				<rev-version>1.0.2</rev-version>
				<changelog lang="en">
					<change>Forgot to include two global variables in the get_msg_moved_topic_to() function.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-02</date>
				<rev-version>1.0.2a</rev-version>
				<changelog lang="en">
					<change>Repackaged for MODX 1.2.0.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-08-18</date>
				<rev-version>1.2.0</rev-version>
				<changelog lang="en">
					<change>Moved most of the code inside of a class structure.</change>
					<change>Fixed a bug where the move information wasn't displayed when selected to display on the last post at the time of the move.</change>
					<change>Reduced the number of code changes.</change>
					<change>Repackaged to fix the Firefox 3 restricted parent directory issue.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-09-23</date>
				<rev-version>1.2.1</rev-version>
				<changelog lang="en">
					<change>Fixed a minor bug where enabling the options to display the moved message on the first post and/or last post would cause the moved message to show up on the first post and/or last post of every page, instead of the actually first post and/or last post.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-05-19</date>
				<rev-version>1.2.2</rev-version>
				<changelog lang="en">
					<change>Fixed a minor bug that could cause an error message to display.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-05-21</date>
				<rev-version>1.2.2a</rev-version>
				<changelog lang="en">
					<change>Fixed a minor mistake in the subsilver2 installation instructions.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-06-08</date>
				<rev-version>1.2.2b</rev-version>
				<changelog lang="en">
					<change>Added a German translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-06-09</date>
				<rev-version>1.2.2c</rev-version>
				<changelog lang="en">
					<change>Updated installation instructions for phpBB 3.0.5.</change>
				</changelog>
			</entry>
		</history>
		<link-group>
			<link type="template" href="contrib/template subsilver2.xml" realname="subsilver2" lang="en">subsilver2</link>
			<link type="language" href="contrib/language de.xml" realname="de" lang="en">German</link>
		</link-group>
	</header>
	<action-group>
		<sql><![CDATA[ALTER TABLE phpbb_topics ADD (
	topic_moved_from mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, 
	topic_moved_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, 
	topic_moved_time int(11) UNSIGNED DEFAULT '0' NOT NULL, 
	topic_moved_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, 
	topic_moved_reason varchar(255) DEFAULT '' NOT NULL
)]]></sql>
		<copy>
			<file from="root/includes/prime_topic_move.php" to="includes/prime_topic_move.php" />
			<file from="root/language/en/mods/prime_topic_move.php" to="language/en/mods/prime_topic_move.php" />
			<file from="root/styles/prosilver/template/prime_topic_move.html" to="styles/prosilver/template/prime_topic_move.html" />
		</copy>
		<open src="includes/acp/acp_board.php">
			<edit>
				<find><![CDATA[		if (isset($display_vars['lang']))]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_topic_move.' . $phpEx);
		$prime_topic_move->display_acp_options($display_vars, $mode);
//-- end: Prime Topic Move --------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[			if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
			if ($submit && $config_name == 'topic_moved_display')
			{
				$prime_topic_move->merge_options($config_name, $cfg_array);
			}
//-- end: Prime Topic Move --------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/mcp/mcp_main.php">
			<edit>
				<find><![CDATA[		$leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false;]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_topic_move.' . $phpEx);
		$prime_topic_move_sql_array = $prime_topic_move->mcp_sql_setup($forum_id);
//-- end: Prime Topic Move --------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[		foreach ($topic_data as $topic_id => $topic_info)
		{
]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
			$prime_topic_move->mcp_sql_execute($topic_info, $prime_topic_move_sql_array);
//-- end: Prime Topic Move --------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[		confirm_box(false, 'MOVE_TOPIC']]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_topic_move.' . $phpEx);
		$prime_topic_move->mcp_assign_template_vars($topic_ids, $forum_id);
//-- end: Prime Topic Move --------------------------------------------------//]]></action>
			</edit>

		</open>

		<open src="viewforum.php">
			<edit>
				<find><![CDATA[		$s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_topic_move.' . $phpEx);
		$prime_topic_move->viewforum_insert_message($row, $forum_id);
//-- end: Prime Topic Move --------------------------------------------------//
]]></action>
			</edit>
		</open>

		<open src="viewtopic.php">
			<edit>
				<find><![CDATA[	if (isset($cp_row['row']) && sizeof($cp_row['row']))]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Topic Move --------------------------------------------------//
	include($phpbb_root_path . 'includes/prime_topic_move.' . $phpEx);
	$prime_topic_move->viewtopic_insert_message($postrow, $topic_data, $i, $end, $viewtopic_url);
//-- end: Prime Topic Move --------------------------------------------------//
]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/mcp_move.html">
			<edit>
				<find><![CDATA[		<dl class="fields2">
			<dt>&nbsp;</dt>
			<dd><strong>{MESSAGE_TEXT}</strong></dd>
		</dl>
]]></find>
		       <action type="before-add"><![CDATA[		<!-- INCLUDE prime_topic_move.html -->]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/viewforum_body.html">
			<edit>
				<find><![CDATA[					<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}]]></find>
				<action type="after-add"><![CDATA[					<!-- IF topicrow.TOPIC_MOVED_MESSAGE -->{topicrow.TOPIC_MOVED_MESSAGE}<!-- ENDIF -->]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/viewtopic_body.html">
			<edit>
				<find><![CDATA[				<div class="ignore">{postrow.L_IGNORE_POST}</div>]]></find>
				<action type="after-add"><![CDATA[				<!-- IF postrow.TOPIC_MOVED_MESSAGE -->{postrow.TOPIC_MOVED_MESSAGE}<!-- ENDIF -->]]></action>
			</edit>

			<edit>
				<find><![CDATA[			<!-- IF postrow.BUMPED_MESSAGE -->]]></find>
				<action type="before-add"><![CDATA[			<!-- IF postrow.TOPIC_MOVED_MESSAGE -->{postrow.TOPIC_MOVED_MESSAGE}<!-- ENDIF -->]]></action>
			</edit>
		</open>

		<diy-instructions lang="en">As an alternative to manually executing the SQL statements, you can use the included 
"db_install.php" (located in the contrib directory). Simply copy the file to the root
directory of your phpbb3 install, and point your web browser to the address. Make 
sure you are logged in as an administrator before you do this, and make sure to
delete the file once you're done.</diy-instructions>
	</action-group>
</mod>
