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:  * Webservice API2 data helper
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Api2
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Api2_Helper_Data extends Mage_Core_Helper_Abstract
 35: {
 36:     /**
 37:      * Request interpret adapters
 38:      */
 39:     const XML_PATH_API2_REQUEST_INTERPRETERS = 'global/api2/request/interpreters';
 40: 
 41:     /**
 42:      * Response render adapters
 43:      */
 44:     const XML_PATH_API2_RESPONSE_RENDERS     = 'global/api2/response/renders';
 45: 
 46:     /**#@+
 47:      * Config paths
 48:      */
 49:     const XML_PATH_AUTH_ADAPTERS = 'global/api2/auth_adapters';
 50:     const XML_PATH_USER_TYPES    = 'global/api2/user_types';
 51:     /**#@- */
 52: 
 53:     /**
 54:      * Compare order to be used in adapters list sort
 55:      *
 56:      * @param int $a
 57:      * @param int $b
 58:      * @return int
 59:      */
 60:     protected static function _compareOrder($a, $b)
 61:     {
 62:         if ($a['order'] == $b['order']) {
 63:             return 0;
 64:         }
 65:         return ($a['order'] < $b['order']) ? -1 : 1;
 66:     }
 67: 
 68:     /**
 69:      * Retrieve Auth adapters info from configuration file as array
 70:      *
 71:      * @param bool $enabledOnly
 72:      * @return array
 73:      */
 74:     public function getAuthAdapters($enabledOnly = false)
 75:     {
 76:         $adapters = Mage::getConfig()->getNode(self::XML_PATH_AUTH_ADAPTERS);
 77: 
 78:         if (!$adapters) {
 79:             return array();
 80:         }
 81:         $adapters = $adapters->asArray();
 82: 
 83:         if ($enabledOnly) {
 84:             foreach ($adapters as $adapter) {
 85:                 if (empty($adapter['enabled'])) {
 86:                     unset($adapters);
 87:                 }
 88:             }
 89:             $adapters = (array) $adapters;
 90:         }
 91:         uasort($adapters, array('Mage_Api2_Helper_Data', '_compareOrder'));
 92: 
 93:         return $adapters;
 94:     }
 95: 
 96:     /**
 97:      * Retrieve enabled user types in form of user type => user model pairs
 98:      *
 99:      * @return array
100:      */
101:     public function getUserTypes()
102:     {
103:         $userModels = array();
104:         $types = Mage::getConfig()->getNode(self::XML_PATH_USER_TYPES);
105: 
106:         if ($types) {
107:             foreach ($types->asArray() as $type => $params) {
108:                 if (!empty($params['allowed'])) {
109:                     $userModels[$type] = $params['model'];
110:                 }
111:             }
112:         }
113:         return $userModels;
114:     }
115: 
116:     /**
117:      * Get interpreter type for Request body according to Content-type HTTP header
118:      *
119:      * @return array
120:      */
121:     public function getRequestInterpreterAdapters()
122:     {
123:         return (array) Mage::app()->getConfig()->getNode(self::XML_PATH_API2_REQUEST_INTERPRETERS);
124:     }
125: 
126:     /**
127:      * Get interpreter type for Request body according to Content-type HTTP header
128:      *
129:      * @return array
130:      */
131:     public function getResponseRenderAdapters()
132:     {
133:         return (array) Mage::app()->getConfig()->getNode(self::XML_PATH_API2_RESPONSE_RENDERS);
134:     }
135: 
136:     /**
137:      * Check API type support
138:      *
139:      * @param string $type
140:      * @return bool
141:      */
142:     public function isApiTypeSupported($type)
143:     {
144:         return in_array($type, Mage_Api2_Model_Server::getApiTypes());
145:     }
146: 
147:     /**
148:      * Get allowed attributes of a rule
149:      *
150:      * @param string $userType
151:      * @param string $resourceId
152:      * @param string $operation One of Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_... constant
153:      * @return array
154:      */
155:     public function getAllowedAttributes($userType, $resourceId, $operation)
156:     {
157:         /** @var $resource Mage_Api2_Model_Resource_Acl_Filter_Attribute */
158:         $resource = Mage::getResourceModel('api2/acl_filter_attribute');
159: 
160:         $attributes = $resource->getAllowedAttributes($userType, $resourceId, $operation);
161: 
162:         return ($attributes === false || $attributes === null ? array() : explode(',', $attributes));
163:     }
164: 
165:     /**
166:      * Check if ALL attributes are allowed
167:      *
168:      * @param string $userType
169:      * @return bool
170:      */
171:     public function isAllAttributesAllowed($userType)
172:     {
173:         /** @var $resource Mage_Api2_Model_Resource_Acl_Filter_Attribute */
174:         $resource = Mage::getResourceModel('api2/acl_filter_attribute');
175: 
176:         return $resource->isAllAttributesAllowed($userType);
177:     }
178: 
179:     /**
180:      * Get operation type for specified operation
181:      *
182:      * @param string $operation One of Mage_Api2_Model_Resource::OPERATION_... constant
183:      * @return string One of Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_... constant
184:      * @throws Exception
185:      */
186:     public function getTypeOfOperation($operation)
187:     {
188:         if (Mage_Api2_Model_Resource::OPERATION_RETRIEVE === $operation) {
189:             return Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ;
190:         } elseif (Mage_Api2_Model_Resource::OPERATION_CREATE === $operation) {
191:             return Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_WRITE;
192:         } elseif (Mage_Api2_Model_Resource::OPERATION_UPDATE === $operation) {
193:             return Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_WRITE;
194:         } else {
195:             throw new Exception('Can not determine operation type');
196:         }
197:     }
198: }
199: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0