Version Notes
Optimisation of the SwiftERM emails.
Download this release
Release Info
Developer | Simon Cooper |
Extension | Swift_Swiftplugin |
Version | 1.1.14 |
Comparing to | |
See all releases |
Code changes from version 1.1.13 to 1.1.14
app/code/community/Swift/Swiftplugin/controllers/MailController.php
CHANGED
@@ -12,54 +12,58 @@ class Swift_Swiftplugin_MailController extends Mage_Core_Controller_Front_Action
|
|
12 |
if (isset($postData['version']) && isset($postData['domain']) && isset($postData['data'])) {
|
13 |
$key = hex2bin(Mage::helper('swift/Data')->getSwiftPrivateKey());
|
14 |
try {
|
15 |
-
$
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
$mail = Mage::getModel('core/email');
|
40 |
-
//$mail = Mage::getModel('core/email_template');
|
41 |
-
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect(array('firstname','lastname','email'))->getItemsByColumnValue('email', $emailTo);
|
42 |
-
if (count($collection) > 1) {
|
43 |
-
foreach($collection as $colKey => $customer) {
|
44 |
-
$customerData = $customer->getData();
|
45 |
-
// if present
|
46 |
-
$mail->setToName($customerData['firstname'] . ' ' . $customerData['lastname']);
|
47 |
-
break;
|
48 |
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
$mail->send();
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
echo 'data recieved and email sent';
|
65 |
}
|
12 |
if (isset($postData['version']) && isset($postData['domain']) && isset($postData['data'])) {
|
13 |
$key = hex2bin(Mage::helper('swift/Data')->getSwiftPrivateKey());
|
14 |
try {
|
15 |
+
$emailPackage = SwiftAPI::Decode($postData['version'], $postData['domain'], $postData['data'], $key);
|
16 |
+
|
17 |
+
foreach($emailPackage->emailPackage as $emailContent) {
|
18 |
+
|
19 |
+
$body = $emailContent->body;
|
20 |
+
$emailTo = $emailContent->email;
|
21 |
+
$subject = $emailContent->subject;
|
22 |
+
|
23 |
+
|
24 |
+
$setReturnPath = Mage::getStoreConfig(self::XML_PATH_SENDING_SET_RETURN_PATH);
|
25 |
+
switch ($setReturnPath) {
|
26 |
+
case 1:
|
27 |
+
$returnPathEmail = Mage::getStoreConfig('trans_email/ident_sales/email');
|
28 |
+
break;
|
29 |
+
case 2:
|
30 |
+
$returnPathEmail = Mage::getStoreConfig(self::XML_PATH_SENDING_RETURN_PATH_EMAIL);
|
31 |
+
break;
|
32 |
+
default:
|
33 |
+
$returnPathEmail = null;
|
34 |
+
break;
|
35 |
+
}
|
36 |
|
37 |
+
if ($returnPathEmail !== null) {
|
38 |
+
$mailTransport = new Zend_Mail_Transport_Sendmail("-f".$returnPathEmail);
|
39 |
+
Zend_Mail::setDefaultTransport($mailTransport);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
+
|
42 |
+
$mail = Mage::getModel('core/email');
|
43 |
+
//$mail = Mage::getModel('core/email_template');
|
44 |
+
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect(array('firstname','lastname','email'))->getItemsByColumnValue('email', $emailTo);
|
45 |
+
if (count($collection) > 1) {
|
46 |
+
foreach($collection as $colKey => $customer) {
|
47 |
+
$customerData = $customer->getData();
|
48 |
+
// if present
|
49 |
+
$mail->setToName($customerData['firstname'] . ' ' . $customerData['lastname']);
|
50 |
+
break;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
$mail->setToEmail($emailTo);
|
55 |
+
$mail->setBody($body);
|
56 |
+
$mail->setSubject($subject);
|
57 |
+
$mail->setFromEmail(Mage::getStoreConfig('trans_email/ident_sales/email'));
|
58 |
+
$mail->setReturnPath(Mage::getStoreConfig('trans_email/ident_sales/email'));
|
59 |
+
$mail->setFromName(Mage::getStoreConfig('trans_email/ident_sales/name'));
|
60 |
+
$mail->setType('html');// You can use 'html' or 'text'
|
61 |
$mail->send();
|
62 |
+
if (property_exists($emailContent, 'monitor') && filter_var( $emailContent->monitor, FILTER_VALIDATE_EMAIL)) {
|
63 |
+
$mail->setToEmail($emailContent->monitor);
|
64 |
+
$mail->setSubject($emailTo.'_'.$subject);
|
65 |
+
$mail->send();
|
66 |
+
}
|
67 |
}
|
68 |
echo 'data recieved and email sent';
|
69 |
}
|
app/code/community/Swift/Swiftplugin/etc/config.xml
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
<modules>
|
6 |
<!-- This must exactly match the namespace and module's folder names, with directory separators replaced by underscores -->
|
7 |
<Swift_Swiftplugin>
|
8 |
-
<version>1.1.
|
9 |
</Swift_Swiftplugin>
|
10 |
</modules>
|
11 |
<!-- Configure our module's behavior in the frontend scope -->
|
5 |
<modules>
|
6 |
<!-- This must exactly match the namespace and module's folder names, with directory separators replaced by underscores -->
|
7 |
<Swift_Swiftplugin>
|
8 |
+
<version>1.1.14</version>
|
9 |
</Swift_Swiftplugin>
|
10 |
</modules>
|
11 |
<!-- Configure our module's behavior in the frontend scope -->
|
lib/SwiftAPI/SwiftAPI.php
CHANGED
@@ -23,6 +23,7 @@ class SwiftAPI
|
|
23 |
const OPERATION_SENDMAIL = 'sendmail';
|
24 |
const OPERATION_UNSUBSCRIBE = 'unsubscribe';
|
25 |
const OPERATION_PING = 'ping';
|
|
|
26 |
|
27 |
const SWIFTAPI_CRM_URL = '//api.swiftcrm.net';
|
28 |
|
@@ -46,7 +47,7 @@ class SwiftAPI
|
|
46 |
|
47 |
// Encrypt data and trim trailing NULL bytes.
|
48 |
$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $json, MCRYPT_MODE_CBC, $iv);
|
49 |
-
|
50 |
// Base64 encode message.
|
51 |
if(!($msg = base64_encode($iv . $data)))
|
52 |
throw new SwiftAPI_Exception('SwiftAPI::Encode(): Failed to base64 encode message.');
|
@@ -155,6 +156,38 @@ class SwiftAPI
|
|
155 |
</script>';
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
////////////////////////////////////
|
160 |
// Public: UserID()
|
23 |
const OPERATION_SENDMAIL = 'sendmail';
|
24 |
const OPERATION_UNSUBSCRIBE = 'unsubscribe';
|
25 |
const OPERATION_PING = 'ping';
|
26 |
+
const OPERATION_EMAILPACKAGE = 'emailpackage';
|
27 |
|
28 |
const SWIFTAPI_CRM_URL = '//api.swiftcrm.net';
|
29 |
|
47 |
|
48 |
// Encrypt data and trim trailing NULL bytes.
|
49 |
$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $json, MCRYPT_MODE_CBC, $iv);
|
50 |
+
|
51 |
// Base64 encode message.
|
52 |
if(!($msg = base64_encode($iv . $data)))
|
53 |
throw new SwiftAPI_Exception('SwiftAPI::Encode(): Failed to base64 encode message.');
|
156 |
</script>';
|
157 |
}
|
158 |
|
159 |
+
public static function BareScript($request, $key)
|
160 |
+
{
|
161 |
+
return '
|
162 |
+
window.onload = function()
|
163 |
+
{
|
164 |
+
var query = "' . SwiftAPI::Query($request, $key) . '";
|
165 |
+
var http;
|
166 |
+
|
167 |
+
// IE7+, Firefox, Chrome, Opera, Safari.
|
168 |
+
if(window.XMLHttpRequest)
|
169 |
+
http=new XMLHttpRequest();
|
170 |
+
|
171 |
+
// IE6, IE5.
|
172 |
+
else
|
173 |
+
http=new ActiveXObject("Microsoft.XMLHTTP");
|
174 |
+
|
175 |
+
http.open("POST","'. self::SWIFTAPI_CRM_URL .'", true);
|
176 |
+
|
177 |
+
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
178 |
+
http.setRequestHeader("Content-length", query.length);
|
179 |
+
http.setRequestHeader("Connection", "close");
|
180 |
+
|
181 |
+
http.onreadystatechange= function()
|
182 |
+
{
|
183 |
+
if (http.readyState==4 && http.status==200)
|
184 |
+
console.log("success");
|
185 |
+
}
|
186 |
+
|
187 |
+
http.send(query);
|
188 |
+
}
|
189 |
+
';
|
190 |
+
}
|
191 |
|
192 |
////////////////////////////////////
|
193 |
// Public: UserID()
|
lib/SwiftAPI/SwiftAPI_Request.php
CHANGED
@@ -12,6 +12,7 @@ require_once('SwiftAPI_Request_PastOrder.php');
|
|
12 |
require_once('SwiftAPI_Request_Subscription.php');
|
13 |
require_once('SwiftAPI_Request_ViewMail.php');
|
14 |
require_once('SwiftAPI_Request_SendMail.php');
|
|
|
15 |
|
16 |
|
17 |
abstract class SwiftAPI_Request
|
@@ -82,7 +83,8 @@ abstract class SwiftAPI_Request
|
|
82 |
return SwiftAPI_Request_SendMail::Create($fields);
|
83 |
case SwiftAPI::OPERATION_UNSUBSCRIBE:
|
84 |
return SwiftAPI_Request_Unsubscribe::Create($fields);
|
85 |
-
|
|
|
86 |
default:
|
87 |
throw new SwiftAPI_Exception('SwiftAPI_Request::Create(): Invalid operation: "' . $fields -> operation . '".');
|
88 |
}
|
12 |
require_once('SwiftAPI_Request_Subscription.php');
|
13 |
require_once('SwiftAPI_Request_ViewMail.php');
|
14 |
require_once('SwiftAPI_Request_SendMail.php');
|
15 |
+
require_once('SwiftAPI_Request_EmailPackage.php');
|
16 |
|
17 |
|
18 |
abstract class SwiftAPI_Request
|
83 |
return SwiftAPI_Request_SendMail::Create($fields);
|
84 |
case SwiftAPI::OPERATION_UNSUBSCRIBE:
|
85 |
return SwiftAPI_Request_Unsubscribe::Create($fields);
|
86 |
+
case SwiftAPI::OPERATION_EMAILPACKAGE:
|
87 |
+
return SwiftAPI_Request_EmailPackage::Create($fields);
|
88 |
default:
|
89 |
throw new SwiftAPI_Exception('SwiftAPI_Request::Create(): Invalid operation: "' . $fields -> operation . '".');
|
90 |
}
|
lib/SwiftAPI/SwiftAPI_Request_EmailPackage.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SwiftAPI_Request_EmailPackage extends SwiftAPI_Request {
|
4 |
+
|
5 |
+
//////////////////////////////////////////////////////////////////////////////
|
6 |
+
// Public properties.
|
7 |
+
//////////////////////////////////////////////////////////////////////////////
|
8 |
+
|
9 |
+
public $emailPackage;
|
10 |
+
public $site;
|
11 |
+
|
12 |
+
|
13 |
+
//////////////////////////////////////////////////////////////////////////////
|
14 |
+
// Public functions
|
15 |
+
//////////////////////////////////////////////////////////////////////////////
|
16 |
+
|
17 |
+
////////////////////////
|
18 |
+
// Public: __construct()
|
19 |
+
////////////////////////
|
20 |
+
|
21 |
+
public function __construct($domain, $user, $site, $emailPackage, $version = NULL, $date = NULL)
|
22 |
+
{
|
23 |
+
$this -> emailPackage = $emailPackage;
|
24 |
+
$this -> site = $site;
|
25 |
+
parent::__construct($domain, SwiftAPI::OPERATION_EMAILPACKAGE, $user, $version, $date);
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
///////////////////
|
30 |
+
// Public: Create()
|
31 |
+
///////////////////
|
32 |
+
|
33 |
+
public static function Create(stdClass $fields)
|
34 |
+
{
|
35 |
+
parent::Validate($fields);
|
36 |
+
|
37 |
+
if(!is_array($fields -> emailPackage) || empty($fields -> emailPackage))
|
38 |
+
throw new SwiftAPI_Exception('SwiftAPI_Request_EmailPackage::Create(): "emailPackage" field is missing or empty.');
|
39 |
+
|
40 |
+
foreach ($fields -> emailPackage as $email_content) {
|
41 |
+
if (!(is_object($email_content))) {
|
42 |
+
throw new SwiftAPI_Exception('SwiftAPI_Request_EmailPackage::Create(): "emailPackage" does not contain the class SwiftAPI_Request_SendMail.');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
if (!isset($fields -> site)) {
|
46 |
+
throw new SwiftAPI_Exception('SwiftAPI_Request_EmailPackage::Create(): "site" field is missing or empty.');
|
47 |
+
}
|
48 |
+
|
49 |
+
return new self
|
50 |
+
(
|
51 |
+
$fields -> domain,
|
52 |
+
$fields -> user,
|
53 |
+
$fields -> site,
|
54 |
+
$fields -> emailPackage,
|
55 |
+
$fields -> version,
|
56 |
+
$fields -> date
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Swift_Swiftplugin</name>
|
4 |
-
<version>1.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/LGPL-3.0">LGPL</license>
|
7 |
<channel>community</channel>
|
@@ -18,11 +18,11 @@ The extension uses background JavaScript calls to collect and store the customer
|
|
18 |
<p>
|
19 |
The extension is easy to set up and uses Magento’s built in features to collect information and send emails to the customers. Visit swiftcrm.net for prices and free trails.
|
20 |
</p></description>
|
21 |
-
<notes>
|
22 |
<authors><author><name>Simon Cooper</name><user>Netready</user><email>simon@netready.biz</email></author></authors>
|
23 |
-
<date>2015-
|
24 |
-
<time>
|
25 |
-
<contents><target name="magelib"><dir name="libXML"><file name="xml.php" hash="fc4d7c79c7b7ea2ac75f28c008cde8eb"/></dir><dir name="SwiftAPI"><file name="SwiftAPI.php" hash="
|
26 |
<compatible/>
|
27 |
<dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php><extension><name>mcrypt</name><min/><max/></extension></required></dependencies>
|
28 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Swift_Swiftplugin</name>
|
4 |
+
<version>1.1.14</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/LGPL-3.0">LGPL</license>
|
7 |
<channel>community</channel>
|
18 |
<p>
|
19 |
The extension is easy to set up and uses Magento’s built in features to collect information and send emails to the customers. Visit swiftcrm.net for prices and free trails.
|
20 |
</p></description>
|
21 |
+
<notes>Optimisation of the SwiftERM emails.</notes>
|
22 |
<authors><author><name>Simon Cooper</name><user>Netready</user><email>simon@netready.biz</email></author></authors>
|
23 |
+
<date>2015-06-23</date>
|
24 |
+
<time>13:19:45</time>
|
25 |
+
<contents><target name="magelib"><dir name="libXML"><file name="xml.php" hash="fc4d7c79c7b7ea2ac75f28c008cde8eb"/></dir><dir name="SwiftAPI"><file name="SwiftAPI.php" hash="1a2b4e86947847e5e524a1c53054f79e"/><file name="SwiftAPI_Exception.php" hash="879b899a7961f4de1212b7296ccafb16"/><file name="SwiftAPI_Product.php" hash="063922cccb485d81c6022de5c4e8e044"/><file name="SwiftAPI_Request.php" hash="da10370a1c8d9c1a8b5d4b1d3840d3b6"/><file name="SwiftAPI_Request_Cart.php" hash="f8955c78200ddb0512adb5214fd64bb2"/><file name="SwiftAPI_Request_EmailPackage.php" hash="221dd4bd936f022a9e07ad79d33c89a2"/><file name="SwiftAPI_Request_Home.php" hash="9268da121dd10db50d5c2675afd1c65e"/><file name="SwiftAPI_Request_Order.php" hash="cd8ce90614468bd4347df3c541482a4b"/><file name="SwiftAPI_Request_PastOrder.php" hash="be620e2e35d6634e6a616431f5312527"/><file name="SwiftAPI_Request_Ping.php" hash="e5e13b71682f8230711d5d2f28f9a534"/><file name="SwiftAPI_Request_Product.php" hash="e5fab27bb2dd45946ed8c143a18fe3c4"/><file name="SwiftAPI_Request_SendMail.php" hash="ba04382a3df6b3e179aed5fe3e809de7"/><file name="SwiftAPI_Request_Subscription.php" hash="5545738b941d8ca4dca69b6059a0cce4"/><file name="SwiftAPI_Request_Unsubscribe.php" hash="78aa37cc0ecb98d501674350a4a409c9"/><file name="SwiftAPI_Request_ViewMail.php" hash="773f0cc695838654b9056269622c217e"/><dir name="doc"><file name="SwiftAPI-Specification.html" hash="093cb08b66a596ebaeb0b50b4a0f8d79"/></dir><file name="index.php" hash="82886bb98883bd5868ea04c7d8c88ba5"/><file name="php.ini" hash="ef29c923925a1d1bbc8879c22297daa4"/></dir></target><target name="magecommunity"><dir name="Swift"><dir name="Swiftplugin"><dir name="Block"><dir name="Adminhtml"><dir name="Swift"><dir name="Edit"><file name="Form.php" hash="bd80ab8170f7f2286f13ac579e5249d9"/><dir name="Tab"><file name="Form.php" hash="3d15c45cb2205acabc20376f41a9bd5b"/><file name="Instruct.php" hash="9f34075cc9cdfa92b7876c33fda514de"/></dir><file name="Tabs.php" hash="993769f682fad7d28df79ff3acea97cc"/></dir><file name="Edit.php" hash="d93f75dbaaa7266d91e828b3208fbf2d"/></dir></dir><file name="Swiftblock.php" hash="ef4796eaf44aa8e4a9b144e5a9365166"/></dir><dir name="Helper"><file name="Data.php" hash="cad7e7ffcde09cdd3c089b42644e9d66"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Swift"><file name="Collection.php" hash="82de0fe56cd875d3e78c8fc690424ee1"/></dir><file name="Swift.php" hash="252d5f2ecb1119804b415758d2db6800"/></dir><file name="Observer.php" hash="139db0541de06e7bed17ad9d40fcd89b"/><file name="Swift.php" hash="1f9e49d4db7f8987cfd8858061fedc6a"/><file name="XmlProduct.php" hash="e2887684881a6a93a618c9e7f812b1d7"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="0d17d7a4d18d3a77fd1af945d016da74"/></dir><file name="MailController.php" hash="9e7930b0f45453616272ac3187fdda35"/><file name="XmlController.php" hash="97b777935db5174501034493dd561099"/></dir><dir name="etc"><file name="config.xml" hash="d5dbc321c25a82740678d907ef818c47"/></dir><dir name="sql"><dir name="swift_setup"><file name="install-1.1.13.php" hash="2447b5645fc36738373678473cec88dc"/><file name="install-1.1.2.php" hash="00832a00c34cb4c997a96330cb28cbfb"/><file name="upgrade-1.1.2-1.1.12.php" hash="cbe3c3fa07facb7b720d7dd518acbeca"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="swift.xml" hash="d80a5229e30cf4b76f5a5150ac1c27c3"/></dir><dir name="template"><dir name="swift"><file name="swiftplugin.phtml" hash="d4d25148e09529e457b6436d7655627b"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Swift_all.xml" hash="0ae5a788c805a9fc79b402fe7a02e54d"/></dir></target></contents>
|
26 |
<compatible/>
|
27 |
<dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php><extension><name>mcrypt</name><min/><max/></extension></required></dependencies>
|
28 |
</package>
|