-
- // getAssignedProjectsForUser - returns an array of projects assigned to a user and associatied with a client.
- static function getAssignedProjectsForUser($client_id)
- {
- global $user;
- $user_id = $user->getActiveUser();
-
- $result = array();
- $mdb2 = getConnection();
-
- // Do a query with inner join to get assigned projects.
- $sql = "select p.id, p.name from tt_projects p
- inner join tt_client_project_binds cpb on (cpb.client_id = $client_id and cpb.project_id = p.id)
- inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id and upb.status = 1)
- where p.team_id = $user->team_id and p.status = 1 order by p.name";
- $res = $mdb2->query($sql);
- if (!is_a($res, 'PEAR_Error')) {
- while ($val = $res->fetchRow()) {
- $result[] = $val;
- }
- }
- return $result;
- }