SpadarLogin - Version 1.0.2

Version Notes

* Magento CE 1.8 compatibility tests
* If customer is registered in removed/inactive store, admin will be logged in to another store from the website or default store
!!! 1.4 Branch compatibility fix

Download this release

Release Info

Developer Yury Ksenevich
Extension SpadarLogin
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/Widgento/Login/Helper/Button.php CHANGED
@@ -21,15 +21,17 @@
21
 
22
  class Widgento_Login_Helper_Button extends Mage_Core_Helper_Abstract
23
  {
 
 
24
  public function getButtonData()
25
  {
26
  return array(
27
  'label' => $this->__('Log in customer'),
28
- 'onclick' => 'window.open(\''.Mage::getModel('adminhtml/url')->getUrl('widgentologinadmin/', array('id' => $this->getCustomerId())).'\', \'customer\');',
29
  );
30
  }
31
 
32
- protected function getCustomerId()
33
  {
34
  $customerId = 0;
35
  $currentCustomer = Mage::registry('current_customer');
@@ -53,7 +55,7 @@ class Widgento_Login_Helper_Button extends Mage_Core_Helper_Abstract
53
  /* @var $adminSession Mage_Admin_Model_Session */
54
  $adminSession = Mage::getSingleton('admin/session');
55
 
56
- if (!$adminSession->isAllowed('customer/login') || !$this->getCustomerId())
57
  {
58
  return 'hidden';
59
  }
21
 
22
  class Widgento_Login_Helper_Button extends Mage_Core_Helper_Abstract
23
  {
24
+
25
+
26
  public function getButtonData()
27
  {
28
  return array(
29
  'label' => $this->__('Log in customer'),
30
+ 'onclick' => 'window.open(\''.Mage::getModel('adminhtml/url')->getUrl('widgentologinadmin/', array('id' => $this->_getCustomerId())).'\', \'customer\');',
31
  );
32
  }
33
 
34
+ protected function _getCustomerId()
35
  {
36
  $customerId = 0;
37
  $currentCustomer = Mage::registry('current_customer');
55
  /* @var $adminSession Mage_Admin_Model_Session */
56
  $adminSession = Mage::getSingleton('admin/session');
57
 
58
+ if (!$adminSession->isAllowed('customer/login') || !Mage::helper('widgentologin')->getCustomerStoreId($this->_getCustomerId()))
59
  {
60
  return 'hidden';
61
  }
app/code/community/Widgento/Login/Helper/Data.php CHANGED
@@ -21,5 +21,38 @@
21
 
22
  class Widgento_Login_Helper_Data extends Mage_Core_Helper_Abstract
23
  {
24
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
21
 
22
  class Widgento_Login_Helper_Data extends Mage_Core_Helper_Abstract
23
  {
24
+ public function getCustomerStoreId($customerId)
25
+ {
26
+ if (!$customerId)
27
+ {
28
+ return false;
29
+ }
30
+
31
+ $customer = Mage::getModel('customer/customer')->load($customerId);
32
+
33
+ $customerStore = Mage::app()->getStore($customer->getStoreId());
34
+
35
+ if ($customerStore && $customerStore->getIsActive())
36
+ {
37
+ return $customer->getStoreId();
38
+ }
39
+
40
+ if ($customerStore)
41
+ {
42
+ $customerWebsite = Mage::app()->getWebsite($customerStore->getWebsiteId());
43
+
44
+ foreach ($customerWebsite->getStores() as $websiteStore)
45
+ {
46
+ if ($websiteStore->getIsActive())
47
+ {
48
+ return $websiteStore->getId();
49
+ }
50
+ }
51
+ }
52
+
53
+ if (0 == Mage::getStoreConfig('customer/account_share/scope'))
54
+ {
55
+ Mage::app()->getDefaultStoreView()->getId();
56
+ }
57
+ }
58
  }
app/code/community/Widgento/Login/controllers/Adminhtml/IndexController.php CHANGED
@@ -41,7 +41,7 @@ class Widgento_Login_Adminhtml_IndexController extends Mage_Adminhtml_Controller
41
 
42
  return $this->_redirect('widgentologin/', array(
43
  'id' => $hash,
44
- '_store' => $customer->getStoreId(),
45
  ));
46
  }
47
  }
41
 
42
  return $this->_redirect('widgentologin/', array(
43
  'id' => $hash,
44
+ '_store' => Mage::helper('widgentologin')->getCustomerStoreId($customer->getStoreId()),
45
  ));
46
  }
47
  }
app/code/community/Widgento/Login/controllers/IndexController.php CHANGED
@@ -32,13 +32,21 @@ class Widgento_Login_IndexController extends Mage_Core_Controller_Front_Action
32
  {
33
  /* @var $customerSession Mage_Customer_Model_Session */
34
  $customerSession = Mage::getSingleton('customer/session');
35
- $customerSession
36
- ->renewSession()
37
- ->loginById($login->getCustomerId());
 
 
 
 
 
 
 
 
38
 
39
  return $this->_redirect('customer/account/');
40
  }
41
 
42
  return $this->_redirect('');
43
  }
