Example #1
0
        if ($success) {
            $use_anonymous = false;
        }
    }
    $uidReset = true;
}
// end
if ($loginFailed == true && !empty($errorMessage)) {
    header('Location: ' . api_get_path(WEB_PUBLIC_PATH) . 'index?error=' . $errorMessage);
    exit;
}
//Now check for anonymous user mode
if (isset($use_anonymous) && $use_anonymous) {
    //if anonymous mode is set, then try to set the current user as anonymous
    //if he doesn't have a login yet
    api_set_anonymous();
} else {
    //if anonymous mode is not set, then check if this user is anonymous. If it
    //is, clean it from being anonymous (make him a nobody :-))
    api_clear_anonymous();
}
// if the requested course is different from the course in session
if (!empty($cidReq) && (!isset($_SESSION['_cid']) or isset($_SESSION['_cid']) && $cidReq != $_SESSION['_cid'])) {
    $cidReset = true;
    $gidReset = true;
    // As groups depend from courses, group id is reset
}
// Setting app user variable
$_user = Session::read('_user');
if ($_user && !isset($_user['complete_name'])) {
    $_user = api_get_user_info(api_get_user_id(), false, false, true);
Example #2
0
/**
 * Tells whether this user is an anonymous user
 * @param int  $user_id      User ID (optional, will take session ID if not provided)
 * @param bool $db_check     Whether to check in the database (true) or simply in
 * the session (false) to see if the current user is the anonymous user
 * @return bool     true if this user is anonymous, false otherwise
 */
function api_is_anonymous($user_id = null, $db_check = false)
{
    /*if (!isset($user_id)) {
            $user_id = api_get_user_id();
        }
        if ($db_check) {
            $info = api_get_user_info($user_id);
            if ($info['status'] == ANONYMOUS) {
                return true;
            }
        }
    
        $_user = api_get_user_info();
        if (isset($_user['status']) && $_user['status'] == ANONYMOUS) {
            //if ($_user['user_id'] == 0) {
            // In some cases, api_set_anonymous doesn't seem to be triggered in local.inc.php. Make sure it is.
            // Occurs in agenda for admin links - YW
            global $use_anonymous;
            if (isset($use_anonymous) && $use_anonymous) {
                api_set_anonymous();
            }
    
            return true;
        }
    
        return ((isset($_user['is_anonymous']) && $_user['is_anonymous'] === true) || $_user === false);*/
    if (!isset($user_id)) {
        $user_id = api_get_user_id();
    }
    if ($db_check) {
        $info = api_get_user_info($user_id);
        if ($info['status'] == 6 || $user_id == 0 || empty($info)) {
            return true;
        }
    }
    $_user = Session::read('_user');
    if (!isset($_user) || isset($_user['user_id']) && $_user['user_id'] == 0) {
        // In some cases, api_set_anonymous doesn't seem to be triggered in local.inc.php. Make sure it is.
        // Occurs in agenda for admin links - YW
        /*global $use_anonymous;
          if (isset($use_anonymous) && $use_anonymous) {*/
        api_set_anonymous();
        //}
        return true;
    }
    return isset($_user['is_anonymous']) && $_user['is_anonymous'] === true;
}
Example #3
0
/**
 * Tells whether this user is an anonymous user
 * @param int  $user_id      User ID (optional, will take session ID if not provided)
 * @param bool $db_check     Whether to check in the database (true) or simply in
 * the session (false) to see if the current user is the anonymous user
 * @return bool     true if this user is anonymous, false otherwise
 */
function api_is_anonymous($user_id = null, $db_check = false)
{
    if (!isset($user_id)) {
        $user_id = api_get_user_id();
    }
    if ($db_check) {
        $info = api_get_user_info($user_id);
        if ($info['status'] == 6) {
            return true;
        }
    }
    global $_user;
    if (!isset($_user)) {
        // In some cases, api_set_anonymous doesn't seem to be triggered in local.inc.php. Make sure it is.
        // Occurs in agenda for admin links - YW
        global $use_anonymous;
        if (isset($use_anonymous) && $use_anonymous) {
            api_set_anonymous();
        }
        return true;
    }
    return isset($_user['is_anonymous']) && $_user['is_anonymous'] === true;
}