From ed600b0d55dd7c38e4416cf4bd6df43a71244b81 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 16 Jul 2006 06:27:25 +0000 Subject: Rename APP_CODE directory name again. --- demos/time-tracker/protected/app/BaseDao.php | 45 ------ demos/time-tracker/protected/app/DaoManager.php | 126 ----------------- demos/time-tracker/protected/app/Project.php | 35 ----- demos/time-tracker/protected/app/ProjectDao.php | 93 ------------- .../protected/app/TimeTrackerException.php | 33 ----- .../time-tracker/protected/app/TimeTrackerUser.php | 48 ------- .../protected/app/TimeTrackerUserTypeHandler.php | 54 ------- demos/time-tracker/protected/app/UserDao.php | 155 --------------------- demos/time-tracker/protected/app/UserManager.php | 68 --------- demos/time-tracker/protected/app/exceptions.txt | 7 - 10 files changed, 664 deletions(-) delete mode 100644 demos/time-tracker/protected/app/BaseDao.php delete mode 100644 demos/time-tracker/protected/app/DaoManager.php delete mode 100644 demos/time-tracker/protected/app/Project.php delete mode 100644 demos/time-tracker/protected/app/ProjectDao.php delete mode 100644 demos/time-tracker/protected/app/TimeTrackerException.php delete mode 100644 demos/time-tracker/protected/app/TimeTrackerUser.php delete mode 100644 demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php delete mode 100644 demos/time-tracker/protected/app/UserDao.php delete mode 100644 demos/time-tracker/protected/app/UserManager.php delete mode 100644 demos/time-tracker/protected/app/exceptions.txt (limited to 'demos/time-tracker/protected/app') diff --git a/demos/time-tracker/protected/app/BaseDao.php b/demos/time-tracker/protected/app/BaseDao.php deleted file mode 100644 index 63b91def..00000000 --- a/demos/time-tracker/protected/app/BaseDao.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * Base DAO class. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class BaseDao -{ - /** - * @var TSqlMapper sqlmap client. - */ - private $_connection; - - /** - * @param TSqlMapper sqlmap client. - */ - public function setConnection($connection) - { - $this->_connection = $connection; - } - - /** - * @return TSqlMapper sqlmap client. - */ - protected function getConnection() - { - return $this->_connection; - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/DaoManager.php b/demos/time-tracker/protected/app/DaoManager.php deleted file mode 100644 index b8ac55af..00000000 --- a/demos/time-tracker/protected/app/DaoManager.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * DaoManager class. - * - * A Registry for Dao and an implementation of that type. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class DaoManager extends TModule -{ - /** - * @var TSqlMapper sqlmap client - */ - private $_connection; - /** - * @var boolean if the module has been initialized - */ - private $_initialized=false; - /** - * @var array registered list of dao - */ - private $_dao=array(); - /** - * Initializes the module. - * This method is required by IModule and is invoked by application. - * It loads dao information from the module configuration. - * @param TXmlElement module configuration - */ - public function init($config) - { - if($this->_connection === null) - throw new TimeTrackerException('daomanager_connection_required'); - $app = $this->getApplication(); - if(is_string($this->_connection)) - { - if(($conn=$app->getModule($this->_connection)->getClient())===null) - throw new TimeTrackerException('daomanager_undefined_connection',$this->_connection); - if(!($conn instanceof TSqlMapper)) - throw new TimeTrackerException('daomanager_invalid_connection', $this->_connection); - $this->_connection = $conn; - } - $this->includeDaoImplementation($config->getElementsByTagName('dao')); - $this->_initialized = true; - } - - /** - * Register the dao type and implementation class names. - * @param array list of TXmlDocument nodes. - */ - protected function includeDaoImplementation($nodes) - { - foreach($nodes as $node) - { - $id = $node->getAttribute('id'); - $class = $node->getAttribute('class'); - $this->_dao[$id] = array('class' => $class); - } - } - - /** - * @return array list of registered Daos - */ - public function getDaos() - { - return $this->_dao; - } - - /** - * Returns an implementation of a Dao type, implements the Registery - * pattern. Multiple calls returns the same Dao instance. - * @param string Dao type to find. - * @return object instance of the Dao implementation. - */ - public function getDao($class) - { - if(isset($this->_dao[$class])) - { - if(!isset($this->_dao[$class]['instance'])) - { - $dao = Prado::createComponent($this->_dao[$class]['class']); - $dao->setConnection($this->getConnection()); - $this->_dao[$class]['instance'] = $dao; - } - return $this->_dao[$class]['instance']; - } - else - throw TimeTrackerException('daomanager_undefined_dao', $class); - } - - /** - * @return TSqlMapper sqlmap client instance - */ - public function getConnection() - { - return $this->_connection; - } - - /** - * Sets the connection for all Daos registered. - * @param string|TSqlMapper sqlmap client module id or TSqlMapper instance. - */ - public function setConnection($client) - { - if($this->_initialized) - throw new TimeTrackerException('daomanager_unchangeable'); - if(!is_string($client) && !($client instanceof TSqlMapper)) - throw new TConfigurationException('daomanager_invalid_connection',$client); - $this->_connection = $client; - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/Project.php b/demos/time-tracker/protected/app/Project.php deleted file mode 100644 index 660fad04..00000000 --- a/demos/time-tracker/protected/app/Project.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * Time Tracker Project class. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class Project -{ - public $ActualDuration = 0; - public $CreatorUserName = ''; - public $CompletionDate = 0; - public $DateCreated = 0; - public $Description = ''; - public $EstimateDuration = 0; - public $ID = 0; - public $ManagerUserName = ''; - public $Name = ''; -} - - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/ProjectDao.php b/demos/time-tracker/protected/app/ProjectDao.php deleted file mode 100644 index 81902e0c..00000000 --- a/demos/time-tracker/protected/app/ProjectDao.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * Project DAO class. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class ProjectDao extends BaseDao -{ -/* public function createNewProject($project) - { - $sqlmap = $this->getConnection(); - $creator = $sqlmap->queryForObject('GetUserByName', $project->CreatorUserName); - $manager = $sqlmap->queryForObject('GetUserByName', $project->ManagerUserName); - $exists = $sqlmap->queryForObject('GetProjectByName', $project->Name); - if($exists) - { - throw new TimeTrackerException( - 'project_exists', $project->Name); - } - else if(!$creator || !$manager) - { - throw new TimeTrackerException( - 'invalid_creator_and_manager', - $project->Name, $project->CreatorUserName, - $project->ManagerUserName); - } - else - { - $param['project'] = $project; - $param['creator'] = $creator->ID; - $param['manager'] = $manager->ID; - return $sqlmap->insert('CreateNewProject', $param); - } - } - - public function getProjectByID($projectID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('GetProjectByID', $projectID); - } - - public function addUserToProject($project, $user) - { - $sqlmap = $this->getConnection(); - $project = $this->getProjectByID($project->ID); - $user = $sqlmap->queryForObject('GetUserByName', $user->Name); - $list = $sqlmap->queryForList('GetProjectMembers', $project); - $userExists = false; - foreach($list as $k) - { - if($k->ID == $user->ID) - $userExists = true; - } - if(!$project) - { - throw new TimeTrackerException( - 'invalid_project', $project->Name); - } - else if(!$user) - { - throw new TimeTrackerException( - 'invalid_user', $user->Name); - } - else if($userExists) - { - throw new TimeTrackerException( - 'project_member_exists', $projet->Name, $user->Name); - } - else - { - $param['project'] = $project; - $param['user'] = $user; - return $sqlmap->insert('AddUserToProject', $param); - } - } -*/ -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/TimeTrackerException.php b/demos/time-tracker/protected/app/TimeTrackerException.php deleted file mode 100644 index 64b11405..00000000 --- a/demos/time-tracker/protected/app/TimeTrackerException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * Generic time tracker application exception. Exception messages are saved in - * "exceptions.txt" - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class TimeTrackerException extends TException -{ - /** - * @return string path to the error message file - */ - protected function getErrorMessageFile() - { - return dirname(__FILE__).'/exceptions.txt'; - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/TimeTrackerUser.php b/demos/time-tracker/protected/app/TimeTrackerUser.php deleted file mode 100644 index 99ac1209..00000000 --- a/demos/time-tracker/protected/app/TimeTrackerUser.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * Import TUser and TUserManager - */ -Prado::using('System.Security.TUser'); -Prado::using('System.Security.TUserManager'); - -/** - * User class for Time Tracker application. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class TimeTrackerUser extends TUser -{ - private $_emailAddress; - - /** - * @param string user email address - */ - public function setEmailAddress($value) - { - $this->_emailAddress = $value; - } - - /** - * @return string user email address - */ - public function getEmailAddress() - { - return $this->_emailAddress; - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php b/demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php deleted file mode 100644 index 07c46acc..00000000 --- a/demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * SQLMap type handler for TimeTrackerUser. - * The TimeTrackerUser requires an instance of IUserManager in constructor. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class TimeTrackerUserTypeHandler implements ITypeHandlerCallback -{ - /** - * Not implemented. - */ - public function getParameter($object) - { - throw new TimeTrackerException('Not implemented'); - } - - /** - * Not implemented. - */ - public function getResult($string) - { - throw new TimeTrackerException('Not implemented'); - } - - /** - * Creates a new instance of TimeTrackerUser - * @param array result data - * @return TimeTrackerUser new user instance - */ - public function createNewInstance($row=null) - { - $manager = Prado::getApplication()->getModule('users'); - if(is_null($manager)) - $manager = new UserManager(); - return new TimeTrackerUser($manager); - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/UserDao.php b/demos/time-tracker/protected/app/UserDao.php deleted file mode 100644 index 4dc39b2b..00000000 --- a/demos/time-tracker/protected/app/UserDao.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * 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. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class UserDao extends BaseDao -{ - /** - * @param string username - * @return TimeTrackerUser find by user name, null if not found or disabled. - */ - public function getUserByName($username) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('GetUserByName', $username); - } - - /** - * @return array list of all enabled users. - */ - public function getAllUsers() - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetAllUsers'); - } - - /** - * @param TimeTrackerUser new user details. - * @param string new user password. - */ - public function addNewUser($user, $password) - { - $sqlmap = $this->getConnection(); - $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->delete('DeleteUserByName', $username); - } - - /** - * Updates the user profile details, including user roles. - * @param TimeTrackerUser updated user details. - * @param string new user password, null to avoid updating password. - */ - public function updateUser($user,$password=null) - { - $sqlmap = $this->getConnection(); - if($password !== null) - { - $param['user'] = $user; - $param['password'] = md5($password); - $sqlmap->update('UpdateUserDetailsAndPassword', $param); - } - else - { - $sqlmap->update('UpdateUserDetails', $user); - } - $this->updateUserRoles($user); - } - - /** - * @param string username to be validated - * @param string matching password - * @return boolean true if the username and password matches. - */ - public function validateUser($username, $password) - { - $sqlmap = $this->getConnection(); - $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->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(); - $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(); - 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->delete('DeleteUserRoles', $user); - foreach($user->getRoles() as $role) - { - $param['username'] = $user->getName(); - $param['role'] = $role; - $sqlmap->update('AddUserRole', $param); - } - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/UserManager.php b/demos/time-tracker/protected/app/UserManager.php deleted file mode 100644 index 1327dc3c..00000000 --- a/demos/time-tracker/protected/app/UserManager.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $16/07/2006: $ - * @package Demos - */ - -/** - * User manager module class for time tracker application. - * - * @author Wei Zhuo - * @version $Revision: $ $16/07/2006: $ - * @package Demos - * @since 3.1 - */ -class UserManager extends TModule implements IUserManager -{ - /** - * @return string name for a guest user. - */ - public function getGuestName() - { - return 'Guest'; - } - - /** - * Returns a user instance given the user name. - * @param string user name, null if it is a guest. - * @return TUser the user instance, null if the specified username is not in the user database. - */ - public function getUser($username=null) - { - if($username===null) - { - $user=new TUser($this); - $user->setIsGuest(true); - return $user; - } - else - { - $daos = $this->getApplication()->getModule('daos'); - $userDao = $daos->getDao('UserDao'); - $user = $userDao->getUserByName($username); - $user->setIsGuest(false); - return $user; - } - } - - /** - * Validates if the username and password are correct. - * @param string user name - * @param string password - * @return boolean true if validation is successful, false otherwise. - */ - public function validateUser($username,$password) - { - $daos = $this->getApplication()->getModule('daos'); - $userDao = $daos->getDao('UserDao'); - return $userDao->validateUser($username, $password); - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/app/exceptions.txt b/demos/time-tracker/protected/app/exceptions.txt deleted file mode 100644 index 6568cc72..00000000 --- a/demos/time-tracker/protected/app/exceptions.txt +++ /dev/null @@ -1,7 +0,0 @@ -timetracker_user_readonly_id = Time tracker user ID is read-only. -invalid_creator_and_manager = Unable to find time tracker usernames '{1}' and '{2}' for project '{0}'. -project_exists = Project '{0}' already exists. -daomanager_connection_required = An TSqlMapper connection is required by Dao Manager. -daomanager_undefined_connection = Connection '{0}' for Dao Manager is undefined. -daomanager_invalid_connection = Connection '{0}' does not appear to ba a TSqlMapper in Dao Manager. -daomanager_undefined_dao = Dao class '{0}' is not registered. \ No newline at end of file -- cgit v1.2.3