Version Notes
- Controllers fix (_isAllowed);
- Auto installation with sample data generation in development version;
Download this release
Release Info
Developer | Alex Gusev |
Extension | Praxigento_LoginAs |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.2.0
- app/code/community/Praxigento/LoginAs/Config.php +128 -130
- app/code/community/Praxigento/LoginAs/Helper/Data.php +30 -30
- app/code/community/Praxigento/LoginAs/Model/Logger.php +109 -110
- app/code/community/Praxigento/LoginAs/Model/Observer.php +168 -168
- app/code/community/Praxigento/LoginAs/Model/Package.php +154 -159
- app/code/community/Praxigento/LoginAs/Test/{ConfigTest.php → Config_Test.php} +49 -60
- app/code/community/Praxigento/LoginAs/Test/Model/{LoggerTest.php → Logger_Test.php} +45 -57
- app/code/community/Praxigento/LoginAs/Test/phpunit.bootstrap.php +29 -30
- app/code/community/Praxigento/LoginAs/Test/phpunit.dist.xml +15 -0
- app/code/community/Praxigento/LoginAs/Test/phpunit.praxigento.loginas.xml +0 -10
- app/code/community/Praxigento/LoginAs/controllers/LoginController.php +115 -107
- app/code/community/Praxigento/LoginAs/controllers/RedirectController.php +96 -86
- app/code/community/Praxigento/LoginAs/etc/config.xml +172 -165
- app/code/community/Praxigento/LoginAs/etc/release.txt +14 -4
- app/code/community/Praxigento/LoginAs/etc/system.xml +117 -117
- app/code/community/Praxigento/LoginAs/sql/prxgt_lgas_setup/mysql4-install-1.0.0.php +44 -48
- app/code/community/Praxigento/LoginAs/sql/prxgt_lgas_setup/prxgt_install_func.php +0 -74
- app/design/adminhtml/default/default/layout/prxgt/lgas/{loginas_adminhtml_layout.xml → adminhtml_layout.xml} +31 -31
- app/design/adminhtml/default/default/template/prxgt/lgas/redirect.phtml +3 -3
- app/design/frontend/base/default/layout/prxgt/lgas/frontend_layout.xml +32 -0
- app/locale/en_US/prxgt/lgas/prxgt_lgas.csv +17 -17
- package.xml +8 -7
app/code/community/Praxigento/LoginAs/Config.php
CHANGED
@@ -1,130 +1,128 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* User: Alex Gusev <flancer64@gmail.com>
|
23 |
-
* Date: 13.10.2
|
24 |
-
* Time: 09:07
|
25 |
-
*/
|
26 |
-
class Praxigento_LoginAs_Config
|
27 |
-
{
|
28 |
-
/******************************************************************************************
|
29 |
-
* Attributes
|
30 |
-
*****************************************************************************************/
|
31 |
-
const ATTR_ORDER_CREATED_BY = 'prxgt_lgas_created_by';
|
32 |
-
/******************************************************************************************
|
33 |
-
*
|
34 |
-
*****************************************************************************************/
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
const
|
46 |
-
|
47 |
-
*
|
48 |
-
|
49 |
-
const
|
50 |
-
/******************************************************************************************
|
51 |
-
* Module's config.xml parameters
|
52 |
-
*****************************************************************************************/
|
53 |
-
const XMLCFG_ROUTER_ADMIN = 'prxgt_lgas_admin';
|
54 |
-
const XMLCFG_ROUTER_FRONT = 'prxgt_lgas_front';
|
55 |
-
|
56 |
-
/**
|
57 |
-
* 'true' - if admin user has right to view 'Created By' value.
|
58 |
-
* @return bool
|
59 |
-
*/
|
60 |
-
public static function canAccessCreatedBy()
|
61 |
-
{
|
62 |
-
return filter_var(Mage::getSingleton('admin/session')->isAllowed('sales/order/prxgt_lgas_created_by_access'), FILTER_VALIDATE_BOOLEAN);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* 'true' - if admin user has right to use 'Login As' feature.
|
67 |
-
* @return bool
|
68 |
-
*/
|
69 |
-
public static function canAccessLoginAs()
|
70 |
-
{
|
71 |
-
return filter_var(Mage::getSingleton('admin/session')->isAllowed('customer/prxgt_lgas_access'), FILTER_VALIDATE_BOOLEAN);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* 'true' - 'login as' feature is enabled, 'false' - otherwise.
|
76 |
-
* @return bool
|
77 |
-
*/
|
78 |
-
public static function cfgGeneralEnabled()
|
79 |
-
{
|
80 |
-
return filter_var(Mage::getStoreConfig('prxgt_lgas/general/enabled'), FILTER_VALIDATE_BOOLEAN);
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* 'true' - log events using Magento logger or Log4php logger (in case of Nmmlm_Log module is installed).
|
85 |
-
* @return bool
|
86 |
-
*/
|
87 |
-
public static function cfgGeneralLogEvents()
|
88 |
-
{
|
89 |
-
return filter_var(Mage::getStoreConfig('prxgt_lgas/general/log_events'), FILTER_VALIDATE_BOOLEAN);
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
*
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
*
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
*
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$val
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
}
|
130 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
23 |
+
* Date: 13.10.2
|
24 |
+
* Time: 09:07
|
25 |
+
*/
|
26 |
+
class Praxigento_LoginAs_Config
|
27 |
+
{
|
28 |
+
/******************************************************************************************
|
29 |
+
* Attributes
|
30 |
+
*****************************************************************************************/
|
31 |
+
const ATTR_ORDER_CREATED_BY = 'prxgt_lgas_created_by';
|
32 |
+
/******************************************************************************************
|
33 |
+
* POST/GET request parameters
|
34 |
+
*****************************************************************************************/
|
35 |
+
/** don't change value: see Observer/doCustomerGridActionAdd() */
|
36 |
+
const REQ_PARAM_LAS_ID = 'id';
|
37 |
+
const ROUTE_CUSTOMER_LOGINAS = '/login/as/';
|
38 |
+
/******************************************************************************************
|
39 |
+
* Routing (/[ctrl]/[action])
|
40 |
+
*****************************************************************************************/
|
41 |
+
const ROUTE_REDIRECT = '/redirect/';
|
42 |
+
/** **************************************************************************************
|
43 |
+
* Session parameters
|
44 |
+
************************************************************************************** */
|
45 |
+
const SESS_LOGGED_AS_OPERATOR = 'prxgtLoggedInAsOperator';
|
46 |
+
/******************************************************************************************
|
47 |
+
* UI components
|
48 |
+
*****************************************************************************************/
|
49 |
+
const UI_BTN_LOGIN_AS = 'prxgt_lgas_button';
|
50 |
+
/******************************************************************************************
|
51 |
+
* Module's config.xml parameters
|
52 |
+
*****************************************************************************************/
|
53 |
+
const XMLCFG_ROUTER_ADMIN = 'prxgt_lgas_admin';
|
54 |
+
const XMLCFG_ROUTER_FRONT = 'prxgt_lgas_front';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* 'true' - if admin user has right to view 'Created By' value.
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
public static function canAccessCreatedBy()
|
61 |
+
{
|
62 |
+
return filter_var(Mage::getSingleton('admin/session')->isAllowed('sales/order/prxgt_lgas_created_by_access'), FILTER_VALIDATE_BOOLEAN);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* 'true' - if admin user has right to use 'Login As' feature.
|
67 |
+
* @return bool
|
68 |
+
*/
|
69 |
+
public static function canAccessLoginAs()
|
70 |
+
{
|
71 |
+
return filter_var(Mage::getSingleton('admin/session')->isAllowed('customer/prxgt_lgas_access'), FILTER_VALIDATE_BOOLEAN);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* 'true' - 'login as' feature is enabled, 'false' - otherwise.
|
76 |
+
* @return bool
|
77 |
+
*/
|
78 |
+
public static function cfgGeneralEnabled()
|
79 |
+
{
|
80 |
+
return filter_var(Mage::getStoreConfig('prxgt_lgas/general/enabled'), FILTER_VALIDATE_BOOLEAN);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* 'true' - log events using Magento logger or Log4php logger (in case of Nmmlm_Log module is installed).
|
85 |
+
* @return bool
|
86 |
+
*/
|
87 |
+
public static function cfgGeneralLogEvents()
|
88 |
+
{
|
89 |
+
return filter_var(Mage::getStoreConfig('prxgt_lgas/general/log_events'), FILTER_VALIDATE_BOOLEAN);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Display or not 'Login as Customer' action on the customers grid.
|
94 |
+
* @return bool
|
95 |
+
*/
|
96 |
+
public static function cfgUiCustomersGridActionEnabled()
|
97 |
+
{
|
98 |
+
return filter_var(Mage::getStoreConfig('prxgt_lgas/ui/action_enabled'), FILTER_VALIDATE_BOOLEAN);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Display or not columns with 'Login As' data on the orders grid.
|
103 |
+
* @return bool
|
104 |
+
*/
|
105 |
+
public static function cfgUiOrdersGridColumnEnabled()
|
106 |
+
{
|
107 |
+
return filter_var(Mage::getStoreConfig('prxgt_lgas/ui/orders_grid_column_enabled'), FILTER_VALIDATE_BOOLEAN);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Returns position of the created by column (by default - 5).
|
112 |
+
* @return int
|
113 |
+
*/
|
114 |
+
public static function cfgUiOrdersGridColumnPosition()
|
115 |
+
{
|
116 |
+
$val = Mage::getStoreConfig('prxgt_lgas/ui/orders_grid_column_position');
|
117 |
+
return (is_null($val)) ? 5 : (int)$val;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Returns default helper for the module.
|
122 |
+
* @return Praxigento_LoginAs_Helper_Data
|
123 |
+
*/
|
124 |
+
public static function helper()
|
125 |
+
{
|
126 |
+
return Mage::helper('prxgt_lgas_helper');
|
127 |
+
}
|
128 |
+
}
|
|
|
|
app/code/community/Praxigento/LoginAs/Helper/Data.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* Default helper for the module.
|
23 |
-
* User: Flancer
|
24 |
-
* Date: 2/8/13
|
25 |
-
* Time: 6:00 PM
|
26 |
-
*/
|
27 |
-
class Praxigento_LoginAs_Helper_Data extends Mage_Core_Helper_Abstract
|
28 |
-
{
|
29 |
-
|
30 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* Default helper for the module.
|
23 |
+
* User: Flancer
|
24 |
+
* Date: 2/8/13
|
25 |
+
* Time: 6:00 PM
|
26 |
+
*/
|
27 |
+
class Praxigento_LoginAs_Helper_Data extends Mage_Core_Helper_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
}
|
app/code/community/Praxigento/LoginAs/Model/Logger.php
CHANGED
@@ -1,110 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* Wrapper for loggers (Mage default or Log4php from Nmmlm_log module)
|
23 |
-
* User: Alex Gusev <flancer64@gmail.com>
|
24 |
-
* Date: 2/20/13
|
25 |
-
* Time: 9:38 AM
|
26 |
-
*/
|
27 |
-
class Praxigento_LoginAs_Model_Logger
|
28 |
-
{
|
29 |
-
/** @var bool 'true' - Log4php logging framework is used. */
|
30 |
-
private static $
|
31 |
-
/** @var
|
32 |
-
private $
|
33 |
-
/** @var
|
34 |
-
private $
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
self::$
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
*
|
50 |
-
*
|
51 |
-
*
|
52 |
-
*
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
{
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* Wrapper for loggers (Mage default or Log4php from Nmmlm_log module)
|
23 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
24 |
+
* Date: 2/20/13
|
25 |
+
* Time: 9:38 AM
|
26 |
+
*/
|
27 |
+
class Praxigento_LoginAs_Model_Logger
|
28 |
+
{
|
29 |
+
/** @var bool 'true' - Log4php logging framework is used. */
|
30 |
+
private static $_isLog4phpUsed = null;
|
31 |
+
/** @var Logger */
|
32 |
+
private $_loggerLog4php;
|
33 |
+
/** @var string name for the current logger */
|
34 |
+
private $_name;
|
35 |
+
|
36 |
+
function __construct($name)
|
37 |
+
{
|
38 |
+
self::$_isLog4phpUsed = class_exists('Nmmlm_Log_Logger', false);
|
39 |
+
if (self::$_isLog4phpUsed) {
|
40 |
+
$this->_loggerLog4php = Nmmlm_Log_Logger::getLogger($name);
|
41 |
+
} else {
|
42 |
+
$this->_name = is_object($name) ? get_class($name) : (string)$name;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Override getter to use '$log = Nmmlm_Log_Logger::getLogger($this)' form in Mage classes.
|
48 |
+
* @static
|
49 |
+
*
|
50 |
+
* @param string $name
|
51 |
+
*
|
52 |
+
* @return Praxigento_LoginAs_Model_Logger
|
53 |
+
*/
|
54 |
+
public static function getLogger($name)
|
55 |
+
{
|
56 |
+
return new Praxigento_LoginAs_Model_Logger($name);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function debug($message, $throwable = null)
|
60 |
+
{
|
61 |
+
$this->doLog($message, $throwable, 'debug', Zend_Log::INFO);
|
62 |
+
}
|
63 |
+
|
64 |
+
public function error($message, $throwable = null)
|
65 |
+
{
|
66 |
+
$this->doLog($message, $throwable, 'error', Zend_Log::ERR);
|
67 |
+
}
|
68 |
+
|
69 |
+
public function fatal($message, $throwable = null)
|
70 |
+
{
|
71 |
+
$this->doLog($message, $throwable, 'fatal', Zend_Log::CRIT);
|
72 |
+
}
|
73 |
+
|
74 |
+
public function info($message, $throwable = null)
|
75 |
+
{
|
76 |
+
$this->doLog($message, $throwable, 'info', Zend_Log::NOTICE);
|
77 |
+
}
|
78 |
+
|
79 |
+
public function trace($message, $throwable = null)
|
80 |
+
{
|
81 |
+
$this->doLog($message, $throwable, 'trace', Zend_Log::DEBUG);
|
82 |
+
}
|
83 |
+
|
84 |
+
public function warn($message, $throwable = null)
|
85 |
+
{
|
86 |
+
$this->doLog($message, $throwable, 'warn', Zend_Log::WARN);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Internal dispatcher for the called log method.
|
91 |
+
* @param $message
|
92 |
+
* @param $throwable
|
93 |
+
* @param $log4phpMethod
|
94 |
+
* @param $zendLevel
|
95 |
+
*/
|
96 |
+
private function doLog($message, $throwable, $log4phpMethod, $zendLevel)
|
97 |
+
{
|
98 |
+
if (Praxigento_LoginAs_Config::cfgGeneralLogEvents()) {
|
99 |
+
if (self::$_isLog4phpUsed) {
|
100 |
+
$this->_loggerLog4php->$log4phpMethod($message, $throwable);
|
101 |
+
} else {
|
102 |
+
Mage::log($this->_name . ': ' . $message, $zendLevel);
|
103 |
+
if ($throwable instanceof Exception) {
|
104 |
+
Mage::logException($throwable);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
|
app/code/community/Praxigento/LoginAs/Model/Observer.php
CHANGED
@@ -1,169 +1,169 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* User: Alex Gusev <flancer64@gmail.com>
|
23 |
-
* Date: 2/20/13
|
24 |
-
* Time: 9:38 AM
|
25 |
-
*/
|
26 |
-
class Praxigento_LoginAs_Model_Observer extends Varien_Object
|
27 |
-
{
|
28 |
-
/**
|
29 |
-
*
|
30 |
-
* @param Varien_Event_Observer $observer
|
31 |
-
*/
|
32 |
-
public function
|
33 |
-
{
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
$
|
97 |
-
if ($
|
98 |
-
$
|
99 |
-
}
|
100 |
-
$
|
101 |
-
}
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Add new action to customers grid.
|
107 |
-
* @param Mage_Adminhtml_Block_Customer_Grid $block
|
108 |
-
*/
|
109 |
-
private function doCustomerGridActionAdd(Mage_Adminhtml_Block_Customer_Grid $block)
|
110 |
-
{
|
111 |
-
/** validate availability & permissions */
|
112 |
-
if (Praxigento_LoginAs_Config::cfgUiCustomersGridActionEnabled() &&
|
113 |
-
Praxigento_LoginAs_Config::canAccessLoginAs()
|
114 |
-
) {
|
115 |
-
/** add action link to grid */
|
116 |
-
/** @var $cols array */
|
117 |
-
$cols = $block->getColumns();
|
118 |
-
/** @var $colAction Mage_Adminhtml_Block_Widget_Grid_Column */
|
119 |
-
$colAction = $cols['action'];
|
120 |
-
$actions = $colAction->getData('actions');
|
121 |
-
if (is_array($actions)) {
|
122 |
-
/** add new action */
|
123 |
-
$actions[] = array(
|
124 |
-
'caption' => Praxigento_LoginAs_Config::helper()->__('Login as...'),
|
125 |
-
'url' => array('base' => Praxigento_LoginAs_Config::XMLCFG_ROUTER_ADMIN . Praxigento_LoginAs_Config::ROUTE_REDIRECT),
|
126 |
-
'field' => Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID,
|
127 |
-
'target' => '_blank',
|
128 |
-
);
|
129 |
-
$colAction->setData('actions', $actions);
|
130 |
-
/** reset default renderer */
|
131 |
-
$colAction->setData('renderer', 'adminhtml/customer_grid_renderer_multiaction');
|
132 |
-
}
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Add new column to orders grid.
|
138 |
-
* @param Mage_Adminhtml_Block_Sales_Order_Grid $grid
|
139 |
-
*/
|
140 |
-
private function doOrderGridColumnAdd(Mage_Adminhtml_Block_Sales_Order_Grid $grid)
|
141 |
-
{
|
142 |
-
/** validate availability & permissions */
|
143 |
-
if (Praxigento_LoginAs_Config::cfgUiOrdersGridColumnEnabled() &&
|
144 |
-
Praxigento_LoginAs_Config::canAccessCreatedBy()
|
145 |
-
) {
|
146 |
-
/** define position for the column */
|
147 |
-
$pos
|
148 |
-
$curr
|
149 |
-
$after = $grid->getLastColumnId();
|
150 |
-
foreach ($grid->getColumns() as $key => $value) {
|
151 |
-
$after = $key;
|
152 |
-
if (++$curr >= $pos) {
|
153 |
-
break;
|
154 |
-
}
|
155 |
-
}
|
156 |
-
/** add new column to grid */
|
157 |
-
$grid->addColumnAfter(Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY,
|
158 |
-
array(
|
159 |
-
'header' => Praxigento_LoginAs_Config::helper()->__('Created by'),
|
160 |
-
'index' => Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY,
|
161 |
-
/** 'renderer' => 'nmmlm_core_block/adminhtml_widget_grid_column_renderer_pv', */
|
162 |
-
'type' => 'text',
|
163 |
-
),
|
164 |
-
$after
|
165 |
-
);
|
166 |
-
$grid->sortColumnsByOrder();
|
167 |
-
}
|
168 |
-
}
|
169 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
23 |
+
* Date: 2/20/13
|
24 |
+
* Time: 9:38 AM
|
25 |
+
*/
|
26 |
+
class Praxigento_LoginAs_Model_Observer extends Varien_Object
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Extend UI blocks.
|
30 |
+
* @param Varien_Event_Observer $observer
|
31 |
+
*/
|
32 |
+
public function onAdminhtmlBlockHtmlBefore(Varien_Event_Observer $observer)
|
33 |
+
{
|
34 |
+
if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
|
35 |
+
$block = $observer->getData('block');
|
36 |
+
if ($block instanceof Mage_Adminhtml_Block_Customer_Grid) {
|
37 |
+
$this->doCustomerGridActionAdd($block);
|
38 |
+
} elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
|
39 |
+
$this->doOrderGridColumnAdd($block);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Adds 'Login As' button to the customer form.
|
46 |
+
* @param Varien_Event_Observer $observer
|
47 |
+
*/
|
48 |
+
public function onAdminhtmlWidgetContainerHtmlBefore(Varien_Event_Observer $observer)
|
49 |
+
{
|
50 |
+
/** validate availability & permissions */
|
51 |
+
if (
|
52 |
+
Praxigento_LoginAs_Config::cfgGeneralEnabled() &&
|
53 |
+
Praxigento_LoginAs_Config::canAccessLoginAs()
|
54 |
+
) {
|
55 |
+
/** add button to the form */
|
56 |
+
/** @var $block Mage_Adminhtml_Block_Customer_Edit */
|
57 |
+
$block = $observer->getEvent()->getBlock();
|
58 |
+
if ($block instanceof Mage_Adminhtml_Block_Customer_Edit) {
|
59 |
+
$customer = Mage::registry('current_customer');
|
60 |
+
if ($customer && $customer->getId()) {
|
61 |
+
/** get data and setup URL to redirection controller */
|
62 |
+
$customerId = $customer->getId();
|
63 |
+
$url = Mage::getModel('adminhtml/url')->getUrl(
|
64 |
+
Praxigento_LoginAs_Config::XMLCFG_ROUTER_ADMIN . Praxigento_LoginAs_Config::ROUTE_REDIRECT,
|
65 |
+
array(
|
66 |
+
Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID => $customerId,
|
67 |
+
'_cache_secret_key', true /* NB-547 */
|
68 |
+
)
|
69 |
+
);
|
70 |
+
/** create UI button */
|
71 |
+
$level = 0;
|
72 |
+
$sortOrder = -1;
|
73 |
+
$area = 'header';
|
74 |
+
$block->addButton(Praxigento_LoginAs_Config::UI_BTN_LOGIN_AS,
|
75 |
+
array(
|
76 |
+
'label' => Praxigento_LoginAs_Config::helper()->__('Login as Customer'),
|
77 |
+
/** open in new window */
|
78 |
+
'onclick' => "window.open('$url')",
|
79 |
+
), $level, $sortOrder, $area);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add 'created by' data to order.
|
87 |
+
*
|
88 |
+
* @param Varien_Event_Observer $observer
|
89 |
+
*/
|
90 |
+
public function onSalesConvertQuoteAddressToOrder(Varien_Event_Observer $observer)
|
91 |
+
{
|
92 |
+
if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
|
93 |
+
$order = $observer->getEvent()->getOrder();
|
94 |
+
/** @var $session Mage_Customer_Model_Session */
|
95 |
+
$session = Mage::getSingleton('customer/session');
|
96 |
+
$operator = $session->getData(Praxigento_LoginAs_Config::SESS_LOGGED_AS_OPERATOR);
|
97 |
+
if (!is_null($operator)) {
|
98 |
+
$order->setData(Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, $operator);
|
99 |
+
} else {
|
100 |
+
$order->setData(Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, '[Customer]');
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Add new action to customers grid.
|
107 |
+
* @param Mage_Adminhtml_Block_Customer_Grid $block
|
108 |
+
*/
|
109 |
+
private function doCustomerGridActionAdd(Mage_Adminhtml_Block_Customer_Grid $block)
|
110 |
+
{
|
111 |
+
/** validate availability & permissions */
|
112 |
+
if (Praxigento_LoginAs_Config::cfgUiCustomersGridActionEnabled() &&
|
113 |
+
Praxigento_LoginAs_Config::canAccessLoginAs()
|
114 |
+
) {
|
115 |
+
/** add action link to grid */
|
116 |
+
/** @var $cols array */
|
117 |
+
$cols = $block->getColumns();
|
118 |
+
/** @var $colAction Mage_Adminhtml_Block_Widget_Grid_Column */
|
119 |
+
$colAction = $cols['action'];
|
120 |
+
$actions = $colAction->getData('actions');
|
121 |
+
if (is_array($actions)) {
|
122 |
+
/** add new action */
|
123 |
+
$actions[] = array(
|
124 |
+
'caption' => Praxigento_LoginAs_Config::helper()->__('Login as...'),
|
125 |
+
'url' => array('base' => Praxigento_LoginAs_Config::XMLCFG_ROUTER_ADMIN . Praxigento_LoginAs_Config::ROUTE_REDIRECT),
|
126 |
+
'field' => Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID,
|
127 |
+
'target' => '_blank',
|
128 |
+
);
|
129 |
+
$colAction->setData('actions', $actions);
|
130 |
+
/** reset default renderer */
|
131 |
+
$colAction->setData('renderer', 'adminhtml/customer_grid_renderer_multiaction');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Add new column to orders grid.
|
138 |
+
* @param Mage_Adminhtml_Block_Sales_Order_Grid $grid
|
139 |
+
*/
|
140 |
+
private function doOrderGridColumnAdd(Mage_Adminhtml_Block_Sales_Order_Grid $grid)
|
141 |
+
{
|
142 |
+
/** validate availability & permissions */
|
143 |
+
if (Praxigento_LoginAs_Config::cfgUiOrdersGridColumnEnabled() &&
|
144 |
+
Praxigento_LoginAs_Config::canAccessCreatedBy()
|
145 |
+
) {
|
146 |
+
/** define position for the column */
|
147 |
+
$pos = Praxigento_LoginAs_Config::cfgUiOrdersGridColumnPosition();
|
148 |
+
$curr = 0;
|
149 |
+
$after = $grid->getLastColumnId();
|
150 |
+
foreach ($grid->getColumns() as $key => $value) {
|
151 |
+
$after = $key;
|
152 |
+
if (++$curr >= $pos) {
|
153 |
+
break;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
/** add new column to grid */
|
157 |
+
$grid->addColumnAfter(Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY,
|
158 |
+
array(
|
159 |
+
'header' => Praxigento_LoginAs_Config::helper()->__('Created by'),
|
160 |
+
'index' => Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY,
|
161 |
+
/** 'renderer' => 'nmmlm_core_block/adminhtml_widget_grid_column_renderer_pv', */
|
162 |
+
'type' => 'text',
|
163 |
+
),
|
164 |
+
$after
|
165 |
+
);
|
166 |
+
$grid->sortColumnsByOrder();
|
167 |
+
}
|
168 |
+
}
|
169 |
}
|
app/code/community/Praxigento/LoginAs/Model/Package.php
CHANGED
@@ -1,159 +1,154 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* Authentication package to be send from adminhtml to the front through the file system.
|
23 |
-
* Also used as a block data bean on UI (to compose redirection form).
|
24 |
-
*
|
25 |
-
* See: http://stackoverflow.com/questions/4006183/magento-passing-data-between-a-controller-and-a-block.
|
26 |
-
* User: Alex Gusev <flancer64@gmail.com>
|
27 |
-
*/
|
28 |
-
class Praxigento_LoginAs_Model_Package extends Varien_Object
|
29 |
-
{
|
30 |
-
const PREFIX = 'las';
|
31 |
-
|
32 |
-
|
33 |
-
private $
|
34 |
-
private $
|
35 |
-
private $
|
36 |
-
/** @var string ID of the package */
|
37 |
-
private $
|
38 |
-
/** @var string URL to use on form to redirect admin to the customer's website */
|
39 |
-
private $
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
return $this->
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
*
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
$
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
$this->
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
*
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$this->
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
return $this->redirectUrl;
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* Authentication package to be send from adminhtml to the front through the file system.
|
23 |
+
* Also used as a block data bean on UI (to compose redirection form).
|
24 |
+
*
|
25 |
+
* See: http://stackoverflow.com/questions/4006183/magento-passing-data-between-a-controller-and-a-block.
|
26 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
27 |
+
*/
|
28 |
+
class Praxigento_LoginAs_Model_Package extends Varien_Object
|
29 |
+
{
|
30 |
+
const PREFIX = 'las';
|
31 |
+
/** @var string administrator's name to be displayed in orders grid and logs */
|
32 |
+
private $_adminName;
|
33 |
+
private $_customerId;
|
34 |
+
private $_customerName;
|
35 |
+
private $_ip;
|
36 |
+
/** @var string ID of the package */
|
37 |
+
private $_packageId;
|
38 |
+
/** @var string URL to use on form to redirect admin to the customer's website */
|
39 |
+
private $_redirectUrl;
|
40 |
+
|
41 |
+
public function getAdminName()
|
42 |
+
{
|
43 |
+
return $this->_adminName;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function setAdminName($adminName)
|
47 |
+
{
|
48 |
+
$this->_adminName = $adminName;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getCustomerId()
|
52 |
+
{
|
53 |
+
return $this->_customerId;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function setCustomerId($customerId)
|
57 |
+
{
|
58 |
+
$this->_customerId = $customerId;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getCustomerName()
|
62 |
+
{
|
63 |
+
return $this->_customerName;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function setCustomerName($customerName)
|
67 |
+
{
|
68 |
+
$this->_customerName = $customerName;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getIp()
|
72 |
+
{
|
73 |
+
return $this->_ip;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function setIp($ip)
|
77 |
+
{
|
78 |
+
$this->_ip = $ip;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function getPackageId()
|
85 |
+
{
|
86 |
+
return $this->_packageId;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @param string $packageId
|
91 |
+
*/
|
92 |
+
public function setPackageId($packageId)
|
93 |
+
{
|
94 |
+
$this->_packageId = $packageId;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public function getRedirectUrl()
|
101 |
+
{
|
102 |
+
return $this->_redirectUrl;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @param string $redirectUrl
|
107 |
+
*/
|
108 |
+
public function setRedirectUrl($redirectUrl)
|
109 |
+
{
|
110 |
+
$this->_redirectUrl = $redirectUrl;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Loads "Login As" parameters from file and removes file from disk.
|
115 |
+
* @param $filename
|
116 |
+
*/
|
117 |
+
public function loadFromFile($filename)
|
118 |
+
{
|
119 |
+
// load data
|
120 |
+
$this->_packageId = $filename;
|
121 |
+
$fname = sys_get_temp_dir() . DS . $this->_packageId;
|
122 |
+
$data = file($fname);
|
123 |
+
if (is_array($data) && sizeof($data >= 4)) {
|
124 |
+
$this->_adminName = trim($data[0]);
|
125 |
+
$this->_customerId = trim($data[1]);
|
126 |
+
$this->_customerName = trim($data[2]);
|
127 |
+
$this->_ip = trim($data[3]);
|
128 |
+
}
|
129 |
+
// remove file
|
130 |
+
unlink($fname);
|
131 |
+
$this->_packageId = null;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Saves login data into file in the temporary directory and returns name of the tmp file including extension.
|
136 |
+
* @return string
|
137 |
+
*/
|
138 |
+
public function saveAsFile()
|
139 |
+
{
|
140 |
+
// generate unique filename and create file to save login data
|
141 |
+
$fname = tempnam(sys_get_temp_dir(), self::PREFIX);
|
142 |
+
$pathParts = pathinfo($fname);
|
143 |
+
$this->_packageId = $pathParts['basename'];
|
144 |
+
$handle = fopen($fname, "w");
|
145 |
+
// write login data to file
|
146 |
+
$content = $this->_adminName . "\n";
|
147 |
+
$content .= $this->_customerId . "\n";
|
148 |
+
$content .= $this->_customerName . "\n";
|
149 |
+
$content .= $this->_ip . "\n";
|
150 |
+
fwrite($handle, $content);
|
151 |
+
fclose($handle);
|
152 |
+
return $this->_packageId;
|
153 |
+
}
|
154 |
+
}
|
|
|
|
|
|
|
|
|
|
app/code/community/Praxigento/LoginAs/Test/{ConfigTest.php → Config_Test.php}
RENAMED
@@ -1,60 +1,49 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* Created by JetBrains PhpStorm.
|
23 |
-
* User: Alex Gusev <flancer64@gmail.com>
|
24 |
-
* Date: 2/18/13
|
25 |
-
* Time: 6:05 PM
|
26 |
-
*/
|
27 |
-
class Praxigento_LoginAs_Test_ConfigTest extends PHPUnit_Framework_TestCase
|
28 |
-
{
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$
|
46 |
-
$this->assertTrue(
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Test default accessors for basic Magento components.
|
54 |
-
*/
|
55 |
-
public function test_defaults()
|
56 |
-
{
|
57 |
-
$helper = Praxigento_LoginAs_Config::helper();
|
58 |
-
$this->assertTrue($helper instanceof Mage_Core_Helper_Abstract);
|
59 |
-
}
|
60 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* Created by JetBrains PhpStorm.
|
23 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
24 |
+
* Date: 2/18/13
|
25 |
+
* Time: 6:05 PM
|
26 |
+
*/
|
27 |
+
class Praxigento_LoginAs_Test_ConfigTest extends PHPUnit_Framework_TestCase
|
28 |
+
{
|
29 |
+
public function testCfg()
|
30 |
+
{
|
31 |
+
// System / Configuration
|
32 |
+
// general
|
33 |
+
$this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgGeneralEnabled()));
|
34 |
+
$this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgGeneralLogEvents()));
|
35 |
+
// UI
|
36 |
+
$this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgUiCustomersGridActionEnabled()));
|
37 |
+
$this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgUiOrdersGridColumnEnabled()));
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Test default accessors for basic Magento components.
|
42 |
+
*/
|
43 |
+
public function test_defaults()
|
44 |
+
{
|
45 |
+
$helper = Praxigento_LoginAs_Config::helper();
|
46 |
+
$this->assertTrue($helper instanceof Mage_Core_Helper_Abstract);
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Praxigento/LoginAs/Test/Model/{LoggerTest.php → Logger_Test.php}
RENAMED
@@ -1,57 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* User: Alex Gusev <flancer64@gmail.com>
|
23 |
-
* Date: 2/18/13
|
24 |
-
* Time: 6:05 PM
|
25 |
-
*/
|
26 |
-
class Praxigento_LoginAs_Test_Model_LoggerTest extends PHPUnit_Framework_TestCase
|
27 |
-
{
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
$log
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$log->warn('warn');
|
47 |
-
$log->error('error');
|
48 |
-
$log->fatal('fatal');
|
49 |
-
$log->trace('trace', new Exception('test trace error'));
|
50 |
-
$log->debug('debug', new Exception('test debug error'));
|
51 |
-
$log->info('info', new Exception('test info error'));
|
52 |
-
$log->warn('warn', new Exception('test warn error'));
|
53 |
-
$log->error('error', new Exception('test error error'));
|
54 |
-
$log->fatal('fatal', new Exception('test fatal error'));
|
55 |
-
}
|
56 |
-
|
57 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
23 |
+
* Date: 2/18/13
|
24 |
+
* Time: 6:05 PM
|
25 |
+
*/
|
26 |
+
class Praxigento_LoginAs_Test_Model_LoggerTest extends PHPUnit_Framework_TestCase
|
27 |
+
{
|
28 |
+
public function test_all()
|
29 |
+
{
|
30 |
+
$log = Praxigento_LoginAs_Model_Logger::getLogger($this);
|
31 |
+
$log->trace('trace');
|
32 |
+
$log->debug('debug');
|
33 |
+
$log->info('info');
|
34 |
+
$log->warn('warn');
|
35 |
+
$log->error('error');
|
36 |
+
$log->fatal('fatal');
|
37 |
+
$log->trace('trace', new Exception('test trace error'));
|
38 |
+
$log->debug('debug', new Exception('test debug error'));
|
39 |
+
$log->info('info', new Exception('test info error'));
|
40 |
+
$log->warn('warn', new Exception('test warn error'));
|
41 |
+
$log->error('error', new Exception('test error error'));
|
42 |
+
$log->fatal('fatal', new Exception('test fatal error'));
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Praxigento/LoginAs/Test/phpunit.bootstrap.php
CHANGED
@@ -1,30 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
//
|
29 |
-
|
30 |
-
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Traverse up and lookup for the './mage/' folder to add to 'include_path'.
|
4 |
+
*/
|
5 |
+
// Set custom memory limit
|
6 |
+
ini_set('memory_limit', '512M');
|
7 |
+
// Magento root folder name (see "magento-root-dir" extra var in test/composer.json)
|
8 |
+
$mageRoot = 'mage';
|
9 |
+
// Magento main file relative to the Magento root.
|
10 |
+
$mageApp = 'app' . DIRECTORY_SEPARATOR . 'Mage.php';
|
11 |
+
// Directory of the current file (phpunit_bootstrap.php)
|
12 |
+
$path = __DIR__;
|
13 |
+
// Clear cache for file_exists()
|
14 |
+
clearstatcache();
|
15 |
+
for($i = 0; $i < 32; $i++) {
|
16 |
+
$pathToMage = $path . DIRECTORY_SEPARATOR . $mageRoot . DIRECTORY_SEPARATOR . $mageApp;
|
17 |
+
if(file_exists($pathToMage)) {
|
18 |
+
$ini_set = ini_get('include_path') . PATH_SEPARATOR . $path . DIRECTORY_SEPARATOR . $mageRoot;
|
19 |
+
ini_set('include_path', $ini_set);
|
20 |
+
require_once $mageApp;
|
21 |
+
break;
|
22 |
+
} else {
|
23 |
+
$path = dirname($path);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
// Start Magento application
|
27 |
+
Mage::app('default');
|
28 |
+
//Avoid issues "Headers already send"
|
29 |
+
session_start();
|
|
app/code/community/Praxigento/LoginAs/Test/phpunit.dist.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<phpunit backupGlobals="false"
|
3 |
+
backupStaticAttributes="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
processIsolation="false"
|
9 |
+
stopOnFailure="false"
|
10 |
+
syntaxCheck="true"
|
11 |
+
bootstrap="phpunit_bootstrap.php">
|
12 |
+
<testsuite name="Magento Unit Test">
|
13 |
+
<directory suffix="_Test.php">.</directory>
|
14 |
+
</testsuite>
|
15 |
+
</phpunit>
|
app/code/community/Praxigento/LoginAs/Test/phpunit.praxigento.loginas.xml
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<phpunit bootstrap="phpunit.bootstrap.php">
|
2 |
-
<testsuites>
|
3 |
-
<testsuite name="Praxigento_LoginAs">
|
4 |
-
<directory>.</directory>
|
5 |
-
</testsuite>
|
6 |
-
</testsuites>
|
7 |
-
<php>
|
8 |
-
<includePath>../../../../../</includePath>
|
9 |
-
</php>
|
10 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Praxigento/LoginAs/controllers/LoginController.php
CHANGED
@@ -1,107 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
|
22 |
-
|
23 |
-
*
|
24 |
-
*
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
$
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
$
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* User: Alex Gusev <flancer64@gmail.com>
|
24 |
+
* Date: 2/20/13
|
25 |
+
* Time: 2:04 PM
|
26 |
+
*/
|
27 |
+
class Praxigento_LoginAs_LoginController extends Mage_Core_Controller_Front_Action
|
28 |
+
{
|
29 |
+
|
30 |
+
protected function _isAllowed()
|
31 |
+
{
|
32 |
+
$result = Praxigento_LoginAs_Config::canAccessLoginAs();
|
33 |
+
return $result;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function asAction()
|
37 |
+
{
|
38 |
+
/** event logger */
|
39 |
+
$log = Praxigento_LoginAs_Model_Logger::getLogger($this);
|
40 |
+
/** get filename from the request parameters */
|
41 |
+
$filename = $this->getRequest()->getPost(Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID);
|
42 |
+
/** @var $authPack Praxigento_LoginAs_Model_Package */
|
43 |
+
$authPack = Mage::getSingleton('prxgt_lgas_model/package');
|
44 |
+
$authPack->loadFromFile($filename);
|
45 |
+
/** extract working data */
|
46 |
+
$customerId = $authPack->getCustomerId();
|
47 |
+
if (!is_null($customerId)) {
|
48 |
+
$customerName = $authPack->getCustomerName();
|
49 |
+
$operatorName = $authPack->getAdminName();
|
50 |
+
$operatorIp = $authPack->getIp();
|
51 |
+
$log->trace("Operator '$operatorName' trying to login as '$customerName' (id=$customerId) from ip '$operatorIp'...");
|
52 |
+
/** validate current customer's session or establish new session and validate request */
|
53 |
+
$session = Mage::getSingleton('customer/session');
|
54 |
+
$sessionCustomer = $session->getCustomer();
|
55 |
+
$sessionCustomerId = $sessionCustomer->getId();
|
56 |
+
/** this operator is already logged in as required customer */
|
57 |
+
if (($session->isLoggedIn()) && ($customerId == $sessionCustomerId)) {
|
58 |
+
$log->debug("Session for customer '$customerName' (id=$customerId) is already exist. Refreshing page...");
|
59 |
+
/** save operator's name into session to use in orders later */
|
60 |
+
$session->setData(Praxigento_LoginAs_Config::SESS_LOGGED_AS_OPERATOR, $operatorName);
|
61 |
+
} else {
|
62 |
+
/** establish new customer session */
|
63 |
+
$validatorData = $session->getValidatorData();
|
64 |
+
if ($this->getRequest()->isPost() && ($operatorIp == $validatorData['remote_addr'])) {
|
65 |
+
try {
|
66 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
67 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
68 |
+
if ($customer->getId() == $customerId) {
|
69 |
+
/** check allowed websites */
|
70 |
+
$wsId = Mage::app()->getStore()->getWebsiteId();
|
71 |
+
$wsids = $customer->getSharedWebsiteIds();
|
72 |
+
$custWsId = $customer->getData('website_id');
|
73 |
+
if (
|
74 |
+
(in_array($wsId, $wsids)) ||
|
75 |
+
($wsId == $custWsId)
|
76 |
+
) {
|
77 |
+
$session->loginById($customerId);
|
78 |
+
/** save operator's name into session to use in orders later */
|
79 |
+
$session->setData(Praxigento_LoginAs_Config::SESS_LOGGED_AS_OPERATOR, $operatorName);
|
80 |
+
$log->info("New session for customer '$customerName' (id=$customerId) is established for operator '$operatorName'");
|
81 |
+
} else {
|
82 |
+
$msg = "Customer '$customerName' (id=$customerId) has no rights to access current website.";
|
83 |
+
$log->error($msg);
|
84 |
+
Mage::throwException($msg);
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
$msg = "Customer with id '$customerId' does not exists.";
|
88 |
+
$log->error($msg);
|
89 |
+
Mage::throwException($msg);
|
90 |
+
}
|
91 |
+
} catch (Mage_Core_Exception $e) {
|
92 |
+
switch ($e->getCode()) {
|
93 |
+
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
|
94 |
+
$message = $e->getMessage();
|
95 |
+
break;
|
96 |
+
default:
|
97 |
+
$message = $e->getMessage();
|
98 |
+
}
|
99 |
+
$session->addError($message);
|
100 |
+
$session->setId(null);
|
101 |
+
$log->error('Session ID is reset due to error is occurred. Exception is not logged.');
|
102 |
+
} catch (Exception $e) {
|
103 |
+
/** Mage::logException($e); // PA DSS violation: this exception log can disclose customer password */
|
104 |
+
}
|
105 |
+
} else {
|
106 |
+
$log->warn("Authentication request failure: request type is not POST or operator's current ip (" .
|
107 |
+
$validatorData['remote_addr'] . ") is not equal to ip from authentication package ($operatorIp).");
|
108 |
+
}
|
109 |
+
}
|
110 |
+
} else {
|
111 |
+
$log->warn("Cannot get customer id for authentication package '$filename'.");
|
112 |
+
}
|
113 |
+
$this->_redirect('customer/account');
|
114 |
+
}
|
115 |
+
}
|
app/code/community/Praxigento/LoginAs/controllers/RedirectController.php
CHANGED
@@ -1,86 +1,96 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
{
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
$
|
60 |
-
|
61 |
-
|
62 |
-
$
|
63 |
-
|
64 |
-
$
|
65 |
-
$
|
66 |
-
$
|
67 |
-
$
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
/**
|
73 |
-
$
|
74 |
-
$
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Controller to process operator's requests to redirect to the frontend to login as a customer.
|
24 |
+
*/
|
25 |
+
class Praxigento_LoginAs_RedirectController extends Mage_Adminhtml_Controller_Action
|
26 |
+
{
|
27 |
+
protected function _isAllowed()
|
28 |
+
{
|
29 |
+
$result = Praxigento_LoginAs_Config::canAccessLoginAs();
|
30 |
+
return $result;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function indexAction()
|
34 |
+
{
|
35 |
+
if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
|
36 |
+
/** define operator name */
|
37 |
+
/** @var $session Mage_Admin_Model_Session */
|
38 |
+
$session = Mage::getSingleton('admin/session');
|
39 |
+
if ($session->isLoggedIn()) {
|
40 |
+
/** @var $user Mage_Admin_Model_User */
|
41 |
+
$user = $session->getUser();
|
42 |
+
$operator = $user->getName() . ' (' . $user->getEmail() . ')';
|
43 |
+
/** if there is customer data in request */
|
44 |
+
if (!is_null($this->getRequest()->getParams())) {
|
45 |
+
$params = $this->getRequest()->getParams();
|
46 |
+
if (!is_null($params[Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID])) {
|
47 |
+
/** extract customer ID from request and load customer data */
|
48 |
+
$customerId = $params[Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID];
|
49 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
50 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
51 |
+
if ($customer->getId() == $customerId) {
|
52 |
+
$customerName = $customer->getName();
|
53 |
+
/** define URL to login to customer's website */
|
54 |
+
$wsId = $customer->getData('website_id');
|
55 |
+
if (is_null($wsId)) {
|
56 |
+
$wsId = Mage::app()->getStore()->getWebsiteId();
|
57 |
+
}
|
58 |
+
/** @var $website Mage_Core_Model_Website */
|
59 |
+
$website = Mage::getModel('core/website')->load($wsId);
|
60 |
+
$defStoreId = $website->getDefaultStore()->getId();
|
61 |
+
$baseTarget = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL, $defStoreId);
|
62 |
+
$baseSource = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL);
|
63 |
+
/** compose redirection URL and replace current base by target base */
|
64 |
+
$urlModel = Mage::getModel('core/url');
|
65 |
+
$store = Mage::getModel('core/store')->load($defStoreId);
|
66 |
+
$urlModel->setStore($store);
|
67 |
+
$url = $urlModel->getUrl(
|
68 |
+
Praxigento_LoginAs_Config::XMLCFG_ROUTER_FRONT .
|
69 |
+
Praxigento_LoginAs_Config::ROUTE_CUSTOMER_LOGINAS);
|
70 |
+
$url = str_replace($baseSource, $baseTarget, $url);
|
71 |
+
/** compose authentication package */
|
72 |
+
/** @var $authPack Praxigento_LoginAs_Model_Package */
|
73 |
+
$authPack = Mage::getSingleton('prxgt_lgas_model/package');
|
74 |
+
$authPack->setAdminName($operator);
|
75 |
+
$authPack->setCustomerId($customerId);
|
76 |
+
$authPack->setCustomerName($customerName);
|
77 |
+
$authPack->setRedirectUrl($url);
|
78 |
+
$validatorData = $session->getValidatorData();
|
79 |
+
$ip = $validatorData['remote_addr'];
|
80 |
+
$authPack->setIp($ip);
|
81 |
+
/** save login data to file */
|
82 |
+
$authPack->saveAsFile();
|
83 |
+
/** log event */
|
84 |
+
$log = Praxigento_LoginAs_Model_Logger::getLogger($this);
|
85 |
+
$log->trace("Operator '$operator' is redirected to front from ip '$ip' to login" .
|
86 |
+
" as customer '$customerName' ($customerId).");
|
87 |
+
}
|
88 |
+
$bu = var_export($this->getLayout()->getUpdate()->getHandles(), true);
|
89 |
+
/** load layout and render blocks */
|
90 |
+
$this->loadLayout()->renderLayout();
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
app/code/community/Praxigento/LoginAs/etc/config.xml
CHANGED
@@ -1,166 +1,173 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2013, Praxigento
|
5 |
-
* All rights reserved.
|
6 |
-
*
|
7 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
-
* following conditions are met:
|
9 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
-
* disclaimer.
|
11 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
-
*
|
14 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
-
*/
|
22 |
-
-->
|
23 |
-
<config>
|
24 |
-
<modules>
|
25 |
-
<Praxigento_LoginAs>
|
26 |
-
<version>1.0
|
27 |
-
</Praxigento_LoginAs>
|
28 |
-
</modules>
|
29 |
-
<admin>
|
30 |
-
<routers>
|
31 |
-
<prxgt_lgas_router>
|
32 |
-
<use>admin</use>
|
33 |
-
<args>
|
34 |
-
<module>Praxigento_LoginAs</module>
|
35 |
-
<frontName>prxgt_lgas_admin</frontName>
|
36 |
-
</args>
|
37 |
-
</prxgt_lgas_router>
|
38 |
-
</routers>
|
39 |
-
</admin>
|
40 |
-
<adminhtml>
|
41 |
-
<acl>
|
42 |
-
<resources>
|
43 |
-
<admin>
|
44 |
-
<children>
|
45 |
-
<sales>
|
46 |
-
<children>
|
47 |
-
<order>
|
48 |
-
<children>
|
49 |
-
<prxgt_lgas_created_by_access translate="title" module="prxgt_lgas_helper">
|
50 |
-
<title>Praxigento: 'Created by' access</title>
|
51 |
-
<sort_order>1024</sort_order>
|
52 |
-
</prxgt_lgas_created_by_access>
|
53 |
-
</children>
|
54 |
-
</order>
|
55 |
-
</children>
|
56 |
-
</sales>
|
57 |
-
<customer>
|
58 |
-
<children>
|
59 |
-
<!-- add entry under Customer section -->
|
60 |
-
<prxgt_lgas_access translate="title" module="prxgt_lgas_helper">
|
61 |
-
<title>Praxigento: 'Login as Customer' access</title>
|
62 |
-
<sort_order>1024</sort_order>
|
63 |
-
</prxgt_lgas_access>
|
64 |
-
</children>
|
65 |
-
</customer>
|
66 |
-
<system>
|
67 |
-
<children>
|
68 |
-
<config>
|
69 |
-
<children>
|
70 |
-
<!-- Section on the "System/Configuration" panel -->
|
71 |
-
<!-- place ACL to config sections here -->
|
72 |
-
<prxgt_lgas translate="title" module="prxgt_lgas_helper">
|
73 |
-
<title>Praxigento: Login As Customer Section</title>
|
74 |
-
<sort_order>600</sort_order>
|
75 |
-
</prxgt_lgas>
|
76 |
-
</children>
|
77 |
-
</config>
|
78 |
-
</children>
|
79 |
-
</system>
|
80 |
-
</children>
|
81 |
-
</admin>
|
82 |
-
</resources>
|
83 |
-
</acl>
|
84 |
-
<events>
|
85 |
-
<adminhtml_block_html_before>
|
86 |
-
<observers>
|
87 |
-
<prxgt_lgas_observer>
|
88 |
-
<type>singleton</type>
|
89 |
-
<class>prxgt_lgas_model/observer</class>
|
90 |
-
<method>onAdminhtmlBlockHtmlBefore</method>
|
91 |
-
</prxgt_lgas_observer>
|
92 |
-
</observers>
|
93 |
-
</adminhtml_block_html_before>
|
94 |
-
<adminhtml_widget_container_html_before>
|
95 |
-
<observers>
|
96 |
-
<prxgt_lgas_observer>
|
97 |
-
<type>singleton</type>
|
98 |
-
<class>prxgt_lgas_model/observer</class>
|
99 |
-
<method>onAdminhtmlWidgetContainerHtmlBefore</method>
|
100 |
-
</prxgt_lgas_observer>
|
101 |
-
</observers>
|
102 |
-
</adminhtml_widget_container_html_before>
|
103 |
-
</events>
|
104 |
-
<layout>
|
105 |
-
<updates>
|
106 |
-
<prxgt_lgas_layout_admin>
|
107 |
-
<file>prxgt/lgas/
|
108 |
-
</prxgt_lgas_layout_admin>
|
109 |
-
</updates>
|
110 |
-
</layout>
|
111 |
-
<translate>
|
112 |
-
<modules>
|
113 |
-
<prxgt_lgas>
|
114 |
-
<files>
|
115 |
-
<default>prxgt/lgas/prxgt_lgas.csv</default>
|
116 |
-
</files>
|
117 |
-
</prxgt_lgas>
|
118 |
-
</modules>
|
119 |
-
</translate>
|
120 |
-
</adminhtml>
|
121 |
-
<frontend>
|
122 |
-
<routers>
|
123 |
-
<prxgt_lgas_router>
|
124 |
-
<use>standard</use>
|
125 |
-
<args>
|
126 |
-
<module>Praxigento_LoginAs</module>
|
127 |
-
<frontName>prxgt_lgas_front</frontName>
|
128 |
-
</args>
|
129 |
-
</prxgt_lgas_router>
|
130 |
-
</routers>
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
</
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2013, Praxigento
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
+
* following conditions are met:
|
9 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
+
* disclaimer.
|
11 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
+
*
|
14 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<config>
|
24 |
+
<modules>
|
25 |
+
<Praxigento_LoginAs>
|
26 |
+
<version>1.2.0</version>
|
27 |
+
</Praxigento_LoginAs>
|
28 |
+
</modules>
|
29 |
+
<admin>
|
30 |
+
<routers>
|
31 |
+
<prxgt_lgas_router>
|
32 |
+
<use>admin</use>
|
33 |
+
<args>
|
34 |
+
<module>Praxigento_LoginAs</module>
|
35 |
+
<frontName>prxgt_lgas_admin</frontName>
|
36 |
+
</args>
|
37 |
+
</prxgt_lgas_router>
|
38 |
+
</routers>
|
39 |
+
</admin>
|
40 |
+
<adminhtml>
|
41 |
+
<acl>
|
42 |
+
<resources>
|
43 |
+
<admin>
|
44 |
+
<children>
|
45 |
+
<sales>
|
46 |
+
<children>
|
47 |
+
<order>
|
48 |
+
<children>
|
49 |
+
<prxgt_lgas_created_by_access translate="title" module="prxgt_lgas_helper">
|
50 |
+
<title>Praxigento: 'Created by' access</title>
|
51 |
+
<sort_order>1024</sort_order>
|
52 |
+
</prxgt_lgas_created_by_access>
|
53 |
+
</children>
|
54 |
+
</order>
|
55 |
+
</children>
|
56 |
+
</sales>
|
57 |
+
<customer>
|
58 |
+
<children>
|
59 |
+
<!-- add entry under Customer section -->
|
60 |
+
<prxgt_lgas_access translate="title" module="prxgt_lgas_helper">
|
61 |
+
<title>Praxigento: 'Login as Customer' access</title>
|
62 |
+
<sort_order>1024</sort_order>
|
63 |
+
</prxgt_lgas_access>
|
64 |
+
</children>
|
65 |
+
</customer>
|
66 |
+
<system>
|
67 |
+
<children>
|
68 |
+
<config>
|
69 |
+
<children>
|
70 |
+
<!-- Section on the "System/Configuration" panel -->
|
71 |
+
<!-- place ACL to config sections here -->
|
72 |
+
<prxgt_lgas translate="title" module="prxgt_lgas_helper">
|
73 |
+
<title>Praxigento: Login As Customer Section</title>
|
74 |
+
<sort_order>600</sort_order>
|
75 |
+
</prxgt_lgas>
|
76 |
+
</children>
|
77 |
+
</config>
|
78 |
+
</children>
|
79 |
+
</system>
|
80 |
+
</children>
|
81 |
+
</admin>
|
82 |
+
</resources>
|
83 |
+
</acl>
|
84 |
+
<events>
|
85 |
+
<adminhtml_block_html_before>
|
86 |
+
<observers>
|
87 |
+
<prxgt_lgas_observer>
|
88 |
+
<type>singleton</type>
|
89 |
+
<class>prxgt_lgas_model/observer</class>
|
90 |
+
<method>onAdminhtmlBlockHtmlBefore</method>
|
91 |
+
</prxgt_lgas_observer>
|
92 |
+
</observers>
|
93 |
+
</adminhtml_block_html_before>
|
94 |
+
<adminhtml_widget_container_html_before>
|
95 |
+
<observers>
|
96 |
+
<prxgt_lgas_observer>
|
97 |
+
<type>singleton</type>
|
98 |
+
<class>prxgt_lgas_model/observer</class>
|
99 |
+
<method>onAdminhtmlWidgetContainerHtmlBefore</method>
|
100 |
+
</prxgt_lgas_observer>
|
101 |
+
</observers>
|
102 |
+
</adminhtml_widget_container_html_before>
|
103 |
+
</events>
|
104 |
+
<layout>
|
105 |
+
<updates>
|
106 |
+
<prxgt_lgas_layout_admin>
|
107 |
+
<file>prxgt/lgas/adminhtml_layout.xml</file>
|
108 |
+
</prxgt_lgas_layout_admin>
|
109 |
+
</updates>
|
110 |
+
</layout>
|
111 |
+
<translate>
|
112 |
+
<modules>
|
113 |
+
<prxgt_lgas>
|
114 |
+
<files>
|
115 |
+
<default>prxgt/lgas/prxgt_lgas.csv</default>
|
116 |
+
</files>
|
117 |
+
</prxgt_lgas>
|
118 |
+
</modules>
|
119 |
+
</translate>
|
120 |
+
</adminhtml>
|
121 |
+
<frontend>
|
122 |
+
<routers>
|
123 |
+
<prxgt_lgas_router>
|
124 |
+
<use>standard</use>
|
125 |
+
<args>
|
126 |
+
<module>Praxigento_LoginAs</module>
|
127 |
+
<frontName>prxgt_lgas_front</frontName>
|
128 |
+
</args>
|
129 |
+
</prxgt_lgas_router>
|
130 |
+
</routers>
|
131 |
+
<layout>
|
132 |
+
<updates>
|
133 |
+
<prxgt_lgas_layout_front>
|
134 |
+
<file>prxgt/lgas/frontend_layout.xml</file>
|
135 |
+
</prxgt_lgas_layout_front>
|
136 |
+
</updates>
|
137 |
+
</layout>
|
138 |
+
</frontend>
|
139 |
+
<global>
|
140 |
+
<events>
|
141 |
+
<sales_convert_quote_address_to_order>
|
142 |
+
<observers>
|
143 |
+
<prxgt_lgas_observer>
|
144 |
+
<type>singleton</type>
|
145 |
+
<class>prxgt_lgas_model/observer</class>
|
146 |
+
<method>onSalesConvertQuoteAddressToOrder</method>
|
147 |
+
</prxgt_lgas_observer>
|
148 |
+
</observers>
|
149 |
+
</sales_convert_quote_address_to_order>
|
150 |
+
</events>
|
151 |
+
<helpers>
|
152 |
+
<!-- Default helper for module (prevents errors like "Class 'Namespace_Module_Helper_Data' not found in") -->
|
153 |
+
<prxgt_lgas_helper>
|
154 |
+
<class>Praxigento_LoginAs_Helper</class>
|
155 |
+
</prxgt_lgas_helper>
|
156 |
+
</helpers>
|
157 |
+
<models>
|
158 |
+
<prxgt_lgas_model>
|
159 |
+
<class>Praxigento_LoginAs_Model</class>
|
160 |
+
</prxgt_lgas_model>
|
161 |
+
</models>
|
162 |
+
<resources>
|
163 |
+
<prxgt_lgas_setup>
|
164 |
+
<setup>
|
165 |
+
<module>Praxigento_LoginAs</module>
|
166 |
+
</setup>
|
167 |
+
<connection>
|
168 |
+
<use>core_setup</use>
|
169 |
+
</connection>
|
170 |
+
</prxgt_lgas_setup>
|
171 |
+
</resources>
|
172 |
+
</global>
|
173 |
</config>
|
app/code/community/Praxigento/LoginAs/etc/release.txt
CHANGED
@@ -1,5 +1,15 @@
|
|
1 |
-
1.0
|
2 |
-
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- Initial version;
|
1 |
+
1.2.0:
|
2 |
+
- Controllers fix (_isAllowed);
|
3 |
+
- Auto installation with sample data generation in development version;
|
4 |
+
|
5 |
+
1.1.0:
|
6 |
+
- Composer module version;
|
7 |
+
|
8 |
+
1.0.2:
|
9 |
+
- Improve code style;
|
10 |
+
|
11 |
+
1.0.1:
|
12 |
+
- Fix ACL related errors;
|
13 |
+
|
14 |
+
1.0.0:
|
15 |
- Initial version;
|
app/code/community/Praxigento/LoginAs/etc/system.xml
CHANGED
@@ -1,118 +1,118 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2013, Praxigento
|
5 |
-
* All rights reserved.
|
6 |
-
*
|
7 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
-
* following conditions are met:
|
9 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
-
* disclaimer.
|
11 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
-
*
|
14 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
-
*/
|
22 |
-
-->
|
23 |
-
<config>
|
24 |
-
<tabs>
|
25 |
-
<prxgt>
|
26 |
-
<!-- This is all module's common tab (should be the same for all modules) -->
|
27 |
-
<label>Praxigento</label>
|
28 |
-
<sort_order>1024</sort_order>
|
29 |
-
</prxgt>
|
30 |
-
</tabs>
|
31 |
-
<sections>
|
32 |
-
<prxgt_lgas translate="label comment" module="prxgt_lgas_helper">
|
33 |
-
<label>Login as Customer</label>
|
34 |
-
<tab>prxgt</tab>
|
35 |
-
<frontend_type>text</frontend_type>
|
36 |
-
<sort_order>600</sort_order>
|
37 |
-
<show_in_default>1</show_in_default>
|
38 |
-
<show_in_website>1</show_in_website>
|
39 |
-
<show_in_store>1</show_in_store>
|
40 |
-
<groups>
|
41 |
-
<general>
|
42 |
-
<!-- ******* -->
|
43 |
-
<!-- General -->
|
44 |
-
<!-- ******* -->
|
45 |
-
<label>General</label>
|
46 |
-
<sort_order>100</sort_order>
|
47 |
-
<show_in_default>1</show_in_default>
|
48 |
-
<show_in_website>0</show_in_website>
|
49 |
-
<show_in_store>0</show_in_store>
|
50 |
-
<fields>
|
51 |
-
<enabled>
|
52 |
-
<label>Enable 'Login as Customer'</label>
|
53 |
-
<comment>Check ACL entries (System / Permissions / Roles) in case of feature is enabled but is not accessible.</comment>
|
54 |
-
<frontend_type>select</frontend_type>
|
55 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
56 |
-
<sort_order>100</sort_order>
|
57 |
-
<show_in_default>1</show_in_default>
|
58 |
-
<show_in_website>0</show_in_website>
|
59 |
-
<show_in_store>0</show_in_store>
|
60 |
-
</enabled>
|
61 |
-
<log_events>
|
62 |
-
<label>Log Events</label>
|
63 |
-
<comment>Log 'login as' events (log4php lib is used in case of Nmmlm_Log module is installed).</comment>
|
64 |
-
<frontend_type>select</frontend_type>
|
65 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
66 |
-
<sort_order>200</sort_order>
|
67 |
-
<show_in_default>1</show_in_default>
|
68 |
-
<show_in_website>0</show_in_website>
|
69 |
-
<show_in_store>0</show_in_store>
|
70 |
-
</log_events>
|
71 |
-
</fields>
|
72 |
-
</general>
|
73 |
-
<ui>
|
74 |
-
<!-- ******** -->
|
75 |
-
<!-- UI setup -->
|
76 |
-
<!-- ******** -->
|
77 |
-
<label>UI Setup</label>
|
78 |
-
<sort_order>200</sort_order>
|
79 |
-
<show_in_default>1</show_in_default>
|
80 |
-
<show_in_website>0</show_in_website>
|
81 |
-
<show_in_store>0</show_in_store>
|
82 |
-
<fields>
|
83 |
-
<action_enabled>
|
84 |
-
<label>Display 'Login as' Action</label>
|
85 |
-
<comment>Display action on the customers grid.</comment>
|
86 |
-
<frontend_type>select</frontend_type>
|
87 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
88 |
-
<sort_order>200</sort_order>
|
89 |
-
<show_in_default>1</show_in_default>
|
90 |
-
<show_in_website>0</show_in_website>
|
91 |
-
<show_in_store>0</show_in_store>
|
92 |
-
</action_enabled>
|
93 |
-
<orders_grid_column_enabled>
|
94 |
-
<label>Display 'Created by' Column</label>
|
95 |
-
<comment>Display column on the orders grid.</comment>
|
96 |
-
<frontend_type>select</frontend_type>
|
97 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
98 |
-
<sort_order>300</sort_order>
|
99 |
-
<show_in_default>1</show_in_default>
|
100 |
-
<show_in_website>0</show_in_website>
|
101 |
-
<show_in_store>0</show_in_store>
|
102 |
-
</orders_grid_column_enabled>
|
103 |
-
<orders_grid_column_position>
|
104 |
-
<label>Position for 'Created by' Column</label>
|
105 |
-
<comment>Setup position for the column on the orders grid.</comment>
|
106 |
-
<frontend_type>text</frontend_type>
|
107 |
-
<validate>required-entry validate-digits validate-digits-range digits-range-1-</validate>
|
108 |
-
<sort_order>400</sort_order>
|
109 |
-
<show_in_default>1</show_in_default>
|
110 |
-
<show_in_website>0</show_in_website>
|
111 |
-
<show_in_store>0</show_in_store>
|
112 |
-
</orders_grid_column_position>
|
113 |
-
</fields>
|
114 |
-
</ui>
|
115 |
-
</groups>
|
116 |
-
</prxgt_lgas>
|
117 |
-
</sections>
|
118 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2013, Praxigento
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
+
* following conditions are met:
|
9 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
+
* disclaimer.
|
11 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
+
*
|
14 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<config>
|
24 |
+
<tabs>
|
25 |
+
<prxgt>
|
26 |
+
<!-- This is all module's common tab (should be the same for all modules) -->
|
27 |
+
<label>Praxigento</label>
|
28 |
+
<sort_order>1024</sort_order>
|
29 |
+
</prxgt>
|
30 |
+
</tabs>
|
31 |
+
<sections>
|
32 |
+
<prxgt_lgas translate="label comment" module="prxgt_lgas_helper">
|
33 |
+
<label>Login as Customer</label>
|
34 |
+
<tab>prxgt</tab>
|
35 |
+
<frontend_type>text</frontend_type>
|
36 |
+
<sort_order>600</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
<groups>
|
41 |
+
<general>
|
42 |
+
<!-- ******* -->
|
43 |
+
<!-- General -->
|
44 |
+
<!-- ******* -->
|
45 |
+
<label>General</label>
|
46 |
+
<sort_order>100</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
<fields>
|
51 |
+
<enabled>
|
52 |
+
<label>Enable 'Login as Customer'</label>
|
53 |
+
<comment>Check ACL entries (System / Permissions / Roles) in case of feature is enabled but is not accessible.</comment>
|
54 |
+
<frontend_type>select</frontend_type>
|
55 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
56 |
+
<sort_order>100</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>0</show_in_website>
|
59 |
+
<show_in_store>0</show_in_store>
|
60 |
+
</enabled>
|
61 |
+
<log_events>
|
62 |
+
<label>Log Events</label>
|
63 |
+
<comment>Log 'login as' events (log4php lib is used in case of Nmmlm_Log module is installed).</comment>
|
64 |
+
<frontend_type>select</frontend_type>
|
65 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
66 |
+
<sort_order>200</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>0</show_in_website>
|
69 |
+
<show_in_store>0</show_in_store>
|
70 |
+
</log_events>
|
71 |
+
</fields>
|
72 |
+
</general>
|
73 |
+
<ui>
|
74 |
+
<!-- ******** -->
|
75 |
+
<!-- UI setup -->
|
76 |
+
<!-- ******** -->
|
77 |
+
<label>UI Setup</label>
|
78 |
+
<sort_order>200</sort_order>
|
79 |
+
<show_in_default>1</show_in_default>
|
80 |
+
<show_in_website>0</show_in_website>
|
81 |
+
<show_in_store>0</show_in_store>
|
82 |
+
<fields>
|
83 |
+
<action_enabled>
|
84 |
+
<label>Display 'Login as' Action</label>
|
85 |
+
<comment>Display action on the customers grid.</comment>
|
86 |
+
<frontend_type>select</frontend_type>
|
87 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
88 |
+
<sort_order>200</sort_order>
|
89 |
+
<show_in_default>1</show_in_default>
|
90 |
+
<show_in_website>0</show_in_website>
|
91 |
+
<show_in_store>0</show_in_store>
|
92 |
+
</action_enabled>
|
93 |
+
<orders_grid_column_enabled>
|
94 |
+
<label>Display 'Created by' Column</label>
|
95 |
+
<comment>Display column on the orders grid.</comment>
|
96 |
+
<frontend_type>select</frontend_type>
|
97 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
98 |
+
<sort_order>300</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
<show_in_website>0</show_in_website>
|
101 |
+
<show_in_store>0</show_in_store>
|
102 |
+
</orders_grid_column_enabled>
|
103 |
+
<orders_grid_column_position>
|
104 |
+
<label>Position for 'Created by' Column</label>
|
105 |
+
<comment>Setup position for the column on the orders grid.</comment>
|
106 |
+
<frontend_type>text</frontend_type>
|
107 |
+
<validate>required-entry validate-digits validate-digits-range digits-range-1-</validate>
|
108 |
+
<sort_order>400</sort_order>
|
109 |
+
<show_in_default>1</show_in_default>
|
110 |
+
<show_in_website>0</show_in_website>
|
111 |
+
<show_in_store>0</show_in_store>
|
112 |
+
</orders_grid_column_position>
|
113 |
+
</fields>
|
114 |
+
</ui>
|
115 |
+
</groups>
|
116 |
+
</prxgt_lgas>
|
117 |
+
</sections>
|
118 |
</config>
|
app/code/community/Praxigento/LoginAs/sql/prxgt_lgas_setup/mysql4-install-1.0.0.php
CHANGED
@@ -1,49 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* Initial installation script. Contains all upgrades
|
23 |
-
*/
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
/** @var $
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
/** Sales Order */
|
47 |
-
prxgt_install_recreate_column($conn, $this->getTable('sales/order_grid'),
|
48 |
-
Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, SQL_TYPE_VARCHAR . ' ' .
|
49 |
'COMMENT \'admin name/email if Praxigento Login As feature was used.\'');
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2013, Praxigento
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
+
* following conditions are met:
|
8 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
+
* disclaimer.
|
10 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
*
|
13 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* Initial installation script. Contains all upgrades
|
23 |
+
*/
|
24 |
+
const SQL_TYPE_VARCHAR = 'VARCHAR(255) DEFAULT NULL';
|
25 |
+
|
26 |
+
/** @var $installer Mage_Core_Model_Resource_Setup */
|
27 |
+
$installer = $this;
|
28 |
+
/** @var $coreSetup Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
|
29 |
+
$coreSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
30 |
+
/** @var $conn Varien_Db_Adapter_Interface */
|
31 |
+
$conn = $installer->getConnection();
|
32 |
+
|
33 |
+
/** ****************************************************************************************************************
|
34 |
+
* Create table columns for static attributes
|
35 |
+
***************************************************************************************************************** */
|
36 |
+
|
37 |
+
/** Sales Order */
|
38 |
+
$conn->addColumn($this->getTable('sales/order'),
|
39 |
+
Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, SQL_TYPE_VARCHAR . ' ' .
|
40 |
+
'COMMENT \'admin name/email if Praxigento Login As feature was used.\'');
|
41 |
+
|
42 |
+
/** Sales Order */
|
43 |
+
$conn->addColumn($this->getTable('sales/order_grid'),
|
44 |
+
Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, SQL_TYPE_VARCHAR . ' ' .
|
|
|
|
|
|
|
|
|
45 |
'COMMENT \'admin name/email if Praxigento Login As feature was used.\'');
|
app/code/community/Praxigento/LoginAs/sql/prxgt_lgas_setup/prxgt_install_func.php
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright (c) 2013, Praxigento
|
4 |
-
* All rights reserved.
|
5 |
-
*
|
6 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
7 |
-
* following conditions are met:
|
8 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
9 |
-
* disclaimer.
|
10 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
11 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
-
*
|
13 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
15 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
17 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
18 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
19 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* Functions library to be used in install/upgrade scripts.
|
23 |
-
*
|
24 |
-
* User: Flancer
|
25 |
-
* Date: 1/9/13
|
26 |
-
* Time: 1:05 PM
|
27 |
-
*/
|
28 |
-
/** ===========================================================================================================================
|
29 |
-
* Functions section below...
|
30 |
-
* ========================================================================================================================== */
|
31 |
-
/**
|
32 |
-
* Backup data for existing column, re-create column and move data back. Removes 'columnOld' in case of new name
|
33 |
-
* for the column was applied.
|
34 |
-
*
|
35 |
-
* @param Varien_Db_Adapter_Interface $conn
|
36 |
-
* @param $table
|
37 |
-
* @param $column
|
38 |
-
* @param $columnDef
|
39 |
-
* @param null $columnOld old name for the column
|
40 |
-
*/
|
41 |
-
function prxgt_install_recreate_column(Varien_Db_Adapter_Pdo_Mysql $conn, $table, $column, $columnDef, $columnOld = null)
|
42 |
-
{
|
43 |
-
$columnTmp = $column . '_tmp';
|
44 |
-
$fetched = $conn->fetchAll("SELECT * FROM $table LIMIT 1");
|
45 |
-
|
46 |
-
// analyze old named column data
|
47 |
-
$oldColumnExists = (!is_null($columnOld) && is_array($fetched) && isset($fetched[0]) && array_key_exists($columnOld, $fetched[0]));
|
48 |
-
// analyze current column data
|
49 |
-
$columnExists = (is_array($fetched) && isset($fetched[0]) && array_key_exists($column, $fetched[0]));
|
50 |
-
// create backup column and backup data
|
51 |
-
if ($columnExists || $oldColumnExists) {
|
52 |
-
$conn->addColumn($table, $columnTmp, $columnDef);
|
53 |
-
if ($oldColumnExists) {
|
54 |
-
// backup old column data
|
55 |
-
$conn->query("UPDATE $table SET $columnTmp = $columnOld");
|
56 |
-
} else {
|
57 |
-
// backup current column data
|
58 |
-
$conn->query("UPDATE $table SET $columnTmp = $column");
|
59 |
-
}
|
60 |
-
}
|
61 |
-
// re-create current column
|
62 |
-
$conn->dropColumn($table, $column);
|
63 |
-
$conn->addColumn($table, $column, $columnDef);
|
64 |
-
// restore column data from backup
|
65 |
-
if ($columnExists || $oldColumnExists) {
|
66 |
-
// restore existed data
|
67 |
-
$conn->query("UPDATE $table SET $column = $columnTmp");
|
68 |
-
$conn->dropColumn($table, $columnTmp);
|
69 |
-
}
|
70 |
-
// drop old column (for case of empty table)
|
71 |
-
if (!is_null($columnOld) && ($oldColumnExists) && ($columnOld != $column)) {
|
72 |
-
$conn->dropColumn($table, $columnOld);
|
73 |
-
}
|
74 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/layout/prxgt/lgas/{loginas_adminhtml_layout.xml → adminhtml_layout.xml}
RENAMED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2013, Praxigento
|
5 |
-
* All rights reserved.
|
6 |
-
*
|
7 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
-
* following conditions are met:
|
9 |
-
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
-
* disclaimer.
|
11 |
-
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
-
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
-
*
|
14 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
-
*/
|
22 |
-
-->
|
23 |
-
<layout version="0.1.0">
|
24 |
-
<!-- ****************************************************************************** -->
|
25 |
-
<!-- Handler name ([router][controller][action]): -->
|
26 |
-
<!-- ... [nmmlm_core_router]_[sync_products]_[index] -->
|
27 |
-
<!-- ... Nmmlm/Core/controllers/Sync/ProductsController.php:indexAction() -->
|
28 |
-
<!-- ****************************************************************************** -->
|
29 |
-
<prxgt_lgas_router_redirect_index>
|
30 |
-
<block type="adminhtml/template" name="root" template="prxgt/lgas/redirect.phtml"/>
|
31 |
-
</prxgt_lgas_router_redirect_index>
|
32 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2013, Praxigento
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
+
* following conditions are met:
|
9 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
+
* disclaimer.
|
11 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
+
*
|
14 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<layout version="0.1.0">
|
24 |
+
<!-- ****************************************************************************** -->
|
25 |
+
<!-- Handler name ([router][controller][action]): -->
|
26 |
+
<!-- ... [nmmlm_core_router]_[sync_products]_[index] -->
|
27 |
+
<!-- ... Nmmlm/Core/controllers/Sync/ProductsController.php:indexAction() -->
|
28 |
+
<!-- ****************************************************************************** -->
|
29 |
+
<prxgt_lgas_router_redirect_index>
|
30 |
+
<block type="adminhtml/template" name="root" template="prxgt/lgas/redirect.phtml"/>
|
31 |
+
</prxgt_lgas_router_redirect_index>
|
32 |
</layout>
|
app/design/adminhtml/default/default/template/prxgt/lgas/redirect.phtml
CHANGED
@@ -33,12 +33,12 @@ $authPack = Mage::getSingleton('prxgt_lgas_model/package');
|
|
33 |
?>
|
34 |
<html>
|
35 |
<body>
|
36 |
-
<form action="<?php echo $authPack->getRedirectUrl() ?>"
|
37 |
method="post" id="login-form">
|
38 |
-
<?php /** Post file name with login parameters
|
39 |
<input type="hidden" name="<?php echo Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID ?>"
|
40 |
id="<?php echo Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID ?>"
|
41 |
-
value="<?php echo $authPack->getPackageId() ?>"/>
|
42 |
</form>
|
43 |
<script type="text/javascript">
|
44 |
//<![CDATA[
|
33 |
?>
|
34 |
<html>
|
35 |
<body>
|
36 |
+
<form action="<?php echo htmlentities($authPack->getRedirectUrl()) ?>"
|
37 |
method="post" id="login-form">
|
38 |
+
<?php /** Post file name with login parameters */ ?>
|
39 |
<input type="hidden" name="<?php echo Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID ?>"
|
40 |
id="<?php echo Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID ?>"
|
41 |
+
value="<?php echo htmlentities($authPack->getPackageId()) ?>"/>
|
42 |
</form>
|
43 |
<script type="text/javascript">
|
44 |
//<![CDATA[
|
app/design/frontend/base/default/layout/prxgt/lgas/frontend_layout.xml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015, Praxigento
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
8 |
+
* following conditions are met:
|
9 |
+
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
10 |
+
* disclaimer.
|
11 |
+
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
12 |
+
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
13 |
+
*
|
14 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
15 |
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
17 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19 |
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
20 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<layout version="0.1.0">
|
24 |
+
<!-- ****************************************************************************** -->
|
25 |
+
<!-- Handler name ([router][controller][action]): -->
|
26 |
+
<!-- ... [nmmlm_core_router]_[sync_products]_[index] -->
|
27 |
+
<!-- ... Nmmlm/Core/controllers/Sync/ProductsController.php:indexAction() -->
|
28 |
+
<!-- ****************************************************************************** -->
|
29 |
+
<prxgt_lgas_front_front_login_as>
|
30 |
+
<block type="adminhtml/template" name="root"/>
|
31 |
+
</prxgt_lgas_front_front_login_as>
|
32 |
+
</layout>
|
app/locale/en_US/prxgt/lgas/prxgt_lgas.csv
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
"Login as Customer","Login as Customer"
|
2 |
-
"Login as...","Login as..."
|
3 |
-
"Created by","Created by"
|
4 |
-
"Praxigento: 'Created by' access","Praxigento: 'Created by' access"
|
5 |
-
"Praxigento: 'Login as Customer' access","Praxigento: 'Login as Customer' access"
|
6 |
-
"Praxigento: Login As Customer Section","Praxigento: Login As Customer Section"
|
7 |
-
"Enable 'Login as Customer'","Enable 'Login as Customer'"
|
8 |
-
"Check ACL entries (System / Permissions / Roles) in case of feature is enabled but is not accessible.","Check ACL entries (System / Permissions / Roles) in case of feature is enabled but is not accessible."
|
9 |
-
"Log Events","Log Events"
|
10 |
-
"Log 'login as' events (log4php lib is used in case of Nmmlm_Log module is installed).","Log 'login as' events (log4php lib is used in case of Nmmlm_Log module is installed)."
|
11 |
-
"UI Setup","UI Setup"
|
12 |
-
"Display 'Login as' Action","Display 'Login as' Action"
|
13 |
-
"Display action on the customers grid.","Display action on the customers grid."
|
14 |
-
"Display 'Created by' Column","Display 'Created by' Column"
|
15 |
-
"Display column on the orders grid.","Display column on the orders grid."
|
16 |
-
"Position for 'Created by' Column","Position for 'Created by' Column"
|
17 |
-
"Setup position for the column on the orders grid.","Setup position for the column on the orders grid."
|
1 |
+
"Login as Customer","Login as Customer"
|
2 |
+
"Login as...","Login as..."
|
3 |
+
"Created by","Created by"
|
4 |
+
"Praxigento: 'Created by' access","Praxigento: 'Created by' access"
|
5 |
+
"Praxigento: 'Login as Customer' access","Praxigento: 'Login as Customer' access"
|
6 |
+
"Praxigento: Login As Customer Section","Praxigento: Login As Customer Section"
|
7 |
+
"Enable 'Login as Customer'","Enable 'Login as Customer'"
|
8 |
+
"Check ACL entries (System / Permissions / Roles) in case of feature is enabled but is not accessible.","Check ACL entries (System / Permissions / Roles) in case of feature is enabled but is not accessible."
|
9 |
+
"Log Events","Log Events"
|
10 |
+
"Log 'login as' events (log4php lib is used in case of Nmmlm_Log module is installed).","Log 'login as' events (log4php lib is used in case of Nmmlm_Log module is installed)."
|
11 |
+
"UI Setup","UI Setup"
|
12 |
+
"Display 'Login as' Action","Display 'Login as' Action"
|
13 |
+
"Display action on the customers grid.","Display action on the customers grid."
|
14 |
+
"Display 'Created by' Column","Display 'Created by' Column"
|
15 |
+
"Display column on the orders grid.","Display column on the orders grid."
|
16 |
+
"Position for 'Created by' Column","Position for 'Created by' Column"
|
17 |
+
"Setup position for the column on the orders grid.","Setup position for the column on the orders grid."
|
package.xml
CHANGED
@@ -1,18 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Praxigento_LoginAs</name>
|
4 |
-
<version>1.0
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Login as Customer by Praxigento</summary>
|
10 |
<description>Allows store manager to login as a customer right from admin panel. No need for master password.</description>
|
11 |
-
<notes>-
|
12 |
-
|
13 |
-
<
|
14 |
-
<
|
15 |
-
<
|
|
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Praxigento_LoginAs</name>
|
4 |
+
<version>1.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>Apache Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Login as Customer by Praxigento</summary>
|
10 |
<description>Allows store manager to login as a customer right from admin panel. No need for master password.</description>
|
11 |
+
<notes>- Controllers fix (_isAllowed);
|
12 |
+
- Auto installation with sample data generation in development version;</notes>
|
13 |
+
<authors><author><name>Alex Gusev</name><user>praxigento</user><email>support@praxigento.com</email></author></authors>
|
14 |
+
<date>2015-08-12</date>
|
15 |
+
<time>10:26:41</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Praxigento"><dir name="LoginAs"><file name="Config.php" hash="5b9cea206028791a29e175b74b5a226a"/><dir name="Helper"><file name="Data.php" hash="4984b63d05e75a800bed82ea1c5e081b"/></dir><dir name="Model"><file name="Logger.php" hash="a55c0ab3225d571005bc4a488f1fd8ff"/><file name="Observer.php" hash="0704bf3aa563d3ff45f68d88708f59c5"/><file name="Package.php" hash="b9714c664553936faebe2a60090f13f7"/></dir><dir name="Test"><file name="Config_Test.php" hash="5429136647bb5729f640f4ea83c1a805"/><dir name="Model"><file name="Logger_Test.php" hash="59e19092bfab28f026ee68f0da5e3f9e"/></dir><file name="phpunit.bootstrap.php" hash="6d6cdbe1dc9f6d6ea75cf371e784988b"/><file name="phpunit.dist.xml" hash="34b1bc2d5936ebfdf7fd51af87691ed1"/></dir><dir name="controllers"><file name="LoginController.php" hash="177024a4886a39375acac24db6bf0cb3"/><file name="RedirectController.php" hash="c3638f19f8309ed428c451526a78111e"/></dir><dir name="etc"><file name="config.xml" hash="59f4d23cda0764ed7c24bbccbe68f564"/><file name="release.txt" hash="8c194a0e7c393ad6ce7178732ba3cef3"/><file name="system.xml" hash="6e09ca027dd76b33449383d9065d7f7b"/></dir><dir name="sql"><dir name="prxgt_lgas_setup"><file name="mysql4-install-1.0.0.php" hash="fd1c7b0979041dc4b6cdf29c0a3beb76"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="prxgt"><dir name="lgas"><file name="adminhtml_layout.xml" hash="0376174d102d76508fb6c0d87095128e"/></dir></dir></dir><dir name="template"><dir name="prxgt"><dir name="lgas"><file name="redirect.phtml" hash="e56d2d6102ed94c58c1db71e6454a48a"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="prxgt"><dir name="lgas"><file name="frontend_layout.xml" hash="61fb35e960abce103d63a1b9eafd0bbd"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="prxgt"><dir name="lgas"><file name="prxgt_lgas.csv" hash="d5eb322c09140891fc56de3e784389cb"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Praxigento_LoginAs.xml" hash="bbff13b9b95dfa4d1dd28bd2e25f74a3"/></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|