Magecompany_CustomerRedirect - Version 1.0.0.1

Version Notes

This Extension help to Redirect your customers on custom/magento page after customer login/Register.

Download this release

Release Info

Developer MageExtension Inc
Extension Magecompany_CustomerRedirect
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/community/Mageextension/Customer/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mageextension_Customer_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Mageextension/Customer/controllers/AccountController.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mage/Customer/controllers/AccountController.php';
4
+ class Mageextension_Customer_AccountController extends Mage_Customer_AccountController
5
+ {
6
+
7
+ public function indexAction()
8
+ {
9
+ //echo "Hello";die;
10
+ $this->loadLayout();
11
+ $this->_initLayoutMessages('customer/session');
12
+ $this->_initLayoutMessages('catalog/session');
13
+
14
+ $this->getLayout()->getBlock('content')->append(
15
+ $this->getLayout()->createBlock('customer/account_dashboard')
16
+ );
17
+ $this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
18
+ $this->renderLayout();
19
+ }
20
+
21
+ /**
22
+ * Login post action
23
+ */
24
+ public function loginPostAction()
25
+ {
26
+
27
+
28
+ if ($this->_getSession()->isLoggedIn()) {
29
+ $this->_redirect('*/*/');
30
+ return;
31
+ }
32
+ $session = $this->_getSession();
33
+
34
+ //checking is it from checkout
35
+ $session->setCustomerRedirectFlag(0);
36
+ $context = $this->getRequest()->getPost('context');
37
+ $customerAlwaysRedirectToUrl = Mage::getStoreConfig('mageextension/customerredirect/always');
38
+ if((!$customerAlwaysRedirectToUrl)){
39
+ $session->setCustomerRedirectFlag(1);
40
+ }
41
+
42
+ if ($this->getRequest()->isPost()) {
43
+ $login = $this->getRequest()->getPost('login');
44
+ if (!empty($login['username']) && !empty($login['password'])) {
45
+ try {
46
+ $session->login($login['username'], $login['password']);
47
+ if ($session->getCustomer()->getIsJustConfirmed()) {
48
+ $this->_welcomeCustomer($session->getCustomer(), true);
49
+
50
+ }
51
+ } catch (Mage_Core_Exception $e) {
52
+ switch ($e->getCode()) {
53
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
54
+ $value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
55
+ $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
56
+ break;
57
+ case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
58
+ $message = $e->getMessage();
59
+ break;
60
+ default:
61
+ $message = $e->getMessage();
62
+ }
63
+ $session->addError($message);
64
+ $session->setUsername($login['username']);
65
+ } catch (Exception $e) {
66
+ // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
67
+ }
68
+ } else {
69
+ $session->addError($this->__('Login and password are required.'));
70
+ }
71
+ }
72
+
73
+ $this->_loginPostRedirect();
74
+ }
75
+
76
+
77
+ protected function _loginPostRedirect()
78
+ {
79
+ //customer session
80
+ $session = $this->_getSession();
81
+ $preUrl = $session->getBeforeAuthUrl(true);
82
+
83
+ $cusromerRedirectStatus = Mage::getStoreConfig('mageextension/customerredirect/active');
84
+ $customerRedirectUrl = Mage::getStoreConfig('mageextension/customerredirect/redirecturl');
85
+
86
+ $redirectUrl = $preUrl;
87
+ if(($cusromerRedirectStatus) && ($customerRedirectUrl) && ($session->getCustomerRedirectFlag()) && (strpos($preUrl, 'checkout/onepage') == '')){
88
+ $redirectUrl = Mage::getUrl().$customerRedirectUrl;
89
+ }
90
+
91
+ if(($cusromerRedirectStatus) && ($customerRedirectUrl) && (!$session->getCustomerRedirectFlag())){
92
+ $redirectUrl = Mage::getUrl().$customerRedirectUrl;
93
+ }
94
+
95
+ if ($this->_getSession()->isLoggedIn()) {
96
+ $this->_redirectUrl($redirectUrl);
97
+ return;
98
+ }
99
+
100
+ $this->_redirectUrl($preUrl);
101
+ }
102
+ protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false)
103
+ {
104
+ $this->_getSession()->addSuccess(
105
+ $this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())
106
+ );
107
+ if ($this->_isVatValidationEnabled()) {
108
+
109
+ $configAddressType = Mage::helper('customer/address')->getTaxCalculationAddressType();
110
+ $userPrompt = '';
111
+ switch ($configAddressType) {
112
+ case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING:
113
+ $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you shipping address for proper VAT calculation', Mage::getUrl('customer/address/edit'));
114
+ break;
115
+ default:
116
+ $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you billing address for proper VAT calculation', Mage::getUrl('customer/address/edit'));
117
+ }
118
+ $this->_getSession()->addSuccess($userPrompt);
119
+ }
120
+
121
+ $customer->sendNewAccountEmail(
122
+ $isJustConfirmed ? 'confirmed' : 'registered',
123
+ '',
124
+ Mage::app()->getStore()->getId()
125
+ );
126
+
127
+
128
+ $cusromerRedirectStatus = Mage::getStoreConfig('mageextension/accountredirect/active');
129
+ $customerCreateRedirectUrl = Mage::getStoreConfig('mageextension/accountredirect/redirecturl');
130
+
131
+
132
+ if($cusromerRedirectStatus==1)
133
+ {
134
+ $successUrl = Mage::getUrl().$customerCreateRedirectUrl;
135
+
136
+ }
137
+ else{
138
+ $successUrl = Mage::getUrl('*/*/index', array('_secure'=>true));}
139
+ if ($this->_getSession()->getBeforeAuthUrl()) {
140
+
141
+ if($cusromerRedirectStatus==1)
142
+ {
143
+ $successUrl = Mage::getUrl().$customerCreateRedirectUrl;
144
+ }else
145
+ {
146
+
147
+ $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
148
+ }
149
+ }
150
+ return $successUrl;
151
+
152
+ }
153
+
154
+ }
app/code/community/Mageextension/Customer/etc/adminhtml.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <menu>
4
+ <mageextension translate="title" module="mageextension">
5
+ <title>Mage Extension</title>
6
+ <sort_order>50</sort_order>
7
+ <children>
8
+ <extension>
9
+ <title>Customer Redirect Configuration</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/system_config/edit/section/mageextension/index</action>
12
+ </extension>
13
+ </children>
14
+ </mageextension>
15
+ </menu>
16
+ </config>
app/code/community/Mageextension/Customer/etc/config.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mageextension_Customer>
5
+ <version>1.1.0</version>
6
+ </Mageextension_Customer>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <customer>
11
+
12
+ <args>
13
+
14
+ <modules>
15
+ <mageextension_customer before="Mage_Customer">Mageextension_Customer</mageextension_customer>
16
+ </modules>
17
+
18
+ </args>
19
+
20
+ </customer>
21
+ </routers>
22
+ </frontend>
23
+ <global>
24
+ <helpers>
25
+ <mageextension>
26
+ <class>Mageextension_Customer_Helper</class>
27
+ </mageextension>
28
+ </helpers>
29
+ </global>
30
+ <adminhtml>
31
+ <acl>
32
+ <resources>
33
+ <all>
34
+ <title>Allow everything</title>
35
+ </all>
36
+ <admin>
37
+ <children>
38
+ <system>
39
+ <children>
40
+ <config>
41
+ <children>
42
+ <mageextension translate="title" module="mageextension">
43
+ <title>Customer Redirect setting</title>
44
+ <sort_order>99</sort_order>
45
+ </mageextension>
46
+ </children>
47
+ </config>
48
+ </children>
49
+ </system>
50
+ </children>
51
+ </admin>
52
+ </resources>
53
+ </acl>
54
+ </adminhtml>
55
+ </config>
app/code/community/Mageextension/Customer/etc/system.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magetab translate="label">
5
+ <label>Mage Extension</label>
6
+ <sort_order>150</sort_order>
7
+ </magetab>
8
+ </tabs>
9
+ <sections>
10
+ <mageextension translate="label" module="mageextension">
11
+
12
+ <label>Customer Redirect Configuration</label>
13
+ <tab>magetab</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
+ <customerredirect translate="label">
20
+ <label>Customer After Login Redirect</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>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <active translate="label">
28
+ <label>Enable</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </active>
36
+ <always translate="label">
37
+ <label>Always Redirect</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>10</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </always>
45
+ <redirecturl translate="label">
46
+ <label>Redirect Url</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>20</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <comment><![CDATA[Put url in format : customer/account]]></comment>
53
+ </redirecturl>
54
+ </fields>
55
+ </customerredirect>
56
+ </groups>
57
+ <groups>
58
+ <accountredirect translate="label">
59
+ <label>Customer Create Account After Redirect</label>
60
+ <frontend_type>text</frontend_type>
61
+ <sort_order>10</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ <fields>
66
+ <active translate="label">
67
+ <label>Enable</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>10</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </active>
75
+ <redirecturl translate="label">
76
+ <label>Redirect Url</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>20</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ <comment><![CDATA[Put url in format : checkout/cart]]></comment>
83
+ </redirecturl>
84
+ </fields>
85
+ </accountredirect>
86
+ </groups>
87
+
88
+ </mageextension>
89
+ </sections>
90
+ </config>
app/etc/modules/Mageextension_Customer.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mageextension_Customer>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Customer/>
9
+ </depends>
10
+ </Mageextension_Customer>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magecompany_CustomerRedirect</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This Extension help to Redirect your customers on custom/magento page after customer login/Register. </summary>
10
+ <description>This Extension help to Redirect your customers on custom/magento page after customer login/Register. </description>
11
+ <notes>This Extension help to Redirect your customers on custom/magento page after customer login/Register. </notes>
12
+ <authors><author><name>MageExtension Inc</name><user>MageExtension</user><email>mageextension2014@gmail.com</email></author></authors>
13
+ <date>2014-12-04</date>
14
+ <time>07:12:43</time>
15
+ <contents><target name="magecommunity"><dir name="Mageextension"><dir name="Customer"><dir name="Helper"><file name="Data.php" hash="1ca7a8fe82b3553ea5b1c743c5ed5b89"/></dir><dir name="controllers"><file name="AccountController.php" hash="7a19ef8fb32fafa4e1725cd6fe4fe34f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="51964739d4b6f9e105ea55717fd8d588"/><file name="config.xml" hash="597ede288e5af679a768ddc1cc5cca16"/><file name="system.xml" hash="7d7528b304f17c62293680c0eadeffab"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mageextension_Customer.xml" hash="292e0fb2f476d774a54c957608e272e5"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>