summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/App_Code/ProjectDao.php
diff options
context:
space:
mode:
Diffstat (limited to 'demos/time-tracker/protected/App_Code/ProjectDao.php')
-rw-r--r--demos/time-tracker/protected/App_Code/ProjectDao.php115
1 files changed, 60 insertions, 55 deletions
diff --git a/demos/time-tracker/protected/App_Code/ProjectDao.php b/demos/time-tracker/protected/App_Code/ProjectDao.php
index 81902e0c..416c6540 100644
--- a/demos/time-tracker/protected/App_Code/ProjectDao.php
+++ b/demos/time-tracker/protected/App_Code/ProjectDao.php
@@ -20,32 +20,17 @@
*/
class ProjectDao extends BaseDao
{
-/* public function createNewProject($project)
+ public function projectNameExists($projectName)
{
$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);
- }
- }
+ return $sqlmap->queryForObject('ProjectNameExists', $projectName);
+ }
+
+ public function addNewProject($project)
+ {
+ $sqlmap = $this->getConnection();
+ $sqlmap->insert('CreateNewProject', $project);
+ }
public function getProjectByID($projectID)
{
@@ -53,41 +38,61 @@ class ProjectDao extends BaseDao
return $sqlmap->queryForObject('GetProjectByID', $projectID);
}
- public function addUserToProject($project, $user)
+ public function deleteProject($projectID)
{
$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
+ $sqlmap->update('DeleteProject',$projectID);
+ }
+
+ public function addUserToProject($projectID, $username)
+ {
+ $sqlmap = $this->getConnection();
+ $members = $this->getProjectMembers($projectID);
+ if(!in_array($username, $members))
{
- $param['project'] = $project;
- $param['user'] = $user;
- return $sqlmap->insert('AddUserToProject', $param);
- }
+ $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()
+ {
+ $sqlmap = $this->getConnection();
+ return $sqlmap->queryForList('GetAllProjects');
+ }
+
+ 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