/**
  * Create a Shibboleth session for the user ID
  *
  * @param  string $uid - The user ID
  * @return $_user (array) - The user infos array created when the user logs in
  */
 function login($uid)
 {
     /* This must be set for local.inc.php to register correctly the global variables in session
      * This is BAD. Logic should be migrated into a function and stop relying on global variables.
      */
     global $_uid, $is_allowedCreateCourse, $is_platformAdmin, $_real_cid, $is_courseAdmin;
     global $is_courseMember, $is_courseTutor, $is_courseCoach, $is_allowed_in_course, $is_sessionAdmin, $_gid;
     $_uid = $uid;
     //is_allowedCreateCourse
     $user = User::store()->get_by_user_id($uid);
     if (empty($user)) {
         return;
     }
     $this->logout();
     Session::instance();
     Session::write('_uid', $_uid);
     global $_user;
     $_user = (array) $user;
     $_SESSION['_user'] = $_user;
     $_SESSION['_user']['user_id'] = $_uid;
     $_SESSION['noredirection'] = true;
     //must be called before 'init_local.inc.php'
     Event::event_login($_uid);
     //used in 'init_local.inc.php' this is BAD but and should be changed
     $loginFailed = false;
     $uidReset = true;
     $gidReset = true;
     $cidReset = false;
     //FALSE !!
     $mainDbName = Database::get_main_database();
     $includePath = api_get_path(SYS_INC_PATH);
     $no_redirection = true;
     require "{$includePath}/local.inc.php";
     return $_user;
 }
 /**
  *
  * @return CurrentUser
  */
 static function user()
 {
     return ChamiloSession::instance()->user();
 }
Esempio n. 3
0
        }
        // Didn't find any? Now try without subdirs
        if ($request_url_root == $details['url']) {
            $_configuration['access_url'] = $details['id'];
            break;
            //found one match, get out of foreach
        }
    }
} else {
    $_configuration['access_url'] = 1;
}
$charset = 'UTF-8';
// Enables the portablity layer and configures PHP for UTF-8
\Patchwork\Utf8\Bootup::initAll();
// Start session after the internationalization library has been initialized.
ChamiloSession::instance()->start($alreadyInstalled);
// Remove quotes added by PHP  - get_magic_quotes_gpc() is deprecated in PHP 5 see #2970
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    array_walk_recursive_limited($_GET, 'stripslashes', true);
    array_walk_recursive_limited($_POST, 'stripslashes', true);
    array_walk_recursive_limited($_COOKIE, 'stripslashes', true);
    array_walk_recursive_limited($_REQUEST, 'stripslashes', true);
}
// access_url == 1 is the default chamilo location
if ($_configuration['access_url'] != 1) {
    $url_info = api_get_access_url($_configuration['access_url']);
    if ($url_info['active'] == 1) {
        $settings_by_access =& api_get_settings(null, 'list', $_configuration['access_url'], 1);
        foreach ($settings_by_access as &$row) {
            if (empty($row['variable'])) {
                $row['variable'] = 0;
 /**
  * The course code (id) to which the object belongs.
  *
  * @return string
  */
 function course_code()
 {
     return ChamiloSession::instance()->course()->code();
 }