<?php
# ---------------------------------------------------------------------
# truc is a tool for requirement and use case tracking
# Copyright (C) 2006 ASDIS - http://sf.net/projects/truc
#
# (rth) Initial truc version based on rth
#       Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net
#
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
#----------------------------------------------------------------------

include"./api/include_api.php";
auth_authenticate_user();

session_validate_form_set($_POST, "requirement_edit_page.php");

if($_POST['record_or_file']=="R") {

	$detail = session_validate_form_get_field('req_detail_required', "", session_use_FCKeditor());
} else {

	$detail = "";
}

$project_id			= $_POST["project_id"];
$req_id				= $_POST["req_id"];
$req_version_id		= $_POST["req_ver_id"];
$user_properties		= session_get_user_properties();
$user_id				= $user_properties['user_id'];
$username				= $user_properties['username'];

$reason_for_change	= session_validate_form_get_field("req_reason_change", "", session_use_FCKeditor());
$req_name			= session_validate_form_get_field('req_name_required');
$req_area			= session_validate_form_get_field('req_area');
$req_type			= session_validate_form_get_field('req_type');
$req_status			= session_validate_form_get_field('req_status');
$req_functionality	= session_validate_form_get_field("req_functionality");
$req_priority		= session_validate_form_get_field("req_priority");
$req_release		= session_validate_form_get_field("assigned_release");
$req_assigned_to		= session_validate_form_get_field("req_assigned_to");

        if (requirement_locked($project_id,$req_id,$username)) {
                 html_print_operation_failed( 'req_edit_page',error_report_msg(CAN_NOT_MODIFY_REQUIREMENT_LOCKED,requirement_locked_by($project_id,$req_id)), "requirement_detail_page.php" );
                 exit;
       }

requirement_edit(	$project_id,
					$req_id,
					$req_version_id,
					$req_name,
					$req_area,
					$req_type,
					$req_status,
					$detail,
					$reason_for_change,
					$req_functionality,
					$req_priority,
					$req_release,$req_assigned_to );


session_validate_form_reset();

############################################################################
# EMAIL NOTIFICATION
############################################################################

$recipients		= requirement_get_notify_users($project_id, $req_id);

requirement_email($project_id, $req_id, $recipients, $action="updated");

############################################################################
############################################################################

html_print_operation_successful( 'req_edit_page', "requirement_detail_page.php" );
?>