/**
 * init_args
 *
 */
function init_args(&$dbHandler)
{
    $reqTitleSize = config_get('field_size')->requirement_title;
    $iParams = array("requirement_id" => array(tlInputParameter::INT_N), "req_version_id" => array(tlInputParameter::INT_N), "req_spec_id" => array(tlInputParameter::INT_N), "req_title" => array(tlInputParameter::STRING_N, 0, $reqTitleSize), "req_id_cbox" => array(tlInputParameter::ARRAY_INT), "reqDocId" => array(tlInputParameter::STRING_N, 0, 64), "reqStatus" => array(tlInputParameter::STRING_N, 0, 1), "reqType" => array(tlInputParameter::STRING_N, 0, 1), "containerID" => array(tlInputParameter::INT_N), "scope" => array(tlInputParameter::STRING_N), "countReq" => array(tlInputParameter::INT_N), "expected_coverage" => array(tlInputParameter::INT_N), "doAction" => array(tlInputParameter::STRING_N, 0, 20), "itemSet" => array(tlInputParameter::ARRAY_INT), "testcase_count" => array(tlInputParameter::ARRAY_INT), "copy_testcase_assignment" => array(tlInputParameter::CB_BOOL), "relation_id" => array(tlInputParameter::INT_N), "relation_source_req_id" => array(tlInputParameter::INT_N), "relation_type" => array(tlInputParameter::STRING_N), "relation_destination_req_doc_id" => array(tlInputParameter::STRING_N, 0, 64), "relation_destination_testproject_id" => array(tlInputParameter::INT_N), "save_rev" => array(tlInputParameter::INT_N), "do_save" => array(tlInputParameter::INT_N), "log_message" => array(tlInputParameter::STRING_N), "tcaseIdentity" => array(tlInputParameter::STRING_N), "file_id" => array(tlInputParameter::INT_N), "fileTitle" => array(tlInputParameter::STRING_N, 0, 100));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args->req_id = $args->requirement_id;
    $args->title = $args->req_title;
    $args->arrReqIds = $args->req_id_cbox;
    $args->basehref = $_SESSION['basehref'];
    $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    if ($args->tproject_id <= 0) {
        throw new Exception(__FILE__ . '::' . __FUNCTION__ . " Test project ID can not be <= 0 ");
    }
    $mgr = new testproject($dbHandler);
    $info = $mgr->get_by_id($args->tproject_id);
    if (is_null($info)) {
        throw new Exception(__FILE__ . '::' . __FUNCTION__ . " Unable to get test project data ");
    }
    $args->tproject_name = $info['name'];
    $args->tcasePrefix = $info['prefix'];
    $args->user_id = isset($_SESSION['userID']) ? $_SESSION['userID'] : 0;
    if (!is_numeric($args->expected_coverage)) {
        $args->expected_coverage = 0;
    }
    $args->refreshTree = isset($_SESSION['setting_refresh_tree_on_action']) ? $_SESSION['setting_refresh_tree_on_action'] : 0;
    $args->stay_here = isset($_REQUEST['stay_here']) ? 1 : 0;
    return $args;
}
 /**
  * 
  *
  */
 function initGuiBean(&$argsObj, $mandatory = null)
 {
     $obj = new stdClass();
     $prop2scan = array('tproject_id' => 'Test project id can not be <= 0', 'tsuiteID' => 'Test suite id can not be <= 0');
     if (!is_null($mandatory)) {
         foreach ($mandatory as $key) {
             $p2check[$key] = $prop2scan[$key];
         }
     } else {
         $p2check =& $prop2scan;
     }
     foreach ($p2check as $prop => $msg) {
         if (($obj->{$prop} = intval($argsObj->{$prop})) <= 0) {
             throw new Exception(__METHOD__ . ':' . $msg);
         }
     }
     $tprojectMgr = new testproject($this->db);
     $dummy = $tprojectMgr->get_by_id($obj->tproject_id);
     $obj->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
     $obj->automationEnabled = $dummy['opt']->automationEnabled;
     $this->keywordSet = array('testproject' => $tprojectMgr->get_keywords_map($argsObj->tproject_id), 'testcase' => null);
     $obj->template_dir = $this->templateCfg->template_dir;
     $obj->action = '';
     $obj->attachments = null;
     $obj->cleanUpWebEditor = false;
     $obj->direct_link = null;
     $obj->execution_types = $this->execution_types;
     $obj->grants = $this->grants;
     $obj->has_been_executed = false;
     $obj->initWebEditorFromTemplate = false;
     $obj->viewerArgs = null;
     $obj->path_info = null;
     $obj->main_descr = '';
     $obj->name = '';
     $obj->sqlResult = '';
     $obj->step_id = -1;
     $obj->step_set = '';
     $obj->steps = '';
     $obj->tableColspan = 5;
     $obj->tcase_id = property_exists($argsObj, 'tcase_id') ? intval($argsObj->tcase_id) : -1;
     $p2check = array('goback_url' => '', 'show_mode' => 'show', 'refreshTree' => !tlTreeMenu::REFRESH_GUI);
     foreach ($p2check as $prop => $value) {
         if (property_exists($argsObj, $prop) && !is_null($argsObj->{$prop})) {
             $obj->{$prop} = $argsObj->{$prop};
         } else {
             $obj->{$prop} = $value;
         }
     }
     // need to check where is used -> on cancel button on tcStepEdit.tpl
     $obj->loadOnCancelURL = "archiveData.php?tproject_id={$obj->tproject_id}&edit=testcase" . "&show_mode={$obj->show_mode}&id=%s&version_id=%s";
     // Used on tcStepEdit.tpl to creare goback_url URL parameter
     $obj->goBackAction = $_SESSION['basehref'] . "lib/testcases/" . $obj->loadOnCancelURL;
     $obj->keywordsViewHREF = "lib/keywords/keywordsView.php?tproject_id={$obj->tproject_id} " . ' target="mainframe" class="bold" ' . ' title="' . lang_get('menu_manage_keywords') . '"';
     return $obj;
 }
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
function init_args(&$dbHandler, $dateFormat)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    // BUGID 3716
    $args->target_date_original = isset($_REQUEST['target_date']) ? $_REQUEST['target_date'] : null;
    $args->start_date_original = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : null;
    // convert target date to iso format to write to db
    if (isset($_REQUEST['target_date']) && $_REQUEST['target_date'] != '') {
        $date_array = split_localized_date($_REQUEST['target_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $args->target_date = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    // convert start date to iso format to write to db
    if (isset($_REQUEST['start_date']) && $_REQUEST['start_date'] != '') {
        $date_array = split_localized_date($_REQUEST['start_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $args->start_date = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    $key2loop = array('low_priority_tcases', 'medium_priority_tcases', 'high_priority_tcases');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? intval($_REQUEST[$key]) : 0;
    }
    $args->id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
    $args->name = isset($_REQUEST['milestone_name']) ? $_REQUEST['milestone_name'] : null;
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : null;
    $args->basehref = $_SESSION['basehref'];
    $treeMgr = new tree($dbHandler);
    $tprojectMgr = new testproject($dbHandler);
    $args->tproject_options = new stdClass();
    $args->tproject_options->testPriorityEnabled = 0;
    $args->tproject_name = '';
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id > 0) {
        $info = $tprojectMgr->get_by_id($args->tproject_id);
        $args->tproject_name = $info['name'];
        $args->tproject_options = $info['opt'];
    }
    $args->tplan_name = '';
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    if ($args->tplan_id > 0) {
        $info = $treeMgr->get_node_hierarchy_info($args->tplan_id);
        $args->tplan_name = $info['name'];
    }
    return $args;
}
Exemplo n.º 5
0
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr)
{
    $gui = new stdClass();
    $gui->title = lang_get('title_gen_test_rep');
    $gui->do_report = array();
    $gui->elapsed_time = 0;
    $mgr = new testproject($dbHandler);
    $dummy = $mgr->get_by_id($argsObj->tproject_id);
    $gui->testprojectOptions = new stdClass();
    $gui->testprojectOptions->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
    $gui->tproject_name = $dummy['name'];
    $info = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->tplan_name = $info['name'];
    return $gui;
}
 function __construct(&$db, $tproject_id)
 {
     $this->db = $db;
     $this->reqSpecMgr = new requirement_spec_mgr($db);
     $this->reqMgr = new requirement_mgr($db);
     $this->treeMgr = $this->reqMgr->tree_mgr;
     $req_spec_cfg = config_get('req_spec_cfg');
     $this->reqSpecTypeDomain = init_labels($req_spec_cfg->type_labels);
     $this->commandMgr = new reqCommands($db);
     $this->submit_button_label = lang_get('btn_save');
     $this->getRequirementsOptions = array('order_by' => " ORDER BY NH_REQ.node_order ");
     $tproject_mgr = new testproject($this->db);
     $info = $tproject_mgr->get_by_id($tproject_id);
     if ($info['reqmgr_integration_enabled']) {
         $sysmgr = new tlReqMgrSystem($this->db);
         $rms = $sysmgr->getInterfaceObject($tproject_id);
         $this->reqMgrSystem = $sysmgr->getLinkedTo($tproject_id);
         unset($sysmgr);
     }
 }
Exemplo n.º 7
0
function init_args(&$dbHandler)
{
    $args = new stdClass();
    $treeMgr = new tree($dbHandler);
    $tprojectMgr = new testproject($dbHandler);
    $args->tproject_name = '';
    $args->tproject_options = new stdClass();
    $args->tproject_options->testPriorityEnabled = 0;
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id > 0) {
        $info = $tprojectMgr->get_by_id($args->tproject_id);
        $args->tproject_name = $info['name'];
        $args->tproject_options = $info['opt'];
    }
    $args->tplan_name = '';
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    if ($args->tplan_id > 0) {
        $info = $treeMgr->get_node_hierarchy_info($args->tplan_id);
        $args->tplan_name = $info['name'];
    }
    return $args;
}
/**
 * initialize user input
 * 
 * @param resource dbHandler
 * @return array $args array with user input information
 */
function init_args(&$dbHandler)
{
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 0, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "format" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    $pParams = R_PARAMS($iParams, $args);
    if (!is_null($args->apikey)) {
        $cerbero = new stdClass();
        $cerbero->args = new stdClass();
        $cerbero->args->tproject_id = $args->tproject_id;
        $cerbero->args->tplan_id = $args->tplan_id;
        if (strlen($args->apikey) == 32) {
            $cerbero->args->getAccessAttr = true;
            $cerbero->method = 'checkRights';
            $cerbero->redirect_target = "../../login.php?note=logout";
            setUpEnvForRemoteAccess($dbHandler, $args->apikey, $cerbero);
        } else {
            $args->addOpAccess = false;
            $cerbero->method = null;
            $cerbero->args->getAccessAttr = false;
            setUpEnvForAnonymousAccess($dbHandler, $args->apikey, $cerbero);
        }
    } else {
        testlinkInitPage($dbHandler, false, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    $tproject_mgr = new testproject($dbHandler);
    $tplan_mgr = new testplan($dbHandler);
    if ($args->tproject_id > 0) {
        $args->tproject_info = $tproject_mgr->get_by_id($args->tproject_id);
        $args->tproject_name = $args->tproject_info['name'];
        $args->tproject_description = $args->tproject_info['notes'];
    }
    if ($args->tplan_id > 0) {
        $args->tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
    }
    return array($args, $tproject_mgr, $tplan_mgr);
}
Exemplo n.º 9
0
/** 
 * Process input data
 * 
 **/
function init_args(&$dbHandler)
{
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "build_id" => array(tlInputParameter::INT_N), "docTestPlanId" => array(tlInputParameter::INT_N), "id" => array(tlInputParameter::INT_N), "type" => array(tlInputParameter::STRING_N, 0, 20), "format" => array(tlInputParameter::INT_N), "level" => array(tlInputParameter::STRING_N, 0, 32));
    $args = new stdClass();
    $pParams = R_PARAMS($iParams, $args);
    // really UGLY HACK
    $typeDomain = array('test_plan' => 'testplan', 'test_report' => 'testreport');
    $args->type = isset($typeDomain[$args->type]) ? $typeDomain[$args->type] : $args->type;
    if (!is_null($args->apikey)) {
        $cerbero = new stdClass();
        $cerbero->args = new stdClass();
        $cerbero->args->tproject_id = $args->tproject_id;
        $cerbero->args->tplan_id = $args->tplan_id;
        if (strlen($args->apikey) == 32) {
            $cerbero->args->getAccessAttr = true;
            $cerbero->method = 'checkRights';
            $cerbero->redirect_target = "../../login.php?note=logout";
            setUpEnvForRemoteAccess($dbHandler, $args->apikey, $cerbero);
        } else {
            $args->addOpAccess = false;
            $cerbero->method = null;
            setUpEnvForAnonymousAccess($dbHandler, $args->apikey, $cerbero);
        }
        $args->itemID = $args->tproject_id;
    } else {
        testlinkInitPage($dbHandler, false, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
        $args->tplan_id = isset($_REQUEST['docTestPlanId']) ? intval($_REQUEST['docTestPlanId']) : 0;
        $args->itemID = $args->id;
    }
    $tproject_mgr = new testproject($dbHandler);
    if ($args->tproject_id > 0) {
        $dummy = $tproject_mgr->get_by_id($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    } else {
        $msg = __FILE__ . '::' . __FUNCTION__ . " :: Invalid Test Project ID ({$args->tproject_id})";
        throw new Exception($msg);
    }
    $args->doc_type = $args->type;
    $args->user_id = isset($_SESSION['userID']) ? intval($_SESSION['userID']) : null;
    $resultsCfg = config_get('results');
    $dcd = array();
    $dcd['node_descr_id'] = $tproject_mgr->tree_manager->get_available_node_types();
    $dcd['node_id_descr'] = array_flip($dcd['node_descr_id']);
    $dcd['status_descr_code'] = $resultsCfg['status_code'];
    $dcd['status_code_descr'] = array_flip($dcd['status_descr_code']);
    return array($args, $tproject_mgr, $dcd);
}
Exemplo n.º 10
0
/**
 * init_args()
 * Get in an object all data that has arrived to page through _REQUEST or _SESSION.
 * If you think this page as a function, you can consider this data arguments (args)
 * to a function call.
 * Using all this data as one object property will help developer to understand
 * if data is received or produced on page.
 *
 * @author franciscom - francisco.mancardi@gmail.com
 * @args - used global coupling accessing $_REQUEST and $_SESSION
 * 
 * @return object of stdClass
 *
 * @internal revisions
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id == 0) {
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    if ($args->tproject_id == 0) {
        throw new Exception(__FILE__ . ' Can not work without Test project ID => Aborting');
    }
    $mgr = new testproject($dbHandler);
    $info = $mgr->get_by_id($args->tproject_id);
    $args->tproject_name = $info['name'];
    $args->testprojectOptions = $info['opt'];
    unset($info);
    // $userSet = $userObj->getNames($dbHandler);
    $args->user_id = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : 0;
    if ($args->user_id != 0) {
        $args->user = new tlUser($args->user_id);
    } else {
        $args->user_id = isset($_SESSION['userID']) ? intval($_SESSION['userID']) : 0;
        if ($args->user_id == 0) {
            throw new Exception(__FILE__ . ' Can not work without User ID => Aborting');
        }
        $args->user = $_SESSION['currentUser'];
    }
    $args->user_name = $args->user->login;
    $args->userSet = $args->user->getNames($dbHandler);
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    $args->build_id = isset($_REQUEST['build_id']) && is_numeric($_REQUEST['build_id']) ? intval($_REQUEST['build_id']) : 0;
    $args->show_inactive_tplans = isset($_REQUEST['show_inactive_tplans']) ? true : false;
    $args->show_all_users = false;
    if (isset($_REQUEST['show_all_users'])) {
        $args->show_all_users = intval($_REQUEST['show_all_users']) == 1;
    }
    // $args->show_all_users = (isset($_REQUEST['show_all_users']) && (intval($_REQUEST['show_all_users'])) =! 0);
    $args->show_user_column = $args->show_all_users;
    $show_closed_builds = isset($_REQUEST['show_closed_builds']) ? true : false;
    $show_closed_builds_hidden = isset($_REQUEST['show_closed_builds_hidden']) ? true : false;
    if ($show_closed_builds) {
        $selection = true;
    } else {
        if ($show_closed_builds_hidden) {
            $selection = false;
        } else {
            if (isset($_SESSION['show_closed_builds'])) {
                $selection = intval($_SESSION['show_closed_builds']);
            } else {
                $selection = false;
            }
        }
    }
    $args->show_closed_builds = $_SESSION['show_closed_builds'] = $selection;
    if ($args->show_all_users) {
        $args->user_id = TL_USER_ANYBODY;
    }
    $args->show_inactive_and_closed = false;
    if (isset($_REQUEST['show_inactive_and_closed'])) {
        $args->show_inactive_and_closed = intval($_REQUEST['show_inactive_and_closed']) != 0;
    }
    $args->priority_enabled = $_SESSION['testprojectOptions']->testPriorityEnabled ? true : false;
    return $args;
}
Exemplo n.º 11
0
/**
 * 
 *
 */
function contextAsXML(&$dbHandler, $contextSet, &$tplanMgr)
{
    $info = array();
    $tprojectMgr = new testproject($dbHandler);
    $info['tproject'] = $tprojectMgr->get_by_id($contextSet->tproject_id);
    unset($tprojectMgr);
    $info['tplan'] = $tplanMgr->get_by_id($contextSet->tplan_id);
    $buildMgr = new build_mgr($dbHandler);
    $info['build'] = $buildMgr->get_by_id($contextSet->build_id);
    unset($buildMgr);
    $info['platform'] = null;
    $platform_template = '';
    if ($contextSet->platform_id > 0) {
        $platformMgr = new tlPlatform($dbHandler, $contextSet->tproject_id);
        $info['platform'] = $platformMgr->getByID($contextSet->platform_id);
        unset($platformMgr);
        $platform_template = "\n\t" . "<platform>" . "\t\t" . "<name><![CDATA[||PLATFORMNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||PLATFORMID||]]></internal_id>" . "\n\t" . "</platform>";
    }
    $key2loop = array_keys($info);
    foreach ($key2loop as $item_key) {
        if (!is_null($info[$item_key])) {
            $contextInfo[$item_key . '_id'] = $info[$item_key]['id'];
            $contextInfo[$item_key . '_name'] = $info[$item_key]['name'];
        }
    }
    $contextInfo['prefix'] = $info['tproject']['prefix'];
    $xml_root = "<context>{{XMLCODE}}\n</context>";
    $xml_template = "\n\t" . "<testproject>" . "\t\t" . "<name><![CDATA[||TPROJECTNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||TPROJECTID||]]></internal_id>" . "\t\t" . "<prefix><![CDATA[||TPROJECTPREFIX||]]></prefix>" . "\n\t" . "</testproject>" . "\n\t" . "<testplan>" . "\t\t" . "<name><![CDATA[||TPLANNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||TPLANID||]]></internal_id>" . "\n\t" . "</testplan>" . $platform_template . "\n\t" . "<build>" . "\t\t" . "<name><![CDATA[||BUILDNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||BUILDID||]]></internal_id>" . "\n\t" . "</build>";
    $xml_mapping = null;
    $xml_mapping = array("||TPROJECTNAME||" => "tproject_name", "||TPROJECTID||" => 'tproject_id', "||TPROJECTPREFIX||" => "prefix", "||TPLANNAME||" => "tplan_name", "||TPLANID||" => 'tplan_id', "||BUILDNAME||" => "build_name", "||BUILDID||" => 'build_id', "||PLATFORMNAME||" => "platform_name", "||PLATFORMID||" => 'platform_id');
    $mm = array($contextInfo);
    $contextXML = exportDataToXML($mm, $xml_root, $xml_template, $xml_mapping, 'noXMLHeader' == 'noXMLHeader');
    // echo '<pre><xmp>';
    // echo $contextXML;
    // echo '</xmp></pre>';
    return $contextXML;
}
Exemplo n.º 12
0
function initializeGui(&$dbHandler, &$argsObj)
{
    $gui = new stdClass();
    $gui->pageTitle = lang_get('caption_testCasesWithoutTester');
    $gui->warning_msg = '';
    $gui->tplan_name = $argsObj->tplan_name;
    $mgr = new testproject($dbHandler);
    $dummy = $mgr->get_by_id($argsObj->tproject_id);
    $gui->tproject_name = $argsObj->tproject_name = $dummy['name'];
    $gui->options = new stdClass();
    $gui->options->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
    $gui->labels = init_labels(array('design' => null, 'execution' => null, 'execution_history' => null, 'match_count' => null));
    return $gui;
}
Exemplo n.º 13
0
/**
* init_args()
* Get in an object all data that has arrived to page through _REQUEST or _SESSION.
* If you think this page as a function, you can consider this data arguments (args)
* to a function call.
* Using all this data as one object property will help developer to understand
* if data is received or produced on page.
*
* @author franciscom - francisco.mancardi@gmail.com
* @args - used global coupling accessing $_REQUEST and $_SESSION
* 	if ($show_platforms)
	{
		$colDef[] = array('title_key' => 'platform', 'width' => 50, 'filter' => 'list', 'filterOptions' => $platforms);
	}
* @return object of stdClass
*
* 
* @internal revisions:
*  20100731 - asimon - additional arguments show_all_users and show_inactive_and_closed
*/
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? $_REQUEST['tproject_id'] : 0;
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $tproject_mgr = new testproject($dbHandler);
        $dummy = $tproject_mgr->get_by_id($args->tproject_id);
        $args->tproject_name = $dummy['name'];
        $args->priority_enabled = $dummy['opt']->testPriorityEnabled ? true : false;
        unset($tproject_mgr);
    }
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : 0;
    $args->user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0;
    if ($args->user_id == 0) {
        $args->user_id = isset($_SESSION['userID']) ? $_SESSION['userID'] : 0;
        $args->user_name = $_SESSION['currentUser']->login;
    }
    return $args;
}
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr, &$tcaseMgr)
{
    $platform_mgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $tcase_cfg = config_get('testcase_cfg');
    $gui = new stdClass();
    $gui->platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
    $gui->usePlatforms = $platform_mgr->platformsActiveForTestplan($argsObj->tplan_id);
    $gui->bulk_platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
    $gui->bulk_platforms[0] = lang_get("all_platforms");
    ksort($gui->bulk_platforms);
    $gui->send_mail = $argsObj->send_mail;
    $gui->send_mail_checked = "";
    if ($gui->send_mail) {
        $gui->send_mail_checked = ' checked="checked" ';
    }
    $gui->glueChar = $tcase_cfg->glue_character;
    if ($argsObj->level != 'testproject') {
        $gui->testCasePrefix = $tcaseMgr->tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
        $gui->testCasePrefix .= $tcase_cfg->glue_character;
        $gui->keywordsFilterType = $argsObj->keywordsFilterType;
        $gui->build_id = $argsObj->build_id;
        $gui->tplan_id = $argsObj->tplan_id;
        $tplan_info = $tplanMgr->get_by_id($argsObj->tplan_id);
        $gui->testPlanName = $tplan_info['name'];
        $build_info = $tplanMgr->get_build_by_id($argsObj->tplan_id, $argsObj->build_id);
        $gui->buildName = $build_info['name'];
        $gui->main_descr = sprintf(lang_get('title_tc_exec_assignment'), $gui->buildName, $gui->testPlanName);
        $tproject_mgr = new testproject($dbHandler);
        $tproject_info = $tproject_mgr->get_by_id($argsObj->tproject_id);
        $gui->all_users = tlUser::getAll($dbHandler, null, "id", null);
        $gui->users = getUsersForHtmlOptions($dbHandler, null, null, null, $gui->all_users);
        $gui->testers = getTestersForHtmlOptions($dbHandler, $argsObj->tplan_id, $tproject_info, $gui->all_users);
    }
    return $gui;
}
/**
 * Gets the arguments used to create the report. 
 * 
 * Some of these arguments are set in the $_REQUEST, and some in $_SESSION. 
 * Having these arguments in hand, the init_args method will use TestLink objects, 
 * such as a Test Project Manager (testproject class) to retrieve other information 
 * that is displayed on the screen (e.g.: project name).
 * 
 * @param $dbHandler handler to TestLink database
 * 
 * @return object of stdClass
 */
function init_args(&$dbHandler)
{
    $args = new stdClass();
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 32), "do_action" => array(tlInputParameter::STRING_N, 6, 6), "tproject_id" => array(tlInputParameter::INT_N), "user_id" => array(tlInputParameter::INT_N), "selected_start_date" => array(tlInputParameter::ARRAY_STRING_N), "selected_end_date" => array(tlInputParameter::ARRAY_STRING_N), "start_Hour" => array(tlInputParameter::INT_N), "end_Hour" => array(tlInputParameter::INT_N));
    $_REQUEST = strings_stripSlashes($_REQUEST);
    R_PARAMS($iParams, $args);
    if (!is_null($args->apikey)) {
        $args->show_only_active = true;
        $cerbero = new stdClass();
        $cerbero->args = new stdClass();
        $cerbero->args->tproject_id = $args->tproject_id;
        $cerbero->args->tplan_id = null;
        $cerbero->args->getAccessAttr = true;
        $cerbero->method = 'checkRights';
        setUpEnvForRemoteAccess($dbHandler, $args->apikey, $cerbero);
    } else {
        testlinkInitPage($dbHandler, false, false, "checkRights");
    }
    if ($args->tproject_id < 0) {
        throw new Exception('Test project id can not be empty');
    }
    $mgr = new testproject($dbHandler);
    $info = $mgr->get_by_id($args->tproject_id);
    $args->tproject_name = $info['name'];
    return $args;
}
Exemplo n.º 16
0
<?php

