コード例 #1
0
ファイル: dcnTopN.php プロジェクト: mokal/DCN_TestLink
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;
}
コード例 #2
0
/**
 * 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);
}
コード例 #3
0
ファイル: lnl.php プロジェクト: mokal/DCN_TestLink
/**
 *
 */
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;
}
コード例 #4
0
ファイル: printDocument.php プロジェクト: JacekKarwas/smutek
/** 
 * 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);
}
コード例 #5
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;
}
コード例 #6
0
/**
 *
 */
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;
}
コード例 #7
0
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);
}
コード例 #8
0
/**
 * 
 *
 */
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;
}
コード例 #9
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;
}