Skip to content

Commit 99b4374

Browse files
committed
Update as of 5/31/2012
* Implemented backend authentication independent of `Mage_Adminhtml` module. Authentication can be disabled * Authentication logic is moved to `Mage_Backend` module and being performed in controller instead of observer * `Mage_Adminhtml_Controller_Action` is changed to `Mage_Backend_Controller_ActionAbstract`, `Mage_Admin_Model_Session` is changed to `Mage_Backend_Model_Auth_Session`, `Mage_User_Model_Role` and `Mage_User_Model_Roles` classes are unified into one `Mage_User_Model_Role` class * Introduced `Mage_User` module for users and roles management * Introduced support of minimized CSS and JS files: in production mode minimized file is used, if exists * Implemented resize, rotate, crop and watermark functionality for ImageMagick adapter * Fixed some issues: * Fixed absence of product without image, if ImageMagick is used * Fixed broken Downloadable product creation page, when developer mode is enabled * Fixed random failures of `Integrity_LayoutTest::testHandlesHierarchy` test * Fixed backup creation: media directory was excluded from the backup file when it should be included and vice-versa * Fixed broken product configuration page in Shopping Cart * Fixed incorrect work of "After number of attempts to login" functionality for CAPTCHA: captcha was not displayed after specified number of incorrect attempts * Fixed creation of User Role: resource access was set to 'Custom', when 'All' is selected * Fixed exception "Unable to locate skin file" at the end of installation * Fixed broken "Use Store Credit" functionality on checkout * Fixed lost MySQL connection, if it's not used for long time * Fixed ability to separate CDN server setup for static and media content * Other small fixes
1 parent b8f3ea4 commit 99b4374

File tree

593 files changed

+18814
-10648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

593 files changed

+18814
-10648
lines changed

CHANGELOG.markdown

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1+
Update as of 5/31/2012
2+
======================
3+
* Implemented backend authentication independent of `Mage_Adminhtml` module. Authentication can be disabled
4+
* Authentication logic is moved to `Mage_Backend` module and being performed in controller instead of observer
5+
* `Mage_Adminhtml_Controller_Action` is changed to `Mage_Backend_Controller_ActionAbstract`, `Mage_Admin_Model_Session` is changed to `Mage_Backend_Model_Auth_Session`, `Mage_User_Model_Role` and `Mage_User_Model_Roles` classes are unified into one `Mage_User_Model_Role` class
6+
* Introduced `Mage_User` module for users and roles management
7+
* Introduced support of minimized CSS and JS files: in production mode minimized file is used, if exists
8+
* Implemented resize, rotate, crop and watermark functionality for ImageMagick adapter
9+
* Fixed some issues:
10+
* Fixed absence of product without image, if ImageMagick is used
11+
* Fixed broken Downloadable product creation page, when developer mode is enabled
12+
* Fixed random failures of `Integrity_LayoutTest::testHandlesHierarchy` test
13+
* Fixed backup creation: media directory was excluded from the backup file when it should be included and vice-versa
14+
* Fixed broken product configuration page in Shopping Cart
15+
* Fixed incorrect work of "After number of attempts to login" functionality for CAPTCHA: captcha was not displayed after specified number of incorrect attempts
16+
* Fixed creation of User Role: resource access was set to 'Custom', when 'All' is selected
17+
* Fixed exception "Unable to locate skin file" at the end of installation
18+
* Fixed broken "Use Store Credit" functionality on checkout
19+
* Fixed lost MySQL connection, if it's not used for long time
20+
* Fixed ability to separate CDN server setup for static and media content
21+
* Other small fixes
22+
123
Update as of 5/23/2012
224
======================
325
* Published performance tests (`dev/tests/performance`)
426
* Implemented support of ImageMagick library for processing images
527
* Distinguished "Page Fragments" and "Pages" in layout handles declaration
628
* Reduced performance drop caused by introducing containers
7-
* Implemented Magento_Data_Structure library which is used to handle structure of layout elements
29+
* Implemented `Magento_Data_Structure` library which is used to handle structure of layout elements
830
* Fixed some issues:
931
* Fixed error on saving newsletter template
1032
* Fixed some checkout issues:
@@ -65,7 +87,7 @@ Update as of 4/13/2012
6587
======================
6688

6789
* Implemented a tool for migrating factory table names from 1.x to 2.x. The tool replaces table names by list of names associations
68-
* Changed Unit tests suite running from usage AllTests.php in each directory to configuration in phpunit.xml.dist. Now all tests in {{testsuite}} directory are launched, there is no necessity to add new tests to the config
90+
* Changed Unit tests suite running from usage AllTests.php in each directory to configuration in phpunit.xml.dist. Now all tests in `testsuite` directory are launched, there is no necessity to add new tests to the config
6991
* Implemented in Visual Desig Editor:
7092
* Containers highlighting
7193
* Dropping of elements

