<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="./contrib/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.0.xsd">
	<header>
		<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
		<title lang="en">Prime Multi-Quote</title>
		<description lang="en">Allows users to quote multiple posts by marking checkboxes located next to each existing quote button.</description>
	    <author-notes lang="en">Requires JavaScript. 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 $5.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#multi_quote]]></homepage>
			</author>
		</author-group>
		<mod-version>1.0.1b</mod-version>
		<installation>
			<level>easy</level>
			<time>180</time>
			<target-version>3.0.1</target-version>
		</installation>
		<history>
			<entry>
				<date>2008-01-07</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en">
					<change>Initial release.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-01-14</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="en">
					<change>Don't display a checkbox if there's only one quotable post on the page.</change>
					<change>Adjust checkboxes so they line up a little better (in the prosilver style).</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-06-15</date>
				<rev-version>1.0.1a</rev-version>
				<changelog lang="en">
					<change>Minor fix to the subsilver2 instructions that would cause the checkbox to show up even when there was only a single post in the thread.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-02</date>
				<rev-version>1.0.1b</rev-version>
				<changelog lang="en">
					<change>Repackaged for MODX 1.2.0.</change>
				</changelog>
			</entry>
		</history>
		<link-group>
			<link type="template" href="contrib/templates/subsilver2.xml" lang="en">subsilver2</link>
		</link-group>
	</header>
	<action-group>
		<copy>
 			<file from="root/styles/prosilver/template/prime_multi_quote.js" to="styles/prosilver/template/prime_multi_quote.js" />
		</copy>

		<open src="posting.php">
			<edit>
				<find><![CDATA[// We need to know some basic information in all cases before we do anything.]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Multi-Quote -------------------------------------------------//
// Get the IDs for the posts that we are going to be quoting.
$prime_multi_quotes = null;
$quote_ids = request_var('quotes', array('' => ''));
if (!empty($quote_ids) && ($mode == 'reply' || $mode == 'quote'))
{
	$prime_multi_quotes = true;
	if ($mode == 'quote' && $post_id && !in_array($post_id, $quote_ids))
	{
		$quote_ids[] = $post_id;
	}
	$mode = 'quote';
	$post_id = !$post_id ? $quote_ids[0] : $post_id;
}
//-- end: Prime Multi-Quote -------------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[				AND u.user_id = p.poster_id
				AND (f.forum_id = t.forum_id
					OR f.forum_id = $forum_id)";]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Multi-Quote -------------------------------------------------//
// Alter the SQL query to include all the posts we are going to be quoting.
		if ($prime_multi_quotes)
		{
			$sql = str_replace("p.post_id = $post_id", $db->sql_in_set('p.post_id', $quote_ids), $sql);
		}
//-- end: Prime Multi-Quote -------------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[$post_data = $db->sql_fetchrow($result);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Multi-Quote -------------------------------------------------//
// Store information for the additional quotes.
if ($prime_multi_quotes)
{
	$prime_multi_quotes = null;
	while ($row = $db->sql_fetchrow($result))
	{
		if (isset($row['poster_id']) && $row['poster_id'] == ANONYMOUS)
		{
			$row['username'] = (!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST'];
		}
		else if (!isset($row['username']))
		{
			$row['username'] = '';
		}
		$prime_multi_quotes[] = array('post_text' => $row['post_text'], 'quote_username' => $row['username'], 'bbcode_uid' => $row['bbcode_uid']); 
	}
	unset($row);
}
//-- end: Prime Multi-Quote -------------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[	$message_parser->message = '[quote=&quot;' . $post_data['quote_username'] . '&quot;]' . censor_text(trim($message_parser->message)) . "[/quote]\n";]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Multi-Quote -------------------------------------------------//
// Add the additional quotes to the message.
	if ($prime_multi_quotes)
	{
		$current_quoted_message = $message_parser->message;
		foreach ($prime_multi_quotes as $quote_data)
		{
			$message_parser->message = &$quote_data['post_text'];
			unset($quote_data['post_text']);
			$message_parser->decode_message($quote_data['bbcode_uid']);
			$current_quoted_message .= "\n[quote=&quot;" . $quote_data['quote_username'] . '&quot;]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
		}
		$message_parser->message = $current_quoted_message;
	}
//-- end: Prime Multi-Quote -------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="viewtopic.php">
			<edit>
				<find><![CDATA[	$prev_post_id = $row['post_id'];]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Multi-Quote -------------------------------------------------//
	$prime_multi_quote_count = !isset($prime_multi_quote_count) ? 1 : ($prime_multi_quote_count + (empty($row['post_deleted_time']) ? 1 : 0));
//-- end: Prime Multi-Quote -------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Multi-Quote -------------------------------------------------//
// Multi-Quote is active if there is more than one quotable post and the user is able to reply (and user is not a bot).
if (isset($prime_multi_quote_count) && $prime_multi_quote_count > 1 && $template->_rootref['S_DISPLAY_REPLY_INFO'] && !$user->data['is_bot'])
{
	$template->assign_var('PRIME_MULTI_QUOTE', $prime_multi_quote_count);
}
//-- end: Prime Multi-Quote -------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/viewtopic_body.html">
			<edit>
				<find><![CDATA[<!-- INCLUDE overall_header.html -->]]></find>
				<action type="after-add"><![CDATA[<!-- IF PRIME_MULTI_QUOTE -->
	<script type="text/javascript" src="{T_TEMPLATE_PATH}/prime_multi_quote.js"></script>
<!-- ENDIF -->]]></action>
			</edit>

			<edit>
				<comment lang="en">This is the first of two identical lines in this file.</comment>
				<find><![CDATA[		<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"]]></find>
				<inline-edit>
					<inline-find><![CDATA[{L_POST_REPLY}<!-- ENDIF -->"]]></inline-find>
					<inline-action type="after-add"><![CDATA[<!-- IF PRIME_MULTI_QUOTE --> onclick="prime_multi_quote(this);"<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>

			<edit>
				<find><![CDATA[<!-- BEGIN postrow -->]]></find>
				<action type="before-add"><![CDATA[<!-- IF PRIME_MULTI_QUOTE --><form action="{U_POST_REPLY_TOPIC}" method="get" name="prime_multi_quote_form" id="prime_multi_quote_form"><!-- ENDIF -->]]></action>
			</edit>

			<edit>
				<comment lang="en">If you want the checkboxes to work only for the Reply buttons and NOT for the Quote buttons, then skip this step.</comment>
				<find><![CDATA[<a href="{postrow.U_QUOTE}" title="{L_REPLY_WITH_QUOTE}"]]></find>
				<inline-edit>
					<inline-find><![CDATA[<a href="{postrow.U_QUOTE}" title="{L_REPLY_WITH_QUOTE}"]]></inline-find>
					<inline-action type="after-add"><![CDATA[<!-- IF PRIME_MULTI_QUOTE --> onclick="prime_multi_quote(this);"<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>

			<edit>
				<find><![CDATA[					<!-- IF postrow.U_QUOTE --><li class="quote-icon"><a href="{postrow.U_QUOTE}" title="{L_REPLY_WITH_QUOTE}"]]></find>
				<action type="after-add"><![CDATA[					<!-- IF PRIME_MULTI_QUOTE --><li><input type="checkbox" name="quotes" value="{postrow.POST_ID}" class="radio" style="width:14px;margin-bottom:-3px;" title="{L_REPLY_WITH_QUOTE}" /></li><!-- ENDIF -->]]></action>
			</edit>

			<edit>
				<find><![CDATA[<!-- END postrow -->]]></find>
				<action type="after-add"><![CDATA[<!-- IF PRIME_MULTI_QUOTE --></form><!-- ENDIF -->]]></action>
			</edit>

			<edit>
				<comment lang="en">This is the second of two identical lines in this file.</comment>
				<find><![CDATA[		<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"]]></find>
				<inline-edit>
					<inline-find><![CDATA[{L_POST_REPLY}<!-- ENDIF -->"]]></inline-find>
					<inline-action type="after-add"><![CDATA[<!-- IF PRIME_MULTI_QUOTE --> onclick="prime_multi_quote(this);"<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>
		</open>
	</action-group>
</mod>