Esempio n. 1
0
    $TPL["taskDuplicateLink"] = $realtask->get_task_link(array("prefixTaskID" => 1, "return" => "html"));
    $mesg = "This task is a duplicate of " . $TPL["taskDuplicateLink"];
    $TPL["message_help_no_esc"][] = $mesg;
    $TPL["editing_disabled"] = true;
}
// Link off to the duplicate tasks, if this task is the source task
$q = prepare("SELECT taskID FROM task WHERE duplicateTaskID = %d", $task->get_id());
$db->query($q);
while ($row = $db->row()) {
    $realtask = new task();
    $realtask->set_id($row["taskID"]);
    $realtask->select();
    $duds .= "<br>" . $realtask->get_task_link(array("prefixTaskID" => 1, "return" => "html"));
}
$duds and $TPL["message_help_no_esc"][] = "The following tasks have been marked as a duplicate of this task: " . $duds;
$rows = $task->get_pending_tasks();
foreach ((array) $rows as $pendingTaskID) {
    $realtask = new task();
    $realtask->set_id($pendingTaskID);
    $realtask->select();
    unset($st1, $st2);
    if (substr($realtask->get_value("taskStatus"), 0, 6) == "closed") {
        $st1 = "<strike>";
        $st2 = "</strike>";
    } else {
        $wasopen = true;
    }
    $pendingTaskLinks[] = $st1 . $realtask->get_task_link(array("prefixTaskID" => 1, "return" => "html")) . $st2;
}
$is = "was";
$wasopen and $is = "is";
Esempio n. 2
0
 function edit_task($commands, $email_receive)
 {
     $task_fields = $this->get_fields("task");
     // Task commands
     if ($commands["task"]) {
         unset($changes);
         $taskPriorities = config::get_config_item("taskPriorities") or $taskPriorities = array();
         foreach ($taskPriorities as $k => $v) {
             $priorities[strtolower($v["label"])] = $k;
         }
         $people_by_username = person::get_people_by_username();
         // Else edit/create the task ...
         $task = new task();
         if ($commands["task"] && strtolower($commands["task"]) != "new") {
             $task->set_id($commands["task"]);
             if (!$task->select()) {
                 alloc_error("Unable to select task with ID: " . $commands["task"]);
             }
         }
         foreach ($commands as $k => $v) {
             // transform from username to personID
             if ($k == "assign") {
                 $changes[$k] = "personID";
                 $v = $people_by_username[$v]["personID"];
                 $v or alloc_error("Unrecognized username.");
             }
             if ($k == "manage") {
                 $changes[$k] = "managerID";
                 $v = $people_by_username[$v]["personID"];
                 $v or alloc_error("Unrecognized username.");
             }
             if ($k == "estimator") {
                 $changes[$k] = "estimatorID";
                 $v = $people_by_username[$v]["personID"];
                 $v or alloc_error("Unrecognized username.");
             }
             // transform from priority label to priority ID
             if ($k == "priority" && !in_array($v, array(1, 2, 3, 4, 5))) {
                 $v = $priorities[strtolower($v)];
             }
             // so that --type parent becomes --type Parent
             // mysql's referential integrity is case-insensitive :(
             if ($k == "type") {
                 $v = ucwords($v);
             }
             // Plug the value in
             if ($task_fields[$k][0]) {
                 $changes[$k] = $task_fields[$k][0];
                 $task->set_value($task_fields[$k][0], sprintf("%s", $v));
             }
         }
         if (isset($commands["pend"])) {
             $changes["pend"] = implode(",", (array) $task->get_pending_tasks());
         }
         if (isset($commands["reopen"])) {
             $reopen_rows = $task->get_reopen_reminders();
             unset($rr_bits);
             foreach ($reopen_rows as $rr) {
                 $rr_bits[] = $rr["reminderTime"];
             }
             $changes["reopen"] = implode(",", (array) $rr_bits);
         }
         if (isset($commands["tags"])) {
             $changes["tags"] = implode(",", $task->get_tags());
         }
         if (strtolower($commands["task"]) == "new") {
             if (!$commands["desc"] && is_object($email_receive)) {
                 $task->set_value("taskDescription", $email_receive->get_converted_encoding());
             }
         }
         $after_label = "After:  ";
         if (strtolower($commands["task"]) != "new") {
             $str = $this->condense_changes($changes, $task->row());
             $str and $status[] = "msg";
             $str and $message[] = "Before: " . $str;
         } else {
             $after_label = "Fields: ";
         }
         // Save task
         $err = $task->validate();
         if (!$err && $task->save()) {
             $task->select();
             if (isset($commands["pend"])) {
                 $task->add_pending_tasks($commands["pend"]);
                 $changes["pend"] = implode(",", (array) $task->get_pending_tasks());
             }
             if (isset($commands["reopen"])) {
                 $task->add_reopen_reminder($commands["reopen"]);
                 $reopen_rows = $task->get_reopen_reminders();
                 unset($rr_bits);
                 foreach ($reopen_rows as $rr) {
                     $rr_bits[] = $rr["reminderTime"];
                 }
                 $changes["reopen"] = implode(",", (array) $rr_bits);
             }
             if (isset($commands["tags"])) {
                 $task->add_tags(array($commands["tags"]));
                 $changes["tags"] = implode(",", $task->get_tags());
             }
             $str = $this->condense_changes($changes, $task->row());
             $str and $status[] = "msg";
             $str and $message[] = $after_label . $str;
             if ($commands["dip"]) {
                 interestedParty::add_remove_ips($commands["dip"], "task", $task->get_id(), $task->get_value("projectID"));
             }
             if (strtolower($commands["task"]) == "new") {
                 $status[] = "yay";
                 $message[] = "Task " . $task->get_id() . " created.";
             } else {
                 $status[] = "yay";
                 $message[] = "Task " . $task->get_id() . " updated.";
             }
             // Problems
         } else {
             alloc_error("Problem updating task: " . implode("\n", (array) $err));
         }
     }
     return array($status, $message);
 }