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:  * Enter description here ...
 29:  *
 30:  * @method Mage_Api_Model_Resource_User _getResource()
 31:  * @method Mage_Api_Model_Resource_User getResource()
 32:  * @method string getFirstname()
 33:  * @method Mage_Api_Model_User setFirstname(string $value)
 34:  * @method string getLastname()
 35:  * @method Mage_Api_Model_User setLastname(string $value)
 36:  * @method string getEmail()
 37:  * @method Mage_Api_Model_User setEmail(string $value)
 38:  * @method string getUsername()
 39:  * @method Mage_Api_Model_User setUsername(string $value)
 40:  * @method string getApiKey()
 41:  * @method Mage_Api_Model_User setApiKey(string $value)
 42:  * @method string getCreated()
 43:  * @method Mage_Api_Model_User setCreated(string $value)
 44:  * @method string getModified()
 45:  * @method Mage_Api_Model_User setModified(string $value)
 46:  * @method int getLognum()
 47:  * @method Mage_Api_Model_User setLognum(int $value)
 48:  * @method int getReloadAclFlag()
 49:  * @method Mage_Api_Model_User setReloadAclFlag(int $value)
 50:  * @method int getIsActive()
 51:  * @method Mage_Api_Model_User setIsActive(int $value)
 52:  *
 53:  * @category    Mage
 54:  * @package     Mage_Api
 55:  * @author      Magento Core Team <core@magentocommerce.com>
 56:  */
 57: class Mage_Api_Model_User extends Mage_Core_Model_Abstract
 58: {
 59:     /**
 60:      * Prefix of model events names
 61:      *
 62:      * @var string
 63:      */
 64:     protected $_eventPrefix = 'api_user';
 65: 
 66:     protected function _construct()
 67:     {
 68:         $this->_init('api/user');
 69:     }
 70: 
 71:     public function save()
 72:     {
 73:         $this->_beforeSave();
 74:         $data = array(
 75:                 'firstname' => $this->getFirstname(),
 76:                 'lastname'  => $this->getLastname(),
 77:                 'email'     => $this->getEmail(),
 78:                 'modified'  => Mage::getSingleton('core/date')->gmtDate()
 79:             );
 80: 
 81:         if($this->getId() > 0) {
 82:             $data['user_id']   = $this->getId();
 83:         }
 84: 
 85:         if( $this->getUsername() ) {
 86:             $data['username']   = $this->getUsername();
 87:         }
 88: 
 89:         if ($this->getApiKey()) {
 90:             $data['api_key']   = $this->_getEncodedApiKey($this->getApiKey());
 91:         }
 92: 
 93:         if ($this->getNewApiKey()) {
 94:             $data['api_key']   = $this->_getEncodedApiKey($this->getNewApiKey());
 95:         }
 96: 
 97:         if ( !is_null($this->getIsActive()) ) {
 98:             $data['is_active']  = intval($this->getIsActive());
 99:         }
100: 
101:         $this->setData($data);
102:         $this->_getResource()->save($this);
103:         $this->_afterSave();
104:         return $this;
105:     }
106: 
107:     public function delete()
108:     {
109:         $this->_beforeDelete();
110:         $this->_getResource()->delete($this);
111:         $this->_afterDelete();
112:         return $this;
113:     }
114: 
115:     public function saveRelations()
116:     {
117:         $this->_getResource()->_saveRelations($this);
118:         return $this;
119:     }
120: 
121:     public function getRoles()
122:     {
123:         return $this->_getResource()->_getRoles($this);
124:     }
125: 
126:     public function deleteFromRole()
127:     {
128:         $this->_getResource()->deleteFromRole($this);
129:         return $this;
130:     }
131: 
132:     public function roleUserExists()
133:     {
134:         $result = $this->_getResource()->roleUserExists($this);
135:         return ( is_array($result) && count($result) > 0 ) ? true : false;
136:     }
137: 
138:     public function add()
139:     {
140:         $this->_getResource()->add($this);
141:         return $this;
142:     }
143: 
144:     public function userExists()
145:     {
146:         $result = $this->_getResource()->userExists($this);
147:         return ( is_array($result) && count($result) > 0 ) ? true : false;
148:     }
149: 
150:     public function getCollection() {
151:         return Mage::getResourceModel('api/user_collection');
152:     }
153: 
154:     public function getName($separator=' ')
155:     {
156:         return $this->getFirstname().$separator.$this->getLastname();
157:     }
158: 
159:     public function getId()
160:     {
161:         return $this->getUserId();
162:     }
163: 
164:     /**
165:      * Get user ACL role
166:      *
167:      * @return string
168:      */
169:     public function getAclRole()
170:     {
171:         return 'U'.$this->getUserId();
172:     }
173: 
174:     /**
175:      * Authenticate user name and api key and save loaded record
176:      *
177:      * @param string $username
178:      * @param string $apiKey
179:      * @return boolean
180:      */
181:     public function authenticate($username, $apiKey)
182:     {
183:         $this->loadByUsername($username);
184:         if (!$this->getId()) {
185:             return false;
186:         }
187:         $auth = Mage::helper('core')->validateHash($apiKey, $this->getApiKey());
188:         if ($auth) {
189:             return true;
190:         } else {
191:             $this->unsetData();
192:             return false;
193:         }
194:     }
195: 
196:     /**
197:      * Login user
198:      *
199:      * @param   string $login
200:      * @param   string $apiKey
201:      * @return  Mage_Api_Model_User
202:      */
203:     public function login($username, $apiKey)
204:     {
205:         $sessId = $this->getSessid();
206:         if ($this->authenticate($username, $apiKey)) {
207:             $this->setSessid($sessId);
208:             $this->getResource()->cleanOldSessions($this)
209:                 ->recordLogin($this)
210:                 ->recordSession($this);
211:             Mage::dispatchEvent('api_user_authenticated', array(
212:                'model'    => $this,
213:                'api_key'  => $apiKey,
214:             ));
215:         }
216: 
217:         return $this;
218:     }
219: 
220:     public function reload()
221:     {
222:         $this->load($this->getId());
223:         return $this;
224:     }
225: 
226:     public function loadByUsername($username)
227:     {
228:         $this->setData($this->getResource()->loadByUsername($username));
229:         return $this;
230:     }
231: 
232:     public function loadBySessId ($sessId)
233:     {
234:         $this->setData($this->getResource()->loadBySessId($sessId));
235:         return $this;
236:     }
237: 
238:     public function logoutBySessId($sessid)
239:     {
240:         $this->getResource()->clearBySessId($sessid);
241:         return $this;
242:     }
243: 
244:     public function hasAssigned2Role($user)
245:     {
246:         return $this->getResource()->hasAssigned2Role($user);
247:     }
248: 
249:     protected function _getEncodedApiKey($apiKey)
250:     {
251:         return Mage::helper('core')->getHash($apiKey, 2);
252:     }
253: 
254: }
255: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0