DigitalPianism_AjaxLogin - Version 0.2.0

Version Notes

- Support for account creation

Download this release

Release Info

Developer Digital Pianism
Extension DigitalPianism_AjaxLogin
Version 0.2.0
Comparing to
See all releases


Code changes from version 0.1.7 to 0.2.0

app/code/community/DigitalPianism/AjaxLogin/controllers/IndexController.php CHANGED
@@ -3,6 +3,253 @@
3
  class DigitalPianism_AjaxLogin_IndexController extends Mage_Core_Controller_Front_Action
4
  {
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  public function forgotpasswordAction()
7
  {
8
  $session = Mage::getSingleton('customer/session');
3
  class DigitalPianism_AjaxLogin_IndexController extends Mage_Core_Controller_Front_Action
4
  {
5
 
6
+ /**
7
+ * Get Customer Model
8
+ *
9
+ * @return Mage_Customer_Model_Customer
10
+ */
11
+ protected function _getCustomer()
12
+ {
13
+ $customer = Mage::registry('current_customer');
14
+ if (!$customer) {
15
+ $customer = Mage::getModel('customer/customer')->setId(null);
16
+ }
17
+ if ($this->getRequest()->getParam('is_subscribed', false)) {
18
+ $customer->setIsSubscribed(1);
19
+ }
20
+ /**
21
+ * Initialize customer group id
22
+ */
23
+ $customer->getGroupId();
24
+
25
+ return $customer;
26
+ }
27
+
28
+ /**
29
+ * Validate customer data and return errors if they are
30
+ *
31
+ * @param Mage_Customer_Model_Customer $customer
32
+ * @return array|string
33
+ */
34
+ protected function _getCustomerErrors($customer)
35
+ {
36
+ $errors = array();
37
+ $request = $this->getRequest();
38
+ if ($request->getPost('create_address')) {
39
+ $errors = $this->_getErrorsOnCustomerAddress($customer);
40
+ }
41
+ $customerForm = $this->_getCustomerForm($customer);
42
+ $customerData = $customerForm->extractData($request);
43
+ $customerErrors = $customerForm->validateData($customerData);
44
+ if ($customerErrors !== true) {
45
+ $errors = array_merge($customerErrors, $errors);
46
+ } else {
47
+ $customerForm->compactData($customerData);
48
+ $customer->setPassword($request->getPost('password'));
49
+ $customer->setPasswordConfirmation($request->getPost('confirmation'));
50
+ $customerErrors = $customer->validate();
51
+ if (is_array($customerErrors)) {
52
+ $errors = array_merge($customerErrors, $errors);
53
+ }
54
+ }
55
+ return $errors;
56
+ }
57
+
58
+ /**
59
+ * Get Customer Form Initalized Model
60
+ *
61
+ * @param Mage_Customer_Model_Customer $customer
62
+ * @return Mage_Customer_Model_Form
63
+ */
64
+ protected function _getCustomerForm($customer)
65
+ {
66
+ /* @var $customerForm Mage_Customer_Model_Form */
67
+ $customerForm = Mage::getModel('customer/form');
68
+ $customerForm->setFormCode('customer_account_create');
69
+ $customerForm->setEntity($customer);
70
+ return $customerForm;
71
+ }
72
+
73
+ /**
74
+ * Gets customer address
75
+ *
76
+ * @param $customer
77
+ * @return array $errors
78
+ */
79
+ protected function _getErrorsOnCustomerAddress($customer)
80
+ {
81
+ $errors = array();
82
+ /* @var $address Mage_Customer_Model_Address */
83
+ $address = Mage::getModel('customer/address');
84
+ /* @var $addressForm Mage_Customer_Model_Form */
85
+ $addressForm = Mage::getModel('customer/form');
86
+ $addressForm->setFormCode('customer_register_address')
87
+ ->setEntity($address);
88
+
89
+ $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
90
+ $addressErrors = $addressForm->validateData($addressData);
91
+ if (is_array($addressErrors)) {
92
+ $errors = array_merge($errors, $addressErrors);
93
+ }
94
+ $address->setId(null)
95
+ ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
96
+ ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
97
+ $addressForm->compactData($addressData);
98
+ $customer->addAddress($address);
99
+
100
+ $addressErrors = $address->validate();
101
+ if (is_array($addressErrors)) {
102
+ $errors = array_merge($errors, $addressErrors);
103
+ }
104
+ return $errors;
105
+ }
106
+
107
+ /**
108
+ * Success Registration
109
+ *
110
+ * @param Mage_Customer_Model_Customer $customer
111
+ * @return Mage_Customer_AccountController
112
+ */
113
+ protected function _successProcessRegistration(Mage_Customer_Model_Customer $customer)
114
+ {
115
+ $session = Mage::getSingleton('customer/session');
116
+ if ($customer->isConfirmationRequired()) {
117
+ /** @var $app Mage_Core_Model_App */
118
+ $app = $this->_getApp();
119
+ /** @var $store Mage_Core_Model_Store*/
120
+ $store = $app->getStore();
121
+ $customer->sendNewAccountEmail(
122
+ 'confirmation',
123
+ $session->getBeforeAuthUrl(),
124
+ $store->getId()
125
+ );
126
+ $customerHelper = Mage::helper('customer');
127
+ $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>.',
128
+ $customerHelper->getEmailConfirmationUrl($customer->getEmail())));
129
+ $url = $this->_getUrl('*/*/index', array('_secure' => true));
130
+ } else {
131
+ $session->setCustomerAsLoggedIn($customer);
132
+ $url = $this->_welcomeCustomer($customer);
133
+ }
134
+ $this->_redirectSuccess($url);
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Add welcome message and send new account email.
140
+ * Returns success URL
141
+ *
142
+ * @param Mage_Customer_Model_Customer $customer
143
+ * @param bool $isJustConfirmed
144
+ * @return string
145
+ */
146
+ protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false)
147
+ {
148
+ Mage::getSingleton('customer/session')->addSuccess(
149
+ $this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())
150
+ );
151
+ if (Mage::helper('customer/address')->isVatValidationEnabled()) {
152
+ // Show corresponding VAT message to customer
153
+ $configAddressType = Mage::helper('customer/address')->getTaxCalculationAddressType();
154
+ $userPrompt = '';
155
+ switch ($configAddressType) {
156
+ case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING:
157
+ $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',
158
+ $this->_getUrl('customer/address/edit'));
159
+ break;
160
+ default:
161
+ $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',
162
+ $this->_getUrl('customer/address/edit'));
163
+ }
164
+ Mage::getSingleton('customer/session')->addSuccess($userPrompt);
165
+ }
166
+
167
+ $customer->sendNewAccountEmail(
168
+ $isJustConfirmed ? 'confirmed' : 'registered',
169
+ '',
170
+ Mage::app()->getStore()->getId()
171
+ );
172
+
173
+ $successUrl = Mage::getUrl('*/*/index', array('_secure' => true));
174
+ if (Mage::getSingleton('customer/session')->getBeforeAuthUrl()) {
175
+ $successUrl = Mage::getSingleton('customer/session')->getBeforeAuthUrl(true);
176
+ }
177
+ return $successUrl;
178
+ }
179
+
180
+ /**
181
+ * Add session error method
182
+ *
183
+ * @param string|array $errors
184
+ */
185
+ protected function _addSessionError($errors)
186
+ {
187
+ $session = Mage::getSingleton('customer/session');
188
+ $session->setCustomerFormData($this->getRequest()->getPost());
189
+ if (is_array($errors)) {
190
+ foreach ($errors as $errorMessage) {
191
+ $session->addError($errorMessage);
192
+ }
193
+ } else {
194
+ $session->addError($this->__('Invalid customer data'));
195
+ }
196
+ }
197
+
198
+ public function createAction()
199
+ {
200
+ // Clear the messages each time we call it
201
+ Mage::getSingleton('core/session')->getMessages(true);
202
+
203
+ $session = Mage::getSingleton('customer/session');
204
+
205
+ if ($session->isLoggedIn()) {
206
+ return;
207
+ }
208
+
209
+ $session->setEscapeMessages(true); // prevent XSS injection in user input
210
+ if (!$this->getRequest()->isPost()) {
211
+ return;
212
+ }
213
+
214
+ $result = array(
215
+ 'success' => false
216
+ );
217
+
218
+ $customer = $this->_getCustomer();
219
+
220
+ try {
221
+ $errors = $this->_getCustomerErrors($customer);
222
+
223
+ if (empty($errors)) {
224
+ $customer->cleanPasswordsValidationData();
225
+ $customer->save();
226
+ Mage::dispatchEvent('customer_register_success',
227
+ array('account_controller' => $this, 'customer' => $customer)
228
+ );
229
+ $this->_successProcessRegistration($customer);
230
+ $result['success'] = true;
231
+ return;
232
+ } else {
233
+ $result['error'] = $errors;
234
+ $this->_addSessionError($errors);
235
+ }
236
+ } catch (Mage_Core_Exception $e) {
237
+ $session->setCustomerFormData($this->getRequest()->getPost());
238
+ if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
239
+ $url = Mage::getUrl('customer/account/forgotpassword');
240
+ $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);
241
+ $session->setEscapeMessages(false);
242
+ } else {
243
+ $message = $e->getMessage();
244
+ }
245
+ $result['error'] = $message;
246
+ } catch (Exception $e) {
247
+ $result['error'] = $this->__('Cannot save the customer.');
248
+ }
249
+
250
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
251
+ }
252
+
253
  public function forgotpasswordAction()