//@TODO this file seems not to be in use
include "../../third_party/charts/charts.php";
require_once '../functions/results.class.php';
require_once '../functions/testplan.class.php';
testlinkInitPage($db);
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$tplan_id = $_REQUEST['tplan_id'];
$tproject_id = $_SESSION['testprojectID'];
$tplan_info = $tplan_mgr->get_by_id($tplan_id);
$tproject_info = $tproject_mgr->get_by_id($tproject_id);
$re = new results($db, $tplan_mgr, $tproject_info, $tplan_info, ALL_TEST_SUITES, ALL_BUILDS);
/**
* KEYWORDS REPORT
*/
$arrDataKeys = $re->getAggregateKeywordResults();
$i = 0;
$arrDataKeys2 = null;
if ($arrDataKeys != null) {
    while ($keywordId = key($arrDataKeys)) {
        $arr = $arrDataKeys[$keywordId];
        $arrDataKeys2[$i] = $arr;
        $i++;
        next($arrDataKeys);
    }
}
$namesOfKeywordsArray = array();
$namesOfKeywordsArray[0] = "";
$passArray = array();
Exemplo n.º 17
0
function init_args(&$dbHandler)
{
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args->importType = isset($_REQUEST['importType']) ? $_REQUEST['importType'] : null;
    // Need to use REQUEST because sometimes data arrives on GET and other on POST (has hidden fields)
    $args->buildID = isset($_REQUEST['buildID']) ? intval($_REQUEST['buildID']) : null;
    $args->platformID = isset($_REQUEST['platformID']) ? intval($_REQUEST['platformID']) : null;
    $args->tplanID = isset($_REQUEST['tplanID']) ? intval($_REQUEST['tplanID']) : null;
    $args->tplanID = !is_null($args->tplanID) ? $args->tplanID : $_SESSION['testplanID'];
    $args->tprojectID = isset($_REQUEST['tprojectID']) ? intval($_REQUEST['tprojectID']) : null;
    if (is_null($args->tprojectID)) {
        $args->tprojectID = $_SESSION['testprojectID'];
        $args->testprojectName = $_SESSION['testprojectName'];
    } else {
        $tproject_mgr = new testproject($dbHandler);
        $dummy = $tproject_mgr->get_by_id($args->tprojectID);
        $args->testprojectName = $dummy['name'];
    }
    $args->doUpload = isset($_REQUEST['UploadFile']) ? 1 : 0;
    $args->userID = $_SESSION['userID'];
    return $args;
}
Exemplo n.º 18
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;
}
Exemplo n.º 19
0
/**
 * @internal revisions
 */
