ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\User\Profile\DataRepository Class Reference
+ Collaboration diagram for ILIAS\User\Profile\DataRepository:

Public Member Functions

 __construct (private readonly \ilDBInterface $db, private readonly ResourceStorage $irss)
 
 getDefault ()
 
 getSingle (int $id)
 
 getMultiple (array $user_ids)
 
 store (Data $user_data)
 
 deleteForFieldIdentifier (string $identifier)
 
 deleteForUser (int $usr_id)
 
 storePasswordFor (int $usr_id, string $password, string $encoding_type, ?string $salt)
 
 storeLoginFor (int $usr_id, string $login)
 

Data Fields

const string USER_VALUES_TABLE = 'usr_profile_data'
 

Private Member Functions

 buildFromData (\stdClass $base_data, array $additional_data)
 
 storeAdditionalFields (Data $user_data)
 

Private Attributes

const string USER_BASE_TABLE = 'usr_data'
 
const string NO_AVATAR_RID = '-'
 

Detailed Description

Definition at line 26 of file DataRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\User\Profile\DataRepository::__construct ( private readonly \ilDBInterface  $db,
private readonly ResourceStorage  $irss 
)

Definition at line 33 of file DataRepository.php.

36 {
37 }

Member Function Documentation

◆ buildFromData()

ILIAS\User\Profile\DataRepository::buildFromData ( \stdClass  $base_data,
array  $additional_data 
)
private

Definition at line 211 of file DataRepository.php.

214 : Data {
215 return (new Data(
216 $base_data->usr_id,
217 $base_data->login,
218 $base_data->rid !== null && $base_data->rid !== self::NO_AVATAR_RID
219 ? $this->irss->manage()->find($base_data->rid)
220 : null,
221 $base_data->firstname ?? '',
222 $base_data->lastname ?? '',
223 $base_data->title ?? '',
224 Genders::tryFrom($base_data->gender ?? ''),
225 $base_data->birthday !== null
226 ? new \DateTimeImmutable($base_data->birthday, new \DateTimeZone('UTC'))
227 : null,
228 $base_data->institution ?? '',
229 $base_data->department ?? '',
230 $base_data->street ?? '',
231 $base_data->city ?? '',
232 $base_data->zipcode ?? '',
233 $base_data->country ?? '',
234 $base_data->email ?? '',
235 $base_data->second_email,
236 $base_data->phone_office ?? '',
237 $base_data->phone_home ?? '',
238 $base_data->phone_mobile ?? '',
239 $base_data->fax ?? '',
240 $base_data->matriculation ?? '',
241 $base_data->hobby ?? '',
242 $base_data->referral_comment ?? '',
243 [
244 'latitude' => $base_data->latitude,
245 'longitude' => $base_data->longitude,
246 'zoom' => $base_data->loc_zoom
247 ],
248 array_reduce(
249 $additional_data,
250 static function (array $c, \stdClass $v): array {
251 if (!array_key_exists($v->field_id, $c)) {
252 $c[$v->field_id] = [];
253 }
254 $c[$v->field_id][] = $v->value;
255 return $c;
256 },
257 []
258 )
260 'last_password_change' => $base_data->last_password_change,
261 'login_attempts' => $base_data->login_attempts,
262 'passwd' => $base_data->passwd,
263 'passwd_salt' => $base_data->passwd_salt,
264 'passwd_enc_type' => $base_data->passwd_enc_type,
265 'passwd_policy_reset' => $base_data->passwd_policy_reset === 1,
266 'client_ip' => $base_data->client_ip ?? '',
267 'last_login' => $base_data->last_login ?? '',
268 'first_login' => $base_data->first_login ?? '',
269 'last_profile_prompt' => $base_data->last_profile_prompt ?? '',
270 'active' => $base_data->active,
271 'approve_date' => $base_data->approve_date,
272 'agree_date' => $base_data->agree_date,
273 'inactivation_date' => $base_data->inactivation_date,
274 'time_limit_owner' => $base_data->time_limit_owner,
275 'time_limit_unlimited' => $base_data->time_limit_unlimited === 1,
276 'time_limit_from' => $base_data->time_limit_from,
277 'time_limit_until' => $base_data->time_limit_until,
278 'profile_incomplete' => $base_data->profile_incomplete === 1,
279 'auth_mode' => $base_data->auth_mode,
280 'ext_account' => $base_data->ext_account,
281 'is_self_registered' => $base_data->is_self_registered === 1,
282 'last_update' => $base_data->last_update ?? '',
283 'create_date' => $base_data->create_date ?? '',
284 ]);
285 }
withSystemInformation(array $system_information)
Definition: Data.php:381
$c
Definition: deliver.php:25

