19declare(strict_types=1);
46 'second_email' => false
62 $base_query = $this->db->query(
63 'SELECT * FROM ' . self::USER_BASE_TABLE .
" WHERE usr_id={$id}"
66 $additional_query = $this->db->query(
67 'SELECT field_id, value FROM ' . self::USER_VALUES_TABLE .
" WHERE usr_id = {$id}"
70 $base_data = $this->db->fetchObject($base_query);
71 if ($base_data ===
null) {
72 throw \InvalidArgumentException(
73 'This user does not exist.'
89 $query = $this->db->query(
90 'SELECT * FROM ' . self::USER_BASE_TABLE
91 .
" WHERE {$this->db->in('usr_id', $user_ids, false, \ilDBConstants::T_INTEGER)}"
94 $prepared_query = $this->db->prepare(
'SELECT field_id, value FROM '
95 . self::USER_VALUES_TABLE .
' WHERE usr_id = ?');
97 while (($base_data = $this->db->fetchObject($query)) !==
null) {
101 $this->db->execute($prepared_query, [$base_data->usr_id]),
107 $this->db->free($prepared_query);
114 self::USER_BASE_TABLE,
155 $system_information[
'last_login'] !==
'' ? $system_information[
'last_login'] :
null
159 $system_information[
'first_login'] !==
'' ? $system_information[
'first_login'] :
null
161 'last_profile_prompt' => [
163 $system_information[
'last_profile_prompt'] !==
'' ? $system_information[
'last_profile_prompt'] :
null
181 $system_information[
'last_visited'] === [] ?
null : serialize($system_information[
'last_visited'])
191 $this->db->manipulateF(
192 'DELETE FROM ' . self::USER_VALUES_TABLE
193 .
" WHERE field_id='{$this->db->quote($identifier, \ilDBConstants::T_TEXT)}'"
199 $this->db->manipulate(
200 'DELETE FROM ' . self::USER_BASE_TABLE
201 .
" WHERE usr_id='{$this->db->quote($usr_id, \ilDBConstants::T_INTEGER)}'"
203 $this->db->manipulate(
204 'DELETE FROM ' . self::USER_VALUES_TABLE
205 .
" WHERE usr_id='{$this->db->quote($usr_id, \ilDBConstants::T_INTEGER)}'"
212 string $encoding_type,
215 $this->db->manipulateF(
217 .
'passwd_enc_type = %s, passwd_salt = %s WHERE usr_id = %s',
219 [$password, $encoding_type, $salt, $usr_id]
227 $this->db->manipulateF(
228 'UPDATE ' . self::USER_BASE_TABLE .
' SET login = %s WHERE usr_id = %s',
238 $this->db->manipulateF(
239 'UPDATE ' . self::USER_BASE_TABLE .
' SET last_visited = %s WHERE usr_id = %s',
242 $last_visited === [] ? null : serialize($last_visited),
252 SettingsDataRepository $settings_data_repository,
253 ProfileFieldsConfigurationRepository $profile_fields_config_repo,
256 $where = $this->buildSearchUsersWhereString(
257 $profile_fields_config_repo,
261 if ($where ===
null) {
265 $query = $this->db->query(
266 $settings_data_repository->getSearchSelectConditionalOnVisibility(
267 self::USER_BASE_TABLE,
268 ...array_keys(self::SEARCH_FIELDS)
274 while (($row = $this->db->fetchObject($query)) !==
null) {
277 $row->lastname ??
'',
278 $row->firstname ??
'',
290 self::USER_BASE_TABLE,
291 self::USER_VALUES_TABLE,
304 $prepared_query = $query->withAdditionalSelectAndJoinForUdfAndMultiValueFields();
305 $cnt = $this->db->fetchObject(
306 $this->db->query($prepared_query->buildCntQueryString())
309 if ($offset >= $cnt) {
313 $this->db->setLimit($limit, $offset);
317 'set' => $this->retrieveRecordsFromQuery($prepared_query)
322 \stdClass $base_data,
323 array $additional_data
328 $base_data->rid !== null && $base_data->rid !== self::NO_AVATAR_RID
329 ? $this->irss->manage()->find($base_data->rid)
331 $base_data->firstname ??
'',
332 $base_data->lastname ??
'',
333 $base_data->title ??
'',
334 Genders::tryFrom($base_data->gender ??
''),
335 $base_data->birthday !== null
336 ? new \DateTimeImmutable($base_data->birthday, new \DateTimeZone(
'UTC'))
338 $base_data->institution ??
'',
339 $base_data->department ??
'',
340 $base_data->street ??
'',
341 $base_data->city ??
'',
342 $base_data->zipcode ??
'',
343 $base_data->country ??
'',
344 $base_data->email ??
'',
345 $base_data->second_email,
346 $base_data->phone_office ??
'',
347 $base_data->phone_home ??
'',
348 $base_data->phone_mobile ??
'',
349 $base_data->fax ??
'',
350 $base_data->matriculation ??
'',
351 $base_data->hobby ??
'',
352 $base_data->referral_comment ??
'',
354 'latitude' => $base_data->latitude,
355 'longitude' => $base_data->longitude,
356 'zoom' => $base_data->loc_zoom
360 static function (array
$c, \stdClass $v): array {
361 if (!array_key_exists($v->field_id,
$c)) {
362 $c[$v->field_id] = [];
364 $c[$v->field_id][] = $v->value;
369 ))->withSystemInformation([
370 'last_password_change' => $base_data->last_password_change,
371 'login_attempts' => $base_data->login_attempts,
372 'passwd' => $base_data->passwd,
373 'passwd_salt' => $base_data->passwd_salt,
374 'passwd_enc_type' => $base_data->passwd_enc_type,
375 'passwd_policy_reset' => $base_data->passwd_policy_reset === 1,
376 'client_ip' => $base_data->client_ip ??
'',
377 'last_login' => $base_data->last_login ??
'',
378 'first_login' => $base_data->first_login ??
'',
379 'last_profile_prompt' => $base_data->last_profile_prompt ??
'',
380 'active' => $base_data->active,
381 'approve_date' => $base_data->approve_date,
382 'agree_date' => $base_data->agree_date,
383 'inactivation_date' => $base_data->inactivation_date,
384 'time_limit_owner' => $base_data->time_limit_owner,
385 'time_limit_unlimited' => $base_data->time_limit_unlimited === 1,
386 'time_limit_from' => $base_data->time_limit_from,
387 'time_limit_until' => $base_data->time_limit_until,
388 'profile_incomplete' => $base_data->profile_incomplete === 1,
389 'auth_mode' => $base_data->auth_mode,
390 'ext_account' => $base_data->ext_account,
391 'is_self_registered' => $base_data->is_self_registered === 1,
392 'last_update' => $base_data->last_update ??
'',
393 'create_date' => $base_data->create_date ??
'',
394 'last_visited' => $this->buildLastVisited($base_data->last_visited)
400 $this->db->manipulate(
401 'DELETE FROM ' . self::USER_VALUES_TABLE
402 .
" WHERE usr_id = {$user_data->getId()}"
406 if ($values_for_storage ===
'') {
410 $this->db->manipulate(
411 'INSERT INTO ' . self::USER_VALUES_TABLE .
' (usr_id, field_id, value) '
412 .
'VALUES ' . $values_for_storage
417 ProfileFieldsConfigurationRepository $profile_fields_config_repo,
420 $available_fields = array_filter(
421 $this->getSearchFieldsWithAvailability(
422 $profile_fields_config_repo,
427 if ($available_fields === []) {
431 $outer_conditions = [];
436 $outer_conditions[] = $this->db->in(
444 $outer_conditions[] =
'(' . implode(
448 array_keys($available_fields)
452 return ' WHERE ' . implode(
' AND ', $outer_conditions);
456 ProfileFieldsConfigurationRepository $profile_fields_config_repo,
459 $search_term = $autocomplete_query->getSearchTermQueryString();
467 'login' => $search_term_long_enough ? $search_term :
null,
468 'firstname' => $profile_fields_config_repo->getByClass(FirstName::class)->isSearchable()
470 ? $firstname_term :
null,
471 'lastname' => $profile_fields_config_repo->getByClass(LastName::class)->isSearchable()
474 'email' => $profile_fields_config_repo->getByClass(Email::class)->isSearchable()
475 && $search_term_long_enough
477 'second_email' => $profile_fields_config_repo->getByClass(SecondEmail::class)->isSearchable()
478 && $search_term_long_enough
486 if ($last_visited ===
null) {
490 $unserialized = unserialize($last_visited, [
'allowed_classes' =>
false]);
492 if (!is_array($unserialized)) {
496 return $unserialized;
504 while (($row = $this->db->fetchAssoc($statement)) !==
null) {
505 $row[
'usr_id'] = (
int) $row[
'usr_id'];
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
buildRecordsQueryString()
explodeArrayValues(array $row)
getAdditionalFieldsStorageValues(\ilDBInterface $db)
searchUsers(SettingsDataRepository $settings_data_repository, ProfileFieldsConfigurationRepository $profile_fields_config_repo, AutocompleteQuery $autocomplete_query)
__construct(private readonly \ilDBInterface $db, private readonly ResourceStorage $irss)
getMultiple(array $user_ids)
getProfileDataQuery(array $select_fields)
const string NO_AVATAR_RID
getSearchFieldsWithAvailability(ProfileFieldsConfigurationRepository $profile_fields_config_repo, AutocompleteQuery $autocomplete_query)
const string USER_BASE_TABLE
deleteForFieldIdentifier(string $identifier)
buildLastVisited(?string $last_visited)
buildSearchUsersWhereString(ProfileFieldsConfigurationRepository $profile_fields_config_repo, AutocompleteQuery $autocomplete_query)
const string USER_VALUES_TABLE
storeLastVisitedFor(int $usr_id, array $last_visited)
getCountAndRecordsForQuery(DataQuery $query, int $offset, int $limit)
retrieveRecordsFromQuery(DataQuery $query)
storeLoginFor(int $usr_id, string $login)
deleteForUser(int $usr_id)
const array SEARCH_FIELDS
buildFromData(\stdClass $base_data, array $additional_data)
storePasswordFor(int $usr_id, string $password, string $encoding_type, ?string $salt)
storeAdditionalFields(Data $user_data)
This class provides some pre-processing for search terms provided by a user when searching for users.
getFirstnameQueryString()
getUnprocessedSearchTerm()
The returned search term might contain wild cards or any other input.
checkSearchTermLength(?string $search_term)
getSearchTermQueryString()
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))