function importTestPlanLinksFromXML(&$dbHandler, &$tplanMgr, $targetFile, $contextObj)
{
    //   <testplan>
    //     <name></name>
    //     <platforms>
    //       <platform>
    //         <name> </name>
    //         <internal_id></internal_id>
    //       </platform>
    //       <platform>
    //       ...
    //       </platform>
    //     </platforms>
    //     <executables>
    //       <link>
    //         <platform>
    //           <name> </name>
    //         </platform>
    //         <testcase>
    //           <name> </name>
    //           <externalid> </externalid>
    //           <version> </version>
    //           <execution_order> </execution_order>
    //         </testcase>
    //       </link>
    //       <link>
    //       ...
    //       </link>
    //     </executables>
    //   </testplan>
    // </xml>
    $msg = array();
    $labels = init_labels(array('link_without_required_platform' => null, 'ok' => null, 'link_without_platform_element' => null, 'no_platforms_on_tproject' => null, 'tcase_link_updated' => null, 'link_with_platform_not_needed' => null, 'tproject_has_zero_testcases' => null, 'platform_not_on_tproject' => null, 'platform_linked' => null, 'platform_not_linked' => null, 'tcase_doesnot_exist' => null, 'tcversion_doesnot_exist' => null, 'not_imported' => null, 'link_to_tplan_feedback' => null, 'link_to_platform' => null));
    // Double Check
    // Check if Test Plan Parent (Test Project) has testcases, if not abort
    $tprojectMgr = new testproject($dbHandler);
    $tprojectInfo = $tprojectMgr->get_by_id($contextObj->tproject_id);
    $tcasePrefix = $tprojectInfo['prefix'] . config_get('testcase_cfg')->glue_character;
    $tprojectHasTC = $tprojectMgr->count_testcases($contextObj->tproject_id) > 0;
    if (!$tprojectHasTC) {
        $msg[] = array(sprintf($labels['tproject_has_zero_testcases'], $tprojectInfo['name']), $labels['not_imported']);
        return $msg;
        // >>>-----> Bye
    }
    $xml = @simplexml_load_file_wrapper($targetFile);
    if ($xml !== FALSE) {
        $tcaseMgr = new testcase($dbHandler);
        $tcaseSet = array();
        $tprojectMgr->get_all_testcases_id($contextObj->tproject_id, $tcaseSet, array('output' => 'external_id'));
        $tcaseSet = array_flip($tcaseSet);
        // Test Plan name will not be used
        // <testplan>  <name></name>
        //
        // Platform definition info will not be used
        //
        // I will try to link the platforms if are defined
        $status_ok = true;
        if (property_exists($xml, 'platforms')) {
            $platformMgr = new tlPlatform($dbHandler, $contextObj->tproject_id);
            $platformUniverse = $platformMgr->getAllAsMap();
            if (is_null($platformUniverse)) {
                $status_ok = false;
                $msg[] = array($labels['no_platforms_on_tproject'], $labels['not_imported']);
            } else {
                $platformUniverse = array_flip($platformUniverse);
                $op = processPlatforms($platformMgr, $tplanMgr, $platformUniverse, $xml->platforms, $labels, $contextObj->tplan_id);
                $status_ok = $op['status_ok'];
                $msg = $op['msg'];
            }
        }
        if ($status_ok && $xml->xpath('//executables')) {
            $tables = tlObjectWithDB::getDBTables(array('testplan_tcversions'));
            $platformSet = $tplanMgr->getPlatforms($contextObj->tplan_id, array('outputFormat' => 'mapAccessByName'));
            $targetHasPlatforms = count($platformSet) > 0;
            $xmlLinks = $xml->executables->children();
            $loops2do = count($xmlLinks);
            // new dBug($platformSet);
            for ($idx = 0; $idx < $loops2do; $idx++) {
                // if Target Test Plan has platforms and importing file NO => Fatal Error
                $targetName = null;
                $platformID = -1;
                $linkWithPlatform = false;
                $status_ok = false;
                $dummy_msg = null;
                $import_status = $labels['ok'];
                if ($platformElementExists = property_exists($xmlLinks[$idx], 'platform')) {
                    $targetName = trim((string) $xmlLinks[$idx]->platform->name);
                    $linkWithPlatform = $targetName != '';
                }
                // echo "\$targetHasPlatforms:$targetHasPlatforms<br>";
                // echo "\$linkWithPlatform:$linkWithPlatform<br>";
                if ($targetHasPlatforms) {
                    // each link need to have platform or will not be imported
                    if ($linkWithPlatform && isset($platformSet[$targetName])) {
                        $platformID = $platformSet[$targetName]['id'];
                        $status_ok = true;
                        $dummy_msg = null;
                    } else {
                        $import_status = $labels['not_imported'];
                        if (!$platformElementExists) {
                            $dummy_msg = sprintf($labels['link_without_platform_element'], $idx + 1);
                        } else {
                            if (!$linkWithPlatform) {
                                $dummy_msg = sprintf($labels['link_without_required_platform'], $idx + 1);
                            } else {
                                $dummy_msg = sprintf($labels['platform_not_linked'], $idx + 1, $targetName, $contextObj->tplan_name);
                            }
                        }
                    }
                } else {
                    if ($linkWithPlatform) {
                        $import_status = $labels['not_imported'];
                        $dummy_msg = sprintf($labels['link_with_platform_not_needed'], $idx + 1);
                    } else {
                        $platformID = 0;
                        $status_ok = true;
                    }
                }
                if (!is_null($dummy_msg)) {
                    $msg[] = array($dummy_msg, $import_status);
                }
                // echo '$status_ok' . $status_ok . ' ' . __LINE__ . '<br>' ;
                if ($status_ok) {
                    $createLink = false;
                    $updateLink = false;
                    // Link passed ok check on platform
                    // Now we need to understand if requested Test case is present on Test Project
                    $externalID = (int) $xmlLinks[$idx]->testcase->externalid;
                    $tcaseName = (string) $xmlLinks[$idx]->testcase->name;
                    $execOrder = (int) $xmlLinks[$idx]->testcase->execution_order;
                    $version = (int) $xmlLinks[$idx]->testcase->version;
                    if (isset($tcaseSet[$externalID])) {
                        // now need to check if requested version exists
                        $dummy = $tcaseMgr->get_basic_info($tcaseSet[$externalID], array('number' => $version));
                        if (count($dummy) > 0) {
                            // Check :
                            // for same test plan there is a different version already linked ?
                            // if YES => error.
                            //
                            $lvFilters = array('tplan_id' => $contextObj->tplan_id);
                            $linkedVersions = $tcaseMgr->get_linked_versions($dummy[0]['id'], $lvFilters);
                            $updateLink = false;
                            $doUpdateFeedBack = true;
                            // TICKET 5189: Import a test plan does not import test cases execution order
                            // new dBug($linkedVersions);
                            if (!($createLink = is_null($linkedVersions))) {
                                // Now need to understand if is already linked with this signature.
                                if (!isset($linkedVersions[$dummy[0]['tcversion_id']])) {
                                    //echo 'CREATE';
                                    $createLink = true;
                                } else {
                                    // linked platforms
                                    $createLink = false;
                                    $updateLink = false;
                                    $plat_keys = array_keys($linkedVersions[$dummy[0]['tcversion_id']][$contextObj->tplan_id]);
                                    $plat_keys = array_flip($plat_keys);
                                    if (isset($plat_keys[$platformID])) {
                                        $updateLink = true;
                                    } else {
                                        if ($platformID == 0) {
                                            // User request to add without platform, but platforms exist => SKIP
                                            $msg[] = array('platform 0 missing messages', $labels['not_imported']);
                                        } else {
                                            $createLink = true;
                                        }
                                    }
                                }
                            }
                            if ($createLink) {
                                // Create link
                                // function link_tcversions($id,&$items_to_link,$userId)
                                $item2link['items'] = array($dummy[0]['id'] => array($platformID => $dummy[0]['tcversion_id']));
                                $item2link['tcversion'] = array($dummy[0]['id'] => $dummy[0]['tcversion_id']);
                                $tplanMgr->link_tcversions($contextObj->tplan_id, $item2link, $contextObj->userID);
                                $dummy_msg = sprintf($labels['link_to_tplan_feedback'], $externalID, $version);
                                if ($platformID > 0) {
                                    $dummy_msg .= sprintf($labels['link_to_platform'], $targetName);
                                }
                                $msg[] = array($dummy_msg, $labels['ok']);
                                // TICKET 5189: Import a test plan does not import test cases execution order
                                $updateLink = true;
                                $doUpdateFeedBack = false;
                            }
                            if ($updateLink) {
                                $newOrder = array($dummy[0]['tcversion_id'] => $execOrder);
                                $tplanMgr->setExecutionOrder($contextObj->tplan_id, $newOrder);
                                if ($doUpdateFeedBack) {
                                    $dummy_msg = sprintf($labels['tcase_link_updated'], $tcasePrefix . $externalID . ' ' . $tcaseName, $version);
                                    $msg[] = array($dummy_msg, $labels['ok']);
                                }
                            }
                        } else {
                            $msg[] = array(sprintf($labels['tcversion_doesnot_exist'], $externalID, $version, $tprojectInfo['name']));
                        }
                    } else {
                        $msg[] = array(sprintf($labels['tcase_doesnot_exist'], $externalID, $tprojectInfo['name']));
                    }
                    //$tcaseMgr->get_by_external
                    // echo '<pre><xmp>';
                    // var_dump($xmlLinks[$idx]->testcase);
                    // echo 'TCBAME' . (string)$xmlLinks[$idx]->testcase->name;
                    // echo '</xmp></pre>';
                }
            }
        }
    }
    return $msg;
}
Exemplo n.º 20
0
function itsProcess(&$dbHandler, $argsObj, &$guiObj)
{
    $its = null;
    $tprojectMgr = new testproject($dbHandler);
    $info = $tprojectMgr->get_by_id($argsObj->tproject_id);
    if ($info['issue_tracker_enabled']) {
        $it_mgr = new tlIssueTracker($dbHandler);
        $issueT = $it_mgr->getLinkedTo($argsObj->tproject_id);
        if (!is_null($issueT)) {
            $its = $it_mgr->getInterfaceObject($argsObj->tproject_id);
            $guiObj->issueTrackerVerboseType = $issueT['verboseType'];
            $guiObj->issueTrackerVerboseID = $issueT['issuetracker_name'];
            $guiObj->bugIDMaxLength = $its->getBugIDMaxLength();
            $guiObj->createIssueURL = $its->getEnterBugURL();
            if (method_exists($its, 'addIssue') && $argsObj->user_action == 'create') {
                list($guiObj->tlCanCreateIssue, $guiObj->msg) = addIssue($dbHandler, $argsObj, $its);
            }
        }
    }
    return array($its, $issueT);
}
Exemplo n.º 21
0
/**
 *
 */
