Netgo_UserandMobile - Version 1.0.1

Version Notes

Second Preview Release

Download this release

Release Info

Developer NetGo
Extension Netgo_UserandMobile
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Netgo/UserandMobile/Model/Observer.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Netgo_UserandMobile_Model_Observer {
3
+
4
+ public function example(Varien_Event_Observer $observer) {
5
+ $customer = $observer->getEvent()->getCustomer();
6
+
7
+ $chkMobileDuplicate = $customer->getMobile();
8
+
9
+ $customerCollection = Mage::getModel('customer/customer')->getCollection();
10
+ $customerCollection->addAttributeToSelect(array('mobile', 'firstname', 'lastname', 'email'));
11
+ $allMobileArr = array();
12
+
13
+ foreach ($customerCollection as $customer) {
14
+ $allMobileArr[] = $customer->getMobile();
15
+ }
16
+
17
+ if(in_array($chkMobileDuplicate, $allMobileArr)){
18
+ Mage::getSingleton('core/session')->addError('Mobile number is already in use.');
19
+ $url = Mage::getUrl('customer/account/create');
20
+ $response = Mage::app()->getFrontController()->getResponse();
21
+ $response->setRedirect($url);
22
+ $response->sendResponse();
23
+ exit;
24
+
25
+
26
+ }else{
27
+ //echo "not duplicate";die;
28
+ }
29
+ }
30
+
31
+ }
32
+ ?>
app/code/community/Netgo/UserandMobile/controllers/Customer/AccountController.php CHANGED
@@ -6,14 +6,14 @@
6
  * @copyright Copyright (c) 2015
7
  * @company NetAttingo Technologies
8
  * @package Netgo_UserandMobile
9
- * @author Vipin
10
- * @dev 77vips@gmail.com
11
  *
12
  */
13
  require_once "Mage/Customer/controllers/AccountController.php";
