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) |
Definition at line 27 of file User.php.
_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
string | $username | |
string | $apiKey |
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
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 | ( | ) |
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
Reimplemented from Mage_Core_Model_Abstract.
Definition at line 120 of file User.php.
getName | ( | $ | separator = ' ' |
) |
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
string | $login | |
string | $apiKey |
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 | ( | ) |
roleUserExists | ( | ) |
save | ( | ) |
Save object data
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 | ( | ) |