You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
<?php
|
|
/*
|
|
Template to automatically create a new user with information from anywhere.
|
|
This file is loaded by main/inc/local.inc.php
|
|
To use it please add this line to main/inc/conf/configuration.php :
|
|
$extAuthSource["external_logininfo"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_logininfo/newUser.php";
|
|
|
|
You also have to implements the external_get_user_info function in functions.inc.php
|
|
*/
|
|
|
|
use \ChamiloSession as Session;
|
|
|
|
require_once(dirname(__FILE__) . '/functions.inc.php');
|
|
|
|
//MAIN CODE
|
|
//$login and $password variables are setted in main/inc/local.inc.php
|
|
|
|
if ($password != DEFAULT_PASSWORD) {
|
|
$user = false;
|
|
} else {
|
|
$user = external_get_user_info($login, $password);
|
|
}
|
|
|
|
if ($user !== false && ($chamilo_uid = external_add_user($user)) !== false) {
|
|
//log in the user
|
|
$loginFailed = false;
|
|
$_user['user_id'] = $chamilo_uid;
|
|
$_user['uidReset'] = true;
|
|
Session::write('_user', $_user);
|
|
$uidReset = true;
|
|
|
|
//Autosubscribe to courses
|
|
if (!empty($user['courses'])) {
|
|
$autoSubscribe = explode('|', $user['courses']);
|
|
foreach ($autoSubscribe as $code) {
|
|
if (CourseManager::course_exists($code)) {
|
|
CourseManager::subscribe_user($_user['user_id'], $code);
|
|
}
|
|
}
|
|
}
|
|
// Is User Admin ?
|
|
if ($user['admin']) {
|
|
$is_platformAdmin = true;
|
|
Database::query("INSERT INTO admin values ('$chamilo_uid')");
|
|
}
|
|
// Can user create course
|
|
$is_allowedCreateCourse = (bool) (($user['status'] == COURSEMANAGER) or (api_get_setting('drhCourseManagerRights') and $user['status'] == SESSIONADMIN));
|
|
|
|
event_login();
|
|
} else {
|
|
$loginFailed = true;
|
|
unset($_user['user_id']);
|
|
$uidReset = false;
|
|
}
|
|
?>
|
|
|