X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttTaskHelper.class.php;h=b4644d5131cc182fbae4e7507a15e7e9b6160cc4;hb=56f1fd19f2c9c72878395b3275f03f192ccca082;hp=d238bfbc882b0809ee5346793d2c3d3e519e7047;hpb=1c40fb09e97ff643c80e9b96106d891e6fdbde1b;p=timetracker.git diff --git a/WEB-INF/lib/ttTaskHelper.class.php b/WEB-INF/lib/ttTaskHelper.class.php index d238bfbc..b4644d51 100644 --- a/WEB-INF/lib/ttTaskHelper.class.php +++ b/WEB-INF/lib/ttTaskHelper.class.php @@ -37,7 +37,7 @@ class ttTaskHelper { $mdb2 = getConnection(); $sql = "select id, name, description, status from tt_tasks - where id = $id and team_id = $user->team_id and (status = 0 or status = 1)"; + where id = $id and group_id = $user->group_id and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -61,7 +61,7 @@ class ttTaskHelper { // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name from tt_projects p inner join tt_project_task_binds ptb on (ptb.project_id = p.id and ptb.task_id = $task_id) - where p.team_id = $user->team_id and p.status = 1 order by p.name"; + where p.group_id = $user->group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -77,15 +77,14 @@ class ttTaskHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_tasks where team_id = $user->team_id and name = ". + $sql = "select id from tt_tasks where group_id = $user->group_id and name = ". $mdb2->quote($task_name)." and (status = 1 or status = 0)"; - $res = $mdb2->query($sql); + $res = $mdb2->query($sql); - if (!is_a($res, 'PEAR_Error')) { + if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); - if ($val['id']) { + if ($val['id']) return $val; - } } return false; } @@ -104,7 +103,7 @@ class ttTaskHelper { // Delete project binds to this task from the tasks field in tt_projects table. // Get projects where tasks is not NULL. - $sql = "select id, tasks from tt_projects where team_id = $user->team_id and tasks is not NULL"; + $sql = "select id, tasks from tt_projects where group_id = $user->group_id and tasks is not NULL"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -136,14 +135,15 @@ class ttTaskHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; $name = $fields['name']; $description = $fields['description']; $projects = $fields['projects']; $status = $fields['status']; - $sql = "insert into tt_tasks (team_id, name, description, status) - values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_tasks (group_id, org_id, name, description, status) + values ($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); $last_id = 0; if (is_a($affected, 'PEAR_Error')) @@ -185,7 +185,7 @@ class ttTaskHelper { return $last_id; } - // update function updates a task in database. + // update function updates a task in the database. static function update($fields) { global $user; @@ -199,7 +199,7 @@ class ttTaskHelper { $projects = $fields['projects']; $sql = "update tt_tasks set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description). - ", status = $status where id = $task_id"; + ", status = $status where id = $task_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); @@ -220,8 +220,8 @@ class ttTaskHelper { // Handle task binds in the tasks field of the tt_projects table. // We need to either delete or insert task id in all affected projects. - // Get all not deleted projects for team. - $sql = "select id, tasks from tt_projects where team_id = $user->team_id and status is not NULL"; + // Get all not deleted projects for group. + $sql = "select id, tasks from tt_projects where group_id = $user->group_id and status is not NULL"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) die($res->getMessage()); @@ -238,14 +238,14 @@ class ttTaskHelper { if ($task_ids) { $task_ids .= ",$task_id"; $task_ids = ttTaskHelper::sort($task_ids); - } else - $task_ids = $task_id; + } else + $task_ids = $task_id; - $sql = "update tt_projects set tasks = ".$mdb2->quote($task_ids)." where id = $project_id"; - $affected = $mdb2->exec($sql); - if (is_a($affected, 'PEAR_Error')) - die($affected->getMessage()); - } + $sql = "update tt_projects set tasks = ".$mdb2->quote($task_ids)." where id = $project_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + die($affected->getMessage()); + } } else { // Task needs to be removed from this project. if (in_array($task_id, $task_arr)) {