ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilOpenIdAttributeToUser Class Reference

@classDescription Open ID auth class More...

+ Collaboration diagram for ilOpenIdAttributeToUser:

Public Member Functions

 __construct ()
 
 create ($a_username, $a_userdata=array())
 Create new ILIAS account. More...
 

Protected Member Functions

 parseFullname ($a_userdata)
 

Private Attributes

 $settings = null
 
 $writer = null
 

Detailed Description

@classDescription Open ID auth class

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 13 of file class.ilOpenIdAttributeToUser.php.

Constructor & Destructor Documentation

◆ __construct()

ilOpenIdAttributeToUser::__construct ( )

Definition at line 21 of file class.ilOpenIdAttributeToUser.php.

22 {
23 global $ilLog;
24
25 $this->log = $ilLog;
26
27 $this->settings = ilOpenIdSettings::getInstance();
28
29 include_once('./Services/Xml/classes/class.ilXmlWriter.php');
30 $this->writer = new ilXmlWriter();
31
32 }
static getInstance()
Get singleton instance.
XML writer class.

References $ilLog, and ilOpenIdSettings\getInstance().

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilOpenIdAttributeToUser::create (   $a_username,
  $a_userdata = array() 
)

Create new ILIAS account.

@access public

Parameters
stringexternal username

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

42 {
43 $a_userdata = $this->parseFullname($a_userdata);
44
45 $this->writer->xmlStartTag('Users');
46
47 // Single users
48 // Required fields
49 // Create user
50 $this->writer->xmlStartTag('User',array('Action' => 'Insert'));
51 $this->writer->xmlElement('Login',array(),$new_name = ilAuthUtils::_generateLogin($a_username));
52
53 // Assign to role only for new users
54 $this->writer->xmlElement('Role',array('Id' => $this->settings->getDefaultRole(),
55 'Type' => 'Global',
56 'Action' => 'Assign'),'');
57
58 if(isset($a_userdata['email']))
59 {
60 $this->writer->xmlElement('Email',array(),$a_userdata['email']);
61 }
62 if(isset($a_userdata['postcode']))
63 {
64 $this->writer->xmlElement('PostalCode',array(),$a_userdata['postcode']);
65 }
66 if(isset($a_userdata['dob']) and $a_userdata['dob'])
67 {
68 $this->writer->xmlElement('Birthday',array(),$a_userdata['dob']);
69 }
70 if(isset($a_userdata['gender']))
71 {
72 $this->writer->xmlElement('Gender',array(),strtolower($a_userdata['gender']));
73 }
74 if(isset($a_userdata['title']))
75 {
76 $this->writer->xmlElement('Title',array(),$a_userdata['title']);
77 }
78 if(isset($a_userdata['firstname']))
79 {
80 $this->writer->xmlElement('Firstname',array(),$a_userdata['firstname']);
81 }
82 if(isset($a_userdata['lastname']))
83 {
84 $this->writer->xmlElement('Lastname',array(),$a_userdata['lastname']);
85 }
86
87 $this->writer->xmlElement('Active',array(),"true");
88 $this->writer->xmlElement('TimeLimitOwner',array(),7);
89 $this->writer->xmlElement('TimeLimitUnlimited',array(),1);
90 $this->writer->xmlElement('TimeLimitFrom',array(),time());
91 $this->writer->xmlElement('TimeLimitUntil',array(),time());
92 $this->writer->xmlElement('AuthMode',array('type' => 'openid'),'openid');
93 $this->writer->xmlElement('ExternalAccount',array(),$a_username);
94
95 $this->writer->xmlEndTag('User');
96 $this->writer->xmlEndTag('Users');
97 $this->log->write('OpenId: Started creation of user: '.$new_name);
98
99 include_once './Services/User/classes/class.ilUserImportParser.php';
100 $importParser = new ilUserImportParser();
101 $importParser->setXMLContent($this->writer->xmlDumpMem(false));
102 $importParser->setRoleAssignment(array($this->settings->getDefaultRole() => $this->settings->getDefaultRole()));
103 $importParser->setFolderId(7);
104 $importParser->startParsing();
105
106 // Assign timezone
107 if(isset($a_userdata['timezone']))
108 {
109 include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
111
112 if(isset($tzs[$a_userdata['timezone']]))
113 {
114 $usr_id = ilObjUser::_lookupId($new_name);
115 ilObjUser::_writePref($usr_id, 'user_tz', $a_userdata['timezone']);
116 }
117 }
118
119 return $new_name;
120 }
_generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
static _getShortTimeZoneList()
get short timezone list
static _writePref($a_usr_id, $a_keyword, $a_value)
static _lookupId($a_user_str)
Lookup id by login.

References ilAuthUtils\_generateLogin(), ilCalendarUtil\_getShortTimeZoneList(), ilObjUser\_lookupId(), ilObjUser\_writePref(), and parseFullname().

+ Here is the call graph for this function:

◆ parseFullname()

ilOpenIdAttributeToUser::parseFullname (   $a_userdata)
protected

Definition at line 122 of file class.ilOpenIdAttributeToUser.php.

123 {
124 include_once './Services/User/classes/class.ilFullnameParser.php';
125
126 $parser = new ilFullnameParser($a_userdata['fullname']);
127
128 if($parser->getNotParseable())
129 {
130 return $a_userdata;
131 }
132
133 $a_userdata['firstname'] = $parser->getFirstName();
134 $a_userdata['lastname'] = $parser->getLastName();
135 $a_userdata['title'] = $parser->getTitle();
136
137 return $a_userdata;
138 }

Referenced by create().

+ Here is the caller graph for this function:

Field Documentation

◆ $settings

ilOpenIdAttributeToUser::$settings = null
private

Definition at line 15 of file class.ilOpenIdAttributeToUser.php.

◆ $writer

ilOpenIdAttributeToUser::$writer = null
private

Definition at line 16 of file class.ilOpenIdAttributeToUser.php.


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