diff options
Diffstat (limited to 'demos/time-tracker/protected/App_Code/Dao/UserDao.php')
-rw-r--r-- | demos/time-tracker/protected/App_Code/Dao/UserDao.php | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/demos/time-tracker/protected/App_Code/Dao/UserDao.php b/demos/time-tracker/protected/App_Code/Dao/UserDao.php index 28719d81..4bb23b3a 100644 --- a/demos/time-tracker/protected/App_Code/Dao/UserDao.php +++ b/demos/time-tracker/protected/App_Code/Dao/UserDao.php @@ -11,7 +11,7 @@ */
/**
- * UserDao class list, create, find and delete users.
+ * UserDao class list, create, find and delete users.
* In addition, it can validate username and password, and update
* the user roles. Furthermore, a unique new token can be generated,
* this token can be used to perform persistent cookie login.
@@ -29,49 +29,49 @@ class UserDao extends BaseDao */
public function getUserByName($username)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
return $sqlmap->queryForObject('GetUserByName', $username);
}
-
+
/**
* @param string username
* @return boolean true if username already exists, false otherwise.
*/
public function usernameExists($username)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
return $sqlmap->queryForObject('UsernameExists', $username);
}
-
+
/**
* @return array list of all enabled users.
*/
public function getAllUsers()
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
return $sqlmap->queryForList('GetAllUsers');
}
-
+
/**
* @param TimeTrackerUser new user details.
* @param string new user password.
*/
public function addNewUser($user, $password)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
$param['user'] = $user;
$param['password'] = md5($password);
$sqlmap->insert('AddNewUser', $param);
if(count($user->getRoles()) > 0)
$this->updateUserRoles($user);
}
-
+
/**
* @param string username to delete
*/
public function deleteUserByName($username)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
$sqlmap->delete('DeleteUserByName', $username);
}
@@ -82,7 +82,7 @@ class UserDao extends BaseDao */
public function updateUser($user,$password=null)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
if($password !== null)
{
$param['user'] = $user;
@@ -103,55 +103,55 @@ class UserDao extends BaseDao */
public function validateUser($username, $password)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
$param['username'] = $username;
$param['password'] = md5($password);
return $sqlmap->queryForObject('ValidateUser', $param);
}
-
+
/**
* @param string unique persistent session token
* @return TimeTrackerUser user details if valid token, null otherwise.
*/
public function validateSignon($token)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
$sqlmap->update('UpdateSignon', $token);
return $sqlmap->queryForObject('ValidateAutoSignon', $token);
}
-
+
/**
* @param TimeTrackerUser user details to generate the token
* @return string unique persistent login token.
*/
public function createSignonToken($user)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
$param['username'] = $user->getName();
$param['token'] = md5(microtime().$param['username']);
$sqlmap->insert('RegisterAutoSignon', $param);
return $param['token'];
}
-
+
/**
* @param TimeTrackerUser deletes all signon token for given user, null to delete all
* tokens.
*/
public function clearSignonTokens($user=null)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
if($user !== null)
$sqlmap->delete('DeleteAutoSignon', $user->getName());
else
$sqlmap->delete('DeleteAllSignon');
}
-
+
/**
* @param TimeTrackerUser user details for updating the assigned roles.
*/
public function updateUserRoles($user)
{
- $sqlmap = $this->getConnection();
+ $sqlmap = $this->getSqlMap();
$sqlmap->delete('DeleteUserRoles', $user);
foreach($user->getRoles() as $role)
{
|