14
  class Netgo_UserandMobile_Customer_AccountController extends Mage_Customer_AccountController{
15
-
16
- /**
17
  * Processes login action
18
  * @return bool
19
  * @throws Exception
@@ -21,41 +21,53 @@ class Netgo_UserandMobile_Customer_AccountController extends Mage_Customer_Accou
21
  public function loginPostAction()
22
  {
23
  $session = $this->_getSession();
24
-
25
- $collection = Mage::getModel('customer/customer')->getCollection();
26
- $username = $this->getRequest()->getPost();
27
- $usermobile = $username['login']['username'];
28
- $website_id = Mage::app()->getWebsite()->getId();
29
- $collection->addAttributeToFilter('mobile', array('eq' =>$username['login']['username']));
30
- $custData = $collection->getData();
31
- $email = trim($custData[0]['email']);
32
- $customerId = (int) trim($custData[0]['entity_id']);
33
- try{
34
- $authenticateUser = Mage::getModel('customer/customer')->setWebsiteId($website_id)->authenticate($email, $username['login']['password']);
35
- }catch( Exception $e ){
36
- $session->addError('Invalid Login Detail');
37
- $this->_redirect('customer/account');
38
- }
39
-
40
-
41
- try{
42
- if($authenticateUser && $customerId){
43
-
44
- $customer = Mage::getModel('customer/customer')->load($customerId);
45
- $session->setCustomerAsLoggedIn($customer);
46
- $message = $this->__('You are now logged in as %s', $customer->getName());
47
- $session->addSuccess($message);
48
- Mage::log($message);
49
- }else{
50
- throw new Exception ($this->__('The login attempt was unsuccessful. Some parameter is missing Or wrong data '));
51
- }
52
- }catch (Exception $e){
53
- $session->addError($e->getMessage());
54
- }
55
- $this->_redirect('customer/account');
56
-
57
- }
 
 
 
 
 
 
 
 
 
58
 
 
 
 
59
  /**
60
  * Gets customer session
61
  * @return Mage_Core_Model_Abstract
@@ -64,5 +76,14 @@ class Netgo_UserandMobile_Customer_AccountController extends Mage_Customer_Accou
64
  {
65
  return Mage::getSingleton('customer/session');
66
  }
 
 
 
 
 
 
 
 
 
67
  }
68
-
6
  * @copyright Copyright (c) 2015
7
  * @company NetAttingo Technologies
8
  * @package Netgo_UserandMobile
9
+ * @author Vipin
10
+ * @dev 77vips@gmail.com
11
  *
12
  */
13
  require_once "Mage/Customer/controllers/AccountController.php";
14
  class Netgo_UserandMobile_Customer_AccountController extends Mage_Customer_AccountController{
15
+
16
+ /**
17
  * Processes login action
18
  * @return bool
19
  * @throws Exception
21
  public function loginPostAction()
22
  {
23
  $session = $this->_getSession();
24
+
25
+ $collection = Mage::getModel('customer/customer')->getCollection();
26
+ $username = $this->getRequest()->getPost();
27
+ $usermobile = $username['login']['username'];
28
+
29
+ if($this->isEmail($usermobile)){
30
+ parent::loginPostAction();
31
+ $message = $this->__('You are successfully logged in.');
32
+ $session->addSuccess($message);
33
+ $this->_redirect('customer/account');
34
+
35
+ }else{
36
+
37
+
38
+
39
+ $website_id = Mage::app()->getWebsite()->getId();
40
+ $collection->addAttributeToFilter('mobile', array('eq' =>$username['login']['username']));
41
+ $custData = $collection->getData();
42
+ $email = trim($custData[0]['email']);
43
+ $customerId = (int) trim($custData[0]['entity_id']);
44
+ try{
45
+ $authenticateUser = Mage::getModel('customer/customer')->setWebsiteId($website_id)->authenticate($email, $username['login']['password']);
46
+ }catch( Exception $e ){
47
+ $session->addError('Invalid Login Detail');
48
+ $this->_redirect('customer/account');
49
+ }
50
+
51
+
52
+ try{
53
+ if($authenticateUser && $customerId){
54
+
55
+ $customer = Mage::getModel('customer/customer')->load($customerId);
56
+ $session->setCustomerAsLoggedIn($customer);
57
+ $message = $this->__('You are now logged in as %s', $customer->getName());
58
+ $session->addSuccess($message);
59
+ Mage::log($message);
60
+ }else{
61
+ throw new Exception ($this->__('The login attempt was unsuccessful. Some parameter is missing Or wrong data '));
62
+ }
63
+ }catch (Exception $e){
64
+ $session->addError($e->getMessage());
65
+ }
66
+ $this->_redirect('customer/account');
67
 
68
+ }
69
+ }
70
+
71
  /**
72
  * Gets customer session
73
  * @return Mage_Core_Model_Abstract
76
  {
77
  return Mage::getSingleton('customer/session');
78
  }
79
+
80
+ function isEmail($user) {
81
+ if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $user)) {
82
+ return true;
83
+ } else {
84
+ return false;
85
+ }
86
+ }
87
+
88
  }
89
+
app/code/community/Netgo/UserandMobile/etc/config.xml CHANGED
@@ -15,7 +15,7 @@
15
  <config>
16
  <modules>
17
  <Netgo_UserandMobile>
18
- <version>0.1.0</version>
19
  </Netgo_UserandMobile>
20
  </modules>
21
  <frontend>
@@ -59,6 +59,19 @@
59
  <resourceModel>userandmobile_mysql4</resourceModel>
60
  </userandmobile>
61
  </models>
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  <resources>
63
  <userandmobile_setup>
64
  <setup>
15
  <config>
16
  <modules>
17
  <Netgo_UserandMobile>
18
+ <version>1.0.1</version>
19
  </Netgo_UserandMobile>
20
  </modules>
21
  <frontend>
59
  <resourceModel>userandmobile_mysql4</resourceModel>
60
  </userandmobile>
61
  </models>
62
+ <!--added by arshad starts-->
63
+ <events>
64
+ <customer_save_before>
65
+ <observers>
66
+ <netgo_userandMobile_model_observer>
67
+ <type>singleton</type>
68
+ <class>Netgo_UserandMobile_Model_Observer</class>
69
+ <method>example</method>
70
+ </netgo_userandMobile_model_observer>
71
+ </observers>
72
+ </customer_save_before>
73
+ </events>
74
+ <!-- added by arshad ends-->
75
  <resources>
76
  <userandmobile_setup>
77
  <setup>
app/code/community/Netgo/UserandMobile/sql/userandmobile_setup/install-0.1.0.php-- DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
- $installer = $this;
3
-
4
- /* @var $installer Diglin_Username_Model_Entity_Setup */
5
- $store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);
6
-
7
- /* @var $eavConfig Mage_Eav_Model_Config */
8
- $eavConfig = Mage::getSingleton('eav/config');
9
-
10
- $attribute = array(
11
- 'label' => 'Username',
12
- 'visible' => true,
13
- 'required' => true,
14
- 'type' => 'varchar',
15
- 'input' => 'text',
16
- 'sort_order' => 65,
17
- 'validate_rules' => array(
18
- 'max_text_length' => 30,
19
- 'min_text_length' => 1
20
- ),
21
- 'used_in_forms' => array('adminhtml_customer','adminhtml_checkout','customer_account_edit', 'customer_account_create', 'checkout_register'),
22
- );
23
-
24
- $installer->addAttribute('customer','username1', $attribute);
25
-
26
- $attributes = array('username1' => $attribute);
27
-
28
- foreach ($attributes as $attributeCode => $data) {
29
- $attribute = $eavConfig->getAttribute('customer', $attributeCode);
30
- $attribute->setWebsite( (($store->getWebsite())?$store->getWebsite():0));
31
- $attribute->addData($data);
32
- if (false === ($attribute->getIsSystem() == 1 && $attribute->getIsVisible() == 0)) {
33
- $usedInForms = array(
34
- 'customer_account_create',
35
- 'customer_account_edit',
36
- 'checkout_register',
37
- );
38
- if (!empty($data['adminhtml_only'])) {
39
- $usedInForms = array('adminhtml_customer');
40
- } else {
41
- $usedInForms[] = 'adminhtml_customer';
42
- }
43
- if (!empty($data['adminhtml_checkout'])) {
44
- $usedInForms[] = 'adminhtml_checkout';
45
- }else {
46
- $usedInForms[] = 'adminhtml_checkout';
47
- }
48
-
49
- $attribute->setData('used_in_forms', $usedInForms);
50
- }
51
- $attribute->save();
52
- }
53
-
54
- $installer->startSetup();
55
-
56
- $result = $installer->getConnection()->raw_fetchRow("SHOW COLUMNS from {$this->getTable('sales_flat_quote')} like '%customer_username%'");
57
- if(!is_array($result) || !in_array('customer_username', $result)){
58
- $installer->run("
59
- ALTER TABLE `{$this->getTable('sales_flat_quote')}`
60
- ADD `customer_username` VARCHAR( 255 ) NULL AFTER `customer_taxvat`
61
- ");
62
- }
63
-
64
- $installer->endSetup();
65
-
66
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netgo/UserandMobile/sql/userandmobile_setup/{install-0.1.0.php → install-1.0.1.php} RENAMED
@@ -19,6 +19,7 @@ $eavConfig = Mage::getSingleton('eav/config');
19
  $attribute = array(
20
  'label' => 'mobile',
21
  'visible' => true,
 
22
  'required' => false,
23
  'type' => 'varchar',
24
  'input' => 'text',
19
  $attribute = array(
20
  'label' => 'mobile',
21
  'visible' => true,
22
+ 'unique' => true,
23
  'required' => false,
24
  'type' => 'varchar',
25
  'input' => 'text',
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Netgo_UserandMobile</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -12,11 +12,11 @@
12
  Additionally, we have implemented such functionality that this extension will not effect front end files. This will not hamper any design or development in website or overwrite the files.&#xD;
13
  &#xD;
14
  To manage this user need to give a code manually as per the instruction mentioned. We will provide the code too.</description>
15
- <notes>First Preview Release</notes>
16
- <authors><author><name>Vipin</name><user>Netgo</user><email>77vips@gmail.com</email></author></authors>
17
- <date>2015-07-22</date>
18
- <time>02:33:08</time>
19
- <contents><target name="magecommunity"><dir name="Netgo"><dir name="UserandMobile"><dir name="Block"><dir name="Adminhtml"><file name="UserandMobilebackend.php" hash="2326928140c84b2abede730f45b4efd1"/></dir><file name="Index.php" hash="2dd9b40c75f9a34d3c32c2da0c9c511f"/><file name="Left.php" hash="27724da5d2012ae5e57bd64e2e0d79c6"/></dir><dir name="Helper"><file name="Data.php" hash="98f97f2a4babb0341cc427af59a36e11"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="UserandmobilebackendController.php" hash="3b7c156702bc890fea0443836a4b8a44"/></dir><dir name="Customer"><file name="AccountController.php" hash="b3dcc1301a052b15130f8066928a0a13"/></dir><file name="IndexController.php" hash="ba582b96acc3868cbf946f6b09697df3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="728bfd3d158f0cb25a661c47809c39d3"/><file name="config.xml" hash="d0007c7b3f50b81adfa79585fce45883"/><file name="system.xml" hash="a4e8feda0115f6c0b46559a09537ccd7"/></dir><dir name="sql"><dir name="userandmobile_setup"><file name="install-0.1.0.php" hash="74e0a57068c6958d7dfb0147a6e3e669"/><file name="install-0.1.0.php--" hash="d8e87b6948cb22ce785df83c6abc90fd"/></dir></dir></dir></dir></target><target name="mage"><dir name="."><file name="readme.txt" hash="bb035cdd5a9a6fe53e34034d35ec6873"/></dir></target><target name="mageetc"><dir name="modules"><file name="Netgo_UserandMobile.xml" hash="ec9d2fc4c023d6d23af1db61cb5ebd9a"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Netgo_UserandMobile</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
12
  Additionally, we have implemented such functionality that this extension will not effect front end files. This will not hamper any design or development in website or overwrite the files.&#xD;
13
  &#xD;
14
  To manage this user need to give a code manually as per the instruction mentioned. We will provide the code too.</description>
15
+ <notes>Second Preview Release</notes>
16
+ <authors><author><name>Netgo</name><user>Netgo</user><email>netattingomails@gmail.com</email></author></authors>
17
+ <date>2016-01-18</date>
18
+ <time>06:30:10</time>
19
+ <contents><target name="magecommunity"><dir name="Netgo"><dir name="UserandMobile"><dir name="Block"><dir name="Adminhtml"><file name="UserandMobilebackend.php" hash="2326928140c84b2abede730f45b4efd1"/></dir><file name="Index.php" hash="2dd9b40c75f9a34d3c32c2da0c9c511f"/><file name="Left.php" hash="27724da5d2012ae5e57bd64e2e0d79c6"/></dir><dir name="Helper"><file name="Data.php" hash="98f97f2a4babb0341cc427af59a36e11"/></dir><dir name="Model"><file name="Observer.php" hash="8cdb39e3c76c8963b83aef20e42ea0f3"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="UserandmobilebackendController.php" hash="3b7c156702bc890fea0443836a4b8a44"/></dir><dir name="Customer"><file name="AccountController.php" hash="f544c7d381ddfec443a318f28a0dd0c4"/></dir><file name="IndexController.php" hash="ba582b96acc3868cbf946f6b09697df3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="728bfd3d158f0cb25a661c47809c39d3"/><file name="config.xml" hash="c27f2e82d1b337c63cd36f7bb66f7cc1"/><file name="system.xml" hash="a4e8feda0115f6c0b46559a09537ccd7"/></dir><dir name="sql"><dir name="userandmobile_setup"><file name="install-1.0.1.php" hash="90a3bdfa671ed4264d9c237c8238c935"/></dir></dir></dir></dir></target><target name="mage"><dir name="."><file name="readme.txt" hash="a047f55e64be41c4bc9e101f1949a55a"/></dir></target><target name="mageetc"><dir name="modules"><file name="Netgo_UserandMobile.xml" hash="ec9d2fc4c023d6d23af1db61cb5ebd9a"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
  </package>
readme.txt CHANGED
@@ -4,7 +4,7 @@
4
 
5
  1) Install this extension using Magento Connect.
6
 
7
- 2) Open "app/design/frontend/your theme package/default or your theme name/template/persistent/customer/form/register.phtml"
8
 
9
  3) Put following code just after email.
10
 
@@ -15,12 +15,12 @@
15
  </div>
16
  </div>
17
 
18
- 4) Now open app/design/frontend/your theme package/default or your theme name/template/persistent/customer/form/login.phtml
19
 
20
  5) Comment the email html and put following code just after email html you commented.
21
 
22
  <li>
23
- <label for="mobile" class="required"><em>*</em>Mobile Number</label>
24
  <div class="input-box">
25
  <input type="text" name="login[username]" value="" id="mobile" class="input-text required-entry validate" title="Mobile Number">
26
  </div>
4
 
5
  1) Install this extension using Magento Connect.
6
 
7
+ 2) Open "app/design/frontend/your_package_name/your_theme_name/template/persistent/customer/form/register.phtml"
8
 
9
  3) Put following code just after email.
10
 
15
  </div>
16
  </div>
17
 
18
+ 4) Now open app/design/frontend/your_package_name/your_theme_name/template/persistent/customer/form/login.phtml
19
 
20
  5) Comment the email html and put following code just after email html you commented.
21
 
22
  <li>
23
+ <label for="mobile" class="required"><em>*</em>Mobile/Email</label>
24
  <div class="input-box">
25
  <input type="text" name="login[username]" value="" id="mobile" class="input-text required-entry validate" title="Mobile Number">
26
  </div>