Exemplo n.º 1
0
 /**
  * Update size of task. Old task sizes are kept as a linked list
  * inside the database, so no information is lost when updating.
  *
  * Returns task object or NULL on failure.
  */
 public static function update_task_size($task_id, $task_size)
 {
     if ($task_size < 0.0) {
         return NULL;
     }
     $task = Sql::get_task_from_id($task_id);
     if ($task && Sql::project_owner_for_id_is_logged_in($task->get_project_id())) {
         $old_size_id = $task->get_size_id();
         $old_size = Sql::get_size($old_size_id);
         $size_id = Sql::create_size_authed($task_size, $old_size_id);
         if ($size_id > 0) {
             $query = new SqlQuery("UPDATE Tasks SET task_sizeid='%s' WHERE task_id='%s' LIMIT 1", $size_id, $task_id);
             if ($query->was_successful()) {
                 $size_change = $task_size - $old_size;
                 Sql::update_todays_remaining_work_authed($task->get_project_id(), $size_change);
                 $task->set_size($task_size);
             }
         }
     }
     return $task;
 }