1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Oauth_Block_Adminhtml_Oauth_Admin_Token_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: 37: 38:
39: public function __construct()
40: {
41: parent::__construct();
42: $this->setId('adminTokenGrid');
43: $this->setUseAjax(true);
44: $this->setSaveParametersInSession(true);
45: $this->setDefaultSort('entity_id')
46: ->setDefaultDir(Varien_Db_Select::SQL_DESC);
47: }
48:
49: 50: 51: 52: 53:
54: protected function _prepareCollection()
55: {
56:
57: $user = Mage::getSingleton('admin/session')->getData('user');
58:
59:
60: $collection = Mage::getModel('oauth/token')->getCollection();
61: $collection->joinConsumerAsApplication()
62: ->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)
63: ->addFilterByAdminId($user->getId());
64: $this->setCollection($collection);
65:
66: parent::_prepareCollection();
67: return $this;
68: }
69:
70: 71: 72: 73: 74:
75: protected function _prepareColumns()
76: {
77: $this->addColumn('entity_id', array(
78: 'header' => Mage::helper('oauth')->__('ID'),
79: 'index' => 'entity_id',
80: 'align' => 'right',
81: 'width' => '50px',
82: ));
83:
84: $this->addColumn('name', array(
85: 'header' => $this->__('Application Name'),
86: 'index' => 'name',
87: 'escape' => true,
88: ));
89:
90:
91: $sourceYesNo = Mage::getSingleton('adminhtml/system_config_source_yesno');
92: $this->addColumn('revoked', array(
93: 'header' => $this->__('Revoked'),
94: 'index' => 'revoked',
95: 'width' => '100px',
96: 'type' => 'options',
97: 'options' => $sourceYesNo->toArray(),
98: 'sortable' => true,
99: ));
100:
101: parent::_prepareColumns();
102: return $this;
103: }
104:
105: 106: 107: 108: 109:
110: protected function _prepareMassaction()
111: {
112: $this->setMassactionIdField('id');
113: $block = $this->getMassactionBlock();
114:
115: $block->setFormFieldName('items');
116: $block->addItem('enable', array(
117: 'label' => Mage::helper('index')->__('Enable'),
118: 'url' => $this->getUrl('*/*/revoke', array('status' => 0)),
119: ));
120: $block->addItem('revoke', array(
121: 'label' => Mage::helper('index')->__('Revoke'),
122: 'url' => $this->getUrl('*/*/revoke', array('status' => 1)),
123: ));
124: $block->addItem('delete', array(
125: 'label' => Mage::helper('index')->__('Delete'),
126: 'url' => $this->getUrl('*/*/delete'),
127: ));
128:
129: return $this;
130: }
131:
132: 133: 134: 135: 136:
137: public function getGridUrl()
138: {
139: return $this->getUrl('*/*/grid', array('_current' => true));
140: }
141: }
142: