<?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 Post Revisions</title>
		<description lang="en">Stores each revision of a post every time a post is edited. It will only make these past revisions viewable to those users who have the necessary permissions.</description>
	    <author-notes lang="en">This MOD works independent of which styles are used. Options can be configured from within the "includes/prime_post_revisions.php" file.

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#post_revisions]]></homepage>
			</author>
		</author-group>
		<mod-version>1.2.7</mod-version>
		<installation>
			<level>easy</level>
			<time>600</time>
			<target-version>3.0.8</target-version>
		</installation>
		<history>
			<entry>
				<date>2007-08-02</date>
				<rev-version>0.0.0</rev-version>
				<changelog lang="en">
					<change>Initial test release</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-15</date>
				<rev-version>0.0.1</rev-version>
				<changelog lang="en">
					<change>Removed the Quick-mod tools dropdown box from the post revisions page.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-28</date>
				<rev-version>0.0.2</rev-version>
				<changelog lang="en">
					<change>Don't store a revision if neither the message nor the subject has changed (disregarding leading and trailing white-spaces).</change>
					<change>Fix a bug where, when viewing the post history, the links that were supposed to lead to back to the original post would instead lead back to the first post of the topic.</change>
					<change>Now when viewing the post history the page title contains the post subject and not the topic title.</change>
					<change>Removed two duplicate SQL queries that happened once for each post with a single SQL query that happens once per topic.</change>
					<change>Corrected a mistake with the installation instructions.</change>
					<change>Gave default values to ALL of the columns added by the SQL statement that's required during installation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-09-06</date>
				<rev-version>0.0.3</rev-version>
				<changelog lang="en">
					<change>Revised slightly so that a UNION of two SQL statements is no longer used.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-22</date>
				<rev-version>0.0.3a</rev-version>
				<changelog lang="en">
					<change>Updated for compatibility with phpBB3.0.RC7.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-11</date>
				<rev-version>0.0.4</rev-version>
				<changelog lang="en">
					<change>Changed the storage type for the message from mediumtext to mediumblob, matching what the forum uses for messages.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-06-24</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en">
					<change>Moved a majority of the code to an external file, and inside of a class structure.</change>
					<change>Added the ability to delete individual revisions.</change>
					<change>Added the ability to set some options.</change>
					<change>Fixed a bug that prevented the "last edited by" information from being displayed.</change>
					<change>Repackaged for MODX 1.2.0.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-11</date>
				<rev-version>1.0.0a</rev-version>
				<changelog lang="en">
					<change>Added a Dutch translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-11</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="en">
					<change>Fixed a bug where occasionally an editor's name would be displayed as "Guest".</change>
					<change>Verified to work with phpBB 3.0.2 (as well as 3.0.1).</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-21</date>
				<rev-version>1.2.0</rev-version>
				<changelog lang="en">
					<change>Fixed a minor bug in an SQL statement.</change>
					<change>Added a language string for when a post has no subject.</change>
					<change>Added an option to delete all revisions (will not delete the actual post).</change>
					<change>Added an option to undo the most recent revision to the post.</change>
					<change>Correctly update the edit time, user, and reason when deleting a revision.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-21</date>
				<rev-version>1.2.1</rev-version>
				<changelog lang="en">
					<change>Fixed a minor bug that would occasionally cease to display the link to undo the most recent revision.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-22</date>
				<rev-version>1.2.1a</rev-version>
				<changelog lang="en">
					<change>Added a German translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-23</date>
				<rev-version>1.2.2</rev-version>
				<changelog lang="en">
					<change>Fixed a bug that would, on rare occasions, cause a minor error to happen when viewing the post history.</change>
					<change>Some minor code optimization.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-09-24</date>
				<rev-version>1.2.3</rev-version>
				<changelog lang="en">
					<change>Fixed a bug that would cause a revision to be stored even when neither the subject nor message had been changed.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-01-15</date>
				<rev-version>1.2.4</rev-version>
				<changelog lang="en">
					<change>Fixed a minor bug (changed $php_root_path to $phpbb_root_path).</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-06-08</date>
				<rev-version>1.2.4a</rev-version>
				<changelog lang="en">
					<change>Added a Slovak translation.</change>
					<change>Added a Brazilian Portuguese translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-10-02</date>
				<rev-version>1.2.4b</rev-version>
				<changelog lang="en">
					<change>Added an Arabic translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-12-08</date>
				<rev-version>1.2.4c</rev-version>
				<changelog lang="en">
					<change>Added a Polish translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2010-02-06</date>
				<rev-version>1.2.5</rev-version>
				<changelog lang="en">
					<change>Added a template variable to indicate viewing of a topic's revisions rather than a topic's posts.</change>
				</changelog>
			</entry>
			<entry>
				<date>2010-06-03</date>
				<rev-version>1.2.5a</rev-version>
				<changelog lang="en">
					<change>Added a Russian translation.</change>
					<change>Added compatibility instructions for another MOD, xMave's Ajax Quick Edit.</change>
				</changelog>
			</entry>
			<entry>
				<date>2010-07-09</date>
				<rev-version>1.2.5b</rev-version>
				<changelog lang="en">
					<change>Added a French translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2010-08-07</date>
				<rev-version>1.2.5c</rev-version>
				<changelog lang="en">
					<change>Added a Formal German translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2010-12-31</date>
				<rev-version>1.2.5d</rev-version>
				<changelog lang="en">
					<change>Added a Spanish translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2011-01-31</date>
				<rev-version>1.2.6</rev-version>
				<changelog lang="en">
					<change>Fixed it so that warnings should no longer occur if the prime_post_revisions.php files is accidentally included multiple times.</change>
					<change>Replaced the two separate files for installing/uninstalling the database updates with a single file containing a form that also lets you preview the database changes.</change>
				</changelog>
			</entry>
			<entry>
				<date>2011-03-01</date>
				<rev-version>1.2.7</rev-version>
				<changelog lang="en">
					<change>Added an Italian translation.</change>
					<change>Very minor code changes.</change>
				</changelog>
			</entry>
		</history>
		<link-group>
			<link type="contrib" href="./contrib/Add-on for AJAX Quick Edit.xml" lang="en">Add-on for AJAX Quick Edit</link>
			<link type="contrib" href="./contrib/update 1.2.5 to 1.2.6.xml" lang="en">Upgrade 1.2.5 to 1.2.6</link>
			<link type="contrib" href="./contrib/update 1.2.4 to 1.2.5.xml" lang="en">Upgrade 1.2.4 to 1.2.5</link>
			<link type="contrib" href="./contrib/update 1.2.3 to 1.2.4.xml" lang="en">Upgrade 1.2.3 to 1.2.4</link>
			<link type="contrib" href="./contrib/update 1.2.2 to 1.2.3.xml" lang="en">Upgrade 1.2.2 to 1.2.3</link>
			<link type="contrib" href="./contrib/update 1.0.0 to 1.0.1.xml" lang="en">Upgrade 1.0.0 to 1.0.1</link>
			<link type="contrib" href="./contrib/update 0.0.3 to 1.0.0.xml" lang="en">Upgrade 0.0.3 to 1.0.0</link>

			<link type="language" href="./contrib/language - ar.xml" realname="ar" lang="en">Arabic</link>
			<link type="language" href="./contrib/language - de.xml" realname="de" lang="en">German</link>
			<link type="language" href="./contrib/language - de_x_sie.xml" realname="de_x_sie" lang="en">German (formal)</link>
			<link type="language" href="./contrib/language - es.xml" realname="es" lang="en">Spanish</link>
			<link type="language" href="./contrib/language - fr.xml" realname="fr" lang="en">French</link>
			<link type="language" href="./contrib/language - it.xml" realname="it" lang="en">Italian</link>
			<link type="language" href="./contrib/language - nl.xml" realname="nl" lang="en">Dutch</link>
			<link type="language" href="./contrib/language - pl.xml" realname="pl" lang="en">Polish</link>
			<link type="language" href="./contrib/language - pt_br.xml" realname="pt_br" lang="en">Brazilian Portuguese</link>
			<link type="language" href="./contrib/language - ru.xml" realname="ru" lang="en">Russian</link>
			<link type="language" href="./contrib/language - sk.xml" realname="sk" lang="en">Slovak</link>
		</link-group>
	</header>
	<action-group>
		<php-installer>update_db.php</php-installer>
		
		<copy>
			<file from="root/update_db.php" to="update_db.php" />
			<file from="root/includes/prime_post_revisions.php" to="includes/prime_post_revisions.php" />
			<file from="root/language/en/mods/prime_post_revisions.php" to="language/en/mods/prime_post_revisions.php" />
		</copy>

		<open src="includes/constants.php">
			<edit>
				<find><![CDATA[define('POSTS_TABLE',				$table_prefix . 'posts');]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
define('POST_REVISIONS_TABLE',		$table_prefix . 'post_revisions');
//-- end: Prime Post Revisions ----------------------------------------------//]]></action>
			</edit>
		</open>


		<open src="includes/functions_admin.php">
			<edit>
				<find>	$table_ary = array(POSTS_TABLE, REPORTS_TABLE);</find>
				<action type="after-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
	$table_ary[] = POST_REVISIONS_TABLE; // To delete the post's edit history
//-- end: Prime Post Revisions ----------------------------------------------//]]></action>
			</edit>
		</open>


		<open src="posting.php">
			<edit>
				<find>				$data['topic_replies'] = $post_data['topic_replies'];</find>
				<action type="after-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
				include($phpbb_root_path . 'includes/prime_post_revisions.' . $phpEx);
				store_post_revision_info($data, $post_data);
//-- end: Prime Post Revisions ----------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="viewtopic.php">
			<edit>
				<find><![CDATA[$max_post_time = 0;]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
include($phpbb_root_path . 'includes/prime_post_revisions.' . $phpEx);
$prime_post_revisions = new prime_post_revisions($post_list, $forum_id, $topic_id, $post_id);
//-- end: Prime Post Revisions ----------------------------------------------//]]></action>
			</edit>

			<edit>
				<find>// Posts are stored in the $rowset</find>
				<action type="before-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
$prime_post_revisions->get_revision_info($post_list, $result, $viewtopic_url, $viewtopic_title);
//-- end: Prime Post Revisions ----------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[// and the global bbcode_bitfield are built
while ($row = $db->sql_fetchrow($result))
{
]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
	$prime_post_revisions->merge_revision_info($post_list, $result, $row);
//-- end: Prime Post Revisions ----------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find>	// Editing information</find>
				<action type="before-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
	$prime_post_revisions->set_edit_count($row);
//-- end: Prime Post Revisions ----------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[		$l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
		$prime_post_revisions->inject_user_data($row);
//-- end: Prime Post Revisions ----------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[	if (isset($cp_row['row']) && sizeof($cp_row['row']))]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Post Revisions ----------------------------------------------//
	$prime_post_revisions->update_postrow($post_list, $i, $rowset, $postrow);
//-- end: Prime Post Revisions ----------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[page_header($user->lang['VIEW_TOPIC']]]></find>
				<action type="after-add"><![CDATA[
//-- mod: Prime Post Revisions ----------------------------------------------//
$prime_post_revisions->assign_template_variables($viewtopic_url, $viewtopic_title);
//-- end: Prime Post Revisions ----------------------------------------------//]]></action>
			</edit>
		</open>

		<diy-instructions lang="en">Make sure to delete the update_db.php file once the database updates are complete.</diy-instructions>

	</action-group>
</mod>
