1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Api2
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Block for rendering attributes tree list tab
29: *
30: * @category Mage
31: * @package Mage_Api2
32: * @author Magento Core Team <core@magentocommerce.com>
33: * @method Mage_Api2_Model_Acl_Global_Role getRole()
34: * @method Mage_Api2_Block_Adminhtml_Attribute_Tab_Resource setRole(Mage_Api2_Model_Acl_Global_Role $role)
35: */
36: class Mage_Api2_Block_Adminhtml_Attribute_Tab_Resource extends Mage_Adminhtml_Block_Widget_Form
37: implements Mage_Adminhtml_Block_Widget_Tab_Interface
38: {
39: /**
40: * Tree model
41: *
42: * @var Mage_Api2_Model_Acl_Global_Rule_Tree
43: */
44: protected $_treeModel = false;
45:
46: /**
47: * Constructor
48: */
49: public function __construct()
50: {
51: parent::__construct();
52:
53: $this->setId('api2_attribute_section_resources')
54: ->setData('default_dir', Varien_Db_Select::SQL_ASC)
55: ->setData('default_sort', 'sort_order')
56: ->setData('title', $this->__('Attribute Rules Information'))
57: ->setData('use_ajax', true);
58:
59: $this->_treeModel = Mage::getModel(
60: 'api2/acl_global_rule_tree',
61: array('type' => Mage_Api2_Model_Acl_Global_Rule_Tree::TYPE_ATTRIBUTE));
62:
63: /** @var $permissions Mage_Api2_Model_Acl_Filter_Attribute_ResourcePermission */
64: $permissions = Mage::getModel('api2/acl_filter_attribute_resourcePermission');
65: $permissions->setFilterValue($this->getRequest()->getParam('type'));
66: $this->_treeModel->setResourcesPermissions($permissions->getResourcesPermissions())
67: ->setHasEntityOnlyAttributes($permissions->getHasEntityOnlyAttributes());
68: }
69:
70: /**
71: * Get Json Representation of Resource Tree
72: *
73: * @return string
74: */
75: public function getResTreeJson()
76: {
77: /** @var $helper Mage_Core_Helper_Data */
78: $helper = Mage::helper('core');
79: return $helper->jsonEncode($this->_treeModel->getTreeResources());
80: }
81:
82: /**
83: * Check if everything is allowed
84: *
85: * @return boolean
86: */
87: public function getEverythingAllowed()
88: {
89: return $this->_treeModel->getEverythingAllowed();
90: }
91:
92: /**
93: * Check if tree has entity only attributes
94: *
95: * @return bool
96: */
97: public function hasEntityOnlyAttributes()
98: {
99: return $this->_treeModel->getHasEntityOnlyAttributes();
100: }
101:
102: /**
103: * Get tab label
104: *
105: * @return string
106: */
107: public function getTabLabel()
108: {
109: return $this->__('ACL Attribute Rules');
110: }
111:
112: /**
113: * Get tab title
114: *
115: * @return string
116: */
117: public function getTabTitle()
118: {
119: return $this->getTabLabel();
120: }
121:
122: /**
123: * Whether tab is available
124: *
125: * @return bool
126: */
127: public function canShowTab()
128: {
129: return true;
130: }
131:
132: /**
133: * Whether tab is hidden
134: *
135: * @return bool
136: */
137: public function isHidden()
138: {
139: return false;
140: }
141: }
142: