<modification>
	<name>Email Templates Core</name>
	<code>emailtemplates_core</code>
	<version>3.0.5.91</version>
	<author>Opencart-Templates</author>
	<link>https://www.opencart-templates.co.uk/advanced_professional_email_template</link>

	<file path="system/library/language.php">
		<operation>
			<search><![CDATA[$file = DIR_LANGUAGE]]></search>
			<ignoreif><![CDATA[$file = $this->path]]></ignoreif>
			<add position="replace"><![CDATA[$file = $this->path]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[private $directory;]]></search>
			<ignoreif><![CDATA[private $path = DIR_LANGUAGE;]]></ignoreif>
			<add position="after"><![CDATA[private $path = DIR_LANGUAGE;]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function get($key]]></search>
			<ignoreif><![CDATA[public function setPath($path)]]></ignoreif>
			<add position="before"><![CDATA[	public function setPath($path) {
		if (!is_dir($path)) {
			trigger_error('Error: check path exists: '.$path);
			exit;
		}

		$this->path = $path;
	}
	]]></add>
		</operation>
	</file>

	<file path="system/library/mail.php">
		<operation>
			<search index="0"><![CDATA[protected $subject;]]></search>
			<ignoreif><![CDATA[protected $bcc;]]></ignoreif>
			<add position="before"><![CDATA[	protected $bcc;]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[protected $subject;]]></search>
			<ignoreif><![CDATA[protected $cc;]]></ignoreif>
			<add position="before"><![CDATA[	protected $cc;]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[protected $subject;]]></search>
			<ignoreif><![CDATA[protected $mail_queue;]]></ignoreif>
			<add position="before"><![CDATA[	protected $mail_queue;]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[protected $subject;]]></search>
			<ignoreif><![CDATA[protected $mail_send;]]></ignoreif>
			<add position="before"><![CDATA[	protected $mail_send;]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[protected $subject;]]></search>
			<ignoreif><![CDATA[protected $reply_to_name;]]></ignoreif>
			<add position="before"><![CDATA[	protected $reply_to_name;]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send(]]></search>
			<ignoreif><![CDATA[public function setMailQueue(]]></ignoreif>
			<add position="before"><![CDATA[	public function setMailQueue($option) {
		$this->mail_queue = (bool)$option;
	}]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send(]]></search>
			<ignoreif><![CDATA[public function setMailSend(]]></ignoreif>
			<add position="before"><![CDATA[	public function setMailSend($option) {
		$this->mail_send = (bool)$option;
	}]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send(]]></search>
			<ignoreif><![CDATA[public function getSubject(]]></ignoreif>
			<add position="before"><![CDATA[	public function getSubject() {
		return $this->subject;
	}]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send(]]></search>
			<ignoreif><![CDATA[public function setCc(]]></ignoreif>
			<add position="before"><![CDATA[
	public function setCc($address) {
		$this->cc = $address;
	}]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send(]]></search>
			<ignoreif><![CDATA[public function setBcc(]]></ignoreif>
			<add position="before"><![CDATA[
	public function setBcc($address) {
		$this->bcc = $address;
	}]]></add>
		</operation>
		<operation error="skip">
			<search index="0"><![CDATA[public function setReplyTo($reply_to) {]]></search>
			<add position="replace"><![CDATA[public function setReplyTo($reply_to, $reply_to_name = '') {
		if ($reply_to_name) {
			$this->reply_to_name = $reply_to_name;
		}
	]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send(]]></search>
			<ignoreif><![CDATA[public function getMailProperties(]]></ignoreif>
			<add position="before"><![CDATA[
	public function getMailProperties() {
		return array(
			'mail_queue' => $this->mail_queue,
			'smtp' => array(
				'hostname' => $this->smtp_hostname,
				'username' => $this->smtp_username,
				//'password' => $this->smtp_password,
				'post' => $this->smtp_port,
				'timeout' => $this->smtp_timeout
			),
			//'protocol' => $this->protocol,
			'parameter' => $this->parameter,
			'attachments' => $this->attachments,
			'to' => $this->to,
			'from' => $this->from,
			'sender' => $this->sender,
			'reply_to' => $this->reply_to,
			'reply_to_name' => $this->reply_to_name,
			'cc' => $this->cc,
			'bcc' => $this->bcc,
			'subject' => $this->subject,
			'text' => $this->text
		);
	}
	]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function send() {]]></search>
			<ignoreif><![CDATA[if ($this->mail_queue) return true;]]></ignoreif>
			<add position="after"><![CDATA[		if ($this->mail_send === false) {
			return true; // unsubscribed
		}

		if ($this->mail_queue) {
			return true; // send later via cron
		}
]]></add>
		</operation>
	</file>

	<file path="system/library/mail/{smtp,mail}.php">
		<operation>
			<search index="0"><![CDATA[$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->reply_to) . '?= <' . $this->reply_to . '>' . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[
			if (!empty($this->reply_to_name)) {
				$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->reply_to_name) . '?= <' . $this->reply_to . '>' . PHP_EOL;
			} else {
				$header .= 'Reply-To: ' . $this->reply_to . PHP_EOL;
			}
		]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[$header .= 'Return-Path]]></search>
			<ignoreif><![CDATA[$header .= 'CC: ' . $this->cc . PHP_EOL;]]></ignoreif>
			<add position="before"><![CDATA[
		if ($this->cc) {
			$header .= 'CC: ' . $this->cc . PHP_EOL;
		}
		]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[$header .= 'Return-Path]]></search>
			<ignoreif><![CDATA[$header .= 'BCC: ' . $this->bcc . PHP_EOL;]]></ignoreif>
			<add position="before"><![CDATA[
		if ($this->bcc) {
			$header .= 'BCC: ' . $this->bcc . PHP_EOL;
		}
		]]></add>
		</operation>
	</file>

	<file path="system/library/cache.php">
		<operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function getAllKeys(]]></ignoreif>
			<add position="before"><![CDATA[
		public function getAllKeys() {
			return $this->adaptor->getAllKeys();
		}]]></add>
		</operation>
	    <operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function flush(]]></ignoreif>
			<add position="before"><![CDATA[
		public function flush() {
			return $this->adaptor->flush();
		}]]></add>
		</operation>
	</file>
	<file path="system/library/cache/apc.php">
		<operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function getAllKeys(]]></ignoreif>
			<add position="before"><![CDATA[
		public function getAllKeys() {
			if (!$this->active) {
				return false;
			}

			$cache_info = apc_cache_info('user');
			return $cache_info['cache_list'];
		}]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function flush(]]></ignoreif>
			<add position="before"><![CDATA[
		public function flush() {
			apc_cache_clear();
		}]]></add>
		</operation>
	</file>
	<file path="system/library/cache/mem.php">
		<operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function getAllKeys(]]></ignoreif>
			<add position="before"><![CDATA[
		public function getAllKeys() {
		    if (!method_exists($this->memcache, 'getAllKeys')) {
		        return false;
		    }
			return $this->memcache->getAllKeys();
		}]]></add>
		</operation>
	    <operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function flush(]]></ignoreif>
			<add position="before"><![CDATA[
		public function flush() {
			return $this->memcache->flush();
		}]]></add>
		</operation>
	</file>
	<file path="system/library/cache/memcached.php" error="skip">
		<operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function getAllKeys(]]></ignoreif>
			<add position="before"><![CDATA[
		public function getAllKeys() {
		    if (!method_exists($this->memcached, 'getAllKeys')) {
		        return false;
		    }
			return $this->memcached->getAllKeys();
		}]]></add>
		</operation>
	    <operation>
			<search index="0"><![CDATA[public function get(]]></search>
			<ignoreif><![CDATA[public function flush(]]></ignoreif>
			<add position="before"><![CDATA[
		public function flush() {
			return $this->memcached->flush();
		}]]></add>
		</operation>
	</file>

    <file path="system/library/db/mssql.php" error="skip">
        <operation error="skip">
            <search index="0"><![CDATA[$this->connection->exec("SET NAMES 'utf8'");]]></search>
            <add position="replace"><![CDATA[$this->connection->exec("SET NAMES 'utf8mb4'");]]></add>
        </operation>
        <operation error="skip">
            <search index="0"><![CDATA[$this->connection->exec("SET CHARACTER SET utf8");]]></search>
            <add position="replace"><![CDATA[$this->connection->exec("SET CHARACTER SET utf8mb4");]]></add>
        </operation>
        <operation error="skip">
            <search index="0"><![CDATA[$this->connection->exec("SET CHARACTER_SET_CONNECTION=utf8");]]></search>
            <add position="replace"><![CDATA[$this->connection->exec("SET CHARACTER_SET_CONNECTION=utf8mb4");]]></add>
        </operation>
    </file>
    <file path="system/library/db/mssql.php" error="skip">
        <operation error="skip">
            <search index="0"><![CDATA[mssql_query("SET NAMES 'utf8'", $this->connection);]]></search>
            <add position="replace"><![CDATA[mssql_query("SET NAMES 'utf8mb4'", $this->connection);]]></add>
        </operation>
        <operation error="skip">
            <search index="0"><![CDATA[mssql_query("SET CHARACTER SET utf8", $this->connection);]]></search>
            <add position="replace"><![CDATA[mssql_query("SET CHARACTER SET utf8mb4", $this->connection);]]></add>
        </operation>
    </file>
    <file path="system/library/db/mysql.php" error="skip">
        <operation error="skip">
            <search index="0"><![CDATA[mysql_query("SET NAMES 'utf8'", $this->connection);]]></search>
            <add position="replace"><![CDATA[mysql_query("SET NAMES 'utf8mb4'", $this->connection);]]></add>
        </operation>
        <operation error="skip">
            <search index="0"><![CDATA[mysql_query("SET CHARACTER SET utf8", $this->connection);]]></search>
            <add position="replace"><![CDATA[mysql_query("SET CHARACTER SET utf8mb4", $this->connection);]]></add>
        </operation>
        <operation error="skip">
            <search index="0"><![CDATA[mysql_query("SET CHARACTER_SET_CONNECTION=utf8", $this->connection);]]></search>
            <add position="replace"><![CDATA[mysql_query("SET CHARACTER_SET_CONNECTION=utf8mb4", $this->connection);]]></add>
        </operation>
    </file>
    <file path="system/library/db/mysqli.php" error="skip">
        <operation error="skip">
            <search index="0"><![CDATA[$this->connection->set_charset("utf8");]]></search>
            <add position="replace"><![CDATA[$this->connection->set_charset("utf8mb4");]]></add>
        </operation>
    </file>
    <file path="system/library/db/postgre.php" error="skip">
        <operation error="skip">
            <search index="0"><![CDATA[pg_query($this->link, "SET CLIENT_ENCODING TO 'UTF8'");]]></search>
            <add position="replace"><![CDATA[pg_query($this->link, "SET CLIENT_ENCODING TO 'UTF8MB4'");]]></add>
        </operation>
    </file>

    <file path="catalog/controller/account/order.php">
        <operation error="skip">
            <search index="0"><![CDATA[nl2br($result['comment'])]]></search>
            <add position="replace"><![CDATA[($result['notify'] ? html_entity_decode($result['comment'], ENT_QUOTES, 'UTF-8') : '')]]></add>
        </operation>
    </file>

	<file path="catalog/model/checkout/order.php">
		<operation error="log">
			<search index="0"><![CDATA[$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET]]></search>
			<ignoreif>
				<![CDATA[weight = '" . (isset($data['weight']) ? floatval($data['weight']) : 0) . "',]]></ignoreif>
			<add position="replace">
				<![CDATA[$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET weight = '" . (isset($data['weight']) ? floatval($data['weight']) : 0) . "',]]></add>
		</operation>
		<operation error="log">
			<search index="0"><![CDATA[=> $order_query->row['customer_id'],]]></search>
			<ignoreif><![CDATA['weight' => (isset($order_query->row['weight'])) ? $order_query->row['weight'] : 0,]]></ignoreif>
			<add position="after"><![CDATA[            	'weight' => (isset($order_query->row['weight'])) ? $order_query->row['weight'] : 0,]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[=> $order_query->row['customer_id'],]]></search>
			<ignoreif><![CDATA['customer_group_id' => (isset($order_query->row['customer_group_id'])) ? $order_query->row['customer_group_id'] : '',]]></ignoreif>
			<add position="after"><![CDATA[				'customer_group_id' => (isset($order_query->row['customer_group_id'])) ? $order_query->row['customer_group_id'] : '',]]></add>
		</operation>
		<operation>
			<search index="0"><![CDATA[=> $order_query->row['customer_id'],]]></search>
			<ignoreif>
				<![CDATA['affiliate_id' => (isset($order_query->row['affiliate_id'])) ? $order_query->row['affiliate_id'] : '',]]></ignoreif>
			<add position="after">
				<![CDATA[				'affiliate_id' => (isset($order_query->row['affiliate_id'])) ? $order_query->row['affiliate_id'] : '',]]></add>
		</operation>
	</file>

	<file path="catalog/controller/affiliate/login.php">
		<operation error="skip">
			<search index="0"><![CDATA[$data['email'] = $this->request->post['email'];]]></search>
			<ignoreif><![CDATA[elseif (isset($this->request->get['email']))]]></ignoreif>
			<add position="after"><![CDATA[		} elseif (isset($this->request->get['email'])) {
			$data['email'] = $this->request->get['email'];]]></add>
		</operation>
	</file>

	<file path="catalog/controller/account/login.php">
		<operation error="skip">
			<search index="0"><![CDATA[$data['email'] = $this->request->post['email'];]]></search>
			<ignoreif><![CDATA[elseif (isset($this->request->get['email']))]]></ignoreif>
			<add position="after"><![CDATA[		} elseif (isset($this->request->get['email'])) {
			$data['email'] = $this->request->get['email'];]]></add>
		</operation>
	</file>

	<file path="admin/controller/startup/permission.php">
		<operation error="skip">
			<search index="0"><![CDATA['extension/module']]></search>
			<ignoreif><![CDATA['extension/module/emailtemplate']]></ignoreif>
			<add position="before"><![CDATA[				'extension/module/emailtemplate',]]></add>
		</operation>
	</file>

	<file path="admin/controller/common/column_left.php">
		<operation>
			<search index="0"><![CDATA[if ($marketplace) {]]></search>
			<ignoreif><![CDATA[$this->url->link('extension/module/emailtemplate',]]></ignoreif>
			<add position="before"><![CDATA[            if ($this->user->hasPermission('access', 'extension/module/emailtemplate')) {
                $marketplace[] = array(
                    'name'     => $this->language->get('text_emailtemplate'),
                    'href'     => $this->url->link('extension/module/emailtemplate', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
            }
        ]]></add>
		</operation>
	</file>

	<file path="admin/language/*/common/column_left.php">
		<operation>
			<search index="0"><![CDATA[<?php]]></search>
			<ignoreif><![CDATA[$_['text_emailtemplate']]]></ignoreif>
			<add position="after"><![CDATA[$_['text_emailtemplate'] = 'Email Templates';]]></add>
		</operation>
	</file>
</modification>
