ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCASAttributeToUser Class Reference

CAS user creation helper. More...

+ Collaboration diagram for ilCASAttributeToUser:

Public Member Functions

 __construct (\ilCASSettings $settings)
 
 create (string $a_username)
 

Private Attributes

ilLogger $logger
 
ilXmlWriter $writer
 
ilCASSettings $settings
 

Detailed Description

CAS user creation helper.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 24 of file class.ilCASAttributeToUser.php.

Constructor & Destructor Documentation

◆ __construct()

ilCASAttributeToUser::__construct ( \ilCASSettings  $settings)

Definition at line 30 of file class.ilCASAttributeToUser.php.

References $DIC, $settings, ILIAS\Repository\logger(), and ILIAS\Repository\settings().

31  {
32  global $DIC;
33 
34  $this->logger = $DIC->logger()->auth();
35 
36  $this->writer = new ilXmlWriter();
37 
38  $this->settings = $settings;
39  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilCASAttributeToUser::create ( string  $a_username)

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

References ilAuthUtils\_generateLogin(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

41  : string
42  {
43  $this->writer->xmlStartTag('Users');
44 
45  $this->writer->xmlStartTag('User', array('Action' => 'Insert'));
46  $new_name = ilAuthUtils::_generateLogin($a_username);
47  $this->writer->xmlElement('Login', array(), $new_name);
48 
49  // Assign to role only for new users
50  $this->writer->xmlElement(
51  'Role',
52  array(
53  'Id' => $this->settings->getDefaultRole(),
54  'Type' => 'Global',
55  'Action' => 'Assign'),
56  ''
57  );
58 
59  $this->writer->xmlElement('Active', array(), "true");
60  $this->writer->xmlElement('TimeLimitOwner', array(), 7);
61  $this->writer->xmlElement('TimeLimitUnlimited', array(), 1);
62  $this->writer->xmlElement('TimeLimitFrom', array(), time());
63  $this->writer->xmlElement('TimeLimitUntil', array(), time());
64  $this->writer->xmlElement('AuthMode', array('type' => 'cas'), 'cas');
65  $this->writer->xmlElement('ExternalAccount', array(), $a_username);
66 
67  $this->writer->xmlEndTag('User');
68  $this->writer->xmlEndTag('Users');
69 
70  $this->logger->info('CAS: Startet creation of user: ' . $new_name);
71 
72  $importParser = new ilUserImportParser();
73  $importParser->setXMLContent($this->writer->xmlDumpMem(false));
74  $importParser->setRoleAssignment(
75  array(
76  $this->settings->getDefaultRole() => $this->settings->getDefaultRole()
77  )
78  );
79  //TODO check if there is a constant
80  $importParser->setFolderId(7);
81  $importParser->startParsing();
82 
83  return $new_name;
84  }
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilCASAttributeToUser::$logger
private

Definition at line 26 of file class.ilCASAttributeToUser.php.

◆ $settings

ilCASSettings ilCASAttributeToUser::$settings
private

Definition at line 28 of file class.ilCASAttributeToUser.php.

Referenced by __construct().

◆ $writer

ilXmlWriter ilCASAttributeToUser::$writer
private

Definition at line 27 of file class.ilCASAttributeToUser.php.


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