24 include_once(
'Auth/Container.php');
53 parent::__construct($a_params);
123 $ilLog->write(__METHOD__.
': Starting ECS authentication.');
127 $GLOBALS[
'ilLog']->write(__METHOD__.
': no active ecs server found. Aborting');
132 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
141 $GLOBALS[
'ilLog']->write(__METHOD__.
': Could not validate ecs hash for any server');
162 $hash =
$_GET[
'ecs_hash'];
164 if(isset(
$_GET[
'ecs_hash_url']))
166 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
167 $hash = basename(parse_url($hashurl,PHP_URL_PATH));
171 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using ecs hash '. $hash);
176 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
178 $res = $connector->getAuth($hash);
179 $auths =
$res->getResult();
181 $GLOBALS[
'ilLog']->write(__METHOD__.
': Auths: '.print_r($auths,TRUE));
187 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
189 $part =
$reader->getParticipantByMID($auths->pid);
191 if(is_object($part)
and is_object($part->getOrganisation()))
193 $this->abreviation = $part->getOrganisation()->getAbbreviation();
197 $this->abreviation = $auths->abbr;
202 $ilLog->write(__METHOD__.
': Authentication failed with message: '.$e->getMessage());
208 $this->abreviation = $auths->abbr;
211 $ilLog->write(__METHOD__.
': Got abr: '.$this->abreviation);
215 $ilLog->write(__METHOD__.
': Authentication failed with message: '.$e->getMessage());
222 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
224 $details = $connector->getAuth($hash,TRUE);
226 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.print_r($details,TRUE));
227 $GLOBALS[
'ilLog']->write(__METHOD__.
': Token created for mid '. $details->getFirstSender());
229 $this->
setMID($details->getFirstSender());
233 $ilLog->write(__METHOD__.
': Receiving mid failed with message: '.$e->getMessage());
246 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
260 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
265 include_once
'./Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
268 $remote->setMid($this->
getMID());
269 $remote->setRemoteUserId($user->getImportId());
272 $GLOBALS[
'ilLog']->write(__METHOD__.
': Current username '.$username);
274 if(!$remote->exists())
279 $a_auth->setAuth($username);
280 $this->log->write(__METHOD__.
': Login succesesful');
291 $this->log->write(__METHOD__.
': Login failed');
307 $userObj->setOwner(SYSTEM_USER_ID);
309 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
312 $newUser[
"login"] = $local_user;
315 $newUser[
'email'] = $user->
getEmail();
319 $newUser[
"passwd"] =
"";
322 $newUser[
"auth_mode"] =
"ecs";
323 $newUser[
"profile_incomplete"] = 0;
326 $userObj->assignData($newUser);
327 $userObj->setTitle($userObj->getFullname());
328 $userObj->setDescription($userObj->getEmail());
331 $userObj->setLanguage($ilSetting->get(
"language"));
334 $userObj->setTimeLimitOwner(7);
335 $userObj->setTimeLimitUnlimited(0);
336 $userObj->setTimeLimitFrom(
time() - 5);
337 $userObj->setTimeLimitUntil(
time() + $ilClientIniFile->readVariable(
"session",
"expire"));
339 #$now = new ilDateTime(time(), IL_CAL_UNIX); 340 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME)); 343 $userObj->setOwner(6);
345 $userObj->setActive(1);
346 $userObj->updateOwner();
347 $userObj->saveAsNew();
348 $userObj->writePrefs();
352 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
356 $ilLog->write(__METHOD__ .
': Created new remote user with usr_id: ' . $user->
getImportId());
359 #$this->sendNotification($userObj); 362 return $userObj->getLogin();
372 global $ilClientIniFile,
$ilLog,$rbacadmin;
374 $user_obj =
new ilObjUser($a_local_user_id);
377 $user_obj->setEmail($user->
getEmail());
379 $user_obj->setActive(
true);
381 $until = $user_obj->getTimeLimitUntil();
383 if($until < (
time() + $ilClientIniFile->readVariable(
'session',
'expire')))
385 $user_obj->setTimeLimitFrom(
time() - 60);
386 $user_obj->setTimeLimitUntil(
time() + $ilClientIniFile->readVariable(
"session",
"expire"));
389 $user_obj->refreshLogin();
393 $rbacadmin->assignUser(
402 $ilLog->write(__METHOD__.
': Finished update of remote user with usr_id: '.$user->
getImportId());
403 return $user_obj->getLogin();
412 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
431 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
449 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
450 include_once
'./Services/Language/classes/class.ilLanguage.php';
454 $lang->loadLanguageModule(
'ecs');
456 include_once(
'./Services/Mail/classes/class.ilMail.php');
458 $mail->enableSoap(
false);
459 $subject =
$lang->txt(
'ecs_new_user_subject');
462 $body =
$lang->txt(
'ecs_new_user_body').
"\n\n";
463 $body .=
$lang->txt(
'ecs_new_user_profile').
"\n\n";
464 $body .= $user_obj->getProfileAsString(
$lang).
"\n\n";
465 $body .= ilMail::_getAutoGeneratedMessageString(
$lang);
updateUser(ilECSUser $user, $a_local_user_id)
update existing user
Class UserMail this class handles user mails.
getFirstname()
get firstname
getAbreviation()
get abbreviation
static getInstance()
Get singleton instance.
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
Storage of ecs remote user.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _lookupId($a_user_str)
Lookup id by login.
getServerSettings()
Get server settings.
createUser(ilECSUser $user)
create new user
sendNotification($user_obj)
Send notification.
static _getLanguage($a_lang_key='')
Get langauge object.
if(!is_array($argv)) $options
This class handles base functions for mail handling.
failedLoginObserver()
Called from base class after failed login.
getCurrentServer()
Get current server.
Storage of ECS imported objects.
Create styles array
The data for the language used.
resetMailOptions($a_usr_id)
Reset mail options to "local only".
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
loginObserver($a_username, $a_auth)
Called from base class after successful login.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
fetchData($a_username, $a_pass)
Check for valid ecs_hash.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setCurrentServer(ilECSSetting $server=null)
Set current server.
initECSServices()
Init ECS Services private.
__construct($a_params=array())
Constructor.
getInstitution()
get institution
Custom PEAR Auth Container for ECS auth checks.
Stores relevant user data.
static _lookupObjIdByImportId($a_import_id)
validateHash()
Validate ECS hash.