function getIssueTracker(&$dbHandler, $argsObj, &$guiObj)
{
    $its = null;
    $tprojectMgr = new testproject($dbHandler);
    $info = $tprojectMgr->get_by_id($argsObj->tproject_id);
    $guiObj->issueTrackerCfg = new stdClass();
    $guiObj->issueTrackerCfg->createIssueURL = null;
    $guiObj->issueTrackerCfg->VerboseID = '';
    $guiObj->issueTrackerCfg->VerboseType = '';
    $guiObj->issueTrackerCfg->bugIDMaxLength = 0;
    $guiObj->issueTrackerCfg->bugSummaryMaxLength = 100;
    // MAGIC
    $guiObj->issueTrackerCfg->tlCanCreateIssue = false;
    $guiObj->issueTrackerCfg->tlCanAddIssueNote = true;
    if ($info['issue_tracker_enabled']) {
        $it_mgr = new tlIssueTracker($dbHandler);
        $issueTrackerCfg = $it_mgr->getLinkedTo($argsObj->tproject_id);
        if (!is_null($issueTrackerCfg)) {
            $its = $it_mgr->getInterfaceObject($argsObj->tproject_id);
            $guiObj->issueTrackerCfg->VerboseType = $issueTrackerCfg['verboseType'];
            $guiObj->issueTrackerCfg->VerboseID = $issueTrackerCfg['issuetracker_name'];
            $guiObj->issueTrackerCfg->bugIDMaxLength = $its->getBugIDMaxLength();
            $guiObj->issueTrackerCfg->createIssueURL = $its->getEnterBugURL();
            $guiObj->issueTrackerCfg->bugSummaryMaxLength = $its->getBugSummaryMaxLength();
            $guiObj->issueTrackerCfg->tlCanCreateIssue = method_exists($its, 'addIssue');
            $guiObj->issueTrackerCfg->tlCanAddIssueNote = method_exists($its, 'addNote');
        }
    }
    return array($its, $issueTrackerCfg);
}
/**
 * render Test Case content for generated documents
 * 
 * @param $integer db DB connection identifier 
 * @return string generated html code
 *
 * @internal revisions
 */
