<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
	<id>fustrate:toksta</id>
	<version>1.0.1</version>

<file name="$themedir/index.template.php">
	<operation>
		<search position="after"><![CDATA[
</body>]]></search>
		<add><![CDATA[';

	if (!$context['user']['is_guest'] && !empty($modSettings['toksta_enable']) && !empty($modSettings['toksta_id']) && !empty($modSettings['toksta_pass'])){
		//Generate the user_data string
		$tk_user_data = "name:" . str_replace(array(':', ';'), '', $context['user']['name']) . ";gender:;age:;single:;url:" . $scripturl . "?action=profile&u=" . $context['user']['id'] . ";pic:" . (isset($context['user']['avatar']['href']) ? str_replace(";", "&", $context['user']['avatar']['href']) : "") . ";city:;zip:;country:";
		$tk_hash = md5($context['user']['id'] . $modSettings['toksta_pass']);

		echo '
	<script language="JavaScript" type="text/javascript">
	var TOKSTA_CONFIG = {
		app_id : "', $modSettings['toksta_id'], '",
		user_id: "', $context['user']['id'], '",
		user_hash: "', $tk_hash, '",
		user_data: "', $tk_user_data, '",
		generated : "1240698402",
		im : {
			advanced_search : ["gender","age","city","country","single"]', !empty($modSettings['toksta_logo']) ? ',
			design : {
				logoImageURL : "' . $modSettings['toksta_logo'] . '"
			}' : '', '
		},
		chatbar : {
			showUserData : ["gender","age"]
		}
	};
	</script>
	<script language="JavaScript" type="text/javascript" src="http://embed.toksta.com/embed/toksta.js"></script>';
	}

	echo ']]></add>
	</operation>
</file>

<file name="$themedir/Profile.template.php">
	<operation>
		<search position="before"><![CDATA[
				<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '">', $txt['profileSendIm'], '</a><br />';]]></search>
		<add><![CDATA[
	if (!$context['user']['is_owner'] && $context['can_send_pm'] && !empty($modSettings['toksta_enable']))
		echo '
				<a href="#" onclick="tokstaChat(\'', $context['member']['id'], '\')">', $txt['toksta_chat_with'], '</a><br />
				<br />';]]></add>
	</operation>
</file>

<file name="$sourcedir/ManageSettings.php">
	<operation>
		<search position="before"><![CDATA[
			array('int', 'max_image_height'),]]></search>
		<add><![CDATA[
		'',
			// Toksta settings
			array('check', 'toksta_enable'),
			array('text', 'toksta_pass'),
			array('int', 'toksta_id'),
		'',]]></add>
	</operation>
</file>

<file name="$languagedir/Modifications.english.php">
	<operation>
		<search position="end" />
		<add><![CDATA[
$txt['toksta_chat_with'] = 'Toksta IM with this member.';
$txt['toksta_enable'] = 'Enable Toksta IM';
$txt['toksta_pass'] = 'App Password';
$txt['toksta_id'] = 'App ID';
$txt['toksta_logo'] = 'Optional Toksta Logo URL';]]></add>
	</operation>
</file>

<file name="$languagedir/Modifications.english-utf8.php" error="skip">
	<operation>
		<search position="end" />
		<add><![CDATA[
$txt['toksta_chat_with'] = 'Toksta IM with this member.';
$txt['toksta_enable'] = 'Enable Toksta IM';
$txt['toksta_pass'] = 'App Password';
$txt['toksta_id'] = 'App ID';
$txt['toksta_logo'] = 'Optional Toksta Logo URL';]]></add>
	</operation>
</file>
</modification>
