Mage_Api_Model_User Class Reference

Inheritance diagram for Mage_Api_Model_User:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 save ()
 delete ()
 saveRelations ()
 getRoles ()
 deleteFromRole ()
 roleUserExists ()
 add ()
 userExists ()
 getCollection ()
 getName ($separator=' ')
 getId ()
 getAclRole ()
 authenticate ($username, $apiKey)
 login ($username, $apiKey)
 reload ()
 loadByUsername ($username)
 loadBySessId ($sessId)
 logoutBySessId ($sessid)
 hasAssigned2Role ($user)

Protected Member Functions

 _construct ()
 _getEncodedApiKey ($apiKey)


Detailed Description

Definition at line 27 of file User.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 29 of file User.php.

00030     {
00031         $this->_init('api/user');
00032     }

_getEncodedApiKey ( apiKey  )  [protected]

Definition at line 210 of file User.php.

00211     {
00212         return Mage::helper('core')->getHash($apiKey, 2);
00213     }

add (  ) 

Definition at line 99 of file User.php.

00100     {
00101         $this->_getResource()->add($this);
00102         return $this;
00103     }

authenticate ( username,
apiKey 
)

Authenticate user name and api key and save loaded record

Parameters:
string $username
string $apiKey
Returns:
boolean

Definition at line 142 of file User.php.

00143     {
00144         $this->loadByUsername($username);
00145         if (!$this->getId()) {
00146             return false;
00147         }
00148         $auth = Mage::helper('core')->validateHash($apiKey, $this->getApiKey());
00149         if ($auth) {
00150             return true;
00151         } else {
00152             $this->unsetData();
00153             return false;
00154         }
00155     }

delete (  ) 

Delete object from database

Returns:
Mage_Core_Model_Abstract

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 70 of file User.php.

00071     {
00072         $this->_getResource()->delete($this);
00073         return $this;
00074     }

deleteFromRole (  ) 

Definition at line 87 of file User.php.

00088     {
00089         $this->_getResource()->deleteFromRole($this);
00090         return $this;
00091     }

getAclRole (  ) 

Get user ACL role

Returns:
string

Definition at line 130 of file User.php.

00131     {
00132         return 'U'.$this->getUserId();
00133     }

getCollection (  ) 

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 111 of file User.php.

00111                                     {
00112         return Mage::getResourceModel('admin/user_collection');
00113     }

getId (  ) 

Retrieve model object identifier

Returns:
mixed

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 120 of file User.php.

00121     {
00122         return $this->getUserId();
00123     }

getName ( separator = ' '  ) 

Definition at line 115 of file User.php.

00116     {
00117         return $this->getFirstname().$separator.$this->getLastname();
00118     }

getRoles (  ) 

Definition at line 82 of file User.php.

00083     {
00084         return $this->_getResource()->_getRoles($this);
00085     }

hasAssigned2Role ( user  ) 

Definition at line 205 of file User.php.

00206     {
00207         return $this->getResource()->hasAssigned2Role($user);
00208     }

loadBySessId ( sessId  ) 

Definition at line 193 of file User.php.

00194     {
00195         $this->setData($this->getResource()->loadBySessId($sessId));
00196         return $this;
00197     }

loadByUsername ( username  ) 

Definition at line 187 of file User.php.

00188     {
00189         $this->setData($this->getResource()->loadByUsername($username));
00190         return $this;
00191     }

login ( username,
apiKey 
)

Login user

Parameters:
string $login
string $apiKey
Returns:
Mage_Api_Model_User

Definition at line 164 of file User.php.

00165     {
00166         $sessId = $this->getSessid();
00167         if ($this->authenticate($username, $apiKey)) {
00168             $this->setSessid($sessId);
00169             $this->getResource()->cleanOldSessions($this)
00170                 ->recordLogin($this)
00171                 ->recordSession($this);
00172             Mage::dispatchEvent('api_user_authenticated', array(
00173                'model'    => $this,
00174                'api_key'  => $apiKey,
00175             ));
00176         }
00177 
00178         return $this;
00179     }

logoutBySessId ( sessid  ) 

Definition at line 199 of file User.php.

00200     {
00201         $this->getResource()->clearBySessId($sessid);
00202         return $this;
00203     }

reload (  ) 

Definition at line 181 of file User.php.

00182     {
00183         $this->load($this->getId());
00184         return $this;
00185     }

roleUserExists (  ) 

Definition at line 93 of file User.php.

00094     {
00095         $result = $this->_getResource()->roleUserExists($this);
00096         return ( is_array($result) && count($result) > 0 ) ? true : false;
00097     }

save (  ) 

Save object data

Returns:
Mage_Core_Model_Abstract

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 34 of file User.php.

00035     {
00036         $this->_beforeSave();
00037         $data = array(
00038                 'firstname' => $this->getFirstname(),
00039                 'lastname'  => $this->getLastname(),
00040                 'email'     => $this->getEmail(),
00041                 'modified'  => Mage::getSingleton('core/date')->gmtDate()
00042             );
00043 
00044         if($this->getId() > 0) {
00045             $data['user_id']   = $this->getId();
00046         }
00047 
00048         if( $this->getUsername() ) {
00049             $data['username']   = $this->getUsername();
00050         }
00051 
00052         if ($this->getApiKey()) {
00053             $data['api_key']   = $this->_getEncodedApiKey($this->getApiKey());
00054         }
00055 
00056         if ($this->getNewApiKey()) {
00057             $data['api_key']   = $this->_getEncodedApiKey($this->getNewApiKey());
00058         }
00059 
00060         if ( !is_null($this->getIsActive()) ) {
00061             $data['is_active']  = intval($this->getIsActive());
00062         }
00063 
00064         $this->setData($data);
00065         $this->_getResource()->save($this);
00066         $this->_afterSave();
00067         return $this;
00068     }

saveRelations (  ) 

Definition at line 76 of file User.php.

00077     {
00078         $this->_getResource()->_saveRelations($this);
00079         return $this;
00080     }

userExists (  ) 

Definition at line 105 of file User.php.

00106     {
00107         $result = $this->_getResource()->userExists($this);
00108         return ( is_array($result) && count($result) > 0 ) ? true : false;
00109     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:33 2009 for Magento by  doxygen 1.5.8