示例#1
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;
}
示例#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;
}
/**
 * 
 *
 */
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;
}
示例#5
0
/**
 * process_reqspec
 *
 */
function process_reqspec(&$dbHandler, $docID, $tprojectID, $tprojectPrefix, $version)
{
    $ret = array();
    $ret['url'] = null;
    $ret['msg'] = sprintf(lang_get('req_spec_not_found'), $docID, $tprojectPrefix);
    $reqspec_mgr = new requirement_spec_mgr($dbHandler);
    $reqSpec = $reqspec_mgr->getByDocID($docID, $tprojectID);
    if (!is_null($reqSpec)) {
        $reqSpec = current($reqSpec);
        $id = $reqSpec['id'];
        $ret['url'] = "lib/requirements/reqSpecView.php?req_spec_id={$id}";
        $cookie = buildCookie($dbHandler, $id, $tprojectID, 'ys-requirement_spec');
        setcookie($cookie['value'], $cookie['path'], TL_COOKIE_KEEPTIME, '/');
    }
    return $ret;
}
示例#6
0
$doc_info->tproject_name = htmlspecialchars($tproject_info['name']);
$doc_info->tproject_scope = $tproject_info['notes'];
$user = tlUser::getById($db, $_SESSION['userID']);
if ($user) {
    $doc_info->author = htmlspecialchars($user->getDisplayName());
}
$treeForPlatform = null;
switch ($doc_info->type) {
    case DOC_REQ_SPEC:
        switch ($doc_info->content_range) {
            case 'testproject':
                $tree =& $subtree;
                $doc_info->title = $doc_info->tproject_name;
                break;
            case 'reqspec':
                $spec_mgr = new requirement_spec_mgr($db);
                $spec = $spec_mgr->get_by_id($args->itemID);
                $spec['childNodes'] = isset($subtree['childNodes']) ? $subtree['childNodes'] : null;
                $spec['node_type_id'] = $hash_descr_id['requirement_spec'];
                $tree['childNodes'][0] =& $spec;
                $doc_info->title = htmlspecialchars($args->tproject_name . $tlCfg->gui_title_separator_2 . $spec['title']);
                break;
        }
        // $doc_info->content_range
        $treeForPlatform[0] = $tree;
        break;
        break;
    case DOC_TEST_SPEC:
        // test specification
        switch ($doc_info->content_range) {
            case 'testproject':
$tables = tlObjectWithDB::getDBTables(array('req_coverage', 'nodes_hierarchy', 'tcversions', 'node_types'));
$args = init_args();
$tproject_mgr = new testproject($db);
// get list of available Req Specification
// $reqSpec = $tproject_mgr->getOptionReqSpec($args->tproject_id);
$reqSpec = $tproject_mgr->genComboReqSpec($args->tproject_id);
$uncovered = null;
$gui = new stdClass();
$gui->items = null;
$gui->tproject_name = $args->tproject_name;
$gui->has_reqspec = count($reqSpec) > 0;
$gui->has_requirements = false;
$gui->has_tc = false;
if ($gui->has_reqspec) {
    // Check if at least one of these requirement spec are not empty.
    $reqSpecMgr = new requirement_spec_mgr($db);
    foreach ($reqSpec as $reqSpecID => $name) {
        if ($gui->has_requirements = $reqSpecMgr->get_requirements_count($reqSpecID) > 0) {
            break;
        }
    }
    unset($reqSpecMgr);
}
if ($gui->has_requirements) {
    // get all test cases id (active/inactive) in test project
    $tcasesID = null;
    $tproject_mgr->get_all_testcases_id($args->tproject_id, $tcasesID);
    if (!is_null($tcasesID) && count($tcasesID) > 0) {
        $debugMsg = 'File: ' . basename(__FILE__) . ' - Line: ' . __LINE__ . ' - ';
        $sql = " /* {$debugMsg} */ " . " SELECT NHA.id AS tc_id, NHA.name, NHA.parent_id AS testsuite_id," . " NT.description, REQC.req_id " . " FROM {$tables['nodes_hierarchy']} NHA " . " JOIN {$tables['node_types']} NT ON NHA.node_type_id=NT.id " . " LEFT OUTER JOIN {$tables['req_coverage']} REQC on REQC.testcase_id=NHA.id " . " WHERE NT.description='testcase' AND NHA.id IN (" . implode(",", $tcasesID) . ") " . " and REQC.req_id IS NULL ";
        $uncovered = $db->fetchRowsIntoMap($sql, 'tc_id');
示例#8
0
/**
 * Prepares nodes in the filtered requirement tree for displaying with ExtJS.
 * @author Andreas Simon
 * @param Database $db reference to database handler object
 * @param array $node the object to prepare
 * @param array $filtered_map a map of filtered requirements, req that are not in this map will be deleted
 * @param array $map_id_nodetype array with node type IDs as keys, node type descriptions as values
 * @return array tree object with all needed data for ExtJS tree
 */
function render_reqspec_treenode(&$db, &$node, &$filtered_map, &$map_id_nodetype)
{
    static $js_functions;
    static $forbidden_parents;
    if (!$js_functions) {
        $js_functions = array('testproject' => 'TPROJECT_REQ_SPEC_MGMT', 'requirement_spec' => 'REQ_SPEC_MGMT', 'requirement' => 'REQ_MGMT');
        $req_cfg = config_get('req_cfg');
        $forbidden_parents['testproject'] = 'none';
        $forbidden_parents['requirement'] = 'testproject';
        // Hmm is ok ? (see next lines, may be it's time to remove this code)
        $forbidden_parents['requirement_spec'] = 'requirement_spec';
        if ($req_cfg->child_requirements_mgmt) {
            $forbidden_parents['requirement_spec'] = 'none';
        }
    }
    $node_type = $map_id_nodetype[$node['node_type_id']];
    $node_id = $node['id'];
    $node['href'] = "javascript:{$js_functions[$node_type]}({$node_id});";
    $node['text'] = htmlspecialchars($node['name']);
    $node['leaf'] = false;
    // will be set to true later for requirement nodes
    $node['position'] = isset($node['node_order']) ? $node['node_order'] : 0;
    $node['cls'] = 'folder';
    // custom Properties that will be accessed by EXT-JS using node.attributes
    $node['testlink_node_type'] = $node_type;
    $node['forbidden_parent'] = $forbidden_parents[$node_type];
    $node['testlink_node_name'] = $node['text'];
    switch ($node_type) {
        case 'testproject':
            break;
        case 'requirement_spec':
            // get doc id from filtered array, it's already stored in there
            $doc_id = '';
            foreach ($node['childNodes'] as $child) {
                if (!is_null($child)) {
                    $child_id = $child['id'];
                    if (isset($filtered_map[$child_id])) {
                        $doc_id = htmlspecialchars($filtered_map[$child_id]['req_spec_doc_id']);
                    }
                    break;
                    // only need to get one child for this
                }
            }
            // BUGID 3765: load doc ID with  if this req spec has no direct req child nodes.
            // Reason: in these cases we do not have a parent doc ID in $filtered_map
            if ($doc_id == '') {
                static $req_spec_mgr = null;
                if (!$req_spec_mgr) {
                    $req_spec_mgr = new requirement_spec_mgr($db);
                }
                $tmp_spec = $req_spec_mgr->get_by_id($node_id);
                $doc_id = $tmp_spec['doc_id'];
                unset($tmp_spec);
            }
            $count = $node['child_req_count'];
            $node['text'] = "{$doc_id}:{$node['text']} ({$count})";
            break;
        case 'requirement':
            $node['leaf'] = true;
            $doc_id = htmlspecialchars($filtered_map[$node_id]['req_doc_id']);
            $node['text'] = "{$doc_id}:{$node['text']}";
            break;
    }
    return $node;
}
示例#9
0
$topText = '';
$doc_data = new stdClass();
// gather content and tests related data
list($args, $tproject_mgr, $decode) = init_args($db);
$tree_manager =& $tproject_mgr->tree_manager;
list($doc_info, $my) = initEnv($db, $args, $tproject_mgr, $args->user_id);
$printingOptions = initPrintOpt($_REQUEST, $doc_info);
$subtree = $tree_manager->get_subtree($args->itemID, $my['filters'], $my['options']);
$treeForPlatform[0] =& $subtree;
$doc_info->title = $doc_info->tproject_name;
$doc_info->outputFormat = $printingOptions['outputFormat'] = $args->format;
switch ($doc_info->type) {
    case DOC_REQ_SPEC:
        switch ($doc_info->content_range) {
            case 'reqspec':
                $spec_mgr = new requirement_spec_mgr($db);
                $spec = $spec_mgr->get_by_id($args->itemID);
                unset($spec_mgr);
                $spec['childNodes'] = isset($subtree['childNodes']) ? $subtree['childNodes'] : null;
                $spec['node_type_id'] = $decode['node_descr_id']['requirement_spec'];
                unset($treeForPlatform[0]['childNodes']);
                $treeForPlatform[0]['childNodes'][0] =& $spec;
                $doc_info->title = htmlspecialchars($args->tproject_name . $tlCfg->gui_title_separator_2 . $spec['title']);
                break;
        }
        // $doc_info->content_range
        break;
    case DOC_TEST_SPEC:
        $printingOptions['importance'] = $doc_info->test_priority_enabled;
        switch ($doc_info->content_range) {
            case 'testsuite':
示例#10
0
/**
 * render a requirement specification node as HTML code for printing
 * 
 * @author Andreas Simon
 * 
 * @param resource $db
 * @param array $node the node to be printed
 * @param array $options
 * @param string $tocPrefix Prefix to be printed in TOC before title of node
 * @param int $level
 * @param int $tprojectID
 * 
 * @return string $output HTML Code
 */
function renderReqSpecNodeForPrinting(&$db, &$node, &$options, $tocPrefix, $level, $tprojectID)
{
    static $tableColspan;
    static $firstColWidth;
    static $labels;
    static $title_separator;
    static $req_spec_mgr;
    static $tplan_mgr;
    static $req_spec_cfg;
    static $reqSpecTypeLabels;
    static $nodeTypes;
    $output = '';
    $level = $level > 0 ? $level : 1;
    if (!$req_spec_mgr) {
        $req_spec_cfg = config_get('req_spec_cfg');
        $firstColWidth = '20%';
        $tableColspan = 2;
        $labels = array('requirements_spec' => 'requirements_spec', 'scope' => 'scope', 'type' => 'type', 'author' => 'author', 'relations' => 'relations', 'overwritten_count' => 'req_total', 'coverage' => 'coverage', 'revision' => 'revision', 'undefined_req_spec_type' => 'undefined_req_spec_type', 'custom_field' => 'custom_field', 'not_aplicable' => 'not_aplicable');
        $labels = init_labels($labels);
        $reqSpecTypeLabels = init_labels($req_spec_cfg->type_labels);
        $title_separator = config_get('gui_title_separator_1');
        $req_spec_mgr = new requirement_spec_mgr($db);
        $tplan_mgr = new testplan($db);
        $nodeTypes = array_flip($tplan_mgr->tree_manager->get_available_node_types());
    }
    switch ($nodeTypes[$node['node_type_id']]) {
        case 'requirement_spec_revision':
            $spec = $req_spec_mgr->getRevisionByID($node['id']);
            $spec_id = $spec['parent_id'];
            $who = array('parent_id' => $spec['parent_id'], 'item_id' => $spec['id'], 'tproject_id' => $spec['testproject_id']);
            break;
        case 'requirement_spec':
            $spec = $req_spec_mgr->get_by_id($node['id']);
            $spec_id = $spec['id'];
            $who = array('parent_id' => $spec['id'], 'item_id' => $spec['revision_id'], 'tproject_id' => $spec['testproject_id']);
            break;
    }
    $name = htmlspecialchars($spec['doc_id'] . $title_separator . $spec['title']);
    $docHeadingNumbering = $options['headerNumbering'] ? "{$tocPrefix}. " : '';
    if ($options['docType'] != SINGLE_REQSPEC) {
        $output = '<p style="page-break-before: always"></p>';
    }
    $output .= "<table class=\"req_spec\"><tr><th colspan=\"{$tableColspan}\">" . "<h{$level} class=\"doclevel\"> <span class=\"label\">{$docHeadingNumbering}{$labels['requirements_spec']}:</span> " . $name . "</th></tr></h{$level}>\n";
    if ($options['toc']) {
        $spacing = $level == 2 ? "<br>" : "";
        $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $level . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n";
        $output .= "<a name='" . prefixToHTMLID($tocPrefix) . "'></a>\n";
    }
    $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['revision'] . "</span></td><td> " . $spec['revision'] . "</td></tr>\n";
    if ($options['req_spec_author']) {
        // get author name for node
        $author = tlUser::getById($db, $spec['author_id']);
        $whois = is_null($author) ? lang_get('undefined') : $author->getDisplayName();
        $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['author'] . "</span></td><td> " . htmlspecialchars($whois) . "</td></tr>\n";
    }
    if ($options['req_spec_type']) {
        $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['type'] . "</span></td>" . "<td>";
        if (isset($reqSpecTypeLabels[$spec['type']])) {
            $output .= $reqSpecTypeLabels[$spec['type']];
        } else {
            $output .= sprintf($labels['undefined_req_spec_type'], $spec['type']);
        }
        $output .= "</td></tr>";
    }
    if ($options['req_spec_overwritten_count_reqs']) {
        $current = $req_spec_mgr->get_requirements_count($spec['id']);
        $expected = $spec['total_req'];
        $coverage = $labels['not_aplicable'] . " ({$current}/0)";
        if ($expected) {
            $percentage = round(100 / $expected * $current, 2);
            $coverage = "{$percentage}% ({$current}/{$expected})";
        }
        $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['overwritten_count'] . " (" . $labels['coverage'] . ")</span></td>" . "<td>" . $coverage . "</td></tr>";
    }
    if ($options['req_spec_scope']) {
        $output .= "<tr><td colspan=\"{$tableColspan}\">" . $spec['scope'] . "</td></tr>";
    }
    if ($options['req_spec_cf']) {
        $linked_cf = $req_spec_mgr->get_linked_cfields($who);
        if ($linked_cf) {
            foreach ($linked_cf as $key => $cf) {
                $cflabel = htmlspecialchars($cf['label']);
                $value = htmlspecialchars($cf['value']);
                $output .= "<tr><td width=\"{$firstColWidth}\"><span class=\"label\">" . $cflabel . "</span></td>" . "<td>{$value}</td></tr>";
            }
        }
    }
    $output .= "</table><br/>\n";
    return $output;
}
示例#11
0
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, &$argsObj, &$commandMgr)
{
    $req_spec_mgr = new requirement_spec_mgr($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->req_cfg = config_get('req_cfg');
    $gui->req_spec_id = $argsObj->req_spec_id;
    if ($argsObj->req_spec_id) {
        $gui->requirements_count = $req_spec_mgr->get_requirements_count($gui->req_spec_id);
        $gui->req_spec = $req_spec_mgr->get_by_id($gui->req_spec_id);
    }
    $gui->user_feedback = null;
    $gui->main_descr = lang_get('req_spec_short');
    if (isset($gui->req_spec)) {
        $gui->main_descr .= config_get('gui_title_separator_1') . $gui->req_spec['title'];
    }
    $gui->action_descr = null;
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = has_rights($dbHandler, "mgt_modify_req");
    $gui->grants->mgt_view_events = has_rights($dbHandler, "mgt_view_events");
    // 20100811 - asimon - fixed two warnings because of undefined variables in template
    $gui->req_version_id = $argsObj->req_version_id;
    $gui->preSelectedType = TL_REQ_TYPE_USE_CASE;
    return $gui;
}
示例#12
0
 * @copyright 	2005-2011, TestLink community
 * @link 		http://www.teamst.org/index.php
 *
 * create printer friendly information for ONE Requirement Specification
 *
 * @internal revisions:
 */
require_once "../../config.inc.php";
require_once "../../cfg/reports.cfg.php";
require_once "print.inc.php";
require_once "common.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$req_cfg = config_get('req_cfg');
$tree_mgr = new tree($db);
$reqspec_mgr = new requirement_spec_mgr($db);
$args = init_args($tree_mgr);
checkRights($db, $_SESSION['currentUser'], $args);
$node = $tree_mgr->get_node_hierarchy_info($args->reqspec_id);
$gui = new stdClass();
$gui->object_name = '';
$gui->object_name = $node['name'];
$gui->page_title = sprintf(lang_get('print_requirement_specification'), $node['name']);
$gui->tproject_name = $args->tproject_name;
$gui->tproject_id = $args->tproject_id;
$gui->reqspec_id = $args->reqspec_id;
// Struture defined in printDocument.php
$options = array('toc' => 0, 'req_spec_scope' => 1, 'req_spec_author' => 1, 'req_spec_type' => 1, 'req_spec_cf' => 1, 'req_spec_overwritten_count_reqs' => 1, 'headerNumbering' => 0, 'docType' => SINGLE_REQSPEC);
$text2print = '';
$text2print .= renderHTMLHeader($gui->page_title, $_SESSION['basehref'], SINGLE_REQSPEC) . '<body>';
//$text2print .= '<div><h2>' . lang_get('req_specification') . '</h2></div>';
示例#13
0
/**
 * processTestCase
 *
 */
function processTestCase(&$dbHandler, &$argsObj, &$guiObj)
{
    $tproject_mgr = new testproject($dbHandler);
    // $guiObj->arrReqSpec = $tproject_mgr->getOptionReqSpec($argsObj->tproject_id,testproject::GET_NOT_EMPTY_REQSPEC);
    $guiObj->arrReqSpec = $tproject_mgr->genComboReqSpec($argsObj->tproject_id);
    $SRS_qty = count($guiObj->arrReqSpec);
    if ($SRS_qty > 0) {
        $tc_mgr = new testcase($dbHandler);
        $arrTc = $tc_mgr->get_by_id($argsObj->id);
        if ($arrTc) {
            $guiObj->tcTitle = $arrTc[0]['name'];
            // get first ReqSpec if not defined
            if (is_null($argsObj->idReqSpec)) {
                reset($guiObj->arrReqSpec);
                $argsObj->idReqSpec = key($guiObj->arrReqSpec);
            }
            if ($argsObj->idReqSpec) {
                $req_spec_mgr = new requirement_spec_mgr($dbHandler);
                $guiObj->arrAssignedReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec, 'assigned', $argsObj->id);
                $guiObj->arrAllReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec);
                $guiObj->arrUnassignedReq = array_diff_byId($guiObj->arrAllReq, $guiObj->arrAssignedReq);
            }
        }
    }
    return $guiObj;
}
示例#14
0
 * @modified $Date: 2009/09/28 08:43:22 $ by $Author: franciscom $
 * @author Martin Havlat
 * 
 * Analyse coverage of a req. specification.
 */
require_once "../../config.inc.php";
require_once "common.php";
require_once 'requirements.inc.php';
require_once 'requirement_spec_mgr.class.php';
require_once 'requirement_mgr.class.php';
testlinkInitPage($db, false, false, "checkRights");
$template_dir = 'requirements/';
$default_template = str_replace('.php', '.tpl', basename($_SERVER['SCRIPT_NAME']));
$args = init_args();
$tproject_mgr = new testproject($db);
$req_spec_mgr = new requirement_spec_mgr($db);
$tcasecfg = config_get('testcase_cfg');
$tcprefix = $tproject_mgr->getTestCasePrefix($args->tprojectID) . $tcasecfg->glue_character;
// get list of ReqSpec
$ns = new stdClass();
// $ns->reqSpec = $tproject_mgr->getOptionReqSpec($args->tprojectID);
$ns->reqSpec = $tproject_mgr->genComboReqSpec($args->tprojectID);
//get first ReqSpec if not defined
if ($args->reqSpecID == 0 && count($ns->reqSpec)) {
    reset($ns->reqSpec);
    $args->reqSpecID = key($ns->reqSpec);
}
// collect REQ data
$ns->coverage = $req_spec_mgr->get_coverage($args->reqSpecID);
$ns->metrics = $req_spec_mgr->get_metrics($args->reqSpecID);
$smarty = new TLSmarty();
示例#15
0
/**
 * processTestCase
 *
 */
function processTestCase(&$dbHandler, &$argsObj, &$guiObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $guiObj->arrReqSpec = $tproject_mgr->genComboReqSpec($argsObj->tproject_id, 'dotted', "&nbsp;");
    $SRS_qty = count($guiObj->arrReqSpec);
    if ($SRS_qty > 0) {
        $tc_mgr = new testcase($dbHandler);
        $arrTc = $tc_mgr->get_by_id($argsObj->id);
        if ($arrTc) {
            $guiObj->tcTitle = $arrTc[0]['name'];
            // get first ReqSpec if not defined
            if (is_null($argsObj->idReqSpec)) {
                reset($guiObj->arrReqSpec);
                $argsObj->idReqSpec = key($guiObj->arrReqSpec);
            }
            if ($argsObj->idReqSpec) {
                $req_spec_mgr = new requirement_spec_mgr($dbHandler);
                $guiObj->arrAssignedReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec, 'assigned', $argsObj->id);
                if (!is_null($guiObj->arrAssignedReq)) {
                    $xc = $req_spec_mgr->getAssignedCoverage($argsObj->idReqSpec);
                    $l2d = count($guiObj->arrAssignedReq);
                    for ($xdx = 0; $xdx < $l2d; $xdx++) {
                        $guiObj->arrAssignedReq[$xdx]['coverageAuthor'] = $xc[$guiObj->arrAssignedReq[$xdx]['id']]['login'];
                        $guiObj->arrAssignedReq[$xdx]['coverageTS'] = $xc[$guiObj->arrAssignedReq[$xdx]['id']]['creation_ts'];
                    }
                }
                $guiObj->arrAllReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec);
                $guiObj->arrUnassignedReq = array_diff_byId($guiObj->arrAllReq, $guiObj->arrAssignedReq);
            }
        }
    }
    return $guiObj;
}
示例#16
0
/**
 * 
 *
 */
function initialize_gui(&$dbHandler, &$argsObj, &$commandMgr)
{
    $req_spec_mgr = new requirement_spec_mgr($dbHandler);
    $gui = $commandMgr->initGuiBean();
    $gui->req_cfg = config_get('req_cfg');
    $gui->user_feedback = null;
    $gui->action_descr = null;
    $gui->main_descr = lang_get('req_spec_short');
    $gui->preSelectedType = TL_REQ_TYPE_USE_CASE;
    $gui->stay_here = $argsObj->stay_here;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->req_spec_id = $argsObj->req_spec_id;
    $gui->req_version_id = $argsObj->req_version_id;
    $gui->requirement_id = $argsObj->requirement_id;
    if ($argsObj->req_spec_id) {
        $gui->requirements_count = $req_spec_mgr->get_requirements_count($gui->req_spec_id);
        $gui->req_spec = $req_spec_mgr->get_by_id($gui->req_spec_id);
    }
    if (isset($gui->req_spec)) {
        $gui->main_descr .= config_get('gui_title_separator_1') . $gui->req_spec['title'];
    }
    $gui->grants = new stdClass();
    $gui->grants->req_mgmt = $argsObj->user->hasRight($dbHandler, "mgt_modify_req", $argsObj->tproject_id);
    $gui->grants->mgt_view_events = $argsObj->user->hasRight($dbHandler, "mgt_view_events");
    $module = $_SESSION['basehref'] . 'lib/requirements/';
    $context = "tproject_id={$gui->tproject_id}&requirement_id={$gui->requirement_id}" . "&req_spec_id={$gui->req_spec_id}";
    $gui->actions = new stdClass();
    $gui->actions->req_view = $module . "reqView.php?{$context}";
    return $gui;
}
示例#17
0
 /**
  * 
  *
  */
 private function copy_requirements($source_id, $target_id, $user_id)
 {
     $mappings = null;
     // need to get subtree and create a new one
     $filters = array();
     $filters['exclude_node_types'] = array('testplan' => 'exclude', 'testcase' => 'exclude', 'testsuite' => 'exclude', 'requirement' => 'exclude');
     $elements = $this->tree_manager->get_children($source_id, $filters['exclude_node_types']);
     if (!is_null($elements)) {
         $mappings = array();
         $reqSpecMgr = new requirement_spec_mgr($this->db);
         // Development Note - 20110817
         // why we choose to do not copy testcase_assignments ?
         // Because due to order used to copy different items, when we ask to copy
         // requirements WE DO NOT HAVE TEST CASES on new test project.
         //
         $options = array('copy_also' => array('testcase_assignments' => false), 'caller' => 'copy_testproject');
         foreach ($elements as $piece) {
             $op = $reqSpecMgr->copy_to($piece['id'], $target_id, $target_id, $user_id, $options);
             $mappings += $op['mappings'];
         }
     }
     return !is_null($mappings) && isset($mappings['req']) ? $mappings['req'] : null;
 }
示例#18
0
/**
 * render a requirement specification node as HTML code for printing
 * 
 * @author Andreas Simon
 * 
 * @param resource $db
 * @param array $node the node to be printed
 * @param array $printingOptions
 * @param string $tocPrefix Prefix to be printed in TOC before title of node
 * @param int $level
 * @param int $tprojectID
 * 
 * @return string $output HTML Code
 */
function renderReqSpecNodeForPrinting(&$db, &$node, &$printingOptions, $tocPrefix, $level, $tprojectID)
{
    static $tableColspan;
    static $firstColWidth;
    static $labels;
    static $title_separator;
    static $req_spec_mgr;
    static $tplan_mgr;
    static $req_spec_cfg;
    static $reqSpecTypeLabels;
    if (!$req_spec_mgr) {
        $req_spec_cfg = config_get('req_spec_cfg');
        $firstColWidth = '20%';
        $tableColspan = 2;
        $labels = array('requirements_spec' => 'requirements_spec', 'scope' => 'scope', 'type' => 'type', 'author' => 'author', 'relations' => 'relations', 'overwritten_count' => 'req_total', 'coverage' => 'coverage', 'custom_field' => 'custom_field', 'not_aplicable' => 'not_aplicable');
        $labels = init_labels($labels);
        $reqSpecTypeLabels = init_labels($req_spec_cfg->type_labels);
        $title_separator = config_get('gui_title_separator_1');
        $req_spec_mgr = new requirement_spec_mgr($db);
        $tplan_mgr = new testplan($db);
    }
    $spec = $req_spec_mgr->get_by_id($node['id']);
    $name = htmlspecialchars($spec['doc_id'] . $title_separator . $spec['title']);
    $docHeadingNumbering = '';
    if ($printingOptions['headerNumbering']) {
        $docHeadingNumbering = "{$tocPrefix}. ";
    }
    $output = "<table class=\"req_spec\"><tr><th colspan=\"{$tableColspan}\">" . "<span class=\"label\">{$docHeadingNumbering}{$labels['requirements_spec']}:</span> " . $name . "</th></tr>\n";
    if ($printingOptions['toc']) {
        $spacing = $level == 2 ? "<br>" : "";
        $printingOptions['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $level . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n";
        $output .= "<a name='" . prefixToHTMLID($tocPrefix) . "'></a>\n";
    }
    if ($printingOptions['req_spec_author']) {
        // get author name for node
        $author = tlUser::getById($db, $spec['author_id']);
        $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['author'] . "</span></td><td> " . htmlspecialchars($author->getDisplayName()) . "</td></tr>\n";
    }
    if ($printingOptions['req_spec_type']) {
        $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['type'] . "</span></td>" . "<td>" . $reqSpecTypeLabels[$spec['type']] . "</td></tr>";
    }
    if ($printingOptions['req_spec_overwritten_count_reqs']) {
        $current = $req_spec_mgr->get_requirements_count($spec['id']);
        $expected = $spec['total_req'];
        $coverage = $labels['not_aplicable'] . " ({$current}/0)";
        if ($expected) {
            $percentage = round(100 / $expected * $current, 2);
            $coverage = "{$percentage}% ({$current}/{$expected})";
        }
        $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['overwritten_count'] . " (" . $labels['coverage'] . ")</span></td>" . "<td>" . $coverage . "</td></tr>";
    }
    if ($printingOptions['req_spec_scope']) {
        $output .= "<tr><td colspan=\"{$tableColspan}\"><span class=\"label\">" . $labels['scope'] . "</span><br/>" . $spec['scope'] . "</td></tr>";
    }
    if ($printingOptions['req_spec_cf']) {
        $linked_cf = $req_spec_mgr->get_linked_cfields($spec['id']);
        if ($linked_cf) {
            foreach ($linked_cf as $key => $cf) {
                $cflabel = htmlspecialchars($cf['label']);
                $value = htmlspecialchars($cf['value']);
                $output .= "<tr><td width=\"{$firstColWidth}\"><span class=\"label\">" . $cflabel . "</span></td>" . "<td>{$value}</td></tr>";
            }
        }
    }
    $output .= "</table><br/>\n";
    return $output;
}
示例#19
0
 /**
  * 
  *
  */
 private function copy_requirements($source_id, $target_id, $user_id)
 {
     $mappings = null;
     // need to get subtree and create a new one
     $filters = array();
     $filters['exclude_node_types'] = array('testplan' => 'exclude', 'testcase' => 'exclude', 'testsuite' => 'exclude', 'requirement' => 'exclude');
     $elements = $this->tree_manager->get_children($source_id, $filters['exclude_node_types']);
     if (!is_null($elements)) {
         $mappings = array();
         $reqSpecMgr = new requirement_spec_mgr($this->db);
         $options = array('copy_also' => array('testcase_assignments' => false));
         foreach ($elements as $piece) {
             // function copy_to($id, $parent_id, $tproject_id, $user_id,$options = null)
             $op = $reqSpecMgr->copy_to($piece['id'], $target_id, $target_id, $user_id, $options);
             $mappings += $op['mappings'];
         }
     }
     return $mappings;
 }
 /**
  * 
  *
  */
 function getTestProjectID($id, $reqSpecID = null)
 {
     $reqSpecMgr = new requirement_spec_mgr($this->db);
     $parent = $reqSpecID;
     if (is_null($parent)) {
         $dummy = $this->tree_mgr->get_node_hierarchy_info($id);
         $parent = $dummy['parent_id'];
     }
     $target = $reqSpecMgr->get_by_id($parent);
     return $target['testproject_id'];
 }
 /**
  * Copy a requirement to a new requirement specification
  * requirement DOC ID will be changed because must be unique inside
  * MASTER CONTAINER (test project)
  * 
  * @param integer $id: requirement ID
  * @param integer $parent_id: target req spec id (where we want to copy)
  * @param integer $user_id: who is requesting copy
  * @param integer $tproject_id: optional, is null will be computed here
  * @param array $options: map
  *
  */
 function copy_to($id, $parent_id, $user_id, $tproject_id = null, $options = null)
 {
     $new_item = array('id' => -1, 'status_ok' => 0, 'msg' => 'ok', 'mappings' => null);
     $my['options'] = array('copy_also' => null);
     $my['options'] = array_merge($my['options'], (array) $options);
     if (is_null($my['options']['copy_also'])) {
         $my['options']['copy_also'] = array('testcase_assignment' => true);
     }
     $root = $tproject_id;
     if (!is_null($root)) {
         $reqSpecMgr = new requirement_spec_mgr($this->db);
         $target = $reqSpecMgr->get_by_id($parent_id);
         $root = $target['testproject_id'];
     }
     $target_doc = $this->generateDocID($id, $root);
     $item_versions = $this->get_by_id($id);
     if ($item_versions) {
         $new_item = $this->create_req_only($parent_id, $target_doc, $item_versions[0]['title'], $item_versions[0]['author_id'], $item_versions[0]['node_order']);
         if ($new_item['status_ok']) {
             $ret['status_ok'] = 1;
             $new_item['mappings'][$id] = $new_item['id'];
             foreach ($item_versions as $req_version) {
                 $op = $this->create_version($new_item['id'], $req_version['version'], $req_version['scope'], $req_version['author_id'], $req_version['status'], $req_version['type'], $req_version['expected_coverage']);
                 $new_item['mappings'][$req_version['id']] = $op['id'];
                 // BUGID 2877 - CF on version
                 $this->copy_cfields(array('id' => $req_version['id'], 'version_id' => $req_version['version_id']), array('id' => $new_item['id'], 'version_id' => $op['id']));
             }
             $this->copy_attachments($id, $new_item['id']);
             if (isset($my['options']['copy_also']['testcase_assignment']) && $my['options']['copy_also']['testcase_assignment']) {
                 $linked_items = $this->get_coverage($id);
                 if (!is_null($linked_items)) {
                     foreach ($linked_items as $value) {
                         $this->assign_to_tcase($new_item['id'], $value['id']);
                     }
                 }
             }
         }
     }
     return $new_item;
 }
示例#22
0
 *                     complete redesign/rewrite of requirement based report 
 * 20090506 - franciscom - requirements refactoring
 * 20090402 - amitkhullar - added TC version while displaying the Req -> TC Mapping 
 * 20090111 - franciscom - BUGID 1967 + improvements
 * 20060104 - fm - BUGID 0000311: Requirements based Report shows errors
 */
require_once "../../config.inc.php";
require_once "common.php";
require_once 'requirements.inc.php';
require_once 'exttable.class.php';
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$tproject_mgr = new testproject($db);
$tplan_mgr = new testplan($db);
$req_mgr = new requirement_mgr($db);
$req_spec_mgr = new requirement_spec_mgr($db);
$glue_char = config_get('gui_title_separator_1');
// BUGID 3439
$no_srs_msg_key = 'no_srs_defined';
$no_finished_reqs_msg_key = 'no_finished_reqs';
$charset = config_get('charset');
$req_cfg = config_get('req_cfg');
$req_spec_cfg = config_get('req_spec_cfg');
$results_cfg = config_get('results');
$coverage_algorithm = $req_cfg->coverageStatusAlgorithm;
$coverage_enabled = $req_cfg->expected_coverage_management;
$external_req_mgmt = $req_cfg->external_req_management;
$req_type_labels = init_labels($req_cfg->type_labels);
$req_spec_type_labels = init_labels($req_spec_cfg->type_labels);
$status_labels = init_labels($req_cfg->status_labels);
$labels = array('requirements' => lang_get('requirements'), 'type' => lang_get('type'), 'na' => lang_get('not_aplicable'), 'req_availability' => lang_get('req_availability'));
示例#23
0
function getReqDocIDs(&$db, $srs_id)
{
    $req_spec_mgr = new requirement_spec_mgr($db);
    $arrCurrentReq = $req_spec_mgr->get_requirements($srs_id);
    $result = null;
    if (count($arrCurrentReq)) {
        // only if some reqs exist
        foreach ($arrCurrentReq as $data) {
            $result[$data['id']] = $data['req_doc_id'];
        }
    }
    return $result;
}
 /**
  * Copy a requirement to a new requirement specification
  * requirement DOC ID will be changed because must be unique inside
  * MASTER CONTAINER (test project)
  * 
  * @param integer $id: requirement ID
  * @param integer $parent_id: target req spec id (where we want to copy)
  * @param integer $user_id: who is requesting copy
  * @param integer $tproject_id: optional, is null will be computed here
  * @param array $options: map
  *
  */
 function copy_to($id, $parent_id, $user_id, $tproject_id = null, $options = null)
 {
     $new_item = array('id' => -1, 'status_ok' => 0, 'msg' => 'ok', 'mappings' => null);
     $my['options'] = array('copy_also' => null);
     $my['options'] = array_merge($my['options'], (array) $options);
     if (is_null($my['options']['copy_also'])) {
         $my['options']['copy_also'] = array('testcase_assignment' => true);
     }
     $root = $tproject_id;
     if (!is_null($root)) {
         $reqSpecMgr = new requirement_spec_mgr($this->db);
         $target = $reqSpecMgr->get_by_id($parent_id);
         $root = $target['testproject_id'];
     }
     // REQ DOCID is test project wide => can not exist duplicates inside
     // a test project => we need to generate a new one using target as
     // starting point
     $target_doc = $this->generateDocID($id, $root);
     $item_versions = $this->get_by_id($id);
     if ($item_versions) {
         // BUGID 4150
         // If a sibling exists with same title => need to generate automatically
         // a new one.
         $title = $this->generateUniqueTitle($item_versions[0]['title'], $parent_id, $root);
         // $new_item = $this->create_req_only($parent_id,$target_doc,$item_versions[0]['title'],
         //                                   $item_versions[0]['author_id'],$item_versions[0]['node_order']);
         $new_item = $this->create_req_only($parent_id, $target_doc, $title, $item_versions[0]['author_id'], $item_versions[0]['node_order']);
         if ($new_item['status_ok']) {
             $ret['status_ok'] = 1;
             $new_item['mappings'][$id] = $new_item['id'];
             foreach ($item_versions as $req_version) {
                 $op = $this->create_version($new_item['id'], $req_version['version'], $req_version['scope'], $req_version['author_id'], $req_version['status'], $req_version['type'], $req_version['expected_coverage']);
                 $new_item['mappings'][$req_version['id']] = $op['id'];
                 // BUGID 2877 - CF on version
                 $this->copy_cfields(array('id' => $req_version['id'], 'version_id' => $req_version['version_id']), array('id' => $new_item['id'], 'version_id' => $op['id']));
             }
             $this->copy_attachments($id, $new_item['id']);
             if (isset($my['options']['copy_also']['testcase_assignment']) && $my['options']['copy_also']['testcase_assignment']) {
                 $linked_items = $this->get_coverage($id);
                 if (!is_null($linked_items)) {
                     foreach ($linked_items as $value) {
                         $this->assign_to_tcase($new_item['id'], $value['id']);
                     }
                 }
             }
         }
     }
     return $new_item;
 }