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_Admin_Helper_Data
  • Mage_Admin_Model_Acl
  • Mage_Admin_Model_Acl_Assert_Ip
  • Mage_Admin_Model_Acl_Assert_Time
  • Mage_Admin_Model_Acl_Resource
  • Mage_Admin_Model_Acl_Role
  • Mage_Admin_Model_Acl_Role_Generic
  • Mage_Admin_Model_Acl_Role_Group
  • Mage_Admin_Model_Acl_Role_Registry
  • Mage_Admin_Model_Acl_Role_User
  • Mage_Admin_Model_Config
  • Mage_Admin_Model_Mysql4_Acl
  • Mage_Admin_Model_Mysql4_Acl_Role
  • Mage_Admin_Model_Mysql4_Acl_Role_Collection
  • Mage_Admin_Model_Mysql4_Permissions_Collection
  • Mage_Admin_Model_Mysql4_Role
  • Mage_Admin_Model_Mysql4_Role_Collection
  • Mage_Admin_Model_Mysql4_Roles
  • Mage_Admin_Model_Mysql4_Roles_Collection
  • Mage_Admin_Model_Mysql4_Roles_User_Collection
  • Mage_Admin_Model_Mysql4_Rules
  • Mage_Admin_Model_Mysql4_Rules_Collection
  • Mage_Admin_Model_Mysql4_User
  • Mage_Admin_Model_Mysql4_User_Collection
  • Mage_Admin_Model_Observer
  • Mage_Admin_Model_Resource_Acl
  • Mage_Admin_Model_Resource_Acl_Role_Collection
  • Mage_Admin_Model_Resource_Permissions_Collection
  • Mage_Admin_Model_Resource_Role
  • Mage_Admin_Model_Resource_Role_Collection
  • Mage_Admin_Model_Resource_Roles
  • Mage_Admin_Model_Resource_Roles_Collection
  • Mage_Admin_Model_Resource_Roles_User_Collection
  • Mage_Admin_Model_Resource_Rules
  • Mage_Admin_Model_Resource_Rules_Collection
  • Mage_Admin_Model_Resource_User
  • Mage_Admin_Model_Resource_User_Collection
  • Mage_Admin_Model_Role
  • Mage_Admin_Model_Roles
  • Mage_Admin_Model_Rules
  • Mage_Admin_Model_Session
  • Mage_Admin_Model_User
  • 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_Admin
 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:  * Admin rule resource model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Admin
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Admin_Model_Resource_Rules extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Define main table
 39:      *
 40:      */
 41:     protected function _construct()
 42:     {
 43:         $this->_init('admin/rule', 'rule_id');
 44:     }
 45: 
 46:     /**
 47:      * Save ACL resources
 48:      *
 49:      * @param Mage_Admin_Model_Rules $rule
 50:      */
 51:     public function saveRel(Mage_Admin_Model_Rules $rule)
 52:     {
 53:         try {
 54:             $adapter = $this->_getWriteAdapter();
 55:             $adapter->beginTransaction();
 56:             $roleId = $rule->getRoleId();
 57: 
 58:             $condition = array(
 59:                 'role_id = ?' => (int) $roleId,
 60:             );
 61: 
 62:             $adapter->delete($this->getMainTable(), $condition);
 63: 
 64:             $postedResources = $rule->getResources();
 65:             if ($postedResources) {
 66:                 $row = array(
 67:                     'role_type'   => 'G',
 68:                     'resource_id' => 'all',
 69:                     'privileges'  => '', // not used yet
 70:                     'assert_id'   => 0,
 71:                     'role_id'     => $roleId,
 72:                     'permission'  => 'allow'
 73:                 );
 74: 
 75:                 // If all was selected save it only and nothing else.
 76:                 if ($postedResources === array('all')) {
 77:                     $insertData = $this->_prepareDataForTable(new Varien_Object($row), $this->getMainTable());
 78: 
 79:                     $adapter->insert($this->getMainTable(), $insertData);
 80:                 } else {
 81:                     foreach (Mage::getModel('admin/roles')->getResourcesList2D() as $index => $resName) {
 82:                         $row['permission']  = (in_array($resName, $postedResources) ? 'allow' : 'deny');
 83:                         $row['resource_id'] = trim($resName, '/');
 84: 
 85:                         $insertData = $this->_prepareDataForTable(new Varien_Object($row), $this->getMainTable());
 86:                         $adapter->insert($this->getMainTable(), $insertData);
 87:                     }
 88:                 }
 89:             }
 90: 
 91:             $adapter->commit();
 92:         } catch (Mage_Core_Exception $e) {
 93:             $adapter->rollBack();
 94:             throw $e;
 95:         } catch (Exception $e){
 96:             $adapter->rollBack();
 97:             Mage::logException($e);
 98:         }
 99:     }
100: }
101: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0