} // spare unnecessary queries if (!$field) { header('HTTP/1.1 400 Bad Request'); exit; } $task = Flyspray::GetTaskDetails(Post::val('task_id')); // we better not forget this one ;) if (!$user->can_edit_task($task)) { header('HTTP/1.1 400 Bad Request'); exit; } // pre build some HTML $task['num_assigned'] = count($task['assigned_to']); $task['assigned_to_name'] = reset($task['assigned_to_name']); $prev = Filters::noXSS(str_replace("'", "\\'", tpl_draw_cell($task, $field, '<span class="%s %s">%s</span>'))); $id = sprintf('id="task%d_%s" name="task%d_%s"', $task['task_id'], $field, $task['task_id'], $field); switch ($field) { case 'summary': echo '<input type="text" class="text" ' . $id . ' value="' . Filters::noXSS($task['item_summary']) . '" />'; break; case 'project': echo '<select ' . $id . '>' . tpl_options($fs->projects, $task['project_id']) . ' </select>'; break; case 'progress': $arr = array(); for ($i = 0; $i <= 100; $i += 10) { $arr[$i] = $i . '%'; } echo '<select ' . $id . '>' . tpl_options($arr, $task['percent_complete']) . '
} $fieldname = Post::val('field'); switch ($fieldname) { case 'summary': $args['item_summary'] = Post::val('value'); break; case 'project': $args['project_id'] = Post::num('value'); break; case 'progress': $args['percent_complete'] = Post::num('value'); break; case 'assigned_to': $args['assigned_to'] = Post::val('value'); $fieldname = 'assignedto'; break; default: // now all the custom fields $field = new Field(substr($fieldname, 5)); if ($field->id) { $args[$fieldname] = Post::val('value'); } } // Let our backend function do the rest Backend::edit_task($task, $args); // let's get the updated value $task = Flyspray::GetTaskDetails(Post::val('task_id')); $task['num_assigned'] = count($task['assigned_to']); $task['assigned_to_name'] = reset($task['assigned_to_name']); echo tpl_draw_cell($task, $fieldname, '<span class="%s %s">%s</span>');