Ejemplo n.º 1
0
function init_args(&$dbHandler)
{
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 64), "tproject_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;
        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);
        }
    } else {
        testlinkInitPage($dbHandler, true, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    if ($args->tproject_id <= 0) {
        $msg = __FILE__ . '::' . __FUNCTION__ . " :: Invalid Test Project ID ({$args->tproject_id})";
        throw new Exception($msg);
    }
    if (is_null($args->format)) {
        tlog("Parameter 'format' is not defined", 'ERROR');
        exit;
    }
    $args->user = $_SESSION['currentUser'];
    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);
}
/**
 * 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;
}
Ejemplo n.º 4
0
/**
 *
 */
function init_args()
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    try {
        // ATTENTION - give a look to $tlCfg->reports_list
        $typeSize = 30;
        $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "level" => array(tlInputParameter::STRING_N, 0, 16), "type" => array(tlInputParameter::STRING_N, 0, $typeSize));
    } catch (Exception $e) {
        echo $e->getMessage();
        exit;
    }
    R_PARAMS($iParams, $args);
    $args->light = 'red';
    $opt = array('setPaths' => true, 'clearSession' => true);
    if (strlen($args->apikey) == 32) {
        setUpEnvForRemoteAccess($dbHandler, $args->apikey, null, $opt);
        $user = tlUser::getByAPIKey($dbHandler, $args->apikey);
        $args->light = count($user) == 1 ? 'green' : 'red';
    } else {
        $kerberos = new stdClass();
        $kerberos->args = $args;
        $kerberos->method = null;
        if (setUpEnvForAnonymousAccess($dbHandler, $args->apikey, $kerberos, $opt)) {
            $args->light = 'green';
        }
    }
    return $args;
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
/**
 * 
 *
 */
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), "do_action" => array(tlInputParameter::STRING_N, 5, 10), "build_set" => array(tlInputParameter::ARRAY_INT), "buildListForExcel" => array(tlInputParameter::STRING_N, 0, 100), "format" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $args->addOpAccess = true;
    if (!is_null($args->apikey)) {
        //var_dump($args);
        $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);
        }
    } else {
        testlinkInitPage($dbHandler, false, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    if ($args->tproject_id <= 0) {
        $msg = __FILE__ . '::' . __FUNCTION__ . " :: Invalid Test Project ID ({$args->tproject_id})";
        throw new Exception($msg);
    }
    switch ($args->format) {
        case FORMAT_XLS:
            if ($args->buildListForExcel != '') {
                $args->build_set = explode(',', $args->buildListForExcel);
            }
            break;
    }
    $args->user = $_SESSION['currentUser'];
    $args->basehref = $_SESSION['basehref'];
    return $args;
}
/**
 *
 */
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));
    $args = new stdClass();
    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;
    }
    if (isset($_REQUEST['debug'])) {
        $args->debug = 'yes';
    }
    return $args;
}
function initEnv(&$dbHandler)
{
    $args = new stdClass();
    $gui = new stdClass();
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "show_only_active" => array(tlInputParameter::CB_BOOL), "show_only_active_hidden" => array(tlInputParameter::CB_BOOL));
    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 = $args->tplan_id;
        $cerbero->args->getAccessAttr = true;
        $cerbero->method = 'checkRights';
        $cerbero->redirect_target = "../../login.php?note=logout";
        if (strlen($args->apikey) == 32) {
            setUpEnvForRemoteAccess($dbHandler, $args->apikey, $cerbero);
        } else {
            setUpEnvForAnonymousAccess($dbHandler, $args->apikey, $cerbero);
        }
    } else {
        testlinkInitPage($dbHandler, false, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    if ($args->tproject_id <= 0) {
        $msg = __FILE__ . '::' . __FUNCTION__ . " :: Invalid Test Project ID ({$args->tproject_id})";
        throw new Exception($msg);
    }
    $mgr = new tree($dbHandler);
    $dummy = $mgr->get_node_hierarchy_info($args->tproject_id);
    $args->tproject_name = $dummy['name'];
    $args->user = $_SESSION['currentUser'];
    $args->currentUserID = $args->user->dbID;
    // I'm sorry for MAGIC
    $args->direct_link_ok = true;
    if (strlen(trim($args->user->userApiKey)) == 32) {
        $args->direct_link = $_SESSION['basehref'] . "lnl.php?type=metricsdashboard&" . "apikey={$args->user->userApiKey}&tproject_id={$args->tproject_id}";
    } else {
        $args->direct_link_ok = false;
        $args->direct_link = lang_get('can_not_create_direct_link');
    }
    if ($args->show_only_active) {
        $selection = true;
    } else {
        if ($args->show_only_active_hidden) {
            $selection = false;
        } else {
            if (isset($_SESSION['show_only_active'])) {
                $selection = $_SESSION['show_only_active'];
            } else {
                $selection = true;
            }
        }
    }
    $args->show_only_active = $_SESSION['show_only_active'] = $selection;
    $gui->tproject_name = $args->tproject_name;
    $gui->show_only_active = $args->show_only_active;
    $gui->direct_link = $args->direct_link;
    $gui->direct_link_ok = $args->direct_link_ok;
    $gui->warning_msg = lang_get('no_testplans_available');
    return array($args, $gui);
}
/**
 * 
 *
 */
function init_args(&$dbHandler, $statusCode)
{
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "format" => array(tlInputParameter::INT_N), "type" => array(tlInputParameter::STRING_N, 0, 1));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $args->addOpAccess = true;
    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);
        }
    } else {
        testlinkInitPage($dbHandler, true, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    $args->user = $_SESSION['currentUser'];
    $args->basehref = $_SESSION['basehref'];
    return $args;
}
Ejemplo n.º 10
0
/**
 *
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    try {
        // ATTENTION - give a look to $tlCfg->reports_list
        // format domain: see reports.cfg.php FORMAT_*
        $typeSize = 30;
        $iParams = array("apikey" => array(tlInputParameter::STRING_N, 32, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "level" => array(tlInputParameter::STRING_N, 0, 16), "type" => array(tlInputParameter::STRING_N, 0, $typeSize), 'id' => array(tlInputParameter::INT_N), 'format' => array(tlInputParameter::STRING_N, 0, 1));
    } catch (Exception $e) {
        echo $e->getMessage();
        exit;
    }
    R_PARAMS($iParams, $args);
    // new dBug($args);
    $args->format = intval($args->format);
    $args->format = $args->format <= 0 ? FORMAT_HTML : $args->format;
    $args->envCheckMode = $args->type == 'file' ? 'hippie' : 'paranoic';
    $args->light = 'red';
    $opt = array('setPaths' => true, 'clearSession' => true);
    if (strlen($args->apikey) == 32) {
        $args->debug = 'USER-APIKEY';
        setUpEnvForRemoteAccess($dbHandler, $args->apikey, null, $opt);
        $user = tlUser::getByAPIKey($dbHandler, $args->apikey);
        $args->light = count($user) == 1 ? 'green' : 'red';
    } else {
        if ($args->type == 'exec') {
            $tex = DB_TABLE_PREFIX . 'executions';
            $sql = "SELECT testplan_id FROM {$tex} WHERE id=" . intval($args->id);
            $rs = $dbHandler->get_recordset($sql);
            if (is_null($rs)) {
                die;
            }
            $rs = $rs[0];
            $tpl = DB_TABLE_PREFIX . 'testplans';
            $sql = "SELECT api_key FROM {$tpl} WHERE id=" . intval($rs['testplan_id']);
            $rs = $dbHandler->get_recordset($sql);
            if (is_null($rs)) {
                die;
            }
            $rs = $rs[0];
            $args->apikey = $rs['api_key'];
            $args->envCheckMode = 'hippie';
        }
        $args->debug = 'OBJECT-APIKEY';
        $kerberos = new stdClass();
        $kerberos->args = $args;
        $kerberos->method = null;
        if (setUpEnvForAnonymousAccess($dbHandler, $args->apikey, $kerberos, $opt)) {
            $args->light = 'green';
        }
    }
    return $args;
}