ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAuthECS Class Reference

Authentication class for ECS users (access to remote courses) More...

+ Inheritance diagram for ilAuthECS:
+ Collaboration diagram for ilAuthECS:

Public Member Functions

 __construct ($a_options, $ecs_hash)
 Constructor.

Protected Member Functions

 loginObserver ($a_username)
 Called from base class after successful login.
 createUser (ilECSUser $user)
 create new user
 updateUser (ilECSUser $user, $a_local_user_id)
 update existing user
 failedLoginObserver ()
 Called from base class after failed login.

Protected Attributes

 $container = null
 $settings = null
 $ilLog = null

Private Member Functions

 setCallbacks ()
 Set callback function for PEAR Auth.
 initLogObserver ()
 Init Log observer.
 initSettings ()
 init ecs settings
 sendNotification ($user_obj)
 Send notification.

Detailed Description

Authentication class for ECS users (access to remote courses)

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
$Id$

Definition at line 37 of file class.ilAuthECS.php.

Constructor & Destructor Documentation

ilAuthECS::__construct (   $a_options,
  $ecs_hash 
)

Constructor.

public

Definition at line 49 of file class.ilAuthECS.php.

References $ilLog, initLogObserver(), and setCallbacks().

{
global $ilLog;
$this->log = $ilLog;
$this->log->write(__METHOD__.': Called constructor...');
$_POST['username'] = 'dummy';
include_once('./Services/WebServices/ECS/classes/class.ilAuthContainerECS.php');
parent::__construct($this->container = new ilAuthContainerECS(array('ecs_hash' => $ecs_hash)),$a_options);
$this->initLogObserver();
$this->setCallbacks();
}

+ Here is the call graph for this function:

Member Function Documentation

ilAuthECS::createUser ( ilECSUser  $user)
protected

create new user

protected

Definition at line 97 of file class.ilAuthECS.php.

References $ilLog, $ilSetting, ilAuthUtils\_generateLogin(), ilObject\_writeImportId(), ilECSUser\getEmail(), ilECSUser\getFirstname(), ilECSUser\getImportId(), ilECSUser\getInstitution(), ilECSUser\getLastname(), ilECSUser\getLogin(), IL_PASSWD_MD5, and initSettings().

Referenced by loginObserver().

{
global $ilClientIniFile,$ilSetting,$rbacadmin,$ilLog;
$userObj = new ilObjUser();
include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
$local_user = ilAuthUtils::_generateLogin($this->container->getAbreviation().'_'.$user->getLogin());
$newUser["login"] = $local_user;
$newUser["firstname"] = $user->getFirstname();
$newUser["lastname"] = $user->getLastname();
$newUser['email'] = $user->getEmail();
$newUser['institution'] = $user->getInstitution();
// set "plain md5" password (= no valid password)
$newUser["passwd"] = "";
$newUser["passwd_type"] = IL_PASSWD_MD5;
$newUser["auth_mode"] = "ecs";
$newUser["profile_incomplete"] = 0;
// system data
$userObj->assignData($newUser);
$userObj->setTitle($userObj->getFullname());
$userObj->setDescription($userObj->getEmail());
// set user language to system language
$userObj->setLanguage($ilSetting->get("language"));
// Time limit
$userObj->setTimeLimitOwner(7);
$userObj->setTimeLimitUnlimited(0);
$userObj->setTimeLimitFrom(time());
$userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session","expire"));
// Create user in DB
$userObj->setOwner(6);
$userObj->create();
$userObj->setActive(1);
$userObj->updateOwner();
$userObj->saveAsNew();
$userObj->writePrefs();
$this->initSettings();
if($global_role = $this->settings->getGlobalRole())
{
$rbacadmin->assignUser($this->settings->getGlobalRole(),$userObj->getId(),true);
}
ilObject::_writeImportId($userObj->getId(),$user->getImportId());
$ilLog->write(__METHOD__.': Created new remote user with usr_id: '.$user->getImportId());
// Send Mail
#$this->sendNotification($userObj);
return $userObj->getLogin();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAuthECS::failedLoginObserver ( )
protected

Called from base class after failed login.

Parameters
stringusername

Definition at line 196 of file class.ilAuthECS.php.

{
$this->log->write(__METHOD__.': Login failed');
}
ilAuthECS::initLogObserver ( )
private

Init Log observer.

private

Parameters

Definition at line 219 of file class.ilAuthECS.php.

References $ilLog.

Referenced by __construct().

{
global $ilLog;
if(!method_exists($this,'attachLogObserver'))
{
$ilLog->write(__METHOD__.': PEAR Auth < 1.5 => disabling logging.');
return false;
}
if(@include_once('Log.php'))
{
if(@include_once('Log/observer.php'))
{
$ilLog->write(__METHOD__.': Attached Logging observer.');
include_once('Services/LDAP/classes/class.ilAuthLDAPLogObserver.php');
$this->attachLogObserver(new ilAuthLDAPLogObserver(AUTH_LOG_DEBUG));
return true;
}
}
$ilLog->write(__METHOD__.': PEAR Log not installed. Logging disabled');
}

+ Here is the caller graph for this function:

ilAuthECS::initSettings ( )
private

init ecs settings

private

Definition at line 248 of file class.ilAuthECS.php.

References ilECSSettings\_getInstance().

Referenced by createUser(), and updateUser().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSSettings.php');
$this->settings = ilECSSettings::_getInstance();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAuthECS::loginObserver (   $a_username)
protected

Called from base class after successful login.

Parameters
stringusername

Definition at line 71 of file class.ilAuthECS.php.

References $_GET, $user, ilObject\_lookupObjIdByImportId(), createUser(), and updateUser().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSUser.php');
if(!$usr_id = ilObject::_lookupObjIdByImportId($user->getImportId()))
{
$username = $this->createUser($user);
}
else
{
$username = $this->updateUser($user,$usr_id);
}
$this->setAuth($username);
$this->log->write(__METHOD__.': Login succesesful');
return;
}

