ILIAS  release_8 Revision v8.24
class.ilECSUser.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
26{
28
30 private $source;
31
32 public string $login;
33 public string $email;
34 public string $firstname;
35 public string $lastname;
36 public string $institution;
37 public string $uid_hash;
38
39 protected string $external_account = '';
40 protected string $auth_mode = '';
41
42
46 public function __construct($a_data)
47 {
48 global $DIC;
49
50 $this->setting = $DIC->settings();
51
52 $this->source = $a_data;
53 if (is_object($a_data)) {
54 $this->loadFromObject();
55 } elseif (is_array($a_data)) {
56 $this->loadFromGET();
57 }
58 }
59
63 public function getLogin(): string
64 {
65 return $this->login;
66 }
67
68 public function getExternalAccount(): string
69 {
71 }
72
73
74
78 public function getFirstname(): string
79 {
80 return $this->firstname;
81 }
82
86 public function getLastname(): string
87 {
88 return $this->lastname;
89 }
90
94 public function getEmail(): string
95 {
96 return $this->email;
97 }
101 public function getInstitution(): string
102 {
103 return $this->institution;
104 }
105
109 public function getImportId(): string
110 {
111 return $this->uid_hash;
112 }
113
117 public function loadFromObject(): void
118 {
119 $this->login = $this->source->getLogin();
120 $this->firstname = $this->source->getFirstname();
121 $this->lastname = $this->source->getLastname();
122 $this->email = $this->source->getEmail();
123 $this->institution = $this->source->getInstitution();
124 if ($this->source instanceof ilObjUser) {
125 $this->external_account = $this->source->getExternalAccount();
126 $this->auth_mode = $this->source->getAuthMode();
127 }
128 $this->uid_hash = 'il_' . $this->setting->get('inst_id', "0") . '_usr_' . $this->source->getId();
129 }
130
134 public function loadFromGET(): void
135 {
136 //TODO add proper testing for get parameters
137 $this->login = ilUtil::stripSlashes(urldecode($this->source['ecs_login']));
138 $this->firstname = ilUtil::stripSlashes(urldecode($this->source['ecs_firstname']));
139 $this->lastname = ilUtil::stripSlashes(urldecode($this->source['ecs_lastname']));
140 $this->email = ilUtil::stripSlashes(urldecode($this->source['ecs_email']));
141 $this->institution = ilUtil::stripSlashes(urldecode($this->source['ecs_institution']));
142
143 if ($this->source['ecs_uid_hash']) {
144 $this->uid_hash = ilUtil::stripSlashes(urldecode($this->source['ecs_uid_hash']));
145 } elseif ($this->source['ecs_uid']) {
146 $this->uid_hash = ilUtil::stripSlashes(urldecode($this->source['ecs_uid']));
147 }
148 }
149
150 public function toJSON(): string
151 {
152 return urlencode(json_encode($this, JSON_THROW_ON_ERROR));
153 }
154
158 public function toGET(ilECSParticipantSetting $setting): string
159 {
160 $login = '';
161 $external_account_info = '';
162
163 // check for external auth mode
164 $external_auth_modes = $setting->getOutgoingExternalAuthModes();
165 if (in_array($this->auth_mode, $external_auth_modes)) {
166 $placeholder = $setting->getOutgoingUsernamePlaceholderByAuthMode($this->auth_mode);
167 if (stripos($placeholder, ilECSParticipantSetting::LOGIN_PLACEHOLDER) !== false) {
168 $login = str_replace(
170 $this->getLogin(),
171 $placeholder
172 );
173 }
174 if (stripos($placeholder, ilECSParticipantSetting::EXTERNAL_ACCOUNT_PLACEHOLDER) !== false) {
175 $login = str_replace(
177 $this->getExternalAccount(),
178 $placeholder
179 );
180 }
181 $external_account_info = '&ecs_external_account=1';
182 } else {
183 $login = $this->getLogin();
184 }
185 return '&ecs_login=' . urlencode((string) $login) .
186 '&ecs_firstname=' . urlencode($this->firstname) .
187 '&ecs_lastname=' . urlencode($this->lastname) .
188 '&ecs_email=' . urlencode($this->email) .
189 '&ecs_institution=' . urlencode($this->institution) .
190 '&ecs_uid_hash=' . urlencode($this->uid_hash) .
191 $external_account_info;
192 }
193
197 public function toREALM(): string
198 {
199 return
200 $this->login .
201 $this->firstname .
202 $this->lastname .
203 $this->email .
204 $this->institution .
206 }
207}
Stores relevant user data.
string $institution
string $lastname
string $auth_mode
loadFromObject()
load from object
getFirstname()
get firstname
getLastname()
getLastname
getLogin()
get login
ilSetting $setting
string $external_account
loadFromGET()
load user data from GET parameters
toGET(ilECSParticipantSetting $setting)
get GET parameter string
toREALM()
Concatenate all attributes to one string.
getImportId()
get Email
string $uid_hash
__construct($a_data)
getEmail()
get email
getInstitution()
get institution
string $firstname
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28