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: * API2 attributes grid block
29: *
30: * @category Mage
31: * @package Mage_Api2
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Api2_Block_Adminhtml_Attribute_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: /**
37: * Set grid ID
38: *
39: * @param array $attributes
40: */
41: public function __construct($attributes = array())
42: {
43: parent::__construct($attributes);
44: $this->setId('api2_attributes');
45: }
46:
47: /**
48: * Collection object set up
49: */
50: protected function _prepareCollection()
51: {
52: $collection = new Varien_Data_Collection();
53:
54: foreach (Mage_Api2_Model_Auth_User::getUserTypes() as $type => $label) {
55: $collection->addItem(
56: new Varien_Object(array('user_type_name' => $label, 'user_type_code' => $type))
57: );
58: }
59:
60: $this->setCollection($collection);
61: }
62:
63: /**
64: * Prepare grid columns
65: *
66: * @return Mage_Api2_Block_Adminhtml_Attribute_Grid
67: */
68: protected function _prepareColumns()
69: {
70: $this->addColumn('user_type_name', array(
71: 'header' => $this->__('User Type'),
72: 'index' => 'user_type_name'
73: ));
74:
75: return parent::_prepareColumns();
76: }
77:
78: /**
79: * Disable unnecessary functionality
80: *
81: * @return Mage_Api2_Block_Adminhtml_Attribute_Grid
82: */
83: public function _prepareLayout()
84: {
85: $this->setFilterVisibility(false);
86: $this->setPagerVisibility(false);
87:
88: return $this;
89: }
90:
91: /**
92: * Get row URL
93: *
94: * @param Varien_Object $row
95: * @return string|null
96: */
97: public function getRowUrl($row)
98: {
99: /** @var $session Mage_Admin_Model_Session */
100: $session = Mage::getSingleton('admin/session');
101: if ($session->isAllowed('system/api/attributes/edit')) {
102: return $this->getUrl('*/*/edit', array('type' => $row->getUserTypeCode()));
103: }
104:
105: return null;
106: }
107: }
108: