SpadarLogin - Version 0.1.1

Version Notes

+Admin users can login as customers from "customer view" pages in admin

+There is an option to allow login as a customer right on the "order view" pages in admin

+There is an access control option. Admin can assign to a specific role whether role users can login as customers.

Download this release

Release Info

Developer Magento Core Team
Extension SpadarLogin
Version 0.1.1
Comparing to
See all releases


Version 0.1.1

app/code/community/Spadar/Login/Helper/Button.php ADDED
@@ -0,0 +1,59 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Spadar_Login_Helper_Button extends Mage_Core_Helper_Abstract
19
+ {
20
+ public function getButtonData()
21
+ {
22
+ return array(
23
+ 'label' => $this->__('Log in customer'),
24
+ 'onclick' => 'popWin(\''.Mage::getModel('adminhtml/url')->getUrl('spadarloginadmin/', array('id' => $this->getCustomerId())).'\', \'customer\');',
25
+ );
26
+ }
27
+
28
+ protected function getCustomerId()
29
+ {
30
+ $customerId = 0;
31
+ $currentCustomer = Mage::registry('current_customer');
32
+ $currentOrder = Mage::registry('current_order');
33
+
34
+ if ($currentCustomer instanceof Mage_Customer_Model_Customer)
35
+ {
36
+ $customerId = $currentCustomer->getId();
37
+ }
38
+
39
+ if ($currentOrder instanceof Mage_Sales_Model_Order)
40
+ {
41
+ $customerId = $currentOrder->getCustomerId();
42
+ }
43
+
44
+ return $customerId;
45
+ }
46
+
47
+ public function getButtonArea()
48
+ {
49
+ /* @var $adminSession Mage_Admin_Model_Session */
50
+ $adminSession = Mage::getSingleton('admin/session');
51
+
52
+ if (!$adminSession->isAllowed('customer/login') || !$this->getCustomerId())
53
+ {
54
+ return 'hidden';
55
+ }
56
+
57
+ return 'header';
58
+ }
59
+ }
app/code/community/Spadar/Login/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Spadar_Login_Helper_Data extends Mage_Core_Helper_Abstract
19
+ {
20
+
21
+ }
app/code/community/Spadar/Login/Model/Login.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Spadar_Login_Model_Login extends Mage_Catalog_Model_Abstract
19
+ {
20
+ protected function _construct()
21
+ {
22
+ $this->_init('spadarlogin/login');
23
+ }
24
+
25
+ public function truncate()
26
+ {
27
+ $this->getResource()->truncate();
28
+
29
+ return $this;
30
+ }
31
+ }
app/code/community/Spadar/Login/Model/Mysql4/Login.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Spadar_Login_Model_Mysql4_Login extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+ /**
21
+ * Initialize resource
22
+ */
23
+ protected function _construct()
24
+ {
25
+ $this->_init('spadarlogin/login', 'login_id');
26
+ }
27
+
28
+ public function truncate()
29
+ {
30
+ $this->_getWriteAdapter()->truncateTable($this->getMainTable());
31
+ }
32
+ }
app/code/community/Spadar/Login/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Spadar_Login_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
19
+ {
20
+ public function indexAction()
21
+ {
22
+ /* @var $adminSession Mage_Admin_Model_Session */
23
+ $adminSession = Mage::getSingleton('admin/session');
24
+ $customerId = $this->getRequest()->getParam('id');
25
+ $customer = Mage::getModel('customer/customer')->load($customerId);
26
+
27
+ if (!$adminSession->isAllowed('customer/login') || !$customer->getId())
28
+ {
29
+ return $this->_redirect('admin/');
30
+ }
31
+
32
+ $hash = md5(uniqid(mt_rand(), true));
33
+ $login = Mage::getModel('spadarlogin/login')
34
+ ->setLoginHash($hash)
35
+ ->setCustomerId($customerId)
36
+ ->save();
37
+
38
+ return $this->_redirect('spadarlogin/', array(
39
+ 'id' => $hash,
40
+ '_store' => $customer->getStoreId(),
41
+ ));
42
+ }
43
+ }
app/code/community/Spadar/Login/controllers/IndexController.php ADDED
@@ -0,0 +1,38 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Spadar_Login_IndexController extends Mage_Core_Controller_Front_Action
19
+ {
20
+ public function indexAction()
21
+ {
22
+ $hash = $this->getRequest()->getParam('id');
23
+ $login = Mage::getModel('spadarlogin/login')->load($hash, 'login_hash');
24
+
25
+ $login->truncate();
26
+
27
+ if ($login->getCustomerId())
28
+ {
29
+ /* @var $customerSession Mage_Customer_Model_Session */
30
+ $customerSession = Mage::getSingleton('customer/session');
31
+ $customerSession->loginById($login->getCustomerId());
32
+
33
+ return $this->_redirect('customer/account/');
34
+ }
35
+
36
+ return $this->_redirect('');
37
+ }
38
+ }
app/code/community/Spadar/Login/etc/config.xml ADDED
@@ -0,0 +1,140 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Spadar_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 Spadar
13
+ * @package Spadar_Login
14
+ * @author Yury Ksenevich <sales@spadar.com>
15
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Spadar_Login>
22
+ <version>0.1.1</version>
23
+ </Spadar_Login>
24
+ </modules>
25
+
26
+ <global>
27
+ <models>
28
+ <spadarlogin>
29
+ <class>Spadar_Login_Model</class>
30
+ <resourceModel>spadarlogin_mysql4</resourceModel>
31
+ </spadarlogin>
32
+ <spadarlogin_mysql4>
33
+ <class>Spadar_Login_Model_Mysql4</class>
34
+ <entities>
35
+ <login>
36
+ <table>spadar_login</table>
37
+ </login>
38
+ </entities>
39
+ </spadarlogin_mysql4>
40
+ </models>
41
+ <blocks>
42
+ <spadarlogin>
43
+ <class>Spadar_Login_Block</class>
44
+ </spadarlogin>
45
+ </blocks>
46
+
47
+ <helpers>
48
+ <spadarlogin><class>Spadar_Login_Helper</class></spadarlogin>
49
+ </helpers>
50
+
51
+ <resources>
52
+ <spadarlogin_setup>
53
+ <setup>
54
+ <module>Spadar_Login</module>
55
+ </setup>
56
+ <connection>
57
+ <use>core_setup</use>
58
+ </connection>
59
+ </spadarlogin_setup>
60
+ <spadarlogin_write>
61
+ <connection>
62
+ <use>core_write</use>
63
+ </connection>
64
+ </spadarlogin_write>
65
+ <spadarlogin_read>
66
+ <connection>
67
+ <use>core_read</use>
68
+ </connection>
69
+ </spadarlogin_read>
70
+ </resources>
71
+ </global>
72
+
73
+ <admin>
74
+ <routers>
75
+ <spadarloginadmin>
76
+ <use>admin</use>
77
+ <args>
78
+ <module>Spadar_Login_Adminhtml</module>
79
+ <frontName>spadarloginadmin</frontName>
80
+ </args>
81
+ </spadarloginadmin>
82
+ </routers>
83
+ </admin>
84
+
85
+ <adminhtml>
86
+ <layout>
87
+ <updates>
88
+ <spadarlogin>
89
+ <file>spadarlogin.xml</file>
90
+ </spadarlogin>
91
+ </updates>
92
+ </layout>
93
+
94
+ <translate>
95
+ <modules>
96
+ <Spadar_Login>
97
+ <files>
98
+ <default>Spadar_Login.csv</default>
99
+ </files>
100
+ </Spadar_Login>
101
+ </modules>
102
+ </translate>
103
+
104
+ <acl>
105
+ <resources>
106
+ <admin>
107
+ <children>
108
+ <customer>
109
+ <children>
110
+ <login>
111
+ <title>Login as Customer</title>
112
+ </login>
113
+ </children>
114
+ </customer>
115
+ </children>
116
+ </admin>
117
+ </resources>
118
+ </acl>
119
+ </adminhtml>
120
+
121
+ <frontend>
122
+ <routers>
123
+ <spadarlogin>
124
+ <use>standard</use>
125
+ <args>
126
+ <module>Spadar_Login</module>
127
+ <frontName>spadarlogin</frontName>
128
+ </args>
129
+ </spadarlogin>
130
+ </routers>
131
+ </frontend>
132
+
133
+ <default>
134
+ <customer>
135
+ <login>
136
+ <order_view_display>0</order_view_display>
137
+ </login>
138
+ </customer>
139
+ </default>
140
+ </config>
app/code/community/Spadar/Login/etc/system.xml ADDED
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Spadar_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 Spadar
13
+ * @package Spadar_Login
14
+ * @author Yury Ksenevich <sales@spadar.com>
15
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
21
+ <customer translate="label comment" module="module">
22
+ <tab>customer</tab>
23
+ <groups>
24
+ <login translate="label comment" module="spadarlogin">
25
+ <label>Log in as customer</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>200</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <fields>
32
+ <order_view_display translate="label">
33
+ <label>Display Login Button on "View Order" page</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>sort</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <comment><![CDATA[]]></comment>
39
+ </order_view_display>
40
+ </fields>
41
+ </login>
42
+ </groups>
43
+ </customer>
44
+ </sections>
45
+ </config>
app/code/community/Spadar/Login/sql/spadarlogin_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,36 @@
1
+ <?php
2
+ /**
3
+ * Spadar_Login
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Spadar
12
+ * @package Spadar_Login
13
+ * @author Yury Ksenevich <sales@spadar.com>
14
+ * @copyright Copyright (c) 2012 Yury Ksenevich s.p.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
19
+ $installer = $this;
20
+
21
+ $installer->startSetup();
22
+
23
+ $installer->run('
24
+
25
+ DROP TABLE IF EXISTS `'.$installer->getTable('spadarlogin/login').';
26
+
27
+ CREATE TABLE `'.$installer->getTable('spadarlogin/login').'` (
28
+ `login_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
29
+ `login_hash` CHAR(32) NOT NULL,
30
+ `customer_id` INT UNSIGNED NOT NULL DEFAULT 0,
31
+ PRIMARY KEY (`login_Id`)
32
+ ) ENGINE = InnoDB;
33
+
34
+ ');
35
+
36
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/spadarlogin.xml ADDED
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_customer_edit>
4
+ <reference name="customer_edit">
5
+ <action method="addButton"><id>login</id><data helper="spadarlogin/button/getButtonData" /><level>-1</level><sort>0</sort><area helper="spadarlogin/button/getButtonArea" /></action>
6
+ </reference>
7
+ </adminhtml_customer_edit>
8
+
9
+ <adminhtml_sales_order_view>
10
+ <reference name="sales_order_edit">
11
+ <action method="addButton" ifconfig="customer/login/order_view_display"><id>login</id><data helper="spadarlogin/button/getButtonData" /><level>-1</level><sort>0</sort><area helper="spadarlogin/button/getButtonArea" /></action>
12
+ </reference>
13
+ </adminhtml_sales_order_view>
14
+ </layout>
app/etc/modules/Spadar_Login.xml ADDED
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Spadar_Login>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <self_name></self_name>
8
+ <priority>1001</priority>
9
+ <depends>
10
+ <Mage_Customer />
11
+ <Mage_Adminhtml />
12
+ </depends>
13
+ </Spadar_Login>
14
+ </modules>
15
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>SpadarLogin</name>
4
+ <version>0.1.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>+Admin users can login as customers from "customer view" pages in admin
12
+
13
+ +There is an option to allow login as a customer right on the "order view" pages in admin
14
+
15
+ +There is an access control option. Admin can assign to a specific role whether role users can login as customers.</notes>
16
+ <authors><author><name>Yury Ksenevich</name><user>auto-converted</user><email>yury@spadar.com</email></author></authors>
17
+ <date>2012-02-09</date>
18
+ <time>18:59:34</time>
19
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="spadarlogin.xml" hash="f470c1380305439bf686d7059aab80fa"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Spadar_Login.xml" hash="f785705a056d3d219ca3b8d0def2236a"/></dir></target><target name="magecommunity"><dir name="Spadar"><dir name="Login"><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="c92575e25cf74732e384c9c6bc32d3c0"/></dir><file name="IndexController.php" hash="b07532165c256e0c7ac7098ba04651dd"/></dir><dir name="etc"><file name="config.xml" hash="20c636a3d34c4c8087c6208feb5074bb"/><file name="system.xml" hash="2885913865982dbee80712c4584c3562"/></dir><dir name="Helper"><file name="Button.php" hash="fd6b89013dd8b1da3ad3be44cf1fb739"/><file name="Data.php" hash="fe708d7516fddc793b2451446b9d3c61"/></dir><dir name="Model"><dir name="Mysql4"><file name="Login.php" hash="1fe212ec6ada70e72a821cc0b533dcd6"/></dir><file name="Login.php" hash="f5023f50d57c0eb6c6b88f380752b14d"/></dir><dir name="sql"><dir name="spadarlogin_setup"><file name="mysql4-install-0.1.0.php" hash="25af0280aa8fc427d93a352aad6f4315"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies/>
22
+ </package>