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/sqlmap/protected/pages/Manual/config.xml | 11 ++
demos/time-tracker/protected/App_Code/BaseDao.php | 45 ++++++
.../time-tracker/protected/App_Code/DaoManager.php | 126 +++++++++++++++++
demos/time-tracker/protected/App_Code/Project.php | 35 +++++
.../time-tracker/protected/App_Code/ProjectDao.php | 93 +++++++++++++
.../protected/App_Code/TimeTrackerException.php | 33 +++++
.../protected/App_Code/TimeTrackerUser.php | 48 +++++++
.../App_Code/TimeTrackerUserTypeHandler.php | 54 +++++++
demos/time-tracker/protected/App_Code/UserDao.php | 155 +++++++++++++++++++++
.../protected/App_Code/UserManager.php | 68 +++++++++
.../time-tracker/protected/App_Code/exceptions.txt | 7 +
.../protected/App_Data/mysql-reset.sql | 26 ++++
.../protected/App_Data/mysql-sqlmap.xml | 21 +++
demos/time-tracker/protected/App_Data/project.xml | 5 +
.../protected/App_Data/time-tracker-mysql.sql | 135 ++++++++++++++++++
demos/time-tracker/protected/App_Data/users.xml | 131 +++++++++++++++++
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 -
demos/time-tracker/protected/application.xml | 23 +++
27 files changed, 1016 insertions(+), 664 deletions(-)
create mode 100644 demos/sqlmap/protected/pages/Manual/config.xml
create mode 100644 demos/time-tracker/protected/App_Code/BaseDao.php
create mode 100644 demos/time-tracker/protected/App_Code/DaoManager.php
create mode 100644 demos/time-tracker/protected/App_Code/Project.php
create mode 100644 demos/time-tracker/protected/App_Code/ProjectDao.php
create mode 100644 demos/time-tracker/protected/App_Code/TimeTrackerException.php
create mode 100644 demos/time-tracker/protected/App_Code/TimeTrackerUser.php
create mode 100644 demos/time-tracker/protected/App_Code/TimeTrackerUserTypeHandler.php
create mode 100644 demos/time-tracker/protected/App_Code/UserDao.php
create mode 100644 demos/time-tracker/protected/App_Code/UserManager.php
create mode 100644 demos/time-tracker/protected/App_Code/exceptions.txt
create mode 100644 demos/time-tracker/protected/App_Data/mysql-reset.sql
create mode 100644 demos/time-tracker/protected/App_Data/mysql-sqlmap.xml
create mode 100644 demos/time-tracker/protected/App_Data/project.xml
create mode 100644 demos/time-tracker/protected/App_Data/time-tracker-mysql.sql
create mode 100644 demos/time-tracker/protected/App_Data/users.xml
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
create mode 100644 demos/time-tracker/protected/application.xml
(limited to 'demos')
diff --git a/demos/sqlmap/protected/pages/Manual/config.xml b/demos/sqlmap/protected/pages/Manual/config.xml
new file mode 100644
index 00000000..2cc63db4
--- /dev/null
+++ b/demos/sqlmap/protected/pages/Manual/config.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Code/BaseDao.php b/demos/time-tracker/protected/App_Code/BaseDao.php
new file mode 100644
index 00000000..63b91def
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/BaseDao.php
@@ -0,0 +1,45 @@
+
+ * @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_Code/DaoManager.php b/demos/time-tracker/protected/App_Code/DaoManager.php
new file mode 100644
index 00000000..b8ac55af
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/DaoManager.php
@@ -0,0 +1,126 @@
+
+ * @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_Code/Project.php b/demos/time-tracker/protected/App_Code/Project.php
new file mode 100644
index 00000000..660fad04
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/Project.php
@@ -0,0 +1,35 @@
+
+ * @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_Code/ProjectDao.php b/demos/time-tracker/protected/App_Code/ProjectDao.php
new file mode 100644
index 00000000..81902e0c
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/ProjectDao.php
@@ -0,0 +1,93 @@
+
+ * @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_Code/TimeTrackerException.php b/demos/time-tracker/protected/App_Code/TimeTrackerException.php
new file mode 100644
index 00000000..64b11405
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/TimeTrackerException.php
@@ -0,0 +1,33 @@
+
+ * @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_Code/TimeTrackerUser.php b/demos/time-tracker/protected/App_Code/TimeTrackerUser.php
new file mode 100644
index 00000000..99ac1209
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/TimeTrackerUser.php
@@ -0,0 +1,48 @@
+
+ * @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_Code/TimeTrackerUserTypeHandler.php b/demos/time-tracker/protected/App_Code/TimeTrackerUserTypeHandler.php
new file mode 100644
index 00000000..07c46acc
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/TimeTrackerUserTypeHandler.php
@@ -0,0 +1,54 @@
+
+ * @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_Code/UserDao.php b/demos/time-tracker/protected/App_Code/UserDao.php
new file mode 100644
index 00000000..4dc39b2b
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/UserDao.php
@@ -0,0 +1,155 @@
+
+ * @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_Code/UserManager.php b/demos/time-tracker/protected/App_Code/UserManager.php
new file mode 100644
index 00000000..1327dc3c
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/UserManager.php
@@ -0,0 +1,68 @@
+
+ * @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_Code/exceptions.txt b/demos/time-tracker/protected/App_Code/exceptions.txt
new file mode 100644
index 00000000..6568cc72
--- /dev/null
+++ b/demos/time-tracker/protected/App_Code/exceptions.txt
@@ -0,0 +1,7 @@
+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
diff --git a/demos/time-tracker/protected/App_Data/mysql-reset.sql b/demos/time-tracker/protected/App_Data/mysql-reset.sql
new file mode 100644
index 00000000..e9581952
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/mysql-reset.sql
@@ -0,0 +1,26 @@
+TRUNCATE `user_roles`;
+TRUNCATE `role_types`;
+TRUNCATE `project_members`;
+TRUNCATE `time_entry`;
+TRUNCATE `signon`;
+TRUNCATE `categories`;
+TRUNCATE `project`;
+TRUNCATE `users`;
+
+INSERT INTO role_types (RoleType, Description) VALUES
+('admin', 'Project administrator may additionally view the list of all users.'),
+('consultant', 'Consultant may log time entries only.'),
+('manager', 'Project manager may additionally edit all projects and view reports.');
+
+INSERT INTO users (Username, Password, EmailAddress, Disabled) VALUES
+('admin', '21232f297a57a5a743894a0e4a801fc3', 'admin@pradosoft.com', 0),
+('manager', '1d0258c2440a8d19e716292b231e3190', 'manager@pradosoft.com', 0),
+('consultant', '7adfa4f2ba9323e6c1e024de375434b0', 'consultant@pradosoft.com', 0);
+
+INSERT INTO user_roles (UserID, RoleType) VALUES
+('admin', 'admin'),
+('admin', 'manager'),
+('admin', 'consultant'),
+('manager', 'manager'),
+('manager', 'consultant'),
+('consultant', 'consultant');
\ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/mysql-sqlmap.xml b/demos/time-tracker/protected/App_Data/mysql-sqlmap.xml
new file mode 100644
index 00000000..fe4ebedc
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/mysql-sqlmap.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/project.xml b/demos/time-tracker/protected/App_Data/project.xml
new file mode 100644
index 00000000..0592f195
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/project.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/time-tracker-mysql.sql b/demos/time-tracker/protected/App_Data/time-tracker-mysql.sql
new file mode 100644
index 00000000..89de378a
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/time-tracker-mysql.sql
@@ -0,0 +1,135 @@
+DROP TABLE IF EXISTS user_roles;
+CREATE TABLE user_roles (
+ UserID varchar(50) NOT NULL,
+ RoleType varchar(50) NOT NULL,
+ PRIMARY KEY (UserID,RoleType),
+ KEY RoleType (RoleType)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS role_types;
+CREATE TABLE role_types (
+ RoleType varchar(50) NOT NULL,
+ Description varchar(255) NOT NULL,
+ PRIMARY KEY (RoleType)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS project_members;
+CREATE TABLE project_members (
+ UserID varchar(50) NOT NULL,
+ ProjectID int(11) NOT NULL,
+ PRIMARY KEY (UserID,ProjectID),
+ KEY ProjectID (ProjectID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS time_entry;
+CREATE TABLE time_entry (
+ EntryID int(11) NOT NULL auto_increment,
+ EntryCreated datetime NOT NULL,
+ Duration float(10,2) NOT NULL default '0.00',
+ Description varchar(1000) default NULL,
+ CategoryID int(11) NOT NULL default '0',
+ EntryDate datetime default NULL,
+ CreatorID varchar(50) NOT NULL,
+ UserID varchar(50) NOT NULL,
+ PRIMARY KEY (EntryID),
+ KEY CategoryID (CategoryID),
+ KEY CreatorID (CreatorID),
+ KEY UserID (UserID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+DROP TABLE IF EXISTS signon;
+CREATE TABLE signon (
+ SessionToken varchar(32) NOT NULL,
+ Username varchar(50) NOT NULL,
+ LastSignOnDate datetime NOT NULL,
+ PRIMARY KEY (SessionToken),
+ KEY Username (Username)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS categories;
+CREATE TABLE categories (
+ CategoryID int(11) NOT NULL auto_increment,
+ `Name` varchar(255) NOT NULL,
+ ProjectID int(11) NOT NULL,
+ ParentCategoryID int(11) default '0',
+ Abbreviation varchar(255) default NULL,
+ EstimateDuration float(10,2) default '0.00',
+ PRIMARY KEY (CategoryID),
+ UNIQUE KEY UniqueNamePerProject (`Name`,ProjectID),
+ KEY ProjectID (ProjectID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+DROP TABLE IF EXISTS project;
+CREATE TABLE project (
+ ProjectID int(11) NOT NULL auto_increment,
+ `Name` varchar(255) NOT NULL,
+ Description varchar(255) default NULL,
+ CreationDate datetime NOT NULL,
+ Disabled tinyint(1) NOT NULL default '0',
+ EstimateDuration float(10,2) NOT NULL default '0.00',
+ CreatorID varchar(50) NOT NULL,
+ ManagerID varchar(50) default NULL,
+ PRIMARY KEY (ProjectID),
+ KEY `Name` (`Name`),
+ KEY CreatorID (CreatorID),
+ KEY ManagerID (ManagerID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+DROP TABLE IF EXISTS users;
+CREATE TABLE users (
+ Username varchar(50) NOT NULL,
+ `Password` varchar(50) NOT NULL,
+ EmailAddress varchar(100) NOT NULL,
+ Disabled tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (Username)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `categories`
+ ADD CONSTRAINT categories_ibfk_1
+ FOREIGN KEY (ProjectID) REFERENCES project (ProjectID);
+
+ALTER TABLE `project`
+ ADD CONSTRAINT project_ibfk_2
+ FOREIGN KEY (ManagerID) REFERENCES users (Username),
+ ADD CONSTRAINT project_ibfk_1
+ FOREIGN KEY (CreatorID) REFERENCES users (Username);
+
+ALTER TABLE `project_members`
+ ADD CONSTRAINT project_members_ibfk_1
+ FOREIGN KEY (UserID) REFERENCES users (Username),
+ ADD CONSTRAINT project_members_ibfk_2
+ FOREIGN KEY (ProjectID) REFERENCES project (ProjectID);
+
+ALTER TABLE `signon`
+ ADD CONSTRAINT signon_ibfk_1
+ FOREIGN KEY (Username) REFERENCES users (Username);
+
+ALTER TABLE `time_entry`
+ ADD CONSTRAINT time_entry_ibfk_2
+ FOREIGN KEY (UserID) REFERENCES users (Username),
+ ADD CONSTRAINT time_entry_ibfk_1
+ FOREIGN KEY (CategoryID) REFERENCES categories (CategoryID);
+
+ALTER TABLE `user_roles`
+ ADD CONSTRAINT user_roles_ibfk_2
+ FOREIGN KEY (RoleType) REFERENCES role_types (RoleType),
+ ADD CONSTRAINT user_roles_ibfk_1
+ FOREIGN KEY (UserID) REFERENCES users (Username);
+
+INSERT INTO role_types (RoleType, Description) VALUES
+('admin', 'Project administrator may additionally view the list of all users.'),
+('consultant', 'Consultant may log time entries only.'),
+('manager', 'Project manager may additionally edit all projects and view reports.');
+
+INSERT INTO users (Username, Password, EmailAddress, Disabled) VALUES
+('admin', '21232f297a57a5a743894a0e4a801fc3', 'admin@pradosoft.com', 0),
+('manager', '1d0258c2440a8d19e716292b231e3190', 'manager@pradosoft.com', 0),
+('consultant', '7adfa4f2ba9323e6c1e024de375434b0', 'consultant@pradosoft.com', 0);
+
+INSERT INTO user_roles (UserID, RoleType) VALUES
+('admin', 'admin'),
+('admin', 'manager'),
+('admin', 'consultant'),
+('manager', 'manager'),
+('manager', 'consultant'),
+('consultant', 'consultant');
\ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/users.xml b/demos/time-tracker/protected/App_Data/users.xml
new file mode 100644
index 00000000..78de588a
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/users.xml
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSERT INTO
+ users (Username, Password, EmailAddress)
+ VALUES
+ (#user.Name#, #password#, #user.EmailAddress#)
+
+
+
+ UPDATE users SET Disabled = 1 WHERE username = #value#
+
+
+
+ INSERT INTO
+ signon (SessionToken, Username, LastSignOnDate)
+ VALUES
+ (#token#, #username#, NOW())
+
+
+
+
+
+ UPDATE signon SET LastSignOnDate = NOW()
+ WHERE SessionToken = #value#
+
+
+
+ DELETE FROM user_roles WHERE UserID = #Name#
+
+
+
+ INSERT INTO user_roles (UserID, RoleType)
+ VALUES(#username#, #role#)
+
+
+
+ UPDATE users
+ SET EmailAddress = #EmailAddress#
+ WHERE Username = #Name#
+
+
+
+ UPDATE users
+ SET EmailAddress = #user.EmailAddress#, Password=#password#
+ WHERE Username = #user.Name#
+
+
+
+ DELETE FROM signon WHERE Username = #value#
+
+
+
+ DELETE FROM signon
+
+
+
\ No newline at end of file
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
diff --git a/demos/time-tracker/protected/application.xml b/demos/time-tracker/protected/application.xml
new file mode 100644
index 00000000..bb1f2fbb
--- /dev/null
+++ b/demos/time-tracker/protected/application.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3