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}"
71 $this->db->fetchObject($base_query),
82 $query = $this->db->query(
83 'SELECT * FROM ' . self::USER_BASE_TABLE
84 .
" WHERE {$this->db->in('usr_id', $user_ids, false, \ilDBConstants::T_INTEGER)}"
87 $prepared_query = $this->db->prepare(
'SELECT field_id, value FROM '
88 . self::USER_VALUES_TABLE .
' WHERE usr_id = ?');
90 while (($base_data = $this->db->fetchObject($query)) !==
null) {
94 $this->db->execute($prepared_query, [$base_data->usr_id]),
100 $this->db->free($prepared_query);
107 self::USER_BASE_TABLE,
148 $system_information[
'last_login'] !==
'' ? $system_information[
'last_login'] :
null
152 $system_information[
'first_login'] !==
'' ? $system_information[
'first_login'] :
null
154 'last_profile_prompt' => [
156 $system_information[
'last_profile_prompt'] !==
'' ? $system_information[
'last_profile_prompt'] :
null
174 $system_information[
'last_visited'] === [] ?
null : serialize($system_information[
'last_visited'])
184 $this->db->manipulateF(
185 'DELETE FROM ' . self::USER_VALUES_TABLE
186 .
" WHERE field_id='{$this->db->quote($identifier, \ilDBConstants::T_TEXT)}'"
192 $this->db->manipulate(
193 'DELETE FROM ' . self::USER_BASE_TABLE
194 .
" WHERE usr_id='{$this->db->quote($usr_id, \ilDBConstants::T_INTEGER)}'"
196 $this->db->manipulate(
197 'DELETE FROM ' . self::USER_VALUES_TABLE
198 .
" WHERE usr_id='{$this->db->quote($usr_id, \ilDBConstants::T_INTEGER)}'"
205 string $encoding_type,
208 $this->db->manipulateF(
210 .
'passwd_enc_type = %s, passwd_salt = %s WHERE usr_id = %s',
212 [$password, $encoding_type, $salt, $usr_id]
220 $this->db->manipulateF(
221 'UPDATE ' . self::USER_BASE_TABLE .
' SET login = %s WHERE usr_id = %s',
231 $this->db->manipulateF(
232 'UPDATE ' . self::USER_BASE_TABLE .
' SET last_visited = %s WHERE usr_id = %s',
235 $last_visited === [] ? null : serialize($last_visited),
245 SettingsDataRepository $settings_data_repository,
246 ProfileFieldsConfigurationRepository $profile_fields_config_repo,
249 $where = $this->buildSearchUsersWhereString(
250 $profile_fields_config_repo,
254 if ($where ===
null) {
258 $query = $this->db->query(
259 $settings_data_repository->getSearchSelectConditionalOnVisibility(
260 self::USER_BASE_TABLE,
261 ...array_keys(self::SEARCH_FIELDS)
267 while (($row = $this->db->fetchObject($query)) !==
null) {
270 $row->lastname ??
'',
271 $row->firstname ??
'',
279 \stdClass $base_data,
280 array $additional_data
285 $base_data->rid !== null && $base_data->rid !== self::NO_AVATAR_RID
286 ? $this->irss->manage()->find($base_data->rid)
288 $base_data->firstname ??
'',
289 $base_data->lastname ??
'',
290 $base_data->title ??
'',
291 Genders::tryFrom($base_data->gender ??
''),
292 $base_data->birthday !== null
293 ? new \DateTimeImmutable($base_data->birthday, new \DateTimeZone(
'UTC'))
295 $base_data->institution ??
'',
296 $base_data->department ??
'',
297 $base_data->street ??
'',
298 $base_data->city ??
'',
299 $base_data->zipcode ??
'',
300 $base_data->country ??
'',
301 $base_data->email ??
'',
302 $base_data->second_email,
303 $base_data->phone_office ??
'',
304 $base_data->phone_home ??
'',
305 $base_data->phone_mobile ??
'',
306 $base_data->fax ??
'',
307 $base_data->matriculation ??
'',
308 $base_data->hobby ??
'',
309 $base_data->referral_comment ??
'',
311 'latitude' => $base_data->latitude,
312 'longitude' => $base_data->longitude,
313 'zoom' => $base_data->loc_zoom
317 static function (array
$c, \stdClass $v): array {
318 if (!array_key_exists($v->field_id,
$c)) {
319 $c[$v->field_id] = [];
321 $c[$v->field_id][] = $v->value;
326 ))->withSystemInformation([
327 'last_password_change' => $base_data->last_password_change,
328 'login_attempts' => $base_data->login_attempts,
329 'passwd' => $base_data->passwd,
330 'passwd_salt' => $base_data->passwd_salt,
331 'passwd_enc_type' => $base_data->passwd_enc_type,
332 'passwd_policy_reset' => $base_data->passwd_policy_reset === 1,
333 'client_ip' => $base_data->client_ip ??
'',
334 'last_login' => $base_data->last_login ??
'',
335 'first_login' => $base_data->first_login ??
'',
336 'last_profile_prompt' => $base_data->last_profile_prompt ??
'',
337 'active' => $base_data->active,
338 'approve_date' => $base_data->approve_date,
339 'agree_date' => $base_data->agree_date,
340 'inactivation_date' => $base_data->inactivation_date,
341 'time_limit_owner' => $base_data->time_limit_owner,
342 'time_limit_unlimited' => $base_data->time_limit_unlimited === 1,
343 'time_limit_from' => $base_data->time_limit_from,
344 'time_limit_until' => $base_data->time_limit_until,
345 'profile_incomplete' => $base_data->profile_incomplete === 1,
346 'auth_mode' => $base_data->auth_mode,
347 'ext_account' => $base_data->ext_account,
348 'is_self_registered' => $base_data->is_self_registered === 1,
349 'last_update' => $base_data->last_update ??
'',
350 'create_date' => $base_data->create_date ??
'',
351 'last_visited' => $base_data->last_visited ===
null
353 : unserialize($base_data->last_visited, [
'allowed_classes' =>
false])
359 $this->db->manipulate(
360 'DELETE FROM ' . self::USER_VALUES_TABLE
361 .
" WHERE usr_id = {$user_data->getId()}"
365 if ($values_for_storage ===
'') {
369 $this->db->manipulate(
370 'INSERT INTO ' . self::USER_VALUES_TABLE .
' (usr_id, field_id, value) '
371 .
'VALUES ' . $values_for_storage
376 ProfileFieldsConfigurationRepository $profile_fields_config_repo,
379 $available_fields = array_filter(
380 $this->getSearchFieldsWithAvailability(
381 $profile_fields_config_repo,
386 if ($available_fields === []) {
390 $outer_conditions = [];
395 $outer_conditions[] = $this->db->in(
403 $outer_conditions[] =
'(' . implode(
407 array_keys($available_fields)
411 return ' WHERE ' . implode(
' AND ', $outer_conditions);
415 ProfileFieldsConfigurationRepository $profile_fields_config_repo,
418 $search_term = $autocomplete_query->getSearchTermQueryString();
426 'login' => $search_term_long_enough ? $search_term :
null,
427 'firstname' => $profile_fields_config_repo->getByClass(FirstName::class)->isSearchable()
429 ? $firstname_term :
null,
430 'lastname' => $profile_fields_config_repo->getByClass(LastName::class)->isSearchable()
433 'email' => $profile_fields_config_repo->getByClass(Email::class)->isSearchable()
434 && $search_term_long_enough
436 'second_email' => $profile_fields_config_repo->getByClass(SecondEmail::class)->isSearchable()
437 && $search_term_long_enough
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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)
const string NO_AVATAR_RID
getSearchFieldsWithAvailability(ProfileFieldsConfigurationRepository $profile_fields_config_repo, AutocompleteQuery $autocomplete_query)
const string USER_BASE_TABLE
deleteForFieldIdentifier(string $identifier)
buildSearchUsersWhereString(ProfileFieldsConfigurationRepository $profile_fields_config_repo, AutocompleteQuery $autocomplete_query)
const string USER_VALUES_TABLE
storeLastVisitedFor(int $usr_id, array $last_visited)
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'))