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: /**
29: * Block for rendering role info tab
30: *
31: * @category Mage
32: * @package Mage_Api2
33: * @author Magento Core Team <core@magentocommerce.com>
34: * @method Mage_Api2_Model_Acl_Global_Role getRole()
35: * @method Mage_Api2_Block_Adminhtml_Roles_Tab_Info setRole(Mage_Api2_Model_Acl_Global_Role $role)
36: */
37: class Mage_Api2_Block_Adminhtml_Roles_Tab_Info extends Mage_Adminhtml_Block_Widget_Form
38: implements Mage_Adminhtml_Block_Widget_Tab_Interface
39: {
40: /**
41: * Prepare form object
42: */
43: protected function _prepareForm()
44: {
45: $form = new Varien_Data_Form();
46:
47: $fieldset = $form->addFieldset('base_fieldset', array(
48: 'legend' => Mage::helper('adminhtml')->__('Role Information')
49: ));
50:
51: $data = array(
52: 'name' => 'role_name',
53: 'label' => Mage::helper('adminhtml')->__('Role Name'),
54: 'id' => 'role_name',
55: 'class' => 'required-entry',
56: 'required' => true,
57: );
58:
59: if ($this->isHidden()) {
60: /** @var $helper Mage_Core_Helper_Data */
61: $helper = Mage::helper('core');
62:
63: $data['note'] = Mage::helper('api2')->__(
64: '%s role is protected.',
65: $helper->escapeHtml($this->getRole()->getRoleName())
66: );
67: $data['readonly'] = 'readonly';
68: }
69: $fieldset->addField('role_name', 'text', $data);
70:
71: $fieldset->addField('entity_id', 'hidden',
72: array(
73: 'name' => 'id',
74: )
75: );
76:
77: $fieldset->addField('in_role_users', 'hidden',
78: array(
79: 'name' => 'in_role_users',
80: 'id' => 'in_role_userz',
81: )
82: );
83:
84: $fieldset->addField('in_role_users_old', 'hidden', array('name' => 'in_role_users_old'));
85:
86: if ($this->getRole()) {
87: $form->setValues($this->getRole()->getData());
88: }
89: $this->setForm($form);
90: }
91:
92: /**
93: * Get tab label
94: *
95: * @return string
96: */
97: public function getTabLabel()
98: {
99: return Mage::helper('api2')->__('Role Info');
100: }
101:
102: /**
103: * Get tab title
104: *
105: * @return string
106: */
107: public function getTabTitle()
108: {
109: return $this->getTabLabel();
110: }
111:
112: /**
113: * Whether tab is available
114: *
115: * @return bool
116: */
117: public function canShowTab()
118: {
119: return true;
120: }
121:
122: /**
123: * Whether tab is hidden
124: *
125: * @return bool
126: */
127: public function isHidden()
128: {
129: return $this->getRole() && Mage_Api2_Model_Acl_Global_Role::isSystemRole($this->getRole());
130: }
131: }
132: