Skip to content

Commit 7fec10a

Browse files
committed
Update as of 8/1/2012
* Refactored ACL for the backend * ACL resources * Strict configuration format, validated by XSD schema * ACL configuration relocation from `app/code/<pool>/<namespace>/<module>/etc/adminhtml.xml` to `app/code/<pool>/<namespace>/<module>/etc/adminhtml/acl.xml` * Renamed ACL resource identifiers according to the format `<namespace>_<module>::<resource>` throughout the system * Backend menu configuration requires to specify ACL resource identifier in the new format * Explicit declaration of ACL resources in `app/code/<pool>/<namespace>/<module>/etc/system.xml` instead of implicit relation by XPath * Migration tool `dev/tools/migration/acl.php` to convert ACL configuration from 1.x to 2.x * Declaration of ACL resource/role/rule loaders through the area configuration * Module `Mage_Backend` declares loader for ACL resources in backend area * Module `Mage_User` declares loaders for ACL roles and rules (relations between roles and resources) in backend area * Implemented integrity and legacy tests for ACL * Fixed issues: * Losing qty and visibility information when importing products * Impossibility to reload captcha on backend * Temporary excluded from execution integration test `Mage_Review_Model_Resource_Review_Product_CollectionTest::testGetResultingIds()` and corresponding fixture script, which cause occasional `segmentation fault` (exit code 139) * Refactored methods with high cyclomatic complexity: * `Mage_Adminhtml_Block_System_Store_Edit_Form::_prepareForm()` * `Mage_Adminhtml_Block_System_Config_Form::initForm()` * `Mage_Adminhtml_Block_System_Config_Form::initFields()` * GitHub requests: * [#32](#32) -- fixed declaration of localization CSV files * [#35](#35) -- removed non-used `Mage_Core_Block_Flush` block * [#41](#41) -- implemented ability to extends `app/etc/local.xml` by specifying additional config file via `MAGE_LOCAL_CONFIG` environment variable
1 parent a27835b commit 7fec10a

File tree

428 files changed

+9597
-4140
lines changed

Some content is hidden

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

428 files changed

+9597
-4140
lines changed

CHANGELOG.markdown

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
Update as of 8/1/2012
2+
=====================
3+
* Refactored ACL for the backend
4+
* ACL resources
5+
* Strict configuration format, validated by XSD schema
6+
* ACL configuration relocation from `app/code/<pool>/<namespace>/<module>/etc/adminhtml.xml` to `app/code/<pool>/<namespace>/<module>/etc/adminhtml/acl.xml`
7+
* Renamed ACL resource identifiers according to the format `<namespace>_<module>::<resource>` throughout the system
8+
* Backend menu configuration requires to specify ACL resource identifier in the new format
9+
* Explicit declaration of ACL resources in `app/code/<pool>/<namespace>/<module>/etc/system.xml` instead of implicit relation by XPath
10+
* Migration tool `dev/tools/migration/acl.php` to convert ACL configuration from 1.x to 2.x
11+
* Declaration of ACL resource/role/rule loaders through the area configuration
12+
* Module `Mage_Backend` declares loader for ACL resources in backend area
13+
* Module `Mage_User` declares loaders for ACL roles and rules (relations between roles and resources) in backend area
14+
* Implemented integrity and legacy tests for ACL
15+
* Fixed issues:
16+
* Losing qty and visibility information when importing products
17+
* Impossibility to reload captcha on backend
18+
* Temporary excluded from execution integration test `Mage_Review_Model_Resource_Review_Product_CollectionTest::testGetResultingIds()` and corresponding fixture script, which cause occasional `segmentation fault` (exit code 139)
19+
* Refactored methods with high cyclomatic complexity:
20+
* `Mage_Adminhtml_Block_System_Store_Edit_Form::_prepareForm()`
21+
* `Mage_Adminhtml_Block_System_Config_Form::initForm()`
22+
* `Mage_Adminhtml_Block_System_Config_Form::initFields()`
23+
* GitHub requests:
24+
* [#32](https://github.com/magento/magento2/pull/32) -- fixed declaration of localization CSV files
25+
* [#35](https://github.com/magento/magento2/issues/35) -- removed non-used `Mage_Core_Block_Flush` block
26+
* [#41](https://github.com/magento/magento2/pull/41) -- implemented ability to extends `app/etc/local.xml` by specifying additional config file via `MAGE_LOCAL_CONFIG` environment variable
27+
128
Update as of 7/26/2012
229
=====================
330
* Implemented Magento Validator library in order to have clear solid mechanism and formal rules of input data validation

app/code/community/Phoenix/Moneybookers/etc/adminhtml.xml renamed to app/code/community/Phoenix/Moneybookers/etc/adminhtml/acl.xml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,13 @@
2828
<config>
2929
<acl>
3030
<resources>
31-
<admin>
32-
<children>
33-
<system>
34-
<children>
35-
<config>
36-
<children>
37-
<moneybookers translate="title" module="Phoenix_Moneybookers">
38-
<title>Moneybookers Settings</title>
39-
</moneybookers>
40-
</children>
41-
</config>
42-
</children>
43-
</system>
44-
</children>
45-
</admin>
31+
<resource id="Mage_Adminhtml::admin">
32+
<resource id="Mage_Adminhtml::system">
33+
<resource id="Mage_Adminhtml::config">
34+
<resource id="Phoenix_Moneybookers::moneybookers" module="Phoenix_Moneybookers" title="Moneybookers Settings" />
35+
</resource>
36+
</resource>
37+
</resource>
4638
</resources>
4739
</acl>
4840
</config>

app/code/community/Phoenix/Moneybookers/etc/system.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<show_in_default>1</show_in_default>
3636
<show_in_website>1</show_in_website>
3737
<show_in_store>1</show_in_store>
38+
<resource>Phoenix_Moneybookers::moneybookers</resource>
3839
<groups>
3940
<settings translate="label">
4041
<label>Moneybookers Settings</label>

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

Lines changed: 0 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -109,221 +109,6 @@ protected function _getHelper($module)
109109
return Mage::helper($module);
110110
}
111111

112-
/**
113-
* Load Acl resources from config
114-
*
115-
* @param Mage_Admin_Model_Acl $acl
116-
* @param Mage_Core_Model_Config_Element $resource
117-
* @param string $parentName
118-
* @return Mage_Admin_Model_Config
119-
*/
120-
public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource = null, $parentName = null)
121-
{
122-
if (is_null($resource)) {
123-
$resource = $this->getAdminhtmlConfig()->getNode("acl/resources");
124-
$resourceName = null;
125-
} else {
126-
$resourceName = (is_null($parentName) ? '' : $parentName . '/') . $resource->getName();
127-
$acl->add(Mage::getModel('Mage_Admin_Model_Acl_Resource', $resourceName), $parentName);
128-
}
129-
130-
if (isset($resource->all)) {
131-
$acl->add(Mage::getModel('Mage_Admin_Model_Acl_Resource', 'all'), null);
132-
}
133-
134-
if (isset($resource->admin)) {
135-
$children = $resource->admin;
136-
} elseif (isset($resource->children)){
137-
$children = $resource->children->children();
138-
}
139-
140-
141-
142-
if (empty($children)) {
143-
return $this;
144-
}
145-
146-
foreach ($children as $res) {
147-
if (1 == $res->disabled) {
148-
continue;
149-
}
150-
$this->loadAclResources($acl, $res, $resourceName);
151-
}
152-
return $this;
153-
}
154-
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-
287-
/**
288-
* Get acl assert config
289-
*
290-
* @param string $name
291-
* @return Mage_Core_Model_Config_Element|boolean
292-
*/
293-
public function getAclAssert($name = '')
294-
{
295-
$asserts = $this->getNode("admin/acl/asserts");
296-
if ('' === $name) {
297-
return $asserts;
298-
}
299-
300-
if (isset($asserts->$name)) {
301-
return $asserts->$name;
302-
}
303-
304-
return false;
305-
}
306-
307-
/**
308-
* Retrieve privilege set by name
309-
*
310-
* @param string $name
311-
* @return Mage_Core_Model_Config_Element|boolean
312-
*/
313-
public function getAclPrivilegeSet($name = '')
314-
{
315-
$sets = $this->getNode("admin/acl/privilegeSets");
316-
if ('' === $name) {
317-
return $sets;
318-
}
319-
320-
if (isset($sets->$name)) {
321-
return $sets->$name;
322-
}
323-
324-
return false;
325-
}
326-
327112
/**
328113
* Retrieve xml config
329114
*

0 commit comments

Comments
 (0)