function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context, $indentLevel)
{
    static $req_mgr;
    static $tc_mgr;
    static $build_mgr;
    static $tplan_mgr;
    static $tplan_urgency;
    static $labels;
    static $tcase_prefix;
    static $userMap = array();
    static $cfg;
    static $tables = null;
    static $force = null;
    static $bugInterfaceOn = false;
    static $its;
    static $buildCfields;
    static $statusL10N;
    static $docRepo;
    static $st;
    $code = null;
    $tcInfo = null;
    $tcResultInfo = null;
    $tcase_pieces = null;
    $id = $node['id'];
    $level = $indentLevel;
    $prefix = isset($context['prefix']) ? $context['prefix'] : null;
    $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
    $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
    $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0;
    $build_id = isset($context['build_id']) ? $context['build_id'] : 0;
    // init static elements
    if (!$tables) {
        $st = new stdClass();
        $tables = tlDBObject::getDBTables(array('executions', 'builds', 'execution_tcsteps'));
        $tc_mgr = new testcase($db);
        $tplan_urgency = new testPlanUrgency($db);
        $build_mgr = new build_mgr($db);
        $tplan_mgr = new testplan($db);
        $req_mgr = new requirement_mgr($db);
        list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options);
        if (!is_null($prefix)) {
            $tcase_prefix = $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;
        $its = null;
        $tproject_mgr = new testproject($db);
        $info = $tproject_mgr->get_by_id($tprojectID);
        $bugInterfaceOn = $info['issue_tracker_enabled'];
        if ($info['issue_tracker_enabled']) {
            $it_mgr = new tlIssueTracker($db);
            $its = $it_mgr->getInterfaceObject($tprojectID);
            unset($it_mgr);
        }
        $statusL10N = null;
        foreach ($cfg['results']['code_status'] as $vc => $vstat) {
            if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) {
                $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]);
            }
        }
        $docRepo = tlAttachmentRepository::create($db);
        $st->locationFilters = $tc_mgr->buildCFLocationMap();
        // change table style in case of single TC printing to not be indented
        $st->table_style = "";
        if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) {
            $st->table_style = 'style="margin-left: 0;"';
        }
        $st->cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => ' colspan = "' . ($cfg['tableColspan'] - 1) . '" ');
        $info = null;
    }
    /** 
     * @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;
    $getByID['filters'] = null;
    $opt = array();
    $opt['step_exec_notes'] = isset($options['step_exec_notes']) && $options['step_exec_notes'];
    $opt['step_exec_status'] = isset($options['step_exec_status']) && $options['step_exec_status'];
    switch ($options["docType"]) {
        case DOC_TEST_SPEC:
            $getByID['tcversion_id'] = testcase::LATEST_VERSION;
            $getExecutions = false;
            break;
        case SINGLE_TESTCASE:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status'];
            break;
        default:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status'];
            break;
    }
    if ($getExecutions) {
        // Thanks to Evelyn from Cortado, have found a very old issue never reported.
        // 1. create TC-1A VERSION 1
        // 2. add to test plan and execute FAILED ON BUILD 1
        // 3. Request Test Report (Test Plan EXECUTION REPORT).
        //    You will get spec for VERSION 1 and result for VERSION 1 - OK cool!
        // 4. create VERSION 2
        // 5. update linked Test Case Versions
        // 6. do nothing more than repeat step 3
        //    without this fix you will get
        //    You will get spec for VERSION 2 and result for VERSION 1 - Hmmm
        //    and in addition is not clear that execution was on VERSION 1 . No GOOD!!
        //
        // HOW has been fixed ?
        // Getting info about THE CURRENT LINKED test case version and looking for
        // exec info for this.
        //
        // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided
        //
        //
        // Get Linked test case version
        $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id);
        $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.execution_type, E.execution_duration, " . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON B.id = E.build_id " . " WHERE 1 = 1 ";
        if (isset($context['exec_id'])) {
            $sql .= " AND E.id=" . intval($context['exec_id']);
        } else {
            $sql .= " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']);
            if ($build_id > 0) {
                $sql .= " AND E.build_id = " . intval($build_id);
            } else {
                // We are looking for LATEST EXECUTION of CURRENT LINKED test case version
                $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']);
            }
            $sql .= " ORDER BY execution_id DESC";
        }
        $exec_info = $db->get_recordset($sql, null, 1);
        $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id'];
        $getByID['filters'] = null;
        $linkedItem = null;
        if (!is_null($exec_info)) {
            $getByID['tcversion_id'] = null;
            $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']);
            if (isset($options['build_cfields']) && $options['build_cfields']) {
                if (!isset($buildCfields[$exec_info[0]['build_id']])) {
                    $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID);
                }
            }
        }
    }
    $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true, 'renderImageInline' => true));
    if ($tcInfo) {
        $tcInfo = $tcInfo[0];
    }
    $external_id = $tcase_prefix . $tcInfo['tc_external_id'];
    $name = htmlspecialchars($node['name']);
    $cfields = array('specScope' => null, 'execScope' => null);
    if ($options['cfields']) {
        // Get custom fields that has specification scope
        // Custom Field values at Test Case VERSION Level
        foreach ($st->locationFilters as $fkey => $fvalue) {
            $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $st->cfieldFormatting, $tcInfo['id']);
        }
        if (!is_null($exec_info)) {
            $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($tcInfo['id'], 'execution', null, $exec_info[0]['execution_id'], $tplan_id, $tprojectID, $st->cfieldFormatting);
        }
    }
    if ($options['toc']) {
        // EXTERNAL ID added
        $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>';
        $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>';
    }
    $code .= '<p>&nbsp;</p><div> <table class="tc" width="90%" ' . $st->table_style . '>';
    $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name;
    // add test case version
    switch ($env->reportType) {
        case DOC_TEST_PLAN_DESIGN:
            $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version'];
            break;
        case DOC_TEST_PLAN_EXECUTION:
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $version_number = $tcInfo['version'];
            break;
        default:
            $version_number = $tcInfo['version'];
            break;
    }
    if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) {
        $code .= '&nbsp;<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';
    }
    if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) {
        $tcase_pieces[] = 'steps';
    }
    if (!is_null($tcase_pieces)) {
        // Check user rights in order to understand if can delete attachments here
        //   function hasRight(&$db,$roleQuestion,$tprojectID = null,$tplanID = null,$getAccess=false)
        // $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
        // $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
        $canManageAttachments = false;
        if (isset($context['user']) && !is_null($context['user'])) {
            $canManageAttachments = $context['user']->hasRight($db, 'testplan_execute', $tprojectID, $tplan_id);
        }
        // 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 (!is_null($tcInfo[$key]) && $tcInfo[$key] != '') {
                    $td_colspan = 3;
                    $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>';
                    $sxni = null;
                    if ($opt['step_exec_notes'] || $opt['step_exec_status']) {
                        $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']);
                        if ($opt['step_exec_notes']) {
                            $td_colspan++;
                            $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>';
                        }
                        if ($opt['step_exec_status']) {
                            $td_colspan++;
                            $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>';
                        }
                    }
                    $code .= '</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>';
                        $nike = !is_null($sxni) && isset($sxni[$tcInfo[$key][$ydx]['id']]) && !is_null($sxni[$tcInfo[$key][$ydx]['id']]);
                        if ($opt['step_exec_notes']) {
                            $code .= '<td>';
                            if ($nike) {
                                $code .= $sxni[$tcInfo[$key][$ydx]['id']]['notes'];
                            }
                            $code .= '</td>';
                        }
                        if ($opt['step_exec_status']) {
                            $code .= '<td>';
                            if ($nike) {
                                $code .= $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']];
                            }
                            $code .= '</td>';
                        }
                        $code .= '</tr>';
                        // Attachment management
                        if ($getExecutions) {
                            if (isset($sxni[$tcInfo[$key][$ydx]['id']])) {
                                $attachInfo = getAttachmentInfos($docRepo, $sxni[$tcInfo[$key][$ydx]['id']]['id'], $tables['execution_tcsteps'], true, 1);
                                if (!is_null($attachInfo)) {
                                    $code .= '<tr><td colspan="' . $td_colspan . '">';
                                    $code .= '<b>' . $labels['exec_attachments'] . '</b><br>';
                                    foreach ($attachInfo as $fitem) {
                                        $code .= '<form method="POST" name="fda' . $fitem['id'] . '" ' . ' id="fda' . $fitem['id'] . "' " . ' action="' . $env->base_href . 'lib/execute/execPrint.php">';
                                        $code .= '<input type="hidden" name="id" value="' . intval($context['exec_id']) . '">';
                                        $code .= '<input type="hidden" name="deleteAttachmentID" value="' . intval($fitem['id']) . '">';
                                        if ($fitem['is_image']) {
                                            $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>";
                                            $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '">';
                                        } else {
                                            $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a>';
                                        }
                                        $code .= '<input type="image" alt="' . $labels['alt_delete_attachment'] . '"' . 'src="' . $env->base_href . TL_THEME_IMG_DIR . 'trash.png"></li></form>';
                                    }
                                    $code .= '</td></tr>';
                                }
                            }
                        }
                        // $getExecutions
                    }
                }
            } 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) . '">';
    // This is what have been choosen DURING DESIGN, but may be we can choose at DESIGN
    // manual and the execute AUTO, or may be choose AUTO and execute MANUAL.
    // After report on MANTIS, seems that we need to provide in output two values:
    // DESIGN execution type
    // EXECUTION execution type
    switch ($tcInfo['execution_type']) {
        case TESTCASE_EXECUTION_TYPE_AUTO:
            $code .= $labels['execution_type_auto'];
            break;
        case TESTCASE_EXECUTION_TYPE_MANUAL:
        default:
            $code .= $labels['execution_type_manual'];
            break;
    }
    $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_exec_duration'];
    $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";
    }
    // 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'];
    //
    $cfields = null;
    $prio_info = null;
    // $code = null;
    // 20140813
    $relSet = $tc_mgr->getRelations($id);
    if (!is_null($relSet['relations'])) {
        // $fx = str_repeat('&nbsp;',5); // MAGIC allowed
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['relations'] . '</span></td>';
        $code .= '<td>';
        for ($rdx = 0; $rdx < $relSet['num_relations']; $rdx++) {
            if ($relSet['relations'][$rdx]['source_id'] == $id) {
                $ak = 'source_localized';
            } else {
                $ak = 'destination_localized';
            }
            $code .= htmlspecialchars($relSet['relations'][$rdx][$ak]) . ' - ' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['fullExternalID']) . ':' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['name']) . '<br>';
        }
        $code .= '</td></tr>';
    }
    $relSet = null;
    // collect REQ for TC
    if ($options['requirement']) {
        $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 .= '&nbsp;' . $labels['none'] . '<br />';
        }
        $code .= "</td></tr>\n";
    }
    $requirements = null;
    // 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) . '">';
        $kwSet = $tc_mgr->getKeywords($id, null, array('fields' => 'keyword_id,keywords.keyword'));
        if (sizeof($kwSet)) {
            foreach ($kwSet as $kw) {
                $code .= htmlspecialchars($kw['keyword']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br>';
        }
        $code .= "</td></tr>\n";
    }
    $kwSet = null;
    // Attachments
    $attachSet = (array) $tc_mgr->getAttachmentInfos($id);
    if (count($attachSet) > 0) {
        $code .= '<tr><td> <span class="label">' . $labels['attached_files'] . '</span></td>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 2) . '"><ul>';
        foreach ($attachSet as $item) {
            $fname = "";
            if ($item['title']) {
                $fname .= htmlspecialchars($item['title']) . " : ";
            }
            $fname .= htmlspecialchars($item['file_name']);
            $code .= "<li>{$fname}</li>";
            if ($item['is_image']) {
                $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>';
            } else {
                $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($item['file_name']) . '</a></li>';
            }
        }
        $code .= "</ul></td></tr>";
    }
    $attachSet = null;
    // generate test results data for test report
    if ($options['passfail']) {
        $tsp = $cfg['tableColspan'] - 1;
        $code .= '<tr style="' . "font-weight: bold;background: #EEE;text-align: left;" . '">' . '<td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['execution_details'] . '</td>' . '<td colspan="' . $tsp . '">' . "&nbsp;" . "</b></td></tr>\n";
        $bn = '';
        switch ($env->reportType) {
            case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
                $ib = $build_mgr->get_by_id($build_id);
                $bn = htmlspecialchars($ib['name']);
                break;
            case DOC_TEST_PLAN_EXECUTION:
                if ($exec_info) {
                    $bn = htmlspecialchars($exec_info[0]['build_name']);
                }
                break;
        }
        if ($bn != '') {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['build'] . '</td>' . '<td ' . $tsp . '>' . $bn . "</b></td></tr>\n";
        }
        if (isset($node['assigned_to'])) {
            $crew = explode(',', $node['assigned_to']);
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['assigned_to'] . '</td>' . '<td colspan="' . $tsp . '">';
            $xdx = 0;
            foreach ($crew as $mm) {
                if ($xdx != 0) {
                    $code .= ',';
                }
                $xdx = -1;
                echo $mm . '<br>';
                $code .= gendocGetUserName($db, $mm);
            }
            $code .= "</td></tr>\n";
        }
        if ($exec_info) {
            $settings['cfg'] = $cfg;
            $settings['lbl'] = $labels;
            $settings['opt'] = array('show_notes' => $options['notes']);
            $settings['colspan'] = $cfg['tableColspan'] - 1;
            $code .= buildTestExecResults($db, $its, $exec_info, $settings, $buildCfields);
            // Get Execution Attachments
            $execAttachInfo = getAttachmentInfos($docRepo, $exec_info[0]['execution_id'], $tables['executions'], true, 1);
            if (!is_null($execAttachInfo)) {
                $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">';
                $code .= '<b>' . $labels['exec_attachments'] . '</b><br>';
                foreach ($execAttachInfo as $fitem) {
                    if ($fitem['is_image']) {
                        $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>";
                        $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '"> </li>';
                    } else {
                        $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a></li>';
                    }
                }
                $code .= '</td></tr>';
            }
        } else {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['report_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n";
        }
        $execAttachInfo = null;
        $exec_info = null;
    }
    $code .= "</table>\n</div>\n";
    return $code;
}
 /**
  * create XML string with following structure
  *
  *  <?xml version="1.0" encoding="UTF-8"?>
  *  
  * @param mixed context: map with following keys 
  *             platform_id: MANDATORY
  *             build_id: OPTIONAL
  *             tproject_id: OPTIONAL
  */
 function exportTestPlanDataToXML($id, $context, $optExport = array())
 {
     $platform_id = $context['platform_id'];
     if (!isset($context['tproject_id']) || is_null($context['tproject_id'])) {
         $dummy = $this->tree_manager->get_node_hierarchy_info($id);
         $context['tproject_id'] = $dummy['parent_id'];
     }
     $context['tproject_id'] = intval($context['tproject_id']);
     $xmlTC = null;
     // CRITIC - this has to be firt population of item_info.
     // Other processes adds info to this map.
     $item_info = $this->get_by_id($id);
     // Need to get family
     $nt2exclude = array('testplan' => 'exclude_me', 'requirement_spec' => 'exclude_me', 'requirement' => 'exclude_me');
     $nt2exclude_children = array('testcase' => 'exclude_my_children', 'requirement_spec' => 'exclude_my_children');
     $my = array();
     // this can be a litte weird but ...
     // when
     // 'order_cfg' => array("type" =>'exec_order'
     // additional info test plan id, and platform id are used to get
     // a filtered view of tree.
     //
     $order_cfg = array("type" => 'exec_order', "tplan_id" => $id);
     if ($context['platform_id'] > 0) {
         $order_cfg['platform_id'] = $context['platform_id'];
     }
     $my['options'] = array('recursive' => true, 'order_cfg' => $order_cfg, 'remove_empty_nodes_of_type' => $this->tree_manager->node_descr_id['testsuite']);
     $my['filters'] = array('exclude_node_types' => $nt2exclude, 'exclude_children_of' => $nt2exclude_children);
     $tplan_spec = $this->tree_manager->get_subtree($context['tproject_id'], $my['filters'], $my['options']);
     // -----------------------------------------------------------------------------------------------------
     // Generate test project info
     $tproject_mgr = new testproject($this->db);
     $tproject_info = $tproject_mgr->get_by_id($context['tproject_id']);
     // ||yyy||-> tags,  {{xxx}} -> attribute
     // tags and attributes receive different treatment on exportDataToXML()
     //
     // each UPPER CASE word in this map is a KEY, that MUST HAVE AN OCCURENCE on $elemTpl
     //
     $xml_template = "\n\t" . "<testproject>" . "\t\t" . "<name><![CDATA[||TESTPROJECTNAME||]]></name>" . "\t\t" . "<prefix><![CDATA[||TESTPROJECTPREFIX||]]></prefix>" . "\t\t" . "<internal_id><![CDATA[||TESTPROJECTID||]]></internal_id>" . "\n\t" . "</testproject>";
     $xml_root = "{{XMLCODE}}";
     $xml_mapping = null;
     $xml_mapping = array("||TESTPROJECTNAME||" => "name", "||TESTPROJECTPREFIX||" => "prefix", "||TESTPROJECTID||" => 'id');
     $mm = array();
     $mm[$context['tproject_id']] = array('name' => $tproject_info['name'], 'prefix' => $tproject_info['prefix'], 'id' => $context['tproject_id']);
     $item_info['testproject'] = exportDataToXML($mm, $xml_root, $xml_template, $xml_mapping, 'noXMLHeader' == 'noXMLHeader');
     // -----------------------------------------------------------------------------------------------------
     // -----------------------------------------------------------------------------------------------------
     // get target platform (if exists)
     $target_platform = '';
     if ($context['platform_id'] > 0) {
         $info = $this->platform_mgr->getByID($context['platform_id']);
         // ||yyy||-> tags,  {{xxx}} -> attribute
         // tags and attributes receive different treatment on exportDataToXML()
         //
         // each UPPER CASE word in this map is a KEY, that MUST HAVE AN OCCURENCE on $elemTpl
         //
         $xml_template = "\n\t" . "<platform>" . "\t\t" . "<name><![CDATA[||PLATFORMNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||PLATFORMID||]]></internal_id>" . "\n\t" . "</platform>";
         $xml_root = "{{XMLCODE}}";
         $xml_mapping = null;
         $xml_mapping = array("||PLATFORMNAME||" => "platform_name", "||PLATFORMID||" => 'id');
         $mm = array();
         $mm[$context['platform_id']] = array('platform_name' => $info['name'], 'id' => $context['platform_id']);
         $item_info['target_platform'] = exportDataToXML($mm, $xml_root, $xml_template, $xml_mapping, 'noXMLHeader' == 'noXMLHeader');
         $target_platform = "\t\t||TARGET_PLATFORM||\n";
     }
     // -----------------------------------------------------------------------------------------------------
     // -----------------------------------------------------------------------------------------------------
     // get Build info (if possible)
     $target_build = '';
     if (isset($context['build_id']) && $context['build_id'] > 0) {
         $dummy = $this->get_builds($id);
         $info = $dummy[$context['build_id']];
         // ||yyy||-> tags,  {{xxx}} -> attribute
         // tags and attributes receive different treatment on exportDataToXML()
         //
         // each UPPER CASE word in this map is a KEY, that MUST HAVE AN OCCURENCE on $elemTpl
         //
         $xml_template = "\n\t" . "<build>" . "\t\t" . "<name><![CDATA[||BUILDNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||BUILDID||]]></internal_id>" . "\n\t" . "</build>";
         $xml_root = "{{XMLCODE}}";
         $xml_mapping = null;
         $xml_mapping = array("||BUILDNAME||" => "name", "||BUILDID||" => 'id');
         $mm = array();
         $mm[$context['build_id']] = array('name' => $info['name'], 'id' => $context['build_id']);
         $item_info['target_build'] = exportDataToXML($mm, $xml_root, $xml_template, $xml_mapping, 'noXMLHeader' == 'noXMLHeader');
         $target_build = "\t\t||TARGET_BUILD||\n";
     }
     // -----------------------------------------------------------------------------------------------------
     // -----------------------------------------------------------------------------------------------------
     // get test plan contents (test suites and test cases)
     $item_info['testsuites'] = null;
     if (!is_null($tplan_spec) && isset($tplan_spec['childNodes']) && ($loop2do = count($tplan_spec['childNodes'])) > 0) {
         $item_info['testsuites'] = '<testsuites>' . $this->exportTestSuiteDataToXML($tplan_spec, $context['tproject_id'], $id, $context['platform_id']) . '</testsuites>';
     }
     $xml_root = "\n\t<testplan>{{XMLCODE}}\n\t</testplan>";
     $xml_template = "\n\t\t" . "<name><![CDATA[||TESTPLANNAME||]]></name>" . "\n" . "\t\t||TESTPROJECT||\n" . $target_platform . $target_build . "\t\t||TESTSUITES||\n";
     $xml_mapping = null;
     $xml_mapping = array("||TESTPLANNAME||" => "name", "||TESTPROJECT||" => "testproject", "||TARGET_PLATFORM||" => "target_platform", "||TARGET_BUILD||" => "target_build", "||TESTSUITES||" => "testsuites");
     $zorba = exportDataToXML(array($item_info), $xml_root, $xml_template, $xml_mapping);
     return $zorba;
 }
