Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Api2_Adminhtml_Api2_AttributeController
  • Mage_Api2_Adminhtml_Api2_RoleController
  • Mage_Api2_Block_Adminhtml_Attribute
  • Mage_Api2_Block_Adminhtml_Attribute_Buttons
  • Mage_Api2_Block_Adminhtml_Attribute_Edit
  • Mage_Api2_Block_Adminhtml_Attribute_Edit_Form
  • Mage_Api2_Block_Adminhtml_Attribute_Grid
  • Mage_Api2_Block_Adminhtml_Attribute_Tab_Resource
  • Mage_Api2_Block_Adminhtml_Attribute_Tabs
  • Mage_Api2_Block_Adminhtml_Permissions_User_Edit_Tab_Roles
  • Mage_Api2_Block_Adminhtml_Roles
  • Mage_Api2_Block_Adminhtml_Roles_Buttons
  • Mage_Api2_Block_Adminhtml_Roles_Grid
  • Mage_Api2_Block_Adminhtml_Roles_Tab_Info
  • Mage_Api2_Block_Adminhtml_Roles_Tab_Resources
  • Mage_Api2_Block_Adminhtml_Roles_Tab_Users
  • Mage_Api2_Block_Adminhtml_Roles_Tabs
  • Mage_Api2_Helper_Data
  • Mage_Api2_Model_Acl
  • Mage_Api2_Model_Acl_Filter
  • Mage_Api2_Model_Acl_Filter_Attribute
  • Mage_Api2_Model_Acl_Filter_Attribute_Operation
  • Mage_Api2_Model_Acl_Filter_Attribute_ResourcePermission
  • Mage_Api2_Model_Acl_Global
  • Mage_Api2_Model_Acl_Global_Role
  • Mage_Api2_Model_Acl_Global_Rule
  • Mage_Api2_Model_Acl_Global_Rule_Permission
  • Mage_Api2_Model_Acl_Global_Rule_Privilege
  • Mage_Api2_Model_Acl_Global_Rule_ResourcePermission
  • Mage_Api2_Model_Acl_Global_Rule_Tree
  • Mage_Api2_Model_Auth
  • Mage_Api2_Model_Auth_Adapter
  • Mage_Api2_Model_Auth_Adapter_Abstract
  • Mage_Api2_Model_Auth_Adapter_Oauth
  • Mage_Api2_Model_Auth_User
  • Mage_Api2_Model_Auth_User_Abstract
  • Mage_Api2_Model_Auth_User_Admin
  • Mage_Api2_Model_Auth_User_Customer
  • Mage_Api2_Model_Auth_User_Guest
  • Mage_Api2_Model_Config
  • Mage_Api2_Model_Dispatcher
  • Mage_Api2_Model_Multicall
  • Mage_Api2_Model_Observer
  • Mage_Api2_Model_Renderer
  • Mage_Api2_Model_Renderer_Json
  • Mage_Api2_Model_Renderer_Query
  • Mage_Api2_Model_Renderer_Xml
  • Mage_Api2_Model_Renderer_Xml_Writer
  • Mage_Api2_Model_Request
  • Mage_Api2_Model_Request_Internal
  • Mage_Api2_Model_Request_Interpreter
  • Mage_Api2_Model_Request_Interpreter_Json
  • Mage_Api2_Model_Request_Interpreter_Query
  • Mage_Api2_Model_Request_Interpreter_Xml
  • Mage_Api2_Model_Resource
  • Mage_Api2_Model_Resource_Acl_Filter_Attribute
  • Mage_Api2_Model_Resource_Acl_Filter_Attribute_Collection
  • Mage_Api2_Model_Resource_Acl_Global_Role
  • Mage_Api2_Model_Resource_Acl_Global_Role_Collection
  • Mage_Api2_Model_Resource_Acl_Global_Rule
  • Mage_Api2_Model_Resource_Acl_Global_Rule_Collection
  • Mage_Api2_Model_Resource_Setup
  • Mage_Api2_Model_Resource_Validator
  • Mage_Api2_Model_Resource_Validator_Eav
  • Mage_Api2_Model_Resource_Validator_Fields
  • Mage_Api2_Model_Response
  • Mage_Api2_Model_Route_Abstract
  • Mage_Api2_Model_Route_ApiType
  • Mage_Api2_Model_Route_Rest
  • Mage_Api2_Model_Router
  • Mage_Api2_Model_Server

Interfaces

  • Mage_Api2_Model_Acl_PermissionInterface
  • Mage_Api2_Model_Renderer_Interface
  • Mage_Api2_Model_Request_Interpreter_Interface
  • Mage_Api2_Model_Route_Interface