44
- }
32
  {
33
  /* @var $customerSession Mage_Customer_Model_Session */
34
  $customerSession = Mage::getSingleton('customer/session');
35
+
36
+ if (method_exists($customerSession, 'renewSession'))
37
+ {
38
+ $customerSession->renewSession();
39
+ }
40
+ else // for 1.4
41
+ {
42
+ $customerSession->logout();
43
+ }
44
+
45
+ $customerSession->loginById($login->getCustomerId());
46
 
47
  return $this->_redirect('customer/account/');
48
  }
49
 
50
  return $this->_redirect('');
51
  }
52
+ }
app/code/community/Widgento/Login/etc/config.xml CHANGED
@@ -23,7 +23,7 @@
23
  <config>
24
  <modules>
25
  <Widgento_Login>
26
- <version>1.0.1</version>
27
  </Widgento_Login>
28
  </modules>
29
 
@@ -150,7 +150,7 @@
150
  <default>
151
  <customer>
152
  <login>
153
- <order_view_display>0</order_view_display>
154
  </login>
155
  </customer>
156
  </default>
23
  <config>
24
  <modules>
25
  <Widgento_Login>
26
+ <version>1.0.2</version>
27
  </Widgento_Login>
28
  </modules>
29
 
150
  <default>
151
  <customer>
152
  <login>
153
+ <order_view_display>1</order_view_display>
154
  </login>
155
  </customer>
156
  </default>
