From 567ab5d2b3545baf1fa536f23ea4f5ef6fe71d68 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sun, 16 Jul 2006 06:25:57 +0000
Subject: Rename APP_CODE directory name.
---
.gitattributes | 24 ++--
demos/sqlmap/protected/App_Data/person.xml | 16 +++
demos/sqlmap/protected/App_Data/personHelper.xml | 42 ++++++
demos/sqlmap/protected/App_Data/test.db | Bin 0 -> 5120 bytes
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 -
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 +
.../protected/pages/Docs/DatabaseDesign.page | 42 ++++++
25 files changed, 778 insertions(+), 674 deletions(-)
create mode 100644 demos/sqlmap/protected/App_Data/person.xml
create mode 100644 demos/sqlmap/protected/App_Data/personHelper.xml
create mode 100644 demos/sqlmap/protected/App_Data/test.db
delete mode 100644 demos/time-tracker/protected/APP_CODE/BaseDao.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/DaoManager.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/Project.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/ProjectDao.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/TimeTrackerException.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/TimeTrackerUser.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/TimeTrackerUserTypeHandler.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/UserDao.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/UserManager.php
delete mode 100644 demos/time-tracker/protected/APP_CODE/exceptions.txt
create mode 100644 demos/time-tracker/protected/app/BaseDao.php
create mode 100644 demos/time-tracker/protected/app/DaoManager.php
create mode 100644 demos/time-tracker/protected/app/Project.php
create mode 100644 demos/time-tracker/protected/app/ProjectDao.php
create mode 100644 demos/time-tracker/protected/app/TimeTrackerException.php
create mode 100644 demos/time-tracker/protected/app/TimeTrackerUser.php
create mode 100644 demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php
create mode 100644 demos/time-tracker/protected/app/UserDao.php
create mode 100644 demos/time-tracker/protected/app/UserManager.php
create mode 100644 demos/time-tracker/protected/app/exceptions.txt
create mode 100644 demos/time-tracker/protected/pages/Docs/DatabaseDesign.page
diff --git a/.gitattributes b/.gitattributes
index 6cdc6483..c9ce218a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1012,6 +1012,9 @@ demos/soap/protected/webservices/SimpleService.php -text
demos/sqlmap/index.php -text
demos/sqlmap/protected/.htaccess -text
demos/sqlmap/protected/APP_CODE/Person.php -text
+demos/sqlmap/protected/App_Data/person.xml -text
+demos/sqlmap/protected/App_Data/personHelper.xml -text
+demos/sqlmap/protected/App_Data/test.db -text
demos/sqlmap/protected/application.xml -text
demos/sqlmap/protected/pages/Manual/BigPicture.page -text
demos/sqlmap/protected/pages/Manual/BuildingTSqlMapper.page -text
@@ -1056,18 +1059,19 @@ demos/sqlmap/protected/pages/Sample/crud2.page -text
demos/sqlmap/protected/pages/Sample/crud2.php -text
demos/time-tracker/index.php -text
demos/time-tracker/protected/.htaccess -text
-demos/time-tracker/protected/APP_CODE/BaseDao.php -text
-demos/time-tracker/protected/APP_CODE/DaoManager.php -text
-demos/time-tracker/protected/APP_CODE/Project.php -text
-demos/time-tracker/protected/APP_CODE/ProjectDao.php -text
-demos/time-tracker/protected/APP_CODE/TimeTrackerException.php -text
-demos/time-tracker/protected/APP_CODE/TimeTrackerUser.php -text
-demos/time-tracker/protected/APP_CODE/TimeTrackerUserTypeHandler.php -text
-demos/time-tracker/protected/APP_CODE/UserDao.php -text
-demos/time-tracker/protected/APP_CODE/UserManager.php -text
-demos/time-tracker/protected/APP_CODE/exceptions.txt -text
demos/time-tracker/protected/App_Data/time_tracker.db -text
+demos/time-tracker/protected/app/BaseDao.php -text
+demos/time-tracker/protected/app/DaoManager.php -text
+demos/time-tracker/protected/app/Project.php -text
+demos/time-tracker/protected/app/ProjectDao.php -text
+demos/time-tracker/protected/app/TimeTrackerException.php -text
+demos/time-tracker/protected/app/TimeTrackerUser.php -text
+demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php -text
+demos/time-tracker/protected/app/UserDao.php -text
+demos/time-tracker/protected/app/UserManager.php -text
+demos/time-tracker/protected/app/exceptions.txt -text
demos/time-tracker/protected/pages/Docs/CreateBusinessCode.page -text
+demos/time-tracker/protected/pages/Docs/DatabaseDesign.page -text
demos/time-tracker/protected/pages/Docs/GettingStarted.page -text
demos/time-tracker/protected/pages/Docs/Home.page -text
demos/time-tracker/protected/pages/Docs/Introduction.page -text
diff --git a/demos/sqlmap/protected/App_Data/person.xml b/demos/sqlmap/protected/App_Data/person.xml
new file mode 100644
index 00000000..4ffe44d9
--- /dev/null
+++ b/demos/sqlmap/protected/App_Data/person.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ SELECT
+ per_id as ID,
+ per_first_name as FirstName,
+ per_last_name as LastName,
+ per_birth_date as BirthDate,
+ per_weight_kg as WeightInKilograms,
+ per_height_m as HeightInMeters
+ FROM
+ person
+
+
+
\ No newline at end of file
diff --git a/demos/sqlmap/protected/App_Data/personHelper.xml b/demos/sqlmap/protected/App_Data/personHelper.xml
new file mode 100644
index 00000000..ea2d4302
--- /dev/null
+++ b/demos/sqlmap/protected/App_Data/personHelper.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+ select
+ PER_ID as ID,
+ PER_FIRST_NAME as FirstName,
+ PER_LAST_NAME as LastName,
+ PER_BIRTH_DATE as BirthDate,
+ PER_WEIGHT_KG as WeightInKilograms,
+ PER_HEIGHT_M as HeightInMeters
+ from PERSON
+ WHERE
+ PER_ID = #value#
+
+
+
+ insert into PERSON
+ (PER_ID, PER_FIRST_NAME, PER_LAST_NAME,
+ PER_BIRTH_DATE, PER_WEIGHT_KG, PER_HEIGHT_M)
+ values
+ (#ID#, #FirstName#, #LastName#,
+ #BirthDate#, #WeightInKilograms#, #HeightInMeters#)
+
+
+
+ update PERSON set
+ PER_FIRST_NAME = #FirstName#,
+ PER_LAST_NAME = #LastName#,
+ PER_BIRTH_DATE = #BirthDate#,
+ PER_WEIGHT_KG = #WeightInKilograms#,
+ PER_HEIGHT_M = #HeightInMeters#
+ where PER_ID = #ID#
+
+
+
+ delete from PERSON
+ where PER_ID = #value#
+
+
+
diff --git a/demos/sqlmap/protected/App_Data/test.db b/demos/sqlmap/protected/App_Data/test.db
new file mode 100644
index 00000000..a40c91fe
Binary files /dev/null and b/demos/sqlmap/protected/App_Data/test.db differ
diff --git a/demos/time-tracker/protected/APP_CODE/BaseDao.php b/demos/time-tracker/protected/APP_CODE/BaseDao.php
deleted file mode 100644
index 63b91def..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/DaoManager.php b/demos/time-tracker/protected/APP_CODE/DaoManager.php
deleted file mode 100644
index b8ac55af..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/Project.php b/demos/time-tracker/protected/APP_CODE/Project.php
deleted file mode 100644
index 660fad04..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/ProjectDao.php b/demos/time-tracker/protected/APP_CODE/ProjectDao.php
deleted file mode 100644
index 81902e0c..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/TimeTrackerException.php b/demos/time-tracker/protected/APP_CODE/TimeTrackerException.php
deleted file mode 100644
index 64b11405..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/TimeTrackerUser.php b/demos/time-tracker/protected/APP_CODE/TimeTrackerUser.php
deleted file mode 100644
index 99ac1209..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/TimeTrackerUserTypeHandler.php b/demos/time-tracker/protected/APP_CODE/TimeTrackerUserTypeHandler.php
deleted file mode 100644
index 07c46acc..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/UserDao.php b/demos/time-tracker/protected/APP_CODE/UserDao.php
deleted file mode 100644
index 4dc39b2b..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/UserManager.php b/demos/time-tracker/protected/APP_CODE/UserManager.php
deleted file mode 100644
index 1327dc3c..00000000
--- a/demos/time-tracker/protected/APP_CODE/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_CODE/exceptions.txt b/demos/time-tracker/protected/APP_CODE/exceptions.txt
deleted file mode 100644
index 6568cc72..00000000
--- a/demos/time-tracker/protected/APP_CODE/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/app/BaseDao.php b/demos/time-tracker/protected/app/BaseDao.php
new file mode 100644
index 00000000..63b91def
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/DaoManager.php b/demos/time-tracker/protected/app/DaoManager.php
new file mode 100644
index 00000000..b8ac55af
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/Project.php b/demos/time-tracker/protected/app/Project.php
new file mode 100644
index 00000000..660fad04
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/ProjectDao.php b/demos/time-tracker/protected/app/ProjectDao.php
new file mode 100644
index 00000000..81902e0c
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/TimeTrackerException.php b/demos/time-tracker/protected/app/TimeTrackerException.php
new file mode 100644
index 00000000..64b11405
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/TimeTrackerUser.php b/demos/time-tracker/protected/app/TimeTrackerUser.php
new file mode 100644
index 00000000..99ac1209
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/TimeTrackerUserTypeHandler.php b/demos/time-tracker/protected/app/TimeTrackerUserTypeHandler.php
new file mode 100644
index 00000000..07c46acc
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/UserDao.php b/demos/time-tracker/protected/app/UserDao.php
new file mode 100644
index 00000000..4dc39b2b
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/UserManager.php b/demos/time-tracker/protected/app/UserManager.php
new file mode 100644
index 00000000..1327dc3c
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/exceptions.txt b/demos/time-tracker/protected/app/exceptions.txt
new file mode 100644
index 00000000..6568cc72
--- /dev/null
+++ b/demos/time-tracker/protected/app/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/pages/Docs/DatabaseDesign.page b/demos/time-tracker/protected/pages/Docs/DatabaseDesign.page
new file mode 100644
index 00000000..a306ba2c
--- /dev/null
+++ b/demos/time-tracker/protected/pages/Docs/DatabaseDesign.page
@@ -0,0 +1,42 @@
+
+Database Design
+The design steps we take in the sample application is a data centric
+approach. That is, we shall consider the application from the view
+point of data structures, data relationships and data integrity.
+Other designs starting from object and class design are also possible but is
+not the approach taken in this guide.
+
+
+Entity Relationship
+We start with the following entity relationship diagram.
+The bold text in each entity indicate required fields. The underline
+text indicates the entity's primary key, also denoted as PK .
+Entity relationships are indicated with arrows between entities and
+each relationship field is denoted with FK .
+
+The four entities: Project , Categories , TimeEntry
+and ProjectMembers
+makes up the time tracker application. While the other entities:
+Users , UserRoles , RoleTypes and Signon are
+usually found in applications where membership or user management is required.
+
+ class="figure" />
+
+
+Info:
+See
Database Normalization
+for a quick reference regarding database design and normalization, especially the
+3rd normal form (3NF).
+
+
+MySQL database
+We shall concentrate on the MySQL database for this sample application.
+Other database engines are also possible and can be quite easily inter-changed.
+The SQL script to initialize the MySQL database is given below. The following
+SQL script was created using MySQL version 4.1.7.
+
+
+
+<%= file_get_contents('protected/data/time-tracker-mysql.sql') %>
+
+
\ No newline at end of file
--
cgit v1.2.3