app/code/core/Mage/Admin/Helper/Data.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,10 @@
3030
* @category Mage
3131
* @package Mage_Admin
3232
* @author Magento Core Team <core@magentocommerce.com>
33+
* @deprecated Moved to Mage_Backend
34+
* @see Mage_User_Helper_Data
3335
*/
3436
class Mage_Admin_Helper_Data extends Mage_Core_Helper_Abstract
3537
{
36-
/**
37-
* Configuration path to expiration period of reset password link
38-
*/
39-
const XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD
40-
= 'default/admin/emails/password_reset_link_expiration_period';
4138

42-
/**
43-
* Generate unique token for reset password confirmation link
44-
*
45-
* @return string
46-
*/
47-
public function generateResetPasswordLinkToken()
48-
{
49-
return Mage::helper('Mage_Core_Helper_Data')->uniqHash();
50-
}
51-
52-
/**
53-
* Retrieve customer reset password link expiration period in days
54-
*
55-
* @return int
56-
*/
57-
public function getResetPasswordLinkExpirationPeriod()
58-
{
59-
return (int) Mage::getConfig()->getNode(self::XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD);
60-
}
6139
}

app/code/core/Mage/Admin/Model/Config.php

Lines changed: 181 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,74 @@ class Mage_Admin_Model_Config extends Varien_Simplexml_Config
4141
*/
4242
protected $_adminhtmlConfig;
4343

44+
/**
45+
* Main Application object
46+
*
47+
* @var Mage_Core_Model_App
48+
*/
49+
protected $_app;
50+
51+
/**
52+
* Main Application config
53+
*
54+
* @var Mage_Core_Model_Config
55+
*/
56+
protected $_appConfig;
57+
58+
/**
59+
* List of helpers by module
60+
*
61+
* @var array
62+
*/
63+
protected $_helpers = array();
64+
4465
/**
4566
* Load config from merged adminhtml.xml files
67+
* @param array $arguments
4668
*/
47-
public function __construct()
69+
public function __construct(array $arguments = array())
4870
{
71+
$this->_app = isset($arguments['app']) ? $arguments['app'] : Mage::app();
72+
$this->_appConfig = isset($arguments['appConfig']) ? $arguments['appConfig'] : Mage::getConfig();
73+
if (isset($arguments['helpers'])) {
74+
$this->_helpers = $arguments['helpers'];
75+
}
76+
77+
4978
parent::__construct();
5079
$this->setCacheId('adminhtml_acl_menu_config');
5180

5281
/* @var $adminhtmlConfig Varien_Simplexml_Config */
53-
$adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
82+
$adminhtmlConfig = $this->_app->loadCache($this->getCacheId());
5483
if ($adminhtmlConfig) {
5584
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
5685
} else {
5786
$adminhtmlConfig = new Varien_Simplexml_Config;
5887
$adminhtmlConfig->loadString('<?xml version="1.0"?><config></config>');
59-
Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
88+
$this->_appConfig->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
6089
$this->_adminhtmlConfig = $adminhtmlConfig;
6190

62-
if (Mage::app()->useCache('config')) {
63-
Mage::app()->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(),
91+
if ($this->_app->useCache('config')) {
92+
$this->_app->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(),
6493
array(Mage_Core_Model_Config::CACHE_TAG));
6594
}
6695
}
6796
}
6897