Exemplo n.º 24
0
/**
 */
function initEnvironment(&$dbHandler, &$userObj)
{
    $argsObj = new stdClass();
    $guiObj = new stdClass();
    $cfg = config_get("gui");
    $tprojectMgr = new testproject($dbHandler);
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $iParams = array("tprojectIDNavBar" => array(tlInputParameter::INT_N), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "testplan" => array(tlInputParameter::INT_N), "updateMainPage" => array(tlInputParameter::INT_N), "runUpdateLogic" => array(tlInputParameter::INT_N));
    R_PARAMS($iParams, $argsObj);
    // @TODO in future refactor tlInput logic to allow pass default value
    $argsObj->updateMainPage = is_null($argsObj->updateMainPage) ? 0 : $argsObj->updateMainPage;
    $argsObj->runUpdateLogic = is_null($argsObj->runUpdateLogic) ? 1 : $argsObj->runUpdateLogic;
    $argsObj->updateMainPage = intval($argsObj->updateMainPage);
    $guiObj->tcasePrefix = '';
    $guiObj->tplanCount = 0;
    $guiObj->tprojectSet = $tprojectMgr->get_accessible_for_user($userObj->dbID);
    $guiObj->tprojectCount = sizeof($guiObj->tprojectSet);
    // -----------------------------------------------------------------------------------------------------
    // Important Logic
    // -----------------------------------------------------------------------------------------------------
    // only when the user has changed test project using the combo in NavBar.tpl this key is present
    // Use this clue to launch a refresh of other frames present on the screen
    // using the onload HTML body attribute
    $argsObj->tprojectIDNavBar = intval($argsObj->tprojectIDNavBar);
    $argsObj->tproject_id = intval($argsObj->tproject_id);
    $guiObj->updateMainPage = $argsObj->updateMainPage;
    if ($guiObj->updateMainPage == 0 && $argsObj->runUpdateLogic) {
        $guiObj->updateMainPage = $argsObj->tprojectIDNavBar > 0 ? 1 : 0;
        if ($argsObj->tprojectIDNavBar == 0 && $argsObj->tproject_id == 0) {
            // we have this situation when doing refresh on browser with something similar
            // http://localhost:8080/development/gitrepo/tlcode/index.php
            // on browser URL
            $guiObj->updateMainPage = 1;
        }
    }
    $argsObj->tproject_id = $argsObj->tproject_id > 0 ? $argsObj->tproject_id : $argsObj->tprojectIDNavBar;
    if ($argsObj->tproject_id == 0) {
        $argsObj->tproject_id = key($guiObj->tprojectSet);
    }
    $guiObj->tprojectID = $argsObj->tproject_id;
    $guiObj->tprojectOptions = null;
    $guiObj->tprojectTopMenu = null;
    if ($guiObj->tprojectID > 0) {
        $dummy = $tprojectMgr->get_by_id($guiObj->tprojectID);
        $guiObj->tprojectOptions = $dummy['opt'];
        if ($guiObj->updateMainPage) {
            setcookie('TL_lastTestProjectForUserID_' . $userObj->dbID, $guiObj->tprojectID, TL_COOKIE_KEEPTIME, '/');
        }
    }
    // -----------------------------------------------------------------------------------------------------
    $argsObj->tplan_id = intval($argsObj->tplan_id);
    $argsObj->tplan_id = $argsObj->tplan_id > 0 ? $argsObj->tplan_id : intval($argsObj->testplan);
    $guiObj->tplanID = $argsObj->tplan_id;
    // Julian: left magic here - do think this value will never be used as a project with a prefix
    //         has to be created after first login -> searchSize should be set dynamically.
    //         If any reviewer agrees on that feel free to change it.
    $guiObj->searchSize = 8;
    $reqMgmtEnabled = 0;
    if ($guiObj->tprojectID > 0) {
        $dummy = $tprojectMgr->get_by_id($guiObj->tprojectID);
        $reqMgmtEnabled = $dummy['opt']->requirementsEnabled;
        $guiObj->tcasePrefix = $dummy['prefix'] . config_get('testcase_cfg')->glue_character;
        $guiObj->searchSize = tlStringLen($guiObj->tcasePrefix) + $cfg->dynamic_quick_tcase_search_input_size;
        $guiObj->tplanSet = $userObj->getAccessibleTestPlans($dbHandler, $guiObj->tprojectID);
        $guiObj->tplanCount = sizeof($guiObj->tplanSet);
        if ($guiObj->tplanID == 0) {
            $guiObj->tplanID = $guiObj->tplanSet[0]['id'];
            $guiObj->tplanSet[0]['selected'] = 1;
        }
    }
    $guiObj->topMenu = initTopMenu($dbHandler, $userObj, $guiObj->tprojectID, $guiObj->tplanID, $reqMgmtEnabled);
    return array($argsObj, $guiObj);
}
Exemplo n.º 25
0
 * 	20050905 - fm - reduce global coupling
 *  20070101 - KL - upgraded to 1.7
 * 	20080626 - mht - added milestomes, priority report, refactorization
 * 
 * ----------------------------------------------------------------------------------- */
