Version Notes
Release notes for users and developers
Download this release
Release Info
Developer | a1professionals |
Extension | EmailBrainApi |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/core/Mage/Customer/Model/Emailbrain.php +147 -0
- app/code/local/Module/Emailbrain/Block/Adminhtml/Emailbrainbackend.php +11 -0
- app/code/local/Module/Emailbrain/Helper/Data.php +7 -0
- app/code/local/Module/Emailbrain/controllers/AccountController.php +163 -0
- app/code/local/Module/Emailbrain/controllers/AddressController.php +86 -0
- app/code/local/Module/Emailbrain/controllers/Adminhtml/EmailbrainbackendController.php +200 -0
- app/code/local/Module/Emailbrain/controllers/ManageController.php +41 -0
- app/code/local/Module/Emailbrain/etc/config.xml +122 -0
- app/code/local/Module/Emailbrain/sql/emailbrain_setup/mysql4-install-0.1.0.php +10 -0
- app/design/adminhtml/default/default/layout/emailbrain.xml +8 -0
- app/design/adminhtml/default/default/template/emailbrain/emailbrainbackend.phtml +144 -0
- app/design/adminhtml/default/default/template/emailbrain/emailbrainimport.phtml +71 -0
- app/etc/modules/Module_Emailbrain.xml +10 -0
- package.xml +18 -0
app/code/core/Mage/Customer/Model/Emailbrain.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mage_Customer_Model_Emailbrain extends Mage_Core_Model_Abstract{
|
3 |
+
function hello(){
|
4 |
+
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
5 |
+
}
|
6 |
+
public function CreateEmailBrainUser($data){
|
7 |
+
$dir=$_SERVER['DOCUMENT_ROOT'].'/CSV';
|
8 |
+
if(!is_dir($dir)){
|
9 |
+
mkdir($dir,755);
|
10 |
+
}
|
11 |
+
$filename=$dir.'/file.csv';
|
12 |
+
@unlink($filename);
|
13 |
+
$baseurl=(isset($_SERVER['HTTPS']) ? 'https' :'http'). '://' . $_SERVER['HTTP_HOST'];
|
14 |
+
$fileurl=$baseurl.'/CSV/file.csv';
|
15 |
+
if (file_exists($filename)):
|
16 |
+
if(!is_writable($filename)):
|
17 |
+
die ("The file: $filename is not writable");
|
18 |
+
endif;
|
19 |
+
elseif( !is_writable( getcwd() ) ):
|
20 |
+
die("you cannot create files in this directory. Check the permissions");
|
21 |
+
endif;
|
22 |
+
//open the file for APPENDING
|
23 |
+
//add the "t" terminator for windows
|
24 |
+
//if using a mac then set the ini directive
|
25 |
+
$fh = fopen($filename, "at");
|
26 |
+
//Lock the file for the write operation
|
27 |
+
flock($fh, LOCK_EX);
|
28 |
+
//loop through the recordset
|
29 |
+
//db output manipulation
|
30 |
+
if(isset($data['firstname'])){
|
31 |
+
$row[1]["firstname"]= $data['firstname'];
|
32 |
+
$row[1]["lastname"]= $data['lastname'];
|
33 |
+
}
|
34 |
+
$row[1]["email"]=$data['email'];
|
35 |
+
if(isset($data['address_1'])){
|
36 |
+
$row[1]["company"]= @$data['company'];
|
37 |
+
$row[1]["telephone"]= $data['telephone'];
|
38 |
+
$row[1]["fax"]= @$data['fax'];
|
39 |
+
$row[1]["address_1"]= $data['address_1'];
|
40 |
+
$row[1]["address_2"]= $data['address_2'];
|
41 |
+
$row[1]["city"]= $data['city'];
|
42 |
+
$row[1]["state"]= $data['state'];
|
43 |
+
$row[1]["zip"]= $data['zip'];
|
44 |
+
$row[1]["country_id"]= $data['country_id'];
|
45 |
+
}
|
46 |
+
//use fputcsv by preference - we can just pass the row-array
|
47 |
+
if (function_exists("fputcsv")):
|
48 |
+
fputcsv($fh, $row[1], ",", "\"");
|
49 |
+
else:
|
50 |
+
//clean up the strings for escaping and add quotes
|
51 |
+
foreach ($row[1] as $val):
|
52 |
+
$b[] = '"'.addslashes($val).'"';
|
53 |
+
endforeach;
|
54 |
+
//comma separate the values
|
55 |
+
$string = implode(",",$b);
|
56 |
+
//write the data to the file
|
57 |
+
fwrite($fh, $string ."\n",strlen($string));
|
58 |
+
endif;
|
59 |
+
|
60 |
+
//close the file handle outside the loop
|
61 |
+
//this releases the lock too
|
62 |
+
fclose($fh);
|
63 |
+
//$user=$this->getUserDetail();
|
64 |
+
if(isset($data['address_1'])){
|
65 |
+
$this->editEmailBrainUser();
|
66 |
+
}else{
|
67 |
+
$this->registerEmailBrainUser();
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function sendPost($url){
|
72 |
+
$ch = curl_init();
|
73 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
74 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
75 |
+
curl_setopt($ch, CURLOPT_NOBODY, true); // remove body
|
76 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
77 |
+
$head = curl_exec($ch);
|
78 |
+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
79 |
+
curl_close($ch);
|
80 |
+
//print_r($head) ;
|
81 |
+
}
|
82 |
+
protected function dataWrite(){
|
83 |
+
/**
|
84 |
+
* Get the resource model
|
85 |
+
*/
|
86 |
+
$resource = Mage::getSingleton('core/resource');
|
87 |
+
/**
|
88 |
+
* Retrieve the write connection
|
89 |
+
*/
|
90 |
+
$writeConnection = $resource->getConnection('core_write');
|
91 |
+
return $writeConnection;
|
92 |
+
}
|
93 |
+
protected function dataRead(){
|
94 |
+
/**
|
95 |
+
* Get the resource model
|
96 |
+
*/
|
97 |
+
$resource = Mage::getSingleton('core/resource');
|
98 |
+
/**
|
99 |
+
* Retrieve the read connection
|
100 |
+
*/
|
101 |
+
$readConnection = $resource->getConnection('core_read');
|
102 |
+
return $readConnection;
|
103 |
+
}
|
104 |
+
protected function getUserDetail(){
|
105 |
+
$Connection=$this->dataRead();
|
106 |
+
$query='SELECT * FROM emailbrain_account';
|
107 |
+
$results = $Connection->fetchAll($query);
|
108 |
+
return $results;
|
109 |
+
}
|
110 |
+
public function updateEmailBrainAccount($oldEmail){
|
111 |
+
$user=$this->getUserDetail();
|
112 |
+
$url="https://".$user[0]['domain']."/api.aspx?Username=".$user[0]['username']."&Password=".$user[0]['password']."&Function=post_delete_emailaddress&MailinglistID=".$user[0]['maillist_id']."&EmailAddress=".$oldEmail."&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
113 |
+
$this->sendPost($url);
|
114 |
+
}
|
115 |
+
public function subscribeEmailBrainNewsletter($email){
|
116 |
+
$user=$this->getUserDetail();
|
117 |
+
$url="https://".$user[0]['domain']."/api.aspx?Username=".$user[0]['username']."&Password=".$user[0]['password']."&Function=post_subscribe&Email=".$email."&MailinglistID=".$user[0]['maillist_id']."&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
118 |
+
$this->sendPost($url);
|
119 |
+
}
|
120 |
+
public function unSubscribeEmailBrainNewsletter($email){
|
121 |
+
$user=$this->getUserDetail();
|
122 |
+
$url="https://".$user[0]['domain']."/api.aspx?Username=".$user[0]['username']."&Password=".$user[0]['password']."&Function=post_unsubscribe&Email=".$email."&MailinglistID=".$user[0]['maillist_id']."&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
123 |
+
$this->sendPost($url);
|
124 |
+
}
|
125 |
+
public function registerEmailBrainUser(){
|
126 |
+
$user=$this->getUserDetail();
|
127 |
+
$baseurl=(isset($_SERVER['HTTPS']) ? 'https' :'http'). '://' . $_SERVER['HTTP_HOST'];
|
128 |
+
$fileurl=$baseurl.'/CSV/file.csv';
|
129 |
+
$url="https://".$user[0]['domain']."/api.aspx?Username=".$user[0]['username']."&Password=".$user[0]['password']."&Function=post_import_dataset&EmailCol=3&Col1=1&Col2=2&Col6=4&Col9=5&Col10=6&Col4=7&DatasetID=".$user[0]['dataset_id']."&MailingListID=".$user[0]['maillist_id']."&ImportMode=1&FileUrl=".$fileurl."&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
130 |
+
$this->sendPost($url);
|
131 |
+
}
|
132 |
+
public function editEmailBrainUser(){
|
133 |
+
$user=$this->getUserDetail();
|
134 |
+
$baseurl=(isset($_SERVER['HTTPS']) ? 'https' :'http'). '://' . $_SERVER['HTTP_HOST'];
|
135 |
+
$fileurl=$baseurl.'/CSV/file.csv';
|
136 |
+
$url="https://".$user[0]['domain']."/api.aspx?Username=".$user[0]['username']."&Password=".$user[0]['password']."&Function=post_import_dataset&EmailCol=3&Col1=1&Col2=2&Col4=4&Col6=5&Col7=6&Col9=7&Col10=8&Col11=9&Col12=10&Col13=11&Col14=12&DatasetID=".$user[0]['dataset_id']."&MailingListID=".$user[0]['maillist_id']."&ImportMode=1&FileUrl=".$fileurl."&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
137 |
+
$this->sendPost($url);
|
138 |
+
}
|
139 |
+
public function ImportExcel($filename){
|
140 |
+
$user=$this->getUserDetail();
|
141 |
+
$baseurl=(isset($_SERVER['HTTPS']) ? 'https' :'http'). '://' . $_SERVER['HTTP_HOST'];
|
142 |
+
$fileurl=$baseurl.'/CSV/'.$filename;
|
143 |
+
$url="https://".$user[0]['domain']."/api.aspx?Username=".$user[0]['username']."&Password=".$user[0]['password']."&Function=post_import_dataset&EmailCol=3&Col1=1&Col2=2&Col4=4&Col6=5&Col7=6&Col9=7&Col10=8&Col11=9&Col12=10&Col13=11&Col14=12&DatasetID=".$user[0]['dataset_id']."&MailingListID=".$user[0]['maillist_id']."&ImportMode=1&FileUrl=".$fileurl."&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
144 |
+
$this->sendPost($url);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
?>
|
app/code/local/Module/Emailbrain/Block/Adminhtml/Emailbrainbackend.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Module_Emailbrain_Block_Adminhtml_Emailbrainbackend extends Mage_Adminhtml_Block_Template {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
$this->setTemplate('Emailbrain/emailbrainbackend.phtml');
|
8 |
+
//$this->setFormAction(Mage::getUrl('*/*/save/index/key'));
|
9 |
+
}
|
10 |
+
}
|
11 |
+
?>
|
app/code/local/Module/Emailbrain/Helper/Data.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Module_Emailbrain_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
7 |
+
|
app/code/local/Module/Emailbrain/controllers/AccountController.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Customer/controllers/AccountController.php';
|
4 |
+
|
5 |
+
class Module_Emailbrain_AccountController extends Mage_Customer_AccountController
|
6 |
+
{
|
7 |
+
|
8 |
+
public function createAction()
|
9 |
+
{
|
10 |
+
if ($this->_getSession()->isLoggedIn()) {
|
11 |
+
$this->_redirect('*/*');
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
$this->loadLayout();
|
16 |
+
$this->_initLayoutMessages('customer/session');
|
17 |
+
/************* EMAILBRAIN CODE *******************/
|
18 |
+
|
19 |
+
$emailbrain = Mage::getModel('customer/emailbrain');
|
20 |
+
//$emailbrain->createEmailBrainUser($customerData);
|
21 |
+
|
22 |
+
/************************ END ***********************/
|
23 |
+
|
24 |
+
$this->renderLayout();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Create customer account action
|
29 |
+
*/
|
30 |
+
public function createPostAction()
|
31 |
+
{
|
32 |
+
$session = $this->_getSession();
|
33 |
+
if ($session->isLoggedIn()) {
|
34 |
+
$this->_redirect('*/*/');
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
$session->setEscapeMessages(true); // prevent XSS injection in user input
|
38 |
+
if ($this->getRequest()->isPost()) {
|
39 |
+
$errors = array();
|
40 |
+
|
41 |
+
if (!$customer = Mage::registry('current_customer')) {
|
42 |
+
$customer = Mage::getModel('customer/customer')->setId(null);
|
43 |
+
}
|
44 |
+
|
45 |
+
/* @var $customerForm Mage_Customer_Model_Form */
|
46 |
+
$customerForm = Mage::getModel('customer/form');
|
47 |
+
$customerForm->setFormCode('customer_account_create')
|
48 |
+
->setEntity($customer);
|
49 |
+
|
50 |
+
$customerData = $customerForm->extractData($this->getRequest());
|
51 |
+
|
52 |
+
/**************** EMAILBRAIN CODE ******************/
|
53 |
+
$emailbrain = Mage::getModel('customer/emailbrain');
|
54 |
+
$emailbrain->createEmailBrainUser($customerData);
|
55 |
+
/*********************** END ************************/
|
56 |
+
|
57 |
+
if ($this->getRequest()->getParam('is_subscribed', false)) {
|
58 |
+
$customer->setIsSubscribed(1);
|
59 |
+
/**************** EMAILBRAIN CODE ******************/
|
60 |
+
$emailbrain->subscribeEmailBrainNewsletter($customerData['email']);
|
61 |
+
/*********************** END ************************/
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Initialize customer group id
|
67 |
+
*/
|
68 |
+
$customer->getGroupId();
|
69 |
+
|
70 |
+
if ($this->getRequest()->getPost('create_address')) {
|
71 |
+
/* @var $address Mage_Customer_Model_Address */
|
72 |
+
$address = Mage::getModel('customer/address');
|
73 |
+
/* @var $addressForm Mage_Customer_Model_Form */
|
74 |
+
$addressForm = Mage::getModel('customer/form');
|
75 |
+
$addressForm->setFormCode('customer_register_address')
|
76 |
+
->setEntity($address);
|
77 |
+
|
78 |
+
$addressData = $addressForm->extractData($this->getRequest(), 'address', false);
|
79 |
+
$addressErrors = $addressForm->validateData($addressData);
|
80 |
+
if ($addressErrors === true) {
|
81 |
+
$address->setId(null)
|
82 |
+
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
|
83 |
+
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
|
84 |
+
$addressForm->compactData($addressData);
|
85 |
+
$customer->addAddress($address);
|
86 |
+
|
87 |
+
$addressErrors = $address->validate();
|
88 |
+
if (is_array($addressErrors)) {
|
89 |
+
$errors = array_merge($errors, $addressErrors);
|
90 |
+
}
|
91 |
+
} else {
|
92 |
+
$errors = array_merge($errors, $addressErrors);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
try {
|
97 |
+
$customerErrors = $customerForm->validateData($customerData);
|
98 |
+
if ($customerErrors !== true) {
|
99 |
+
$errors = array_merge($customerErrors, $errors);
|
100 |
+
} else {
|
101 |
+
$customerForm->compactData($customerData);
|
102 |
+
$customer->setPassword($this->getRequest()->getPost('password'));
|
103 |
+
$customer->setConfirmation($this->getRequest()->getPost('confirmation'));
|
104 |
+
$customerErrors = $customer->validate();
|
105 |
+
if (is_array($customerErrors)) {
|
106 |
+
$errors = array_merge($customerErrors, $errors);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$validationResult = count($errors) == 0;
|
111 |
+
|
112 |
+
if (true === $validationResult) {
|
113 |
+
$customer->save();
|
114 |
+
|
115 |
+
Mage::dispatchEvent('customer_register_success',
|
116 |
+
array('account_controller' => $this, 'customer' => $customer)
|
117 |
+
);
|
118 |
+
|
119 |
+
if ($customer->isConfirmationRequired()) {
|
120 |
+
$customer->sendNewAccountEmail(
|
121 |
+
'confirmation',
|
122 |
+
$session->getBeforeAuthUrl(),
|
123 |
+
Mage::app()->getStore()->getId()
|
124 |
+
);
|
125 |
+
$session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
|
126 |
+
$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
|
127 |
+
return;
|
128 |
+
} else {
|
129 |
+
$session->setCustomerAsLoggedIn($customer);
|
130 |
+
$url = $this->_welcomeCustomer($customer);
|
131 |
+
$this->_redirectSuccess($url);
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
} else {
|
135 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
136 |
+
if (is_array($errors)) {
|
137 |
+
foreach ($errors as $errorMessage) {
|
138 |
+
$session->addError($errorMessage);
|
139 |
+
}
|
140 |
+
} else {
|
141 |
+
$session->addError($this->__('Invalid customer data'));
|
142 |
+
}
|
143 |
+
}
|
144 |
+
} catch (Mage_Core_Exception $e) {
|
145 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
146 |
+
if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
|
147 |
+
$url = Mage::getUrl('customer/account/forgotpassword');
|
148 |
+
$message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
|
149 |
+
$session->setEscapeMessages(false);
|
150 |
+
} else {
|
151 |
+
$message = $e->getMessage();
|
152 |
+
}
|
153 |
+
$session->addError($message);
|
154 |
+
} catch (Exception $e) {
|
155 |
+
$session->setCustomerFormData($this->getRequest()->getPost())
|
156 |
+
->addException($e, $this->__('Cannot save the customer.'));
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
|
161 |
+
}
|
162 |
+
|
163 |
+
}
|
app/code/local/Module/Emailbrain/controllers/AddressController.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'Mage/Customer/controllers/AddressController.php';
|
3 |
+
|
4 |
+
class Module_Emailbrain_AddressController extends Mage_Customer_AddressController
|
5 |
+
{
|
6 |
+
public function formPostAction()
|
7 |
+
{
|
8 |
+
/**************** EMAILBRAIN CODE ********h**********/
|
9 |
+
$emailbrain = Mage::getModel('customer/emailbrain');
|
10 |
+
$u=Mage::helper('customer')->getCustomer()->getData();
|
11 |
+
$data=$this->getRequest()->getPost();
|
12 |
+
$data['address_1']=$data['street'][0];
|
13 |
+
$data['address_1']=$data['street'][1];
|
14 |
+
$data['email']=$u['email'];
|
15 |
+
|
16 |
+
/*********************** END ************************/
|
17 |
+
|
18 |
+
|
19 |
+
if (!$this->_validateFormKey()) {
|
20 |
+
return $this->_redirect('*/*/');
|
21 |
+
}
|
22 |
+
// Save data
|
23 |
+
if ($this->getRequest()->isPost()) {
|
24 |
+
$customer = $this->_getSession()->getCustomer();
|
25 |
+
/* @var $address Mage_Customer_Model_Address */
|
26 |
+
$address = Mage::getModel('customer/address');
|
27 |
+
$addressId = $this->getRequest()->getParam('id');
|
28 |
+
if ($addressId) {
|
29 |
+
$existsAddress = $customer->getAddressById($addressId);
|
30 |
+
if ($existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) {
|
31 |
+
$address->setId($existsAddress->getId());
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$errors = array();
|
36 |
+
|
37 |
+
/* @var $addressForm Mage_Customer_Model_Form */
|
38 |
+
$addressForm = Mage::getModel('customer/form');
|
39 |
+
$addressForm->setFormCode('customer_address_edit')
|
40 |
+
->setEntity($address);
|
41 |
+
$addressData = $addressForm->extractData($this->getRequest());
|
42 |
+
$addressErrors = $addressForm->validateData($addressData);
|
43 |
+
if ($addressErrors !== true) {
|
44 |
+
$errors = $addressErrors;
|
45 |
+
}
|
46 |
+
|
47 |
+
try {
|
48 |
+
$addressForm->compactData($addressData);
|
49 |
+
$address->setCustomerId($customer->getId())
|
50 |
+
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
|
51 |
+
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
|
52 |
+
|
53 |
+
$addressErrors = $address->validate();
|
54 |
+
if ($addressErrors !== true) {
|
55 |
+
$errors = array_merge($errors, $addressErrors);
|
56 |
+
}
|
57 |
+
|
58 |
+
if (count($errors) === 0) {
|
59 |
+
$address->save();
|
60 |
+
/**************** EMAILBRAIN CODE ******************/
|
61 |
+
$emailbrain->CreateEmailBrainUser($data);
|
62 |
+
/*********************** END ************************/
|
63 |
+
|
64 |
+
$this->_getSession()->addSuccess($this->__('The address has been saved.'));
|
65 |
+
$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
|
66 |
+
return;
|
67 |
+
} else {
|
68 |
+
$this->_getSession()->setAddressFormData($this->getRequest()->getPost());
|
69 |
+
foreach ($errors as $errorMessage) {
|
70 |
+
$this->_getSession()->addError($errorMessage);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
} catch (Mage_Core_Exception $e) {
|
74 |
+
$this->_getSession()->setAddressFormData($this->getRequest()->getPost())
|
75 |
+
->addException($e, $e->getMessage());
|
76 |
+
} catch (Exception $e) {
|
77 |
+
$this->_getSession()->setAddressFormData($this->getRequest()->getPost())
|
78 |
+
->addException($e, $this->__('Cannot save address.'));
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
return $this->_redirectError(Mage::getUrl('*/*/edit', array('id' => $address->getId())));
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
}
|
app/code/local/Module/Emailbrain/controllers/Adminhtml/EmailbrainbackendController.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Module_Emailbrain_Adminhtml_EmailbrainbackendController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout();
|
7 |
+
$this->_title($this->__("EmailBrain Setting"));
|
8 |
+
|
9 |
+
if(isset($_POST['domain'])){
|
10 |
+
$_SESSION['message']=$this->updateEmailAccount($_POST);
|
11 |
+
}
|
12 |
+
$userinfo=$this->getEmailAccount();
|
13 |
+
$_SESSION['EmailAccount']=$userinfo;
|
14 |
+
|
15 |
+
$condt=$this->getMaillingList($userinfo[0]);
|
16 |
+
if($condt!=1)
|
17 |
+
{
|
18 |
+
$_SESSION['mailinglist']=$this->getMaillingList($userinfo[0]);
|
19 |
+
}
|
20 |
+
$_SESSION['dataset']=$this->getDataset($userinfo[0]);
|
21 |
+
$this->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function saveAction() {
|
25 |
+
$this->loadLayout();
|
26 |
+
$this->_title($this->__("EmailBrain Setting"));
|
27 |
+
$this->renderLayout();
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
public function importAction(){
|
32 |
+
|
33 |
+
/* Get customer model, run a query */
|
34 |
+
$collection = Mage::getModel('customer/customer')
|
35 |
+
->getCollection()
|
36 |
+
->addAttributeToSelect('*');
|
37 |
+
|
38 |
+
$result = array();
|
39 |
+
foreach ($collection as $customer) {
|
40 |
+
$result[] = $customer->toArray();
|
41 |
+
}
|
42 |
+
$this->createCSV($result);
|
43 |
+
$emailbrain = Mage::getModel('customer/emailbrain');
|
44 |
+
$emailbrain->registerEmailBrainUser();
|
45 |
+
$_SESSION['message']='No Permission';
|
46 |
+
$this->_redirect('*/*/');
|
47 |
+
}
|
48 |
+
protected function dataWrite(){
|
49 |
+
/**
|
50 |
+
* Get the resource model
|
51 |
+
*/
|
52 |
+
$resource = Mage::getSingleton('core/resource');
|
53 |
+
/**
|
54 |
+
* Retrieve the write connection
|
55 |
+
*/
|
56 |
+
$writeConnection = $resource->getConnection('core_write');
|
57 |
+
return $writeConnection;
|
58 |
+
}
|
59 |
+
protected function dataRead(){
|
60 |
+
/**
|
61 |
+
* Get the resource model
|
62 |
+
*/
|
63 |
+
$resource = Mage::getSingleton('core/resource');
|
64 |
+
/**
|
65 |
+
* Retrieve the read connection
|
66 |
+
*/
|
67 |
+
$readConnection = $resource->getConnection('core_read');
|
68 |
+
return $readConnection;
|
69 |
+
}
|
70 |
+
protected function updateEmailAccount($data){
|
71 |
+
$Connection=$this->dataWrite();
|
72 |
+
$fields="username='$data[username]', password='$data[password]', domain='$data[domain]'";
|
73 |
+
|
74 |
+
$userinfo=$this->getEmailAccount();
|
75 |
+
$condt=$this->getMaillingList($userinfo[0]);
|
76 |
+
|
77 |
+
if($condt==1)
|
78 |
+
{
|
79 |
+
$fields.=" ,dataset_id='$data[dataset_id]',maillist_id='$data[maillist_id]'";
|
80 |
+
$message='<li class="error-msg">Authentication failed.Check username and password.</li></ul></li>';
|
81 |
+
}
|
82 |
+
$fields.=" ,dataset_id='$data[dataset_id]',maillist_id='$data[maillist_id]'";
|
83 |
+
$query="UPDATE emailbrain_account SET ".$fields;
|
84 |
+
$Connection->query($query);
|
85 |
+
return $message;
|
86 |
+
}
|
87 |
+
protected function getEmailAccount(){
|
88 |
+
$Connection=$this->dataRead();
|
89 |
+
$query='SELECT * FROM emailbrain_account';
|
90 |
+
$results = $Connection->fetchAll($query);
|
91 |
+
return $results;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
public function resetAction() {
|
96 |
+
$Connection=$this->dataWrite();
|
97 |
+
$fields="username='', password='', maillist_id=''";
|
98 |
+
$query="UPDATE emailbrain_account SET ".$fields;
|
99 |
+
|
100 |
+
$Connection->query($query);
|
101 |
+
$this->_redirect('*/*');
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function getMaillingList($user){
|
105 |
+
$path="https://".$user['domain']."/api.aspx?Username=".$user['username']."&Password=".$user['password']."&Function=get_mailinglists&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
106 |
+
$doc = new DomDocument();
|
107 |
+
$doc->load($path);
|
108 |
+
$mailinglists = $doc->getElementsByTagName( "mailinglist" );
|
109 |
+
$count=1;
|
110 |
+
$_select='<select name="maillist_id">';
|
111 |
+
$_select.="<option selected='selected' value='0'>--------------------Select MailingList--------------------</option>";
|
112 |
+
foreach( $mailinglists as $mailinglist ){
|
113 |
+
$mailinglistid = $mailinglist->getElementsByTagName("mailinglistid" );
|
114 |
+
$mailinglistid = $mailinglistid->item(0)->nodeValue;
|
115 |
+
$description = $mailinglist->getElementsByTagName("description" );
|
116 |
+
$description = $description->item(0)->nodeValue;
|
117 |
+
if($mailinglistid){
|
118 |
+
$count++;
|
119 |
+
if(@$user['maillist_id']==$mailinglistid)
|
120 |
+
$_select.="<option selected='selected' value='$mailinglistid'>$description</option>";
|
121 |
+
else
|
122 |
+
$_select.="<option value='$mailinglistid'>$description</option>";
|
123 |
+
}
|
124 |
+
}
|
125 |
+
$_select.='</select>';
|
126 |
+
if($count>1)
|
127 |
+
{
|
128 |
+
return $_select;
|
129 |
+
}
|
130 |
+
else
|
131 |
+
{
|
132 |
+
return $count;
|
133 |
+
|
134 |
+
}
|
135 |
+
}
|
136 |
+
protected function getDataset($user){
|
137 |
+
$path="https://".$user['domain']."/api.aspx?Username=".$user['username']."&Password=".$user['password']."&Function=get_datasets&Principal=blGnGdu9T4JLZWPAVI2D3sYSK2c9gT2Z";
|
138 |
+
$doc = new DomDocument();
|
139 |
+
$doc->load($path);
|
140 |
+
$datasets = $doc->getElementsByTagName( "dataset" );
|
141 |
+
$count=0;
|
142 |
+
$_dataset='<select name="dataset_id">';
|
143 |
+
foreach( $datasets as $dataset ){
|
144 |
+
$datasetid = $dataset->getElementsByTagName("datasetid" );
|
145 |
+
$datasetid = $datasetid->item(0)->nodeValue;
|
146 |
+
$name = $dataset->getElementsByTagName("name" );
|
147 |
+
$name = $name->item(0)->nodeValue;
|
148 |
+
|
149 |
+
if(@$user['dataset_id']==$datasetid)
|
150 |
+
$_dataset.="<option selected='selected' value='$datasetid'>$name</option>";
|
151 |
+
else
|
152 |
+
$_dataset.="<option value='$datasetid'>$name</option>";
|
153 |
+
}
|
154 |
+
$_dataset.='</select>';
|
155 |
+
return $_dataset;
|
156 |
+
}
|
157 |
+
protected function createCSV($datas){
|
158 |
+
$dir=$_SERVER['DOCUMENT_ROOT'].'/CSV';
|
159 |
+
if(!is_dir($dir)){
|
160 |
+
mkdir($dir,755);
|
161 |
+
}
|
162 |
+
$filename=$dir.'/file.csv';
|
163 |
+
@unlink($filename);
|
164 |
+
$baseurl=(isset($_SERVER['HTTPS']) ? 'https' :'http'). '://' . $_SERVER['HTTP_HOST'];
|
165 |
+
$fileurl=$baseurl.'/CSV/file.csv';
|
166 |
+
if (file_exists($filename)):
|
167 |
+
if(!is_writable($filename)):
|
168 |
+
die ("The file: $filename is not writable");
|
169 |
+
endif;
|
170 |
+
elseif( !is_writable( getcwd() ) ):
|
171 |
+
die("you cannot create files in this directory. Check the permissions");
|
172 |
+
endif;
|
173 |
+
//open the file for APPENDING
|
174 |
+
//add the "t" terminator for windows
|
175 |
+
//if using a mac then set the ini directive
|
176 |
+
$fh = fopen($filename, "at");
|
177 |
+
//Lock the file for the write operation
|
178 |
+
flock($fh, LOCK_EX);
|
179 |
+
//loop through the recordset
|
180 |
+
//db output manipulation
|
181 |
+
foreach($datas as $data){
|
182 |
+
++$count;
|
183 |
+
if(isset($data['firstname'])){
|
184 |
+
$row[$count]["firstname"]= $data['firstname'];
|
185 |
+
$row[$count]["lastname"]= $data['lastname'];
|
186 |
+
}
|
187 |
+
$row[$count]["email"]=$data['email'];
|
188 |
+
}
|
189 |
+
|
190 |
+
foreach ($row as $fields) {
|
191 |
+
fputcsv($fh, $fields);
|
192 |
+
}
|
193 |
+
|
194 |
+
//close the file handle outside the loop
|
195 |
+
//this releases the lock too
|
196 |
+
fclose($fh);
|
197 |
+
|
198 |
+
}
|
199 |
+
}
|
200 |
+
?>
|
app/code/local/Module/Emailbrain/controllers/ManageController.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'Mage/Newsletter/controllers/ManageController.php';
|
3 |
+
|
4 |
+
class Module_Emailbrain_ManageController extends Mage_Newsletter_ManageController
|
5 |
+
{
|
6 |
+
|
7 |
+
public function saveAction()
|
8 |
+
{
|
9 |
+
if (!$this->_validateFormKey()) {
|
10 |
+
return $this->_redirect('customer/account/');
|
11 |
+
}
|
12 |
+
/**************** EMAILBRAIN CODE ******************/
|
13 |
+
$emailbrain = Mage::getModel('customer/emailbrain');
|
14 |
+
$data=Mage::helper('customer')->getCustomer()->getData();
|
15 |
+
/*********************** END ************************/
|
16 |
+
|
17 |
+
try {
|
18 |
+
Mage::getSingleton('customer/session')->getCustomer()
|
19 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
20 |
+
->setIsSubscribed((boolean)$this->getRequest()->getParam('is_subscribed', false))
|
21 |
+
->save();
|
22 |
+
if ((boolean)$this->getRequest()->getParam('is_subscribed', false)) {
|
23 |
+
Mage::getSingleton('customer/session')->addSuccess($this->__('The subscription has been saved.'));
|
24 |
+
/**************** EMAILBRAIN CODE ******************/
|
25 |
+
$emailbrain->subscribeEmailBrainNewsletter($data['email']);
|
26 |
+
/*********************** END ************************/
|
27 |
+
|
28 |
+
} else {
|
29 |
+
Mage::getSingleton('customer/session')->addSuccess($this->__('The subscription has been removed.'));
|
30 |
+
/**************** EMAILBRAIN CODE ******************/
|
31 |
+
$emailbrain->unSubscribeEmailBrainNewsletter($data['email']);
|
32 |
+
/*********************** END ************************/
|
33 |
+
|
34 |
+
}
|
35 |
+
}
|
36 |
+
catch (Exception $e) {
|
37 |
+
Mage::getSingleton('customer/session')->addError($this->__('An error occurred while saving your subscription.'));
|
38 |
+
}
|
39 |
+
$this->_redirect('customer/account/');
|
40 |
+
}
|
41 |
+
}
|
app/code/local/Module/Emailbrain/etc/config.xml
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Module_Emailbrain>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Module_Emailbrain>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<frontend>
|
10 |
+
<routers>
|
11 |
+
<customer>
|
12 |
+
<args>
|
13 |
+
<modules>
|
14 |
+
<module_emailbrain before="Mage_Customer">Module_Emailbrain</module_emailbrain>
|
15 |
+
</modules>
|
16 |
+
</args>
|
17 |
+
</customer>
|
18 |
+
</routers>
|
19 |
+
</frontend>
|
20 |
+
|
21 |
+
<frontend>
|
22 |
+
<routers>
|
23 |
+
<newsletter>
|
24 |
+
<args>
|
25 |
+
<modules>
|
26 |
+
<module_emailbrain before="Mage_Newsletter">Module_Emailbrain</module_emailbrain>
|
27 |
+
</modules>
|
28 |
+
</args>
|
29 |
+
</newsletter>
|
30 |
+
</routers>
|
31 |
+
</frontend>
|
32 |
+
|
33 |
+
<global>
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
<helpers>
|
38 |
+
<emailbrain>
|
39 |
+
<class>Module_Emailbrain_Helper</class>
|
40 |
+
</emailbrain>
|
41 |
+
</helpers>
|
42 |
+
|
43 |
+
<blocks><emailbrain><class>Module_Emailbrain_Block</class></emailbrain></blocks>
|
44 |
+
<resources>
|
45 |
+
<emailbrain_setup>
|
46 |
+
<setup>
|
47 |
+
<module>Module_Emailbrain</module>
|
48 |
+
</setup>
|
49 |
+
<connection>
|
50 |
+
<use>core_setup</use>
|
51 |
+
</connection>
|
52 |
+
</emailbrain_setup>
|
53 |
+
<emailbrain_write>
|
54 |
+
<connection>
|
55 |
+
<use>core_write</use>
|
56 |
+
</connection>
|
57 |
+
</emailbrain_write>
|
58 |
+
<emailbrain_read>
|
59 |
+
<connection>
|
60 |
+
<use>core_read</use>
|
61 |
+
</connection>
|
62 |
+
</emailbrain_read>
|
63 |
+
|
64 |
+
</resources>
|
65 |
+
|
66 |
+
</global>
|
67 |
+
<admin>
|
68 |
+
<routers>
|
69 |
+
<emailbrain>
|
70 |
+
<use>admin</use>
|
71 |
+
<args>
|
72 |
+
<module>Module_Emailbrain</module>
|
73 |
+
<frontName>emailbrain</frontName>
|
74 |
+
</args>
|
75 |
+
</emailbrain>
|
76 |
+
</routers>
|
77 |
+
</admin><adminhtml>
|
78 |
+
<menu>
|
79 |
+
<emailbrain module="emailbrain">
|
80 |
+
<title>EmailBrain</title>
|
81 |
+
<sort_order>100</sort_order>
|
82 |
+
<children>
|
83 |
+
<emailbrainbackend module="emailbrain">
|
84 |
+
<title>EmailBrain Setting</title>
|
85 |
+
<sort_order>0</sort_order>
|
86 |
+
<action>emailbrain/adminhtml_emailbrainbackend</action>
|
87 |
+
</emailbrainbackend>
|
88 |
+
</children>
|
89 |
+
</emailbrain>
|
90 |
+
</menu>
|
91 |
+
<acl>
|
92 |
+
<resources>
|
93 |
+
<all>
|
94 |
+
<title>Allow Everything</title>
|
95 |
+
</all>
|
96 |
+
<admin>
|
97 |
+
<children>
|
98 |
+
<emailbrain translate="title" module="emailbrain">
|
99 |
+
<title>EmailBrain</title>
|
100 |
+
<sort_order>1000</sort_order>
|
101 |
+
<children>
|
102 |
+
<emailbrainbackend translate="title">
|
103 |
+
<title>EmailBrain Setting</title>
|
104 |
+
</emailbrainbackend>
|
105 |
+
</children>
|
106 |
+
</emailbrain>
|
107 |
+
</children>
|
108 |
+
</admin>
|
109 |
+
|
110 |
+
</resources>
|
111 |
+
</acl>
|
112 |
+
|
113 |
+
<layout>
|
114 |
+
<updates>
|
115 |
+
<emailbrain>
|
116 |
+
<file>emailbrain.xml</file>
|
117 |
+
</emailbrain>
|
118 |
+
</updates>
|
119 |
+
</layout>
|
120 |
+
</adminhtml>
|
121 |
+
|
122 |
+
</config>
|
app/code/local/Module/Emailbrain/sql/emailbrain_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
$installer->run("create table emailbrain_account(id int not null auto_increment, domain text,username text,password text,maillist_id int(11),dataset_id int(11), primary key(id));insert into emailbrain_account values (NULL,'www.emailbrain.com','Username','Password','','');
|
5 |
+
");
|
6 |
+
//demo
|
7 |
+
Mage::getModel('core/url_rewrite')->setId(null);
|
8 |
+
//demo
|
9 |
+
$installer->endSetup();
|
10 |
+
|
app/design/adminhtml/default/default/layout/emailbrain.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<emailbrain_adminhtml_emailbrainbackend_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="emailbrain/adminhtml_emailbrainbackend" name="emailbrainbackend" template="emailbrain/emailbrainbackend.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</emailbrain_adminhtml_emailbrainbackend_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/emailbrain/emailbrainbackend.phtml
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<style type="text/css">
|
2 |
+
.black_overlay{
|
3 |
+
display: none;
|
4 |
+
position: fixed;
|
5 |
+
top: 0%;
|
6 |
+
left: 0%;
|
7 |
+
width: 100%;
|
8 |
+
height: 100%;
|
9 |
+
background-color: black;
|
10 |
+
z-index:1001;
|
11 |
+
-moz-opacity: 0.8;
|
12 |
+
opacity:.80;
|
13 |
+
filter: alpha(opacity=80);
|
14 |
+
}
|
15 |
+
.white_content {
|
16 |
+
display: none;
|
17 |
+
position: absolute;
|
18 |
+
top: 25%;
|
19 |
+
left: 39%;
|
20 |
+
width: 16%;
|
21 |
+
height:15%;
|
22 |
+
padding: 16px;
|
23 |
+
border: 1px solid orange;
|
24 |
+
background-color: white;
|
25 |
+
z-index:1002;
|
26 |
+
overflow: auto;
|
27 |
+
}
|
28 |
+
.btn{
|
29 |
+
background: url("images/btn_bg.gif") repeat-x scroll 0 100% #FFAC47;
|
30 |
+
border-color: #ED6502 #A04300 #A04300 #ED6502;
|
31 |
+
border-style: solid;
|
32 |
+
border-width: 1px;
|
33 |
+
color: #FFFFFF;
|
34 |
+
cursor: pointer;
|
35 |
+
font: bold 12px arial,helvetica,sans-serif;
|
36 |
+
padding: 0 7px 1px;
|
37 |
+
text-align: center !important;
|
38 |
+
white-space: nowrap;
|
39 |
+
text-decoration:none;
|
40 |
+
}
|
41 |
+
|
42 |
+
</style>
|
43 |
+
<div id="anchor-content" class="middle">
|
44 |
+
<div id="page:main-container">
|
45 |
+
|
46 |
+
<div id="messages"><ul class="messages">
|
47 |
+
<?php if($_SESSION['mailinglist'])
|
48 |
+
{
|
49 |
+
echo '<li class="success-msg">Account Information has been saved.</li></ul></li>';
|
50 |
+
}
|
51 |
+
else if(isset($_SESSION['message'])){ ?>
|
52 |
+
<?php echo $_SESSION['message']?>
|
53 |
+
<?php } ?>
|
54 |
+
<?php if(isset($_SESSION['error'])){ ?>
|
55 |
+
<li class="error-msg">
|
56 |
+
<ul>
|
57 |
+
<li><?php echo $_SESSION['error']?></li>
|
58 |
+
</ul>
|
59 |
+
</li>
|
60 |
+
<?php } ?>
|
61 |
+
</ul>
|
62 |
+
</div>
|
63 |
+
|
64 |
+
<div class="content-header" style="visibility: visible;">
|
65 |
+
<h3 class="icon-head head-system-account">EmailBrain</h3>
|
66 |
+
<?php $_key=explode('/',$_SERVER['REQUEST_URI']);$c=count($_key);$_key=$_key[$c-2];?>
|
67 |
+
<p class="form-buttons">
|
68 |
+
<a href="<?php echo $this->getUrl('*/*/reset')?>"><button style="" class="scalable " type="button" id="id_<?php echo $_key?>"><span>Reset</span></button></a>
|
69 |
+
<button style="" onclick="editForm.submit();" class="scalable save" type="button" id="id_<?php echo $_key?>"><span>Save Account</span></button>
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
</p>
|
74 |
+
</div>
|
75 |
+
<?php $readonly=isset($_SESSION['mailinglist'])?'':'';?>
|
76 |
+
|
77 |
+
<div class="entry-edit">
|
78 |
+
|
79 |
+
<form id="edit_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><div><input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" /></div><div class="entry-edit-head">
|
80 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Account Information</h4>
|
81 |
+
<div class="form-buttons"></div>
|
82 |
+
</div>
|
83 |
+
<div id="base_fieldset" class="fieldset ">
|
84 |
+
<div class="hor-scroll">
|
85 |
+
<table cellspacing="0" class="form-list">
|
86 |
+
<tbody>
|
87 |
+
<tr>
|
88 |
+
<td class="label"><label for="userame">EmailBrain Domain <span class="required">*</span></label></td>
|
89 |
+
<td class="value">
|
90 |
+
<input <?php echo $readonly?> type="text" class=" input-text required-entry" title="Enter EmailBrain Domain" value="<?php echo isset($_SESSION['EmailAccount'])?$_SESSION['EmailAccount'][0][domain]:''?>" name="domain" id="domain"> </td>
|
91 |
+
</tr>
|
92 |
+
<tr>
|
93 |
+
<td class="label"><label for="userame">EmailBrain Username <span class="required">*</span></label></td>
|
94 |
+
<td class="value">
|
95 |
+
<input <?php echo $readonly?> type="text" class=" input-text required-entry" title="User Name" value="<?php echo isset($_SESSION['EmailAccount'])?$_SESSION['EmailAccount'][0][username]:''?>" name="username" id="api_user"> </td>
|
96 |
+
</tr>
|
97 |
+
<tr>
|
98 |
+
<td class="label"><label for="firstname">EmailBrain Password <span class="required">*</span></label></td>
|
99 |
+
<td class="value">
|
100 |
+
<input <?php echo $readonly?> type="password" class=" input-text required-entry" title="Password" value="<?php echo isset($_SESSION['EmailAccount'])?$_SESSION['EmailAccount'][0][password]:''?>" name="password" id="firstname"> </td>
|
101 |
+
</tr>
|
102 |
+
<?php if($_SESSION['mailinglist']):?>
|
103 |
+
<tr>
|
104 |
+
<td class="label"><label for="firstname">EmailBrain Malling List</label></td>
|
105 |
+
<td class="value">
|
106 |
+
<?php echo $_SESSION['mailinglist']?>
|
107 |
+
</td>
|
108 |
+
</tr>
|
109 |
+
</tr>
|
110 |
+
<!-----<tr>
|
111 |
+
<td class="label"><label for="firstname">EmailBrain Dataset</label></td>
|
112 |
+
<td class="value">
|
113 |
+
<?php echo $_SESSION['dataset']?>
|
114 |
+
</td>
|
115 |
+
</tr>----->
|
116 |
+
<?php endif; ?>
|
117 |
+
</tbody>
|
118 |
+
</table>
|
119 |
+
</div>
|
120 |
+
</div>
|
121 |
+
</form></div>
|
122 |
+
<script type="text/javascript">
|
123 |
+
editForm = new varienForm('edit_form', '');
|
124 |
+
</script>
|
125 |
+
</div>
|
126 |
+
</div>
|
127 |
+
<?php unset($_SESSION['message'])?>
|
128 |
+
<?php unset($_SESSION['error'])?>
|
129 |
+
<?php unset($_SESSION['EmailAccount'])?>
|
130 |
+
<?php unset($_SESSION['mailinglist'])?>
|
131 |
+
<?php unset($_SESSION['dataset'])?>
|
132 |
+
|
133 |
+
<div id="light" class="white_content">
|
134 |
+
<?php $baseurl=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>
|
135 |
+
<form action="<?php echo $baseurl.'/index.php/emailbrain/adminhtml_emailbrainbackend/import/key/'.$_key; ?>" method="post" enctype="multipart/form-data">
|
136 |
+
<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />
|
137 |
+
<table>
|
138 |
+
<tr><td class="label">Do you Really want to import data </td></tr>
|
139 |
+
<tr><td><input class="btn" type="submit" name="import" value="Import" />
|
140 |
+
<input class="btn" type="button" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'" value="Cancel" /></td></tr>
|
141 |
+
</table>
|
142 |
+
</form></div>
|
143 |
+
|
144 |
+
<div id="fade" class="black_overlay"></div>
|
app/design/adminhtml/default/default/template/emailbrain/emailbrainimport.phtml
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="anchor-content" class="middle">
|
2 |
+
<div id="page:main-container">
|
3 |
+
|
4 |
+
<?php if(isset($_SESSION['message'])){ ?>
|
5 |
+
<div id="messages"><ul class="messages"><li class="success-msg"><ul><li><?php echo $_SESSION['message']?></li></ul></li></ul></div>
|
6 |
+
<?php } ?>
|
7 |
+
<div class="content-header" style="visibility: visible;">
|
8 |
+
<h3 class="icon-head head-system-account">EmailBrain</h3>
|
9 |
+
<?php $_key=explode('/',$_SERVER['REQUEST_URI']);$c=count($_key);$_key=$_key[$c-2];?>
|
10 |
+
<p class="form-buttons">
|
11 |
+
<button style="" onclick="setLocation(window.location.href)" class="scalable " type="button" id="id_<?php echo $_key?>"><span>Reset</span></button>
|
12 |
+
<button style="" onclick="editForm.submit();" class="scalable save" type="button" id="id_<?php echo $_key?>"><span>Save Account</span></button>
|
13 |
+
|
14 |
+
</p>
|
15 |
+
</div>
|
16 |
+
<?php $readonly=isset($_SESSION['mailinglist'])?' readonly="yes" ':'';?>
|
17 |
+
|
18 |
+
<div class="entry-edit">
|
19 |
+
|
20 |
+
<form id="edit_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><div><input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" /></div><div class="entry-edit-head">
|
21 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Account Information</h4>
|
22 |
+
<div class="form-buttons"></div>
|
23 |
+
</div>
|
24 |
+
<div id="base_fieldset" class="fieldset ">
|
25 |
+
<div class="hor-scroll">
|
26 |
+
<table cellspacing="0" class="form-list">
|
27 |
+
<tbody>
|
28 |
+
<tr>
|
29 |
+
<td class="label"><label for="userame">EmailBrain Domain <span class="required">*</span></label></td>
|
30 |
+
<td class="value">
|
31 |
+
<input <?php echo $readonly?> type="text" class=" input-text required-entry" title="Enter EmailBrain Domain" value="<?php echo isset($_SESSION['EmailAccount'])?$_SESSION['EmailAccount'][0][domain]:''?>" name="domain" id="domain"> </td>
|
32 |
+
</tr>
|
33 |
+
<tr>
|
34 |
+
<td class="label"><label for="userame">EmailBrain Username <span class="required">*</span></label></td>
|
35 |
+
<td class="value">
|
36 |
+
<input <?php echo $readonly?> type="text" class=" input-text required-entry" title="User Name" value="<?php echo isset($_SESSION['EmailAccount'])?$_SESSION['EmailAccount'][0][username]:''?>" name="username" id="api_user"> </td>
|
37 |
+
</tr>
|
38 |
+
<tr>
|
39 |
+
<td class="label"><label for="firstname">EmailBrain Password <span class="required">*</span></label></td>
|
40 |
+
<td class="value">
|
41 |
+
<input <?php echo $readonly?> type="password" class=" input-text required-entry" title="Password" value="<?php echo isset($_SESSION['EmailAccount'])?$_SESSION['EmailAccount'][0][password]:''?>" name="password" id="firstname"> </td>
|
42 |
+
</tr>
|
43 |
+
<?php if($_SESSION['mailinglist']):?>
|
44 |
+
<tr>
|
45 |
+
<td class="label"><label for="firstname">EmailBrain Malling List</label></td>
|
46 |
+
<td class="value">
|
47 |
+
<?php echo $_SESSION['mailinglist']?>
|
48 |
+
</td>
|
49 |
+
</tr>
|
50 |
+
</tr>
|
51 |
+
<!-----<tr>
|
52 |
+
<td class="label"><label for="firstname">EmailBrain Dataset</label></td>
|
53 |
+
<td class="value">
|
54 |
+
<?php echo $_SESSION['dataset']?>
|
55 |
+
</td>
|
56 |
+
</tr>----->
|
57 |
+
<?php endif; ?>
|
58 |
+
</tbody>
|
59 |
+
</table>
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
</form></div>
|
63 |
+
<script type="text/javascript">
|
64 |
+
editForm = new varienForm('edit_form', '');
|
65 |
+
</script>
|
66 |
+
</div>
|
67 |
+
</div>
|
68 |
+
<?php unset($_SESSION['message'])?>
|
69 |
+
<?php unset($_SESSION['EmailAccount'])?>
|
70 |
+
<?php unset($_SESSION['mailinglist'])?>
|
71 |
+
<?php unset($_SESSION['dataset'])?>
|
app/etc/modules/Module_Emailbrain.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Module_Emailbrain>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</Module_Emailbrain>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>EmailBrainApi</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Grow your mailing list through Magento transactions! Every time someone registers to buy from your online shop or service via Magento, ask them to opt in to your EmailBrain newsletter. This way, you can send them targeted newsletters, i.e. notify them of new specials, good deals, or new products.</summary>
|
10 |
+
<description>This is a free extension.Grow your mailing list through Magento transactions! Every time someone registers to buy from your online shop or service via Magento, ask them to opt in to your EmailBrain newsletter. This way, you can send them targeted newsletters, i.e. notify them of new specials, good deals, or new products.</description>
|
11 |
+
<notes>Release notes for users and developers</notes>
|
12 |
+
<authors><author><name>a1professionals</name><user>a1professionals</user><email>teamlead@a1professionals.com</email></author></authors>
|
13 |
+
<date>2013-02-20</date>
|
14 |
+
<time>08:39:29</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Module"><dir name="Emailbrain"><dir name="Block"><dir name="Adminhtml"><file name="Emailbrainbackend.php" hash="ffbd0936597991bf2e0e349f7213a804"/></dir></dir><dir name="Helper"><file name="Data.php" hash="b01ef9472d6cc239ea0aeff6c936bf27"/></dir><dir name="controllers"><file name="AccountController.php" hash="ffe948bc6cb51ae9b8d229b041d7f4d5"/><file name="AddressController.php" hash="b3275919743311574eaea04f788491a1"/><dir name="Adminhtml"><file name="EmailbrainbackendController.php" hash="465792de21c85cde99a12843157acdf8"/></dir><file name="ManageController.php" hash="197b03fb8cf23218dcd094e5acef8d58"/></dir><dir name="etc"><file name="config.xml" hash="ae0942944719211da024808f54f067fd"/></dir><dir name="sql"><dir name="emailbrain_setup"><file name="mysql4-install-0.1.0.php" hash="b9b8c5b29941f4994b971f771d811f61"/></dir></dir></dir></dir></target><target name="magecore"><dir name="Mage"><dir name="Customer"><dir name="Model"><file name="Emailbrain.php" hash="b7ab51270c11a12ca3676d939c24d13e"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="emailbrain.xml" hash="b85ceb1b6d610e337972bea5c2743ace"/></dir><dir name="template"><dir name="emailbrain"><file name="emailbrainbackend.phtml" hash="c2419d9729a6edd3583d79434fad1f9f"/><file name="emailbrainimport.phtml" hash="de45c1f7201b452ee705c6480ef07ed0"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Module_Emailbrain.xml" hash="27ebf6d5b1a7e4d5b3dd34a052117957"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|