Loewenstark_Newsletter - Version 1.1.0

Version Notes

initial connect release

Download this release

Release Info

Developer Mathis Klooss
Extension Loewenstark_Newsletter
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/community/Loewenstark/Newsletter/Block/Unsubscribe.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Loewenstark_Newsletter_Block_Unsubscribe
4
+ extends Mage_Newsletter_Block_Subscribe
5
+ {
6
+
7
+ /**
8
+ * Retrieve form action url and set "secure" param to avoid confirm
9
+ * message when we submit form from secure page to unsecure
10
+ *
11
+ * @return string
12
+ */
13
+ public function getFormActionUrl()
14
+ {
15
+ return $this->getUrl('newsletter/unsubscribe', array('_secure' => true));
16
+ }
17
+ }
app/code/community/Loewenstark/Newsletter/Model/Unsubscribe.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Loewenstark_Newsletter_Block_Unsubscribe
4
+ extends Mage_Newsletter_Model_Subscriber
5
+ {
6
+ /** @var bool $_sendConfirmationSuccessEmail check if email already send **/
7
+ private $_sendConfirmationSuccessEmail = true;
8
+
9
+ /**
10
+ * unsubscribes by email
11
+ *
12
+ * @param string $email
13
+ * @throws Exception
14
+ * @return int
15
+ */
16
+ public function unsubscribeByEmail($email) {
17
+ $this->setStoreId(Mage::app()->getStore()->getId());
18
+ $this->loadByEmail($email);
19
+ if( !$this->getId() ) {
20
+ return false;
21
+ }
22
+ $this->setCheckCode($this->getCode());
23
+ $this->unsubscribe();
24
+ return $this->getStatus();
25
+ }
26
+
27
+ /**
28
+ * Confirms subscriber newsletter
29
+ *
30
+ * @param string $code
31
+ * @return boolean
32
+ */
33
+ public function confirm($code)
34
+ {
35
+ $parent = (bool) parent::confirm($code);
36
+ if( $parent ) {
37
+ $this->sendConfirmationSuccessEmail();
38
+ return true;
39
+ }
40
+ return false;
41
+ }
42
+
43
+ /**
44
+ * Sends out confirmation success email
45
+ *
46
+ * @see Mage_Newsletter_Model_Subscriber::sendConfirmationSuccessEmail
47
+ *
48
+ * @return Mage_Newsletter_Model_Subscriber
49
+ */
50
+ public function sendConfirmationSuccessEmail() {
51
+ // do not send two E-Mails, may Magento will be implements this line in methode self::confirm($code)
52
+ if( $this->_sendConfirmationSuccessEmail ) {
53
+ parent::sendConfirmationSuccessEmail();
54
+ $this->_sendConfirmationSuccessEmail = !$this->_sendConfirmationSuccessEmail;
55
+ }
56
+ return $this;
57
+ }
58
+ }
app/code/community/Loewenstark/Newsletter/controllers/UnsubscriberController.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Loewenstark_Newsletter_UnsubscribeController
4
+ extends Mage_Core_Controller_Front_Action
5
+ {
6
+ public function indexAction()
7
+ {
8
+ if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
9
+ $session = Mage::getSingleton('core/session');
10
+ $email = (string) $this->getRequest()->getPost('email');
11
+
12
+ try {
13
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
14
+ Mage::throwException($this->__('Please enter a valid email address.'));
15
+ }
16
+
17
+ $status = Mage::getModel('newsletter/unsubscribe')->unsubscribeByEmail($email);
18
+ $session->addSuccess($this->__('You have been unsubscribed.'));
19
+ }
20
+ catch (Mage_Core_Exception $e) {
21
+ $session->addException($e, $this->__('There was a problem with the unsubscription: %s', $e->getMessage()));
22
+ }
23
+ catch (Exception $e) {
24
+ $session->addException($e, $this->__('There was a problem with the unsubscription.'));
25
+ }
26
+ }
27
+ $this->_redirectReferer();
28
+ }
29
+ }
app/code/community/Loewenstark/Newsletter/etc/config.xml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Loewenstark_Newsletter>
5
+ <version>1.1.0</version>
6
+ </Loewenstark_Newsletter>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <newsletter>
11
+ <args>
12
+ <modules>
13
+ <Loewenstark_Newsletter before="Mage_Newsletter">Loewenstark_Newsletter</Loewenstark_Newsletter>
14
+ </modules>
15
+ </args>
16
+ </newsletter>
17
+ </routers>
18
+ <translate>
19
+ <modules>
20
+ <Loewenstark_Newsletter>
21
+ <files>
22
+ <default>Loewenstark_Newsletter.csv</default>
23
+ </files>
24
+ </Loewenstark_Newsletter>
25
+ </modules>
26
+ </translate>
27
+ <layout>
28
+ <updates>
29
+ <lws_newsletter module="Loewenstark_Newsletter">
30
+ <file>loewenstark/newsletter.xml</file>
31
+ </lws_newsletter>
32
+ </updates>
33
+ </layout>
34
+ <secure_url>
35
+ <newsletter_subscriber>/newsletter/subscriber/</newsletter_subscriber>
36
+ <newsletter_unsubscriber>/newsletter/unsubscriber/</newsletter_unsubscriber>
37
+ </secure_url>
38
+ </frontend>
39
+ <global>
40
+ <models>
41
+ <lws_newsletter>
42
+ <class>Loewenstark_Newsletter_Model</class>
43
+ </lws_newsletter>
44
+ <newsletter>
45
+ <rewrite>
46
+ <unsubscribe>Loewenstark_Newsletter_Model_Unsubscribe</unsubscribe>
47
+ </rewrite>
48
+ </newsletter>
49
+ </models>
50
+ <blocks>
51
+ <lws_newsletter>
52
+ <class>Loewenstark_Newsletter_Block</class>
53
+ </lws_newsletter>
54
+ <newsletter>
55
+ <rewrite>Mage_Newsletter_Block_Unsubscribe
56
+ <unsubscribe>Loewenstark_Newsletter_Block_Unsubscribe</unsubscribe>
57
+ </rewrite>
58
+ </newsletter>
59
+ </blocks>
60
+ </global>
61
+ </config>
app/design/frontend/base/default/layout/loewenstark/newsletter.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.2.0">
3
+ <default>
4
+ <reference name="left">
5
+ <block type="newsletter/unsubscribe" name="newsletter.unsubscribe" as="newsletter_unsubscribe" after="newsletter" template="newsletter/unsubscribe.phtml"/>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/newsletter/unsubscribe.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loewenstark_Newsletter
4
+ *
5
+ * @category design
6
+ * @package Loewenstark_Newsletter
7
+ * @copyright Copyright (c) 2012 Mathis Klooss (http://www.loewenstark.de/)
8
+ * @license https://github.com/mklooss/Loewenstark_Newsletter/blob/master/README.md
9
+ */
10
+ ?>
11
+ <div class="block block-subscribe block-unsubscribe">
12
+ <div class="block-title">
13
+ <strong><span><?php echo $this->__('Newsletter Unsubscribe') ?></span></strong>
14
+ </div>
15
+ <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-unsubscribe-validate-detail">
16
+ <div class="block-content">
17
+ <div class="form-subscribe-header form-unsubscribe-header">
18
+ <label for="newsletter-unsubscribe"><?php echo $this->__('Unsubscribe Our Newsletter:') ?></label>
19
+ </div>
20
+ <div class="input-box">
21
+ <input type="text" name="email" id="newsletter-unsubscribe" title="<?php echo $this->__('Unsubscribe Our Newsletter') ?>" class="input-text required-entry validate-email" />
22
+ </div>
23
+ <div class="actions">
24
+ <button type="submit" title="<?php echo $this->__('Unsubscribe') ?>" class="button"><span><span><?php echo $this->__('Unsubscribe') ?></span></span></button>
25
+ </div>
26
+ </div>
27
+ </form>
28
+ <script type="text/javascript">
29
+ //<![CDATA[
30
+ var newsletterUnsubscriberFormDetail = new VarienForm('newsletter-unsubscribe-validate-detail');
31
+ //]]>
32
+ </script>
33
+ </div>
app/etc/modules/Loewenstark_Newsletter.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Loewenstark_Newsletter>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Newsletter />
9
+ </depends>
10
+ </Loewenstark_Newsletter>
11
+ </modules>
12
+ </config>
app/locale/de_DE/Loewenstark_Newsletter.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "Newsletter Unsubscribe","Newsletter Abmelden"
2
+ "Unsubscribe Our Newsletter:","Vom Newsletter abmelden:"
3
+ "Unsubscribe","Abmelden"
app/locale/en_US/Loewenstark_Newsletter.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "Newsletter Unsubscribe","Newsletter Unsubscribe"
2
+ "Unsubscribe Our Newsletter:","Unsubscribe Our Newsletter:"
3
+ "Unsubscribe","Unsubscribe"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Loewenstark_Newsletter</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://github.com/mklooss/Loewenstark_Newsletter/blob/master/README.md">GPL-3</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>unscubscribe as guest, send double opt in confirmation</summary>
10
+ <description>unscubscribe as guest, send double opt in confirmation</description>
11
+ <notes>initial connect release</notes>
12
+ <authors><author><name>Mathis Klooss</name><user>mklooss</user><email>m.klooss@loewenstark.de</email></author></authors>
13
+ <date>2012-12-07</date>
14
+ <time>08:59:05</time>
15
+ <contents><target name="magecommunity"><dir name="Loewenstark"><dir name="Newsletter"><dir><dir name="Block"><file name="Unsubscribe.php" hash="03cf2c135ca87e9d15c2cb92a0a21ee0"/></dir><dir name="Model"><file name="Unsubscribe.php" hash="3379279490d57ffecbe362750609a9bb"/></dir><dir name="controllers"><file name="UnsubscriberController.php" hash="191cf8f7ecefa2c968de1efb689d9877"/></dir><dir name="etc"><file name="config.xml" hash="9dfcd5f68236e8136ffa7d400d063907"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="loewenstark"><file name="newsletter.xml" hash=""/></dir></dir><dir name="template"><dir name="newsletter"><file name="unsubscribe.phtml" hash=""/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Loewenstark_Newsletter.xml" hash=""/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Loewenstark_Newsletter.csv" hash=""/></dir><dir name="en_US"><file name="Loewenstark_Newsletter.csv" hash=""/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.12</min><max>7.0.0</max></php></required></dependencies>
18
+ </package>