require '../../config.inc.php';
require_once 'common.php';
require_once 'results.class.php';
require_once 'displayMgr.php';
testlinkInitPage($db, true, false, "checkRights");
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$templateCfg = templateConfiguration();
$args = init_args();
$tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
$tproject_info = $tproject_mgr->get_by_id($args->tproject_id);
$arrDataSuite = array();
$gui = new stdClass();
$gui->title = lang_get('title_gen_test_rep');
$gui->do_report = array();
$gui->showPlatforms = true;
$gui->columnsDefinition = new stdClass();
$gui->columnsDefinition->keywords = null;
$gui->columnsDefinition->testers = null;
$gui->columnsDefinition->platform = null;
$gui->statistics = new stdClass();
$gui->statistics->keywords = null;
$gui->statistics->testers = null;
$gui->statistics->milestones = null;
$gui->tplan_name = $tplan_info['name'];
$gui->tproject_name = $tproject_info['name'];
Exemplo n.º 26
0
/**
 * 
 *
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $iParams = array("edit" => array(tlInputParameter::STRING_N, 0, 50), "id" => array(tlInputParameter::INT_N), "tcase_id" => array(tlInputParameter::INT_N), "tcversion_id" => array(tlInputParameter::INT_N), "targetTestCase" => array(tlInputParameter::STRING_N, 0, 24), "show_path" => array(tlInputParameter::INT_N), "show_mode" => array(tlInputParameter::STRING_N, 0, 50), "tcasePrefix" => array(tlInputParameter::STRING_N, 0, 16), "tcaseExternalID" => array(tlInputParameter::STRING_N, 0, 16), "tcaseVersionNumber" => array(tlInputParameter::INT_N), "add_relation_feedback_msg" => array(tlInputParameter::STRING_N, 0, 255), "caller" => array(tlInputParameter::STRING_N, 0, 10));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $tprojectMgr = new testproject($dbHandler);
    $cfg = config_get('testcase_cfg');
    $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    $args->user_id = isset($_SESSION['userID']) ? $_SESSION['userID'] : 0;
    $args->feature = $args->edit;
    $args->tcaseTestProject = null;
    $args->viewerArgs = null;
    $args->automationEnabled = 0;
    $args->requirementsEnabled = 0;
    $args->testPriorityEnabled = 0;
    $args->tcasePrefix = trim($args->tcasePrefix);
    $args->form_token = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0;
    // For more information about the data accessed in session here, see the comment
    // in the file header of lib/functions/tlTestCaseFilterControl.class.php.
    $args->refreshTree = getSettingFromFormNameSpace('edit_mode', 'setting_refresh_tree_on_action');
    // Try to understan how this script was called.
    switch ($args->caller) {
        case 'navBar':
            systemWideTestCaseSearch($dbHandler, $args, $cfg->glue_character);
            break;
        case 'openTCW':
            // all data come in
            // tcaseExternalID   DOM-22
            // tcaseVersionNumber  1
            $args->targetTestCase = $args->tcaseExternalID;
            // trick for systemWideTestCaseSearch
            systemWideTestCaseSearch($dbHandler, $args, $cfg->glue_character);
            break;
        default:
            if (!$args->tcversion_id) {
                $args->tcversion_id = testcase::ALL_VERSIONS;
            }
            break;
    }
    // used to manage goback
    if (intval($args->tcase_id) > 0) {
        $args->feature = 'testcase';
        $args->id = intval($args->tcase_id);
    }
    switch ($args->feature) {
        case 'testsuite':
            $args->viewerArgs = null;
            $_SESSION['setting_refresh_tree_on_action'] = $args->refreshTree ? 1 : 0;
            break;
        case 'testcase':
            $args->viewerArgs = array('action' => '', 'msg_result' => '', 'user_feedback' => '', 'disable_edit' => 0, 'refreshTree' => 0, 'add_relation_feedback_msg' => $args->add_relation_feedback_msg);
            $args->id = is_null($args->id) ? 0 : $args->id;
            $args->tcase_id = $args->id;
            if (is_null($args->tcaseTestProject) && $args->id > 0) {
                $args->tcaseTestProject = $tprojectMgr->getByChildID($args->id);
            }
            break;
    }
    if (is_null($args->tcaseTestProject)) {
        $args->tcaseTestProject = $tprojectMgr->get_by_id($args->tproject_id);
    }
    $args->requirementsEnabled = $args->tcaseTestProject['opt']->requirementsEnabled;
    $args->automationEnabled = $args->tcaseTestProject['opt']->automationEnabled;
    $args->testPriorityEnabled = $args->tcaseTestProject['opt']->testPriorityEnabled;
    return $args;
}
Exemplo n.º 27
0
 /**
  * get relations for a given requirement ID
  * 
  * @author Andreas Simon
  * 
  * @param int $id Requirement ID
  * 
  * @return array $relations in which this req is either source or destination
  */
 public function get_relations($id)
 {
     $debugMsg = '/* Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__ . ' */';
     $relations = array();
     $relations['num_relations'] = 0;
     $relations['req'] = current($this->get_by_id($id));
     $relations['relations'] = array();
     $tproject_mgr = new testproject($this->db);
     $interproject_linking = config_get('req_cfg')->relations->interproject_linking;
     $sql = " {$debugMsg} SELECT id, source_id, destination_id, relation_type, author_id, creation_ts " . " FROM {$this->tables['req_relations']} " . " WHERE source_id={$id} OR destination_id={$id} " . " ORDER BY id ASC ";
     $relations['relations'] = $this->db->get_recordset($sql);
     if (!is_null($relations['relations']) && count($relations['relations']) > 0) {
         $labels = $this->get_all_relation_labels();
         $label_keys = array_keys($labels);
         foreach ($relations['relations'] as $key => $rel) {
             // is this relation type is configured?
             if ($relTypeAllowed = in_array($rel['relation_type'], $label_keys)) {
                 $relations['relations'][$key]['source_localized'] = $labels[$rel['relation_type']]['source'];
                 $relations['relations'][$key]['destination_localized'] = $labels[$rel['relation_type']]['destination'];
                 if ($id == $rel['source_id']) {
                     $type_localized = 'source_localized';
                     $other_key = 'destination_id';
                 } else {
                     $type_localized = 'destination_localized';
                     $other_key = 'source_id';
                 }
                 $relations['relations'][$key]['type_localized'] = $relations['relations'][$key][$type_localized];
                 $other_req = $this->get_by_id($rel[$other_key]);
                 // only add it, if either interproject linking is on or if it is in the same project
                 $relTypeAllowed = false;
                 if ($interproject_linking || $other_req[0]['testproject_id'] == $relations['req']['testproject_id']) {
                     $relTypeAllowed = true;
                     $relations['relations'][$key]['related_req'] = $other_req[0];
                     $other_tproject = $tproject_mgr->get_by_id($other_req[0]['testproject_id']);
                     $relations['relations'][$key]['related_req']['testproject_name'] = $other_tproject['name'];
                     $user = tlUser::getByID($this->db, $rel['author_id']);
                     $relations['relations'][$key]['author'] = $user->getDisplayName();
                 }
             }
             if (!$relTypeAllowed) {
                 unset($relations['relations'][$key]);
             }
         }
         // end foreach
         $relations['num_relations'] = count($relations['relations']);
     }
     return $relations;
 }
