ND_Emmasignupapi - Version 1.0.0

Version Notes

Integrate Emma's Remote Signup Api

Download this release

Release Info

Developer Magento Core Team
Extension ND_Emmasignupapi
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/ND/Emmasignupapi/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ND_Emmasignupapi_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/ND/Emmasignupapi/Model/Emmasignupapi.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ND_Emmasignupapi_Model_Emmasignupapi extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ protected $_signup_post = '';
7
+ protected $_emma_account_id = '';
8
+ protected $_group_208161086 = '';
9
+ protected $_username = '';
10
+ protected $_password = '';
11
+
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+
16
+ $this->_signup_post = Mage::getStoreConfig('emmasignupapi/settings/signup_post');
17
+ $this->_emma_account_id = Mage::getStoreConfig('emmasignupapi/settings/emma_account_id');
18
+ $this->_group_id = Mage::getStoreConfig('emmasignupapi/settings/group_id');
19
+ $this->_username = Mage::getStoreConfig('emmasignupapi/settings/username');
20
+ $this->_password = Mage::getStoreConfig('emmasignupapi/settings/password');
21
+
22
+ $this->_init('emmasignupapi/emmasignupapi');
23
+ }
24
+
25
+ public function addMember($email='',$firstname='',$lastname='')
26
+ {
27
+ $add = Mage::getStoreConfig('emmasignupapi/settings/add_member');
28
+
29
+ if($add && $email) {
30
+ $post = "signup_post=".$this->_signup_post."&emma_account_id=".$this->_emma_account_id."&username=".$this->_username."&password=".$this->_password."&group[".$this->_group_id."]=1";
31
+ $post .= "&emma_member_email=$email&emma_member_name_first=$firstname&emma_member_name_last=$lastname";
32
+ $ch = curl_init();
33
+ curl_setopt($ch, CURLOPT_URL,"https://app.e2ma.net/app/view:RemoteSignup");
34
+ curl_setopt($ch, CURLOPT_POST, 1);
35
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
36
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
37
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
38
+ $response_code = curl_exec ($ch);
39
+ curl_close ($ch);
40
+ }
41
+ }
42
+
43
+ public function deleteMember($email='',$firstname='',$lastname='')
44
+ {
45
+ $delete = Mage::getStoreConfig('emmasignupapi/settings/delete_member');
46
+ if($delete && $email) {
47
+ $post = "signup_post=".$this->_signup_post."&emma_account_id=".$this->_emma_account_id."&username=".$this->_username."&password=".$this->_password."&group[".$this->_group_id."]=1&delete_member=1";
48
+ $post .= "&emma_member_email=$email&emma_member_name_first=$firstname&emma_member_name_last=$lastname";
49
+ $ch = curl_init();
50
+ curl_setopt($ch, CURLOPT_URL,"https://app.e2ma.net/app/view:RemoteSignup");
51
+ curl_setopt($ch, CURLOPT_POST, 1);
52
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
53
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
54
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
55
+ $response_code = curl_exec ($ch);
56
+ curl_close ($ch);
57
+ }
58
+ }
59
+ }
app/code/local/ND/Emmasignupapi/Model/Observer.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ND_Emmasignupapi_Model_Observer
4
+ {
5
+ public function callRemoteAddApi(Varien_Event_Observer $observer)
6
+ {
7
+ $model = $observer->getEvent()->getCustomer();
8
+
9
+ $is_emmasignupapi = Mage::getStoreConfig('emmasignupapi/settings/enable');
10
+
11
+ if($is_emmasignupapi) {
12
+ $email = $model->getEmail();
13
+ $firstname = $model->getFirstName();
14
+ $lastname = $model->getLastName();
15
+ Mage::getModel('emmasignupapi/emmasignupapi')->addMember($email, $firstname, $lastname);
16
+ }
17
+
18
+ return $this;
19
+ }
20
+
21
+ public function callRemoteDeleteApi(Varien_Event_Observer $observer)
22
+ {
23
+ $model = $observer->getEvent()->getCustomer();
24
+
25
+ $is_emmasignupapi = Mage::getStoreConfig('emmasignupapi/settings/enable');
26
+
27
+ if($is_emmasignupapi) {
28
+ $email = $model->getEmail();
29
+ $firstname = $model->getFirstName();
30
+ $lastname = $model->getLastName();
31
+ Mage::getModel('emmasignupapi/emmasignupapi')->deleteMember($email, $firstname, $lastname);
32
+ }
33
+
34
+ return $this;
35
+ }
36
+ }
app/code/local/ND/Emmasignupapi/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ND_Emmasignupapi_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('emmasignupapi')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('emmasignupapi')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/ND/Emmasignupapi/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ND_Emmasignupapi>
5
+ <version>1.0.0</version>
6
+ </ND_Emmasignupapi>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <emmasignupapi>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>ND_Emmasignupapi</module>
14
+ <frontName>emmasignupapi</frontName>
15
+ </args>
16
+ </emmasignupapi>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <emmasignupapi>
21
+ <file>emmasignupapi.xml</file>
22
+ </emmasignupapi>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <emmasignupapi>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>ND_Emmasignupapi</module>
32
+ <frontName>emmasignupapi</frontName>
33
+ </args>
34
+ </emmasignupapi>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <acl>
39
+ <resources>
40
+ <all>
41
+ <title>Allow Everything</title>
42
+ </all>
43
+ <admin>
44
+ <children>
45
+ <system>
46
+ <children>
47
+ <config>
48
+ <children>
49
+ <emmasignupapi>
50
+ <title>Emmasignupapi Module</title>
51
+ <sort_order>10</sort_order>
52
+ </emmasignupapi>
53
+ </children>
54
+ </config>
55
+ </children>
56
+ </system>
57
+ </children>
58
+ </admin>
59
+ </resources>
60
+ </acl>
61
+ </adminhtml>
62
+ <global>
63
+ <events>
64
+ <customer_save_after>
65
+ <observers>
66
+ <emmasignupapi_add_observer>
67
+ <class>emmasignupapi/observer</class>
68
+ <method>callRemoteAddApi</method>
69
+ </emmasignupapi_add_observer>
70
+ </observers>
71
+ </customer_save_after>
72
+ <customer_delete_after>
73
+ <observers>
74
+ <emmasignupapi_delete_observer>
75
+ <class>emmasignupapi/observer</class>
76
+ <method>callRemoteDeleteApi</method>
77
+ </emmasignupapi_delete_observer>
78
+ </observers>
79
+ </customer_delete_after>
80
+ </events>
81
+ <models>
82
+ <emmasignupapi>
83
+ <class>ND_Emmasignupapi_Model</class>
84
+ <resourceModel>emmasignupapi_mysql4</resourceModel>
85
+ </emmasignupapi>
86
+ <emmasignupapi_mysql4>
87
+ <class>ND_Emmasignupapi_Model_Mysql4</class>
88
+ <entities>
89
+ <emmasignupapi>
90
+ <table>emmasignupapi</table>
91
+ </emmasignupapi>
92
+ </entities>
93
+ </emmasignupapi_mysql4>
94
+ </models>
95
+ <resources>
96
+ <emmasignupapi_setup>
97
+ <setup>
98
+ <module>ND_Emmasignupapi</module>
99
+ </setup>
100
+ <connection>
101
+ <use>core_setup</use>
102
+ </connection>
103
+ </emmasignupapi_setup>
104
+ <emmasignupapi_write>
105
+ <connection>
106
+ <use>core_write</use>
107
+ </connection>
108
+ </emmasignupapi_write>
109
+ <emmasignupapi_read>
110
+ <connection>
111
+ <use>core_read</use>
112
+ </connection>
113
+ </emmasignupapi_read>
114
+ </resources>
115
+ <blocks>
116
+ <emmasignupapi>
117
+ <class>ND_Emmasignupapi_Block</class>
118
+ </emmasignupapi>
119
+ </blocks>
120
+ <helpers>
121
+ <emmasignupapi>
122
+ <class>ND_Emmasignupapi_Helper</class>
123
+ </emmasignupapi>
124
+ </helpers>
125
+ </global>
126
+ </config>
app/code/local/ND/Emmasignupapi/etc/system.xml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <emmasignupapi translate="label" module="emmasignupapi">
5
+ <label>ND</label>
6
+ <sort_order>300</sort_order>
7
+ </emmasignupapi>
8
+ </tabs>
9
+ <sections>
10
+ <emmasignupapi translate="label" module="emmasignupapi">
11
+ <class>separator-top</class>
12
+ <label>Remote Signup Api</label>
13
+ <tab>emmasignupapi</tab>
14
+ <sort_order>130</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <settings translate="label">
20
+ <label>Api Configuration</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>0</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <fields>
27
+ <enable translate="label">
28
+ <label>Status</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>0</show_in_website>
34
+ <show_in_store>0</show_in_store>
35
+ </enable>
36
+ <signup_post translate="label">
37
+ <label>Signup Post</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>0</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ </signup_post>
44
+ <emma_account_id translate="label">
45
+ <label>Emma Account Id</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>0</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </emma_account_id>
52
+ <group_id translate="label">
53
+ <label>Group Id</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>4</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>0</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </group_id>
60
+ <username translate="label">
61
+ <label>Username</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>5</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>0</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ </username>
68
+ <password translate="label">
69
+ <label>Password</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>6</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>0</show_in_website>
74
+ <show_in_store>0</show_in_store>
75
+ </password>
76
+ <add_member translate="label">
77
+ <label>Add Member</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>adminhtml/system_config_source_yesno</source_model>
80
+ <sort_order>7</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>0</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ <comment>Add member into remote server while creating customer</comment>
85
+ </add_member>
86
+ <delete_member translate="label">
87
+ <label>Delete Member</label>
88
+ <frontend_type>select</frontend_type>
89
+ <source_model>adminhtml/system_config_source_yesno</source_model>
90
+ <sort_order>8</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>0</show_in_website>
93
+ <show_in_store>0</show_in_store>
94
+ <comment>Delete member from remote server while deleting customer</comment>
95
+ </delete_member>
96
+ </fields>
97
+ </settings>
98
+ </groups>
99
+ </emmasignupapi>
100
+ </sections>
101
+ </config>
app/etc/modules/ND_Emmasignupapi.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ND_Emmasignupapi>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Customer/>
9
+ </depends>
10
+ </ND_Emmasignupapi>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ND_Emmasignupapi</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>ND extensions</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrate Emma's Remote Signup Api</summary>
10
+ <description>Integrate Emma's Remote Signup Api</description>
11
+ <notes>Integrate Emma's Remote Signup Api</notes>
12
+ <authors><author><name>Nikul</name><user>auto-converted</user><email>doshinikul@gmail.com</email></author></authors>
13
+ <date>2010-09-11</date>
14
+ <time>07:24:11</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="ND_Emmasignupapi.xml" hash="7328b80a8186b544f410f1ca2402378e"/></dir></target><target name="magelocal"><dir name="ND"><dir name="Emmasignupapi"><dir name="etc"><file name="config.xml" hash="fadf511570ebededb281a8c391b3936a"/><file name="system.xml" hash="f1e8e44707a256e7ae6ca591c55e76fc"/></dir><dir name="Helper"><file name="Data.php" hash="5e133630c3305d19e20f8f06ba51508b"/></dir><dir name="Model"><file name="Emmasignupapi.php" hash="aa268f422bb10b433989ad92195a1dde"/><file name="Observer.php" hash="721e79e454462121a612153a8f619856"/><file name="Status.php" hash="e6d6065e0828d9e990b477e944ae74e5"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>