254
  {
255
  $session = Mage::getSingleton('customer/session');
app/code/community/DigitalPianism/AjaxLogin/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <DigitalPianism_AjaxLogin>
5
- <version>0.1.7</version>
6
  </DigitalPianism_AjaxLogin>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <DigitalPianism_AjaxLogin>
5
+ <version>0.2.0</version>
6
  </DigitalPianism_AjaxLogin>
7
  </modules>
8
  <global>
app/design/frontend/base/default/layout/digitalpianism/ajaxlogin.xml CHANGED
@@ -14,10 +14,16 @@
14
  </action>
15
  </reference>
16
  <reference name="before_body_end">
17
- <block type="core/template" name="ajaxlogin" />
18
- </reference>
19
- <reference name="ajaxlogin">
20
- <action method="setTemplate" ifconfig="ajaxlogin/options/enable"><template>digitalpianism/ajaxlogin/index.phtml</template></action>
 
 
 
 
 
 
21
  </reference>
22
  </default>
23
 
14
  </action>
15
  </reference>
16
  <reference name="before_body_end">
17
+ <block type="core/template" name="ajaxlogin">
18
+ <action method="setTemplate" ifconfig="ajaxlogin/options/enable"><template>digitalpianism/ajaxlogin/index.phtml</template></action>
19
+ <block type="customer/form_register" name="customer_form_register_ajax" template="digitalpianism/ajaxlogin/register.phtml">
20
+ <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label">
21
+ <label>Form Fields Before</label>
22
+ </block>
23
+ </block>
24
+ <block type="persistent/form_remember" name="persistent.remember.me" template="persistent/remember_me.phtml" />
25
+ <block type="core/template" name="persistent.remember.me.tooltip" template="persistent/remember_me_tooltip.phtml" />
26
+ </block>
27
  </reference>
28
  </default>
29
 
app/design/frontend/base/default/template/digitalpianism/ajaxlogin/index.phtml CHANGED
@@ -22,7 +22,7 @@
22
  </ul>
23
  </div>
24
  <div class="buttons-set">
25
- <button type="button" class="button" title="<?php echo $this->__('Register') ?>" name="noaccount" id="noaccount" onclick="window.location = '<?php echo $this->getUrl('customer/account/create') ?>'"><span><span><?php echo $this->__('Register') ?></span></span></button>
26
  <button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
27
  <div class="progress-indicator">
28
  <span class="please-wait" id="login-please-wait" style="display:none;">
@@ -81,6 +81,23 @@
81
  </script>
82
  </div>
83
  <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  <?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
85
  <div id="ajaxlogin-logout-window" style="display: none;">
86
  <div class="page-title">
@@ -185,6 +202,11 @@
185
  maxWidth: 300
186
  }