Exemplo n.º 28
0
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr, &$tcaseMgr)
{
    $tcase_cfg = config_get('testcase_cfg');
    $title_separator = config_get('gui_title_separator_1');
    $gui = new stdClass();
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->testCasePrefix = $tcaseMgr->tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->testCasePrefix .= $tcase_cfg->glue_character;
    $gui->can_remove_executed_testcases = $argsObj->user->hasRight($dbHandler, "testplan_unlink_executed_testcases", $argsObj->tproject_id);
    $gui->can_remove_executed_testcases = $gui->can_remove_executed_testcases == 'yes';
    $tprojectInfo = $tcaseMgr->tproject_mgr->get_by_id($argsObj->tproject_id);
    $gui->priorityEnabled = $tprojectInfo['opt']->testPriorityEnabled;
    $gui->keywordsFilterType = $argsObj->keywordsFilterType;
    $gui->keywords_filter = '';
    $gui->has_tc = 0;
    $gui->items = null;
    $gui->has_linked_items = false;
    $gui->keywordsFilterType = new stdClass();
    $gui->keywordsFilterType->options = array('OR' => 'Or', 'AND' => 'And');
    $gui->keywordsFilterType->selected = $argsObj->keywordsFilterType;
    // full_control, controls the operations planAddTC_m1.tpl will allow
    // 1 => add/remove
    // 0 => just remove
    $gui->full_control = 1;
    $tplan_info = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testPlanName = $tplan_info['name'];
    $gui->pageTitle = lang_get('test_plan') . $title_separator . $gui->testPlanName;
    $gui->refreshTree = $argsObj->refreshTree;
    $tproject_mgr = new testproject($dbHandler);
    $tproject_info = $tproject_mgr->get_by_id($argsObj->tproject_id);
    $userSet = $argsObj->user->getAll($dbHandler);
    $gui->testers = tlUser::getTestersForHtmlOptions($tplan_info, $tproject_info, $userSet);
    $gui->testerID = $argsObj->testerID;
    $gui->send_mail = $argsObj->send_mail;
    $gui->send_mail_checked = '';
    if ($gui->send_mail) {
        $gui->send_mail_checked = ' checked="checked" ';
    }
    $platform_mgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui->platforms = $platform_mgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->platformsForHtmlOptions = null;
    $gui->usePlatforms = $platform_mgr->platformsActiveForTestplan($argsObj->tplan_id);
    if ($gui->usePlatforms) {
        // Create options for two different select boxes. $bulk_platforms
        // has "All platforms" on top and "$platformsForHtmlOptions" has an
        // empty item
        $gui->platformsForHtmlOptions[0] = '';
        foreach ($gui->platforms as $elem) {
            $gui->platformsForHtmlOptions[$elem['id']] = $elem['name'];
        }
        $gui->bulk_platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
        $gui->bulk_platforms[0] = lang_get("all_platforms");
        ksort($gui->bulk_platforms);
    }
    //
    $gui->warning_msg = new stdClass();
    $gui->warning_msg->executed = lang_get('executed_can_not_be_removed');
    if ($gui->can_remove_executed_testcases) {
        $gui->warning_msg->executed = lang_get('has_been_executed');
    }
    // BUGID 3406
    $gui->build = init_build_selector($tplanMgr, $argsObj);
    return $gui;
}
Exemplo n.º 29
0
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr)
{
    $gui = new stdClass();
    $gui->title = lang_get('title_gen_test_rep');
    $gui->do_report = array();
    $gui->showPlatforms = true;
    $gui->columnsDefinition = new stdClass();
    $gui->columnsDefinition->keywords = null;
    $gui->columnsDefinition->testers = null;
    $gui->columnsDefinition->platform = null;
    $gui->statistics = new stdClass();
    $gui->statistics->keywords = null;
    $gui->statistics->testers = null;
    $gui->statistics->milestones = null;
    $gui->statistics->overalBuildStatus = null;
    $gui->elapsed_time = 0;
    $gui->displayBuildMetrics = false;
    $gui->buildMetricsFeedback = lang_get('buildMetricsFeedback');
    $mgr = new testproject($dbHandler);
    $dummy = $mgr->get_by_id($argsObj->tproject_id);
    $gui->testprojectOptions = new stdClass();
    $gui->testprojectOptions->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
    $gui->tproject_name = $dummy['name'];
    $info = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->tplan_name = $info['name'];
    $gui->platformSet = $tplanMgr->getPlatforms($argsObj->tplan_id, array('outputFormat' => 'map'));
    if (is_null($gui->platformSet)) {
        $gui->platformSet = array('');
        $gui->showPlatforms = false;
    }
    return $gui;
}
/**
 * init_args()
 * Get in an object all data that has arrived to page through _REQUEST or _SESSION.
 * If you think this page as a function, you can consider this data arguments (args)
 * to a function call.
 * Using all this data as one object property will help developer to understand
 * if data is received or produced on page.
 *
 * @author franciscom - francisco.mancardi@gmail.com
 * @args - used global coupling accessing $_REQUEST and $_SESSION
 * 
 * @return object of stdClass
 *
 * @internal revisions
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id == 0) {
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    if ($args->tproject_id == 0) {
        throw new Exception(__FILE__ . ' Can not work without Test project ID => Aborting');
    }
    $mgr = new testproject($dbHandler);
    $info = $mgr->get_by_id($args->tproject_id);
    $args->tproject_name = $info['name'];
    $args->testprojectOptions = $info['opt'];
    unset($info);
    $args->user_id = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : 0;
    if ($args->user_id != 0) {
        $args->user = new tlUser($args->user_id);
    } else {
        $args->user_id = isset($_SESSION['userID']) ? intval($_SESSION['userID']) : 0;
        if ($args->user_id == 0) {
            throw new Exception(__FILE__ . ' Can not work without User ID => Aborting');
        }
        $args->user = $_SESSION['currentUser'];
    }
    $args->executedBy = $args->user_id;
    $args->user_name = $args->user->login;
    $args->userSet = $args->user->getNames($dbHandler);
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    $args->build_id = isset($_REQUEST['build_id']) && is_numeric($_REQUEST['build_id']) ? intval($_REQUEST['build_id']) : 0;
    $args->show_inactive_tplans = isset($_REQUEST['show_inactive_tplans']) ? true : false;
    $args->show_all_users = false;
    if (isset($_REQUEST['show_all_users'])) {
        $args->show_all_users = intval($_REQUEST['show_all_users']) == 1;
    }
    $args->show_user_column = $args->show_all_users;
    $show_closed_builds = isset($_REQUEST['show_closed_builds']) ? true : false;
    $show_closed_builds_hidden = isset($_REQUEST['show_closed_builds_hidden']) ? true : false;
    if ($show_closed_builds) {
        $selection = true;
    } else {
        if ($show_closed_builds_hidden) {
            $selection = false;
        } else {
            if (isset($_SESSION['show_closed_builds'])) {
                $selection = intval($_SESSION['show_closed_builds']);
            } else {
                $selection = false;
            }
        }
    }
    $args->show_closed_builds = $_SESSION['show_closed_builds'] = $selection;
    if ($args->show_all_users) {
        $args->user_id = TL_USER_ANYBODY;
    }
    $args->show_inactive_and_closed = false;
    if (isset($_REQUEST['show_inactive_and_closed'])) {
        $args->show_inactive_and_closed = intval($_REQUEST['show_inactive_and_closed']) != 0;
    }
    $args->priority_enabled = $_SESSION['testprojectOptions']->testPriorityEnabled ? true : false;
    // quick & dirty execution
    $args->tpx = isset($_REQUEST['tpx']) ? intval($_REQUEST['tpx']) : 0;
    $dirtyHarry = array('pxi', 'bxi', 'tcvx');
    foreach ($dirtyHarry as $tg) {
        $key = $tg . '_' . $args->tpx;
        $args->{$tg} = isset($_REQUEST[$key]) ? intval($_REQUEST[$key]) : 0;
    }
    $args->result = isset($_REQUEST['result_' . $args->tpx]) ? $_REQUEST['result_' . $args->tpx][0] : '';
    return $args;
}