/** * Initialize the HTML select box for selection of a source build when * user wants to copy the user assignments on creation of a new build. * * @author Andreas Simon * @param testplan $testplan_mgr reference to testplan manager object * @param object $argsObj reference to user input object * @return array $htmlMenu array structure with all information needed for the menu * * @internal revision * 20100820 - franciscom - refactoring to remove unneeded support/temp variables and * event viewer complain due to foreach() over a null variable. */ function init_source_build_selector(&$testplan_mgr, &$argsObj) { $htmlMenu = array('items' => null, 'selected' => null, 'build_count' => 0); $htmlMenu['items'] = $testplan_mgr->get_builds_for_html_options($argsObj->tplan_id); // get the number of existing execution assignments with each build if (!is_null($htmlMenu['items'])) { $htmlMenu['build_count'] = count($htmlMenu['items']); foreach ($htmlMenu['items'] as $key => $name) { $count = $testplan_mgr->assignment_mgr->get_count_of_assignments_for_build_id($key); $htmlMenu['items'][$key] = $name . " (" . $count . ")"; } // if no build has been chosen yet, select the newest build by default if (!$argsObj->source_build_id) { $htmlMenu['selected'] = key($htmlMenu['items']); } } return $htmlMenu; }
/** * */ private function init_filter_result() { $result_key = 'filter_result_result'; $method_key = 'filter_result_method'; $build_key = 'filter_result_build'; if (is_null($this->testplan_mgr)) { $this->testplan_mgr = new testplan($this->db); } $tplan_id = $this->settings['setting_testplan']['selected']; $this->configuration->results = config_get('results'); // determine, which config to load and use for filter methods - depends on mode! $cfg = $this->mode == 'execution_mode' ? 'execution_filter_methods' : 'execution_assignment_filter_methods'; $this->configuration->filter_methods = config_get($cfg); // // CRITIC - Differences bewteen this configuration and // (file const.inc.php) // $tlCfg->execution_filter_methods['default_type'] // $tlCfg->execution_assignment_filter_methods['default_type'] // // Will create issues: you will see an string on HTML SELECT, but code // returned on submit will not code for string you are seeing.!!!! // // determine which filter method shall be selected by the JS function in template, // when only one build is selectable by the user $js_key_to_select = 0; if ($this->mode == 'execution_mode') { $js_key_to_select = $this->configuration->filter_methods['status_code']['current_build']; } else { if ($this->mode == 'plan_mode') { $js_key_to_select = $this->configuration->filter_methods['status_code']['specific_build']; } } // values selected by user $result_selection = $this->args->{$result_key}; $method_selection = $this->args->{$method_key}; $build_selection = $this->args->{$build_key}; // default values $default_filter_method = $this->configuration->filter_methods['default_type']; $any_result_key = $this->configuration->results['status_code']['all']; $newest_build_id = $this->testplan_mgr->get_max_build_id($tplan_id, testplan::GET_ACTIVE_BUILD); if (is_null($method_selection)) { $method_selection = $default_filter_method; } if (is_null($result_selection) || $this->args->reset_filters) { // no selection yet or filter reset requested $result_selection = $any_result_key; $method_selection = $default_filter_method; $build_selection = $newest_build_id; } else { $this->do_filtering = true; } // init array structure $key = 'filter_result'; $this->filters[$key] = array($result_key => array('items' => null, 'selected' => $result_selection), $method_key => array('items' => array(), 'selected' => $method_selection, 'js_selection' => $js_key_to_select), $build_key => array('items' => null, 'selected' => $build_selection)); // init menu for result selection by function from exec.inc.php $this->filters[$key][$result_key]['items'] = createResultsMenu(); $this->filters[$key][$result_key]['items'][$any_result_key] = $this->option_strings['any']; // init menu for filter method selection foreach ($this->configuration->filter_methods['status_code'] as $statusname => $statusshortcut) { $code = $this->configuration->filter_methods['status_code'][$statusname]; $this->filters[$key][$method_key]['items'][$code] = lang_get($this->configuration->filter_methods['status_label'][$statusname]); } // init menu for build selection $this->filters[$key][$build_key]['items'] = $this->testplan_mgr->get_builds_for_html_options($tplan_id, testplan::GET_ACTIVE_BUILD); // if "any" is selected, nullify the active filters if (is_array($result_selection) && in_array($any_result_key, $result_selection) || $result_selection == $any_result_key) { $this->active_filters[$result_key] = null; $this->active_filters[$method_key] = null; $this->active_filters[$build_key] = null; $this->filters[$key][$result_key]['selected'] = $any_result_key; } else { $this->active_filters[$result_key] = $result_selection; $this->active_filters[$method_key] = $method_selection; $this->active_filters[$build_key] = $build_selection; } }
/** * Initialize the HTML select box for selection of a build to which * user wants to assign testers which are added to testplan. * * @author Andreas Simon * @param testplan $testplan_mgr reference to testplan manager object * @param object $argsObj reference to user input object * @return array $html_menu array structure with all information needed for the menu */ function init_build_selector(&$testplan_mgr, &$argsObj) { // init array $html_menu = array('items' => null, 'selected' => null, 'count' => 0); $html_menu['items'] = $testplan_mgr->get_builds_for_html_options($argsObj->tplan_id, testplan::GET_ACTIVE_BUILD, testplan::GET_OPEN_BUILD); $html_menu['count'] = count($html_menu['items']); // if no build has been chosen yet, select the newest build by default $build_id = $argsObj->build_id; if (!$build_id && $html_menu['count']) { $keys = array_keys($html_menu['items']); $build_id = end($keys); } $html_menu['selected'] = $build_id; return $html_menu; }
/** * initialize Gui */ function initializeGui(&$dbHandler, &$argsObj, $dateFormat) { $reports_cfg = config_get('reportsCfg'); $gui = new stdClass(); $tplan_mgr = new testplan($dbHandler); $tproject_mgr = new testproject($dbHandler); $getOpt = array('outputFormat' => 'map'); $gui->platformSet = $tplan_mgr->getPlatforms($argsObj->tplan_id, $getOpt); $gui->title = lang_get('query_metrics_report'); $gui->showPlatforms = true; if (is_null($gui->platformSet)) { $gui->platformSet = array(''); $gui->showPlatforms = false; } $gui->resultsCfg = config_get('results'); // BUGID 3716, BUGID 3930 // convert starttime to iso format for database usage if (isset($_REQUEST['selected_start_date']) && $_REQUEST['selected_start_date'] != '') { $date_array = split_localized_date($_REQUEST['selected_start_date'], $dateFormat); if ($date_array != null) { // set date in iso format $gui->startTime = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day']; } } // convert starttime to iso format for database usage if (isset($_REQUEST['selected_end_date']) && $_REQUEST['selected_end_date'] != '') { $date_array = split_localized_date($_REQUEST['selected_end_date'], $dateFormat); if ($date_array != null) { // set date in iso format $gui->endTime = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day']; } } $start_hour = isset($_REQUEST['start_Hour']) ? $_REQUEST['start_Hour'] : "00"; $gui->startTime = $gui->startTime . " " . $start_hour . ":00:00"; $end_hour = isset($_REQUEST['end_Hour']) ? $_REQUEST['end_Hour'] : "00"; $gui->endTime = $gui->endTime . " " . $end_hour . ":59:59"; $gui_open = config_get('gui_separator_open'); $gui_close = config_get('gui_separator_close'); $gui->str_option_any = $gui_open . lang_get('any') . $gui_close; $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close; $gui->search_notes_string = $argsObj->search_notes_string; $gui->tplan_id = $argsObj->tplan_id; $gui->tproject_id = $argsObj->tproject_id; $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id); $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id); $gui->tplan_name = $tplan_info['name']; $gui->tproject_name = $tproject_info['name']; $testsuiteIds = null; $testsuiteNames = null; $tsuites_qty = sizeOf($argsObj->testsuitesSelected); for ($id = 0; $id < $tsuites_qty; $id++) { list($suiteId, $suiteName) = preg_split("/\\,/", $argsObj->testsuitesSelected[$id], 2); $testsuiteIds[$id] = $suiteId; $testsuiteNames[$id] = $suiteName; } $buildsToQuery = -1; if (sizeof($argsObj->buildsSelected)) { $buildsToQuery = implode(",", $argsObj->buildsSelected); } // statusForClass is used for results.class.php // lastStatus is used to be displayed $statusForClass = 'a'; // amitkhullar - added this parameter to get the latest results. $latest_resultset = $argsObj->display->latest_results; // BUGID 2500 // $assignee = $argsObj->ownerSelected ? TL_USER_ANYBODY : null; // $tester = $argsObj->executorSelected ? TL_USER_ANYBODY : null; $assignee = $argsObj->ownerSelected > 0 ? $argsObj->ownerSelected : TL_USER_ANYBODY; $tester = $argsObj->executorSelected > 0 ? $argsObj->executorSelected : TL_USER_ANYBODY; // BUGID 4027 $re = new newResults($dbHandler, $tplan_mgr, $tproject_info, $tplan_info, $testsuiteIds, $buildsToQuery, $argsObj->platformsSelected, $statusForClass, $latest_resultset, $argsObj->keywordSelected, $assignee, $gui->startTime, $gui->endTime, $tester, $argsObj->search_notes_string, null); $gui->suiteList = $re->getSuiteList(); // test executions results // Filter test cases on selected platforms foreach ($gui->suiteList as $suiteid => $tcases) { $filtered = array(); foreach ($tcases as $index => $tcase) { if ($tcase['platform_id'] == 0 || $argsObj->platformsSelected[0] == ALL_PLATFORMS || array_search($tcase['platform_id'], $argsObj->platformsSelected) !== false) { array_push($filtered, $tcase); } } unset($gui->suiteList[$suiteid]); $gui->suiteList[$suiteid] = $filtered; } $gui->flatArray = $re->getFlatArray(); $gui->mapOfSuiteSummary = $re->getAggregateMap(); $gui->totals = new stdClass(); $gui->totals->items = $re->getTotalsForPlan(); $gui->totals->labels = array(); foreach ($gui->totals->items as $key => $value) { $l18n = $key == 'total' ? 'th_total_cases' : $gui->resultsCfg['status_label'][$key]; $gui->totals->labels[$key] = lang_get($l18n); } // BUGID 2012 - franciscom $gui->keywords = new stdClass(); $gui->keywords->items[0] = $gui->str_option_any; if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) { $gui->keywords->items += $tplan_keywords_map; } $gui->keywords->qty = count($gui->keywords->items); $gui->keywordSelected = $gui->keywords->items[$argsObj->keywordSelected]; $gui->builds_html = $tplan_mgr->get_builds_for_html_options($gui->tplan_id); $gui->users = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any)); $gui->ownerSelected = $gui->users[$argsObj->ownerSelected]; $gui->executorSelected = $gui->users[$argsObj->executorSelected]; $gui->testsuitesSelected = $testsuiteNames; $gui->buildsSelected = $argsObj->buildsSelected; $gui->platformsSelected = $argsObj->platformsSelected; $gui->display = $argsObj->display; // init display rows attribute and some status localized labels $gui->displayResults = array(); $gui->lastStatus = array(); foreach ($reports_cfg->exec_status as $verbose => $label) { $gui->displayResults[$gui->resultsCfg['status_code'][$verbose]] = false; } foreach ($gui->resultsCfg['status_label'] as $status_verbose => $label_key) { $gui->statusLabels[$gui->resultsCfg['status_code'][$status_verbose]] = lang_get($label_key); } $lastStatus_localized = null; foreach ($argsObj->lastStatus as $key => $status_code) { $verbose = $gui->resultsCfg['code_status'][$status_code]; $gui->displayResults[$status_code] = true; $lastStatus_localized[] = lang_get($gui->resultsCfg['status_label'][$verbose]); } $gui->lastStatus = $lastStatus_localized; return $gui; }