Praxigento_LoginAs - Version 1.2.0

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

Files changed (22) hide show
  1. app/code/community/Praxigento/LoginAs/Config.php +128 -130
  2. app/code/community/Praxigento/LoginAs/Helper/Data.php +30 -30
  3. app/code/community/Praxigento/LoginAs/Model/Logger.php +109 -110
  4. app/code/community/Praxigento/LoginAs/Model/Observer.php +168 -168
  5. app/code/community/Praxigento/LoginAs/Model/Package.php +154 -159
  6. app/code/community/Praxigento/LoginAs/Test/{ConfigTest.php → Config_Test.php} +49 -60
  7. app/code/community/Praxigento/LoginAs/Test/Model/{LoggerTest.php → Logger_Test.php} +45 -57
  8. app/code/community/Praxigento/LoginAs/Test/phpunit.bootstrap.php +29 -30
  9. app/code/community/Praxigento/LoginAs/Test/phpunit.dist.xml +15 -0
  10. app/code/community/Praxigento/LoginAs/Test/phpunit.praxigento.loginas.xml +0 -10
  11. app/code/community/Praxigento/LoginAs/controllers/LoginController.php +115 -107
  12. app/code/community/Praxigento/LoginAs/controllers/RedirectController.php +96 -86
  13. app/code/community/Praxigento/LoginAs/etc/config.xml +172 -165
  14. app/code/community/Praxigento/LoginAs/etc/release.txt +14 -4
  15. app/code/community/Praxigento/LoginAs/etc/system.xml +117 -117
  16. app/code/community/Praxigento/LoginAs/sql/prxgt_lgas_setup/mysql4-install-1.0.0.php +44 -48
  17. app/code/community/Praxigento/LoginAs/sql/prxgt_lgas_setup/prxgt_install_func.php +0 -74
  18. app/design/adminhtml/default/default/layout/prxgt/lgas/{loginas_adminhtml_layout.xml → adminhtml_layout.xml} +31 -31
  19. app/design/adminhtml/default/default/template/prxgt/lgas/redirect.phtml +3 -3
  20. app/design/frontend/base/default/layout/prxgt/lgas/frontend_layout.xml +32 -0
  21. app/locale/en_US/prxgt/lgas/prxgt_lgas.csv +17 -17
  22. 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
