$all_tasks = ttTeamHelper::getAllTasks($group_id);
foreach ($all_tasks as $task) {
if(in_array($task['id'], $tasks)) {
- $sql = "insert into tt_project_task_binds (project_id, task_id) values($last_id, ".$task['id'].")";
+ $sql = "insert into tt_project_task_binds (project_id, task_id, group_id, org_id)".
+ " values($last_id, ".$task['id'].", $group_id, $org_id)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
static function update($fields) {
global $user;
$mdb2 = getConnection();
-
+
+ $group_id = $user->getActiveGroup();
+ $org_id = $user->org_id;
$project_id = $fields['id']; // Project we are updating.
$name = $fields['name']; // Project name.
$description = $fields['description']; // Project description.
while ($row = $res->fetchRow()) {
$user_rate[$row['id']] = $row['rate'];
}
- $group_id = $user->getActiveGroup();
- $org_id = $user->org_id;
foreach ($users_to_add as $id) {
$sql = "insert into tt_user_project_binds (user_id, project_id, group_id, org_id, rate, status)".
" values($id, $project_id, $group_id, $org_id, ".$user_rate[$id].", 1)";
return false;
}
foreach ($task_binds_to_add as $task_id) {
- $sql = "insert into tt_project_task_binds (project_id, task_id) values($project_id, $task_id)";
+ $sql = "insert into tt_project_task_binds (project_id, task_id, group_id, org_id)".
+ " values($project_id, $task_id, $group_id, $org_id)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
if (is_array($projects)) {
foreach ($projects as $p_id) {
// Insert task binds into tt_project_task_binds table.
- $sql = "insert into tt_project_task_binds (project_id, task_id) values($p_id, $last_id)";
+ $sql = "insert into tt_project_task_binds (project_id, task_id, group_id, org_id)".
+ " values($p_id, $last_id, $group_id, $org_id)";
$affected = $mdb2->exec($sql);
- if (is_a($affected, 'PEAR_Error'))
- return false;
+ if (is_a($affected, 'PEAR_Error'))
+ return false;
- // Add task bind to the tasks field of the tt_projects table.
+ // Add task bind to the tasks field of the tt_projects table.
$sql = "select tasks from tt_projects where id = $p_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
$val = $res->fetchRow();
$task_ids = $val['tasks'];
if ($task_ids) {
- $task_ids .= ",$last_id";
- $task_ids = ttTaskHelper::sort($task_ids);
- } else
- $task_ids = $last_id;
+ $task_ids .= ",$last_id";
+ $task_ids = ttTaskHelper::sort($task_ids);
+ } else
+ $task_ids = $last_id;
$sql = "update tt_projects set tasks = ".$mdb2->quote($task_ids)." where id = $p_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
- }
+ }
}
return $last_id;
}
static function update($fields)
{
global $user;
-
$mdb2 = getConnection();
+ $group_id = $user->getActiveGroup();
+ $org_id = $user->org_id;
$task_id = (int)$fields['task_id'];
$name = $fields['name'];
$description = $fields['description'];
$projects = $fields['projects'];
$sql = "update tt_tasks set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description).
- ", status = $status where id = $task_id and group_id = $user->group_id";
+ ", status = $status where id = $task_id and group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
die($affected->getMessage());
die($affected->getMessage());
if (count($projects) > 0)
foreach ($projects as $p_id) {
- $sql = "insert into tt_project_task_binds (project_id, task_id) values($p_id, $task_id)";
+ $sql = "insert into tt_project_task_binds (project_id, task_id, group_id, org_id)".
+ " values($p_id, $task_id, $group_id, $org_id)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
die($affected->getMessage());
// We need to either delete or insert task id in all affected projects.
// 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";
+ $sql = "select id, tasks from tt_projects where group_id = $group_id and status is not NULL";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
die($res->getMessage());