Ajax_newsletter_extension - Version 1.0.1

Version Notes

version 1.0.1

Download this release

Release Info

Developer Rohit Dhiman
Extension Ajax_newsletter_extension
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/local/AjaxNewsletter/Ajaxnewsletter/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class AjaxNewsletter_Ajaxnewsletter_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/local/AjaxNewsletter/Ajaxnewsletter/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class AjaxNewsletter_Ajaxnewsletter_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/local/AjaxNewsletter/Ajaxnewsletter/controllers/IndexController.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class AjaxNewsletter_Ajaxnewsletter_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+
5
+ $this->loadLayout();
6
+
7
+ $this->renderLayout();
8
+
9
+ }
10
+ public function newAction()
11
+ {
12
+
13
+ if ($_REQUEST['email']) {
14
+ $session = Mage::getSingleton('core/session');
15
+ $customerSession = Mage::getSingleton('customer/session');
16
+ $email = $_REQUEST['email'];
17
+ try {
18
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
19
+
20
+ echo "Please enter a valid email address.&&0";
21
+ return;
22
+ }
23
+
24
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
25
+ !$customerSession->isLoggedIn()) {
26
+ echo 'Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()."&&0";
27
+ return;
28
+ }
29
+
30
+ $ownerId = Mage::getModel('customer/customer')
31
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
32
+ ->loadByEmail($email)
33
+ ->getId();
34
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
35
+ echo 'This email address is already assigned to another user.&&0';
36
+ return;
37
+ }
38
+
39
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
40
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
41
+ echo "Confirmation request has been sent.&&1";
42
+ return;
43
+ }
44
+ else {
45
+ echo "Thank you for your subscription.&&1";
46
+ return;
47
+ }
48
+ }
49
+ catch (Mage_Core_Exception $e) {
50
+ echo "There was a problem with the subscription:".$e."&&0";
51
+ return;
52
+ }
53
+ catch (Exception $e) {
54
+ echo "There was a problem with the subscription".$e."&&0";
55
+ return;
56
+ }
57
+ }
58
+ $this->_redirectReferer();
59
+ }
60
+ }
app/code/local/AjaxNewsletter/Ajaxnewsletter/etc/config.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <AjaxNewsletter_Ajaxnewsletter>
5
+ <version>0.1.0</version>
6
+ </AjaxNewsletter_Ajaxnewsletter>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <ajaxnewsletter>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>AjaxNewsletter_Ajaxnewsletter</module>
14
+ <frontName>ajaxnewsletter</frontName>
15
+ </args>
16
+ </ajaxnewsletter>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <ajaxnewsletter>
21
+ <file>ajaxnewsletter.xml</file>
22
+ </ajaxnewsletter>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <ajaxnewsletter>
29
+ <class>AjaxNewsletter_Ajaxnewsletter_Helper</class>
30
+ </ajaxnewsletter>
31
+ </helpers>
32
+ <blocks>
33
+ <ajaxnewsletter>
34
+ <class>AjaxNewsletter_Ajaxnewsletter_Block</class>
35
+ </ajaxnewsletter>
36
+ </blocks>
37
+ </global>
38
+ </config>
app/design/frontend/base/default/template/ajaxnewsletter/index.phtml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="block block-subscribe">
28
+ <div class="block-title">
29
+ <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
30
+ </div>
31
+ <form action="javascript:void(0)<?php //echo $this->getUrl('ajaxnewsletter/index/new');?>" method="post" id="newsletter-validate-detail" onsubmit="myfunc();">
32
+ <div class="block-content">
33
+ <div class="form-subscribe-header">
34
+ <div class="output" id="output"></div>
35
+ <label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
36
+ </div>
37
+ <div class="input-box">
38
+ <input type="text" name="email" id="newsletter" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" />
39
+ <div class="error-news-msg" id="error-news-msg" style="display:none;">Please insert a valid email address.</div>
40
+
41
+ </div>
42
+ <div class="actions">
43
+ <button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
44
+ </div>
45
+ </div>
46
+ </form>
47
+ <script type="text/javascript">
48
+
49
+
50
+ function myfunc()
51
+ {
52
+ var newsletterSubscriberFormDetail = new VarienForm('newsletter-form');
53
+
54
+
55
+ var form_email = $('newsletter').getValue();
56
+ var params_form = $('newsletter-validate-detail');
57
+
58
+ new Validation('newsletter');
59
+
60
+ if(echeck(form_email))
61
+
62
+ {
63
+ new Ajax.Request( "<?php echo Mage::getBaseUrl();?>ajaxnewsletter/index/new", {
64
+ method: "post",
65
+ parameters: {
66
+ email : form_email
67
+ },
68
+ onSuccess: function( transport ) {
69
+ Element.hide('error-news-msg');
70
+
71
+ var da = transport.responseText;
72
+ var dat = da.split("&&");
73
+ $('output').innerHTML = dat[0];
74
+ if(dat[1]==1){ Element.show('output');
75
+ $('output').setAttribute("class", "success-msg");} else { Element.show('output'); $('output').setAttribute("class", "error-msg"); }
76
+ }
77
+ });
78
+
79
+
80
+ } else { return true;}}
81
+
82
+
83
+
84
+ function echeck(str) {
85
+
86
+ var at="@"
87
+ var dot="."
88
+ var lat=str.indexOf(at)
89
+ var lstr=str.length
90
+ var ldot=str.indexOf(dot)
91
+ if (str.indexOf(at)==-1){
92
+ goProcedural();
93
+ return false;
94
+ }
95
+
96
+ if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
97
+ goProcedural();
98
+ return false;
99
+ }
100
+
101
+ if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
102
+ goProcedural();
103
+ return false;
104
+ }
105
+
106
+ if (str.indexOf(at,(lat+1))!=-1){
107
+ goProcedural();
108
+ return false;
109
+ }
110
+
111
+ if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
112
+ goProcedural();
113
+ return false;
114
+ }
115
+
116
+ if (str.indexOf(dot,(lat+2))==-1){
117
+ goProcedural();
118
+ return false;
119
+ }
120
+
121
+ if (str.indexOf(" ")!=-1){
122
+ goProcedural();
123
+ return false;
124
+ }
125
+
126
+ return true;
127
+ }
128
+ function goProcedural()
129
+ {
130
+ Element.hide('output');
131
+ $('error-news-msg').setAttribute("class", "validation-advice");
132
+ Element.show('error-news-msg');
133
+
134
+ Element.hide.delay(10, 'error-news-msg');
135
+ }
136
+
137
+ </script>
138
+ </div>
app/design/frontend/base/default/template/ajaxnewsletter/index.phtml~ ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_crispandclean
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="block block-subscribe">
28
+ <div class="block-title new-ti">
29
+ <strong><span><?php echo $this->__('Subscribe to our Newsletter') ?></span></strong>
30
+ </div>
31
+
32
+ <div id="feedback" style="display:none" class="mini-newsletter">
33
+
34
+
35
+ Thank you for subscribing to our newsletter!
36
+ </div>
37
+
38
+ <div id="ab"><form name="newsletter-form" id="newsletter-form" method="post">
39
+ <div class="block-content">
40
+ <label for="newsletter">Enter your e-mail address</label>
41
+ <div class="input-box">
42
+ <input type="text" name="email" id="newsletter" title="<?php echo $this->__('Subscribe to Our Newsletter') ?>" class="required-entry validate-email input-subscribe" style="width:170px;" />
43
+ <div class="error-news-msg" id="error-news-msg" style="display:none;">Please insert a valid email address.</div>
44
+ </div>
45
+ <div class="actions">
46
+ <button type="button" title="<?php echo $this->__('Subscribe') ?>" onclick="myfunc();" class="submit-butn"></button>
47
+
48
+ </div>
49
+ </div>
50
+ </form> </div>
51
+ </div>
52
+ <script type="text/javascript">
53
+
54
+
55
+ function myfunc()
56
+ {
57
+ var newsletterSubscriberFormDetail = new VarienForm('newsletter-form');
58
+ var form_email = $('newsletter').getValue();
59
+ var params_form = $('newsletter-validate-detail');
60
+ //alert(params_form);
61
+ new Validation('newsletter');
62
+ if(echeck(form_email))
63
+ {
64
+ //alert(form_email);
65
+ //alert(Form.serialize($('newsletter-validate-detail')));
66
+ new Ajax.Updater({ success: 'newsletter-form' }, '<?php echo $this->getUrl('newsletter/subscriber/new') ?>', {
67
+ asynchronous:true, evalScripts:false,
68
+ parameters: { email: form_email },
69
+ onComplete:function(request, json){Element.hide('newsletter-form'); Element.show('feedback'); },
70
+ onLoading:function(request, json){},
71
+
72
+ });
73
+
74
+
75
+
76
+ }
77
+ else
78
+ {
79
+ //alert(form_email);
80
+ return false;
81
+ }
82
+
83
+ }
84
+
85
+
86
+
87
+ function echeck(str) {
88
+
89
+ var at="@"
90
+ var dot="."
91
+ var lat=str.indexOf(at)
92
+ var lstr=str.length
93
+ var ldot=str.indexOf(dot)
94
+ if (str.indexOf(at)==-1){
95
+ //alert("Invalid E-mail ID")
96
+ goProcedural()
97
+ return false
98
+ }
99
+
100
+ if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
101
+ //alert("Invalid E-mail ID")
102
+ goProcedural()
103
+ return false
104
+ }
105
+
106
+ if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
107
+ //alert("Invalid E-mail ID")
108
+ goProcedural()
109
+ return false
110
+ }
111
+
112
+ if (str.indexOf(at,(lat+1))!=-1){
113
+ //alert("Invalid E-mail ID")
114
+ goProcedural()
115
+ return false
116
+ }
117
+
118
+ if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
119
+ //alert("Invalid E-mail ID")
120
+ goProcedural()
121
+ return false
122
+ }
123
+
124
+ if (str.indexOf(dot,(lat+2))==-1){
125
+ //alert("Invalid E-mail ID")
126
+ goProcedural()
127
+ return false
128
+ }
129
+
130
+ if (str.indexOf(" ")!=-1){
131
+ //alert("Invalid E-mail ID")
132
+ goProcedural()
133
+ return false
134
+ }
135
+
136
+ return true
137
+ }
138
+ function goProcedural()
139
+ {
140
+ Element.show('error-news-msg');
141
+ Element.hide.delay(5, 'error-news-msg');
142
+ }
143
+
144
+ </script>
145
+
app/etc/modules/AjaxNewsletter_Ajaxnewsletter.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <AjaxNewsletter_Ajaxnewsletter>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>0.1.0</version>
8
+ </AjaxNewsletter_Ajaxnewsletter>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ajax_newsletter_extension</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSLv1.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Ajax newsletter help you to submit the magneto newsletter without refersh the page..</summary>
10
+ <description>Ajax newsletter help you to submit the magneto newsletter without refersh the page..</description>
11
+ <notes>version 1.0.1</notes>
12
+ <authors><author><name>Rohit Dhiman</name><user>rdhimansujji</user><email>rdhimansujji@gmail.com</email></author></authors>
13
+ <date>2014-04-28</date>
14
+ <time>08:09:24</time>
15
+ <contents><target name="mage"><dir name="."><dir name="app"><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="ajaxnewsletter"><file name="index.phtml" hash="2d8a10689bbbc9c06fe8c2103519be81"/><file name="index.phtml~" hash="5cc98d5f9264774c91c6ac118f467dd7"/></dir></dir></dir></dir></dir></dir><dir name="code"><dir name="local"><dir name="AjaxNewsletter"><dir name="Ajaxnewsletter"><dir name="Block"><file name="Index.php" hash="80edd59c75a245d3a8e9a3061f56435e"/></dir><dir name="Helper"><file name="Data.php" hash="628d6a8b0e790302245b8f3d147e0981"/></dir><dir name="controllers"><file name="IndexController.php" hash="65797ebb7b7360d8bd6d81a99c61432d"/></dir><dir name="etc"><file name="config.xml" hash="1200017c455a361baf7f14bd3e5ef385"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="AjaxNewsletter_Ajaxnewsletter.xml" hash="993602044b4266b880ed50bab7147a9d"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>