app/code/community/Widgento/Login/sql/widgentologin_setup/mysql4-install-0.1.0.php CHANGED
@@ -28,12 +28,11 @@ $installer->run('
28
 
29
  DROP TABLE IF EXISTS `'.$installer->getTable('widgentologin/login_deprecated').';
30
 
31
- DELETE FROM `'.$installer->getTable('core/resource').'`
32
  WHERE code LIKE "spadar%";
33
 
34
  ');
35
 
36
-
37
  $installer->run('
38
 
39
  DROP TABLE IF EXISTS `'.$installer->getTable('widgentologin/login').';
28
 
29
  DROP TABLE IF EXISTS `'.$installer->getTable('widgentologin/login_deprecated').';
30
 
31
+ DELETE FROM `'.$installer->getTable('core/resource').'
32
  WHERE code LIKE "spadar%";
33
 
34
  ');
35
 
 
36
  $installer->run('
37
 
38
  DROP TABLE IF EXISTS `'.$installer->getTable('widgentologin/login').';
app/code/community/Widgento/Login/sql/widgentologin_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Widgento_Login
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Widgento
13
+ * @package Widgento_Login
14
+ * @author Yury Ksenevich <info@widgento.com>
15
+ * @copyright Copyright (c) 2012-2013 Yury Ksenevich p.e.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+
20
+ ?><?php
21
+
22
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
23
+ $installer = $this;
24
+
25
+ $installer->startSetup();
26
+
27
+ $installer->run('
28
+
29
+ DROP TABLE IF EXISTS `'.$installer->getTable('widgentologin/login').';
30
+
31
+ CREATE TABLE `'.$installer->getTable('widgentologin/login').'` (
32
+ `login_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
33
+ `login_hash` CHAR(32) NOT NULL,
34
+ `customer_id` INT UNSIGNED NOT NULL DEFAULT 0,
35
+ PRIMARY KEY (`login_Id`)
36
+ ) ENGINE = InnoDB;
37
+
38
+ ');
39
+
40
+ $installer->endSetup();
app/etc/modules/Widgento_Login.xml CHANGED
@@ -18,6 +18,27 @@
18
  */
19
 
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  -->
22
 
23
  <config>
@@ -34,4 +55,4 @@
34
  </depends>
35
  </Widgento_Login>
36
  </modules>
37
- </config>
18
  */
19
 
20
 
21
+ -->
22
+
23
+ <!--
24
+
25
+ /**
26
+ * Widgento_Login
27
+ *
28
+ * NOTICE OF LICENSE
29
+ *
30
+ * This source file is subject to the Open Software License (OSL 3.0), a
31
+ * copy of which is available through the world-wide-web at this URL:
32
+ * http://opensource.org/licenses/osl-3.0.php
33
+ *
34
+ * @category Widgento
35
+ * @package Widgento_Login
36
+ * @author Yury Ksenevich <info@widgento.com>
37
+ * @copyright Copyright (c) 2012-2013 Yury Ksenevich p.e.
38
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
39
+ */
40
+
41
+
42
  -->
43
 
44
  <config>
55
  </depends>
56
  </Widgento_Login>
57
  </modules>
58
+ </config>
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SpadarLogin</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Login as Customer</summary>
10
  <description>Allows admin users login as customers from admin</description>
11
- <notes>* Installer and uninstaller fixes</notes>
 
 
12
  <authors><author><name>Yury Ksenevich</name><user>widgento</user><email>info@widgento.com</email></author><author><name>Yury Ksenevich</name><user>spadar</user><email>yury@spadar.com</email></author></authors>
13
- <date>2013-03-19</date>
14
- <time>06:12:33</time>
15
- <contents><target name="magecommunity"><dir name="Widgento"><dir name="Core"><dir name="Helper"><file name="Data.php" hash="a673690cb6fde3ca3e25d7b83afba4cd"/></dir><dir name="Model"><file name="Feed.php" hash="91781b3c405ce3900bdf3f64795f3309"/><dir name="Uninstall"><file name="Abstract.php" hash="c069c7e45b5de8b65a58d370d4e56de5"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RewriteController.php" hash="0e05cd7a8f0d40ab027245efc63981fb"/></dir></dir><dir name="etc"><file name="config.xml" hash="37d79fc4c59ede48d9a2caa524004500"/><file name="manifest.xml" hash="eda1735b3b36cd7b6ed3684b07977dcc"/></dir></dir><dir name="Login"><dir name="Helper"><file name="Button.php" hash="f3756ce56dc28eea983fefc1a6e0d0e0"/><file name="Data.php" hash="8461aed15af139ada4c642176f4ff334"/></dir><dir name="Model"><file name="Login.php" hash="31e985418c1c873832602d10cc04f60d"/><dir name="Mysql4"><file name="Login.php" hash="2fb95870ec9c5a39e8a189f9c68c73c9"/></dir><file name="Uninstall.php" hash="2434a51afa2a2ea347787d4fa1851270"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="dbe5649f46d090c984f402bb2f1c4d73"/></dir><file name="IndexController.php" hash="fbb750cd6a1b4711d25b9b06a531a03f"/></dir><dir name="etc"><file name="config.xml" hash="4ef0860ba65388c51e9b33427d6694f9"/><file name="manifest.xml" hash="4b90d9b13f74af0fc9a6fb18d62834b4"/><file name="system.xml" hash="ae3eeeadd9e69fd4183734e64d8b5704"/></dir><dir name="sql"><dir name="widgentologin_setup"><file name="mysql4-install-0.1.0.php" hash="335ae70160c9b35ae21dbdb1959b6276"/><file name="mysql4-upgrade-1.0.1.php" hash="2afebc758e86bf5da091c4695c6c5781"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Widgento_Core.xml" hash="bbbe85f43685ff715e596022e8f3b85c"/><file name="Widgento_Login.xml" hash="8a6d46626452447c230b316a3f6e5408"/><file name="Spadar_Login.xml" hash="2f268af3c708a77c5386f394c665b2f1"/></dir></target><target name="mage"><dir name="shell"><file name="widgento_uninstall.php" hash="39ce6580a0e517991a171d4e36a3f1bf"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Widgento_Login.csv" hash="0b9020a898e0ae4c95b3a61a8a193156"/></dir><dir name="en_US"><file name="Widgento_Login.csv" hash="68458781e96bf72778efce90103748e9"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="widgentologin.xml" hash="3cf262f067940c92cfa7fce0adf63012"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.4</min><max>1.7.0.2</max></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SpadarLogin</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Login as Customer</summary>
10
  <description>Allows admin users login as customers from admin</description>
11
+ <notes>* Magento CE 1.8 compatibility tests&#xD;
12
+ * If customer is registered in removed/inactive store, admin will be logged in to another store from the website or default store&#xD;
13
+ !!! 1.4 Branch compatibility fix </notes>
14
  <authors><author><name>Yury Ksenevich</name><user>widgento</user><email>info@widgento.com</email></author><author><name>Yury Ksenevich</name><user>spadar</user><email>yury@spadar.com</email></author></authors>
15
+ <date>2013-10-28</date>
16
+ <time>08:22:14</time>
17
+ <contents><target name="magecommunity"><dir name="Widgento"><dir name="Core"><dir name="Helper"><file name="Data.php" hash="a673690cb6fde3ca3e25d7b83afba4cd"/></dir><dir name="Model"><file name="Feed.php" hash="91781b3c405ce3900bdf3f64795f3309"/><dir name="Uninstall"><file name="Abstract.php" hash="c069c7e45b5de8b65a58d370d4e56de5"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RewriteController.php" hash="0e05cd7a8f0d40ab027245efc63981fb"/></dir></dir><dir name="etc"><file name="config.xml" hash="37d79fc4c59ede48d9a2caa524004500"/><file name="manifest.xml" hash="eda1735b3b36cd7b6ed3684b07977dcc"/></dir></dir><dir name="Login"><dir name="Helper"><file name="Button.php" hash="4b7520e5f6361f242f787183ff522ffd"/><file name="Data.php" hash="8d52284b9f5ad177f9d2759159a77101"/></dir><dir name="Model"><file name="Login.php" hash="31e985418c1c873832602d10cc04f60d"/><dir name="Mysql4"><file name="Login.php" hash="2fb95870ec9c5a39e8a189f9c68c73c9"/></dir><file name="Uninstall.php" hash="2434a51afa2a2ea347787d4fa1851270"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="9f4670f3e0408057843c65a95eb57f9d"/></dir><file name="IndexController.php" hash="2d6ab4505667dc4be6df53ba32566cdb"/></dir><dir name="etc"><file name="config.xml" hash="953d41348ee7a5df4d899c5d31ae7dc7"/><file name="manifest.xml" hash="4b90d9b13f74af0fc9a6fb18d62834b4"/><file name="system.xml" hash="ae3eeeadd9e69fd4183734e64d8b5704"/></dir><dir name="sql"><dir name="widgentologin_setup"><file name="mysql4-install-0.1.0.php" hash="b6a1f14309120188482a98bc8b9752a4"/><file name="mysql4-install-1.0.1.php" hash="100adfc73e521d31e5d72abb19a63b10"/><file name="mysql4-upgrade-1.0.1.php" hash="2afebc758e86bf5da091c4695c6c5781"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Widgento_Core.xml" hash="bbbe85f43685ff715e596022e8f3b85c"/><file name="Widgento_Login.xml" hash="b2f6acf7566648e2404294075c28a0bd"/><file name="Spadar_Login.xml" hash="2f268af3c708a77c5386f394c665b2f1"/></dir></target><target name="mage"><dir name="shell"><file name="widgento_uninstall.php" hash="39ce6580a0e517991a171d4e36a3f1bf"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Widgento_Login.csv" hash="0b9020a898e0ae4c95b3a61a8a193156"/></dir><dir name="en_US"><file name="Widgento_Login.csv" hash="68458781e96bf72778efce90103748e9"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="widgentologin.xml" hash="3cf262f067940c92cfa7fce0adf63012"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.4</min><max/></package></required></dependencies>
20
  </package>