- * UI components
34
- *****************************************************************************************/
35
- const UI_BTN_LOGIN_AS = 'prxgt_lgas_button';
36
- /******************************************************************************************
37
- * POST/GET request parameters
38
- *****************************************************************************************/
39
- /** don't change value: see Observer/doCustomerGridActionAdd() */
40
- const REQ_PARAM_LAS_ID = 'id';
41
- /******************************************************************************************
42
- * Routing (/[ctrl]/[action])
43
- *****************************************************************************************/
44
- const ROUTE_REDIRECT = '/redirect/';
45
- const ROUTE_CUSTOMER_LOGINAS = '/login/as/';
46
- /** **************************************************************************************
47
- * Session parameters
48
- ************************************************************************************** */
49
- const SESS_LOGGED_AS_OPERATOR = 'prxgtLoggedInAsOperator';
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
- * Display or not 'Login as Customer' action on the customers grid.
95
- * @return bool
96
- */
97
- public static function cfgUiCustomersGridActionEnabled()
98
- {
99
- return filter_var(Mage::getStoreConfig('prxgt_lgas/ui/action_enabled'), FILTER_VALIDATE_BOOLEAN);
100
- }
101
-
102
- /**
103
- * Display or not columns with 'Login As' data on the orders grid.
104
- * @return bool
105
- */
106
- public static function cfgUiOrdersGridColumnEnabled()
107
- {
108
- return filter_var(Mage::getStoreConfig('prxgt_lgas/ui/orders_grid_column_enabled'), FILTER_VALIDATE_BOOLEAN);
109
- }
110
-
111
- /**
112
- * Returns position of the created by column (by default - 5).
113
- * @return int
114
- */
115
- public static function cfgUiOrdersGridColumnPosition()
116
- {
117
- $val = Mage::getStoreConfig('prxgt_lgas/ui/orders_grid_column_position');
118
- return (is_null($val)) ? 5 : (int)$val;
119
- }
120
-
121
-
122
- /**
123
- * Returns default helper for the module.
124
- * @return Praxigento_LoginAs_Helper_Data
125
- */
126
- public static function helper()
127
- {
128
- return Mage::helper('prxgt_lgas_helper');
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 $isLog4phpUsed = null;
31
- /** @var string name for the current logger */
32
- private $name;
33
- /** @var Logger */
34
- private $loggerLog4php;
35
-
36
-
37
- function __construct($name)
38
- {
39
- self::$isLog4phpUsed = class_exists('Nmmlm_Log_Logger', false);
40
- if (self::$isLog4phpUsed) {
41
- $this->loggerLog4php = Nmmlm_Log_Logger::getLogger($name);
42
- } else {
43
- $this->name = is_object($name) ? get_class($name) : (string)$name;
44
- }
45
- }
46
-
47
- /**
48
- * Override getter to use '$log = Nmmlm_Log_Logger::getLogger($this)' form in Mage classes.
49
- * @static
50
- *
51
- * @param string $name
52
- *
53
- * @return Praxigento_LoginAs_Model_Logger
54
- */
55
- public static function getLogger($name)
56
- {
57
- return new Praxigento_LoginAs_Model_Logger($name);
58
- }
59
-
60
- /**
61
- * Internal dispatcher for the called log method.
62
- * @param $message
63
- * @param $throwable
64
- * @param $log4phpMethod
65
- * @param $zendLevel
66
- */
67
- private function doLog($message, $throwable, $log4phpMethod, $zendLevel)
68
- {
69
- if (Praxigento_LoginAs_Config::cfgGeneralLogEvents()) {
70
- if (self::$isLog4phpUsed) {
71
- $this->loggerLog4php->$log4phpMethod($message, $throwable);
72
- } else {
73
- Mage::log($this->name . ': ' . $message, $zendLevel);
74
- if ($throwable instanceof Exception) {
75
- Mage::logException($throwable);
76
- }
77
- }
78
- }
79
- }
80
-
81
- public function trace($message, $throwable = null)
82
- {
83
- $this->doLog($message, $throwable, 'trace', Zend_Log::DEBUG);
84
- }
85
-
86
- public function debug($message, $throwable = null)
87
- {
88
- $this->doLog($message, $throwable, 'debug', Zend_Log::INFO);
89
- }
90
-
91
- public function info($message, $throwable = null)
92
- {
93
- $this->doLog($message, $throwable, 'info', Zend_Log::NOTICE);
94
- }
95
-
96
- public function warn($message, $throwable = null)
97
- {
98
- $this->doLog($message, $throwable, 'warn', Zend_Log::WARN);
99
- }
100
-
101
- public function error($message, $throwable = null)
102
- {
103
- $this->doLog($message, $throwable, 'error', Zend_Log::ERR);
104
- }
105
-
106
- public function fatal($message, $throwable = null)
107
- {
108
- $this->doLog($message, $throwable, 'fatal', Zend_Log::CRIT);
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
- * Adds 'Login As' button to the customer form.
30
- * @param Varien_Event_Observer $observer
31
- */
32
- public function onAdminhtmlWidgetContainerHtmlBefore(Varien_Event_Observer $observer)
33
- {
34
- /** validate availability & permissions */
35
- if (
36
- Praxigento_LoginAs_Config::cfgGeneralEnabled() &&
37
- Praxigento_LoginAs_Config::canAccessLoginAs()
38
- ) {
39
- /** add button to the form */
40
- /** @var $block Mage_Adminhtml_Block_Customer_Edit */
41
- $block = $observer->getEvent()->getBlock();
42
- if ($block instanceof Mage_Adminhtml_Block_Customer_Edit) {
43
- $customer = Mage::registry('current_customer');
44
- if ($customer && $customer->getId()) {
45
- /** get data and setup URL to redirection controller */
46
- $customerId = $customer->getId();
47
- $url = Mage::getModel('adminhtml/url')->getUrl(
48
- Praxigento_LoginAs_Config::XMLCFG_ROUTER_ADMIN . Praxigento_LoginAs_Config::ROUTE_REDIRECT,
49
- array(
50
- Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID => $customerId,
51
- )
52
- );
53
- /** create UI button */
54
- $level = 0;
55
- $sortOrder = -1;
56
- $area = 'header';
57
- $block->addButton(Praxigento_LoginAs_Config::UI_BTN_LOGIN_AS,
58
- array(
59
- 'label' => Praxigento_LoginAs_Config::helper()->__('Login as Customer'),
60
- /** open in new window */
61
- 'onclick' => "window.open('$url')",
62
- ), $level, $sortOrder, $area);
63
- }
64
- }
65
- }
66
- }
67
-
68
-
69
- /**
70
- * Add 'created by' data to order.
71
- *
72
- * @param Varien_Event_Observer $observer
73
- */
74
- public function onSalesConvertQuoteAddressToOrder(Varien_Event_Observer $observer)
75
- {
76
- if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
77
- $order = $observer->getEvent()->getOrder();
78
- /** @var $session Mage_Customer_Model_Session */
79
- $session = Mage::getSingleton('customer/session');
80
- $operator = $session->getData(Praxigento_LoginAs_Config::SESS_LOGGED_AS_OPERATOR);
81
- if (!is_null($operator)) {
82
- $order->setData(Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, $operator);
83
- } else {
84
- $order->setData(Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, '[Customer]');
85
- }
86
- }
87
- }
88
-
89
- /**
90
- * Extend UI blocks.
91
- * @param Varien_Event_Observer $observer
92
- */
93
- public function onAdminhtmlBlockHtmlBefore(Varien_Event_Observer $observer)
94
- {
95
- if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
96
- $block = $observer->getData('block');
97
- if ($block instanceof Mage_Adminhtml_Block_Customer_Grid) {
98
- $this->doCustomerGridActionAdd($block);
99
- } elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
100
- $this->doOrderGridColumnAdd($block);
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
  }
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
- /** @var string administrator's name to be displayed in orders grid and logs */
33
- private $adminName;
34
- private $customerId;
35
- private $customerName;
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
-
42
- public function setCustomerId($customerId)
43
- {
44
- $this->customerId = $customerId;
45
- }
46
-
47
- public function getCustomerId()
48
- {
49
- return $this->customerId;
50
- }
51
-
52
- private $ip;
53
-
54
- public function setAdminName($adminName)
55
- {
56
- $this->adminName = $adminName;
57
- }
58
-
59
- public function getAdminName()
60
- {
61
- return $this->adminName;
62
- }
63
-
64
- public function setCustomerName($customerName)
65
- {
66
- $this->customerName = $customerName;
67
- }
68
-
69
- public function getCustomerName()
70
- {
71
- return $this->customerName;
72
- }
73
-
74
- public function setIp($ip)
75
- {
76
- $this->ip = $ip;
77
- }
78
-
79
- public function getIp()
80
- {
81
- return $this->ip;
82
- }
83
-
84
- /**
85
- * Saves login data into file in the temporary directory and returns name of the tmp file including extension.
86
- * @return string
87
- */
88
- public function saveAsFile()
89
- {
90
- // generate unique filename and create file to save login data
91
- $fname = tempnam(sys_get_temp_dir(), self::PREFIX);
92
- $path_parts = pathinfo($fname);
93
- $this->packageId = $path_parts['basename'];
94
- $handle = fopen($fname, "w");
95
- // write login data to file
96
- $content = $this->adminName . "\n";
97
- $content .= $this->customerId . "\n";
98
- $content .= $this->customerName . "\n";
99
- $content .= $this->ip . "\n";
100
- fwrite($handle, $content);
101
- fclose($handle);
102
- return $this->packageId;
103
- }
104
-
105
- /**
106
- * Loads "Login As" parameters from file and removes file from disk.
107
- * @param $filename
108
- */
109
- public function loadFromFile($filename)
110
- {
111
- // load data
112
- $this->packageId = $filename;
113
- $fname = sys_get_temp_dir() . DS . $this->packageId;
114
- $data = file($fname);
115
- if (is_array($data) && sizeof($data >= 4)) {
116
- $this->adminName = trim($data[0]);
117
- $this->customerId = trim($data[1]);
118
- $this->customerName = trim($data[2]);
119
- $this->ip = trim($data[3]);
120
- }
121
- // remove file
122
- unlink($fname);
123
- $this->packageId = null;
124
- }
125
-
126
- /**
127
- * @param string $packageId
128
- */
129
- public function setPackageId($packageId)
130
- {
131
- $this->packageId = $packageId;
132
- }
133
-
134
- /**
135
- * @return string
136
- */
137
- public function getPackageId()
138
- {
139
- return $this->packageId;
140
- }
141
-
142
- /**
143
- * @param string $redirectUrl
144
- */
145
- public function setRedirectUrl($redirectUrl)
146
- {
147
- $this->redirectUrl = $redirectUrl;
148
- }
149
-
150
- /**
151
- * @return string
152
- */
153
- public function getRedirectUrl()
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
- * Sets up the fixture, for example, opens a network connection.
31
- * This method is called before a test is executed.
32
- */
33
- protected function setUp()
34
- {
35
- if (!class_exists('Mage')) {
36
- require_once '../../../../../Mage.php';
37
- }
38
- Mage::app();
39
- }
40
-
41
- public function testCfg()
42
- {
43
- // System / Configuration
44
- // general
45
- $this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgGeneralEnabled()));
46
- $this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgGeneralLogEvents()));
47
- // UI
48
- $this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgUiCustomersGridActionEnabled()));
49
- $this->assertTrue(is_bool(Praxigento_LoginAs_Config::cfgUiOrdersGridColumnEnabled()));
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
- * Sets up the fixture, for example, opens a network connection.
30
- * This method is called before a test is executed.
31
- */
32
- protected function setUp()
33
- {
34
- if (!class_exists('Mage')) {
35
- require_once '../../../../../../Mage.php';
36
- }
37
- Mage::app();
38
- }
39
-
40
- public function test_all()
41
- {
42
- $log = Praxigento_LoginAs_Model_Logger::getLogger($this);
43
- $log->trace('trace');
44
- $log->debug('debug');
45
- $log->info('info');
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
- * Copyright (c) 2012, 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
- * Bootstrap file for PHPUnit tests.
23
- * User: Alex Gusev <flancer64@gmail.com>
24
- * Date: 2013/02/18
25
- */
26
- /** Load 'Mage' class to enable Magento autoloading. */
27
- require_once '../../../../../Mage.php';
28
- // buffer output to prevent errors when test suite is running.
29
- ob_start();
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
- * User: Alex Gusev <flancer64@gmail.com>
23
- * Date: 2/20/13
24
- * Time: 2:04 PM
25
- */
26
- class Praxigento_LoginAs_LoginController extends Mage_Core_Controller_Front_Action
27
- {
28
- public function asAction()
29
- {
30
- /** event logger */
31
- $log = Praxigento_LoginAs_Model_Logger::getLogger($this);
32
- /** get filename from the request parameters */
33
- $filename = $this->getRequest()->getPost(Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID);
34
- /** @var $authPack Praxigento_LoginAs_Model_Package */
35
- $authPack = Mage::getSingleton('prxgt_lgas_model/package');
36
- $authPack->loadFromFile($filename);
37
- /** extract working data */
38
- $customerId = $authPack->getCustomerId();
39
- if (!is_null($customerId)) {
40
- $customerName = $authPack->getCustomerName();
41
- $operatorName = $authPack->getAdminName();
42
- $operatorIp = $authPack->getIp();
43
- $log->trace("Operator '$operatorName' trying to login as '$customerName' (id=$customerId) from ip '$operatorIp'...");
44
- /** validate current customer's session or establish new session and validate request */
45
- $session = Mage::getSingleton('customer/session');
46
- $sessionCustomer = $session->getCustomer();
47
- $sessionCustomerId = $sessionCustomer->getId();
48
- /** this operator is already logged in as required customer */
49
- if (($session->isLoggedIn()) && ($customerId == $sessionCustomerId)) {
50
- $log->debug("Session for customer '$customerName' (id=$customerId) is already exist. Refreshing page...");
51
- /** save operator's name into session to use in orders later */
52
- $session->setData(Praxigento_LoginAs_Config::SESS_LOGGED_AS_OPERATOR, $operatorName);
53
- } else {
54
- /** establish new customer session */
55
- $validatorData = $session->getValidatorData();
56
- if ($this->getRequest()->isPost() && ($operatorIp == $validatorData['remote_addr'])) {
57
- try {
58
- /** @var $customer Mage_Customer_Model_Customer */
59
- $customer = Mage::getModel('customer/customer')->load($customerId);
60
- if ($customer->getId() == $customerId) {
61
- /** check allowed websites */
62
- $wsId = Mage::app()->getStore()->getWebsiteId();
63
- $wsids = $customer->getSharedWebsiteIds();
64
- $custWsId = $customer->getData('website_id');
65
- if (
66
- (in_array($wsId, $wsids)) ||
67
- ($wsId == $custWsId)
68
- ) {
69
- $session->loginById($customerId);
70
- /** save operator's name into session to use in orders later */
71
- $session->setData(Praxigento_LoginAs_Config::SESS_LOGGED_AS_OPERATOR, $operatorName);
72
- $log->info("New session for customer '$customerName' (id=$customerId) is established for operator '$operatorName'");
73
- } else {
74
- $msg = "Customer '$customerName' (id=$customerId) has no rights to access current website.";
75
- $log->error($msg);
76
- Mage::throwException($msg);
77
- }
78
- } else {
79
- $msg = "Customer with id '$customerId' does not exists.";
80
- $log->error($msg);
81
- Mage::throwException($msg);
82
- }
83
- } catch (Mage_Core_Exception $e) {
84
- switch ($e->getCode()) {
85
- case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
86
- $message = $e->getMessage();
87
- break;
88
- default:
89
- $message = $e->getMessage();
90
- }
91
- $session->addError($message);
92
- $session->setId(null);
93
- $log->error('Session ID is reset due to error is occurred. Exception is not logged.');
94
- } catch (Exception $e) {
95
- /** Mage::logException($e); // PA DSS violation: this exception log can disclose customer password */
96
- }
97
- } else {
98
- $log->warn("Authentication request failure: request type is not POST or operator's current ip (" .
99
- $validatorData['remote_addr'] . ") is not equal to ip from authentication package ($operatorIp).");
100
- }
101
- }
102
- } else {
103
- $log->warn("Cannot get customer id for authentication package '$filename'.");
104
- }
105
- $this->_redirect('customer/account');
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
- * Controller to process operator's requests to redirect to the frontend to login as a customer.
23
- */
24
- class Praxigento_LoginAs_RedirectController extends Mage_Adminhtml_Controller_Action
25
- {
26
-
27
- public function indexAction()
28
- {
29
- if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
30
- /** define operator name */
31
- /** @var $session Mage_Admin_Model_Session */
32
- $session = Mage::getSingleton('admin/session');
33
- if ($session->isLoggedIn()) {
34
- /** @var $user Mage_Admin_Model_User */
35
- $user = $session->getUser();
36
- $operator = $user->getName() . ' (' . $user->getEmail() . ')';
37
- /** if there is customer data in request */
38
- if (!is_null($this->getRequest()->getParams())) {
39
- $params = $this->getRequest()->getParams();
40
- if (!is_null($params[Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID])) {
41
- /** extract customer ID from request and load customer data */
42
- $customerId = $params[Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID];
43
- /** @var $customer Mage_Customer_Model_Customer */
44
- $customer = Mage::getModel('customer/customer')->load($customerId);
45
- if ($customer->getId() == $customerId) {
46
- $customerName = $customer->getName();
47
- /** define URL to login to customer's website */
48
- $wsId = $customer->getData('website_id');
49
- if (is_null($wsId)) {
50
- $wsId = Mage::app()->getStore()->getWebsiteId();
51
- }
52
- /** @var $website Mage_Core_Model_Website */
53
- $website = Mage::getModel('core/website')->load($wsId);
54
- $defStoreId = $website->getDefaultStore()->getId();
55
- $baseTarget = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL, $defStoreId);
56
- $baseSource = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL);
57
- /** compose redirection URL and replace current base by target base */
58
- $url = Mage::getModel('core/url')->getUrl(Praxigento_LoginAs_Config::XMLCFG_ROUTER_FRONT . Praxigento_LoginAs_Config::ROUTE_CUSTOMER_LOGINAS);
59
- $url = str_replace($baseSource, $baseTarget, $url);
60
- /** compose authentication package */
61
- /** @var $authPack Praxigento_LoginAs_Model_Package */
62
- $authPack = Mage::getSingleton('prxgt_lgas_model/package');
63
- $authPack->setAdminName($operator);
64
- $authPack->setCustomerId($customerId);
65
- $authPack->setCustomerName($customerName);
66
- $authPack->setRedirectUrl($url);
67
- $validatorData = $session->getValidatorData();
68
- $ip = $validatorData['remote_addr'];
69
- $authPack->setIp($ip);
70
- /** save login data to file */
71
- $authPack->saveAsFile();
72
- /** log event */
73
- $log = Praxigento_LoginAs_Model_Logger::getLogger($this);
74
- $log->trace("Operator '$operator' is redirected to front from ip '$ip' to login" .
75
- " as customer '$customerName' ($customerId).");
76
- }
77
- /** load layout and render blocks */
78
- $this->loadLayout()->renderLayout();
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.1</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/loginas_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
- </frontend>
132
- <global>
133
- <events>
134
- <sales_convert_quote_address_to_order>
135
- <observers>
136
- <prxgt_lgas_observer>
137
- <type>singleton</type>
138
- <class>prxgt_lgas_model/observer</class>
139
- <method>onSalesConvertQuoteAddressToOrder</method>
140
- </prxgt_lgas_observer>
141
- </observers>
142
- </sales_convert_quote_address_to_order>
143
- </events>
144
- <helpers>
145
- <!-- Default helper for module (prevents errors like "Class 'Namespace_Module_Helper_Data' not found in") -->
146
- <prxgt_lgas_helper>
147
- <class>Praxigento_LoginAs_Helper</class>
148
- </prxgt_lgas_helper>
149
- </helpers>
150
- <models>
151
- <prxgt_lgas_model>
152
- <class>Praxigento_LoginAs_Model</class>
153
- </prxgt_lgas_model>
154
- </models>
155
- <resources>
156
- <prxgt_lgas_setup>
157
- <setup>
158
- <module>Praxigento_LoginAs</module>
159
- </setup>
160
- <connection>
161
- <use>core_setup</use>
162
- </connection>
163
- </prxgt_lgas_setup>
164
- </resources>
165
- </global>
 
 
 
 
 
 
 
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.1:
2
- - Fix ACL related errors;
3
-
4
- 1.0.0:
 
 
 
 
 
 
 
 
 
 
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
- /** include function to replace old columns with new ones */
25
- include_once('prxgt_install_func.php');
26
-
27
-
28
- const SQL_TYPE_VARCHAR = 'VARCHAR(255) DEFAULT NULL';
29
-
30
- /** @var $installer Mage_Core_Model_Resource_Setup */
31
- $installer = $this;
32
- /** @var $coreSetup Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
33
- $coreSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
34
- /** @var $conn Varien_Db_Adapter_Interface */
35
- $conn = $installer->getConnection();
36
-
37
- /** ****************************************************************************************************************
38
- * Create table columns for static attributes
39
- ***************************************************************************************************************** */
40
-
41
- /** Sales Order */
42
- prxgt_install_recreate_column($conn, $this->getTable('sales/order'),
43
- Praxigento_LoginAs_Config::ATTR_ORDER_CREATED_BY, SQL_TYPE_VARCHAR . ' ' .
44
- 'COMMENT \'admin name/email if Praxigento Login As feature was used.\'');
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.1</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/apachepl-1.1.php">ASF</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>- Fix ACL related errors;</notes>
12
- <authors><author><name>Alex Gusev</name><user>praxigento</user><email>info@flancer.lv</email></author></authors>
13
- <date>2013-04-08</date>
14
- <time>12:57:27</time>
15
- <contents><target name="magecommunity"><dir name="Praxigento"><dir name="LoginAs"><file name="Config.php" hash="6353a543c2a829fe3c36072b035f62f1"/><dir name="Helper"><file name="Data.php" hash="8953db573e1a359cce3177741a166024"/></dir><dir name="Model"><file name="Logger.php" hash="04ddc399d206a4f9c1c5f6088c8ad811"/><file name="Observer.php" hash="3b3e9128dfe7883344380956faff175c"/><file name="Package.php" hash="1c945f7061451eaec17ca7ba15d03590"/></dir><dir name="Test"><file name="ConfigTest.php" hash="bce99007796d30ee4086eba5a5c1fb08"/><dir name="Model"><file name="LoggerTest.php" hash="6f45e5a49612305912fd1fce72734008"/></dir><file name="phpunit.bootstrap.php" hash="b27a8bb387f22af87d3505d1ef6c0325"/><file name="phpunit.praxigento.loginas.xml" hash="8fdc08af610b56397ce4a026bbf1bf71"/></dir><dir name="controllers"><file name="LoginController.php" hash="bbb4de789aaec13af2f191a2015c728a"/><file name="RedirectController.php" hash="05133cd77c2d0cb9a99fe840d7247e73"/></dir><dir name="etc"><file name="config.xml" hash="e8a02cf95209014b15f0d77dd9f0b8c9"/><file name="release.txt" hash="1998e8844cfc4ed0d0bcba637eb2a423"/><file name="system.xml" hash="72d8cacd82b3f03efce67ec7dccf4990"/></dir><dir name="sql"><dir name="prxgt_lgas_setup"><file name="mysql4-install-1.0.0.php" hash="e411ae4ef99146b606ddcdaf49020f8b"/><file name="prxgt_install_func.php" hash="17e7e7f7ac12da3c31eeb7ba37c3d524"/></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="loginas_adminhtml_layout.xml" hash="1c738335b661f3f5d68fa81520bd5d7a"/></dir></dir></dir><dir name="template"><dir name="prxgt"><dir name="lgas"><file name="redirect.phtml" hash="ccda9df924c7a0e79fdf85c163890674"/></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="fa4a8396c84de6c3585b87d13c882085"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Praxigento_LoginAs.xml" hash="bbff13b9b95dfa4d1dd28bd2e25f74a3"/></dir></target></contents>
 
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);&#xD;
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>