Ejemplo n.º 1
0
function init_args(&$dbHandler, $cfgObj)
{
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    // Settings and Filters that we put on session to create some
    // sort of persistent scope, because we have had issues when passing this info
    // using GET mode (size limits)
    //
    // we get info about build_id, platform_id, etc ...
    getSettingsAndFilters($args);
    manageCookies($args, $cfgObj);
    // need to comunicate with left frame, will do via $_SESSION and form_token
    if (($args->treeFormToken = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0) > 0) {
        // do not understand why this do not works OK
        // $_SESSION[$args->treeFormToken]['loadExecDashboard'] = false;
        $_SESSION['loadExecDashboard'][$args->treeFormToken] = false;
    }
    if (is_null($args->refreshTree)) {
        $args->refreshTree = isset($_REQUEST['refresh_tree']) ? intval($_REQUEST['refresh_tree']) : 0;
    }
    $args->tc_id = null;
    $args->tsuite_id = null;
    $args->user = $_SESSION['currentUser'];
    $args->user_id = $args->user->dbID;
    $args->id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $args->caller = isset($_REQUEST['caller']) ? $_REQUEST['caller'] : 'exec_feature';
    $args->reload_caller = false;
    $args->doExec = isset($_REQUEST['execute_cases']) ? 1 : 0;
    $args->doDelete = isset($_REQUEST['do_delete']) ? $_REQUEST['do_delete'] : 0;
    $args->doMoveNext = isset($_REQUEST['move2next']) ? $_REQUEST['move2next'] : 0;
    $args->doMovePrevious = isset($_REQUEST['move2previous']) ? $_REQUEST['move2previous'] : 0;
    $args->moveTowards = $args->doMoveNext ? 'forward' : ($args->doMovePrevious ? 'backward' : null);
    // can be a list, will arrive via form POST
    $args->tc_versions = isset($_REQUEST['tc_version']) ? $_REQUEST['tc_version'] : null;
    $key2loop = array('level' => '', 'status' => null, 'do_bulk_save' => 0, 'save_results' => 0, 'save_and_next' => 0, 'save_and_exit' => 0);
    foreach ($key2loop as $key => $value) {
        $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : $value;
    }
    // See details on: "When nullify filter_status - 20080504" in this file
    if ($args->level == 'testcase' || is_null($args->filter_status) || !is_array($args->filter_status) && trim($args->filter_status) == '') {
        $args->filter_status = null;
    } else {
        // 20130306 - franciscom
        // This (without the strlen() check) generated issue 5541: When "Result" filter is used ...
        // at least when result DIFFERENT that NOT RUN is used on filter
        //
        // 20120616 - franciscom
        // some strange thing to investigate, seems that userialize is invoked
        // under the hood when getting data from $_REQUEST, then this piece
        // of code not only will be useless BUT WRONG, because will try
        // to unserialize something that IS NOT SERIALIZED!!!!
        if (is_string($args->filter_status) && strlen($args->filter_status) > 1) {
            $args->filter_status = unserialize($args->filter_status);
        }
    }
    switch ($args->level) {
        case 'testcase':
            $args->tc_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
            if (!is_null($args->tc_versions)) {
                $args->tc_id = current($args->tc_versions);
                $args->id = $args->tc_id;
                $args->version_id = key($args->tc_versions);
            }
            $args->tsuite_id = null;
            break;
        case 'testsuite':
            $args->tsuite_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
            $args->tc_id = null;
            break;
    }
    $args->tsuitesInBranch = null;
    if (!is_null($args->tsuite_id)) {
        // will get all test suites in this branch, in order to limit amount of data returned
        // by functions/method that collect linked tcversions
        // THIS COLLECT ONLY FIRST LEVEL UNDER test suite, do not do deep search
        // Need to understand is still needed
        $tsuite_mgr = new testsuite($dbHandler);
        $xx = $tsuite_mgr->get_children($args->tsuite_id, array('details' => 'id'));
        $ldx = count($xx);
        $xx[$ldx] = $args->tsuite_id;
        $args->tsuitesInBranch = $xx;
        unset($tsuite_mgr);
    }
    // TICKET 5630: Test Results by direct link ...
    $args->tplan_id = intval(isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : $_SESSION['testplanID']);
    $args->tproject_id = intval(isset($_REQUEST['tproject_id']) ? $_REQUEST['tproject_id'] : $_SESSION['testprojectID']);
    if ($args->tproject_id <= 0) {
        $tree_mgr = new tree($dbHandler);
        $dm = $tree_mgr->get_node_hierarchy_info($args->tplan_id);
        $args->tproject_id = $dm['parent_id'];
    }
    return $args;
}
function init_args(&$dbHandler, $cfgObj)
{
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    // Settings and Filters that we put on session to create some
    // sort of persistent scope, because we have had issues when passing this info
    // using GET mode (size limits)
    //
    // we get info about build_id, platform_id, etc ...
    getSettingsAndFilters($args);
    manageCookies($args, $cfgObj);
    // need to comunicate with left frame, will do via $_SESSION and form_token
    if (($args->treeFormToken = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0) > 0) {
        // do not understand why this do not works OK
        // $_SESSION[$args->treeFormToken]['loadExecDashboard'] = false;
        $_SESSION['loadExecDashboard'][$args->treeFormToken] = false;
    }
    if (is_null($args->refreshTree)) {
        $args->refreshTree = isset($_REQUEST['refresh_tree']) ? intval($_REQUEST['refresh_tree']) : 0;
    }
    $args->assignTask = isset($_REQUEST['assignTask']) ? 1 : 0;
    $args->createIssue = isset($_REQUEST['createIssue']) ? 1 : 0;
    $args->copyIssues = isset($_REQUEST['copyIssues']) ? 1 : 0;
    $args->tc_id = null;
    $args->tsuite_id = null;
    $args->user = $_SESSION['currentUser'];
    $args->user_id = intval($args->user->dbID);
    $args->id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $args->caller = isset($_REQUEST['caller']) ? $_REQUEST['caller'] : 'exec_feature';
    $args->reload_caller = false;
    $args->doExec = isset($_REQUEST['execute_cases']) ? 1 : 0;
    $args->doDelete = isset($_REQUEST['do_delete']) ? $_REQUEST['do_delete'] : 0;
    $args->doMoveNext = isset($_REQUEST['move2next']) ? $_REQUEST['move2next'] : 0;
    $args->doMovePrevious = isset($_REQUEST['move2previous']) ? $_REQUEST['move2previous'] : 0;
    $args->moveTowards = $args->doMoveNext ? 'forward' : ($args->doMovePrevious ? 'backward' : null);
    // can be a list, will arrive via form POST
    $args->tc_versions = isset($_REQUEST['tc_version']) ? $_REQUEST['tc_version'] : null;
    $key2loop = array('level' => '', 'status' => null, 'statusSingle' => null, 'do_bulk_save' => 0, 'save_results' => 0, 'save_and_next' => 0, 'save_and_exit' => 0);
    foreach ($key2loop as $key => $value) {
        $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : $value;
    }
    // See details on: "When nullify filter_status - 20080504" in this file
    if ($args->level == 'testcase' || is_null($args->filter_status) || !is_array($args->filter_status) && trim($args->filter_status) == '') {
        $args->filter_status = null;
    } else {
        // 20130306 - franciscom
        // This (without the strlen() check) generated issue 5541: When "Result" filter is used ...
        // at least when result DIFFERENT that NOT RUN is used on filter
        //
        // 20120616 - franciscom
        // some strange thing to investigate, seems that unserialize is invoked
        // under the hood when getting data from $_REQUEST, then this piece
        // of code not only will be useless BUT WRONG, because will try
        // to unserialize something that IS NOT SERIALIZED!!!!
        // After TICKET 6651, may be need to limit size of $args->filter_status
        if (is_string($args->filter_status) && strlen($args->filter_status) > 1) {
            $args->filter_status = json_decode($args->filter_status);
        }
    }
    switch ($args->level) {
        case 'testcase':
            $args->tc_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
            if (!is_null($args->tc_versions)) {
                $args->tc_id = current($args->tc_versions);
                $args->id = $args->tc_id;
                $args->version_id = key($args->tc_versions);
            }
            $args->tsuite_id = null;
            break;
        case 'testsuite':
            $args->tsuite_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
            $args->tc_id = null;
            break;
    }
    $args->tsuitesInBranch = null;
    if (!is_null($args->tsuite_id)) {
        // will get all test suites in this branch, in order to limit amount of data returned
        // by functions/method that collect linked tcversions
        // THIS COLLECT ONLY FIRST LEVEL UNDER test suite, do not do deep search
        // Need to understand is still needed
        $tsuite_mgr = new testsuite($dbHandler);
        $xx = $tsuite_mgr->get_children($args->tsuite_id, array('details' => 'id'));
        $ldx = count($xx);
        $xx[$ldx] = $args->tsuite_id;
        $args->tsuitesInBranch = $xx;
        unset($tsuite_mgr);
    }
    // TICKET 5630: Test Results by direct link ...
    $args->tplan_id = intval(isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : $_SESSION['testplanID']);
    $args->tproject_id = intval(isset($_REQUEST['tproject_id']) ? $_REQUEST['tproject_id'] : $_SESSION['testprojectID']);
    if ($args->tproject_id <= 0) {
        $tree_mgr = new tree($dbHandler);
        $dm = $tree_mgr->get_node_hierarchy_info($args->tplan_id);
        $args->tproject_id = $dm['parent_id'];
    }
    // Do this only on single execution mode
    // get issue tracker config and object to manage TestLink - BTS integration
    $args->itsCfg = null;
    $its = null;
    $tproject_mgr = new testproject($dbHandler);
    $info = $tproject_mgr->get_by_id($args->tproject_id);
    unset($tproject_mgr);
    $bug_summary['minLengh'] = 1;
    $bug_summary['maxLengh'] = 1;
    if ($args->issue_tracker_enabled = $info['issue_tracker_enabled']) {
        $it_mgr = new tlIssueTracker($dbHandler);
        $its = $it_mgr->getInterfaceObject($args->tproject_id);
        $bug_summary['maxLengh'] = $its->getBugSummaryMaxLength();
        $args->itsCfg = $it_mgr->getLinkedTo($args->tproject_id);
        unset($it_mgr);
    }
    $inputCfg = array("bug_notes" => array("POST", tlInputParameter::STRING_N), "issueType" => array("POST", tlInputParameter::INT_N), "issuePriority" => array("POST", tlInputParameter::INT_N), "artifactComponent" => array("POST", tlInputParameter::ARRAY_INT), "artifactVersion" => array("POST", tlInputParameter::ARRAY_INT));
    $inputCfg["bug_summary"] = array("POST", tlInputParameter::STRING_N);
    if (!$args->do_bulk_save) {
        $inputCfg["bug_summary"][2] = $bug_summary['minLengh'];
        $inputCfg["bug_summary"][3] = $bug_summary['maxLengh'];
    }
    I_PARAMS($inputCfg, $args);
    $args->basehref = $_SESSION['basehref'];
    return array($args, $its);
}