Conlabz_Useroptin - Version 1.0.1

Version Notes

Init extension version

Download this release

Release Info

Developer Conlabz GmbH
Extension Conlabz_Useroptin
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/local/Conlabz/Useroptin/Model/Newsletter/Subscriber.php CHANGED
@@ -78,5 +78,20 @@ class Conlabz_Useroptin_Model_Newsletter_Subscriber extends Mage_Newsletter_Mode
78
  throw new Exception($e->getMessage());
79
  }
80
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  }
78
  throw new Exception($e->getMessage());
79
  }
80
  }
81
+ public function loadByCustomer(Mage_Customer_Model_Customer $customer)
82
+ {
83
+ $data = $this->getResource()->loadByCustomer($customer);
84
+ $this->addData($data);
85
+ if (!empty($data) && $customer->getId() && !$this->getCustomerId()) {
86
+ $this->setCustomerId($customer->getId());
87
+ //$this->setSubscriberConfirmCode($this->randomSequence());
88
+ if ($this->getStatus()==self::STATUS_NOT_ACTIVE) {
89
+ $this->setStatus($customer->getIsSubscribed() ? self::STATUS_SUBSCRIBED : self::STATUS_UNSUBSCRIBED);
90
+ }
91
+ $this->save();
92
+ }
93
+ return $this;
94
+ }
95
+
96
 
97
  }
app/code/local/Conlabz/Useroptin/controllers/AccountController.php CHANGED
@@ -30,12 +30,16 @@ class Conlabz_Useroptin_AccountController extends Mage_Customer_AccountControlle
30
 
31
  if (Mage::getStoreConfig("newsletter/subscription/confirm_logged_email_template") == 1){
32
 
33
- $status = Mage::getModel("newsletter/subscriber")->subscribe($this->getRequest()->getPost('email'));
34
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
35
- Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
36
- }
37
- else {
38
- Mage::getSingleton('customer/session')->addSuccess($this->__('Thank you for your subscription.'));
 
 
 
 
39
  }
40
 
41
  }else{
30
 
31
  if (Mage::getStoreConfig("newsletter/subscription/confirm_logged_email_template") == 1){
32
 
33
+ if ($this->getRequest()->getParam('is_subscribed', false)) {
34
+
35
+ $status = Mage::getModel("newsletter/subscriber")->subscribe($this->getRequest()->getPost('email'));
36
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
37
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
38
+ }
39
+ else {
40
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Thank you for your subscription.'));
41
+ }
42
+
43
  }
44
 
45
  }else{
app/code/local/Conlabz/Useroptin/controllers/ManageController.php CHANGED
@@ -11,14 +11,28 @@ class Conlabz_Useroptin_ManageController extends Mage_Newsletter_ManageControlle
11
 
12
  if (Mage::getStoreConfig("newsletter/subscription/confirm_logged_email_template") == 1){
13
 
14
- $status = Mage::getModel("newsletter/subscriber")->subscribe(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
15
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
16
- Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
17
- }
18
- else {
19
- Mage::getSingleton('customer/session')->addSuccess($this->__('Thank you for your subscription.'));
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
 
22
  }else{
23
  Mage::getSingleton('customer/session')->getCustomer()
24
  ->setStoreId(Mage::app()->getStore()->getId())
@@ -38,6 +52,7 @@ class Conlabz_Useroptin_ManageController extends Mage_Newsletter_ManageControlle
38
  }
39
  $this->_redirect('customer/account/');
40
  }
 
41
 
42
 
43
  }
11
 
12
  if (Mage::getStoreConfig("newsletter/subscription/confirm_logged_email_template") == 1){
13
 
14
+ if ((boolean)$this->getRequest()->getParam('is_subscribed', false)) {
15
+
16
+ $subscriber = Mage::getModel("newsletter/subscriber")->loadByEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
17
+ if (!$subscriber->isSubscribed()) {
18
+ $status = Mage::getModel("newsletter/subscriber")->subscribe(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
19
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
20
+ }else {
21
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Thank you for your subscription.'));
22
+ }
23
+
24
+ } else {
25
+
26
+ Mage::getSingleton('customer/session')->getCustomer()
27
+ ->setStoreId(Mage::app()->getStore()->getId())
28
+ ->setIsSubscribed((boolean)$this->getRequest()->getParam('is_subscribed', false))
29
+ ->save();
30
+
31
+ Mage::getSingleton('customer/session')->addSuccess($this->__('The subscription has been removed.'));
32
+
33
+ }
34
 
35
+
36
  }else{
37
  Mage::getSingleton('customer/session')->getCustomer()
38
  ->setStoreId(Mage::app()->getStore()->getId())
52
  }
53
  $this->_redirect('customer/account/');
54
  }
55
+
56
 
57
 
58
  }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Conlabz_Useroptin</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
  <channel>community</channel>
@@ -11,10 +11,10 @@
11
  &#xD;
12
  Die Extension unterst&#xFC;tzt die M&#xF6;glichkeit einer E-Mail Best&#xE4;tigung f&#xFC;r bereits registrierte Nutzer.</description>
13
  <notes>Init extension version</notes>
14
- <authors><author><name>Conlabz GmbH</name><user>conlabz</user><email>info@conlabz.de</email></author></authors>
15
- <date>2012-10-31</date>
16
- <time>12:35:08</time>
17
- <contents><target name="magelocal"><dir name="Conlabz"><dir name="Useroptin"><dir><dir name="Model"><dir name="Newsletter"><file name="Subscriber.php" hash="caf374c0edd74e7790156b9e11dbeeb5"/></dir></dir><dir name="controllers"><file name="AccountController.php" hash="ce0480909da1e826004c369683f869f8"/><file name="ManageController.php" hash="5c992a56639ff73d7e11b727d7234bd7"/></dir><dir name="etc"><file name="config.xml" hash="1f8bbe36a855612700d547cbf7d0f65a"/><file name="system.xml" hash="c1b2c86ab52c60983cc2418b351b4b97"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Conlabz_Useroptin.xml" hash="3ea42c7b0f6070edce5ffc159374a8f3"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.13</min><max>5.4.7</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Conlabz_Useroptin</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
  <channel>community</channel>
11
  &#xD;
12
  Die Extension unterst&#xFC;tzt die M&#xF6;glichkeit einer E-Mail Best&#xE4;tigung f&#xFC;r bereits registrierte Nutzer.</description>
13
  <notes>Init extension version</notes>
14
+ <authors><author><name>Conlabz GmbH</name><user>conlabz</user><email>ingo@conlabz.de</email></author></authors>
15
+ <date>2012-11-12</date>
16
+ <time>12:47:27</time>
17
+ <contents><target name="magelocal"><dir name="Conlabz"><dir name="Useroptin"><dir><dir name="Model"><dir name="Newsletter"><file name="Subscriber.php" hash="3d059f356ea930807c65b3792bb786d8"/></dir></dir><dir name="controllers"><file name="AccountController.php" hash="408e22761be5451ad6a511e735f2f6dc"/><file name="ManageController.php" hash="8c874a74b0ad5ec4010f581aa0608a24"/></dir><dir name="etc"><file name="config.xml" hash="1f8bbe36a855612700d547cbf7d0f65a"/><file name="system.xml" hash="c1b2c86ab52c60983cc2418b351b4b97"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Conlabz_Useroptin.xml" hash="3ea42c7b0f6070edce5ffc159374a8f3"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.13</min><max>5.4.7</max></php></required></dependencies>
20
  </package>