References $c.

Referenced by ILIAS\User\Profile\DataRepository\getMultiple(), and ILIAS\User\Profile\DataRepository\getSingle().

+ Here is the caller graph for this function:

◆ deleteForFieldIdentifier()

ILIAS\User\Profile\DataRepository::deleteForFieldIdentifier ( string  $identifier)

Definition at line 167 of file DataRepository.php.

167 : void
168 {
169 $this->db->manipulateF(
170 'DELETE FROM ' . self::USER_VALUES_TABLE
171 . " WHERE field_id='{$this->db->quote($identifier, \ilDBConstants::T_TEXT)}'"
172 );
173 }

◆ deleteForUser()

ILIAS\User\Profile\DataRepository::deleteForUser ( int  $usr_id)

Definition at line 175 of file DataRepository.php.

175 : void
176 {
177 $this->db->manipulate(
178 'DELETE FROM ' . self::USER_BASE_TABLE
179 . " WHERE usr_id='{$this->db->quote($usr_id, \ilDBConstants::T_INTEGER)}'"
180 );
181 $this->db->manipulate(
182 'DELETE FROM ' . self::USER_VALUES_TABLE
183 . " WHERE usr_id='{$this->db->quote($usr_id, \ilDBConstants::T_INTEGER)}'"
184 );
185 }

◆ getDefault()

ILIAS\User\Profile\DataRepository::getDefault ( )

Definition at line 39 of file DataRepository.php.

39 : Data
40 {
41 return new Data();
42 }

◆ getMultiple()

ILIAS\User\Profile\DataRepository::getMultiple ( array  $user_ids)
Parameters
array<int>$user_ids
Returns
Generator<UserData>

Definition at line 69 of file DataRepository.php.

69 : \Generator
70 {
71 $query = $this->db->query(
72 'SELECT * FROM ' . self::USER_BASE_TABLE
73 . " WHERE {$this->db->in('usr_id', $user_ids)}"
74 );
75
76 $prepared_query = $this->db->prepare('SELECT field_id, value FROM '
77 . self::USER_VALUES_TABLE . ' WHERE usr_id = ?');
78
79 while (($base_data = $this->db->fetchObject($query)) !== null) {
80 yield $this->buildFromData(
81 $base_data,
82 $this->db->fetchAll(
83 $this->db->execute($prepared_query, $base_data->usr_id),
85 )
86 );
87 }
88
89 $this->db->free($prepared_query);
90 }
buildFromData(\stdClass $base_data, array $additional_data)

References ILIAS\User\Profile\DataRepository\buildFromData(), and ilDBConstants\FETCHMODE_OBJECT.

+ Here is the call graph for this function:

◆ getSingle()

ILIAS\User\Profile\DataRepository::getSingle ( int  $id)

Definition at line 44 of file DataRepository.php.

44 : Data
45 {
46 $base_query = $this->db->query(
47 'SELECT * FROM ' . self::USER_BASE_TABLE . " WHERE usr_id={$id}"
48 );
49
50 $additional_query = $this->db->query(
51 'SELECT field_id, value FROM ' . self::USER_VALUES_TABLE . " WHERE usr_id = {$id}"
52 );
53
54 return $this->buildFromData(
55 $this->db->fetchObject($base_query),
56 $this->db->fetchAll(
57 $additional_query,
59 )
60 );
61
62 }

References ILIAS\User\Profile\DataRepository\buildFromData(), and ilDBConstants\FETCHMODE_OBJECT.

+ Here is the call graph for this function:

◆ store()

ILIAS\User\Profile\DataRepository::store ( Data  $user_data)

Definition at line 92 of file DataRepository.php.

