function initializeGui(&$dbHandler, $args)
{
    $gui = new stdClass();
    $tplan_mgr = new testplan($dbHandler);
    $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->tplan_id = $args->tplan_id;
    $gui->tproject_id = $args->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    $gui->tplan_name = $tplan_info['name'];
    unset($tplan_info);
    $ni = $tplan_mgr->tree_manager->get_node_hierarchy_info($gui->tproject_id);
    $gui->tproject_name = $ni['name'];
    unset($ni);
    $gui->assigned_users = new stdClass();
    $gui->keywords = new stdClass();
    $gui->builds = new stdClass();
    $gui->platforms = new stdClass();
    $gui->testsuites = new stdClass();
    // 20090107 - franciscom
    // Show only users that are able to execute test cases ?
    // What happens if a user that has loose right to execute, but
    // before loosing this right has been assigned some tests, or have executed it?
    //
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, ADD_BLANK_OPTION);
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER,
    // 	                                                   array(TL_USER_ANYBODY => $gui->str_option_any,
    //                                                            TL_USER_NOBODY => $gui->str_option_none) );
    //
    $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->builds->items = $tplan_mgr->get_builds($gui->tplan_id, testplan::ACTIVE_BUILDS);
    $gui->platforms->items = $tplan_mgr->getPlatforms($gui->tplan_id);
    $gui->testsuites->items = $tplan_mgr->getRootTestSuites($gui->tplan_id, $gui->tproject_id, array('output' => 'plain'));
    $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;
    }
    $key2loop = array('keywords', 'builds', 'platforms', 'testsuites', 'assigned_users');
    foreach ($key2loop as $kx) {
        $gui->{$kx}->qty = count($gui->{$kx}->items);
    }
    $gui->status_code_label = get_status_for_reports_html_options();
    $gui->report_type = $args->format;
    $reports_cfg = config_get('reportsCfg');
    $ldf = config_get('locales_date_format');
    $date_format = $ldf[isset($_SESSION['locale']) ? $_SESSION['locale'] : 'en_GB'];
    $gui->selected_start_date = strftime($date_format, time() - $reports_cfg->start_date_offset);
    $gui->selected_start_time = $reports_cfg->start_time;
    $gui->selected_end_date = strftime($date_format, time());
    $gui->selected_end_time = null;
    return $gui;
}
Ejemplo n.º 2
0
function initializeGui(&$dbHandler, $args)
{
    $gui = new stdClass();
    $tplan_mgr = new testplan($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $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->tplan_id = $args->tplan_id;
    $gui->tproject_id = $args->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    $gui->tplan_name = $tplan_info['name'];
    $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id);
    $gui->tproject_name = $tproject_info['name'];
    $re = new results($dbHandler, $tplan_mgr, $tproject_info, $tplan_info);
    $gui->assigned_users = new stdClass();
    $gui->keywords = new stdClass();
    $gui->builds = new stdClass();
    $gui->testsuites = new stdClass();
    // 20090107 - franciscom
    // Show only users that are able to execute test cases ?
    // What happens if a user that has loose right to execute, but
    // before loosing this right has been assigned some tests, or have executed it?
    //
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, ADD_BLANK_OPTION);
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER,
    // 	                                                   array(TL_USER_ANYBODY => $gui->str_option_any,
    //                                                            TL_USER_NOBODY => $gui->str_option_none) );
    //
    $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->assigned_users->qty = count($gui->assigned_users->items);
    // BUGID 2012 - franciscom
    $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->builds->items = $tplan_mgr->get_builds($gui->tplan_id, testplan::ACTIVE_BUILDS);
    $gui->testsuites->items = $re->getTopLevelSuites();
    $gui->keywords->qty = count($gui->keywords->items);
    $gui->builds->qty = count($gui->builds->items);
    $gui->testsuites->qty = count($gui->testsuites->items);
    $gui->status_code_label = get_status_for_reports_html_options();
    $gui->report_type = $args->format;
    $reports_cfg = config_get('reportsCfg');
    $startDate = time() - $reports_cfg->start_date_offset;
    $gui->selected_start_date = $startDate;
    $gui->selected_start_time = $reports_cfg->start_time;
    $gui->selected_end_date = null;
    $gui->selected_end_time = null;
    return $gui;
}
 /**
  * 
  * @internal revision
  * @since 1.9.13
  * mode this affect domain
  */
 private function init_filter_keywords()
 {
     $key = 'filter_keywords';
     $type = 'filter_keywords_filter_type';
     $this->filters[$key] = false;
     $keywords = null;
     $l10n = init_labels(array('logical_or' => null, 'logical_and' => null, 'not_linked' => null));
     switch ($this->mode) {
         case 'edit_mode':
         case 'plan_add_mode':
             // we need the keywords for the whole testproject
             if (!$this->testproject_mgr) {
                 $this->testproject_mgr = new testproject($this->db);
             }
             $keywords = $this->testproject_mgr->get_keywords_map($this->args->testproject_id);
             break;
         default:
             // otherwise (not in edit mode), we want only keywords assigned to testplan
             if (!$this->testplan_mgr) {
                 $this->testplan_mgr = new testplan($this->db);
             }
             $tplan_id = $this->settings['setting_testplan']['selected'];
             $keywords = $this->testplan_mgr->get_keywords_map($tplan_id, ' ORDER BY keyword ');
             break;
     }
     $special = array('domain' => array(), 'filter_mode' => array());
     switch ($this->mode) {
         case 'edit_mode':
             $special['domain'] = array(-1 => $this->option_strings['without_keywords'], 0 => $this->option_strings['any']);
             $special['filter_mode'] = array('NotLinked' => $l10n['not_linked']);
             break;
         case 'execution_mode':
         case 'plan_add_mode':
         case 'plan_mode':
         default:
             $special['domain'] = array(0 => $this->option_strings['any']);
             $special['filter_mode'] = array();
             break;
     }
     $selection = $this->args->{$key};
     $type_selection = $this->args->{$type};
     // are there any keywords?
     if (!is_null($keywords) && count($keywords)) {
         $this->filters[$key] = array();
         if (!$selection || !$type_selection || $this->args->reset_filters) {
             // default values for filter reset
             $selection = null;
             $type_selection = 'Or';
         } else {
             $this->do_filtering = true;
         }
         // data for the keywords themselves
         $this->filters[$key]['items'] = $special['domain'] + $keywords;
         $this->filters[$key]['selected'] = $selection;
         $this->filters[$key]['size'] = min(count($this->filters[$key]['items']), self::ADVANCED_FILTER_ITEM_QUANTITY);
         // additional data for the filter type (logical and/or)
         $this->filters[$key][$type] = array();
         $this->filters[$key][$type]['items'] = array('Or' => $l10n['logical_or'], 'And' => $l10n['logical_and']) + $special['filter_mode'];
         $this->filters[$key][$type]['selected'] = $type_selection;
     }
     // set the active value to filter
     // delete keyword filter if "any" (0) is part of the selection - regardless of filter mode
     if (is_array($this->filters[$key]['selected']) && in_array(0, $this->filters[$key]['selected'])) {
         $this->active_filters[$key] = null;
     } else {
         $this->active_filters[$key] = $this->filters[$key]['selected'];
     }
     $this->active_filters[$type] = $selection ? $type_selection : null;
 }
Ejemplo n.º 4
0
/**
 * 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;
}