Example #1
0
/**
 * set session data after modification or authorization
 *
 * @param resource &$db reference to DB identifier
 * @param string $user
 * @param integer $id
 * @param integer $roleID 
 * @param string $email 
 * @param string $locale [default = null]
 * @param boolean $active [default = null] documentation
 * 
 * @return integer status code
 * 
 * @TODO havlatm: move to tlSession class
 * @TODO fix return functionality
 **/
function setUserSession(&$db, $user, $id, $roleID, $email, $locale = null, $active = null)
{
    tLog('setUserSession: $user='******' $id=' . $id . ' $roleID=' . $roleID . ' $email=' . $email . ' $locale=' . $locale);
    $_SESSION['userID'] = $id;
    $_SESSION['testprojectID'] = null;
    $_SESSION['s_lastAttachmentList'] = null;
    if (!is_null($locale)) {
        $_SESSION['locale'] = $locale;
        set_dt_formats();
    }
    $tproject_mgr = new testproject($db);
    $gui_cfg = config_get('gui');
    $order_by = $gui_cfg->tprojects_combo_order_by;
    $arrProducts = $tproject_mgr->get_accessible_for_user($id, 'map', $order_by);
    // 20051208 - JBA - added to set the lastProduct the user has selected before logging off.
    $tproject_cookie = 'TL_lastTestProjectForUserID_' . $id;
    if (isset($_COOKIE[$tproject_cookie])) {
        if (isset($arrProducts[$_COOKIE[$tproject_cookie]]) && $arrProducts[$_COOKIE[$tproject_cookie]]) {
            $_SESSION['testprojectID'] = $_COOKIE[$tproject_cookie];
            tLog('Cookie: {$tproject_cookie}=' . $_SESSION['testprojectID']);
        }
    }
    if (!$_SESSION['testprojectID']) {
        $tpID = null;
        if (sizeof($arrProducts)) {
            $tpID = key($arrProducts);
        }
        $_SESSION['testprojectID'] = $tpID;
    }
    // Validation is done in navBar.php
    $tplan_cookie = 'TL_lastTestPlanForUserID_' . $id;
    if (isset($_COOKIE[$tplan_cookie])) {
        $_SESSION['testplanID'] = $_COOKIE[$tplan_cookie];
        tLog("Cookie: {$tplan_cookie}=" . $_SESSION['testplanID']);
    }
    return 1;
}
Example #2
0
/**
 * set session data after modification or authorization
 *
 * @param resource &$db reference to DB identifier
 * @param string $user
 * @param integer $id
 * @param integer $roleID 
 * @param string $email 
 * @param string $locale [default = null]
 * @param boolean $active [default = null] documentation
 * 
 * @return integer status code
 * 
 * @TODO havlatm: move to tlSession class
 * @TODO fix return functionality
 **/