Exceptions

  • Mage_Api2_Exception
  • Overview
  • Package
  • Class
  • Tree
  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 users 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_Roles_Tab_Users setRole(Mage_Api2_Model_Acl_Global_Role $role)
 35:  * @method Mage_Api2_Block_Adminhtml_Roles_Tab_Users setUsers(array $users)
 36:  * @method Mage_Admin_Model_Resource_User_Collection getCollection()
 37:  */
 38: class Mage_Api2_Block_Adminhtml_Roles_Tab_Users extends Mage_Adminhtml_Block_Widget_Grid
 39:     implements Mage_Adminhtml_Block_Widget_Tab_Interface
 40: {
 41:     /**
 42:      * Construct grid block
 43:      */
 44:     public function __construct()
 45:     {
 46:         parent::__construct();
 47:         $this->setId('roleUsersGrid');
 48:         $this->setData('use_ajax', true);
 49:         $this->setSaveParametersInSession(true);
 50:         $this->setDefaultSort('user_id')
 51:             ->setDefaultDir(Varien_Db_Select::SQL_DESC);
 52:         $this->setDefaultFilter(array('filter_in_role_users'=>1));
 53:     }
 54: 
 55:     /**
 56:      * Prepare collection
 57:      *
 58:      * @return Mage_Api2_Block_Adminhtml_Roles_Tab_Users
 59:      */
 60:     protected function _prepareCollection()
 61:     {
 62:         /** @var $collection Mage_Admin_Model_Resource_User_Collection */
 63:         $collection = Mage::getModel('admin/user')->getCollection();
 64:         $collection->getSelect()->joinLeft(
 65:             array('acl' => $collection->getTable('api2/acl_user')),
 66:             'acl.admin_id = main_table.user_id',
 67:             'role_id'
 68:         );
 69:         if ($this->getRole() && $this->getRole()->getId()) {
 70:             $collection->addFilter('acl.role_id', $this->getRole()->getId());
 71:         }
 72: 
 73:         $this->setCollection($collection);
 74:         parent::_prepareCollection();
 75:         return $this;
 76:     }
 77: 
 78:     /**
 79:      * Prepare columns
 80:      *
 81:      * @return Mage_Api2_Block_Adminhtml_Roles_Tab_Users
 82:      */
 83:     protected function _prepareColumns()
 84:     {
 85:         $this->addColumn('filter_in_role_users', array(
 86:             'header_css_class' => 'a-center',
 87:             'type'      => 'checkbox',
 88:             'name'      => 'filter_in_role_users',
 89:             'values'    => $this->getUsers(),
 90:             'align'     => 'center',
 91:             'index'     => 'user_id'
 92:         ));
 93: 
 94:         $this->addColumn('user_id', array(
 95:             'header' => Mage::helper('api2')->__('ID'), 'index' => 'user_id', 'align' => 'right', 'width' => '50px',
 96:         ));
 97: 
 98:         $this->addColumn('username', array(
 99:             'header' => Mage::helper('adminhtml')->__('User Name'), 'align' => 'left', 'index' => 'username'
100:         ));
101: 
102:         $this->addColumn('firstname', array(
103:             'header' => Mage::helper('adminhtml')->__('First Name'), 'align' => 'left', 'index' => 'firstname'
104:         ));
105: 
106:         $this->addColumn('lastname', array(
107:             'header' => Mage::helper('adminhtml')->__('Last Name'), 'align' => 'left', 'index' => 'lastname'
108:         ));
109: 
110:         return parent::_prepareColumns();
111:     }
112: 
113:     /**
114:      * Get grid URL
115:      *
116:      * @return string
117:      */
118:     public function getGridUrl()
119:     {
120:         return $this->getUrl('*/*/usersGrid', array('_current' => true));
121:     }
122: 
123:     /**
124:      * Get row URL
125:      *
126:      * @param Mage_Api2_Model_Acl_Global_Role $row
127:      * @return string|null
128:      */
129:     public function getRowUrl($row)
130:     {
131:         return null;
132:     }
133: 
134:     /**
135:      * Get tab label
136:      *
137:      * @return string
138:      */
139:     public function getTabLabel()
140:     {
141:         return Mage::helper('api2')->__('Role Users');
142:     }
143: 
144:     /**
145:      * Get tab title
146:      *
147:      * @return string
148:      */
149:     public function getTabTitle()
150:     {
151:         return $this->getTabLabel();
152:     }
153: 
154:     /**
155:      * Whether tab is available
156:      *
157:      * @return bool
158:      */
159:     public function canShowTab()
160:     {
161:         return !$this->isHidden();
162:     }
163: 
164:     /**
165:      * Whether tab is hidden
166:      *
167:      * @return bool
168:      */
169:     public function isHidden()
170:     {
171:         return $this->getRole() && Mage_Api2_Model_Acl_Global_Role::isSystemRole($this->getRole());
172:     }
173: 
174:     /**
175:      * Render block only when not hidden
176:      *
177:      * @return string
178:      */
179:     public function _toHtml()
180:     {
181:         if (!$this->isHidden()) {
182:             return parent::_toHtml();
183:         }
184:         return '';
185:     }
186: 
187:     /**
188:      * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
189:      * @return Mage_Api2_Block_Adminhtml_Roles_Tab_Users
190:      */
191:     protected function _addColumnFilterToCollection($column)
192:     {
193:         if ($column->getId() == 'filter_in_role_users') {
194:             $inRoleIds = $this->getUsers();
195:             if (empty($inRoleIds)) {
196:                 $inRoleIds = 0;
197:             }
198: 
199:             if ($column->getFilter()->getValue()) {
200:                 $this->getCollection()->addFieldToFilter('user_id', array('in' => $inRoleIds));
201:             } else {
202:                 if($inRoleIds) {
203:                     $this->getCollection()->addFieldToFilter('user_id', array('nin' => $inRoleIds));
204:                 }
205:             }
206:         } else {
207:             parent::_addColumnFilterToCollection($column);
208:         }
209:         return $this;
210:     }
211: 
212:     /**
213:      * Get users
214:      *
215:      * @param bool $json
216:      * @return array|string
217:      */
218:     public function getUsers($json = false)
219:     {
220:         $users = $this->getData('users');
221: 
222:         if ($json) {
223:             if ($users === array()) {
224:                 return '{}';
225:             }
226:             $jsonUsers = array();
227:             foreach($users as $usrId) {
228:                 $jsonUsers[$usrId] = 0;
229:             }
230:             /** @var $helper Mage_Core_Helper_Data */
231:             $helper = Mage::helper('core');
232:             $result = $helper->jsonEncode((object) $jsonUsers);
233:         } else {
234:             $result = array_values($users);
235:         }
236: 
237:         return $result;
238:     }
239: }
240: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0