187
  },
 
 
 
 
 
188
  forgot: {
189
  el : $$('.ajaxlogin-forgot'),
190
  event : 'click',
22
  </ul>
23
  </div>
24
  <div class="buttons-set">
25
+ <button type="button" class="button" title="<?php echo $this->__('Register') ?>" name="noaccount" id="noaccount"><span><span><?php echo $this->__('Register') ?></span></span></button>
26
  <button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
27
  <div class="progress-indicator">
28
  <span class="please-wait" id="login-please-wait" style="display:none;">
81
  </script>
82
  </div>
83
  <?php endif; ?>
84
+
85
+ <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()): ?>
86
+ <div id="ajaxlogin-create-window" style="display: none;">
87
+ <div class="page-title">
88
+ <span><?php echo $this->__('Create an Account') ?></span>
89
+ </div>
90
+ <form action="<?php echo $this->getUrl('ajaxlogin/index/create', array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'))) ?>" method="post" id="ajaxlogin-create-form">
91
+ <?php echo $this->getChildHtml(); ?>
92
+ </form>
93
+ <script type="text/javascript">
94
+ //<![CDATA[
95
+ var ajaxForgotForm = new VarienForm('ajaxlogin-create-form', true);
96
+ //]]>
97
+ </script>
98
+ </div>
99
+ <?php endif; ?>
100
+
101
  <?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