function setUserSession(&$db, $user, $id, $roleID, $email, $locale = null, $active = null)
{
    tLog('setUserSession: $user='******' $id=' . $id . ' $roleID=' . $roleID . ' $email=' . $email . ' $locale=' . $locale);
    $_SESSION['userID'] = $id;
    $_SESSION['testprojectID'] = null;
    $_SESSION['s_lastAttachmentList'] = null;
    if (!is_null($locale)) {
        $_SESSION['locale'] = $locale;
        setDateTimeFormats($locale);
    }
    $tproject_mgr = new testproject($db);
    $gui_cfg = config_get('gui');
    $opt = array('output' => 'map_name_with_inactive_mark', 'order_by' => $gui_cfg->tprojects_combo_order_by);
    $arrProducts = $tproject_mgr->get_accessible_for_user($id, $opt);
    $tproject_cookie = 'TL_lastTestProjectForUserID_' . $id;
    if (isset($_COOKIE[$tproject_cookie])) {
        if (isset($arrProducts[$_COOKIE[$tproject_cookie]]) && $arrProducts[$_COOKIE[$tproject_cookie]]) {
            $_SESSION['testprojectID'] = $_COOKIE[$tproject_cookie];
            tLog('Cookie: {$tproject_cookie}=' . $_SESSION['testprojectID']);
        }
    }
    if (!$_SESSION['testprojectID']) {
        $tpID = null;
        if (sizeof($arrProducts)) {
            $tpID = key($arrProducts);
        }
        $_SESSION['testprojectID'] = $tpID;
    }
    // Validation is done in navBar.php
    $tplan_cookie = 'TL_lastTestPlanForUserID_' . $id;
    if (isset($_COOKIE[$tplan_cookie])) {
        $_SESSION['testplanID'] = $_COOKIE[$tplan_cookie];
        tLog("Cookie: {$tplan_cookie}=" . $_SESSION['testplanID']);
    }
    return 1;
}
Example #3
0
**/
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) {
    // User rights configurations does not allow access to ANY test project
    $_SESSION['testprojectTopMenu'] = '';
    $gui->tprojectID = 0;
}
if ($gui->tprojectID) {
    $testPlanSet = $args->user->getAccessibleTestPlans($db, $gui->tprojectID);
    $gui->TestPlanCount = sizeof($testPlanSet);
    $tplanID = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : null;
    if (!is_null($tplanID)) {
        // Need to set this info on session with first Test Plan from $testPlanSet
        // if this test plan is present on $testPlanSet
$item->color = '';
$item->options = new stdClass();
//$item->options->requirement_mgmt = 1;
//$item->options->priority_mgmt = 1;
//$item->options->automated_execution = 1;
$item->active = 1;
$item->is_public = 1;
$item->prefix = 'TPX :: ';
try {
    $id = $tproject_mgr->create($item, array('doChecks' => true));
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
die;
// new dBug($_SESSION);
$xx = $tproject_mgr->get_accessible_for_user(1, array('output' => 'map', 'field_set' => 'id', 'format' => 'simple'));
new dBug($xx);
die;
// create()
// function create($name,$color,$options,$notes,$active=1,$tcasePrefix='',$is_public=1)
$notes = " Created doing test ";
$color = '';
$options = new stdClass();
$options->requirement_mgmt = 1;
$options->priority_mgmt = 1;
$options->automated_execution = 1;
$active = 1;
$is_public = 1;
$namePrefix = 'TPX :: ';
$name = uniqid($namePrefix, true);
$tcasePrefix = uniqid('', false);
 * @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;
$gui = new stdClass();
$gui->grants = getGrants($db, $user, $userIsBlindFolded);
$gui->hasTestCases = false;
if ($gui->grants['view_tc']) {
    $gui->hasTestCases = $tproject_mgr->count_testcases($testprojectID) > 0 ? 1 : 0;
}
Example #6
0
 */
require_once '../../config.inc.php';
require_once "common.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$args = init_args();
checkRights($db, $_SESSION['currentUser'], $args);
$gui = new stdClass();
$gui->canManage = true;
// $_SESSION['currentUser']->hasRight($db,"mgt_modify_product",$args->tproject_id);
$gui->doAction = $args->doAction;
$gui->tproject_id = $args->contextTprojectID;
$gui->contextTprojectID = $args->contextTprojectID;
$gui->reloadType = 'none';
$tproject_mgr = new testproject($db);
$gui->tprojects = $tproject_mgr->get_accessible_for_user($args->userID, 'array_of_map');
$template2launch = $templateCfg->default_template;
if (count($gui->tprojects) == 0) {
    $template2launch = "projectEdit.tpl";
    $gui->doAction = "create";
}
// new dBug($gui);
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $template2launch);
/**
 * 
 *
 */
function init_args()
{
Example #7
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);
}
Example #8
0
 * @author 		TestLink community
 * @copyright 	2007-2009, TestLink community 
 * @version    	CVS: $Id: projectView.php,v 1.13 2010/02/16 21:46:32 havlat Exp $
 * @link 		http://www.teamst.org/index.php
 *
 */
require_once '../../config.inc.php';
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$gui = new stdClass();
$gui->doAction = $args->doAction;
$gui->canManage = has_rights($db, "mgt_modify_product");
$tproject_mgr = new testproject($db);
$gui->tprojects = $tproject_mgr->get_accessible_for_user($args->userID, 'array_of_map', " ORDER BY nodes_hierarchy.name ");
$template2launch = $templateCfg->default_template;
if (count($gui->tprojects) == 0) {
    $template2launch = "projectEdit.tpl";
    $gui->doAction = "create";
}
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $template2launch);
/**
 * 
 *
 */
