/** * @param resource &$db reference to database handler **/ public static function getAll(&$db, $whereClause = null, $column = null, $orderBy = null, $detailLevel = self::TLOBJ_O_GET_DETAIL_FULL) { $tables = tlObject::getDBTables('rights'); $sql = " SELECT id FROM {$tables['rights']} "; if (!is_null($whereClause)) { $sql .= ' ' . $whereClause; } $sql .= is_null($orderBy) ? " ORDER BY id ASC " : $orderBy; return tlDBObject::createObjectsFromDBbySQL($db, $sql, 'id', __CLASS__, true, $detailLevel); }
/** * Creates an attachment by a given database identifier * * @param $db [ref] the database connection * @param $id the database identifier of the attachment * @param $detailLevel the detailLevel * @return tlAttachment the created attachment or null on failure */ public static function getByID(&$db, $id, $detailLevel = self::TLOBJ_O_GET_DETAIL_FULL) { return tlDBObject::createObjectFromDB($db, $id, __CLASS__, tlAttachment::TLOBJ_O_SEARCH_BY_ID, $detailLevel); }
/** * create some keywords by given ids * * @param resource $db [ref] the database connection * @param array $ids the database identifiers of the keywords * @param integer $detailLevel an optional detaillevel, any combination of TLOBJ_O_GET_DETAIL Flags * * @return array returns the created keywords (tlKeyword) on success, or null else */ public static function getByIDs(&$db, $ids, $detailLevel = self::TLOBJ_O_GET_DETAIL_FULL) { return tlDBObject::createObjectsFromDB($db, $ids, __CLASS__, false, $detailLevel); }
public static function getAll(&$db, $whereClause = null, $column = null, $orderBy = null, $detailLevel = self::TLOBJ_O_GET_DETAIL_FULL) { $tables = tlObject::getDBTables("roles"); $sql = "SELECT id FROM {$tables['roles']} "; if (!is_null($whereClause)) { $sql .= ' ' . $whereClause; } $sql .= is_null($orderBy) ? " ORDER BY id ASC " : $orderBy; $roles = tlDBObject::createObjectsFromDBbySQL($db, $sql, 'id', __CLASS__, true, $detailLevel); $inheritedRole = new tlRole(TL_ROLES_INHERITED); $inheritedRole->name = "<inherited>"; $roles[TL_ROLES_INHERITED] = $inheritedRole; return $roles; }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions * 20121017 - asimon - TICKET 5288 - print priority when printing test plan */ function renderTestCaseForPrinting(&$db, &$node, &$options, $level, $context) { static $req_mgr; static $tc_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; static $force = null; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; // init static elements // tplan_id = 0, // $prefix = null, $tprojectID = 0, $platform_id = 0) if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr); if (!is_null($context->prefix)) { $tcase_prefix = $context->prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; } $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); $versionID = isset($node['tcversion_id']) ? intval($node['tcversion_id']) : testcase::LATEST_VERSION; $tcInfo = $tc_mgr->get_by_id($id, $versionID); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); // ----- BUGID 3451 and related --------------------------------------- // asimon: I finally found the real problem here: // $versionID was used in the following "dirty" SQL statement, but was still set to "-1" //(the value to load all tc versions) instead of a real testcase version ID. $versionID = $tcInfo['id']; // This still does not change the fact that this marked SQL statement below // should be removed and replaced by existing functions. $cfields = array('specScope' => null, 'execScope' => null); // get custom fields that has specification scope if ($options['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } foreach ($locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $context->tplan_id, $context->tproject_id, $cfieldFormatting, $tcInfo['id']); } } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getExecutions = false; if ($options["docType"] != DOC_TEST_SPEC && $options["docType"] != SINGLE_TESTCASE) { $getExecutions = $options['cfields'] || $options['passfail']; } if ($getExecutions) { $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," . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON E.build_id= B.id " . " WHERE E.tcversion_id = {$versionID} " . " AND E.testplan_id = {$context->tplan_id} " . " AND E.platform_id = {$context->platform_id} " . " ORDER BY execution_id DESC"; echo $sql; $exec_info = $db->get_recordset($sql, null, 1); } // Added condition for the display on/off of the custom fields on test cases. if ($options['cfields'] && !is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $context->tplan_id, $context->tproject_id, $cfieldFormatting); } if ($options['toc']) { $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $table_style = 'style="margin-left: 0;"'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td></tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>' . '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; switch ($tcInfo['execution_type']) { case testcase::EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case testcase::EXECUTION_TYPE_MANUAL: $code .= $labels['execution_type_manual']; break; default: $code .= lang_get('execution_type_custom_' . $tcInfo['execution_type']); break; } $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['status'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['text_status_labels'][$tcInfo['status']]; $code .= "</td></tr>\n"; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_execution_duration']; $code .= "</td></tr>\n"; // TICKET 5288 - print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($options['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1, $options['notes']); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC if ($options['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $code .= "</table>\n</div>\n"; return $code; }
/** * Deletes the keyword with the given id * * @param int $id the keywordID * @return int returns 1 on success, 0 else * * @todo should we now increment the tcversion also? **/ function deleteKeyword($id) { $result = tl::ERROR; $keyword = $this->getKeyword($id); if ($keyword) { $result = tlDBObject::deleteObjectFromDB($this->db, $id, "tlKeyword"); } if ($result >= tl::OK) { logAuditEvent(TLS("audit_keyword_deleted", $keyword->name), "DELETE", $id, "keywords"); } return $result; }
/** * */ 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; }
function getAllUsersRoles(&$db, $order_by = null) { $tables = tlObject::getDBTables(array('users', 'roles')); $sql = "SELECT users.id FROM {$tables['users']} users " . " LEFT OUTER JOIN {$tables['roles']} roles ON users.role_id = roles.id "; $sql .= is_null($order_by) ? " ORDER BY login " : $order_by; $users = tlDBObject::createObjectsFromDBbySQL($db, $sql, "id", "tlUser", false, tlUser::TLOBJ_O_GET_DETAIL_MINIMUM); $loop2do = count($users); $specialK = array_flip((array) config_get('demoSpecialUsers')); $demoModeEnabled = config_get('demoMode'); for ($idx = 0; $idx < $loop2do; $idx++) { $users[$idx]->isDemoSpecial = $demoModeEnabled ? isset($specialK[$users[$idx]->login]) : false; } return $users; }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions * 20100920 - franciscom - changed key on $cfieldFormatting * 20100905 - franciscom - BUGID 3431 - Custom Field values at Test Case VERSION Level * 20100724 - asimon - BUGID 3459 - added platform ID * 20100723 - asimon - BUGID 3451 and related finally solved * 20090517 - havlatm - fixed execution layot; added tester name * 20080819 - franciscom - removed mysql only code * 20071014 - franciscom - display test case version * 20070509 - franciscom - added Contribution */ function renderTestCaseForPrinting(&$db, &$node, &$printingOptions, $level, $tplan_id = 0, $prefix = null, $tprojectID = 0, $platform_id = 0) { static $req_mgr; static $tc_mgr; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); } $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; // init static elements $id = $node['id']; if (!$cfg) { $tc_mgr = new testcase($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr); if (!is_null($prefix)) { $tcase_prefix = $prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; } // 20100920 - franciscom $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); $versionID = isset($node['tcversion_id']) ? $node['tcversion_id'] : testcase::LATEST_VERSION; $tcInfo = $tc_mgr->get_by_id($id, $versionID); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); // ----- BUGID 3451 and related --------------------------------------- // asimon: I finally found the real problem here: // $versionID was used in the following "dirty" SQL statement, but was still set to "-1" //(the value to load all tc versions) instead of a real testcase version ID. $versionID = $tcInfo['id']; // This still does not change the fact that this marked SQL statement below // should be removed and replaced by existing functions. // ----- BUGID 3451 and related --------------------------------------- $cfields = array('specScope' => null, 'execScope' => null); // get custom fields that has specification scope if ($printingOptions['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } foreach ($locationFilters as $fkey => $fvalue) { // BUGID 3431 - Custom Field values at Test Case VERSION Level $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $cfieldFormatting, $tcInfo['id']); } } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $bGetExecutions = false; if ($printingOptions["docType"] != DOC_TEST_SPEC) { $bGetExecutions = $printingOptions['cfields'] || $printingOptions['passfail']; } if ($bGetExecutions) { $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.has_attach," . " B.name AS build_name " . " FROM {$tables['executions']} E, {$tables['builds']} B" . " WHERE E.build_id= B.id " . " AND E.tcversion_id = {$versionID} " . " AND E.testplan_id = {$tplan_id} " . " AND E.platform_id = {$platform_id} " . " ORDER BY execution_id DESC"; $exec_info = $db->get_recordset($sql, null, 1); } // Added condition for the display on/off of the custom fields on test cases. if ($printingOptions['cfields'] && !is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $tplan_id, $tprojectID, $cfieldFormatting); } if ($printingOptions['toc']) { if ($printingOptions['passfail']) { if ($exec_info) { //<span style="color:green">different text color</span> switch ($exec_info[0]['status']) { case "p": $result_of_case .= '<span style="color:green">' . $cfg['status_labels'][$exec_info[0]['status']] . '</span>'; break; case "f": $result_of_case .= '<span style="color:red">' . $cfg['status_labels'][$exec_info[0]['status']] . '</span>'; break; default: $result_of_case .= $cfg['status_labels'][$exec_info[0]['status']]; break; } } else { $result_of_case .= "<b>Not Run</b>"; } } $printingOptions['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . $name . '</a> ' . $result_of_case . '</p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $code .= '<p> </p><div> <table class="tc" width="90%">'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; if ($cfg['doc']->tc_version_enabled) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($printingOptions['author']) { $authorName = gendocGetUserName($db, $tcInfo['author_id']); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $authorName; if ($tcInfo['updater_id'] > 0 && $tcInfo['updater_id'] != $tcInfo['author_id']) { // add updater if available and differs from author $updaterName = gendocGetUserName($db, $tcInfo['updater_id']); $code .= '<br />' . $labels['last_edit'] . " " . $updaterName; } $code .= "</td></tr>\n"; } if ($printingOptions['body'] || $printingOptions['summary']) { $tcase_pieces = array('summary'); } if ($printingOptions['body']) { $tcase_pieces[] = 'preconditions'; $tcase_pieces[] = 'steps'; // $tcase_pieces[] = 'expected_results'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { // 20090719 - franciscom - cf location if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td></tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>' . '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; // 20090719 - franciscom - cf location $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($printingOptions['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC // based on contribution by JMU (#1045) if ($printingOptions['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC // based on contribution by JMU (#1045) if ($printingOptions['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $code .= "</table>\n</div>\n"; return $code; }
/** * Deletes the keyword with the given id * * @param int $id the keywordID * @return int returns 1 on success, 0 else * **/ function deleteKeyword($id, $opt = null) { $result = tl::ERROR; $my['opt'] = array('checkBeforeDelete' => true, 'nameForAudit' => null, 'context' => ''); $my['opt'] = array_merge($my['opt'], (array) $opt); $doIt = !$my['opt']['checkBeforeDelete']; $keyword = $my['opt']['nameForAudit']; if ($my['opt']['checkBeforeDelete']) { $kw = $this->getKeyword($id); if ($doIt = !is_null($kw)) { $keyword = $kw->name; } } if ($doIt) { $result = tlDBObject::deleteObjectFromDB($this->db, $id, "tlKeyword"); } if ($result >= tl::OK && $this->auditCfg->logEnabled) { logAuditEvent(TLS("audit_keyword_deleted", $keyword, $my['opt']['context']), "DELETE", $id, "keywords"); } return $result; }
function getAllUsersRoles(&$db, $order_by = null) { $tables = tlObject::getDBTables(array('users', 'roles')); $sql = "SELECT users.id FROM {$tables['users']} users " . " LEFT OUTER JOIN {$tables['roles']} roles ON users.role_id = roles.id "; $sql .= is_null($order_by) ? " ORDER BY login " : $order_by; $users = tlDBObject::createObjectsFromDBbySQL($db, $sql, "id", "tlUser", false, tlUser::TLOBJ_O_GET_DETAIL_MINIMUM); return $users; }