/** * * */ 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) { $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; }
/** * 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; }
/** * 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; }
$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': $tsuite = new testsuite($db);
/** * 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; }
$testcases = array(); // first step: get the requirements and linked testcases with which we have to work, // order them into $req_spec_map by spec if (count($req_ids)) { foreach ($req_ids as $id) { // get the information for this requirement $req = $req_mgr->get_by_id($id, requirement_mgr::LATEST_VERSION); $req_info = $req[0]; $spec_id = $req_info['srs_id']; // if req is "usable" (either finished status or all requested) add it if (!$args->show_only_finished || $req_info['status'] == TL_REQ_STATUS_FINISH) { // coverage data $linked_tcs = (array) $req_mgr->get_coverage($id); $req_info['linked_testcases'] = $linked_tcs; if (!isset($req_spec_map[$spec_id])) { $spec_info = $req_spec_mgr->get_by_id($spec_id); $req_spec_map[$spec_id] = $spec_info; $req_spec_map[$spec_id]['requirements'] = array(); } $req_spec_map[$spec_id]['requirements'][$id] = $req_info; foreach ($linked_tcs as $tc) { $tc_ids[] = $tc['id']; } } } // BUGID 3439 if (!count($req_spec_map)) { $gui->warning_msg = lang_get($no_finished_reqs_msg_key); } } else { $gui->warning_msg = lang_get($no_srs_msg_key);
/** * * */ 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']; }
/** * 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; }
/** * * */ 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; }
/** * * */ 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; }
/** * 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; }