102
  <div id="ajaxlogin-logout-window" style="display: none;">
103
  <div class="page-title">
202
  maxWidth: 300
203
  }
204
  },
205
+ create: {
206
+ el : $$('#noaccount'),
207
+ event : 'click',
208
+ window: $('ajaxlogin-create-window')
209
+ },
210
  forgot: {
211
  el : $$('.ajaxlogin-forgot'),
212
  event : 'click',
app/design/frontend/base/default/template/digitalpianism/ajaxlogin/register.phtml ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="fieldset">
2
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
3
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
4
+ <h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
5
+ <ul class="form-list">
6
+ <li class="fields">
7
+ <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
8
+ </li>
9
+ <li>
10
+ <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
11
+ <div class="input-box">
12
+ <input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Email Address')) ?>" class="input-text validate-email required-entry" />
13
+ </div>
14
+ </li>
15
+ <?php if ($this->isNewsletterEnabled()): ?>
16
+ <li class="control">
17
+ <div class="input-box">
18
+ <input type="checkbox" name="is_subscribed" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sign Up for Newsletter')) ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
19
+ </div>
20
+ <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
21
+ <?php /* Extensions placeholder */ ?>
22
+ <?php echo $this->getChildHtml('customer.form.register.newsletter')?>
23
+ </li>
24
+ <?php endif ?>
25
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
26
+ <?php if ($_dob->isEnabled()): ?>
27
+ <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
28
+ <?php endif ?>
29
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
30
+ <?php if ($_taxvat->isEnabled()): ?>
31
+ <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
32
+ <?php endif ?>
33
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
34
+ <?php if ($_gender->isEnabled()): ?>
35
+ <li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
36
+ <?php endif ?>
37
+ </ul>
38
+ </div>
39
+ <?php if($this->getShowAddressFields()): ?>
40
+ <div class="fieldset">
41
+ <input type="hidden" name="create_address" value="1" />
42
+ <h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
43
+ <ul class="form-list">
44
+ <li class="fields">
45
+ <div class="field">
46
+ <label for="company"><?php echo $this->__('Company') ?></label>
47
+ <div class="input-box">
48
+ <input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
49
+ </div>
50
+ </div>
51
+ <div class="field">
52
+ <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
53
+ <div class="input-box">
54
+ <input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
55
+ </div>
56
+ </div>
57
+ </li>
58
+ <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
59
+ <li class="wide">
60
+ <label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
61
+ <div class="input-box">
62
+ <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
63
+ </div>
64
+ </li>
65
+ <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
66
+ <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
67
+ <li class="wide">
68
+ <div class="input-box">
69
+ <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
70
+ </div>
71
+ </li>
72
+ <?php endfor; ?>
73
+ <li class="fields">
74
+ <div class="field">
75
+ <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
76
+ <div class="input-box">
77
+ <input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('City')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
78
+ </div>
79
+ </div>
80
+ <div class="field">
81
+ <label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
82
+ <div class="input-box">
83
+ <select id="region_id" name="region_id" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
84
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
85
+ </select>
86
+ <script type="text/javascript">
87
+ //<![CDATA[
88
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
89
+ //]]>
90
+ </script>
91
+ <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
92
+ </div>
93
+ </div>
94
+ </li>
95
+ <li class="fields">
96
+ <div class="field">
97
+ <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
98
+ <div class="input-box">
99
+ <input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Zip/Postal Code')) ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
100
+ </div>
101
+ </div>
102
+ <div class="field">
103
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
104
+ <div class="input-box">
105
+ <?php echo $this->getCountryHtmlSelect() ?>
106
+ </div>
107
+ </div>
108
+ </li>
109
+ </ul>
110
+ <input type="hidden" name="default_billing" value="1" />
111
+ <input type="hidden" name="default_shipping" value="1" />
112
+ </div>
113
+ <?php endif; ?>
114
+ <div class="fieldset">
115
+ <h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
116
+ <ul class="form-list">
117
+ <li class="fields">
118
+ <div class="field">
119
+ <label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
120
+ <div class="input-box">
121
+ <input type="password" name="password" id="password" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
122
+ </div>
123
+ </div>
124
+ <div class="field">
125
+ <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
126
+ <div class="input-box">
127
+ <input type="password" name="confirmation" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Confirm Password')) ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
128
+ </div>
129
+ </div>
130
+ </li>
131
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
132
+ </ul>
133
+ </div>
134
+ <div class="buttons-set">
135
+ <div class="progress-indicator">
136
+ <span class="please-wait" id="create-please-wait" style="display:none;">
137
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" class="v-middle" alt=""/>
138
+ </span>
139
+ </div>
140
+ <button type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Submit')) ?>" class="button" name="create" id="create"><span><span><?php echo $this->__('Submit') ?></span></span></button>
141
+ </div>
142
+ <script type="text/javascript">
143
+ //<![CDATA[
144
+ <?php if($this->getShowAddressFields()): ?>
145
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
146
+ <?php endif; ?>
147
+ //]]>
148
+ </script>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DigitalPianism_AjaxLogin</name>
4
- <version>0.1.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -20,11 +20,11 @@
20
  &lt;p&gt;The module is enabled by default but you can disable it here if you need to.&lt;/p&gt;&#xD;
21
  &#xD;
22
  </description>
23
- <notes>- Fix a bug where the persistent popup would keep poping up after closing it.</notes>
24
  <authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
25
- <date>2015-09-18</date>
26
- <time>10:19:26</time>
27
- <contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="AjaxLogin"><dir name="Helper"><file name="Data.php" hash="1a04218d84eb0ad89d072f421cc2f993"/></dir><dir name="controllers"><file name="IndexController.php" hash="eb95f030fb4f847e68fef3d0160ea750"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2569f90cd6868d15e41f4788c61e7638"/><file name="config.xml" hash="e006262afad48f62eefb1a3873fc17f8"/><file name="system.xml" hash="71c81e7c67e405512bb5ed0729bfa2de"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_AjaxLogin.xml" hash="ff28627543caa7543c763f21ef4a5683"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="index.phtml" hash="6b904a3be849e831ef6d9552b6394716"/></dir></dir></dir><dir name="layout"><dir name="digitalpianism"><file name="ajaxlogin.xml" hash="09378fb468dbe71689acd53fa75c1eac"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="styles.css" hash="8a7f560e5041e52904858828acf378e9"/></dir></dir></dir><dir name="images"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="ajax-loader.gif" hash="b256d80f54c1415d7a6a6fdec39769f4"/><file name="box-content-bg.gif" hash="f5344140a3a9ad4267687b8ec40c5751"/><file name="box-header-bg.gif" hash="e1e109e8f6bfc2f2ccef04769553c60c"/><file name="cancel_round.png" hash="afcb08c1bdcdb7f9922ea289906fdfbf"/><file name="close.png" hash="0aa9c71e1e00deb929514c3b004e30c2"/><file name="shd-medium.png" hash="ed62cea276345a5003a4a6c6f47c1071"/><file name="spinner.gif" hash="73e57937304d89f251e7e540a24b095a"/></dir></dir></dir><dir name="js"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="script.js" hash="6fc82a436ed559a9b73ca7d6dfc0e48b"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="DigitalPianism_AjaxLogin.csv" hash="6eb7c029c2d98c59b574889e8380ccc2"/></dir><dir name="en_US"><file name="DigitalPianism_AjaxLogin.csv" hash="fd8a1490469491f382a9e0463e3de38b"/></dir></target></contents>
28
  <compatible/>
29
  <dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
30
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DigitalPianism_AjaxLogin</name>
4
+ <version>0.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
20
  &lt;p&gt;The module is enabled by default but you can disable it here if you need to.&lt;/p&gt;&#xD;
21
  &#xD;
22
  </description>
23
+ <notes>- Support for account creation</notes>
24
  <authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
25
+ <date>2015-09-21</date>
26
+ <time>14:16:04</time>
27
+ <contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="AjaxLogin"><dir name="Helper"><file name="Data.php" hash="1a04218d84eb0ad89d072f421cc2f993"/></dir><dir name="controllers"><file name="IndexController.php" hash="1d901439e801a1113c7a92097b5cf09b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2569f90cd6868d15e41f4788c61e7638"/><file name="config.xml" hash="211adcaa8849391879258a160897bd51"/><file name="system.xml" hash="71c81e7c67e405512bb5ed0729bfa2de"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_AjaxLogin.xml" hash="ff28627543caa7543c763f21ef4a5683"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="index.phtml" hash="860f08a68848ae0a40638261f8ae5719"/><file name="register.phtml" hash="fe2aa593c7ac9cccec12ab77ada97ec4"/></dir></dir></dir><dir name="layout"><dir name="digitalpianism"><file name="ajaxlogin.xml" hash="c583f009b9ac0e8bb344d46f0bb0a417"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="styles.css" hash="8a7f560e5041e52904858828acf378e9"/></dir></dir></dir><dir name="images"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="ajax-loader.gif" hash="b256d80f54c1415d7a6a6fdec39769f4"/><file name="box-content-bg.gif" hash="f5344140a3a9ad4267687b8ec40c5751"/><file name="box-header-bg.gif" hash="e1e109e8f6bfc2f2ccef04769553c60c"/><file name="cancel_round.png" hash="afcb08c1bdcdb7f9922ea289906fdfbf"/><file name="close.png" hash="0aa9c71e1e00deb929514c3b004e30c2"/><file name="shd-medium.png" hash="ed62cea276345a5003a4a6c6f47c1071"/><file name="spinner.gif" hash="73e57937304d89f251e7e540a24b095a"/></dir></dir></dir><dir name="js"><dir name="digitalpianism"><dir name="ajaxlogin"><file name="script.js" hash="765bc25958b87f1d3e206353cbc556eb"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="DigitalPianism_AjaxLogin.csv" hash="6eb7c029c2d98c59b574889e8380ccc2"/></dir><dir name="en_US"><file name="DigitalPianism_AjaxLogin.csv" hash="fd8a1490469491f382a9e0463e3de38b"/></dir></target></contents>
28
  <compatible/>
29
  <dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
30
  </package>
skin/frontend/base/default/js/digitalpianism/ajaxlogin/script.js CHANGED
@@ -381,6 +381,72 @@ AjaxLogin.prototype = {
381
  });
