Exemplo n.º 1
0
function prj_beginCopyTasks($pid, $source_task)
{
    global $_TABLES, $_CONF, $_USER;
    $insertID = prj_insertTask($pid, 0);
    $sql = "select tid, pid, lhs, rhs, priority_id, status_id, duration_type_id, progress_id, name, parent_task, description, notification_enabled_flag, keywords, ";
    $sql .= "create_date, start_date, estimated_end_date, planned_end_date, actual_end_date, last_updated_date, duration, progress, ";
    $sql .= "make_private_enabled_flag from {$_TABLES['prj_tasks']} where tid='{$source_task}' and pid='{$pid}'";
    $res = DB_query($sql);
    $A = DB_fetchArray($res);
    $A['tid'] = $insertID;
    $A['name'] = "Copy of " . $A['name'];
    prj_updateTask($A);
    //copy permissions
    $sql = "insert into {$_TABLES['prj_projPerms']} (pid, taskid, uid, gid, viewread, writechange, fullaccess, seedetails) ";
    $sql .= "(select '{$pid}','{$insertID}', uid, gid, viewread, writechange, fullaccess, seedetails  from {$_TABLES['prj_projPerms']} ";
    $sql .= "where taskid='{$source_task}' and pid='{$pid}')";
    DB_query($sql);
    //copy ownership
    $sql = "insert into {$_TABLES['prj_task_users']} (tid, uid, role) ";
    $sql .= "(select '{$insertID}', uid, role from {$_TABLES['prj_task_users']} where tid='{$source_task}')";
    DB_query($sql);
    prj_copyProjectTasks($pid, $pid, $source_task, $insertID, 'Copy of ');
}
Exemplo n.º 2
0
     $newrec['actual_end_date'] = pm_convertdate($newrec['actual_end_date']);
 }
 $newrec['planned_end_date'] = pm_convertdate($newrec['planned_end_date']);
 $newrec['create_date'] = pm_getdate();
 $newrec['last_updated_date'] = pm_getdate();
 if ($newrec['actual_end_date'] < $newrec['start_date']) {
     $newrec['actual_end_date'] = $newrec['start_date'] + 604800;
     //add 1 week to the start date...
 }
 if ($newrec['estimated_end_date'] < $newrec['start_date']) {
     $newrec['estimated_end_date'] = $newrec['start_date'] + 604800;
     //add 1 week to the start date...
 }
 $newrec['tid'] = prj_insertTask($pid, $parent_task);
 // Insert the new record and update the lhs and rhs values
 prj_updateTask($newrec);
 // Update the new record values
 if (empty($newrec['resource'])) {
     DB_query("INSERT INTO {$_TABLES['prj_task_users']} (tid, uid, role) VALUES ('{$newrec['tid']}', {$uid}, 'o')");
 } else {
     DB_query("INSERT INTO {$_TABLES['prj_task_users']} (tid, uid, role) VALUES ('{$newrec['tid']}', {$newrec['resource']},'o')");
 }
 /*********************************************/
 //create new task default permissions here
 //whoever created it, gets full perms.
 /*********************************************/
 $sql = "insert into {$_TABLES['prj_projPerms']} (pid, taskID, uid, gid, viewRead, writeChange, fullAccess, seeDetails) values ";
 $sql .= "(";
 $sql .= "'{$pid}',";
 $sql .= "'{$newrec['tid']}',";
 $sql .= "'{$uid}',";