示例#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;
}
示例#2
0
/**
 * General GUI page initialization procedure
 * - init session
 * - init database
 * - check rights
 * - initialize project data (if requested)
 * 
 * @param integer $db DB connection identifier
 * @param boolean $initProject (optional) Set true if adjustment of Product or
 * 		Test Plan is required; default is FALSE
 * @param boolean $bDontCheckSession (optional) Set to true if no session should be
 * 		 started
 */
function testlinkInitPage(&$db, $initProject = FALSE, $bDontCheckSession = false, $userRightsCheckFunction = null)
{
    doSessionStart();
    setPaths();
    set_dt_formats();
    doDBConnect($db);
    static $pageStatistics = null;
    if (!$pageStatistics && config_get('log_level') == 'EXTENDED') {
        $pageStatistics = new tlPageStatistics($db);
    }
    if (!$bDontCheckSession) {
        checkSessionValid($db);
    }
    if ($userRightsCheckFunction) {
        checkUserRightsFor($db, $userRightsCheckFunction);
    }
    // adjust Product and Test Plan to $_SESSION
    if ($initProject) {
        initProject($db, $_REQUEST);
    }
    // used to disable the attachment feature if there are problems with repository path
    /** @TODO this check should not be done anytime but on login and using */
    global $g_repositoryType;
    global $g_attachments;
    global $g_repositoryPath;
    $g_attachments->disabled_msg = "";
    if ($g_repositoryType == TL_REPOSITORY_TYPE_FS) {
        $ret = checkForRepositoryDir($g_repositoryPath);
        if (!$ret['status_ok']) {
            $g_attachments->enabled = FALSE;
            $g_attachments->disabled_msg = $ret['msg'];
        }
    }
}
示例#3
0
 function setUserSession(&$db)
 {
     // tLog('setUserSession: $user='******' $id='.$id.' $roleID='.$roleID.' $email='.$email.' $locale='.$locale);
     $_SESSION['userID'] = $this->dbID;
     $_SESSION['s_lastAttachmentList'] = null;
     $_SESSION['locale'] = $this->locale;
     set_dt_formats();
     return 1;
 }
示例#4
0
/**
 * General GUI page initialization procedure
 * - init session
 * - init database
 * 
 * @param integer $db DB connection identifier
 * @param boolean $checkSession (optional) 
 */
function testlinkInitPage(&$db, $checkSession = true)
{
    doSessionStart();
    setPaths();
    set_dt_formats();
    doDBConnect($db);
    static $pageStatistics = null;
    if (!$pageStatistics && config_get('log_level') == 'EXTENDED') {
        $pageStatistics = new tlPageStatistics($db);
    }
    if ($checkSession) {
        checkSessionValid($db);
    }
}