382
  });
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  $('ajaxlogin-forgot-password-form') && $('ajaxlogin-forgot-password-form').observe('submit', function(e) {
385
  if (typeof event != 'undefined') { // ie9 fix
386
  event.preventDefault ? event.preventDefault() : event.returnValue = false;
381
  });
382
  });
383
 
384
+ $('ajaxlogin-create-form') && $('ajaxlogin-create-form').observe('submit', function(e) {
385
+ if (typeof event != 'undefined') { // ie9 fix
386
+ event.preventDefault ? event.preventDefault() : event.returnValue = false;
387
+ }
388
+ Event.stop(e);
389
+
390
+ if (!ajaxLoginForm.validator.validate()) {
391
+ return false;
392
+ }
393
+
394
+ $('create-please-wait').show();
395
+ $('create').setAttribute('disabled', 'disabled');
396
+ $$('#ajaxlogin-create-form .buttons-set')[0]
397
+ .addClassName('disabled')
398
+ .setOpacity(0.5);
399
+
400
+ new Ajax.Request($('ajaxlogin-create-form').action, {
401
+ parameters: $('ajaxlogin-create-form').serialize(),
402
+ onSuccess: function(transport) {
403
+ var section = $('ajaxlogin-create-form');
404
+ if (!section) {
405
+ return;
406
+ }
407
+ var ul = section.select('.messages')[0];
408
+ if (ul) {
409
+ ul.remove();
410
+ }
411
+
412
+ var response = transport.responseText.evalJSON();
413
+ if (response.error) {
414
+ var section = $('ajaxlogin-create-form');
415
+ if (!section) {
416
+ return;
417
+ }
418
+ var ul = section.select('.messages')[0];
419
+ if (!ul) {
420
+ section.insert({
421
+ top: '<ul class="messages"></ul>'
422
+ });
423
+ ul = section.select('.messages')[0]
424
+ }
425
+ var li = $(ul).select('.error-msg')[0];
426
+ if (!li) {
427
+ $(ul).insert({
428
+ top: '<li class="error-msg"><ul></ul></li>'
429
+ });
430
+ li = $(ul).select('.error-msg')[0];
431
+ }
432
+ $(li).select('ul')[0].insert(
433
+ '<li>' + response.error + '</li>'
434
+ );
435
+ self.updateCaptcha('user_login');
436
+ }
437
+ if (response.redirect) {
438
+ document.location = response.redirect;
439
+ return;
440
+ }
441
+ $('create-please-wait').hide();
442
+ $('create').removeAttribute('disabled');
443
+ $$('#ajaxlogin-create-form .buttons-set')[0]
444
+ .removeClassName('disabled')
445
+ .setOpacity(1);
446
+ }
447
+ });
448
+ });
449
+
450
  $('ajaxlogin-forgot-password-form') && $('ajaxlogin-forgot-password-form').observe('submit', function(e) {
451
  if (typeof event != 'undefined') { // ie9 fix
452
  event.preventDefault ? event.preventDefault() : event.returnValue = false;