Пример #1
0
 function load_task_filter($_FORM)
 {
     $current_user =& singleton("current_user");
     $db = new db_alloc();
     // Load up the forms action url
     $rtn["url_form_action"] = $_FORM["url_form_action"];
     $rtn["hide_field_options"] = $_FORM["hide_field_options"];
     //time Load up the filter bits
     has("project") and $rtn["projectOptions"] = project::get_list_dropdown($_FORM["projectType"], $_FORM["projectID"]);
     $_FORM["projectType"] and $rtn["projectType_checked"][$_FORM["projectType"]] = " checked";
     $ops = array("0" => "Nobody");
     $rtn["personOptions"] = page::select_options($ops + person::get_username_list($_FORM["personID"]), $_FORM["personID"]);
     $rtn["managerPersonOptions"] = page::select_options($ops + person::get_username_list($_FORM["managerID"]), $_FORM["managerID"]);
     $rtn["creatorPersonOptions"] = page::select_options(person::get_username_list($_FORM["creatorID"]), $_FORM["creatorID"]);
     $rtn["all_tags"] = task::get_tags(true);
     $rtn["tags"] = $_FORM["tags"];
     $taskType = new meta("taskType");
     $taskType_array = $taskType->get_assoc_array("taskTypeID", "taskTypeID");
     $rtn["taskTypeOptions"] = page::select_options($taskType_array, $_FORM["taskTypeID"]);
     $_FORM["taskView"] and $rtn["taskView_checked_" . $_FORM["taskView"]] = " checked";
     $taskStatii = task::get_task_statii_array();
     $rtn["taskStatusOptions"] = page::select_options($taskStatii, $_FORM["taskStatus"]);
     $_FORM["showDescription"] and $rtn["showDescription_checked"] = " checked";
     $_FORM["showDates"] and $rtn["showDates_checked"] = " checked";
     $_FORM["showCreator"] and $rtn["showCreator_checked"] = " checked";
     $_FORM["showAssigned"] and $rtn["showAssigned_checked"] = " checked";
     $_FORM["showTimes"] and $rtn["showTimes_checked"] = " checked";
     $_FORM["showPercent"] and $rtn["showPercent_checked"] = " checked";
     $_FORM["showPriority"] and $rtn["showPriority_checked"] = " checked";
     $_FORM["showTaskID"] and $rtn["showTaskID_checked"] = " checked";
     $_FORM["showManager"] and $rtn["showManager_checked"] = " checked";
     $_FORM["showProject"] and $rtn["showProject_checked"] = " checked";
     $_FORM["showTags"] and $rtn["showTags_checked"] = " checked";
     $_FORM["showParentID"] and $rtn["showParentID_checked"] = " checked";
     $arrow = " -->";
     $taskDateOps = array("" => "", "new" => "New Tasks", "due_today" => "Due Today", "overdue" => "Overdue", "d_created" => "Date Created" . $arrow, "d_assigned" => "Date Assigned" . $arrow, "d_targetStart" => "Estimated Start" . $arrow, "d_targetCompletion" => "Estimated Completion" . $arrow, "d_actualStart" => "Date Started" . $arrow, "d_actualCompletion" => "Date Completed" . $arrow);
     $rtn["taskDateOptions"] = page::select_options($taskDateOps, $_FORM["taskDate"], 45, false);
     if (!in_array($_FORM["taskDate"], array("new", "due_today", "overdue"))) {
         $rtn["dateOne"] = $_FORM["dateOne"];
         $rtn["dateTwo"] = $_FORM["dateTwo"];
     }
     $task_num_ops = array("" => "All results", 1 => "1 result", 2 => "2 results", 3 => "3 results", 4 => "4 results", 5 => "5 results", 10 => "10 results", 15 => "15 results", 20 => "20 results", 30 => "30 results", 40 => "40 results", 50 => "50 results", 100 => "100 results", 150 => "150 results", 200 => "200 results", 300 => "300 results", 400 => "400 results", 500 => "500 results", 1000 => "1000 results", 2000 => "2000 results", 3000 => "3000 results", 4000 => "4000 results", 5000 => "5000 results", 10000 => "10000 results");
     $rtn["limitOptions"] = page::select_options($task_num_ops, $_FORM["limit"]);
     // unset vars that aren't necessary
     foreach ((array) $_FORM as $k => $v) {
         if (!$v) {
             unset($_FORM[$k]);
         }
     }
     // Get
     $rtn["FORM"] = "FORM=" . urlencode(serialize($_FORM));
     return $rtn;
 }
Пример #2
0
if ($task->get_id()) {
    $TPL["task_taskType"] = $task->get_value("taskTypeID");
} else {
    $TPL["task_children_summary"] = "";
    $TPL["task_taskType"] = "Task";
}
if ($taskID) {
    $TPL["taskTypeImage"] = $task->get_task_image();
    $TPL["taskSelfLink"] = "<a href=\"" . $task->get_url() . "\">" . $task->get_id() . " " . $task->get_name(array("return" => "html")) . "</a>";
    $TPL["main_alloc_title"] = "Task " . $task->get_id() . ": " . $task->get_name() . " - " . APPLICATION_NAME;
    $TPL["task_exists"] = true;
    $q = prepare("SELECT GROUP_CONCAT(pendingTaskID) as pendingTaskIDs FROM pendingTask WHERE taskID = %d", $task->get_id());
    $db->query($q);
    $row = $db->row();
    $TPL["task_pendingTaskIDs"] = $row["pendingTaskIDs"];
    $TPL["task_tags"] = implode(", ", $task->get_tags());
} else {
    $TPL["taskSelfLink"] = "New Task";
    $TPL["main_alloc_title"] = "New Task - " . APPLICATION_NAME;
}
$TPL["tagOptions"] = page::select_options($task->get_tags(true), $task->get_tags(), 300);
if (!$task->get_id()) {
    $TPL["message_help"][] = "Enter a Task Name and click the Save button to create a new Task.";
    $TPL["task_dateTargetStart"] or $TPL["task_dateTargetStart"] = date("Y-m-d");
}
$TPL["task"] = $task;
// Printer friendly view
if ($_GET["media"] == "print") {
    if (has("client")) {
        $client = new client();
        $client->set_id($project->get_value("clientID"));
Пример #3
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);
 }