debug_message($task->getLastError());
			fatal_error("Could not retreive task!");
		}
		if($project->get($task->project_id) === FALSE){
			debug_message($project->getLastError());
			fatal_error("Could not retreive project!");
		}
		if(!$project->hasRights(PROJECT_RIGHT_EDIT)){
			fatal_error('Insufficent access rights for this project!');
		}
	}

	if($_POST['save']){
		$_POST['due_ts'] = getTSFromInput($_POST['due_ts']);
		$task->updateFromAssocArray($_POST);
		if($task->update()){
			if(!empty($_FILES['attachment_file']['tmp_name'])){
				if($task->addAttachment($_FILES['attachment_file']['tmp_name'], $_FILES['attachment_file']['name'], $_POST['attachment_description']) === FALSE){
					$error_msg .= "Error adding attachment!\n";
					debug_message($task->getLastError());
				}
			}
			if(!empty($_POST['new_item'])){
				if($task->addTaskItem($_POST['new_item'], $_POST['new_item_parent']) === FALSE){
					$error_msg .= "Error adding new task item!\n";
				}
			}
		}else{
			$error_msg .= "Error updating Task!\n";
		}
		if(empty($error_msg) && $_POST['save'] != "Add"){