Magazento_Emailregistration - Version 1.0.0

Version Notes

1.0.0

Download this release

Release Info

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


Version 1.0.0

app/code/community/Magazento/Emailregistration/Block/Links.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Emailregistration_Block_Links extends Mage_Customer_Block_Account_Navigation
4
+ {
5
+
6
+ public function addTopLink()
7
+ {
8
+ // if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
9
+ // $storeId = Mage::app()->getStore()->getId();
10
+ // $storeUrl = Mage::getModel('core/store')->load($storeId)->getUrl();
11
+ //
12
+ // $route = $storeUrl.'#';
13
+ // $title = 'Magazento-Log-In';
14
+ // $this->getParentBlock()->addLink($title, '#', $title, false, array(), 15, null, 'class="osx"');
15
+ // }
16
+
17
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
18
+ $storeId = Mage::app()->getStore()->getId();
19
+ $storeUrl = Mage::getModel('core/store')->load($storeId)->getUrl();
20
+ $route = 'emailregistration/account/create/';
21
+ $title = 'Register';
22
+ $this->getParentBlock()->addLink($title, $route, $title, true, array(), 15, null, 'class="-"');
23
+ }
24
+
25
+
26
+ }
27
+
28
+
29
+
30
+
31
+ }
app/code/community/Magazento/Emailregistration/Block/Register.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magazento_Emailregistration_Block_Register extends Mage_Customer_Block_Form_Register
3
+ {
4
+ function getStoreUrl() {
5
+ $storeId = Mage::app()->getStore()->getId();
6
+ $storeUrl = Mage::getModel('core/store')->load($storeId)->getUrl();
7
+ return $storeUrl;
8
+ }
9
+ function getPostActionUrl() {
10
+ return $this->getStoreUrl().'emailregistration/account/createPost';
11
+ }
12
+ function getSuccessUrl() {
13
+ return $this->getStoreUrl().'customer/account/';
14
+ }
15
+ function getCreateUrl() {
16
+ return $this->getStoreUrl().'emailregistration/account/create/';
17
+ }
18
+
19
+
20
+ }
app/code/community/Magazento/Emailregistration/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Emailregistration_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ function getStoreUrl() {
7
+ $storeId = Mage::app()->getStore()->getId();
8
+ $storeUrl = Mage::getModel('core/store')->load($storeId)->getUrl();
9
+ return $storeUrl;
10
+ }
11
+ function getRegisterPostUrl() {
12
+ return $this->getStoreUrl().'emailregistration/account/createPost';
13
+ }
14
+ function getRegisterSuccessUrl() {
15
+ return $this->getStoreUrl().'customer/account/';
16
+ }
17
+ function getRegisterErrorUrl() {
18
+ return $this->getStoreUrl().'emailregistration/account/create/';
19
+ }
20
+
21
+ }
app/code/community/Magazento/Emailregistration/controllers/AccountController.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Customer/controllers/AccountController.php';
3
+
4
+ class Magazento_Emailregistration_AccountController extends Mage_Customer_AccountController
5
+ {
6
+ function genRandomString() {
7
+ $length = 10;
8
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
9
+ $string ='';
10
+ for ($p = 0; $p < $length; $p++) {
11
+ $string .= $characters[mt_rand(0, strlen($characters))];
12
+ }
13
+ return $string;
14
+ }
15
+
16
+ public function createAction()
17
+ {
18
+ $this->loadLayout();
19
+ $this->renderLayout();
20
+ }
21
+
22
+ public function createPostAction()
23
+ {
24
+
25
+ $session = $this->_getSession();
26
+ if ($session->isLoggedIn()) {
27
+ $this->_redirect('customer/*/');
28
+ return;
29
+ }
30
+ $session->setEscapeMessages(true); // prevent XSS injection in user input
31
+ if ($this->getRequest()->isPost()) {
32
+ $errors = array();
33
+
34
+ if (!$customer = Mage::registry('current_customer')) {
35
+ $customer = Mage::getModel('customer/customer')->setId(null);
36
+ }
37
+
38
+ /* @var $customerForm Mage_Customer_Model_Form */
39
+ $customerForm = Mage::getModel('customer/form');
40
+ $customerForm->setFormCode('customer_account_create')
41
+ ->setEntity($customer);
42
+
43
+ $customerData = $customerForm->extractData($this->getRequest());
44
+
45
+ if ($this->getRequest()->getParam('is_subscribed', false)) {
46
+ $customer->setIsSubscribed(1);
47
+ }
48
+
49
+ /**
50
+ * Initialize customer group id
51
+ */
52
+ $customer->getGroupId();
53
+
54
+ if ($this->getRequest()->getPost('create_address')) {
55
+ /* @var $address Mage_Customer_Model_Address */
56
+ $address = Mage::getModel('customer/address');
57
+ /* @var $addressForm Mage_Customer_Model_Form */
58
+ $addressForm = Mage::getModel('customer/form');
59
+ $addressForm->setFormCode('customer_register_address')
60
+ ->setEntity($address);
61
+
62
+ $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
63
+ $addressErrors = $addressForm->validateData($addressData);
64
+ if ($addressErrors === true) {
65
+ $address->setId(null)
66
+ ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
67
+ ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
68
+ $addressForm->compactData($addressData);
69
+ $customer->addAddress($address);
70
+
71
+ $addressErrors = $address->validate();
72
+ if (is_array($addressErrors)) {
73
+ $errors = array_merge($errors, $addressErrors);
74
+ }
75
+ } else {
76
+ $errors = array_merge($errors, $addressErrors);
77
+ }
78
+ }
79
+
80
+ try {
81
+ $password = $this->genRandomString();
82
+ // -------------------------------------- NEW
83
+ $customerForm->compactData($customerData);
84
+ $customer->setPassword($password);
85
+ $customer->setConfirmation($password);
86
+ $validationResult = count($errors) == 0;
87
+
88
+ if (true === $validationResult) {
89
+ $customer->save();
90
+
91
+ if ($customer->isConfirmationRequired()) {
92
+
93
+
94
+
95
+ $customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl());
96
+ $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
97
+ $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
98
+ return;
99
+ } else {
100
+ $session->setCustomerAsLoggedIn($customer);
101
+ $url = $this->_welcomeCustomer($customer);
102
+ $this->_redirectSuccess($url);
103
+ return;
104
+ }
105
+ } else {
106
+ $session->setCustomerFormData($this->getRequest()->getPost());
107
+ if (is_array($errors)) {
108
+ foreach ($errors as $errorMessage) {
109
+ $session->addError($errorMessage);
110
+ }
111
+ } else {
112
+ $session->addError($this->__('Invalid customer data'));
113
+ }
114
+ }
115
+ } catch (Mage_Core_Exception $e) {
116
+ $session->setCustomerFormData($this->getRequest()->getPost());
117
+ if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
118
+ $url = Mage::getUrl('customer/account/forgotpassword');
119
+ $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
120
+ $session->setEscapeMessages(false);
121
+ Mage::getSingleton('core/session')->addError($this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url));
122
+ } else {
123
+ $message = $e->getMessage();
124
+ }
125
+ $session->addError($message);
126
+ } catch (Exception $e) {
127
+ $session->setCustomerFormData($this->getRequest()->getPost())
128
+ ->addException($e, $this->__('Cannot save the customer.'));
129
+ }
130
+ }
131
+
132
+ $this->_redirectError(Mage::getUrl('emailregistration/account/create/', array('_secure' => true)));
133
+ }
134
+ }
app/code/community/Magazento/Emailregistration/etc/config.xml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magazento_Emailregistration>
5
+ <version>0.1.0</version>
6
+ </Magazento_Emailregistration>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <emailregistration>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Magazento_Emailregistration</module>
14
+ <frontName>magazento_emailregistration</frontName>
15
+ </args>
16
+ </emailregistration>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <emailregistration>
21
+ <file>magazento_emailregistration.xml</file>
22
+ </emailregistration>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <emailregistration>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Magazento_Emailregistration</module>
32
+ <frontName>emailregistration</frontName>
33
+ </args>
34
+ </emailregistration>
35
+ </routers>
36
+ </admin>
37
+ <global>
38
+ <models>
39
+ <emailregistration>
40
+ <class>Magazento_Emailregistration_Model</class>
41
+ <resourceModel>emailregistration_mysql4</resourceModel>
42
+ </emailregistration>
43
+ <emailregistration_mysql4>
44
+ <class>Magazento_Emailregistration_Model_Mysql4</class>
45
+ <entities>
46
+ <item>
47
+ <table>magazento_emailregistration_item</table>
48
+ </item>
49
+ <item_store>
50
+ <table>magazento_emailregistration_item_store</table>
51
+ </item_store>
52
+ </entities>
53
+ </emailregistration_mysql4>
54
+ </models>
55
+ <resources>
56
+ <emailregistration_setup>
57
+ <setup>
58
+ <module>Magazento_Emailregistration</module>
59
+ </setup>
60
+ <connection>
61
+ <use>core_setup</use>
62
+ </connection>
63
+ </emailregistration_setup>
64
+ <emailregistration_write>
65
+ <connection>
66
+ <use>core_write</use>
67
+ </connection>
68
+ </emailregistration_write>
69
+ <emailregistration_read>
70
+ <connection>
71
+ <use>core_read</use>
72
+ </connection>
73
+ </emailregistration_read>
74
+ </resources>
75
+ <blocks>
76
+ <emailregistration>
77
+ <class>Magazento_Emailregistration_Block</class>
78
+ </emailregistration>
79
+ </blocks>
80
+ <helpers>
81
+ <emailregistration>
82
+ <class>Magazento_Emailregistration_Helper</class>
83
+ </emailregistration>
84
+ </helpers>
85
+ </global>
86
+
87
+
88
+ </config>
app/design/frontend/default/default/layout/magazento_emailregistration.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <!-- <default>
5
+ <reference name="head">
6
+ <action method="addCss"><stylesheet>magazento/emailregistration/osx.css</stylesheet></action>
7
+ <action method="addItem">
8
+ <type>skin_js</type>
9
+ <name>magazento/jquery-1.5.1.min.js</name>
10
+ <params/>
11
+ </action>
12
+ <action method="addItem">
13
+ <type>skin_js</type>
14
+ <name>magazento/emailregistration/jquery.simplemodal.js</name>
15
+ <params/>
16
+ </action>
17
+ <action method="addItem">
18
+ <type>skin_js</type>
19
+ <name>magazento/emailregistration/osx.js</name>
20
+ <params/>
21
+ </action>
22
+ </reference>
23
+ <reference name="before_body_end">
24
+ <block type="emailregistration/register" name="emailregistration" template="magazento/emailregistration/form.phtml" />
25
+ </reference>
26
+ </default>-->
27
+
28
+
29
+ <default>
30
+ <reference name="top.links">
31
+ <block type="emailregistration/links" name="add.reg.link">
32
+ <action method="addTopLink"></action>
33
+ </block>
34
+ </reference>
35
+ </default>
36
+
37
+
38
+ <customer_account_create>
39
+ <remove name="customer_form_register"/>
40
+
41
+ <reference name="root">
42
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
43
+ </reference>
44
+ <reference name="content">
45
+ <block type="emailregistration/register" name="emailregistration.create" template="magazento/emailregistration/account.create.phtml" />
46
+ </reference>
47
+ </customer_account_create>
48
+
49
+ <emailregistration_account_create>
50
+ <reference name="root">
51
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
52
+ </reference>
53
+ <reference name="content">
54
+ <block type="emailregistration/register" name="emailregistration.create" template="magazento/emailregistration/account.create.phtml" />
55
+ </reference>
56
+ </emailregistration_account_create>
57
+
58
+
59
+ </layout>
app/design/frontend/default/default/template/magazento/emailregistration/account.create.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="account-create">
2
+ <div class="page-title">
3
+ <h1 class="login_title"><?php echo $this->__('Create an Account') ?></h1>
4
+ </div>
5
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
6
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
7
+ <fieldset>
8
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
9
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
10
+ <input type="hidden" value="Firstname" name="firstname" >
11
+ <input type="hidden" value="Lastname" name="lastname" >
12
+
13
+ <h3><?php echo $this->__('New Account Information') ?></h3>
14
+ <ul class="form-list group-select">
15
+ <li>
16
+ <div class="input-box">
17
+ <label for="email_address"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br />
18
+ <input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
19
+ </div>
20
+ </li>
21
+ </ul>
22
+ </fieldset>
23
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
24
+ <div class="buttons-set">
25
+ <a href="<?php echo $this->getBackUrl() ?>" class="back-link">&laquo; <?php echo $this->__('Back') ?></a>
26
+ <button class="button" type="submit"><span><?php echo $this->__('Submit') ?></span></button>
27
+ </div>
28
+ </form>
29
+ <script type="text/javascript">
30
+ //<![CDATA[
31
+ var dataForm = new VarienForm('form-validate', true);
32
+ //]]>
33
+ </script>
34
+ </div>
app/etc/modules/Magazento_Emailregistration.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magazento_Emailregistration>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magazento_Emailregistration>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magazento_Emailregistration</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>We have created a very simple customer registration where customer can just enter his or her email address.</summary>
10
+ <description>We have created a very simple customer registration where one can just enter his or her email address and then the system would set this as the new username, add a generic password, which only had to be changed by the user when she/he wants to login next time to add more info into the name/address/etc fields.
11
+
12
+ ------------
13
+ Registrations are annoying. People hate them. No matter how clear benefits of registration are and no matter how much of them WILL register eventually, they still hate it. But, in the other hand, they want to finish their jobs online, and most of them are willing to provide some information in order to finish their jobs. So why don't make their lives easier?</description>
14
+ <notes>1.0.0</notes>
15
+ <authors><author><name>volgodark</name><user>auto-converted</user><email>volgodark@gmail.com</email></author></authors>
16
+ <date>2011-04-16</date>
17
+ <time>10:36:48</time>
18
+ <contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="magazento_emailregistration.xml" hash="4fe81a392efb860195fe56a1b253ed68"/></dir><dir name="template"><dir name="magazento"><dir name="emailregistration"><file name="account.create.phtml" hash="24e380ef953d57e5d622b7ba4e196212"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Magazento"><dir name="Emailregistration"><dir name="Block"><file name="Links.php" hash="a2cb967cd9095ab429cd5aa9083434a0"/><file name="Register.php" hash="199e6700cefe89c437b415ad22675c40"/></dir><dir name="controllers"><file name="AccountController.php" hash="50df6b6bd36cf423fa4e7ecc9907ec5f"/></dir><dir name="etc"><file name="config.xml" hash="12564745849e0b5ac6fdbf355eb74ec7"/></dir><dir name="Helper"><file name="Data.php" hash="e6427edf67b1ec12829b15207666c57d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magazento_Emailregistration.xml" hash="789472d0078ad3bc704fb5a5d5930112"/></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies/>
21
+ </package>