summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/App_Code/ProjectDao.php
blob: 0a0771e3ce254cca46d1d679a9330bdf8e66d607 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
 * Project DAO class file.
 *
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2006 PradoSoft
 * @license http://www.pradosoft.com/license/
 * @version $Revision: $  $16/07/2006: $
 * @package Demos
 */

/**
 * Project DAO class.
 *
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 * @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);
	}
}

?>