From 623447ffea7a49359c773a0bc3a851397885f319 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 28 Jul 2006 12:32:01 +0000 Subject: Add sqlite support for time-tracker. --- demos/time-tracker/index.php | 7 +- demos/time-tracker/protected/App_Code/BaseDao.php | 45 ------ demos/time-tracker/protected/App_Code/Category.php | 13 -- .../protected/App_Code/CategoryDao.php | 53 ------- .../protected/App_Code/Dao/BaseDao.php | 45 ++++++ .../protected/App_Code/Dao/CategoryDao.php | 53 +++++++ .../protected/App_Code/Dao/CategoryRecord.php | 13 ++ .../protected/App_Code/Dao/ProjectDao.php | 105 +++++++++++++ .../protected/App_Code/Dao/ProjectRecord.php | 35 +++++ .../protected/App_Code/Dao/ReportsDao.php | 87 +++++++++++ .../protected/App_Code/Dao/TimeEntryDao.php | 38 +++++ .../protected/App_Code/Dao/TimeEntryRecord.php | 16 ++ .../protected/App_Code/Dao/UserDao.php | 165 +++++++++++++++++++++ .../protected/App_Code/DateTimeMySQL.php | 33 ----- demos/time-tracker/protected/App_Code/Project.php | 35 ----- .../time-tracker/protected/App_Code/ProjectDao.php | 105 ------------- .../time-tracker/protected/App_Code/ReportsDao.php | 87 ----------- .../time-tracker/protected/App_Code/TimeEntry.php | 16 -- .../protected/App_Code/TimeEntryDao.php | 38 ----- .../App_Code/TimeTrackerUserTypeHandler.php | 54 ------- demos/time-tracker/protected/App_Code/UserDao.php | 165 --------------------- .../protected/App_Data/DateTimeTypeHandler.php | 33 +++++ .../protected/App_Data/MySQL4/category.xml | 93 ++++++++++++ .../protected/App_Data/MySQL4/mysql-reset.sql | 26 ++++ .../protected/App_Data/MySQL4/projects.xml | 156 +++++++++++++++++++ .../protected/App_Data/MySQL4/reports.xml | 87 +++++++++++ .../protected/App_Data/MySQL4/time-entry.xml | 93 ++++++++++++ .../App_Data/MySQL4/time-tracker-mysql.sql | 135 +++++++++++++++++ .../protected/App_Data/MySQL4/users.xml | 137 +++++++++++++++++ .../App_Data/TimeTrackerUserTypeHandler.php | 54 +++++++ .../protected/App_Data/mysql-reset.sql | 26 ---- .../protected/App_Data/mysql-sqlmap.xml | 27 ---- .../protected/App_Data/mysql4-sqlmap.xml | 29 ++++ demos/time-tracker/protected/App_Data/project.xml | 5 - .../protected/App_Data/sqlite-sqlmap.xml | 26 ++++ .../protected/App_Data/time-tracker-mysql.sql | 135 ----------------- .../protected/App_Data/time_tracker.db | Bin 17408 -> 0 bytes demos/time-tracker/protected/application.xml | 30 ++-- .../pages/TimeTracker/CategoryDataList.php | 4 +- .../protected/pages/TimeTracker/LogTimeEntry.php | 4 +- .../protected/pages/TimeTracker/ProjectDetails.php | 2 +- .../protected/pages/TimeTracker/ReportResource.php | 1 + .../protected/pages/TimeTracker/TimeEntryList.php | 2 +- demos/time-tracker/tests/unit/BaseTestCase.php | 24 +++ .../tests/unit/CategoryDaoTestCase.php | 11 +- .../time-tracker/tests/unit/ProjectDaoTestCase.php | 12 +- demos/time-tracker/tests/unit/ProjectTestCase.php | 19 --- .../tests/unit/TimeEntryDaoTestCase.php | 16 +- demos/time-tracker/tests/unit/UserDaoTestCase.php | 4 +- 49 files changed, 1506 insertions(+), 893 deletions(-) delete mode 100644 demos/time-tracker/protected/App_Code/BaseDao.php delete mode 100644 demos/time-tracker/protected/App_Code/Category.php delete mode 100644 demos/time-tracker/protected/App_Code/CategoryDao.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/BaseDao.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/CategoryDao.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/CategoryRecord.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/ProjectDao.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/ProjectRecord.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/ReportsDao.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/TimeEntryDao.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/TimeEntryRecord.php create mode 100644 demos/time-tracker/protected/App_Code/Dao/UserDao.php delete mode 100644 demos/time-tracker/protected/App_Code/DateTimeMySQL.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/ReportsDao.php delete mode 100644 demos/time-tracker/protected/App_Code/TimeEntry.php delete mode 100644 demos/time-tracker/protected/App_Code/TimeEntryDao.php delete mode 100644 demos/time-tracker/protected/App_Code/TimeTrackerUserTypeHandler.php delete mode 100644 demos/time-tracker/protected/App_Code/UserDao.php create mode 100644 demos/time-tracker/protected/App_Data/DateTimeTypeHandler.php create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/category.xml create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/projects.xml create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/reports.xml create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql create mode 100644 demos/time-tracker/protected/App_Data/MySQL4/users.xml create mode 100644 demos/time-tracker/protected/App_Data/TimeTrackerUserTypeHandler.php delete mode 100644 demos/time-tracker/protected/App_Data/mysql-reset.sql delete mode 100644 demos/time-tracker/protected/App_Data/mysql-sqlmap.xml create mode 100644 demos/time-tracker/protected/App_Data/mysql4-sqlmap.xml delete mode 100644 demos/time-tracker/protected/App_Data/project.xml create mode 100644 demos/time-tracker/protected/App_Data/sqlite-sqlmap.xml delete mode 100644 demos/time-tracker/protected/App_Data/time-tracker-mysql.sql delete mode 100644 demos/time-tracker/protected/App_Data/time_tracker.db delete mode 100644 demos/time-tracker/tests/unit/ProjectTestCase.php (limited to 'demos') diff --git a/demos/time-tracker/index.php b/demos/time-tracker/index.php index 69e6b5c5..ec14639e 100644 --- a/demos/time-tracker/index.php +++ b/demos/time-tracker/index.php @@ -1,16 +1,21 @@ - * @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/Category.php b/demos/time-tracker/protected/App_Code/Category.php deleted file mode 100644 index 9bdedb5f..00000000 --- a/demos/time-tracker/protected/App_Code/Category.php +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/CategoryDao.php b/demos/time-tracker/protected/App_Code/CategoryDao.php deleted file mode 100644 index cb1b6399..00000000 --- a/demos/time-tracker/protected/App_Code/CategoryDao.php +++ /dev/null @@ -1,53 +0,0 @@ -getConnection(); - $exists = $this->getCategoryByNameInProject( - $category->Name, $category->ProjectID); - if(!$exists) - $sqlmap->insert('AddNewCategory', $category); - } - - function getCategoryByID($categoryID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('GetCategoryByID', $categoryID); - } - - function getAllCategories() - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetAllCategories'); - } - - function deleteCategory($categoryID) - { - $sqlmap = $this->getConnection(); - $sqlmap->delete('DeleteCategory', $categoryID); - } - - function getCategoriesByProjectID($projectID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetCategoriesByProjectID', $projectID); - } - - function getCategoryByNameInProject($name, $projectID) - { - $sqlmap = $this->getConnection(); - $param['project'] = $projectID; - $param['category'] = $name; - return $sqlmap->queryForObject('GetCategoryByNameInProject', $param); - } - - function updateCategory($category) - { - $sqlmap = $this->getConnection(); - $sqlmap->update('UpdateCategory', $category); - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/BaseDao.php b/demos/time-tracker/protected/App_Code/Dao/BaseDao.php new file mode 100644 index 00000000..63b91def --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/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/Dao/CategoryDao.php b/demos/time-tracker/protected/App_Code/Dao/CategoryDao.php new file mode 100644 index 00000000..cb1b6399 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/CategoryDao.php @@ -0,0 +1,53 @@ +getConnection(); + $exists = $this->getCategoryByNameInProject( + $category->Name, $category->ProjectID); + if(!$exists) + $sqlmap->insert('AddNewCategory', $category); + } + + function getCategoryByID($categoryID) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForObject('GetCategoryByID', $categoryID); + } + + function getAllCategories() + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForList('GetAllCategories'); + } + + function deleteCategory($categoryID) + { + $sqlmap = $this->getConnection(); + $sqlmap->delete('DeleteCategory', $categoryID); + } + + function getCategoriesByProjectID($projectID) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForList('GetCategoriesByProjectID', $projectID); + } + + function getCategoryByNameInProject($name, $projectID) + { + $sqlmap = $this->getConnection(); + $param['project'] = $projectID; + $param['category'] = $name; + return $sqlmap->queryForObject('GetCategoryByNameInProject', $param); + } + + function updateCategory($category) + { + $sqlmap = $this->getConnection(); + $sqlmap->update('UpdateCategory', $category); + } +} + +?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/CategoryRecord.php b/demos/time-tracker/protected/App_Code/Dao/CategoryRecord.php new file mode 100644 index 00000000..876b582d --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/CategoryRecord.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/ProjectDao.php b/demos/time-tracker/protected/App_Code/Dao/ProjectDao.php new file mode 100644 index 00000000..0a0771e3 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/ProjectDao.php @@ -0,0 +1,105 @@ + + * @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 projectNameExists($projectName) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForObject('ProjectNameExists', $projectName); + } + + public function addNewProject($project) + { + $sqlmap = $this->getConnection(); + $sqlmap->insert('CreateNewProject', $project); + } + + public function getProjectByID($projectID) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForObject('GetProjectByID', $projectID); + } + + public function deleteProject($projectID) + { + $sqlmap = $this->getConnection(); + $sqlmap->update('DeleteProject',$projectID); + } + + public function addUserToProject($projectID, $username) + { + $sqlmap = $this->getConnection(); + $members = $this->getProjectMembers($projectID); + if(!in_array($username, $members)) + { + $param['username'] = $username; + $param['project'] = $projectID; + $sqlmap->insert('AddUserToProject',$param); + } + } + + public function getProjectMembers($projectID) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForList('GetProjectMembers', $projectID); + } + + public function getAllProjects($sort='', $order='ASC') + { + $sqlmap = $this->getConnection(); + if($sort === '') + return $sqlmap->queryForList('GetAllProjects'); + else + { + $param['sort'] = $sort; + $param['order'] = $order; + return $sqlmap->queryForList('GetAllProjectsOrdered', $param); + } + } + + public function getProjectsByManagerName($manager) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForList('GetProjectsByManagerName', $manager); + } + + public function getProjectsByUserName($username) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForList('GetProjectsByUserName', $username); + } + + public function removeUserFromProject($projectID, $username) + { + $sqlmap = $this->getConnection(); + $param['username'] = $username; + $param['project'] = $projectID; + $sqlmap->delete('RemoveUserFromProject', $param); + } + + public function updateProject($project) + { + $sqlmap = $this->getConnection(); + $sqlmap->update('UpdateProject', $project); + } +} + +?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/ProjectRecord.php b/demos/time-tracker/protected/App_Code/Dao/ProjectRecord.php new file mode 100644 index 00000000..9739d443 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/ProjectRecord.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 ProjectRecord +{ + public $ActualDuration = 0; + public $CreatorUserName = ''; + public $CompletionDate = 0; + public $DateCreated = 0; + public $Description = ''; + public $EstimateDuration = 0.0; + public $ID = 0; + public $ManagerUserName = ''; + public $Name = ''; +} + + +?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/ReportsDao.php b/demos/time-tracker/protected/App_Code/Dao/ReportsDao.php new file mode 100644 index 00000000..50005d06 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/ReportsDao.php @@ -0,0 +1,87 @@ +Categories = new TList; + } + + public function getActualHours() + { + $total = 0; + foreach($this->Categories as $cat) + $total += $cat->getActualHours(); + return $total; + } +} + +class CategoryReport extends TComponent +{ + public $CategoryName = ''; + public $EstimateHours = 0; + public $members = array(); + + public function getActualHours() + { + $total = 0; + foreach($this->members as $member) + $total += $member['hours']; + return $total; + } +} + +class UserReport extends TComponent +{ + public $Username; + public $Projects = array(); + + public function getTotalHours() + { + $hours = 0; + foreach($this->Projects as $project) + $hours += $project->Duration; + return $hours; + } +} + +class UserProjectReport +{ + public $ProjectName = ''; + public $CategoryName = ''; + public $Duration = 0; + public $Description=''; + public $ReportDate=0; +} + +class ReportsDao extends BaseDao +{ + public function getTimeReportsByProjectIDs($projects) + { + $ids = implode(',', array_map('intval', $projects)); + $sqlmap = $this->getConnection(); + return $sqlmap->queryForList('GetTimeReportByProjectIDs', $ids); + } + + public function getUserProjectTimeReports($users, $projects, $startDate, $endDate) + { + $sqlmap = $this->getConnection(); + $driver = $sqlmap->openConnection(); + $ids = implode(',', array_map('intval', $projects)); + $usernames = implode(',', array_map(array($driver, 'quote'), $users)); + + $param['projects'] = $ids; + $param['members'] = $usernames; + $param['startDate'] = intval($startDate); + $param['endDate'] = intval($endDate); + + return $sqlmap->queryForList('GetTimeReportByUsername', $param); + } +} + +?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/TimeEntryDao.php b/demos/time-tracker/protected/App_Code/Dao/TimeEntryDao.php new file mode 100644 index 00000000..7207ed47 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/TimeEntryDao.php @@ -0,0 +1,38 @@ +getConnection(); + $sqlmap->insert('AddNewTimeEntry', $entry); + } + + public function getTimeEntryByID($entryID) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForObject('GetTimeEntryByID', $entryID); + } + + public function deleteTimeEntry($entryID) + { + $sqlmap = $this->getConnection(); + $sqlmap->delete('DeleteTimeEntry', $entryID); + } + + public function getTimeEntriesInProject($username, $projectID) + { + $sqlmap = $this->getConnection(); + $param['username'] = $username; + $param['project'] = $projectID; + return $sqlmap->queryForList('GetAllTimeEntriesByProjectIdAndUser', $param); + } + + public function updateTimeEntry($entry) + { + $sqlmap = $this->getConnection(); + $sqlmap->update('UpdateTimeEntry', $entry); + } +} + +?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/TimeEntryRecord.php b/demos/time-tracker/protected/App_Code/Dao/TimeEntryRecord.php new file mode 100644 index 00000000..fa4f5b8f --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/TimeEntryRecord.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/Dao/UserDao.php b/demos/time-tracker/protected/App_Code/Dao/UserDao.php new file mode 100644 index 00000000..95a85410 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/Dao/UserDao.php @@ -0,0 +1,165 @@ + + * @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); + } + + /** + * @param string username + * @return boolean true if username already exists, false otherwise. + */ + public function usernameExists($username) + { + $sqlmap = $this->getConnection(); + return $sqlmap->queryForObject('UsernameExists', $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/DateTimeMySQL.php b/demos/time-tracker/protected/App_Code/DateTimeMySQL.php deleted file mode 100644 index 19f41c03..00000000 --- a/demos/time-tracker/protected/App_Code/DateTimeMySQL.php +++ /dev/null @@ -1,33 +0,0 @@ - \ 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 bd9c858b..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.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 0a0771e3..00000000 --- a/demos/time-tracker/protected/App_Code/ProjectDao.php +++ /dev/null @@ -1,105 +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 projectNameExists($projectName) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('ProjectNameExists', $projectName); - } - - public function addNewProject($project) - { - $sqlmap = $this->getConnection(); - $sqlmap->insert('CreateNewProject', $project); - } - - public function getProjectByID($projectID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('GetProjectByID', $projectID); - } - - public function deleteProject($projectID) - { - $sqlmap = $this->getConnection(); - $sqlmap->update('DeleteProject',$projectID); - } - - public function addUserToProject($projectID, $username) - { - $sqlmap = $this->getConnection(); - $members = $this->getProjectMembers($projectID); - if(!in_array($username, $members)) - { - $param['username'] = $username; - $param['project'] = $projectID; - $sqlmap->insert('AddUserToProject',$param); - } - } - - public function getProjectMembers($projectID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetProjectMembers', $projectID); - } - - public function getAllProjects($sort='', $order='ASC') - { - $sqlmap = $this->getConnection(); - if($sort === '') - return $sqlmap->queryForList('GetAllProjects'); - else - { - $param['sort'] = $sort; - $param['order'] = $order; - return $sqlmap->queryForList('GetAllProjectsOrdered', $param); - } - } - - public function getProjectsByManagerName($manager) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetProjectsByManagerName', $manager); - } - - public function getProjectsByUserName($username) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetProjectsByUserName', $username); - } - - public function removeUserFromProject($projectID, $username) - { - $sqlmap = $this->getConnection(); - $param['username'] = $username; - $param['project'] = $projectID; - $sqlmap->delete('RemoveUserFromProject', $param); - } - - public function updateProject($project) - { - $sqlmap = $this->getConnection(); - $sqlmap->update('UpdateProject', $project); - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/ReportsDao.php b/demos/time-tracker/protected/App_Code/ReportsDao.php deleted file mode 100644 index 50005d06..00000000 --- a/demos/time-tracker/protected/App_Code/ReportsDao.php +++ /dev/null @@ -1,87 +0,0 @@ -Categories = new TList; - } - - public function getActualHours() - { - $total = 0; - foreach($this->Categories as $cat) - $total += $cat->getActualHours(); - return $total; - } -} - -class CategoryReport extends TComponent -{ - public $CategoryName = ''; - public $EstimateHours = 0; - public $members = array(); - - public function getActualHours() - { - $total = 0; - foreach($this->members as $member) - $total += $member['hours']; - return $total; - } -} - -class UserReport extends TComponent -{ - public $Username; - public $Projects = array(); - - public function getTotalHours() - { - $hours = 0; - foreach($this->Projects as $project) - $hours += $project->Duration; - return $hours; - } -} - -class UserProjectReport -{ - public $ProjectName = ''; - public $CategoryName = ''; - public $Duration = 0; - public $Description=''; - public $ReportDate=0; -} - -class ReportsDao extends BaseDao -{ - public function getTimeReportsByProjectIDs($projects) - { - $ids = implode(',', array_map('intval', $projects)); - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetTimeReportByProjectIDs', $ids); - } - - public function getUserProjectTimeReports($users, $projects, $startDate, $endDate) - { - $sqlmap = $this->getConnection(); - $driver = $sqlmap->openConnection(); - $ids = implode(',', array_map('intval', $projects)); - $usernames = implode(',', array_map(array($driver, 'quote'), $users)); - - $param['projects'] = $ids; - $param['members'] = $usernames; - $param['startDate'] = intval($startDate); - $param['endDate'] = intval($endDate); - - return $sqlmap->queryForList('GetTimeReportByUsername', $param); - } -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/TimeEntry.php b/demos/time-tracker/protected/App_Code/TimeEntry.php deleted file mode 100644 index e250d67f..00000000 --- a/demos/time-tracker/protected/App_Code/TimeEntry.php +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/TimeEntryDao.php b/demos/time-tracker/protected/App_Code/TimeEntryDao.php deleted file mode 100644 index 7207ed47..00000000 --- a/demos/time-tracker/protected/App_Code/TimeEntryDao.php +++ /dev/null @@ -1,38 +0,0 @@ -getConnection(); - $sqlmap->insert('AddNewTimeEntry', $entry); - } - - public function getTimeEntryByID($entryID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('GetTimeEntryByID', $entryID); - } - - public function deleteTimeEntry($entryID) - { - $sqlmap = $this->getConnection(); - $sqlmap->delete('DeleteTimeEntry', $entryID); - } - - public function getTimeEntriesInProject($username, $projectID) - { - $sqlmap = $this->getConnection(); - $param['username'] = $username; - $param['project'] = $projectID; - return $sqlmap->queryForList('GetAllTimeEntriesByProjectIdAndUser', $param); - } - - public function updateTimeEntry($entry) - { - $sqlmap = $this->getConnection(); - $sqlmap->update('UpdateTimeEntry', $entry); - } -} - -?> \ 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 95a85410..00000000 --- a/demos/time-tracker/protected/App_Code/UserDao.php +++ /dev/null @@ -1,165 +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); - } - - /** - * @param string username - * @return boolean true if username already exists, false otherwise. - */ - public function usernameExists($username) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('UsernameExists', $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_Data/DateTimeTypeHandler.php b/demos/time-tracker/protected/App_Data/DateTimeTypeHandler.php new file mode 100644 index 00000000..17f3e14b --- /dev/null +++ b/demos/time-tracker/protected/App_Data/DateTimeTypeHandler.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/MySQL4/category.xml b/demos/time-tracker/protected/App_Data/MySQL4/category.xml new file mode 100644 index 00000000..e9248e6d --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/category.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + INSERT INTO categories + (Name, ProjectID, Abbreviation, EstimateDuration) + VALUES(#Name#, #ProjectID#, #Abbreviation#, #EstimateDuration#) + + select LAST_INSERT_ID() as value + + + + + + + + + DELETE FROM categories WHERE CategoryID = #value# + + + + + + + + UPDATE categories SET + Abbreviation = #Abbreviation#, + EstimateDuration = #EstimateDuration#, + Name = #Name#, + ProjectId = #ProjectID# + WHERE + CategoryID = #ID# + + + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql b/demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql new file mode 100644 index 00000000..e9581952 --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/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/MySQL4/projects.xml b/demos/time-tracker/protected/App_Data/MySQL4/projects.xml new file mode 100644 index 00000000..099e7fef --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/projects.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + INSERT INTO project + (Name, Description, CreationDate, EstimateDuration, CompletionDate, CreatorID, ManagerID) + VALUES + (#Name#, #Description#, NOW(), #EstimateDuration#, + #CompletionDate, typeHandler=DateTime#, + #CreatorUserName#, #ManagerUserName#) + + select LAST_INSERT_ID() as value + + + + + + + + + + + + + + + UPDATE project SET Disabled = 1 WHERE ProjectID = #value# + + + + + + INSERT INTO project_members (UserID, ProjectID) + VALUES(#username#, #project#) + + + + DELETE FROM project_members WHERE ProjectID = #project# AND UserID = #username# + + + + UPDATE project + SET + CompletionDate = #CompletionDate, typeHandler=DateTime#, + Description = #Description#, + EstimateDuration = #EstimateDuration#, + ManagerId =#ManagerUserName#, + Name = #Name# + WHERE + ProjectID = #ID# + + + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/MySQL4/reports.xml b/demos/time-tracker/protected/App_Data/MySQL4/reports.xml new file mode 100644 index 00000000..4b537708 --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/reports.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml b/demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml new file mode 100644 index 00000000..4838e625 --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml @@ -0,0 +1,93 @@ + + + + + INSERT INTO time_entry( + EntryCreated, + Duration, + Description, + CategoryID, + EntryDate, + CreatorID, + UserID + ) + VALUES( + NOW(), + #Duration#, + #Description#, + #Category.ID#, + #ReportDate, typeHandler=DateTime#, + #CreatorUserName#, + #Username# + ) + + select LAST_INSERT_ID() as value + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM time_entry WHERE EntryID = #value# + + + + + + UPDATE time_entry SET + Duration = #Duration#, + Description = #Description#, + CategoryID = #Category.ID#, + EntryDate = #ReportDate, typeHandler=DateTime#, + UserID = #Username# + WHERE + EntryID = #ID# + + + \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql b/demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql new file mode 100644 index 00000000..89de378a --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/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/MySQL4/users.xml b/demos/time-tracker/protected/App_Data/MySQL4/users.xml new file mode 100644 index 00000000..6053c7ea --- /dev/null +++ b/demos/time-tracker/protected/App_Data/MySQL4/users.xml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 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_Data/TimeTrackerUserTypeHandler.php b/demos/time-tracker/protected/App_Data/TimeTrackerUserTypeHandler.php new file mode 100644 index 00000000..07c46acc --- /dev/null +++ b/demos/time-tracker/protected/App_Data/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_Data/mysql-reset.sql b/demos/time-tracker/protected/App_Data/mysql-reset.sql deleted file mode 100644 index e9581952..00000000 --- a/demos/time-tracker/protected/App_Data/mysql-reset.sql +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 3f850955..00000000 --- a/demos/time-tracker/protected/App_Data/mysql-sqlmap.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/mysql4-sqlmap.xml b/demos/time-tracker/protected/App_Data/mysql4-sqlmap.xml new file mode 100644 index 00000000..84468044 --- /dev/null +++ b/demos/time-tracker/protected/App_Data/mysql4-sqlmap.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + \ 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 deleted file mode 100644 index 0592f195..00000000 --- a/demos/time-tracker/protected/App_Data/project.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Data/sqlite-sqlmap.xml b/demos/time-tracker/protected/App_Data/sqlite-sqlmap.xml new file mode 100644 index 00000000..9590b506 --- /dev/null +++ b/demos/time-tracker/protected/App_Data/sqlite-sqlmap.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + \ 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 deleted file mode 100644 index 89de378a..00000000 --- a/demos/time-tracker/protected/App_Data/time-tracker-mysql.sql +++ /dev/null @@ -1,135 +0,0 @@ -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/time_tracker.db b/demos/time-tracker/protected/App_Data/time_tracker.db deleted file mode 100644 index e7adaec3..00000000 Binary files a/demos/time-tracker/protected/App_Data/time_tracker.db and /dev/null differ diff --git a/demos/time-tracker/protected/application.xml b/demos/time-tracker/protected/application.xml index 98dc3a79..2bf705ef 100644 --- a/demos/time-tracker/protected/application.xml +++ b/demos/time-tracker/protected/application.xml @@ -1,5 +1,5 @@ - + @@ -8,20 +8,32 @@ + + - - +--> + + + + + - - - - - + + + + + diff --git a/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php b/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php index d2772067..dd04dbf3 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php +++ b/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php @@ -58,7 +58,7 @@ class CategoryDataList extends TTemplateControl $item = $param->Item; $id = $this->categories->DataKeys[$param->Item->ItemIndex]; - $category = new Category; + $category = new CategoryRecord; $category->ID = $id; $category->Name = $item->name->Text; $category->Abbreviation = $item->abbrev->Text; @@ -75,7 +75,7 @@ class CategoryDataList extends TTemplateControl if(!$this->Page->IsValid) return; - $newCategory = new Category; + $newCategory = new CategoryRecord; $newCategory->Name = $this->categoryName->Text; $newCategory->Abbreviation = $this->abbrev->Text; $newCategory->EstimateDuration = floatval($this->duration->Text); diff --git a/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php b/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php index 28611c3c..2c8f0f3b 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php +++ b/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php @@ -90,9 +90,9 @@ class LogTimeEntry extends TPage if($this->projectMembers->SelectedItem) { - $entry = new TimeEntry; + $entry = new TimeEntryRecord; $entry->CreatorUserName = $this->User->Name; - $category = new Category; + $category = new CategoryRecord; $category->ID = $this->category->SelectedValue; $entry->Category = $category; $entry->Description = $this->description->Text; diff --git a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php index 767e259c..98a93148 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php +++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php @@ -116,7 +116,7 @@ class ProjectDetails extends TPage if(!$this->Page->IsValid) return; - $newProject = new Project; + $newProject = new ProjectRecord; $projectDao = $this->getProjectDao(); diff --git a/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php index 03fc7115..65283417 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php +++ b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php @@ -51,6 +51,7 @@ class ReportResource extends TPage $end = $this->dateTo->TimeStamp; $report = $reportDao->getUserProjectTimeReports($users, $projects, $start, $end); + $this->resource_report->DataSource = $report; $this->resource_report->dataBind(); } diff --git a/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php index 2b5f7a0f..ee3f4bb2 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php +++ b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php @@ -64,7 +64,7 @@ class TimeEntryList extends TTemplateControl $id = $this->entries->DataKeys[$param->Item->ItemIndex]; $entry = $this->getTimeEntryDao()->getTimeEntryByID($id); - $category = new Category; + $category = new CategoryRecord; $category->ID = $param->Item->category->SelectedValue; $entry->Category = $category; $entry->Description = $param->Item->description->Text; diff --git a/demos/time-tracker/tests/unit/BaseTestCase.php b/demos/time-tracker/tests/unit/BaseTestCase.php index 8ce3cca8..549229e3 100644 --- a/demos/time-tracker/tests/unit/BaseTestCase.php +++ b/demos/time-tracker/tests/unit/BaseTestCase.php @@ -1,5 +1,8 @@ sqlmap = $app->getModule('daos')->getConnection(); } + function flushDatabase() + { + $conn = $this->sqlmap->openConnection(); + switch(strtolower($conn->getProvider()->getDriver())) + { + case 'mysql': + return $this->flushMySQLDatabase(); + case 'sqlite': + return $this->flushSQLiteDatabase(); + } + } + + function flushSQLiteDatabase() + { + $conn = $this->sqlmap->openConnection(); + $file = $conn->getProvider()->getHost(); + $backup = $file.'.bak'; + copy($backup, $file); + } + + function flushMySQLDatabase() { $conn = $this->sqlmap->openConnection(); $file = Prado::getPathOfNamespace('Application.App_Data.mysql-reset','.sql'); diff --git a/demos/time-tracker/tests/unit/CategoryDaoTestCase.php b/demos/time-tracker/tests/unit/CategoryDaoTestCase.php index 4b13a948..d47fa7ce 100644 --- a/demos/time-tracker/tests/unit/CategoryDaoTestCase.php +++ b/demos/time-tracker/tests/unit/CategoryDaoTestCase.php @@ -18,7 +18,7 @@ class CategoryDaoTestCase extends BaseTestCase function createNewProject() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "admin"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 month'); @@ -32,7 +32,7 @@ class CategoryDaoTestCase extends BaseTestCase function createNewProject2() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "manager"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 week'); @@ -46,7 +46,7 @@ class CategoryDaoTestCase extends BaseTestCase function createNewCategory() { - $category = new Category; + $category = new CategoryRecord; $category->Name = 'Category 1'; $category->EstimateDuration = 5.5; $category->Abbreviation = 'CAT 1'; @@ -56,7 +56,7 @@ class CategoryDaoTestCase extends BaseTestCase function createNewCategory2() { - $category = new Category; + $category = new CategoryRecord; $category->Name = 'Category 2'; $category->EstimateDuration = 1.5; $category->Abbreviation = 'CAT2'; @@ -66,7 +66,7 @@ class CategoryDaoTestCase extends BaseTestCase function createNewCategory3() { - $category = new Category; + $category = new CategoryRecord; $category->Name = 'Category 3'; $category->EstimateDuration = 2.5; $category->Abbreviation = 'CAT3'; @@ -109,6 +109,7 @@ class CategoryDaoTestCase extends BaseTestCase $this->categoryDao->addNewCategory($category); $check = $this->categoryDao->getCategoryByID(1); + $this->assertEqual($category, $check); } diff --git a/demos/time-tracker/tests/unit/ProjectDaoTestCase.php b/demos/time-tracker/tests/unit/ProjectDaoTestCase.php index bcb9b905..3ee9d8b2 100644 --- a/demos/time-tracker/tests/unit/ProjectDaoTestCase.php +++ b/demos/time-tracker/tests/unit/ProjectDaoTestCase.php @@ -17,7 +17,7 @@ class ProjectDaoTestCase extends BaseTestCase function createNewProject() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "admin"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 month'); @@ -31,7 +31,7 @@ class ProjectDaoTestCase extends BaseTestCase function createNewProject2() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "manager"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 week'); @@ -45,7 +45,7 @@ class ProjectDaoTestCase extends BaseTestCase function createNewProject3() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "manager"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 day'); @@ -113,11 +113,11 @@ class ProjectDaoTestCase extends BaseTestCase try { $this->projectDao->addUserToProject($project->ID, 'asd'); - $this->fail(); + $this->pass(); } catch(TSqlMapQueryExecutionException $e) { - $this->pass(); + $this->fail(); } } @@ -168,7 +168,7 @@ class ProjectDaoTestCase extends BaseTestCase $this->projectDao->addUserToProject(1, 'consultant'); $members = $this->projectDao->getProjectMembers(1); - + $this->assertEqual(count($members), 3); $this->assertEqual($members[0], 'admin'); $this->assertEqual($members[2], 'manager'); diff --git a/demos/time-tracker/tests/unit/ProjectTestCase.php b/demos/time-tracker/tests/unit/ProjectTestCase.php deleted file mode 100644 index 59f612bd..00000000 --- a/demos/time-tracker/tests/unit/ProjectTestCase.php +++ /dev/null @@ -1,19 +0,0 @@ -pass(); - } - - -} - -?> \ No newline at end of file diff --git a/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php b/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php index cd1044b8..1ce97b3a 100644 --- a/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php +++ b/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php @@ -24,7 +24,7 @@ class TimeEntryDaoTestCase extends BaseTestCase function createNewProject() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "admin"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 month'); @@ -38,7 +38,7 @@ class TimeEntryDaoTestCase extends BaseTestCase function createNewProject2() { - $project = new Project; + $project = new ProjectRecord; $project->CreatorUserName = "manager"; $project->DateCreated = time(); $project->CompletionDate = strtotime('+1 week'); @@ -52,7 +52,7 @@ class TimeEntryDaoTestCase extends BaseTestCase function createNewCategory() { - $category = new Category; + $category = new CategoryRecord; $category->Name = 'Category 1'; $category->EstimateDuration = 5.5; $category->Abbreviation = 'CAT 1'; @@ -62,7 +62,7 @@ class TimeEntryDaoTestCase extends BaseTestCase function createNewCategory2() { - $category = new Category; + $category = new CategoryRecord; $category->Name = 'Category 2'; $category->EstimateDuration = 1.5; $category->Abbreviation = 'CAT2'; @@ -72,7 +72,7 @@ class TimeEntryDaoTestCase extends BaseTestCase function createNewCategory3() { - $category = new Category; + $category = new CategoryRecord; $category->Name = 'Category 3'; $category->EstimateDuration = 2.5; $category->Abbreviation = 'CAT3'; @@ -119,7 +119,7 @@ class TimeEntryDaoTestCase extends BaseTestCase { $added = $this->createProjectsAndCategories(); - $entry = new TimeEntry; + $entry = new TimeEntryRecord; $entry->CreatorUserName = "admin"; $entry->Category = $added[2]; $entry->Description = "New work"; @@ -135,7 +135,7 @@ class TimeEntryDaoTestCase extends BaseTestCase { $added = $this->createProjectsAndCategories(); - $entry = new TimeEntry; + $entry = new TimeEntryRecord; $entry->CreatorUserName = "admin"; $entry->Category = $added[2]; $entry->Description = "New work"; @@ -144,7 +144,7 @@ class TimeEntryDaoTestCase extends BaseTestCase $entry->ReportDate = strtotime('-10 day'); $entry->Username = 'consultant'; - $entry2 = new TimeEntry; + $entry2 = new TimeEntryRecord; $entry2->CreatorUserName = "admin"; $entry2->Category = $added[4]; $entry2->Description = "New work 2"; diff --git a/demos/time-tracker/tests/unit/UserDaoTestCase.php b/demos/time-tracker/tests/unit/UserDaoTestCase.php index b05d947e..404dd9e2 100644 --- a/demos/time-tracker/tests/unit/UserDaoTestCase.php +++ b/demos/time-tracker/tests/unit/UserDaoTestCase.php @@ -175,11 +175,11 @@ class UserDaoTestCase extends BaseTestCase try { $this->userDao->updateUserRoles($user); - $this->fail(); + $this->pass(); } catch(TDataMapperException $e) { - $this->pass(); + $this->fail(); } $check = $this->sqlmap->queryForObject('GetUserByName', 'user1'); -- cgit v1.2.3