Example #1
0
function startSession()
{
    global $_SERVER, $notAuthorizedURL, $DEPLOYMENT_NAME;
    // $_SERVER variables courtesy of Shibboleth
    $firstName = $_SERVER['givenName'];
    $lastName = $_SERVER['sn'];
    session_start();
    $userID = getCurrentClasUserId();
    $user = new Users();
    if (!isset($_SESSION['authenticated'])) {
        // if still no user then account does not exist
        // not authorized
        if (is_null($userID)) {
            notAuthorized();
        } else {
            $currentClasUser = $user->getUserInfo(array($userID));
            $currentClasUser = $currentClasUser[0];
            $currentFirstName = null;
            $currentLastName = null;
            if (!is_null($currentClasUser)) {
                $currentFirstName = $currentClasUser['first_name'];
                $currentLastName = $currentClasUser['last_name'];
            }
            if (!is_null($currentFirstName) && $currentFirstName != "" && trim(strtoupper($currentFirstName)) != "NULL") {
                $firstName = $currentFirstName;
            }
            if (!is_null($currentLastName) && $currentLastName != "" && trim(strtoupper($currentLastName)) != "NULL") {
                $lastName = $currentLastName;
            }
            $nameNotAvailable = false;
            if ($firstName == null && $lastName == null || $firstName == "" && $lastName == "" || $firstName == "NULL" && $lastName == "NULL") {
                $firstName = "Name";
                $lastName = "Not Available";
                $nameNotAvailable = true;
            }
            $currentClasUser = $user->getUserInfo(array($userID));
            $role = $currentClasUser[0]['role'];
            $_SESSION['name'] = $userName;
            $_SESSION['role'] = $role;
            $_SESSION['user_id'] = $userID;
            $_SESSION['authenticated'] = 1;
            // write user name to database
            if (!$nameNotAvailable) {
                $user->setName($firstName, $lastName, $userID);
            }
            // log session start
            $user->recordLogin($userID);
            //record the user event
            //$user->recordEvent($userID, $classID);
        }
    } else {
        //print "isset(\$_SESSION['authenticated'])";
    }
    $user->close();
}
Example #2
0
            notAuthorized();
        }
    } else {
        if ($DEPLOYMENT_NAME == "demo") {
            if ($hashedCurrentUser != $Jenny_hashed_id && $hashedCurrentUser != $Thomas_hashed_id) {
                //	notAuthorized();
            }
        } else {
            if ($DEPLOYMENT_NAME == "medclas") {
                if ($hashedCurrentUser != $Jenny_hashed_id && $hashedCurrentUser != $Thomas_hashed_id) {
                    notAuthorized();
                }
            } else {
                if ($DEPLOYMENT_NAME == "educ") {
                    if ($hashedCurrentUser != $Jenny_hashed_id && $hashedCurrentUser != $Thomas_hashed_id && $hashedCurrentUser != $Sharon_hashed_id) {
                        notAuthorized();
                    }
                }
            }
        }
    }
}
// Choose the theme color for the interface so that it's harder to confuse between instances
$themeColor = "#FFFFFF";
if ($DEPLOYMENT_NAME == "prod") {
    $themeColor = "rgb(50,50,50)";
} else {
    if ($DEPLOYMENT_NAME == "dev") {
        $themeColor = "rgb(218,226,233)";
    } else {
        if ($DEPLOYMENT_NAME == "demo") {