<?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();

$page				= basename(__FILE__);
$test_id			= $_POST['test_id'];
//$test_version_id	= $_POST['test_version_id'];
//$page				= 'test_detail_page.php';
$redirect_page 		= "test_detail_page.php";
if (!empty($_POST['way']))
$redirect_page 		= "test_detail_page.php?way=".$_POST['way'];

session_validate_form_set($_POST, $redirect_page);

$user_properties		= session_get_user_properties();
$user_id				= $user_properties['user_id'];
$username				= $user_properties['username'];
$project_id=-1;

        if (usecase_locked($project_id,$test_id,$username)) {
                 html_print_operation_failed( 'usecase_edit_page',error_report_msg(CAN_NOT_MODIFY_USECASE_LOCKED,usecase_locked_by($project_id,$test_id)), "test_detail_page.php?test_id=".$test_id);
                 exit;
       }


$info_step="N";
if (!empty($_POST['info_step'])) $info_step=$_POST['info_step'];
$parent_step=0;
if (!empty($_POST['parent_step'])) $parent_step=$_POST['parent_step'];

test_add_test_step( $test_id,
					session_validate_form_get_field('location', "", session_use_FCKeditor()),
					session_validate_form_get_field('step_action_required', "", session_use_FCKeditor()),
					session_validate_form_get_field('step_expected_required', "", session_use_FCKeditor()),
					session_validate_form_get_field('step_test_inputs', "", session_use_FCKeditor()),
					$info_step,
					$page,
					$parent_step);


session_validate_form_reset();

html_print_operation_successful( "add_test_step_page", $redirect_page );
?>