예제 #1
1
function initializeGui(&$dbHandler, &$argsObj, &$cfgObj, &$tplanMgr, &$tcaseMgr)
{
    $buildMgr = new build_mgr($dbHandler);
    $platformMgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui = new stdClass();
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->build_id = $argsObj->build_id;
    $gui->platform_id = $argsObj->platform_id;
    $gui->execStatusValues = null;
    $gui->can_use_bulk_op = 0;
    $gui->exec_notes_editors = null;
    $gui->bulk_exec_notes_editor = null;
    $gui->req_details = null;
    $gui->attachmentInfos = null;
    $gui->bugs = null;
    $gui->other_exec_cfields = null;
    $gui->ownerDisplayName = null;
    $gui->editorType = $cfgObj->editorCfg['type'];
    $gui->filter_assigned_to = $argsObj->filter_assigned_to;
    $gui->tester_id = $argsObj->user_id;
    $gui->include_unassigned = $argsObj->include_unassigned;
    $gui->tpn_view_status = $argsObj->tpn_view_status;
    $gui->bn_view_status = $argsObj->bn_view_status;
    $gui->bc_view_status = $argsObj->bc_view_status;
    $gui->platform_notes_view_status = $argsObj->platform_notes_view_status;
    $gui->refreshTree = $argsObj->refreshTree;
    if (!$argsObj->status || $argsObj->status == $cfgObj->tc_status['not_run']) {
        $gui->refreshTree = 0;
    }
    $gui->map_last_exec_any_build = null;
    $gui->map_last_exec = null;
    // 20081122 - franciscom
    // Just for the record:
    // doing this here, we avoid to do on processTestSuite() and processTestCase(),
    // but absolutely this will not improve in ANY WAY perfomance, because we do not loop
    // over these two functions.
    $tprojectMgr = new testproject($dbHandler);
    $gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id);
    $build_info = $buildMgr->get_by_id($argsObj->build_id);
    $gui->build_notes = $build_info['notes'];
    $gui->build_is_open = $build_info['is_open'] == 1 ? 1 : 0;
    $gui->execution_types = $tcaseMgr->get_execution_types();
    if ($argsObj->filter_assigned_to) {
        $userSet = tlUser::getByIds($dbHandler, array_values($argsObj->filter_assigned_to));
        if ($userSet) {
            foreach ($userSet as $key => $userObj) {
                $gui->ownerDisplayName[$key] = $userObj->getDisplayName();
            }
        }
    }
    // ------------------------------------------------------------------
    $the_builds = $tplanMgr->get_builds_for_html_options($argsObj->tplan_id);
    $gui->build_name = isset($the_builds[$argsObj->build_id]) ? $the_builds[$argsObj->build_id] : '';
    // 20090419 - franciscom
    $gui->grants = initializeRights($dbHandler, $argsObj->user, $argsObj->tproject_id, $argsObj->tplan_id);
    $gui->exec_mode = initializeExecMode($dbHandler, $cfgObj->exec_cfg, $argsObj->user, $argsObj->tproject_id, $argsObj->tplan_id);
    $rs = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testplan_notes = $rs['notes'];
    // Important note:
    // custom fields for test plan can be edited ONLY on design, that's reason why we are using
    // scope = 'design' instead of 'execution'
    $gui->testplan_cfields = $tplanMgr->html_table_of_custom_field_values($argsObj->tplan_id, 'design', array('show_on_execution' => 1));
    $gui->history_on = manage_history_on($_REQUEST, $_SESSION, $cfgObj->exec_cfg, 'btn_history_on', 'btn_history_off', 'history_on');
    $gui->history_status_btn_name = $gui->history_on ? 'btn_history_off' : 'btn_history_on';
    $dummy = $platformMgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->has_platforms = !is_null($dummy) ? 1 : 0;
    $gui->platform_info['id'] = 0;
    $gui->platform_info['name'] = '';
    if (!is_null($argsObj->platform_id) && $argsObj->platform_id > 0) {
        $gui->platform_info = $platformMgr->getByID($argsObj->platform_id);
    }
    $gui->node_id = $argsObj->id;
    return $gui;
}
예제 #2
0
function saveImportedResultData(&$db, $resultData, $context)
{
    if (!$resultData) {
        return;
    }
    $debugMsg = ' FUNCTION: ' . __FUNCTION__;
    $tables = tlObjectWithDB::getDBTables(array('executions', 'execution_bugs'));
    $l18n = array('import_results_tc_not_found' => '', 'import_results_invalid_result' => '', 'tproject_id_not_found' => '', 'import_results_ok' => '');
    foreach ($l18n as $key => $value) {
        $l18n[$key] = lang_get($key);
    }
    // Get Column definitions to get size dinamically instead of create constants
    $columnDef = array();
    $adodbObj = $db->get_dbmgr_object();
    $columnDef['execution_bugs'] = $adodbObj->MetaColumns($tables['execution_bugs']);
    $keySet = array_keys($columnDef['execution_bugs']);
    foreach ($keySet as $keyName) {
        if (($keylow = strtolower($keyName)) != $keyName) {
            $columnDef['execution_bugs'][$keylow] = $columnDef['execution_bugs'][$keyName];
            unset($columnDef['execution_bugs'][$keyName]);
        }
    }
    $user = new tlUser($context->userID);
    $user->readFromDB($db);
    $tcase_mgr = new testcase($db);
    $resulstCfg = config_get('results');
    $tcaseCfg = config_get('testcase_cfg');
    $resultMap = array();
    $tplan_mgr = null;
    $tc_qty = sizeof($resultData);
    if ($tc_qty) {
        $tplan_mgr = new testplan($db);
        $tproject_mgr = new testproject($db);
        $build_mgr = new build_mgr($db);
    }
    // Need to do checks on common settings
    //
    // test project exists
    //
    // test plan id:
    //              belongs to target test project
    //              is active
    // build id:
    //          belongs to target test plan
    //          is open
    //
    // platform id:
    //          is linked  to target test plan
    //
    // execution type if not present -> set to MANUAL
    //          if presente is valid i.e. inside the TL domain
    //
    $checks = array();
    $checks['status_ok'] = true;
    $checks['msg'] = null;
    $dummy = null;
    if (!is_null($context->tprojectID) && intval($context->tprojectID) > 0) {
        $dummy = array($tproject_mgr->get_by_id($context->tprojectID, array('output' => 'existsByID')));
    } else {
        if (!is_null($context->tprojectName)) {
            $dummy = $tproject_mgr->get_by_name($context->tprojectName, null, array('output' => 'existsByName'));
        }
    }
    $checks['status_ok'] = !is_null($dummy);
    if (!$checks['status_ok']) {
        $checks['msg'][] = sprintf($l18n['tproject_id_not_found'], $context->tprojectID);
    }
    if (!$checks['status_ok']) {
        foreach ($checks['msg'] as $warning) {
            $resultMap[] = array($warning);
        }
    }
    if ($doIt = $checks['status_ok']) {
        $context->tprojectID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    $dummy = null;
    if (!is_null($context->tplanID) && intval($context->tplanID) > 0) {
        $dummy = $tplan_mgr->get_by_id($context->tplanID, array('output' => 'minimun'));
        if (!is_null($dummy)) {
            $dummy['id'] = $context->tplanID;
        }
    } else {
        if (!is_null($context->tplanName)) {
            $dummy = $tplan_mgr->get_by_name($context->tplanName, $context->tprojectID, array('output' => 'minimun'));
            if (!is_null($dummy)) {
                $dummy = $dummy[0];
            }
        }
    }
    if (!is_null($dummy)) {
        $context->tplanID = $dummy['id'];
    }
    if (intval($context->tprojectID) <= 0 && intval($context->tplanID) > 0) {
        $dummy = $tplan_mgr->tree_manager->get_node_hierarchy_info($context->tplanID);
        $context->tprojectID = $dummy['parent_id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    $dummy = null;
    $tplan_mgr->platform_mgr->setTestProjectID($context->tprojectID);
    if (!is_null($context->platformID) && intval($context->platformID) > 0) {
        $dummy = array($tplan_mgr->platform_mgr->getByID($context->platformID));
    } else {
        if (property_exists($context, 'platformName') && !is_null($context->platformName)) {
            if (!is_null($xx = $tplan_mgr->platform_mgr->getID($context->platformName))) {
                $dummy = array(0 => array('id' => $xx));
            }
        }
    }
    if (!is_null($dummy)) {
        $context->platformID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    $optGB = array('tplan_id' => $context->tplanID, 'output' => 'minimun');
    $dummy = null;
    if (!is_null($context->buildID) && intval($context->buildID) > 0) {
        $dummy = array($build_mgr->get_by_id($context->buildID, $optGB));
    } else {
        if (!is_null($context->buildName)) {
            $dummy = $build_mgr->get_by_name($context->buildName, $optGB);
        }
    }
    if (!is_null($dummy)) {
        $context->buildID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    for ($idx = 0; $doIt && $idx < $tc_qty; $idx++) {
        $tester_id = 0;
        $tester_name = '';
        $using_external_id = false;
        $message = null;
        $status_ok = true;
        $tcase_exec = $resultData[$idx];
        // New attribute "execution type" makes old XML import files incompatible
        // Important NOTICE:
        // tcase_exec is passed BY REFERENCE to allow check_exec_values()change execution type if needed
        //
        $checks = check_exec_values($db, $tcase_mgr, $user_mgr, $tcaseCfg, $tcase_exec, $columnDef['execution_bugs']);
        $status_ok = $checks['status_ok'];
        if ($status_ok) {
            $tcase_id = $checks['tcase_id'];
            $tcase_external_id = trim($tcase_exec['tcase_external_id']);
            $tester_id = $checks['tester_id'];
            // external_id has precedence over internal id
            $using_external_id = $tcase_external_id != "";
        } else {
            foreach ($checks['msg'] as $warning) {
                $resultMap[] = array($warning);
            }
        }
        if ($status_ok) {
            $tcase_identity = $using_external_id ? $tcase_external_id : $tcase_id;
            $result_code = strtolower($tcase_exec['result']);
            $result_is_acceptable = isset($resulstCfg['code_status'][$result_code]) ? true : false;
            $notes = $tcase_exec['notes'];
            $message = null;
            $info_on_case = $tplan_mgr->getLinkInfo($context->tplanID, $tcase_id, $context->platformID);
            if (is_null($info_on_case)) {
                $message = sprintf($l18n['import_results_tc_not_found'], $tcase_identity);
            } else {
                if (!$result_is_acceptable) {
                    $message = sprintf($l18n['import_results_invalid_result'], $tcase_identity, $tcase_exec['result']);
                } else {
                    $info_on_case = current($info_on_case);
                    $tcversion_id = $info_on_case['tcversion_id'];
                    $version = $info_on_case['version'];
                    $notes = $db->prepare_string(trim($notes));
                    // N.B.: db_now() returns an string ready to be used in an SQL insert
                    //       example '2008-09-04', while $tcase_exec["timestamp"] => 2008-09-04
                    //
                    $execution_ts = $tcase_exec['timestamp'] != '' ? "'" . $tcase_exec["timestamp"] . "'" : $db->db_now();
                    if ($tester_id != 0) {
                        $tester_name = $tcase_exec['tester'];
                    } else {
                        $tester_name = $user->login;
                        $tester_id = $context->userID;
                    }
                    $addExecDuration = strlen($tcase_exec['execution_duration']) > 0 && is_numeric($tcase_exec['execution_duration']);
                    $sql = " /* {$debugMsg} */ " . " INSERT INTO {$tables['executions']} (build_id,tester_id,status,testplan_id," . " tcversion_id,execution_ts,notes,tcversion_number,platform_id,execution_type" . ($addExecDuration ? ',execution_duration' : '') . ")" . " VALUES ({$context->buildID}, {$tester_id},'{$result_code}',{$context->tplanID}, " . " {$tcversion_id},{$execution_ts},'{$notes}', {$version}, " . " {$context->platformID}, {$tcase_exec['execution_type']}" . ($addExecDuration ? ",{$tcase_exec['execution_duration']}" : '') . ")";
                    $db->exec_query($sql);
                    if (isset($tcase_exec['bug_id']) && !is_null($tcase_exec['bug_id']) && is_array($tcase_exec['bug_id'])) {
                        $execution_id = $db->insert_id($tables['executions']);
                        foreach ($tcase_exec['bug_id'] as $bug_id) {
                            $bug_id = trim($bug_id);
                            $sql = " /* {$debugMsg} */ " . " SELECT execution_id AS check_qty FROM  {$tables['execution_bugs']} " . " WHERE bug_id = '{$bug_id}' AND execution_id={$execution_id} ";
                            $rs = $db->get_recordset($sql);
                            if (is_null($rs)) {
                                $sql = " /* {$debugMsg} */ " . " INSERT INTO {$tables['execution_bugs']} (bug_id,execution_id)" . " VALUES ('" . $db->prepare_string($bug_id) . "', {$execution_id} )";
                                $db->exec_query($sql);
                            }
                        }
                    }
                    $message = sprintf($l18n['import_results_ok'], $tcase_identity, $version, $tester_name, $resulstCfg['code_status'][$result_code], $execution_ts);
                }
            }
        }
        if (!is_null($message)) {
            $resultMap[] = array($message);
        }
    }
    return $resultMap;
}
예제 #3
0
function initializeGui(&$dbHandler, &$argsObj, &$cfgObj, &$tplanMgr)
{
    $buildMgr = new build_mgr($dbHandler);
    $platformMgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui = new stdClass();
    $gui->form_token = $argsObj->form_token;
    $gui->remoteExecFeedback = $gui->user_feedback = '';
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->build_id = $argsObj->build_id;
    $gui->platform_id = $argsObj->platform_id;
    $gui->attachmentInfos = null;
    $gui->refreshTree = 0;
    // Just for the records:
    // doing this here, we avoid to do on processTestSuite() and processTestCase(),
    // but absolutely this will not improve in ANY WAY perfomance, because we do not loop
    // over these two functions.
    $tprojectMgr = new testproject($dbHandler);
    $gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id);
    $build_info = $buildMgr->get_by_id($argsObj->build_id);
    $gui->build_notes = $build_info['notes'];
    $gui->build_is_open = $build_info['is_open'] == 1 ? 1 : 0;
    $dummy = $tplanMgr->get_builds_for_html_options($argsObj->tplan_id);
    $gui->build_name = isset($dummy[$argsObj->build_id]) ? $dummy[$argsObj->build_id] : '';
    $rs = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testplan_notes = $rs['notes'];
    $gui->testplan_name = $rs['name'];
    // Important note:
    // custom fields for test plan can be edited ONLY on design, that's reason why we are using
    // scope = 'design' instead of 'execution'
    $gui->testplan_cfields = $tplanMgr->html_table_of_custom_field_values($argsObj->tplan_id, 'design', array('show_on_execution' => 1));
    $gui->build_cfields = $buildMgr->html_table_of_custom_field_values($argsObj->build_id, $argsObj->tproject_id, 'design', array('show_on_execution' => 1));
    $dummy = $platformMgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->has_platforms = !is_null($dummy) ? 1 : 0;
    $gui->platform_info['id'] = 0;
    $gui->platform_info['name'] = '';
    if (!is_null($argsObj->platform_id) && $argsObj->platform_id > 0) {
        $gui->platform_info = $platformMgr->getByID($argsObj->platform_id);
    }
    $gui->pageTitlePrefix = lang_get('execution_context') . ':';
    return $gui;
}
예제 #4
0
/**
 * 
 *
 */
function contextAsXML(&$dbHandler, $contextSet, &$tplanMgr)
{
    $info = array();
    $tprojectMgr = new testproject($dbHandler);
    $info['tproject'] = $tprojectMgr->get_by_id($contextSet->tproject_id);
    unset($tprojectMgr);
    $info['tplan'] = $tplanMgr->get_by_id($contextSet->tplan_id);
    $buildMgr = new build_mgr($dbHandler);
    $info['build'] = $buildMgr->get_by_id($contextSet->build_id);
    unset($buildMgr);
    $info['platform'] = null;
    $platform_template = '';
    if ($contextSet->platform_id > 0) {
        $platformMgr = new tlPlatform($dbHandler, $contextSet->tproject_id);
        $info['platform'] = $platformMgr->getByID($contextSet->platform_id);
        unset($platformMgr);
        $platform_template = "\n\t" . "<platform>" . "\t\t" . "<name><![CDATA[||PLATFORMNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||PLATFORMID||]]></internal_id>" . "\n\t" . "</platform>";
    }
    $key2loop = array_keys($info);
    foreach ($key2loop as $item_key) {
        if (!is_null($info[$item_key])) {
            $contextInfo[$item_key . '_id'] = $info[$item_key]['id'];
            $contextInfo[$item_key . '_name'] = $info[$item_key]['name'];
        }
    }
    $contextInfo['prefix'] = $info['tproject']['prefix'];
    $xml_root = "<context>{{XMLCODE}}\n</context>";
    $xml_template = "\n\t" . "<testproject>" . "\t\t" . "<name><![CDATA[||TPROJECTNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||TPROJECTID||]]></internal_id>" . "\t\t" . "<prefix><![CDATA[||TPROJECTPREFIX||]]></prefix>" . "\n\t" . "</testproject>" . "\n\t" . "<testplan>" . "\t\t" . "<name><![CDATA[||TPLANNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||TPLANID||]]></internal_id>" . "\n\t" . "</testplan>" . $platform_template . "\n\t" . "<build>" . "\t\t" . "<name><![CDATA[||BUILDNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||BUILDID||]]></internal_id>" . "\n\t" . "</build>";
    $xml_mapping = null;
    $xml_mapping = array("||TPROJECTNAME||" => "tproject_name", "||TPROJECTID||" => 'tproject_id', "||TPROJECTPREFIX||" => "prefix", "||TPLANNAME||" => "tplan_name", "||TPLANID||" => 'tplan_id', "||BUILDNAME||" => "build_name", "||BUILDID||" => 'build_id', "||PLATFORMNAME||" => "platform_name", "||PLATFORMID||" => 'platform_id');
    $mm = array($contextInfo);
    $contextXML = exportDataToXML($mm, $xml_root, $xml_template, $xml_mapping, 'noXMLHeader' == 'noXMLHeader');
    // echo '<pre><xmp>';
    // echo $contextXML;
    // echo '</xmp></pre>';
    return $contextXML;
}
예제 #5
0
 $tcLink = $args->format == FORMAT_MAIL_HTML ? $mail_link : $image_link;
 //$tcLink = '<a href="lib/testcases/archiveData.php?edit=testcase&id=' .
 //          $testcase['tc_id'] . '">' . htmlspecialchars($tcaseName) . '</a>';
 if (!isset($pathCache[$testcase['tc_id']])) {
     $dummy = $tcase_mgr->getPathLayered(array($testcase['tc_id']));
     $pathCache[$testcase['tc_id']] = $dummy[$testcase['testsuite_id']]['value'];
     $levelCache[$testcase['tc_id']] = $dummy[$testcase['testsuite_id']]['level'];
     $ky = current(array_keys($dummy));
     $topCache[$testcase['tc_id']] = $ky;
 }
 $verbosePath = $pathCache[$testcase['tc_id']];
 $level = $levelCache[$testcase['tc_id']];
 if ($args->type == $statusCode['not_run']) {
     $build_mgr = new build_mgr($db);
     if (isset($testcase['assigned_build_id'])) {
         $build_info = $build_mgr->get_by_id($testcase['assigned_build_id']);
         $testcase['assigned_build_name'] = $build_info['name'];
     } else {
         $testcase['assigned_build_name'] = lang_get('unassigned');
     }
     // When not run, test case version, is the version currently linked to test plan
     $topLevelSuites[$topCache[$testcase['tc_id']]]['items'][$level][] = array('suiteName' => $verbosePath, 'level' => $level, 'testTitle' => $tcLink, 'testVersion' => $testcase['version'], 'platformName' => htmlspecialchars($testcase['platform_name']), 'buildName' => htmlspecialchars($testcase['assigned_build_name']), 'testerName' => htmlspecialchars($testerName), 'notes' => strip_tags($testcase['summary']), 'platformID' => $testcase['platform_id']);
 } else {
     // BUGID 3492
     // BUGID 3356
     // When test case has been runned, version must be get from executions.tcversion_number
     if ($gui->bugInterfaceOn) {
         $bugs = get_bugs_for_exec($db, $bugInterface, $testcase['exec_id']);
         //count all test cases that have no bug linked
         if (count($bugs) == 0) {
             $gui->without_bugs_counter += 1;
 */
require_once dirname(__FILE__) . "/../../config.inc.php";
require_once "common.php";
testlinkInitPage($db);
$assignment_mgr = new assignment_mgr($db);
$testplan_mgr = new testplan($db);
$build_mgr = new build_mgr($db);
$templateCfg = templateConfiguration();
$args = init_args($testplan_mgr->tree_manager);
checkRights($db, $_SESSION['currentUser'], $args);
$gui = init_gui($db, $args);
$assignment_count = 0;
$build_name = "";
if ($args->build_id) {
    $assignment_count = $assignment_mgr->get_count_of_assignments_for_build_id($args->build_id);
    $build_info = $build_mgr->get_by_id($args->build_id);
    $build_name = $build_info['name'];
}
if ($assignment_count > 0) {
    if ($args->confirmed) {
        // their deletion has been confirmed, so delete them
        $assignment_mgr->delete_by_build_id($args->build_id);
        $gui->message = sprintf(lang_get('unassigned_all_tcs_msg'), $build_name);
        $gui->refreshTree = $args->refreshTree ? true : false;
    } else {
        // there are assignments, but their deletion has still to be confirmed
        $gui->draw_tc_unassign_button = true;
        $gui->popup_title = lang_get('unassign_all_tcs_msgbox_title');
        $gui->popup_message = sprintf(lang_get('unassign_all_tcs_warning_msg'), $build_name);
        $gui->message = sprintf(lang_get('number_of_assignments_per_build'), $assignment_count, $build_name);
    }
/**
 * render Test Case content for generated documents
 * 
 * @param $integer db DB connection identifier 
 * @return string generated html code
 *
 * @internal revisions
 */
function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context, $indentLevel)
{
    static $req_mgr;
    static $tc_mgr;
    static $build_mgr;
    static $tplan_mgr;
    static $tplan_urgency;
    static $labels;
    static $tcase_prefix;
    static $userMap = array();
    static $cfg;
    static $tables = null;
    static $force = null;
    static $bugInterfaceOn = false;
    static $its;
    static $buildCfields;
    static $statusL10N;
    static $docRepo;
    static $st;
    $code = null;
    $tcInfo = null;
    $tcResultInfo = null;
    $tcase_pieces = null;
    $id = $node['id'];
    $level = $indentLevel;
    $prefix = isset($context['prefix']) ? $context['prefix'] : null;
    $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
    $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
    $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0;
    $build_id = isset($context['build_id']) ? $context['build_id'] : 0;
    // init static elements
    if (!$tables) {
        $st = new stdClass();
        $tables = tlDBObject::getDBTables(array('executions', 'builds', 'execution_tcsteps'));
        $tc_mgr = new testcase($db);
        $tplan_urgency = new testPlanUrgency($db);
        $build_mgr = new build_mgr($db);
        $tplan_mgr = new testplan($db);
        $req_mgr = new requirement_mgr($db);
        list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options);
        if (!is_null($prefix)) {
            $tcase_prefix = $prefix;
        } else {
            list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id);
        }
        $tcase_prefix .= $cfg['testcase']->glue_character;
        $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false;
        $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false;
        $its = null;
        $tproject_mgr = new testproject($db);
        $info = $tproject_mgr->get_by_id($tprojectID);
        $bugInterfaceOn = $info['issue_tracker_enabled'];
        if ($info['issue_tracker_enabled']) {
            $it_mgr = new tlIssueTracker($db);
            $its = $it_mgr->getInterfaceObject($tprojectID);
            unset($it_mgr);
        }
        $statusL10N = null;
        foreach ($cfg['results']['code_status'] as $vc => $vstat) {
            if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) {
                $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]);
            }
        }
        $docRepo = tlAttachmentRepository::create($db);
        $st->locationFilters = $tc_mgr->buildCFLocationMap();
        // change table style in case of single TC printing to not be indented
        $st->table_style = "";
        if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) {
            $st->table_style = 'style="margin-left: 0;"';
        }
        $st->cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => ' colspan = "' . ($cfg['tableColspan'] - 1) . '" ');
        $info = null;
    }
    /** 
     * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, 
     * using existent methods - franciscom - 20090329 
     * Need to get CF with execution scope
     */
    $exec_info = null;
    $getByID['filters'] = null;
    $opt = array();
    $opt['step_exec_notes'] = isset($options['step_exec_notes']) && $options['step_exec_notes'];
    $opt['step_exec_status'] = isset($options['step_exec_status']) && $options['step_exec_status'];
    switch ($options["docType"]) {
        case DOC_TEST_SPEC:
            $getByID['tcversion_id'] = testcase::LATEST_VERSION;
            $getExecutions = false;
            break;
        case SINGLE_TESTCASE:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status'];
            break;
        default:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status'];
            break;
    }
    if ($getExecutions) {
        // Thanks to Evelyn from Cortado, have found a very old issue never reported.
        // 1. create TC-1A VERSION 1
        // 2. add to test plan and execute FAILED ON BUILD 1
        // 3. Request Test Report (Test Plan EXECUTION REPORT).
        //    You will get spec for VERSION 1 and result for VERSION 1 - OK cool!
        // 4. create VERSION 2
        // 5. update linked Test Case Versions
        // 6. do nothing more than repeat step 3
        //    without this fix you will get
        //    You will get spec for VERSION 2 and result for VERSION 1 - Hmmm
        //    and in addition is not clear that execution was on VERSION 1 . No GOOD!!
        //
        // HOW has been fixed ?
        // Getting info about THE CURRENT LINKED test case version and looking for
        // exec info for this.
        //
        // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided
        //
        //
        // Get Linked test case version
        $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id);
        $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " E.execution_type, E.execution_duration, " . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON B.id = E.build_id " . " WHERE 1 = 1 ";
        if (isset($context['exec_id'])) {
            $sql .= " AND E.id=" . intval($context['exec_id']);
        } else {
            $sql .= " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']);
            if ($build_id > 0) {
                $sql .= " AND E.build_id = " . intval($build_id);
            } else {
                // We are looking for LATEST EXECUTION of CURRENT LINKED test case version
                $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']);
            }
            $sql .= " ORDER BY execution_id DESC";
        }
        $exec_info = $db->get_recordset($sql, null, 1);
        $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id'];
        $getByID['filters'] = null;
        $linkedItem = null;
        if (!is_null($exec_info)) {
            $getByID['tcversion_id'] = null;
            $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']);
            if (isset($options['build_cfields']) && $options['build_cfields']) {
                if (!isset($buildCfields[$exec_info[0]['build_id']])) {
                    $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID);
                }
            }
        }
    }
    $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true, 'renderImageInline' => true));
    if ($tcInfo) {
        $tcInfo = $tcInfo[0];
    }
    $external_id = $tcase_prefix . $tcInfo['tc_external_id'];
    $name = htmlspecialchars($node['name']);
    $cfields = array('specScope' => null, 'execScope' => null);
    if ($options['cfields']) {
        // Get custom fields that has specification scope
        // Custom Field values at Test Case VERSION Level
        foreach ($st->locationFilters as $fkey => $fvalue) {
            $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $st->cfieldFormatting, $tcInfo['id']);
        }
        if (!is_null($exec_info)) {
            $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($tcInfo['id'], 'execution', null, $exec_info[0]['execution_id'], $tplan_id, $tprojectID, $st->cfieldFormatting);
        }
    }
    if ($options['toc']) {
        // EXTERNAL ID added
        $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>';
        $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>';
    }
    $code .= '<p>&nbsp;</p><div> <table class="tc" width="90%" ' . $st->table_style . '>';
    $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name;
    // add test case version
    switch ($env->reportType) {
        case DOC_TEST_PLAN_DESIGN:
            $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version'];
            break;
        case DOC_TEST_PLAN_EXECUTION:
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $version_number = $tcInfo['version'];
            break;
        default:
            $version_number = $tcInfo['version'];
            break;
    }
    if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) {
        $code .= '&nbsp;<span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>';
    }
    $code .= "</th></tr>\n";
    if ($options['author']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']);
        if (isset($options['displayDates']) && $options['displayDates']) {
            $dummy = null;
            $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']);
        }
        $code .= "</td></tr>\n";
        if ($tcInfo['updater_id'] > 0) {
            // add updater if available and differs from author OR forced
            if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) {
                $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']);
                if (isset($options['displayDates']) && $options['displayDates']) {
                    $dummy = null;
                    $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']);
                }
                $code .= "</td></tr>\n";
            }
        }
    }
    if ($options['body'] || $options['summary']) {
        $tcase_pieces = array('summary');
    }
    if ($options['body']) {
        $tcase_pieces[] = 'preconditions';
    }
    if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) {
        $tcase_pieces[] = 'steps';
    }
    if (!is_null($tcase_pieces)) {
        // Check user rights in order to understand if can delete attachments here
        //   function hasRight(&$db,$roleQuestion,$tprojectID = null,$tplanID = null,$getAccess=false)
        // $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
        // $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
        $canManageAttachments = false;
        if (isset($context['user']) && !is_null($context['user'])) {
            $canManageAttachments = $context['user']->hasRight($db, 'testplan_execute', $tprojectID, $tplan_id);
        }
        // Multiple Test Case Steps Feature
        foreach ($tcase_pieces as $key) {
            if ($key == 'steps') {
                if (isset($cfields['specScope']['before_steps_results'])) {
                    $code .= $cfields['specScope']['before_steps_results'];
                }
                if (!is_null($tcInfo[$key]) && $tcInfo[$key] != '') {
                    $td_colspan = 3;
                    $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>';
                    $sxni = null;
                    if ($opt['step_exec_notes'] || $opt['step_exec_status']) {
                        $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']);
                        if ($opt['step_exec_notes']) {
                            $td_colspan++;
                            $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>';
                        }
                        if ($opt['step_exec_status']) {
                            $td_colspan++;
                            $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>';
                        }
                    }
                    $code .= '</tr>';
                    $loop2do = count($tcInfo[$key]);
                    for ($ydx = 0; $ydx < $loop2do; $ydx++) {
                        $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>';
                        $nike = !is_null($sxni) && isset($sxni[$tcInfo[$key][$ydx]['id']]) && !is_null($sxni[$tcInfo[$key][$ydx]['id']]);
                        if ($opt['step_exec_notes']) {
                            $code .= '<td>';
                            if ($nike) {
                                $code .= $sxni[$tcInfo[$key][$ydx]['id']]['notes'];
                            }
                            $code .= '</td>';
                        }
                        if ($opt['step_exec_status']) {
                            $code .= '<td>';
                            if ($nike) {
                                $code .= $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']];
                            }
                            $code .= '</td>';
                        }
                        $code .= '</tr>';
                        // Attachment management
                        if ($getExecutions) {
                            if (isset($sxni[$tcInfo[$key][$ydx]['id']])) {
                                $attachInfo = getAttachmentInfos($docRepo, $sxni[$tcInfo[$key][$ydx]['id']]['id'], $tables['execution_tcsteps'], true, 1);
                                if (!is_null($attachInfo)) {
                                    $code .= '<tr><td colspan="' . $td_colspan . '">';
                                    $code .= '<b>' . $labels['exec_attachments'] . '</b><br>';
                                    foreach ($attachInfo as $fitem) {
                                        $code .= '<form method="POST" name="fda' . $fitem['id'] . '" ' . ' id="fda' . $fitem['id'] . "' " . ' action="' . $env->base_href . 'lib/execute/execPrint.php">';
                                        $code .= '<input type="hidden" name="id" value="' . intval($context['exec_id']) . '">';
                                        $code .= '<input type="hidden" name="deleteAttachmentID" value="' . intval($fitem['id']) . '">';
                                        if ($fitem['is_image']) {
                                            $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>";
                                            $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '">';
                                        } else {
                                            $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a>';
                                        }
                                        $code .= '<input type="image" alt="' . $labels['alt_delete_attachment'] . '"' . 'src="' . $env->base_href . TL_THEME_IMG_DIR . 'trash.png"></li></form>';
                                    }
                                    $code .= '</td></tr>';
                                }
                            }
                        }
                        // $getExecutions
                    }
                }
            } else {
                // disable the field if it's empty
                if ($tcInfo[$key] != '') {
                    $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>";
                }
            }
        }
    }
    $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
    // This is what have been choosen DURING DESIGN, but may be we can choose at DESIGN
    // manual and the execute AUTO, or may be choose AUTO and execute MANUAL.
    // After report on MANTIS, seems that we need to provide in output two values:
    // DESIGN execution type
    // EXECUTION execution type
    switch ($tcInfo['execution_type']) {
        case TESTCASE_EXECUTION_TYPE_AUTO:
            $code .= $labels['execution_type_auto'];
            break;
        case TESTCASE_EXECUTION_TYPE_MANUAL:
        default:
            $code .= $labels['execution_type_manual'];
            break;
    }
    $code .= "</td></tr>\n";
    //
    $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration'];
    $code .= "</td></tr>\n";
    if (isset($options['importance']) && $options['importance']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']];
        $code .= "</td></tr>\n";
    }
    // print priority when printing test plan
    if (isset($options['priority']) && $options['priority']) {
        // Get priority of this tc version for this test plan by using testplanUrgency class.
        // Is there maybe a better method than this one?
        $filters = array('tcversion_id' => $tcInfo['id']);
        $opt = array('details' => 'tcversion');
        $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt);
        $prio = $prio_info[$tcInfo['id']]['priority_level'];
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio];
        $code .= "</td></tr>\n";
    }
    // Spacer
    $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>";
    $code .= $cfields['specScope']['standard_location'] . $cfields['execScope'];
    //
    $cfields = null;
    $prio_info = null;
    // $code = null;
    // 20140813
    $relSet = $tc_mgr->getRelations($id);
    if (!is_null($relSet['relations'])) {
        // $fx = str_repeat('&nbsp;',5); // MAGIC allowed
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['relations'] . '</span></td>';
        $code .= '<td>';
        for ($rdx = 0; $rdx < $relSet['num_relations']; $rdx++) {
            if ($relSet['relations'][$rdx]['source_id'] == $id) {
                $ak = 'source_localized';
            } else {
                $ak = 'destination_localized';
            }
            $code .= htmlspecialchars($relSet['relations'][$rdx][$ak]) . ' - ' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['fullExternalID']) . ':' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['name']) . '<br>';
        }
        $code .= '</td></tr>';
    }
    $relSet = null;
    // collect REQ for TC
    if ($options['requirement']) {
        $requirements = $req_mgr->get_all_for_tcase($id);
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
        if (sizeof($requirements)) {
            foreach ($requirements as $req) {
                $code .= htmlspecialchars($req['req_doc_id'] . ":  " . $req['title']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br />';
        }
        $code .= "</td></tr>\n";
    }
    $requirements = null;
    // collect keywords for TC
    if ($options['keyword']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
        $kwSet = $tc_mgr->getKeywords($id, null, array('fields' => 'keyword_id,keywords.keyword'));
        if (sizeof($kwSet)) {
            foreach ($kwSet as $kw) {
                $code .= htmlspecialchars($kw['keyword']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br>';
        }
        $code .= "</td></tr>\n";
    }
    $kwSet = null;
    // Attachments
    $attachSet = (array) $tc_mgr->getAttachmentInfos($id);
    if (count($attachSet) > 0) {
        $code .= '<tr><td> <span class="label">' . $labels['attached_files'] . '</span></td>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 2) . '"><ul>';
        foreach ($attachSet as $item) {
            $fname = "";
            if ($item['title']) {
                $fname .= htmlspecialchars($item['title']) . " : ";
            }
            $fname .= htmlspecialchars($item['file_name']);
            $code .= "<li>{$fname}</li>";
            if ($item['is_image']) {
                $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>';
            } else {
                $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($item['file_name']) . '</a></li>';
            }
        }
        $code .= "</ul></td></tr>";
    }
    $attachSet = null;
    // generate test results data for test report
    if ($options['passfail']) {
        $tsp = $cfg['tableColspan'] - 1;
        $code .= '<tr style="' . "font-weight: bold;background: #EEE;text-align: left;" . '">' . '<td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['execution_details'] . '</td>' . '<td colspan="' . $tsp . '">' . "&nbsp;" . "</b></td></tr>\n";
        $bn = '';
        switch ($env->reportType) {
            case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
                $ib = $build_mgr->get_by_id($build_id);
                $bn = htmlspecialchars($ib['name']);
                break;
            case DOC_TEST_PLAN_EXECUTION:
                if ($exec_info) {
                    $bn = htmlspecialchars($exec_info[0]['build_name']);
                }
                break;
        }
        if ($bn != '') {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['build'] . '</td>' . '<td ' . $tsp . '>' . $bn . "</b></td></tr>\n";
        }
        if (isset($node['assigned_to'])) {
            $crew = explode(',', $node['assigned_to']);
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['assigned_to'] . '</td>' . '<td colspan="' . $tsp . '">';
            $xdx = 0;
            foreach ($crew as $mm) {
                if ($xdx != 0) {
                    $code .= ',';
                }
                $xdx = -1;
                echo $mm . '<br>';
                $code .= gendocGetUserName($db, $mm);
            }
            $code .= "</td></tr>\n";
        }
        if ($exec_info) {
            $settings['cfg'] = $cfg;
            $settings['lbl'] = $labels;
            $settings['opt'] = array('show_notes' => $options['notes']);
            $settings['colspan'] = $cfg['tableColspan'] - 1;
            $code .= buildTestExecResults($db, $its, $exec_info, $settings, $buildCfields);
            // Get Execution Attachments
            $execAttachInfo = getAttachmentInfos($docRepo, $exec_info[0]['execution_id'], $tables['executions'], true, 1);
            if (!is_null($execAttachInfo)) {
                $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">';
                $code .= '<b>' . $labels['exec_attachments'] . '</b><br>';
                foreach ($execAttachInfo as $fitem) {
                    if ($fitem['is_image']) {
                        $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>";
                        $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '"> </li>';
                    } else {
                        $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a></li>';
                    }
                }
                $code .= '</td></tr>';
            }
        } else {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['report_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n";
        }
        $execAttachInfo = null;
        $exec_info = null;
    }
    $code .= "</table>\n</div>\n";
    return $code;
}
예제 #8
0
function initializeGui(&$dbHandler, &$argsObj, &$cfgObj, &$tplanMgr, &$tcaseMgr, &$issueTracker)
{
    $buildMgr = new build_mgr($dbHandler);
    $platformMgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui = new stdClass();
    $gui->showExternalAccessString = true;
    $gui->showImgInlineString = false;
    $gui->issueSummaryForStep = null;
    $gui->addIssueOp = null;
    $gui->allowStepAttachments = true;
    $gui->tlCanCreateIssue = !is_null($issueTracker) && method_exists($issueTracker, 'addIssue');
    $gui->remoteExecFeedback = $gui->user_feedback = '';
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->build_id = $argsObj->build_id;
    $gui->platform_id = $argsObj->platform_id;
    $gui->loadExecDashboard = false;
    $gui->treeFormToken = $argsObj->treeFormToken;
    $gui->import_limit = TL_REPOSITORY_MAXFILESIZE;
    $gui->execStatusValues = createResultsMenu();
    $gui->execStatusValues[$cfgObj->tc_status['not_run']] = '';
    if (isset($gui->execStatusValues[$cfgObj->tc_status['all']])) {
        unset($gui->execStatusValues[$cfgObj->tc_status['all']]);
    }
    $gui->can_use_bulk_op = 0;
    $gui->exec_notes_editors = null;
    $gui->bulk_exec_notes_editor = null;
    $gui->req_details = null;
    $gui->attachmentInfos = null;
    $gui->bugs = null;
    $gui->other_exec_cfields = null;
    $gui->ownerDisplayName = null;
    $gui->editorType = $cfgObj->editorCfg['type'];
    $gui->filter_assigned_to = $argsObj->filter_assigned_to;
    $gui->tester_id = $argsObj->user_id;
    $gui->include_unassigned = $argsObj->include_unassigned;
    $gui->tpn_view_status = $argsObj->tpn_view_status;
    $gui->bn_view_status = $argsObj->bn_view_status;
    $gui->bc_view_status = $argsObj->bc_view_status;
    $gui->platform_notes_view_status = $argsObj->platform_notes_view_status;
    $gui->refreshTree = $argsObj->refreshTree;
    if (!$argsObj->statusSingle || current($argsObj->statusSingle) == $cfgObj->tc_status['not_run']) {
        $gui->refreshTree = 0;
    }
    $gui->map_last_exec_any_build = null;
    $gui->map_last_exec = null;
    // 20081122 - franciscom
    // Just for the records:
    // doing this here, we avoid to do on processTestSuite() and processTestCase(),
    // but absolutely this will not improve in ANY WAY perfomance, because we do not loop
    // over these two functions.
    $tprojectMgr = new testproject($dbHandler);
    $gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id);
    $build_info = $buildMgr->get_by_id($argsObj->build_id);
    $gui->build_notes = $build_info['notes'];
    $gui->build_is_open = $build_info['is_open'] == 1 ? 1 : 0;
    $gui->execution_types = $tcaseMgr->get_execution_types();
    if ($argsObj->filter_assigned_to) {
        $userSet = tlUser::getByIds($dbHandler, array_values($argsObj->filter_assigned_to));
        if ($userSet) {
            foreach ($userSet as $key => $userObj) {
                $gui->ownerDisplayName[$key] = $userObj->getDisplayName();
            }
        }
    }
    // ------------------------------------------------------------------
    $dummy = $tplanMgr->get_builds_for_html_options($argsObj->tplan_id);
    $gui->build_name = isset($dummy[$argsObj->build_id]) ? $dummy[$argsObj->build_id] : '';
    $gui->build_div_title = lang_get('build') . ' ' . $gui->build_name;
    $gui->exec_mode = initializeExecMode($dbHandler, $cfgObj->exec_cfg, $argsObj->user, $argsObj->tproject_id, $argsObj->tplan_id);
    $gui->grants = initializeRights($dbHandler, $argsObj->user, $argsObj->tproject_id, $argsObj->tplan_id);
    $rs = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testplan_notes = $rs['notes'];
    $gui->testplan_div_title = lang_get('test_plan') . ' ' . $rs['name'];
    $argsObj->tplan_apikey = $rs['api_key'];
    // Important note:
    // custom fields for test plan can be edited ONLY on design, that's reason why we are using
    // scope = 'design' instead of 'execution'
    $gui->testplan_cfields = $tplanMgr->html_table_of_custom_field_values($argsObj->tplan_id, 'design', array('show_on_execution' => 1));
    $gui->build_cfields = $buildMgr->html_table_of_custom_field_values($argsObj->build_id, $argsObj->tproject_id, 'design', array('show_on_execution' => 1));
    $gui->history_on = manage_history_on($_REQUEST, $_SESSION, $cfgObj->exec_cfg, 'btn_history_on', 'btn_history_off', 'history_on');
    $gui->history_status_btn_name = $gui->history_on ? 'btn_history_off' : 'btn_history_on';
    $dummy = $platformMgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->has_platforms = !is_null($dummy) ? 1 : 0;
    $gui->platform_info['id'] = 0;
    $gui->platform_info['name'] = '';
    if (!is_null($argsObj->platform_id) && $argsObj->platform_id > 0) {
        $gui->platform_info = $platformMgr->getByID($argsObj->platform_id);
    }
    $gui->platform_div_title = lang_get('platform') . ' ' . $gui->platform_info['name'];
    $gui->issueTrackerIntegrationOn = $gui->tlCanCreateIssue = $gui->tlCanAddIssueNote = false;
    $gui->node_id = $argsObj->id;
    $gui->draw_save_and_exit = $argsObj->caller == 'tcAssignedToMe';
    $gui->issueTrackerCfg = new stdClass();
    $gui->issueTrackerCfg->bugSummaryMaxLength = 100;
    // MAGIC I'm sorry
    $gui->issueTrackerCfg->editIssueAttr = false;
    if (!is_null($issueTracker)) {
        if ($issueTracker->isConnected()) {
            $itsCfg = $issueTracker->getCfg();
            $gui->issueTrackerCfg->bugSummaryMaxLength = $issueTracker->getBugSummaryMaxLength();
            $gui->issueTrackerCfg->editIssueAttr = intval($itsCfg->userinteraction);
            $gui->issueTrackerIntegrationOn = true;
            $gui->accessToIssueTracker = lang_get('link_bts_create_bug') . "({$argsObj->itsCfg['issuetracker_name']})";
            $gui->createIssueURL = $issueTracker->getEnterBugURL();
            $gui->tlCanCreateIssue = method_exists($issueTracker, 'addIssue') && $issueTracker->canCreateViaAPI();
            $gui->tlCanAddIssueNote = method_exists($issueTracker, 'addNote');
        } else {
            $gui->user_feedback = lang_get('issue_tracker_integration_problems');
        }
    }
    // get matadata
    $gui->issueTrackerMetaData = null;
    if ($gui->issueTrackerCfg->editIssueAttr == 1) {
        $gui->issueTrackerMetaData = !is_null($issueTracker) ? getIssueTrackerMetaData($issueTracker) : null;
        $k2c = array('issueType', 'issuePriority', 'artifactVersion', 'artifactComponent');
        foreach ($k2c as $kj) {
            $gui->{$kj} = $argsObj->{$kj};
            $kx = $kj . 'ForStep';
            $gui->{$kx} = $argsObj->{$kx};
        }
    }
    return $gui;
}
$linked_tcversions = $tplan_mgr->get_linked_tcversions($tplan_id);
new dBug($linked_tcversions);
// -------------------------------------------------------------------------------------------
echo "<hr><h2> Build Manager Class </h2>";
echo "<pre> build manager - constructor - build_mgr(&\$db)";
echo "</pre>";
$build_mgr = new build_mgr($db);
new dBug($build_mgr);
$all_builds = $tplan_mgr->get_builds($tplan_id);
$dummy = array_keys($all_builds);
$build_id = $dummy[0];
echo "<pre> build manager - get_by_id(\$id)";
echo "</pre>";
echo "<pre>                 get_by_id({$build_id})";
echo "</pre>";
$build_info = $build_mgr->get_by_id($build_id);
new dBug($build_info);
/*

// getKeywords($testproject_id,$keywordID = null)
$tplan_id=1;
echo "<pre> testplan - getKeywords(\$testproject_id,\$keywordID = null)";echo "</pre>";
echo "<pre>               getKeywords($tplan_id)";echo "</pre>";
$keywords=$tplan_mgr->getKeywords($tplan_id);
new dBug($keywords);


echo "<pre> testplan - get_keywords_map(\$testproject_id)";echo "</pre>";
$tplan_id=1;
echo "<pre>               get_keywords_map($tplan_id)";echo "</pre>";
$keywords_map=$tplan_mgr->get_keywords_map($tplan_id);