function initEnv(&$dbHandler) { testlinkInitPage($dbHandler); $argsObj = init_args(); $guiObj = init_gui($dbHandler, $argsObj); return array($argsObj, $guiObj); }
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; }
/** * * */ function initEnv(&$dbHandler) { testlinkInitPage($dbHandler); $argsObj = init_args(); checkPageAccess($dbHandler, $argsObj); // Will exit if check failed $guiObj = init_gui($dbHandler, $argsObj); return array($argsObj, $guiObj); }
/** * 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); }
<?php /** * TestLink Open Source Project - http://testlink.sourceforge.net/ * * @filesource navBar.php * * This file manages the navigation bar. * * internal revisions * **/ require_once '../../config.inc.php'; require_once "common.php"; testlinkInitPage($db, 'initProject' == 'initProject'); $tproject_mgr = new testproject($db); $args = init_args(); $gui = new stdClass(); $gui_cfg = config_get("gui"); $gui->tprojectID = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0; $gui->tcasePrefix = ''; $gui->searchSize = 8; if ($gui->tprojectID > 0) { $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($gui->tprojectID) . config_get('testcase_cfg')->glue_character; $gui->searchSize = tlStringLen($gui->tcasePrefix) + $gui_cfg->dynamic_quick_tcase_search_input_size; } $gui->TestProjects = $tproject_mgr->get_accessible_for_user($args->user->dbID, array('output' => 'map_name_with_inactive_mark', 'order_by' => $tlCfg->gui->tprojects_combo_order_by)); $gui->TestProjectCount = sizeof($gui->TestProjects); $gui->TestPlanCount = 0; $tprojectQty = $tproject_mgr->getItemCount(); if ($gui->TestProjectCount == 0 && $tprojectQty > 0) {
* @author Francisco Mancardi * @copyright 2015, TestLink community * @link http://www.testlink.org/ * * @internal revisions * @since 1.9.15 */ // use output buffer to prevent headers/data from being sent before // cookies are set, else it will fail ob_start(); // some session and settings stuff from original index.php require_once 'lib/functions/configCheck.php'; checkConfiguration(); require_once 'config.inc.php'; require_once 'common.php'; testlinkInitPage($db, true); $smarty = new TLSmarty(); // This process seems to have two steps // // Step 1 // Display outer frame, and do a new call // to display the wished content, in inner frame // // Step 2 // Here we will get what we need // // display outer or inner frame? // why I'm asking this question? // if (!isset($_GET['load'])) { // display outer frame, pass parameters to next script call for inner frame
/** * 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; }
* This script is distributed under the GNU General Public License 2 or later. * * Downloads the attachment by a given id * * @filesource attachmentdownload.php * * @internal revisions * @since 1.9.13 * */ @ob_end_clean(); require_once '../../config.inc.php'; require_once '../functions/common.php'; require_once '../functions/attachments.inc.php'; // This way can be called without _SESSION, this is useful for reports testlinkInitPage($db, false, true); $args = init_args(); if ($args->id) { $attachmentRepository = tlAttachmentRepository::create($db); $attachmentInfo = $attachmentRepository->getAttachmentInfo($args->id); // if ($attachmentInfo) if ($attachmentInfo && ($args->skipCheck || checkAttachmentID($db, $args->id, $attachmentInfo))) { $content = $attachmentRepository->getAttachmentContent($args->id, $attachmentInfo); if ($content != "") { @ob_end_clean(); header('Pragma: public'); header("Cache-Control: "); if (!(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" && preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"]))) { header('Pragma: no-cache'); } header('Content-Type: ' . $attachmentInfo['file_type']);
/** * 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); }
* * This file is the first page that the user sees when they log in. * Most of the code in it is html but there is some logic that displays * based upon the login. * There is also some javascript that handles the form information. * * @internal revisions * @since 1.9.10 * **/ require_once '../../config.inc.php'; require_once 'common.php'; if (function_exists('memory_get_usage') && function_exists('memory_get_peak_usage')) { tlog("mainPage.php: Memory after common.php> Usage: " . memory_get_usage(), 'DEBUG'); } testlinkInitPage($db, TRUE); $smarty = new TLSmarty(); $tproject_mgr = new testproject($db); $user = $_SESSION['currentUser']; $testprojectID = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0; $testplanID = isset($_SESSION['testplanID']) ? intval($_SESSION['testplanID']) : 0; $accessibleItems = $tproject_mgr->get_accessible_for_user($user->dbID, array('output' => 'map_name_with_inactive_mark')); $tprojectQty = $tproject_mgr->getItemCount(); $userIsBlindFolded = (is_null($accessibleItems) || count($accessibleItems) == 0) && $tprojectQty > 0; if ($userIsBlindFolded) { $testprojectID = $testplanID = 0; $_SESSION['testprojectTopMenu'] = ''; } $tplan2check = null; $currentUser = $_SESSION['currentUser']; $userID = $currentUser->dbID;
/** * * */ 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; }
/** * * */ 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); }
* Checks if a test case with this name already exist. Used to warn user * if non-unique test case name is entered. * * @package TestLink * @author Erik Eloff * @copyright 2010, TestLink community * @version CVS: $Id: checkTCaseDuplicateName.php,v 1.3 2010/10/10 13:41:13 franciscom Exp $ * * @internal Revisions: * 20101010 - franciscom - added testsuite_id as parameter, needed to do checks when creating test case * 20100225 - eloff - initial commit * **/ require_once '../../config.inc.php'; require_once 'common.php'; testlinkInitPage($db); $data = array('success' => true, 'message' => ''); $iParams = array("name" => array(tlInputParameter::STRING_N, 0, 100), "testcase_id" => array(tlInputParameter::INT), "testsuite_id" => array(tlInputParameter::INT)); $args = G_PARAMS($iParams); if (has_rights($db, 'mgt_view_tc')) { $tree_manager = new tree($db); $node_types_descr_id = $tree_manager->get_available_node_types(); // To allow name check when creating a NEW test case => we do not have test case id $args['testcase_id'] = $args['testcase_id'] > 0 ? $args['testcase_id'] : null; $args['testsuite_id'] = $args['testsuite_id'] > 0 ? $args['testsuite_id'] : null; // for debug - // $xx = "\$args['testcase_id']:{$args['testcase_id']} - \$args['name']:{$args['name']}" . // " - \$args['testsuite_id']:{$args['testsuite_id']}"; // file_put_contents('c:\checkTCaseDuplicateName.php.ajax', $xx); $check = $tree_manager->nodeNameExists($args['name'], $node_types_descr_id['testcase'], $args['testcase_id'], $args['testsuite_id']); $data['success'] = !$check['status'];
* * @filesource projectEdit.php * @package TestLink * @copyright 2007-2015, TestLink community * @link http://www.testlink.org * * @internal revisions * @since 1.9.14 * */ require_once '../../config.inc.php'; require_once 'common.php'; require_once "web_editor.php"; $editorCfg = getWebEditorCfg('testproject'); require_once require_web_editor($editorCfg['type']); testlinkInitPage($db, true, false, "checkRights"); $gui_cfg = config_get('gui'); $templateCfg = templateConfiguration(); $session_tproject_id = intval(isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0); $template = null; $ui = new stdClass(); $ui->doActionValue = ''; $ui->buttonValue = ''; $ui->caption = ''; $ui->main_descr = lang_get('title_testproject_management'); $user_feedback = ''; $reloadType = 'none'; // domain 'none','reloadNavBar' $tproject_mgr = new testproject($db); $args = init_args($tproject_mgr, $_REQUEST, $session_tproject_id); $gui = initializeGui($db, $args);
/** * filter testcases by the result of their latest execution * * @param object &$db reference to database handler * @param object &$tplan_mgr reference to test plan manager object * @param array &$tcase_set reference to test case set to filter * @param integer $tplan_id ID of test plan * @param array $filters filters to apply to test case set * @return array new tcase_set */ function filter_by_status_for_last_execution(&$tplan_mgr, &$tcase_set, $tplan_id, $filters) { testlinkInitPage($db); //BUGID 3806 $tables = tlObject::getDBTables('executions'); $result_key = 'filter_result_result'; // need to check if result is array because multiple can be selected in advanced filter mode $in_status = is_array($filters->{$result_key}) ? implode("','", $filters->{$result_key}) : $filters->{$result_key}; foreach ($tcase_set as $tc_id => $tc_info) { // get last execution result for each testcase, // if it differs from the result in tcase_set the tcase will be deleted from set $sql = " SELECT status FROM {$tables['executions']} E " . " WHERE tcversion_id = {$tc_info['tcversion_id']} AND testplan_id = {$tplan_id} " . " AND platform_id = {$tc_info['platform_id']} " . " AND status = '{$tc_info['exec_status']}' " . " AND status IN ('{$in_status}') " . " ORDER BY execution_ts DESC "; $result = null; // BUGID 3772: MS SQL - LIMIT CLAUSE can not be used $result = $db->fetchArrayRowsIntoMap($sql, 'status', 1); if (is_null($result)) { unset($tcase_set[$tc_id]); } } return $tcase_set; }