+ Here is the call graph for this function:

ilAuthECS::sendNotification (   $user_obj)
private

Send notification.

private

Parameters

Definition at line 261 of file class.ilAuthECS.php.

References $GLOBALS, $lang, ilMail\_getAutoGeneratedMessageString(), and ilLanguageFactory\_getLanguage().

{
if(!count($this->settings->getUserRecipients()))
{
return true;
}
include_once('./Services/Language/classes/class.ilLanguageFactory.php');
$GLOBALS['lng'] = $lang;
$GLOBALS['ilUser'] = $user_obj;
$lang->loadLanguageModule('ecs');
include_once('./Services/Mail/classes/class.ilMail.php');
$mail = new ilMail(6);
$mail->enableSoap(false);
$subject = $lang->txt('ecs_new_user_subject');
// build body
$body = $lang->txt('ecs_new_user_body')."\n\n";
$body .= $lang->txt('ecs_new_user_profile')."\n\n";
$body .= $user_obj->getProfileAsString($lang)."\n\n";
$mail->sendMail($this->settings->getUserRecipientsAsString(),"","",$subject,$body,array(),array("normal"));
}

+ Here is the call graph for this function:

ilAuthECS::setCallbacks ( )
private

Set callback function for PEAR Auth.

Definition at line 206 of file class.ilAuthECS.php.

Referenced by __construct().

{
$this->setLoginCallback(array($this,'loginObserver'));
$this->setFailedLoginCallback(array($this,'failedLoginObserver'));
}

+ Here is the caller graph for this function:

ilAuthECS::updateUser ( ilECSUser  $user,
  $a_local_user_id 
)
protected

update existing user

protected

Definition at line 161 of file class.ilAuthECS.php.

References $ilLog, ilECSUser\getEmail(), ilECSUser\getFirstname(), ilECSUser\getImportId(), ilECSUser\getInstitution(), ilECSUser\getLastname(), and initSettings().

Referenced by loginObserver().

{
global $ilClientIniFile,$ilLog,$rbacadmin;
$user_obj = new ilObjUser($a_local_user_id);
$user_obj->setFirstname($user->getFirstname());
$user_obj->setLastname($user->getLastname());
$user_obj->setEmail($user->getEmail());
$user_obj->setInstitution($user->getInstitution());
$until = $user_obj->getTimeLimitUntil();
if($until < (time() + $ilClientIniFile->readVariable('session','expire')))
{
$user_obj->setTimeLimitFrom(time());
$user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session","expire"));
}
$user_obj->update();
$user_obj->refreshLogin();
$this->initSettings();
if($global_role = $this->settings->getGlobalRole())
{
$rbacadmin->assignUser($this->settings->getGlobalRole(),$user_obj->getId(),true);
}
$ilLog->write(__METHOD__.': Finished update of remote user with usr_id: '.$user->getImportId());
return $user_obj->getLogin();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilAuthECS::$container = null
protected

Definition at line 39 of file class.ilAuthECS.php.

ilAuthECS::$ilLog = null
protected

Definition at line 41 of file class.ilAuthECS.php.

Referenced by __construct(), createUser(), initLogObserver(), and updateUser().

ilAuthECS::$settings = null
protected

Definition at line 40 of file class.ilAuthECS.php.


The documentation for this class was generated from the following file: