예제 #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 initialize_gui(&$dbHandler, $argsObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $req_mgr = new requirement_mgr($dbHandler);
    $commandMgr = new reqCommands($db);
    $gui = $commandMgr->initGuiBean();
    $gui->req_cfg = config_get('req_cfg');
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = has_rights($db, "mgt_modify_req");
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->glueChar = config_get('testcase_cfg')->glue_character;
    $gui->pieceSep = config_get('gui_title_separator_1');
    $gui->req_id = $argsObj->req_id;
    $gui->req_versions = $req_mgr->get_by_id($gui->req_id);
    $gui->req = current($gui->req_versions);
    $gui->req_coverage = $req_mgr->get_coverage($gui->req_id);
    // This seems weird but is done to adapt template than can display multiple
    // requirements. This logic has been borrowed from test case versions management
    $gui->current_version[0] = array($gui->req);
    // BUGID 2877 - Custom Fields linked to Requirement Versions
    $gui->cfields_current_version[0] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $gui->req['version_id'], $argsObj->tproject_id);
    // Now CF for other Versions
    $gui->other_versions[0] = null;
    $gui->cfields_other_versions[] = null;
    if (count($gui->req_versions) > 1) {
        $gui->other_versions[0] = array_slice($gui->req_versions, 1);
        $loop2do = count($gui->other_versions[0]);
        for ($qdx = 0; $qdx < $loop2do; $qdx++) {
            $target_version = $gui->other_versions[0][$qdx]['version_id'];
            $gui->cfields_other_versions[0][$qdx] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $target_version, $argsObj->tproject_id);
        }
    }
    $gui->show_title = false;
    $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->req['title'];
    $gui->showReqSpecTitle = $argsObj->showReqSpecTitle;
    if ($gui->showReqSpecTitle) {
        $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->req['req_spec_title'];
    }
    // BUGID 2877 - Custom Fields linked to Requirement Versions
    // $gui->cfields = array();
    // $gui->cfields[] = $req_mgr->html_table_of_custom_field_values($gui->req_id,$argsObj->tproject_id);
    $gui->attachments[$gui->req_id] = getAttachmentInfosFrom($req_mgr, $gui->req_id);
    $gui->attachmentTableName = $req_mgr->getAttachmentTableName();
    $gui->reqStatus = init_labels($gui->req_cfg->status_labels);
    $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels);
    // added req relations for BUGID 1748
    $gui->req_relations = FALSE;
    $gui->req_relation_select = FALSE;
    $gui->testproject_select = FALSE;
    $gui->req_add_result_msg = isset($argsObj->relation_add_result_msg) ? $argsObj->relation_add_result_msg : "";
    if ($gui->req_cfg->relations->enable) {
        $gui->req_relations = $req_mgr->get_relations($gui->req_id);
        $gui->req_relation_select = $req_mgr->init_relation_type_select();
        if ($gui->req_cfg->relations->interproject_linking) {
            $gui->testproject_select = initTestprojectSelect($db, $argsObj, $tproject_mgr);
        }
    }
    return $gui;
}
예제 #3
0
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, &$argsObj)
{
    $req_spec_mgr = new requirement_spec_mgr($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $commandMgr = new reqSpecCommands($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->refreshTree = $argsObj->refreshTree;
    $gui->req_spec_cfg = config_get('req_spec_cfg');
    $gui->req_cfg = config_get('req_cfg');
    $gui->external_req_management = $gui->req_cfg->external_req_management == ENABLED ? 1 : 0;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = $argsObj->user->hasRight($dbHandler, "mgt_modify_req", $argsObj->tproject_id);
    $gui->req_spec = $req_spec_mgr->get_by_id($argsObj->req_spec_id);
    $gui->revCount = $req_spec_mgr->getRevisionsCount($argsObj->req_spec_id);
    $gui->req_spec_id = $argsObj->req_spec_id;
    $gui->parentID = $argsObj->req_spec_id;
    $gui->req_spec_revision_id = $gui->req_spec['revision_id'];
    $gui->name = $gui->req_spec['title'];
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->main_descr = lang_get('req_spec_short') . config_get('gui_title_separator_1') . "[{$gui->req_spec['doc_id']}] :: " . $gui->req_spec['title'];
    $gui->refresh_tree = 'no';
    $gui->cfields = $req_spec_mgr->html_table_of_custom_field_values($argsObj->req_spec_id, $gui->req_spec_revision_id, $argsObj->tproject_id);
    $gui->attachments = $req_spec_mgr->getAttachmentInfos($argsObj->req_spec_id);
    $gui->requirements_count = $req_spec_mgr->get_requirements_count($argsObj->req_spec_id);
    $gui->reqSpecTypeDomain = init_labels($gui->req_spec_cfg->type_labels);
    $prefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->direct_link = $_SESSION['basehref'] . 'linkto.php?tprojectPrefix=' . urlencode($prefix) . '&item=reqspec&id=' . urlencode($gui->req_spec['doc_id']);
    $gui->actions = initializeActions($gui);
    return $gui;
}
예제 #4
0
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, &$argsObj)
{
    $req_spec_mgr = new requirement_spec_mgr($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $commandMgr = new reqSpecCommands($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->req_spec_cfg = config_get('req_spec_cfg');
    $gui->req_cfg = config_get('req_cfg');
    // 20100810 - asimon - BUGID 3317: disabled total count of requirements by default
    $gui->external_req_management = $gui->req_cfg->external_req_management == ENABLED ? 1 : 0;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = has_rights($db, "mgt_modify_req");
    $gui->req_spec = $req_spec_mgr->get_by_id($argsObj->req_spec_id);
    $gui->req_spec_id = $argsObj->req_spec_id;
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->name = $gui->req_spec['title'];
    $gui->main_descr = lang_get('req_spec_short') . config_get('gui_title_separator_1') . "[{$gui->req_spec['doc_id']}] :: " . $gui->req_spec['title'];
    $gui->refresh_tree = 'no';
    $gui->cfields = $req_spec_mgr->html_table_of_custom_field_values($argsObj->req_spec_id, $argsObj->tproject_id);
    $gui->attachments = getAttachmentInfosFrom($req_spec_mgr, $argsObj->req_spec_id);
    $gui->requirements_count = $req_spec_mgr->get_requirements_count($argsObj->req_spec_id);
    $gui->reqSpecTypeDomain = init_labels($gui->req_spec_cfg->type_labels);
    /* contribution BUGID 2999, show direct link */
    $prefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->direct_link = $_SESSION['basehref'] . 'linkto.php?tprojectPrefix=' . urlencode($prefix) . '&item=reqspec&id=' . urlencode($gui->req_spec['doc_id']);
    return $gui;
}
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, $argsObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $itemMgr = new requirement_spec_mgr($dbHandler);
    $commandMgr = new reqSpecCommands($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->itemCfg = config_get('req_spec_cfg');
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = $argsObj->hasRight($dbHandler, "mgt_modify_req", $argsObj->tproject_id);
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->glueChar = config_get('testcase_cfg')->glue_character;
    $gui->pieceSep = config_get('gui_title_separator_1');
    $gui->item_id = $argsObj->item_id;
    $info = $itemMgr->getRevisionByID($gui->item_id, array('decode_user' => true));
    $gui->item = $info;
    $gui->cfields = $itemMgr->html_table_of_custom_field_values(null, $gui->item_id, $argsObj->tproject_id);
    $gui->show_title = false;
    $gui->main_descr = lang_get('req_spec') . $gui->pieceSep . $gui->item['name'];
    $gui->showContextInfo = $argsObj->showContextInfo;
    if ($gui->showContextInfo) {
        $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->item['name'];
    }
    $gui->itemSpecStatus = null;
    $gui->itemTypeDomain = init_labels($gui->itemCfg->type_labels);
    return $gui;
}
예제 #6
0
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, $argsObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $req_mgr = new requirement_mgr($dbHandler);
    $commandMgr = new reqCommands($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->req_cfg = config_get('req_cfg');
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = has_rights($dbHandler, "mgt_modify_req");
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->glueChar = config_get('testcase_cfg')->glue_character;
    $gui->pieceSep = config_get('gui_title_separator_1');
    $gui->item_id = $argsObj->item_id;
    // identify item is version or revision ?
    $node_type_id = $req_mgr->tree_mgr->get_available_node_types();
    $node_id_type = array_flip($node_type_id);
    $item = $req_mgr->tree_mgr->get_node_hierarchy_info($gui->item_id);
    // TICKET 4702
    // target_is is db id of item, item['id'] is the REQ ID.
    // for several logics we need to DB id (target_id)
    $info = null;
    switch ($node_id_type[$item['node_type_id']]) {
        case 'requirement_version':
            $info = $req_mgr->get_version($gui->item_id);
            $info['revision_id'] = -1;
            $info['target_id'] = $info['version_id'];
            break;
        case 'requirement_revision':
            $info = $req_mgr->get_revision($gui->item_id);
            $info['target_id'] = $info['revision_id'];
            break;
    }
    $gui->item = $info;
    $gui->cfields = $req_mgr->html_table_of_custom_field_values(null, $gui->item_id, $argsObj->tproject_id);
    $gui->show_title = false;
    $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->item['title'];
    $gui->showReqSpecTitle = $argsObj->showReqSpecTitle;
    if ($gui->showReqSpecTitle) {
        $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->item['req_spec_title'];
    }
    $gui->reqStatus = init_labels($gui->req_cfg->status_labels);
    $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels);
    return $gui;
}
예제 #7
0
function initializeGui(&$dbHandler, &$argsObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $gui = new stdClass();
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tprojectID) . config_get('testcase_cfg')->glue_character;
    $gui->mainCaption = lang_get('testproject') . " " . $argsObj->tprojectName;
    $gui->importance = config_get('testcase_importance_default');
    $gui->creation_date_from = null;
    $gui->creation_date_to = null;
    $gui->modification_date_from = null;
    $gui->modification_date_to = null;
    $gui->search_important_notice = sprintf(lang_get('search_important_notice'), $argsObj->tprojectName);
    $gui->design_cf = $tproject_mgr->cfield_mgr->get_linked_cfields_at_design($argsObj->tprojectID, cfield_mgr::ENABLED, null, 'testcase');
    $gui->keywords = $tproject_mgr->getKeywords($argsObj->tprojectID);
    $gui->filter_by['design_scope_custom_fields'] = !is_null($gui->design_cf);
    $gui->filter_by['keyword'] = !is_null($gui->keywords);
    $reqSpecSet = $tproject_mgr->genComboReqSpec($argsObj->tprojectID);
    $gui->filter_by['requirement_doc_id'] = !is_null($reqSpecSet);
    $gui->option_importance = array(0 => '', HIGH => lang_get('high_importance'), MEDIUM => lang_get('medium_importance'), LOW => lang_get('low_importance'));
    return $gui;
}
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, &$argsObj)
{
    $req_spec_mgr = new requirement_spec_mgr($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $commandMgr = new reqSpecCommands($dbHandler, $argsObj->tproject_id);
    $gui = $commandMgr->initGuiBean();
    $gui->refreshTree = $argsObj->refreshTree;
    $gui->req_spec_cfg = config_get('req_spec_cfg');
    $gui->req_cfg = config_get('req_cfg');
    $gui->external_req_management = $gui->req_cfg->external_req_management == ENABLED ? 1 : 0;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = has_rights($db, "mgt_modify_req");
    $gui->req_spec = $req_spec_mgr->get_by_id($argsObj->req_spec_id);
    $gui->revCount = $req_spec_mgr->getRevisionsCount($argsObj->req_spec_id);
    $gui->req_spec_id = intval($argsObj->req_spec_id);
    $gui->parentID = $argsObj->req_spec_id;
    $gui->req_spec_revision_id = $gui->req_spec['revision_id'];
    $gui->name = $gui->req_spec['title'];
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->main_descr = lang_get('req_spec_short') . config_get('gui_title_separator_1') . "[{$gui->req_spec['doc_id']}] :: " . $gui->req_spec['title'];
    $gui->refresh_tree = 'no';
    $gui->cfields = $req_spec_mgr->html_table_of_custom_field_values($gui->req_spec_id, $gui->req_spec_revision_id, $argsObj->tproject_id);
    $gui->attachments = getAttachmentInfosFrom($req_spec_mgr, $argsObj->req_spec_id);
    $gui->requirements_count = $req_spec_mgr->get_requirements_count($argsObj->req_spec_id);
    $gui->reqSpecTypeDomain = init_labels($gui->req_spec_cfg->type_labels);
    $prefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->direct_link = $_SESSION['basehref'] . 'linkto.php?tprojectPrefix=' . urlencode($prefix) . '&item=reqspec&id=' . urlencode($gui->req_spec['doc_id']);
    $gui->fileUploadURL = $_SESSION['basehref'] . $req_spec_mgr->getFileUploadRelativeURL($gui->req_spec_id);
    $gui->delAttachmentURL = $_SESSION['basehref'] . $req_spec_mgr->getDeleteAttachmentRelativeURL($gui->req_spec_id);
    $gui->fileUploadMsg = '';
    $gui->import_limit = TL_REPOSITORY_MAXFILESIZE;
    $gui->btn_import_req_spec = '';
    $gui->reqMgrSystemEnabled = 0;
    if (!is_null($reqMgrSystem = $commandMgr->getReqMgrSystem())) {
        $gui->btn_import_req_spec = sprintf(lang_get('importViaAPI'), $reqMgrSystem['reqmgrsystem_name']);
        $gui->reqMgrSystemEnabled = 1;
    }
    return $gui;
}
function saveImportedTCData(&$db, $tcData, $tproject_id, $container_id, $userID, $kwMap, $duplicatedLogic = array('hitCriteria' => 'name', 'actionOnHit' => null))
{
    static $messages;
    static $fieldSizeCfg;
    static $feedbackMsg;
    static $tcase_mgr;
    static $tproject_mgr;
    static $req_spec_mgr;
    static $req_mgr;
    static $safeSizeCfg;
    static $linkedCustomFields;
    static $tprojectHas;
    static $reqSpecSet;
    static $getVersionOpt;
    static $userObj;
    if (!$tcData) {
        return;
    }
    // $tprojectHas = array('customFields' => false, 'reqSpec' => false);
    $hasCustomFieldsInfo = false;
    $hasRequirements = false;
    if (is_null($messages)) {
        $feedbackMsg = array();
        $messages = array();
        $fieldSizeCfg = config_get('field_size');
        $tcase_mgr = new testcase($db);
        $tproject_mgr = new testproject($db);
        $req_spec_mgr = new requirement_spec_mgr($db);
        $req_mgr = new requirement_mgr($db);
        $userObj = new tlUser();
        $k2l = array('already_exists_updated', 'original_name', 'testcase_name_too_long', 'start_warning', 'end_warning', 'testlink_warning', 'hit_with_same_external_ID');
        foreach ($k2l as $k) {
            $messages[$k] = lang_get($k);
        }
        $messages['start_feedback'] = $messages['start_warning'] . "\n" . $messages['testlink_warning'] . "\n";
        $messages['cf_warning'] = lang_get('no_cf_defined_can_not_import');
        $messages['reqspec_warning'] = lang_get('no_reqspec_defined_can_not_import');
        $feedbackMsg['cfield'] = lang_get('cf_value_not_imported_missing_cf_on_testproject');
        $feedbackMsg['tcase'] = lang_get('testcase');
        $feedbackMsg['req'] = lang_get('req_not_in_req_spec_on_tcimport');
        $feedbackMsg['req_spec'] = lang_get('req_spec_ko_on_tcimport');
        // because name can be changed automatically during item creation
        // to avoid name conflict adding a suffix automatically generated,
        // is better to use a max size < max allowed size
        $safeSizeCfg = new stdClass();
        $safeSizeCfg->testcase_name = $fieldSizeCfg->testcase_name * 0.8;
        // Get CF with scope design time and allowed for test cases linked to this test project
        $linkedCustomFields = $tcase_mgr->cfield_mgr->get_linked_cfields_at_design($tproject_id, 1, null, 'testcase', null, 'name');
        $tprojectHas['customFields'] = !is_null($linkedCustomFields);
        $reqSpecSet = $tproject_mgr->getReqSpec($tproject_id, null, array('RSPEC.id', 'NH.name AS title', 'RSPEC.doc_id as rspec_doc_id', 'REQ.req_doc_id'), 'req_doc_id');
        $tprojectHas['reqSpec'] = !is_null($reqSpecSet) && count($reqSpecSet) > 0;
        $getVersionOpt = array('output' => 'minimun');
        $tcasePrefix = $tproject_mgr->getTestCasePrefix($tproject_id);
    }
    $resultMap = array();
    $tc_qty = sizeof($tcData);
    $userIDCache = array();
    for ($idx = 0; $idx < $tc_qty; $idx++) {
        $tc = $tcData[$idx];
        $name = $tc['name'];
        $summary = $tc['summary'];
        $steps = $tc['steps'];
        // I've changed value to use when order has not been provided
        // from testcase:DEFAULT_ORDER to a counter, because with original solution
        // an issue arise with 'save execution and go next'
        // if use has not provided order I think is OK TestLink make any choice.
        $node_order = isset($tc['node_order']) ? intval($tc['node_order']) : $idx + 1;
        $internalid = $tc['internalid'];
        $preconditions = $tc['preconditions'];
        $exec_type = isset($tc['execution_type']) ? $tc['execution_type'] : TESTCASE_EXECUTION_TYPE_MANUAL;
        $importance = isset($tc['importance']) ? $tc['importance'] : MEDIUM;
        $externalid = $tc['externalid'];
        if (intval($externalid) <= 0) {
            $externalid = null;
        }
        $personID = $userID;
        if (!is_null($tc['author_login'])) {
            if (isset($userIDCache[$tc['author_login']])) {
                $personID = $userIDCache[$tc['author_login']];
            } else {
                $userObj->login = $tc['author_login'];
                if ($userObj->readFromDB($db, tlUser::USER_O_SEARCH_BYLOGIN) == tl::OK) {
                    $personID = $userObj->dbID;
                }
                // I will put always a valid userID on this cache,
                // this way if author_login does not exit, and is used multiple times
                // i will do check for existence JUST ONCE.
                $userIDCache[$tc['author_login']] = $personID;
            }
        }
        $name_len = tlStringLen($name);
        if ($name_len > $fieldSizeCfg->testcase_name) {
            // Will put original name inside summary
            $xx = $messages['start_feedback'];
            $xx .= sprintf($messages['testcase_name_too_long'], $name_len, $fieldSizeCfg->testcase_name) . "\n";
            $xx .= $messages['original_name'] . "\n" . $name . "\n" . $messages['end_warning'] . "\n";
            $summary = nl2br($xx) . $summary;
            $name = tlSubStr($name, 0, $safeSizeCfg->testcase_name);
        }
        $kwIDs = null;
        if (isset($tc['keywords']) && $tc['keywords']) {
            $kwIDs = implode(",", buildKeywordList($kwMap, $tc['keywords']));
        }
        $doCreate = true;
        if ($duplicatedLogic['actionOnHit'] == 'update_last_version') {
            switch ($duplicatedLogic['hitCriteria']) {
                case 'name':
                    $info = $tcase_mgr->getDuplicatesByName($name, $container_id);
                    break;
                case 'internalID':
                    $dummy = $tcase_mgr->tree_manager->get_node_hierarchy_info($internalid, $container_id);
                    if (!is_null($dummy)) {
                        $info = null;
                        $info[$internalid] = $dummy;
                    }
                    break;
                case 'externalID':
                    $info = $tcase_mgr->get_by_external($externalid, $container_id);
                    break;
            }
            if (!is_null($info)) {
                $tcase_qty = count($info);
                switch ($tcase_qty) {
                    case 1:
                        $doCreate = false;
                        $tcase_id = key($info);
                        $last_version = $tcase_mgr->get_last_version_info($tcase_id, $getVersionOpt);
                        $tcversion_id = $last_version['id'];
                        $ret = $tcase_mgr->update($tcase_id, $tcversion_id, $name, $summary, $preconditions, $steps, $personID, $kwIDs, $node_order, $exec_type, $importance);
                        $ret['id'] = $tcase_id;
                        $ret['tcversion_id'] = $tcversion_id;
                        $resultMap[] = array($name, $messages['already_exists_updated']);
                        break;
                    case 0:
                        $doCreate = true;
                        break;
                    default:
                        $doCreate = false;
                        break;
                }
            }
        }
        if ($doCreate) {
            // Want to block creation of with existent EXTERNAL ID, if containers ARE DIFFERENT.
            $item_id = intval($tcase_mgr->getInternalID($externalid, array('tproject_id' => $tproject_id)));
            if ($item_id > 0) {
                // who is his parent ?
                $owner = $tcase_mgr->getTestSuite($item_id);
                if ($owner != $container_id) {
                    // Get full path of existent Test Cases
                    $stain = $tcase_mgr->tree_manager->get_path($item_id, null, 'name');
                    $n = count($stain);
                    $stain[$n - 1] = $tcasePrefix . config_get('testcase_cfg')->glue_character . $externalid . ':' . $stain[$n - 1];
                    $stain = implode('/', $stain);
                    $resultMap[] = array($name, $messages['hit_with_same_external_ID'] . $stain);
                    $doCreate = false;
                }
            }
        }
        if ($doCreate) {
            $createOptions = array('check_duplicate_name' => testcase::CHECK_DUPLICATE_NAME, 'action_on_duplicate_name' => $duplicatedLogic['actionOnHit'], 'external_id' => $externalid);
            if ($ret = $tcase_mgr->create($container_id, $name, $summary, $preconditions, $steps, $personID, $kwIDs, $node_order, testcase::AUTOMATIC_ID, $exec_type, $importance, $createOptions)) {
                $resultMap[] = array($name, $ret['msg']);
            }
        }
    }
    return $resultMap;
}
예제 #10
0
/**
 * replace BBCode-link tagged links in req/reqspec scope with actual links
 *
 * @internal revisions:
 * 20100301 - asimon - added anchor and tproj parameters to tags
 * 
 * @param resource $dbHandler database handle
 * @param string $scope text in which to replace tags with links
 * @param integer $tprojectID ID of testproject to which req/reqspec belongs
 * @return string $scope text with generated links
 */
function req_link_replace($dbHandler, $scope, $tprojectID)
{
    $tree_mgr = new tree($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $prefix = $tproject_mgr->getTestCasePrefix($tprojectID);
    $tables = tlObjectWithDB::getDBTables(array('requirements', 'req_specs'));
    $cfg = config_get('internal_links');
    $string2replace = array();
    $title = array();
    // configure target in which link shall open
    // use a reasonable default value if nothing is set in config
    $cfg->target = isset($cfg->target) ? $cfg->target : 'popup';
    switch ($cfg->target) {
        case 'popup':
            // use javascript to open popup window
            $string2replace['req'] = '<a href="javascript:openLinkedReqWindow(%s,\'%s\')">%s%s</a>';
            $string2replace['req_spec'] = '<a href="javascript:openLinkedReqSpecWindow(%s,\'%s\')">%s%s</a>';
            break;
        case 'window':
        case 'frame':
            // open in same frame
            $target = $cfg->target == 'window' ? 'target="_blank"' : 'target="_self"';
            $string2replace['req'] = '<a ' . $target . ' href="lib/requirements/reqView.php?' . 'item=requirement&requirement_id=%s#%s">%s%s</a>';
            $string2replace['req_spec'] = '<a ' . $target . ' href="lib/requirements/reqSpecView.php?' . 'item=req_spec&req_spec_id=%s#%s">%s%s</a>';
            break;
    }
    // configure link title (first part of the generated link)
    // default: use item type as name (localized name for req)
    $title['req'] = lang_get('requirement') . ": ";
    // default: use short item type as name (localized name for req spec)
    $title['req_spec'] = lang_get('req_spec_short') . ": ";
    if ($cfg->req_link_title->type == 'string' && $cfg->req_link_title->value != '') {
        $title['req'] = lang_get($cfg->req_link_title->value);
    } else {
        if ($cfg->req_link_title->type == 'none') {
            $title['req'] = '';
        }
    }
    // now for the req specs
    if ($cfg->req_spec_link_title->type == 'string' && $cfg->req_spec_link_title->value != '') {
        // use user-configured string as link title
        $title['req_spec'] = lang_get($cfg->req_spec_link_title->value);
    } else {
        if ($cfg->req_spec_link_title->type == 'none') {
            $title['req_spec'] = '';
        }
    }
    // now the actual replacing
    $patterns2search = array();
    $patterns2search['req'] = "#\\[req[\\s]*(tproj=([\\w]+))*[\\s]*(anchor=([\\w]+))*[\\s]*(tproj=([\\w]+))*\\](.*)\\[/req\\]#iU";
    $patterns2search['req_spec'] = "#\\[req_spec[\\s]*(tproj=([\\w]+))*[\\s]*(anchor=([\\w]+))*[\\s]*(tproj=([\\w]+))*\\](.*)\\[/req_spec\\]#iU";
    $sql2exec = array();
    $sql2exec['req'] = " SELECT id, req_doc_id AS doc_id " . " FROM {$tables['requirements']} WHERE req_doc_id=";
    $sql2exec['req_spec'] = " SELECT id, doc_id FROM {$tables['req_specs']} " . " WHERE doc_id=";
    foreach ($patterns2search as $accessKey => $pattern) {
        $matches = array();
        preg_match_all($pattern, $scope, $matches);
        if (count($matches[7]) == 0) {
            continue;
        }
        foreach ($matches[0] as $key => $matched_string) {
            // get testproject prefix, if that was found with regex
            // if not, get prefix of current project
            if ($matches[2][$key] != '') {
                $matched_prefix = $matches[2][$key];
            } else {
                if ($matches[6][$key] != '') {
                    $matched_prefix = $matches[6][$key];
                } else {
                    $matched_prefix = $prefix;
                }
            }
            $matched_anchor = $matches[4][$key];
            $matched_doc_id = $matches[7][$key];
            $sql = $sql2exec[$accessKey] . "'{$matched_doc_id}'";
            $rs = $dbHandler->get_recordset($sql);
            if (count($rs)) {
                //20100818 - Julian - fixed error if same doc_id exists in multiple projects
                foreach ($rs as $key => $value) {
                    // get root of linked node and check
                    $real_root = $tree_mgr->getTreeRoot($value['id']);
                    $matched_root_info = $tproject_mgr->get_by_prefix($matched_prefix);
                    if ($real_root == $matched_root_info['id']) {
                        $urlString = sprintf($string2replace[$accessKey], $value['id'], $matched_anchor, $title[$accessKey], $value['doc_id']);
                        $scope = str_replace($matched_string, $urlString, $scope);
                    }
                }
            }
        }
    }
    return $scope;
}
예제 #11
0
$tcase_mgr = new testcase($db);
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$glue = config_get('testcase_cfg')->glue_character;
$args = init_args();
$gui = initializeGui($args);
$getOpt = array('outputFormat' => 'map', 'addIfNull' => true);
$gui->platformSet = $tplan_mgr->getPlatforms($args->tplan_id, $getOpt);
$options['output'] = 'essential';
$tcase_all_info = $tcase_mgr->get_by_id($args->tcase_id, testcase::ALL_VERSIONS, null, $options);
if (!is_null($tcase_all_info)) {
    foreach ($tcase_all_info as $tcversion_info) {
        if ($tcversion_info['id'] == $args->tcversion_id) {
            $version = $tcversion_info['version'];
            $gui->pageTitle = lang_get('test_case') . ':' . $tcversion_info['name'];
            $gui->tcaseIdentity = $tproject_mgr->getTestCasePrefix($args->tproject_id);
            $gui->tcaseIdentity .= $glue . $tcversion_info['tc_external_id'] . ':' . $tcversion_info['name'];
            break;
        }
    }
}
// 20100514 - franciscom
// Why I'm filter on NOT_EXECUTED ??? -> this causes BUGID 3189
// $link_info = $tcase_mgr->get_linked_versions($args->tcase_id,'NOT_EXECUTED');
$link_info = $tcase_mgr->get_linked_versions($args->tcase_id);
// 20100124 - work only on ACTIVE TEST PLANS => array('plan_status' => 1)
if (!is_null($tplanSet = $tproject_mgr->get_all_testplans($args->tproject_id, array('plan_status' => 1)))) {
    $has_links = array_fill_keys(array_keys($tplanSet), false);
    $linked_tplans = null;
    if (!is_null($link_info)) {
        foreach ($link_info as $tcversion_id => $info) {
예제 #12
0
require_once "common.php";
require_once 'exttable.class.php';
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$tpl = 'tcSearchResults.tpl';
$tproject_mgr = new testproject($db);
$tcase_cfg = config_get('testcase_cfg');
$charset = config_get('charset');
$args = init_args();
$edit_label = lang_get('design');
$edit_icon = TL_THEME_IMG_DIR . "edit_icon.png";
$gui = initializeGui($args);
$map = null;
if ($args->tprojectID) {
    $tables = tlObjectWithDB::getDBTables(array('cfield_design_values', 'nodes_hierarchy', 'requirements', 'req_coverage', 'tcsteps', 'testcase_keywords', 'tcversions'));
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($args->tprojectID);
    $gui->tcasePrefix .= $tcase_cfg->glue_character;
    $from = array('by_keyword_id' => ' ', 'by_custom_field' => ' ', 'by_requirement_doc_id' => '');
    $filter = null;
    $tcaseID = null;
    // if Both dates exists check From >= To
    if (!is_null($args->creation_date_from) && !is_null($args->creation_date_to)) {
        $date_from = date_create_from_format('Y-n-j', $args->creation_date_from);
        $date_to = date_create_from_format('Y-n-j', $args->creation_date_to);
    }
    if (!is_null($args->creation_date_from)) {
        $db_date = $db->db->DBdate($args->creation_date_from);
        $filter['by_creation_date_from'] = " AND TCV.creation_ts >= {$db_date} ";
    }
    if (!is_null($args->creation_date_to)) {
        $db_date = $db->db->DBdate($args->creation_date_to);
예제 #13
0
 /**
  * 
  *
  */
 function buildDirectWebLink($base_href, $id, $tproject_id)
 {
     $tproject_mgr = new testproject($this->db);
     $prefix = $tproject_mgr->getTestCasePrefix($tproject_id);
     $dl = $base_href . 'linkto.php?tprojectPrefix=' . urlencode($prefix) . '&item=testsuite&id=' . $id;
     return $dl;
 }
예제 #14
0
function renderTestPlanForPrinting(&$db, &$node, $item_type, &$options, $tocPrefix, $tcCnt, $level, $user_id, $tplan_id, $tprojectID, $platform_id)
{
    $tProjectMgr = new testproject($db);
    $tcPrefix = $tProjectMgr->getTestCasePrefix($tprojectID);
    $code = renderTestSpecTreeForPrinting($db, $node, $item_type, $options, $tocPrefix, $tcCnt, $level, $user_id, $tplan_id, $tcPrefix, $tprojectID, $platform_id);
    return $code;
}
예제 #15
0
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, $argsObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $req_mgr = new requirement_mgr($dbHandler);
    $commandMgr = new reqCommands($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->refreshTree = $argsObj->refreshTree;
    $gui->req_cfg = config_get('req_cfg');
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->tproject_name = $argsObj->tproject_name;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = $argsObj->user->hasRight($dbHandler, "mgt_modify_req", $argsObj->tproject_id);
    // IMPORTANT NOTICE
    // We can arrive here after following operation
    // 1. user click on left pane tree on REQ SPEC NODE
    // 2. on right pane screen user click on CREATE button on Requirements Operations
    // 3. on new screen user CLICK CANCEL
    // In this situation $argsObj->req_id is 0 OR EMPTY
    $gui->req_id = $argsObj->req_id;
    if ($gui->req_id <= 0) {
        // Quick Exit
        // is not too clear why do not need to add lib/requirements/ on target
        $target = "reqSpecView.php?tproject_id={$gui->tproject_id}" . "&req_spec_id={$argsObj->req_spec_id}";
        header("Location: {$target}");
        exit;
    }
    // everything is fine - standard processing
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->glueChar = config_get('testcase_cfg')->glue_character;
    $gui->pieceSep = config_get('gui_title_separator_1');
    /* if wanted, show only the given version */
    $gui->version_option = $argsObj->req_version_id ? $argsObj->req_version_id : requirement_mgr::ALL_VERSIONS;
    $gui->req_versions = $req_mgr->get_by_id($gui->req_id, $gui->version_option);
    $gui->req_has_history = count($req_mgr->get_history($gui->req_id, array('output' => 'array'))) > 1;
    $gui->req = current($gui->req_versions);
    $gui->req_coverage = $req_mgr->get_coverage($gui->req_id);
    // This seems weird but is done to adapt template than can display multiple
    // requirements. This logic has been borrowed from test case versions management
    $gui->current_version[0] = array($gui->req);
    $gui->cfields_current_version[0] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $gui->req['version_id'], $argsObj->tproject_id);
    // Now CF for other Versions
    $gui->other_versions[0] = null;
    $gui->cfields_other_versions[] = null;
    if (count($gui->req_versions) > 1) {
        $gui->other_versions[0] = array_slice($gui->req_versions, 1);
        $loop2do = count($gui->other_versions[0]);
        for ($qdx = 0; $qdx < $loop2do; $qdx++) {
            $target_version = $gui->other_versions[0][$qdx]['version_id'];
            $gui->cfields_other_versions[0][$qdx] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $target_version, $argsObj->tproject_id);
        }
    }
    $gui->show_title = false;
    $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->req['title'];
    $gui->showReqSpecTitle = $argsObj->showReqSpecTitle;
    if ($gui->showReqSpecTitle) {
        $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->req['req_spec_title'];
    }
    $gui->attachments[$gui->req_id] = $req_mgr->getAttachmentInfos($gui->req_id);
    $gui->attachmentTableName = $req_mgr->getAttachmentTableName();
    $gui->reqStatus = init_labels($gui->req_cfg->status_labels);
    $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels);
    // added req relations for BUGID 1748
    $gui->req_relations = FALSE;
    $gui->req_relation_select = FALSE;
    $gui->testproject_select = FALSE;
    $gui->req_add_result_msg = isset($argsObj->relation_add_result_msg) ? $argsObj->relation_add_result_msg : "";
    if ($gui->req_cfg->relations->enable) {
        $gui->req_relations = $req_mgr->get_relations($gui->req_id);
        $gui->req_relation_select = $req_mgr->init_relation_type_select();
        if ($gui->req_cfg->relations->interproject_linking) {
            $gui->testproject_select = initTestprojectSelect($argsObj->userID, $argsObj->tproject_id, $tproject_mgr);
        }
    }
    return $gui;
}
예제 #16
0
/**
 */
function initEnvironment(&$dbHandler, &$userObj)
{
    $argsObj = new stdClass();
    $guiObj = new stdClass();
    $cfg = config_get("gui");
    $tprojectMgr = new testproject($dbHandler);
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $iParams = array("tprojectIDNavBar" => array(tlInputParameter::INT_N), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N));
    R_PARAMS($iParams, $argsObj);
    $guiObj->tcasePrefix = '';
    $guiObj->tplanCount = 0;
    $guiObj->tprojectSet = $tprojectMgr->get_accessible_for_user($userObj->dbID);
    $guiObj->tprojectCount = sizeof($guiObj->tprojectSet);
    // -----------------------------------------------------------------------------------------------------
    // Important Logic
    // -----------------------------------------------------------------------------------------------------
    $argsObj->tprojectIDNavBar = intval($argsObj->tprojectIDNavBar);
    $argsObj->tproject_id = intval($argsObj->tproject_id);
    $argsObj->tproject_id = $argsObj->tproject_id > 0 ? $argsObj->tproject_id : $argsObj->tprojectIDNavBar;
    if ($argsObj->tproject_id == 0) {
        $argsObj->tproject_id = key($guiObj->tprojectSet);
    }
    $guiObj->tprojectID = $argsObj->tproject_id;
    $guiObj->tprojectOptions = null;
    $guiObj->tprojectTopMenu = null;
    if ($guiObj->tprojectID > 0) {
        $dummy = $tprojectMgr->get_by_id($guiObj->tprojectID);
        $guiObj->tprojectOptions = $dummy['opt'];
    }
    // -----------------------------------------------------------------------------------------------------
    $argsObj->tplan_id = intval($argsObj->tplan_id);
    $guiObj->tplanID = $argsObj->tplan_id;
    // Julian: left magic here - do think this value will never be used as a project with a prefix
    //         has to be created after first login -> searchSize should be set dynamically.
    //         If any reviewer agrees on that feel free to change it.
    $guiObj->searchSize = 8;
    if ($guiObj->tprojectID > 0) {
        $guiObj->tcasePrefix = $tprojectMgr->getTestCasePrefix($guiObj->tprojectID) . config_get('testcase_cfg')->glue_character;
        $guiObj->searchSize = tlStringLen($guiObj->tcasePrefix) + $cfg->dynamic_quick_tcase_search_input_size;
        $guiObj->tplanSet = $userObj->getAccessibleTestPlans($dbHandler, $guiObj->tprojectID);
        $guiObj->tplanCount = sizeof($guiObj->tplanSet);
        if ($guiObj->tplanID == 0) {
            $guiObj->tplanID = $guiObj->tplanSet[0]['id'];
            $guiObj->tplanSet[0]['selected'] = 1;
        }
    }
    return array($argsObj, $guiObj);
}
예제 #17
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;
}
$labels = init_labels(array('design' => null, 'execution' => null, 'execution_history' => null));
$edit_img = TL_THEME_IMG_DIR . "edit_icon.png";
$history_img = TL_THEME_IMG_DIR . "history_small.png";
$msg_key = 'no_linked_tcversions';
if ($tplan_mgr->count_testcases($args->tplan_id) > 0) {
    $msg_key = 'all_testcases_have_tester';
    // BUGID 3723 - filter test cases by exec_status => not run
    $cfg = config_get('results');
    $filters = array('assigned_to' => TL_USER_NOBODY, 'exec_status' => $cfg['status_code']['not_run']);
    $options = array('output' => 'array', 'details' => 'summary');
    $testCaseSet = $tplan_mgr->get_linked_tcversions($args->tplan_id, $filters, $options);
    if (($gui->row_qty = count($testCaseSet)) > 0) {
        $msg_key = '';
        $gui->pageTitle .= " - " . lang_get('match_count') . ":" . $gui->row_qty;
        $tproject_mgr = new testproject($db);
        $prefix = $tproject_mgr->getTestCasePrefix($args->tproject_id);
        unset($tproject_mgr);
        // Collect all tc_id:s and get all test suite paths
        $tcase_set = array();
        foreach ($testCaseSet as $item) {
            $tcase_set[] = $item['tc_id'];
        }
        $tree_mgr = new tree($db);
        $path_info = $tree_mgr->get_full_path_verbose($tcase_set);
        unset($tree_mgr);
        $data = array();
        foreach ($testCaseSet as $item) {
            $verbosePath = join(" / ", $path_info[$item['tc_id']]);
            $name = buildExternalIdString($prefix, $item['external_id'] . ': ' . $item['name']);
            // create linked icons
            $exec_history_link = "<a href=\"javascript:openExecHistoryWindow({$item['tc_id']});\">" . "<img title=\"{$labels['execution_history']}\" src=\"{$history_img}\" /></a> ";
예제 #19
0
$args = init_args();
$tproject_mgr = new testproject($db);
$msg_key = 'all_testcases_has_testplan';
$edit_label = lang_get('design');
$edit_img = TL_THEME_IMG_DIR . "edit_icon.png";
$gui = new stdClass();
$gui->freeTestCases = $tproject_mgr->getFreeTestCases($args->tproject_id);
$gui->path_info = null;
$gui->tableSet = null;
if (!is_null($gui->freeTestCases['items'])) {
    if ($gui->freeTestCases['allfree']) {
        // has no sense display all test cases => display just message.
        $msg_key = 'all_testcases_are_free';
    } else {
        $msg_key = '';
        $tcasePrefix = $tproject_mgr->getTestCasePrefix($args->tproject_id) . $tcase_cfg->glue_character;
        $tcaseSet = array_keys($gui->freeTestCases['items']);
        $options = array('output_format' => 'path_as_string');
        $tsuites = $tproject_mgr->tree_manager->get_full_path_verbose($tcaseSet, $options);
        $titleSeperator = config_get('gui_title_separator_1');
        $columns = getColumnsDefinition();
        // Extract the relevant data and build a matrix
        $matrixData = array();
        foreach ($gui->freeTestCases['items'] as $tcases) {
            $rowData = array();
            $rowData[] = strip_tags($tsuites[$tcases['id']]);
            //build test case link
            $edit_link = "<a href=\"javascript:openTCEditWindow({$tcases['id']});\">" . "<img title=\"{$edit_label}\" src=\"{$edit_img}\" /></a> ";
            $tcaseName = $tcasePrefix . $tcases['tc_external_id'] . $titleSeperator . strip_tags($tcases['name']);
            $tcLink = $edit_link . $tcaseName;
            $rowData[] = $tcLink;
예제 #20
0
 /** 
  * Creates data for tree menu used on :
  * - Execution of Test Cases
  * - Remove Test cases from test plan
  * 
  * @internal Revisions:
  *
  *	20101003 - franciscom - added option remove_empty_nodes_of_type on get_subtree() call
  */
 function generateExecTree(&$db, &$menuUrl, $env, $filters, $options)
 {
     $tplan_tcases = null;
     $tck_map = null;
     $idx = 0;
     $apply_other_filters = true;
     $map_node_tccount = array();
     $renderOpt = array();
     $renderAux = array();
     $tplan_mgr = new testplan($db);
     $tproject_mgr = new testproject($db);
     // ---------------------------------------------------------------------------------------------
     // initialize configuration and options
     // ---------------------------------------------------------------------------------------------
     $tproject_id = $env['tproject_id'];
     $tplan_id = $env['tplan_id'];
     $my['filters'] = normalizeFilters($filters);
     $node_types = $tproject_mgr->tree_manager->get_available_node_types();
     $renderAux['hash_id_descr'] = array_flip($node_types);
     $renderAux['testCasePrefix'] = $tproject_mgr->getTestCasePrefix($tproject_id) . config_get('testcase_cfg')->glue_character;
     $renderOpt['showTestCaseID'] = config_get('treemenu_show_testcase_id');
     $renderOpt['hideTCs'] = isset($filters->hide_testcases) ? $filters->hide_testcases : false;
     $renderOpt['showTestSuiteContents'] = isset($filters->show_testsuite_contents) ? $filters->show_testsuite_contents : true;
     $renderOpt['useCounters'] = isset($options->useCounters) ? $options->useCounters : false;
     $renderOpt['colorOptions'] = isset($options->colorOptions) ? $options->colorOptions : null;
     $renderOpt['tc_action_enabled'] = isset($options->tc_action_enabled) ? $options->tc_action_enabled : false;
     $colorBySelectedBuild = isset($options->testcases_colouring_by_selected_build) ? $options->testcases_colouring_by_selected_build : false;
     // ---------------------------------------------------------------------------------------------
     // echo __LINE__;
     $test_spec = getTestSpec4ExecTree($tplan_mgr->tree_manager, $env, $my['filters']);
     if ($doIt = !is_null($test_spec)) {
         if (is_null($my['filters']->filter_tc_id) || $my['filters']->filter_tc_id >= 0) {
             list($tplan_tcases, $tck_map) = getTPlanTCases4ExecTree($db, $tproject_mgr, $tplan_mgr, $env, $my['filters']);
         }
         // new dBug($tplan_tcases);
         // new dBug($tck_map);
         if (is_null($tplan_tcases)) {
             $tplan_tcases = array();
             $apply_other_filters = false;
         } else {
             $tplan_tcases = applyFilters4ExeTree($tplan_mgr, $tplan_tcases, $env['tplan_id'], $filters);
             // new dBug($tplan_tcases);
         }
         $apply_other_filters = !is_null($tplan_tcases) && count($tplan_tcases) > 0;
         // BUGID 3450 - Change colors/counters in exec tree.
         // Means: replace exec status in filtered array $tplan_tcases  by the one of last execution of selected build.
         // Since this changes exec status, replacing is done after filtering by status.
         // It has to be done before call to prepareNode() though, because that one sets the counters according to status.
         if ($apply_other_filters && (!is_null($renderOpt['colorOptions']) && $colorBySelectedBuild)) {
             $tplan_tcases = updateStatus4ExecTree($db, $tplan_tcases, $env['tplan_id'], $filters->selected_build, $this->cfg->results);
         }
         // 20080224 - franciscom -
         // After reviewing code, seems that assignedTo has no sense because tp_tcs
         // has been filtered.
         // Then to avoid changes to prepareNode() due to include_unassigned,
         // seems enough to set assignedTo to 0, if include_unassigned==true
         $pnFilters['assignedTo'] = $my['filters']->filter_assigned_user_include_unassigned ? null : $my['filters']->filter_assigned_user;
         $keys2init = array('filter_testcase_name', 'filter_execution_type', 'filter_priority');
         foreach ($keys2init as $keyname) {
             $pnFilters[$keyname] = isset($filters->{$keyname}) ? $filters->{$keyname} : null;
         }
         $pnOptions = array('hideTestCases' => $renderOpt['hideTCs'], 'viewType' => 'executionTree');
         $testcase_counters = prepareNode($db, $test_spec, $decoding_hash, $map_node_tccount, $tck_map, $tplan_tcases, $pnFilters, $pnOptions);
         foreach ($testcase_counters as $key => $value) {
             $test_spec[$key] = $testcase_counters[$key];
         }
         $keys = array_keys($tplan_tcases);
         // IMPORTANT NOTICE: process makes changes on $test_spec
         renderExecTreeNode($env, 1, $test_spec, $tplan_tcases, $menuUrl, $renderOpt, $renderAux);
     }
     // if($test_spec)
     $treeMenu = new stdClass();
     $treeMenu->menustring = '';
     $treeMenu->rootnode = new stdClass();
     $treeMenu->rootnode->name = $test_spec['text'];
     $treeMenu->rootnode->id = $test_spec['id'];
     $treeMenu->rootnode->leaf = $test_spec['leaf'];
     $treeMenu->rootnode->text = $test_spec['text'];
     $treeMenu->rootnode->position = $test_spec['position'];
     $treeMenu->rootnode->href = $test_spec['href'];
     $menustring = '';
     // new dBug($test_spec['childNodes']);
     if ($doIt) {
         // Change key ('childNodes')  to the one required by Ext JS tree.
         $menustring = str_ireplace('childNodes', 'children', json_encode($test_spec['childNodes']));
         // Remove null elements (Ext JS tree do not like it ).
         // :null happens on -> "children":null,"text" that must become "children":[],"text"
         // $menustring = str_ireplace(array(':null',',null','null,'),array(':[]','',''), $menustring);
         $menustring = str_ireplace(array(':null', ',null', 'null,', 'null'), array(':[]', '', '', ''), $menustring);
     }
     $treeMenu->menustring = $menustring;
     return array($treeMenu, $keys);
 }
예제 #21
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;
}
예제 #22
0
/**
 * Generate a filtered map with all fitting requirements in it.
 * 
 * @author Andreas Simon
 * @param Database $db reference to database handler object
 * @param int $testproject_id ID of the project for which the tree shall be generated
 * @param testproject $testproject_mgr reference to testproject manager object
 * @param array $filters Filter settings which shall be applied to the tree
 * @param array $options Further options which shall be applied on generating the tree
 * @return array $filtered_map map with all fitting requirements
 */
function get_filtered_req_map(&$db, $testproject_id, &$testproject_mgr, $filters, $options)
{
    $filtered_map = null;
    $tables = tlObjectWithDB::getDBTables(array('nodes_hierarchy', 'requirements', 'req_specs', 'req_relations', 'req_versions', 'req_coverage', 'tcversions', 'cfield_design_values'));
    $sql = " SELECT R.id, R.req_doc_id, NH_R.name AS title, R.srs_id, " . "        RS.doc_id AS req_spec_doc_id, NH_RS.name AS req_spec_title, " . "        RV.version, RV.id AS version_id, NH_R.node_order, " . "        RV.expected_coverage, RV.status, RV.type, RV.active, RV.is_open " . " FROM {$tables['requirements']} R " . " JOIN {$tables['nodes_hierarchy']} NH_R ON NH_R.id = R.id " . " JOIN {$tables['nodes_hierarchy']} NH_RV ON NH_RV.parent_id = NH_R.id " . " JOIN {$tables['req_versions']} RV ON RV.id = NH_RV.id " . " JOIN {$tables['req_specs']} RS ON RS.id = R.srs_id " . " JOIN {$tables['nodes_hierarchy']} NH_RS ON NH_RS.id = RS.id ";
    if (isset($filters['filter_relation'])) {
        $sql .= " JOIN {$tables['req_relations']} RR " . " ON (RR.destination_id = R.id OR RR.source_id = R.id) ";
    }
    if (isset($filters['filter_tc_id'])) {
        $tc_cfg = config_get('testcase_cfg');
        $tc_prefix = $testproject_mgr->getTestCasePrefix($testproject_id);
        $tc_prefix .= $tc_cfg->glue_character;
        $tc_ext_id = $db->prepare_int(str_replace($tc_prefix, '', $filters['filter_tc_id']));
        $sql .= " JOIN {$tables['req_coverage']} RC ON RC.req_id = R.id " . " JOIN {$tables['nodes_hierarchy']} NH_T ON NH_T.id = RC.testcase_id " . " JOIN {$tables['nodes_hierarchy']} NH_TV on NH_TV.parent_id = NH_T.id " . " JOIN {$tables['tcversions']} TV ON TV.id = NH_TV.id " . "                                    AND TV.tc_external_id = {$tc_ext_id} ";
    }
    if (isset($filters['filter_custom_fields'])) {
        $suffix = 1;
        foreach ($filters['filter_custom_fields'] as $cf_id => $cf_value) {
            $sql .= " JOIN {$tables['cfield_design_values']} CF{$suffix} " . " ON CF{$suffix}.node_id = RV.id " . " AND CF{$suffix}.field_id = {$cf_id} ";
            // single value or array?
            if (is_array($cf_value)) {
                $sql .= " AND ( ";
                $count = 1;
                foreach ($cf_value as $value) {
                    if ($count > 1) {
                        $sql .= " OR ";
                    }
                    $sql .= " CF{$suffix}.value LIKE '%{$value}%' ";
                    $count++;
                }
                $sql .= " ) ";
            } else {
                $sql .= " AND CF{$suffix}.value LIKE '%{$cf_value}%' ";
            }
            $suffix++;
        }
    }
    $sql .= " WHERE RS.testproject_id = {$testproject_id} ";
    if (isset($filters['filter_doc_id'])) {
        $doc_id = $db->prepare_string($filters['filter_doc_id']);
        $sql .= " AND R.req_doc_id LIKE '%{$doc_id}%' OR RS.doc_id LIKE '%{$doc_id}%' ";
    }
    if (isset($filters['filter_title'])) {
        $title = $db->prepare_string($filters['filter_title']);
        $sql .= " AND NH_R.name LIKE '%{$title}%' ";
    }
    if (isset($filters['filter_coverage'])) {
        $coverage = $db->prepare_int($filters['filter_coverage']);
        $sql .= " AND expected_coverage = {$coverage} ";
    }
    if (isset($filters['filter_status'])) {
        $statuses = (array) $filters['filter_status'];
        foreach ($statuses as $key => $status) {
            $statuses[$key] = "'" . $db->prepare_string($status) . "'";
        }
        $statuses = implode(",", $statuses);
        $sql .= " AND RV.status IN ({$statuses}) ";
    }
    if (isset($filters['filter_type'])) {
        $types = (array) $filters['filter_type'];
        // BUGID 3671
        foreach ($types as $key => $type) {
            $types[$key] = $db->prepare_string($type);
        }
        $types = implode("','", $types);
        $sql .= " AND RV.type IN ('{$types}') ";
    }
    if (isset($filters['filter_spec_type'])) {
        $spec_types = (array) $filters['filter_spec_type'];
        // BUGID 3671
        foreach ($spec_types as $key => $type) {
            $spec_types[$key] = $db->prepare_string($type);
        }
        $spec_types = implode("','", $spec_types);
        $sql .= " AND RS.type IN ('{$spec_types}') ";
    }
    if (isset($filters['filter_relation'])) {
        $sql .= " AND ( ";
        $count = 1;
        foreach ($filters['filter_relation'] as $key => $rel_filter) {
            $relation_info = explode('_', $rel_filter);
            $relation_type = $db->prepare_int($relation_info[0]);
            $relation_side = isset($relation_info[1]) ? $relation_info[1] : null;
            $sql .= $count == 1 ? " ( " : " OR ( ";
            if ($relation_side == "destination") {
                $sql .= " RR.destination_id = R.id ";
            } else {
                if ($relation_side == "source") {
                    $sql .= " RR.source_id = R.id ";
                } else {
                    $sql .= " (RR.destination_id = R.id OR RR.source_id = R.id) ";
                }
            }
            $sql .= " AND RR.relation_type = {$relation_type} ) ";
            $count++;
        }
        $sql .= " ) ";
    }
    $sql .= " ORDER BY RV.version DESC ";
    $filtered_map = $db->fetchRowsIntoMap($sql, 'id');
    return $filtered_map;
}
예제 #23
0
function initializeGui(&$db, $args)
{
    $tcaseCfg = config_get('testcase_cfg');
    $reqCfg = config_get('req_cfg');
    $gui = new stdClass();
    $gui->mainTitle = '';
    $tprojectMgr = new testproject($db);
    $tcasePrefix = $tprojectMgr->getTestCasePrefix($args->tproject_id);
    $gui->tree_title = '';
    $gui->ajaxTree = new stdClass();
    $gui->ajaxTree->root_node = new stdClass();
    $gui->ajaxTree->dragDrop = new stdClass();
    $gui->ajaxTree->dragDrop->enabled = false;
    $gui->ajaxTree->dragDrop->BackEndUrl = null;
    $gui->ajaxTree->children = '';
    // Prefix for cookie used to save tree state
    $gui->ajaxTree->cookiePrefix = 'print' . str_replace(' ', '_', $args->doc_type) . '_';
    $gui->doc_type = $args->doc_type;
    switch ($args->doc_type) {
        // BUGID 3067
        case 'reqspec':
            $gui->tree_title = lang_get('title_req_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/getrequirementnodes.php?' . "root_node={$args->tproject_id}&" . "show_children=0&operation=print";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP_RS({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $req_qty = $tprojectMgr->count_all_requirements($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$req_qty})";
            $gui->ajaxTree->cookiePrefix .= $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('requirement_specification_report');
            break;
            // end BUGID 3067
        // end BUGID 3067
        case 'testspec':
            $gui->tree_title = lang_get('title_tc_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$args->tproject_id}&" . "show_tcases=0&operation=print&" . "tcprefix=" . urlencode($tcasePrefix . $tcaseCfg->glue_character) . "}";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $tcase_qty = $tprojectMgr->count_testcases($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$tcase_qty})";
            $gui->ajaxTree->cookiePrefix .= $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('testspecification_report');
            break;
        case 'testreport':
            $gui->mainTitle = lang_get('test_report');
            break;
        case 'testplan':
            $gui->tree_title = lang_get('title_tp_print_navigator');
            $gui->ajaxTree->loadFromChildren = 1;
            $gui->ajaxTree->loader = '';
            $gui->mainTitle = lang_get('test_plan');
            break;
    }
    $gui->mainTitle .= ' - ' . lang_get('doc_opt_title');
    $gui->outputFormat = array(FORMAT_HTML => lang_get('format_html'), FORMAT_ODT => lang_get('format_odt'), FORMAT_MSWORD => lang_get('format_msword'));
    return $gui;
}
/**
 *
 */
function renderExecutionForPrinting(&$dbHandler, $baseHref, $id, $userObj = null)
{
    static $tprojectMgr;
    static $tcaseMgr;
    static $st;
    $out = '';
    if (!$st) {
        $st = new stdClass();
        $st->tables = tlDBObject::getDBTables(array('executions', 'builds'));
        $tprojectMgr = new testproject($dbHandler);
        $tcaseMgr = new testcase($dbHandler);
    }
    $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.platform_id,E.execution_duration, " . " B.name AS build_name, B.id AS build_id " . " FROM {$st->tables['executions']} E " . " JOIN {$st->tables['builds']} B  ON B.id = E.build_id " . " WHERE E.id = " . intval($id);
    $exec_info = $dbHandler->get_recordset($sql);
    if (!is_null($exec_info)) {
        $exec_info = $exec_info[0];
        $context['exec_id'] = intval($id);
        $context['tplan_id'] = $exec_info['testplan_id'];
        $context['platform_id'] = $exec_info['platform_id'];
        $context['build_id'] = $exec_info['build_id'];
        $context['level'] = '??';
        // ???
        $node = $tprojectMgr->tree_manager->get_node_hierarchy_info($context['tplan_id']);
        $context['prefix'] = $tprojectMgr->getTestCasePrefix($node['parent_id']);
        $context['tproject_id'] = $node['parent_id'];
        unset($tprojectMgr);
        // IMPORTANT DEVELOPMENT NOTICE
        // Remember that on executions table we have following fields
        //
        // testplan_id
        // tcversion_id
        // tcversion_number
        //
        // a. (testplan_id ,tcversion_id) ARE LINK To testplan_tcversions table
        // b. if user creates a new version of a LINKED AND EXECUTED test case
        //    when he/she updates test plan, ONLY tcversion_id is updated,
        //    while tcversion_number HAS ALWAYS the VERSION HUMAN READABLE NUMBER
        //    of executed version.
        //
        // Then if you want to access specification of executed test case version
        // you need to proceed this way
        // 1. with tcversion_id => get test case id
        // 2. using test case id AND tcversion_number you access the data.
        //
        // Why is important to remember this?
        // Because here we need to get data for renderTestCaseForPrinting
        //
        // The Cinematic Orchestra: To build a home Incubus: Wish you were here Mau Mau: La ola
        $node = $tcaseMgr->tree_manager->get_node_hierarchy_info($exec_info['tcversion_id']);
        // get_by_id($id,$version_id = self::ALL_VERSIONS, $filters = null, $options=null)
        $tcase = $tcaseMgr->get_by_id($node['parent_id'], null, array('version_number' => $exec_info['tcversion_number']));
        $renderOptions = array('toc' => 0, 'body' => 1, 'summary' => 1, 'header' => 0, 'headerNumbering' => 0, 'passfail' => 1, 'author' => 1, 'notes' => 1, 'requirement' => 1, 'keyword' => 1, 'cfields' => 1, 'displayVersion' => 1, 'displayDates' => 1, 'docType' => SINGLE_TESTCASE, 'importance' => 1, 'step_exec_notes' => 1, 'step_exec_status' => 1);
        // need to change keys
        $tcase = $tcase[0];
        $tcase['tcversion_id'] = $tcase['id'];
        $tcase['id'] = $node['parent_id'];
        $env = new stdClass();
        $env->base_href = $baseHref;
        $env->reportType = $renderOptions['docType'];
        $indentLevel = 100000;
        $context['user'] = $userObj;
        $out .= renderTestCaseForPrinting($dbHandler, $tcase, $renderOptions, $env, $context, $indentLevel);
        $out .= '<br>' . lang_get('direct_link') . ':' . $env->base_href . 'lnl.php?type=exec&id=' . intval($id) . '<br>';
        $exec_info = null;
    }
    return $out;
}
예제 #25
0
/**
 * 
 * @internal revisions
 *  20121010 - asimon - TICKET 4353: added active/inactive filter
 */
function generateTestSpecTreeNew(&$db, $tproject_id, $tproject_name, $linkto, $filters = null, $options = null)
{
    $chronos[] = microtime(true);
    $tables = tlObjectWithDB::getDBTables(array('tcversions', 'nodes_hierarchy'));
    $my = array();
    $my['options'] = array('forPrinting' => 0, 'hideTestCases' => 0, 'tc_action_enabled' => 1, 'viewType' => 'testSpecTree');
    $my['filters'] = array('keywords' => null, 'testplan' => null);
    $my['options'] = array_merge($my['options'], (array) $options);
    $my['options']['showTestCaseID'] = config_get('treemenu_show_testcase_id');
    $my['filters'] = array_merge($my['filters'], (array) $filters);
    $treeMenu = new stdClass();
    $treeMenu->rootnode = null;
    $treeMenu->menustring = '';
    $resultsCfg = config_get('results');
    $glueChar = config_get('testcase_cfg')->glue_character;
    $menustring = null;
    $tproject_mgr = new testproject($db);
    $tree_manager =& $tproject_mgr->tree_manager;
    $hash_descr_id = $tree_manager->get_available_node_types();
    $hash_id_descr = array_flip($hash_descr_id);
    $status_descr_code = $resultsCfg['status_code'];
    $status_code_descr = $resultsCfg['code_status'];
    $decoding_hash = array('node_id_descr' => $hash_id_descr, 'status_descr_code' => $status_descr_code, 'status_code_descr' => $status_code_descr);
    $tcase_prefix = $tproject_mgr->getTestCasePrefix($tproject_id) . $glueChar;
    $test_spec = getTestSpecTree($tproject_id, $tproject_mgr, $filters);
    // Added root node for test specification -> testproject
    $test_spec['name'] = $tproject_name;
    $test_spec['id'] = $tproject_id;
    $test_spec['node_type_id'] = $hash_descr_id['testproject'];
    $map_node_tccount = array();
    $tc2show = null;
    if ($test_spec) {
        if (isset($my['filters']['filter_custom_fields']) && isset($test_spec['childNodes'])) {
            $test_spec['childNodes'] = filter_by_cf_values($db, $test_spec['childNodes'], $my['filters']['filter_custom_fields'], $hash_descr_id);
        }
        $pnFilters = array('keywords' => $my['filters']['filter_keywords'], 'keywords_filter_type' => $my['filters']['filter_keywords_filter_type']);
        $pnOptions = array('hideTestCases' => $my['options']['hideTestCases'], 'ignoreInactiveTestCases' => $my['options']['ignore_inactive_testcases'], 'ignoreActiveTestCases' => $my['options']['ignore_active_testcases']);
        // Important/CRITIC:
        // prepareTestSpecNode() will make changes to $test_spec like filtering by test case keywords.
        $testcase_counters = prepareTestSpecNode($db, $tproject_mgr, $tproject_id, $test_spec, $map_node_tccount, $pnFilters, $pnOptions);
        if (is_null($test_spec)) {
            $test_spec['name'] = $tproject_name;
            $test_spec['id'] = $tproject_id;
            $test_spec['node_type_id'] = $hash_descr_id['testproject'];
        }
        foreach ($testcase_counters as $key => $value) {
            $test_spec[$key] = $testcase_counters[$key];
        }
        $tc2show = renderTreeNode(1, $test_spec, $hash_id_descr, $linkto, $tcase_prefix, $my['options']);
    }
    $menustring = '';
    $treeMenu->rootnode = new stdClass();
    $treeMenu->rootnode->name = $test_spec['text'];
    $treeMenu->rootnode->id = $test_spec['id'];
    $treeMenu->rootnode->leaf = isset($test_spec['leaf']) ? $test_spec['leaf'] : false;
    $treeMenu->rootnode->text = $test_spec['text'];
    $treeMenu->rootnode->position = $test_spec['position'];
    $treeMenu->rootnode->href = $test_spec['href'];
    // 20090328 - franciscom - BUGID 2299
    // More details about problem found on 20090308 and fixed IN WRONG WAY
    // TPROJECT
    //    |______ TSA
    //            |__ TC1
    //            |__ TC2
    //    |
    //    |______ TSB
    //            |______ TSC
    //
    // Define Keyword K1,K2
    //
    // NO TEST CASE HAS KEYWORD ASSIGNED
    // Filter by K1
    // Tree will show root that spins Forever
    // menustring before str_ireplace : [null,null]
    // menustring AFTER [null]
    //
    // Now fixed.
    //
    // Some minor fix to do
    // Il would be important exclude Top Level Test suites.
    //
    //
    // 20090308 - franciscom
    // Changed because found problem on:
    // Test Specification tree when applying Keyword filter using a keyword NOT PRESENT
    // in test cases => Tree root shows loading icon and spin never stops.
    //
    // Attention: do not know if in other situation this will generate a different bug
    //
    //
    // Change key ('childNodes')  to the one required by Ext JS tree.
    if (isset($test_spec['childNodes'])) {
        $menustring = str_ireplace('childNodes', 'children', json_encode($test_spec['childNodes']));
    }
    if (!is_null($menustring)) {
        // Remove null elements (Ext JS tree do not like it ).
        // :null happens on -> "children":null,"text" that must become "children":[],"text"
        // $menustring = str_ireplace(array(':null',',null','null,'),array(':[]','',''), $menustring);
        $menustring = str_ireplace(array(':null', ',null', 'null,', 'null'), array(':[]', '', '', ''), $menustring);
    }
    $treeMenu->menustring = $menustring;
    $tc2show = !is_null($tc2show) ? explode(",", trim($tc2show, ",")) : null;
    return array('menu' => $treeMenu, 'leaves' => $tc2show, 'tree' => $test_spec);
}
예제 #26
0
function testPlanTree(&$dbHandler, &$menuUrl, $tproject_id, $tproject_name, $tplan_id, $tplan_name, $objFilters, $objOptions)
{
    $debugMsg = ' - Method: ' . __FUNCTION__;
    $chronos[] = $tstart = microtime(true);
    $treeMenu = new stdClass();
    $treeMenu->rootnode = null;
    $treeMenu->menustring = '';
    $resultsCfg = config_get('results');
    $glueChar = config_get('testcase_cfg')->glue_character;
    $menustring = null;
    $tplan_tcases = null;
    $renderTreeNodeOpt = null;
    $renderTreeNodeOpt['showTestCaseID'] = config_get('treemenu_show_testcase_id');
    list($filters, $options, $renderTreeNodeOpt['showTestSuiteContents'], $renderTreeNodeOpt['useCounters'], $renderTreeNodeOpt['useColors'], $colorBySelectedBuild) = initExecTree($objFilters, $objOptions);
    $tplan_mgr = new testplan($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $tree_manager = $tplan_mgr->tree_manager;
    $tcase_node_type = $tree_manager->node_descr_id['testcase'];
    $hash_descr_id = $tree_manager->get_available_node_types();
    $hash_id_descr = array_flip($hash_descr_id);
    $tcase_prefix = $tproject_mgr->getTestCasePrefix($tproject_id) . $glueChar;
    $nt2exclude = array('testplan' => 'exclude_me', 'requirement_spec' => 'exclude_me', 'requirement' => 'exclude_me');
    $nt2exclude_children = array('testcase' => 'exclude_my_children', 'requirement_spec' => 'exclude_my_children');
    // remove test spec, test suites (or branches) that have ZERO test cases linked to test plan
    //
    // IMPORTANT:
    // using 'order_cfg' => array("type" =>'exec_order',"tplan_id" => $tplan_id))
    // makes the magic of ignoring test cases not linked to test plan.
    // This unexpected bonus can be useful on export test plan as XML.
    //
    $my['options'] = array('recursive' => true, 'remove_empty_nodes_of_type' => $tree_manager->node_descr_id['testsuite'], 'order_cfg' => array("type" => 'exec_order', "tplan_id" => $tplan_id), 'hideTestCases' => $options['hideTestCases'], 'tc_action_enabled' => $options['tc_action_enabled'], 'showTestCaseExecStatus' => $options['showTestCaseExecStatus']);
    $my['filters'] = array('exclude_node_types' => $nt2exclude, 'exclude_children_of' => $nt2exclude_children);
    if (isset($objFilters->filter_toplevel_testsuite) && is_array($objFilters->filter_toplevel_testsuite)) {
        $my['filters']['exclude_branches'] = $objFilters->filter_toplevel_testsuite;
    }
    if (isset($objFilters->filter_custom_fields) && is_array($objFilters->filter_custom_fields)) {
        $my['filters']['filter_custom_fields'] = $objFilters->filter_custom_fields;
    }
    if (property_exists($objOptions, 'actionJS')) {
        foreach (array('testproject', 'testsuite', 'testcase') as $nk) {
            if (isset($objOptions->actionJS[$nk])) {
                $renderTreeNodeOpt['actionJS'][$nk] = $objOptions->actionJS[$nk];
            }
        }
    }
    if (property_exists($objOptions, 'nodeHelpText')) {
        foreach (array('testproject', 'testsuite', 'testcase') as $nk) {
            if (isset($objOptions->nodeHelpText[$nk])) {
                $renderTreeNodeOpt['nodeHelpText'][$nk] = $objOptions->nodeHelpText[$nk];
            }
        }
    }
    $test_spec = $tplan_mgr->getSkeleton($tplan_id, $tproject_id, $my['filters'], $my['options']);
    $test_spec['name'] = $tproject_name . " / " . $tplan_name;
    // To be discussed
    $test_spec['id'] = $tproject_id;
    $test_spec['node_type_id'] = $hash_descr_id['testproject'];
    $test_spec['node_type'] = 'testproject';
    $map_node_tccount = array();
    $tplan_tcases = array();
    if ($test_spec) {
        if (is_null($filters['tcase_id']) || $filters['tcase_id'] > 0) {
            // Step 1 - get item set with exec status.
            // This has to scopes:
            // 1. tree coloring according exec status on (Test plan, platform, build ) context
            // 2. produce sql that can be used to reduce item set on combination with filters
            //    that can not be used on this step like:
            //    a. test cases belonging to branch with root TEST SUITE
            //    b. keyword filter on AND MODE
            //    c. execution results on other builds, any build etc
            //
            // WE NEED TO ADD FILTERING on CUSTOM FIELD VALUES, WE HAVE NOT REFACTORED
            // THIS YET.
            //
            if (!is_null($sql2do = $tplan_mgr->{$objOptions->getTreeMethod}($tplan_id, $filters, $options))) {
                $doPinBall = false;
                if (is_array($sql2do)) {
                    if ($doPinBall = $filters['keyword_filter_type'] == 'And') {
                        $kmethod = "fetchRowsIntoMapAddRC";
                        $unionClause = " UNION ALL ";
                    } else {
                        $kmethod = "fetchRowsIntoMap";
                        $unionClause = ' UNION ';
                    }
                    $sql2run = $sql2do['exec'] . $unionClause . $sql2do['not_run'];
                } else {
                    $kmethod = "fetchRowsIntoMap";
                    $sql2run = $sql2do;
                }
                $tplan_tcases = $dbHandler->{$kmethod}($sql2run, 'tcase_id');
                if ($doPinBall && !is_null($tplan_tcases)) {
                    $kwc = count($filters['keyword_id']);
                    $ak = array_keys($tplan_tcases);
                    $mx = null;
                    foreach ($ak as $tk) {
                        if ($tplan_tcases[$tk]['recordcount'] == $kwc) {
                            $mx[$tk] = $tplan_tcases[$tk];
                        }
                    }
                    $tplan_tcases = null;
                    $tplan_tcases = $mx;
                }
                $setTestCaseStatus = $tplan_tcases;
            }
        }
        if (is_null($tplan_tcases)) {
            $tplan_tcases = array();
        }
        // OK, now we need to work on status filters
        // if "any" was selected as filtering status, don't filter by status
        $targetExecStatus = (array) (isset($objFilters->filter_result_result) ? $objFilters->filter_result_result : null);
        if (!is_null($targetExecStatus) && !in_array($resultsCfg['status_code']['all'], $targetExecStatus)) {
            applyStatusFilters($tplan_id, $tplan_tcases, $objFilters, $tplan_mgr, $resultsCfg['status_code']);
        }
        if (isset($my['filters']['filter_custom_fields']) && isset($test_spec['childNodes'])) {
            $test_spec['childNodes'] = filter_by_cf_values($dbHandler, $test_spec['childNodes'], $my['filters']['filter_custom_fields'], $hash_descr_id);
        }
        // here we have LOT OF CONFUSION, sometimes we use $my['options'] other $options
        $pnFilters = null;
        $pnOptions = array('hideTestCases' => $my['options']['hideTestCases'], 'viewType' => 'executionTree');
        $testcase_counters = prepareExecTreeNode($dbHandler, $test_spec, $map_node_tccount, $tplan_tcases, $pnFilters, $pnOptions);
        foreach ($testcase_counters as $key => $value) {
            $test_spec[$key] = $testcase_counters[$key];
        }
        $keys = array_keys($tplan_tcases);
        $renderTreeNodeOpt['hideTestCases'] = $my['options']['hideTestCases'];
        // $renderTreeNodeOpt['tc_action_enabled'] = 1;
        $renderTreeNodeOpt['tc_action_enabled'] = isset($my['options']['tc_action_enabled']) ? $my['options']['tc_action_enabled'] : 1;
        // $renderTreeNodeOpt['nodeHelpText'] = $my['options']['nodeHelpText'];
        $renderTreeNodeOpt['showTestCaseExecStatus'] = $my['options']['showTestCaseExecStatus'];
        $menustring = renderExecTreeNode(1, $test_spec, $tplan_tcases, $hash_id_descr, $menuUrl, $tcase_prefix, $renderTreeNodeOpt);
    }
    // if($test_spec)
    $treeMenu->rootnode = new stdClass();
    $treeMenu->rootnode->name = $test_spec['text'];
    $treeMenu->rootnode->id = $test_spec['id'];
    $treeMenu->rootnode->leaf = $test_spec['leaf'];
    $treeMenu->rootnode->text = $test_spec['text'];
    $treeMenu->rootnode->position = $test_spec['position'];
    $treeMenu->rootnode->href = $test_spec['href'];
    if (!is_null($menustring)) {
        // Change key ('childNodes')  to the one required by Ext JS tree.
        if (isset($test_spec['childNodes'])) {
            $menustring = str_ireplace('childNodes', 'children', json_encode($test_spec['childNodes']));
        }
        // Remove null elements (Ext JS tree do not like it ).
        // :null happens on -> "children":null,"text" that must become "children":[],"text"
        // $menustring = str_ireplace(array(':null',',null','null,'),array(':[]','',''), $menustring);
        $menustring = str_ireplace(array(':null', ',null', 'null,', 'null'), array(':[]', '', '', ''), $menustring);
    }
    $treeMenu->menustring = $menustring;
    return array($treeMenu, $keys);
}
예제 #27
0
/**
 * replace BBCode-link tagged links in req/reqspec scope with actual links
 *
 * @internal revisions:
 * 20110525 - Julian - BUGID 4487 - allow to specify requirement version for internal links
 * 20100301 - asimon - added anchor and tproj parameters to tags
 * 
 * @param resource $dbHandler database handle
 * @param string $scope text in which to replace tags with links
 * @param integer $tprojectID ID of testproject to which req/reqspec belongs
 * @return string $scope text with generated links
 */
function req_link_replace($dbHandler, $scope, $tprojectID)
{
    // Use this to improve performance when is called in loops
    static $tree_mgr;
    static $tproject_mgr;
    static $req_mgr;
    static $cfg;
    static $l18n;
    static $title;
    static $tables;
    if (!$tproject_mgr) {
        $tproject_mgr = new testproject($dbHandler);
        $tree_mgr = new tree($dbHandler);
        $req_mgr = new requirement_mgr($dbHandler);
        $tables = tlObjectWithDB::getDBTables(array('requirements', 'req_specs'));
        $cfg = config_get('internal_links');
        $l18n['version'] = lang_get('tcversion_indicator');
        $prop2loop = array('req' => array('prop' => 'req_link_title', 'default_lbl' => 'requirement'), 'req_spec' => array('prop' => 'req_spec_link_title', 'default_lbl' => 'req_spec_short'));
        // configure link title (first part of the generated link)
        $title = array();
        foreach ($prop2loop as $key => $elem) {
            $prop = $elem['prop'];
            if ($cfg->{$prop}->type == 'string' && $cfg->{$prop}->value != '') {
                $title[$key] = lang_get($cfg->{$prop}->value);
            } else {
                if ($cfg->{$prop}->type == 'none') {
                    $title[$key] = '';
                } else {
                    $title[$key] = lang_get($elem['default_lbl']) . ": ";
                }
            }
        }
    }
    $prefix = $tproject_mgr->getTestCasePrefix($tprojectID);
    $string2replace = array();
    // configure target in which link shall open
    // use a reasonable default value if nothing is set in config
    $cfg->target = isset($cfg->target) ? $cfg->target : 'popup';
    switch ($cfg->target) {
        case 'popup':
            // use javascript to open popup window
            $string2replace['req'] = '<a href="javascript:openLinkedReqVersionWindow(%s,%s,\'%s\')">%s%s%s</a>';
            $string2replace['req_spec'] = '<a href="javascript:openLinkedReqSpecWindow(%s,\'%s\')">%s%s</a>';
            break;
        case 'window':
        case 'frame':
            // open in same frame
            $target = $cfg->target == 'window' ? 'target="_blank"' : 'target="_self"';
            $string2replace['req'] = '<a ' . $target . ' href="lib/requirements/reqView.php?' . 'item=requirement&requirement_id=%s&req_version_id=%s#%s">%s%s%s</a>';
            $string2replace['req_spec'] = '<a ' . $target . ' href="lib/requirements/reqSpecView.php?' . 'item=req_spec&req_spec_id=%s#%s">%s%s</a>';
            break;
    }
    // now the actual replacing
    $patterns2search = array();
    $patterns2search['req'] = "#\\[req(.*)\\](.*)\\[/req\\]#iU";
    $patterns2search['req_spec'] = "#\\[req_spec(.*)\\](.*)\\[/req_spec\\]#iU";
    $patternPositions = array('complete_string' => 0, 'attributes' => 1, 'doc_id' => 2);
    $items2search['req'] = array('tproj', 'anchor', 'version');
    $items2search['req_spec'] = array('tproj', 'anchor');
    $itemPositions = array('item' => 0, 'item_value' => 1);
    $sql2exec = array();
    $sql2exec['req'] = " SELECT id, req_doc_id AS doc_id " . " FROM {$tables['requirements']} WHERE req_doc_id=";
    $sql2exec['req_spec'] = " SELECT id, doc_id FROM {$tables['req_specs']} " . " WHERE doc_id=";
    foreach ($patterns2search as $accessKey => $pattern) {
        $matches = array();
        preg_match_all($pattern, $scope, $matches);
        // if no req_doc_id is set skip loop
        if (count($matches[$patternPositions['doc_id']]) == 0) {
            continue;
        }
        foreach ($matches[$patternPositions['complete_string']] as $key => $matched_string) {
            $matched = array();
            $matched['tproj'] = '';
            $matched['anchor'] = '';
            $matched['version'] = '';
            // only look for attributes if any found
            if ($matches[$patternPositions['attributes']][$key] != '') {
                foreach ($items2search[$accessKey] as $item) {
                    $matched_item = array();
                    preg_match('/' . $item . '=([\\w]+)/', $matched_string, $matched_item);
                    $matched[$item] = isset($matched_item[$itemPositions['item_value']]) ? $matched_item[$itemPositions['item_value']] : '';
                }
            }
            // set tproj to current project if tproj is not specified in attributes
            if (!isset($matched['tproj']) || $matched['tproj'] == '') {
                $matched['tproj'] = $prefix;
            }
            // get all reqs / req specs with the specified doc_id
            $sql = $sql2exec[$accessKey] . "'{$matches[$patternPositions['doc_id']][$key]}'";
            $rs = $dbHandler->get_recordset($sql);
            if (count($rs) > 0) {
                foreach ($rs as $key => $value) {
                    // get root of linked node and check
                    $real_root = $tree_mgr->getTreeRoot($value['id']);
                    $matched_root_info = $tproject_mgr->get_by_prefix($matched['tproj']);
                    // do only continue if project with the specified project exists and
                    // if the requirement really belongs to the specified project (requirements
                    // with the same doc_id may exist within different projects)
                    if ($real_root == $matched_root_info['id']) {
                        if ($accessKey == 'req') {
                            // add version to link title if set
                            $version = '';
                            $req_version_id = 'null';
                            if ($matched['version'] != '') {
                                // get requirement version_id of the specified version
                                $req_version = $req_mgr->get_by_id($value['id'], null, $matched['version']);
                                // if version is not set or wrong version was set
                                // -> show latest version by setting version_id to null
                                $req_version_id = isset($req_version[0]['version_id']) ? $req_version[0]['version_id'] : 'null';
                                // if req_version_id exists set the version to show on hyperlink text
                                if ($req_version_id != 'null') {
                                    $version = sprintf($l18n['version'], $matched['version']);
                                }
                            }
                            $urlString = sprintf($string2replace[$accessKey], $value['id'], $req_version_id, $matched['anchor'], $title[$accessKey], $value['doc_id'], $version);
                        } else {
                            // build urlString for req specs which do not have a version
                            $urlString = sprintf($string2replace[$accessKey], $value['id'], $matched['anchor'], $title[$accessKey], $value['doc_id']);
                        }
                        $scope = str_replace($matched_string, $urlString, $scope);
                    }
                }
            }
        }
    }
    return $scope;
}
/**
 * Initialize gui (stdClass) object that will be used as argument
 * in call to Template Engine.
 *
 * @param class pointer args: object containing User Input and some session values
 *    TBD structure
 * 
 * ?     tprojectMgr: test project manager object.
 * ?     treeDragDropEnabled: true/false. Controls Tree drag and drop behaivor.
 * 
 * @return stdClass TBD structure
 */
function initializeGui(&$db, $args)
{
    $tcaseCfg = config_get('testcase_cfg');
    $reqCfg = config_get('req_cfg');
    $gui = new stdClass();
    $gui->showOptionsCheckBoxes = $gui->showOptions = $args->showOptions;
    $gui->showHelpIcon = $args->showHelpIcon;
    $gui->mainTitle = '';
    $gui->outputFormat = array(FORMAT_HTML => lang_get('format_html'), FORMAT_MSWORD => lang_get('format_pseudo_msword'));
    $gui->outputOptions = init_checkboxes($args);
    if ($gui->showOptions == false) {
        $loop2do = count($gui->outputOptions);
        for ($idx = 0; $idx < $loop2do; $idx++) {
            $gui->outputOptions[$idx]['checked'] = 'y';
        }
    }
    $tprojectMgr = new testproject($db);
    $tcasePrefix = $tprojectMgr->getTestCasePrefix($args->tproject_id);
    $gui->tree_title = '';
    $gui->ajaxTree = new stdClass();
    $gui->ajaxTree->root_node = new stdClass();
    $gui->ajaxTree->dragDrop = new stdClass();
    $gui->ajaxTree->dragDrop->enabled = false;
    $gui->ajaxTree->dragDrop->BackEndUrl = null;
    $gui->ajaxTree->children = '';
    // improved cookie prefix for test spec doc and req spec doc
    $gui->ajaxTree->cookiePrefix = $args->doc_type . '_doc_';
    $gui->doc_type = $args->doc_type;
    $addTestPlanID = false;
    switch ($args->doc_type) {
        case DOC_REQ_SPEC:
            $gui->showOptions = true;
            $gui->showOptionsCheckBoxes = false;
            $gui->tree_title = lang_get('title_req_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/getrequirementnodes.php?' . "root_node={$args->tproject_id}&show_children=0&operation=print";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP_RS({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $req_qty = $tprojectMgr->count_all_requirements($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$req_qty})";
            $gui->ajaxTree->cookiePrefix .= "tproject_id_" . $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('requirement_specification_report');
            break;
        case DOC_TEST_SPEC:
            $gui->tree_title = lang_get('title_tc_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$args->tproject_id}&" . "show_tcases=0&operation=print&" . "tcprefix=" . urlencode($tcasePrefix . $tcaseCfg->glue_character) . "}";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $tcase_qty = $tprojectMgr->count_testcases($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$tcase_qty})";
            $gui->ajaxTree->cookiePrefix .= "tproject_id_" . $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('testspecification_report');
            break;
        case DOC_TEST_PLAN_EXECUTION:
            $addTestPlanID = true;
            $gui->mainTitle = lang_get('test_report');
            break;
        case DOC_TEST_PLAN_DESIGN:
            $addTestPlanID = true;
            $gui->tree_title = lang_get('title_tp_print_navigator');
            $gui->ajaxTree->loadFromChildren = 1;
            $gui->ajaxTree->loader = '';
            $gui->mainTitle = lang_get('test_plan');
            break;
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $addTestPlanID = true;
            $gui->mainTitle = lang_get('test_report_on_build');
            break;
    }
    // Do not move
    if ($args->mainTitle == '') {
        $gui->mainTitle .= ' - ' . lang_get('doc_opt_title');
    } else {
        $gui->mainTitle = $args->mainTitle;
    }
    $gui->getArguments = "&type=" . $args->doc_type;
    if ($addTestPlanID) {
        $gui->getArguments .= '&docTestPlanId=' . $args->tplan_id;
    }
    return $gui;
}
예제 #29
0
 *
 * internal revisions
 *
**/
require_once '../../config.inc.php';
require_once "common.php";
testlinkInitPage($db, 'initProject' == 'initProject');
$tproject_mgr = new testproject($db);
$args = init_args();
$gui = new stdClass();
$gui_cfg = config_get("gui");
$gui->tprojectID = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
$gui->tcasePrefix = '';
$gui->searchSize = 8;
if ($gui->tprojectID > 0) {
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($gui->tprojectID) . config_get('testcase_cfg')->glue_character;
    $gui->searchSize = tlStringLen($gui->tcasePrefix) + $gui_cfg->dynamic_quick_tcase_search_input_size;
}
$gui->TestProjects = $tproject_mgr->get_accessible_for_user($args->user->dbID, array('output' => 'map_name_with_inactive_mark', 'order_by' => $tlCfg->gui->tprojects_combo_order_by));
$gui->TestProjectCount = sizeof($gui->TestProjects);
$gui->TestPlanCount = 0;
$tprojectQty = $tproject_mgr->getItemCount();
if ($gui->TestProjectCount == 0 && $tprojectQty > 0) {
    // User rights configurations does not allow access to ANY test project
    $_SESSION['testprojectTopMenu'] = '';
    $gui->tprojectID = 0;
}
if ($gui->tprojectID) {
    $testPlanSet = $args->user->getAccessibleTestPlans($db, $gui->tprojectID);
    $gui->TestPlanCount = sizeof($testPlanSet);
    $tplanID = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : null;
예제 #30
0
function initializeGui(&$dbHandler, &$argsObj)
{
    $guiObj = new stdClass();
    $guiObj->pageTitle = lang_get('caption_testCasesWithCF');
    $guiObj->warning_msg = '';
    $guiObj->tcasePrefix = '';
    $guiObj->path_info = null;
    $guiObj->resultSet = null;
    $guiObj->tproject_name = $argsObj->tproject_name;
    $guiObj->tplan_name = $argsObj->tplan_name;
    $guiObj->tplan_id = $argsObj->tplan_id;
    $tproject_mgr = new testproject($dbHandler);
    $guiObj->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    unset($tproject_mgr);
    // Get the mapping for the Verbose Status Description of Test Case Status
    $resultsCfg = config_get('results');
    $guiObj->code_status = $resultsCfg['code_status'];
    foreach ($guiObj->code_status as $code => $verbose) {
        if (isset($resultsCfg['status_label'][$verbose])) {
            $guiObj->status_code_labels[$code] = lang_get($resultsCfg['status_label'][$verbose]);
        }
    }
    return $guiObj;
}