Beispiel #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->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;
}
Beispiel #2
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;
}
$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');
    }
}
Beispiel #4
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;
}
Beispiel #5
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;
}
Beispiel #6
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;
}