92 : void
93 {
94 $system_information = $user_data->getSystemInformation();
95 $this->db->replace(
96 self::USER_BASE_TABLE,
97 [
98 'usr_id' => [
100 $user_data->getId()
101 ]
102 ],
103 [
104 'login' => [\ilDBConstants::T_TEXT, $user_data->getAlias()],
105 'firstname' => [\ilDBConstants::T_TEXT, $user_data->getFirstname()],
106 'lastname' => [\ilDBConstants::T_TEXT, $user_data->getLastname()],
107 'title' => [\ilDBConstants::T_TEXT, $user_data->getTitle()],
108 'gender' => [\ilDBConstants::T_TEXT, $user_data->getGender()?->value],
109 'rid' => [\ilDBConstants::T_TEXT, $user_data->getAvatarRid()?->serialize() ?? self::NO_AVATAR_RID],
110 'email' => [\ilDBConstants::T_TEXT, $user_data->getEmail()],
111 'second_email' => [\ilDBConstants::T_TEXT, $user_data->getSecondEmail()],
112 'hobby' => [\ilDBConstants::T_TEXT, $user_data->getHobby()],
113 'institution' => [\ilDBConstants::T_TEXT, $user_data->getInstitution()],
114 'department' => [\ilDBConstants::T_TEXT, $user_data->getDepartment()],
115 'street' => [\ilDBConstants::T_TEXT, $user_data->getStreet()],
116 'city' => [\ilDBConstants::T_TEXT, $user_data->getCity()],
117 'zipcode' => [\ilDBConstants::T_TEXT, $user_data->getZipcode()],
118 'country' => [\ilDBConstants::T_TEXT, $user_data->getCountry()],
119 'phone_office' => [\ilDBConstants::T_TEXT, $user_data->getPhoneOffice()],
120 'phone_home' => [\ilDBConstants::T_TEXT, $user_data->getPhoneHome()],
121 'phone_mobile' => [\ilDBConstants::T_TEXT, $user_data->getPhoneMobile()],
122 'fax' => [\ilDBConstants::T_TEXT, $user_data->getFax()],
123 'birthday' => [\ilDBConstants::T_DATE, $user_data->getBirthday()?->format('Y-m-d')],
124 'referral_comment' => [\ilDBConstants::T_TEXT, $user_data->getReferralComment()],
125 'matriculation' => [\ilDBConstants::T_TEXT, $user_data->getMatriculation()],
126 'latitude' => [\ilDBConstants::T_TEXT, $user_data->getGeoCoordinates()['latitude'] ?? null],
127 'longitude' => [\ilDBConstants::T_TEXT, $user_data->getGeoCoordinates()['longitude'] ?? null],
128 'loc_zoom' => [\ilDBConstants::T_INTEGER, $user_data->getGeoCoordinates()['zoom'] ?? 0],
129 'last_password_change' => [\ilDBConstants::T_INTEGER, $system_information['last_password_change']],
130 'passwd' => [\ilDBConstants::T_TEXT, $system_information['passwd']],
131 'passwd_salt' => [\ilDBConstants::T_TEXT, $system_information['passwd_salt']],
132 'passwd_enc_type' => [\ilDBConstants::T_TEXT, $system_information['passwd_enc_type']],
133 'passwd_policy_reset' => [\ilDBConstants::T_INTEGER, $system_information['passwd_policy_reset'] ? 1 : 0],
134 'client_ip' => [\ilDBConstants::T_TEXT, $system_information['client_ip']],
135 'last_login' => [
137 $system_information['last_login'] !== '' ? $system_information['last_login'] : null
138 ],
139 'first_login' => [
141 $system_information['first_login'] !== '' ? $system_information['first_login'] : null
142 ],
143 'last_profile_prompt' => [
145 $system_information['last_profile_prompt'] !== '' ? $system_information['last_profile_prompt'] : null
146 ],
147 'active' => [\ilDBConstants::T_INTEGER, $system_information['active']],
148 'approve_date' => [\ilDBConstants::T_TIMESTAMP, $system_information['approve_date']],
149 'agree_date' => [\ilDBConstants::T_TIMESTAMP, $system_information['agree_date']],
150 'inactivation_date' => [\ilDBConstants::T_TIMESTAMP, $system_information['inactivation_date']],
151 'time_limit_owner' => [\ilDBConstants::T_INTEGER, $system_information['time_limit_owner']],
152 'time_limit_unlimited' => [\ilDBConstants::T_INTEGER, $system_information['time_limit_unlimited'] ? 1 : 0],
153 'time_limit_from' => [\ilDBConstants::T_INTEGER, $system_information['time_limit_from']],
154 'time_limit_until' => [\ilDBConstants::T_INTEGER, $system_information['time_limit_until']],
155 'profile_incomplete' => [\ilDBConstants::T_INTEGER, $system_information['profile_incomplete']],
156 'auth_mode' => [\ilDBConstants::T_TEXT, $system_information['auth_mode']],
157 'ext_account' => [\ilDBConstants::T_TEXT, $system_information['ext_account']],
158 'is_self_registered' => [\ilDBConstants::T_INTEGER, $system_information['is_self_registered'] ? 1 : 0],
159 'last_update' => [\ilDBConstants::T_TIMESTAMP, date('Y-m-d H:i:s')],
160 'create_date' => [\ilDBConstants::T_TIMESTAMP, $system_information['create_date']],
161 ]
162 );
163
164 $this->storeAdditionalFields($user_data);
165 }

