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_Api_Controller_Action
  • Mage_Api_Helper_Data
  • Mage_Api_IndexController
  • Mage_Api_Model_Acl
  • Mage_Api_Model_Acl_Assert_Ip
  • Mage_Api_Model_Acl_Assert_Time
  • Mage_Api_Model_Acl_Resource
  • Mage_Api_Model_Acl_Role
  • Mage_Api_Model_Acl_Role_Generic
  • Mage_Api_Model_Acl_Role_Group
  • Mage_Api_Model_Acl_Role_Registry
  • Mage_Api_Model_Acl_Role_User
  • Mage_Api_Model_Config
  • Mage_Api_Model_Mysql4_Acl
  • Mage_Api_Model_Mysql4_Acl_Role
  • Mage_Api_Model_Mysql4_Acl_Role_Collection
  • Mage_Api_Model_Mysql4_Permissions_Collection
  • Mage_Api_Model_Mysql4_Role
  • Mage_Api_Model_Mysql4_Role_Collection
  • Mage_Api_Model_Mysql4_Roles
  • Mage_Api_Model_Mysql4_Roles_Collection
  • Mage_Api_Model_Mysql4_Roles_User_Collection
  • Mage_Api_Model_Mysql4_Rules
  • Mage_Api_Model_Mysql4_Rules_Collection
  • Mage_Api_Model_Mysql4_User
  • Mage_Api_Model_Mysql4_User_Collection
  • Mage_Api_Model_Resource_Abstract
  • Mage_Api_Model_Resource_Acl
  • Mage_Api_Model_Resource_Acl_Role
  • Mage_Api_Model_Resource_Acl_Role_Collection
  • Mage_Api_Model_Resource_Permissions_Collection
  • Mage_Api_Model_Resource_Role
  • Mage_Api_Model_Resource_Role_Collection
  • Mage_Api_Model_Resource_Roles
  • Mage_Api_Model_Resource_Roles_Collection
  • Mage_Api_Model_Resource_Roles_User_Collection
  • Mage_Api_Model_Resource_Rules
  • Mage_Api_Model_Resource_Rules_Collection
  • Mage_Api_Model_Resource_User
  • Mage_Api_Model_Resource_User_Collection
  • Mage_Api_Model_Role
  • Mage_Api_Model_Roles
  • Mage_Api_Model_Rules
  • Mage_Api_Model_Server
  • Mage_Api_Model_Server_Adapter_Soap
  • Mage_Api_Model_Server_Adapter_Xmlrpc
  • Mage_Api_Model_Server_Handler
  • Mage_Api_Model_Server_Handler_Abstract
  • Mage_Api_Model_Server_V2_Adapter_Soap
  • Mage_Api_Model_Server_V2_Handler
  • Mage_Api_Model_Server_WSI_Adapter_Soap
  • Mage_Api_Model_Server_WSI_Handler
  • Mage_Api_Model_Session
  • Mage_Api_Model_User
  • Mage_Api_Model_Wsdl_Config
  • Mage_Api_Model_Wsdl_Config_Base
  • Mage_Api_SoapController
  • Mage_Api_V2_SoapController
  • Mage_Api_XmlrpcController

Interfaces

  • Mage_Api_Model_Server_Adapter_Interface

Exceptions

  • Mage_Api_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_Api
 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:  * ACL roles resource
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Api
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Api_Model_Resource_Roles extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * User table name
 39:      *
 40:      * @var unknown
 41:      */
 42:     protected $_usersTable;
 43: 
 44:     /**
 45:      * Rule table name
 46:      *
 47:      * @var unknown
 48:      */
 49:     protected $_ruleTable;
 50: 
 51:     /**
 52:      * Resource initialization
 53:      *
 54:      */
 55:     protected function _construct()
 56:     {
 57:         $this->_init('api/role', 'role_id');
 58: 
 59:         $this->_usersTable  = $this->getTable('api/user');
 60:         $this->_ruleTable   = $this->getTable('api/rule');
 61:     }
 62: 
 63:     /**
 64:      * Action before save
 65:      *
 66:      * @param Mage_Core_Model_Abstract $role
 67:      * @return Mage_Api_Model_Resource_Roles
 68:      */
 69:     protected function _beforeSave(Mage_Core_Model_Abstract $role)
 70:     {
 71:         if ($role->getId() == '') {
 72:             if ($role->getIdFieldName()) {
 73:                 $role->unsetData($role->getIdFieldName());
 74:             } else {
 75:                 $role->unsetData('id');
 76:             }
 77:         }
 78: 
 79:         if ($role->getPid() > 0) {
 80:             $row = $this->load($role->getPid());
 81:         } else {
 82:             $row = array('tree_level' => 0);
 83:         }
 84:         $role->setTreeLevel($row['tree_level'] + 1);
 85:         $role->setRoleName($role->getName());
 86:         return $this;
 87:     }
 88: 
 89:     /**
 90:      * Action after save
 91:      *
 92:      * @param Mage_Core_Model_Abstract $role
 93:      * @return Mage_Api_Model_Resource_Roles
 94:      */
 95:     protected function _afterSave(Mage_Core_Model_Abstract $role)
 96:     {
 97:         $this->_updateRoleUsersAcl($role);
 98:         Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG);
 99:         return $this;
100:     }
101: 
102:     /**
103:      * Action after delete
104:      *
105:      * @param Mage_Core_Model_Abstract $role
106:      * @return Mage_Api_Model_Resource_Roles
107:      */
108:     protected function _afterDelete(Mage_Core_Model_Abstract $role)
109:     {
110:         $adapter = $this->_getWriteAdapter();
111:         $adapter->delete($this->getMainTable(), array('parent_id=?'=>$role->getId()));
112:         $adapter->delete($this->_ruleTable, array('role_id=?'=>$role->getId()));
113:         return $this;
114:     }
115: 
116:     /**
117:      * Get role users
118:      *
119:      * @param Mage_Api_Model_Roles $role
120:      * @return unknown
121:      */
122:     public function getRoleUsers(Mage_Api_Model_Roles $role)
123:     {
124:         $adapter   = $this->_getReadAdapter();
125:         $select     = $adapter->select()
126:             ->from($this->getMainTable(), array('user_id'))
127:             ->where('parent_id = ?', $role->getId())
128:             ->where('role_type = ?', Mage_Api_Model_Acl::ROLE_TYPE_USER)
129:             ->where('user_id > 0');
130:         return $adapter->fetchCol($select);
131:     }
132: 
133:     /**
134:      * Update role users
135:      *
136:      * @param Mage_Api_Model_Roles $role
137:      * @return boolean
138:      */
139:     private function _updateRoleUsersAcl(Mage_Api_Model_Roles $role)
140:     {
141:         $users  = $this->getRoleUsers($role);
142:         $rowsCount = 0;
143:         if (sizeof($users) > 0) {
144:             $rowsCount = $this->_getWriteAdapter()->update(
145:                 $this->_usersTable,
146:                 array('reload_acl_flag' => 1),
147:                 array('user_id IN(?)' => $users));
148:         }
149:         return ($rowsCount > 0) ? true : false;
150:     }
151: }
152: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0