# 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
#----------------------------------------------------------------------
# ---------------------------------------------------------------------
# Test Requirement Edit Coverage Action Page
#
# $RCSfile: test_req_edit_coverage_action.php,v $  $Revision: 1.2 $
# ---------------------------------------------------------------------
include "./api/include_api.php";
auth_authenticate_user();
$s_test_details = session_get_properties("test");
$s_test_id = $s_test_details['test_id'];
$assoc_id = $_POST['assoc_id'];
$percent_covered = $_POST['percent_covered'];
$project_id = session_get_project_id();
$page = 'test_detail_page.php';
$redirect_page = "test_detail_page.php?test_id={$s_test_id}&project_id={$project_id}&tab=3";
session_validate_form_set($_POST, $redirect_page);
test_set_percent_req_coverage($assoc_id, $percent_covered);
session_validate_form_reset();
html_print_operation_successful("test_req_coverage_page", $redirect_page);
# ---------------------------------------------------------------------
# $Log: test_req_edit_coverage_action.php,v $
# Revision 1.2  2008/07/21 07:42:34  peter_thal
# small bug fixes for test_detail_page linking parameter
#
# Revision 1.1.1.1  2005/11/30 23:00:58  gth2
# importing initial version - gth
#
# ---------------------------------------------------------------------
function bug_add_bugnote($bug_id, $bugnote)
{
    global $db;
    $bugnote_tbl = BUG_NOTE_TBL;
    $f_bug_id = BUG_NOTE_BUG_ID;
    $f_author = BUG_NOTE_AUTHOR;
    $f_date_created = BUG_NOTE_DATE_CREATED;
    $f_bugnote = BUG_NOTE_DETAIL;
    $author = session_get_username();
    $created_date = date_get_short_dt();
    $q = "INSERT INTO {$bugnote_tbl}\n\t\t  ( {$f_bug_id}, {$f_author}, {$f_date_created}, {$f_bugnote} )\n\t\t  VALUES\n\t\t  ( '{$bug_id}', '{$author}', '{$created_date}', '{$bugnote}' )";
    db_query($db, $q);
    $bugnote_id = db_get_last_autoincrement_id($db);
    $bugnote_id = util_pad_id($bugnote_id);
    if ($GLOBALS['default_notify_flags']['bugnote']) {
        $action = "add_bugnote";
        $project_id = session_get_project_id();
        $s_user_properties = session_get_user_properties();
        $user_id = $s_user_properties['user_id'];
        bug_monitor_attach_user($bug_id);
        # Gather recipients and send email
        $recipients = bug_email_collect_recipients($bug_id, $action);
        bug_email($project_id, $bug_id, $recipients, $action);
    }
    bug_history_log_event($bug_id, lang_get('add_bugnote'), '', $bugnote_id);
}
# ---------------------------------------------------------------------
# rth is a requirement, test, and bugtracking system
# 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
#----------------------------------------------------------------------
# --------------------------------------------------
# Release Add Action Page
#
# $RCSfile: release_add_action.php,v $ $Revision: 1.2 $
# --------------------------------------------------
include "./api/include_api.php";
auth_authenticate_user();
$redirect_page = 'release_page.php';
$release_page = 'release_page.php';
$project_id = session_get_project_id($release_page);
session_validate_form_set($_POST, $redirect_page);
if (admin_release_name_exists($project_id, session_validate_form_get_field('rel_name_required'))) {
    error_report_show($redirect_page, DUPLICATE_RELEASE_NAME);
}
admin_add_release(session_validate_form_get_field('rel_name_required'), session_validate_form_get_field('rel_description'), $project_id, "CREATE RELEASE");
session_validate_form_reset();
html_print_operation_successful("add_release", $release_page);
# ------------------------------------
# $Log: release_add_action.php,v $
# Revision 1.2  2007/02/03 11:58:12  gth2
# no message
#
# Revision 1.1.1.1  2005/11/30 23:00:57  gth2
# importing initial version - gth
#
function testset_add_tests_from_session($testset_properties, $f_status, $property_set)
{
    $checked_tests = array();
    $project_id = session_get_project_id();
    $s_user_properties = session_get_user_properties();
    $s_project_properties = session_get_project_properties();
    $testset_id = $testset_properties['testset_id'];
    $testset_name = admin_get_testset_name($testset_id);
    $build_id = $testset_properties['build_id'];
    $build_name = admin_get_build_name($build_id);
    $release_id = $testset_properties['release_id'];
    $release_name = admin_get_release_name($release_id);
    global $db;
    $testsuite_tbl = TEST_TBL;
    $f_test_id = TEST_TBL . "." . TEST_ID;
    $f_project_id = TEST_TBL . "." . PROJECT_ID;
    $f_deleted = TEST_TBL . "." . TEST_DELETED;
    $f_archived = TEST_TBL . "." . TEST_ARCHIVED;
    $ts_assoc_tbl = TEST_TS_ASSOC_TBL;
    $f_ts_assoc_id = TEST_TS_ASSOC_TBL . "." . TEST_TS_ASSOC_ID;
    $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL . "." . TEST_TS_ASSOC_TEST_ID;
    $q = "SELECT {$f_test_id},\n\t\t\t{$f_ts_assoc_id},\n\t\t\t{$f_status}\n\t     FROM {$ts_assoc_tbl}\n\t     RIGHT JOIN {$testsuite_tbl} ON {$f_ts_assoc_test_id} = {$f_test_id}\n\t     WHERE {$f_project_id} = {$project_id}\n\t     AND {$f_archived} = 'N'\n\t     AND {$f_deleted} = 'N'\n\t     GROUP BY {$f_test_id}";
    $rs = db_query($db, $q);
    while ($row = db_fetch_row($db, $rs)) {
        if (isset($row[$f_status])) {
            # If the checkbox is ticked, then form an association between Test/TestSet
            if (session_records_ischecked($property_set, $row[TEST_ID], $row[$f_status])) {
                $checked_tests[$row[TEST_ID]] = "on";
            }
        }
    }
    testset_edit($testset_id, $checked_tests);
}