References ILIAS\User\Profile\Data\getAlias(), ILIAS\User\Profile\Data\getAvatarRid(), ILIAS\User\Profile\Data\getBirthday(), ILIAS\User\Profile\Data\getCity(), ILIAS\User\Profile\Data\getCountry(), ILIAS\User\Profile\Data\getDepartment(), ILIAS\User\Profile\Data\getEmail(), ILIAS\User\Profile\Data\getFax(), ILIAS\User\Profile\Data\getFirstname(), ILIAS\User\Profile\Data\getGender(), ILIAS\User\Profile\Data\getGeoCoordinates(), ILIAS\User\Profile\Data\getHobby(), ILIAS\User\Profile\Data\getId(), ILIAS\User\Profile\Data\getInstitution(), ILIAS\User\Profile\Data\getLastname(), ILIAS\User\Profile\Data\getMatriculation(), ILIAS\User\Profile\Data\getPhoneHome(), ILIAS\User\Profile\Data\getPhoneMobile(), ILIAS\User\Profile\Data\getPhoneOffice(), ILIAS\User\Profile\Data\getReferralComment(), ILIAS\User\Profile\Data\getSecondEmail(), ILIAS\User\Profile\Data\getStreet(), ILIAS\User\Profile\Data\getSystemInformation(), ILIAS\User\Profile\Data\getTitle(), ILIAS\User\Profile\Data\getZipcode(), ILIAS\User\Profile\DataRepository\storeAdditionalFields(), ilDBConstants\T_DATE, ilDBConstants\T_INTEGER, ilDBConstants\T_TEXT, and ilDBConstants\T_TIMESTAMP.

+ Here is the call graph for this function:

◆ storeAdditionalFields()

ILIAS\User\Profile\DataRepository::storeAdditionalFields ( Data  $user_data)
private

Definition at line 287 of file DataRepository.php.

287 : void
288 {
289 $this->db->manipulate(
290 'DELETE FROM ' . self::USER_VALUES_TABLE
291 . " WHERE usr_id = {$user_data->getId()}"
292 );
293
294 $values_for_storage = $user_data->getAdditionalFieldsStorageValues($this->db);
295 if ($values_for_storage === '') {
296 return;
297 }
298
299 $this->db->manipulate(
300 'INSERT INTO ' . self::USER_VALUES_TABLE . ' (usr_id, field_id, value) '
301 . 'VALUES ' . $values_for_storage
302 );
303 }
getAdditionalFieldsStorageValues(\ilDBInterface $db)
Definition: Data.php:359

References ILIAS\User\Profile\Data\getAdditionalFieldsStorageValues().

Referenced by ILIAS\User\Profile\DataRepository\store().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeLoginFor()

ILIAS\User\Profile\DataRepository::storeLoginFor ( int  $usr_id,
string  $login 
)

Definition at line 200 of file DataRepository.php.

203 : void {
204 $this->db->manipulateF(
205 'UPDATE usr_data SET login = %s WHERE usr_id = %s',
207 [$login, $usr_id]
208 );
209 }

◆ storePasswordFor()

ILIAS\User\Profile\DataRepository::storePasswordFor ( int  $usr_id,
string  $password,
string  $encoding_type,
?string  $salt 
)

Definition at line 187 of file DataRepository.php.

192 : void {
193 $this->db->manipulateF(
194 'UPDATE usr_data SET passwd = %s, passwd_enc_type = %s, passwd_salt = %s WHERE usr_id = %s',
196 [$password, $encoding_type, $salt, $usr_id]
197 );
198 }

Field Documentation

◆ NO_AVATAR_RID

const string ILIAS\User\Profile\DataRepository::NO_AVATAR_RID = '-'
private

Definition at line 31 of file DataRepository.php.

◆ USER_BASE_TABLE

const string ILIAS\User\Profile\DataRepository::USER_BASE_TABLE = 'usr_data'
private

Definition at line 28 of file DataRepository.php.

◆ USER_VALUES_TABLE

const string ILIAS\User\Profile\DataRepository::USER_VALUES_TABLE = 'usr_profile_data'

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