function init_args()
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
Example #9
0
/**
 * 
 *
 */
function initializeGui(&$dbHandler, &$argsObj)
{
    $guiObj = new stdClass();
    $guiObj->doAction = $argsObj->doAction;
    $guiObj->canManage = $argsObj->user->hasRight($dbHandler, "mgt_modify_product");
    $guiObj->name = is_null($argsObj->name) ? '' : $argsObj->name;
    $guiObj->feedback = '';
    switch ($argsObj->doAction) {
        case 'search':
            $filters = array('name' => array('op' => 'like', 'value' => $argsObj->name));
            $guiObj->feedback = lang_get('no_records_found');
            break;
        case 'list':
        default:
            $filters = null;
            break;
    }
    $tproject_mgr = new testproject($dbHandler);
    $opt = array('output' => 'array_of_map', 'order_by' => " ORDER BY name ", 'add_issuetracker' => true, 'add_reqmgrsystem' => true);
    $guiObj->tprojects = $tproject_mgr->get_accessible_for_user($argsObj->userID, $opt, $filters);
    return $guiObj;
}
Example #10
0
testlinkInitPage($db, true);
$tproject_mgr = new testproject($db);
$args = init_args();
$gui = new stdClass();
$gui->tprojectID = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
$gui->tcasePrefix = '';
$gui->searchSize = 8;
// magic default
if ($gui->tprojectID > 0) {
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($gui->tprojectID) . config_get('testcase_cfg')->glue_character;
    $gui->searchSize = tlStringLen($gui->tcasePrefix) + 7;
    // magic again
}
$user = $_SESSION['currentUser'];
$userID = $user->dbID;
$gui->TestProjects = $tproject_mgr->get_accessible_for_user($userID, 'map', $tlCfg->gui->tprojects_combo_order_by);
$gui->TestProjectCount = sizeof($gui->TestProjects);
$gui->TestPlanCount = 0;
if ($gui->tprojectID) {
    $testPlanSet = $user->getAccessibleTestPlans($db, $gui->tprojectID);
    $gui->TestPlanCount = sizeof($testPlanSet);
    $tplanID = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : null;
    if (!is_null($tplanID)) {
        // Need to set this info on session with first Test Plan from $testPlanSet
        // if this test plan is present on $testPlanSet
        //	  OK we will set it on $testPlanSet as selected one.
        // else
        //    need to set test plan on session
        //
        $index = 0;
        $testPlanFound = 0;
Example #11
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));
    R_PARAMS($iParams, $argsObj);
    $guiObj->tcasePrefix = '';
    $guiObj->tplanCount = 0;
    $guiObj->tprojectSet = $tprojectMgr->get_accessible_for_user($userObj->dbID);
    $guiObj->tprojectCount = sizeof($guiObj->tprojectSet);
    // -----------------------------------------------------------------------------------------------------
    // Important Logic
    // -----------------------------------------------------------------------------------------------------
    $argsObj->tprojectIDNavBar = intval($argsObj->tprojectIDNavBar);
    $argsObj->tproject_id = intval($argsObj->tproject_id);
    $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'];
    }
    // -----------------------------------------------------------------------------------------------------
    $argsObj->tplan_id = intval($argsObj->tplan_id);
    $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;
    if ($guiObj->tprojectID > 0) {
        $guiObj->tcasePrefix = $tprojectMgr->getTestCasePrefix($guiObj->tprojectID) . 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;
        }
    }
    return array($argsObj, $guiObj);
}