98+
/**
99+
* Retrieve base helper by module
100+
*
101+
* @param string $module
102+
* @return Mage_Core_Helper_Abstract
103+
*/
104+
protected function _getHelper($module)
105+
{
106+
if (isset($this->_helpers[$module])) {
107+
return $this->_helpers[$module];
108+
}
109+
return Mage::helper($module);
110+
}
111+
69112
/**
70113
* Load Acl resources from config
71114
*
@@ -109,6 +152,138 @@ public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource = null, $p
109152
return $this;
110153
}
111154

155+
/**
156+
* Retrieve Acl Resource Tree with module and path information
157+
*
158+
* @return Varien_Simplexml_Element
159+
*/
160+
public function getAclResourceTree()
161+
{
162+
return $this->_walkResourceTree();
163+
}
164+
165+
/**
166+
* Retrieve flat Acl Resource list with level information
167+
* @param bool $shortFormat
168+
* @return array
169+
*/
170+
public function getAclResourceList($shortFormat = false)
171+
{
172+
return $this->_flattenResourceTree(null, null, 0, 'Mage_Backend', $shortFormat);
173+
}
174+
175+
/**
176+
* Decorate acl resource tree
177+
*
178+
* @param Varien_Simplexml_Element $resource
179+
* @param null $parentName
180+
* @param string $module
181+
* @return Varien_Simplexml_Element
182+
*/
183+
protected function _walkResourceTree(Varien_Simplexml_Element $resource = null,
184+
$parentName = null, $module = 'Mage_Backend')
185+
{
186+
$resourceName = $parentName;
187+
if (is_null($resource)) {
188+
$resource = $this->getAdminhtmlConfig()->getNode('acl/resources');
189+
$resourceName = null;
190+
$level = -1;
191+
} else {
192+
if (!$this->_isServiceElement($resource)) {
193+
$resourceName = $this->_buildFullResourceName($resource, $parentName);
194+
//assigning module for its' children nodes
195+
if ($resource->getAttribute('module')) {
196+
$module = (string)$resource->getAttribute('module');
197+
198+
}
199+
$resource->addAttribute('aclpath', $resourceName);
200+
$resource->addAttribute('module_c', $module);
201+
}
202+
}
203+
204+
//check children and run recursion if they exists
205+
$children = $resource->children();
206+
foreach ($children as $key => $child) {
207+
if (1 == $child->disabled) {
208+
$resource->{$key} = null;
209+
continue;
210+
}
211+
$this->_walkResourceTree($child, $resourceName, $module);
212+
}
213+
return $resource;
214+
}
215+
216+
/**
217+
* Flatten acl resources tree
218+
*
219+
* @param null|Varien_Simplexml_Element $resource
220+
* @param null $parentName
221+
* @param int $level
222+
* @param string $module
223+
* @param bool $shortFormat
224+
* @return array
225+
*/
226+
protected function _flattenResourceTree(Varien_Simplexml_Element $resource = null,
227+
$parentName = null, $level = 0, $module = 'Mage_Backend', $shortFormat = false)
228+
{
229+
$result = array();
230+
$resourceName = $parentName;
231+
if (is_null($resource)) {
232+
$resource = $this->getAdminhtmlConfig()->getNode('acl/resources');
233+
$resourceName = null;
234+
$level = -1;
235+
} else {
236+
if (!$this->_isServiceElement($resource)) {
237+
$resourceName = $this->_buildFullResourceName($resource, $parentName);
238+
239+
if ($shortFormat) {
240+
$result[] = $resourceName;
241+
} else {
242+
if ($resource->getAttribute('module')) {
243+
$module = (string)$resource->getAttribute('module');
244+
}
245+
$result[$resourceName]['name'] = $this->_getHelper($module)->__((string)$resource->title);
246+
$result[$resourceName]['level'] = $level;
247+
}
248+
}
249+
}
250+
//check children and run recursion if they exists
251+
$children = $resource->children();
252+
foreach ($children as $key => $child) {
253+
if (1 == $child->disabled) {
254+
continue;
255+
}
256+
$result = array_merge(
257+
$this->_flattenResourceTree($child, $resourceName, $level + 1, $module, $shortFormat),
258+
$result
259+
);
260+
}
261+
return $result;
262+
}
263+
264+
/**
265+
* Check whether provided element is a service element of Admin Xml configuration
266+
*
267+
* @param Varien_Simplexml_Element $resource
268+
* @return bool
269+
*/
270+
protected function _isServiceElement(Varien_Simplexml_Element $resource)
271+
{
272+
return in_array($resource->getName(), array('title', 'sort_order', 'children', 'disabled'));
273+
}
274+
275+
/**
276+
* Build acl resource name with path to parent
277+
*
278+
* @param Varien_Simplexml_Element $resource
279+
* @param string $path
280+
* @return string
281+
*/
282+
protected function _buildFullResourceName(Varien_Simplexml_Element $resource, $path = null)
283+
{
284+
return (is_null($path) ? '' : $path . '/') . $resource->getName();
285+
}
286+
112287
/**
113288
* Get acl assert config
114289
*
@@ -172,6 +347,6 @@ public function getMenuItemLabel($path)
172347
if ($menuNode->getAttribute('module')) {
173348
$moduleName = (string)$menuNode->getAttribute('module');
174349
}
175-
return Mage::helper($moduleName)->__((string)$menuNode->title);
350+
return $this->_getHelper($moduleName)->__((string)$menuNode->title);
176351
}
177352
}

app/code/core/Mage/Admin/Model/Role.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)