/**
  * @author Lennard Bredenkamp, BFE
  * store TTS relation in Mantis-DB and pass on data to TestLink
  */
 function store_ttslink($p_event, $p_data, $p_bug_id)
 {
     // global $tts_new_ttslink_bug;
     // if ($tts_new_ttslink_bug)
     $args = $_POST;
     if (isset($args['tts_exec_id'], $args['tts_tproject_id'])) {
         //extract data from form POST
         $tts_exec_id = gpc_get_string('tts_exec_id');
         $tts_tproject_id = gpc_get_string('tts_tproject_id');
         //create new TTS relation Object and store in DB
         $tts_relation = new TTSrelation($p_bug_id, $tts_exec_id, $tts_tproject_id);
         $tts_relation->savetoDB();
         pass_to_testlink($tts_tproject_id, $tts_exec_id, $p_bug_id);
         $tts_new_ttslink_bug = false;
     }
 }
form_security_validate('tts_relationship_add');
$f_tts_exec_id = gpc_get_int('exec_id');
$f_tts_tproject_id = gpc_get_int('tproject_id');
$bug_id = gpc_get_string('bug_id');
# user has access to update the bug...
// access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_src_bug_id );
// $f_dest_bug_id_string = str_replace( ',', '|', $f_dest_bug_id_string );
// $f_dest_bug_id_array = explode( '|', $f_dest_bug_id_string );
if ($f_tts_exec_id == '' || $f_tts_tproject_id == '') {
    // print_header_redirect_view( $bug_id );
    # Summary cannot be blank
    // if( is_blank( $this->summary ) ) {
    // error_parameters( lang_get( 'summary' ) );
    error_parameters('(Ausführungs-ID/Testprojekt-ID)');
    trigger_error(ERROR_EMPTY_FIELD, ERROR);
} else {
    // $twin_relation = TTSrelation::loadRelation( $bug_id, $f_tts_exec_id );
    // $twin_relation = loadRelation( $bug_id, $f_tts_exec_id );
    if (!tts_relation_isDuplicate($f_tts_tproject_id, $f_tts_exec_id, $bug_id)) {
        $f_tts_relation = new TTSrelation($bug_id, $f_tts_exec_id, $f_tts_tproject_id);
        $f_tts_relation->savetoDB();
        tts_log_history('add', $f_tts_tproject_id, $f_tts_exec_id, $bug_id);
        //write log entry (code: TTSintegr.API.php)
        pass_to_testlink($f_tts_tproject_id, $f_tts_exec_id, $bug_id);
    } else {
        trigger_error(ERROR_DUPLICATE_FILE, ERROR);
    }
    // else trigger_error( ERROR_DUPLICATE_FILE, "Diese Verknüpfung existiert bereits!" );
}
form_security_purge('tts_relationship_add');
// print_header_redirect_view( $bug_id );