98 bool $a_call_by_reference =
false
101 $this->irss =
$DIC[
'resource_storage'];
102 $this->ilias_settings =
$DIC[
'ilSetting'];
103 $this->auth_session =
$DIC[
'ilAuthSession'];
104 $this->
ctrl = $DIC[
'ilCtrl'];
105 $this->app_event_handler =
$DIC[
'ilAppEventHandler'];
106 $this->delivery =
$DIC[
'file_delivery']->delivery();
108 if (defined(
'USER_FOLDER_ID')) {
112 $local_dic = LocalDIC::dic();
113 $this->profile_data_repository = $local_dic[ProfileDataRepository::class];
114 $this->profile_data = $this->profile_data_repository->getDefault();
115 $this->profile_configuration_repository = $local_dic[ProfileConfigurationRepository::class];
116 $this->settings_data_repository = $local_dic[SettingsDataRepository::class];
118 $this->data_factory = (
new DataFactory());
125 $this->auth_mode =
'default';
127 if ($a_user_id > 0) {
128 $this->
setId($a_user_id);
133 $this->user_settings = [];
134 $this->user_settings[
'language'] = $this->
ilias->ini->readVariable(
'language',
'default');
135 $this->user_settings[
'skin'] = $this->
ilias->ini->readVariable(
'layout',
'skin');
136 $this->user_settings[
'style'] = $this->
ilias->ini->readVariable(
'layout',
'style');
146 $this->profile_data = $this->profile_data_repository->getSingle($this->
id);
157 $this->inactivation_date =
null;
158 if ($this->active === 0) {
159 $this->inactivation_date = date(
'Y-m-d H:i:s');
163 $system_information[
'create_date'] = $this->data_factory->clock()->utc()->now()
164 ->format(self::DATABASE_DATE_FORMAT);
166 $this->profile_data = $this->profile_data->withId($this->
id);
167 $this->profile_data_repository->store(
168 $this->profile_data->withSystemInformation($this->buildSystemInformationArrayForDB())
173 $mbox->createDefaultFolder();
176 $mail_options->createMailOptionsEntry();
178 $this->app_event_handler->raise(
179 'components/ILIAS/User',
181 [
'user_obj' => $this]
187 $this->profile_data_repository->store(
188 $this->profile_data->withSystemInformation($this->buildSystemInformationArrayForDB())
198 $this->app_event_handler->raise(
199 'components/ILIAS/User',
201 [
'user_obj' => $this]
209 if (!empty(
$data[
'passwd'])) {
210 $this->
setPasswd($data[
'passwd'], self::PASSWD_CRYPTED);
213 $this->password_salt =
$data[
'passwd_salt'];
214 $this->password_encoding_type =
$data[
'passwd_enc_type'];
215 $this->last_password_change_ts =
$data[
'last_password_change'];
216 $this->login_attempts =
$data[
'login_attempts'];
217 $this->passwd_policy_reset =
$data[
'passwd_policy_reset'];
218 $this->client_ip =
$data[
'client_ip'];
219 $this->last_login =
$data[
'last_login'];
220 $this->first_login =
$data[
'first_login'];
221 $this->last_profile_prompt =
$data[
'last_profile_prompt'];
222 $this->last_update =
$data[
'last_update'];
223 $this->create_date =
$data[
'create_date'];
224 $this->approve_date =
$data[
'approve_date'];
225 $this->active =
$data[
'active'];
226 $this->agree_date =
$data[
'agree_date'];
227 $this->inactivation_date =
$data[
'inactivation_date'];
229 $this->time_limit_owner =
$data[
'time_limit_owner'];
230 $this->time_limit_unlimited =
$data[
'time_limit_unlimited'];
231 $this->time_limit_from =
$data[
'time_limit_from'];
232 $this->time_limit_until =
$data[
'time_limit_until'];
234 $this->profile_incomplete =
$data[
'profile_incomplete'];
236 $this->auth_mode =
$data[
'auth_mode'];
237 $this->ext_account =
$data[
'ext_account'] ??
'';
238 $this->is_self_registered =
$data[
'is_self_registered'];
239 $this->last_visited =
$data[
'last_visited'];
265 'ext_account' => $this->ext_account ??
'',
275 if ($this->passwd_type === self::PASSWD_PLAIN
276 && $this->passwd !==
'') {
277 LocalUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
285 if (is_string($this->agree_date && strtotime($this->agree_date) ===
false)) {
293 LocalUserPasswordManager::getInstance()->encodePassword($this, $new_raw_password);
294 $this->profile_data_repository->storePasswordFor(
297 $this->password_encoding_type,
305 $this->db->setLimit(1, 0);
306 $res = $this->db->queryF(
308 SELECT login, history_date FROM loginname_history
309 WHERE usr_id = %s ORDER BY history_date DESC',
313 $row = $this->db->fetchAssoc(
$res);
326 if ($login ===
'' || $login === $this->profile_data->getAlias()) {
332 if (!$context->isFieldChangeable(
333 $this->profile_configuration_repository->getByClass(Alias::class),
340 if ($this->ilias_settings->get(
'reuse_of_loginnames') ===
'0'
341 && self::_doesLoginnameExistInHistory($login)) {
345 if ((
int) $this->ilias_settings->get(
'loginname_change_blocking_time') > 0
346 && is_array($last_history_entry)
347 && $last_history_entry[1] + (
int) $this->ilias_settings->get(
'loginname_change_blocking_time') > time()) {
350 $this->
lng->txt(
'changing_loginname_not_possible_info'),
355 new ilDateTime(($last_history_entry[1] + (
int) $this->ilias_settings->get(
'loginname_change_blocking_time')),
IL_CAL_UNIX)
361 if ($this->ilias_settings->get(
'create_history_loginname') ===
'1') {
365 $this->profile_data = $this->profile_data->withAlias($login);
366 $this->profile_data_repository->storeLoginFor($this->
id, $this->profile_data->getAlias());
373 $res = $this->db->queryF(
374 'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
375 [
'integer',
'text',
'integer'],
376 [$this->
id, $login, time()]
379 if ($this->db->numRows(
$res) == 0) {
380 $this->db->manipulateF(
382 INSERT INTO loginname_history
383 (usr_id, login, history_date)
384 VALUES (%s, %s, %s)',
385 [
'integer',
'text',
'integer'],
386 [$this->
id, $login, time()]
395 $this->settings_data_repository->storeSingleFor($this->
id, $key, $value);
401 $this->settings_data_repository->deleteSingleFor($this->
id, $key);
402 unset($this->user_settings[$key]);
407 $this->settings_data_repository->deleteFor($this->
id);
408 $this->settings_data_repository->storeFor($this->
id, $this->user_settings);
413 $tz = $this->getPref(
'user_tz');
422 $format = $this->getPref(
'time_format');
423 if ($format !==
null) {
431 $format = $this->getPref(
'date_format');
432 if ($format ===
null) {
436 return match ((
int) $format) {
440 default => $this->data_factory->dateFormat()->standard()
447 return $this->data_factory->dateFormat()->withTime24($this->getDateFormat());
449 return $this->data_factory->dateFormat()->withTime12($this->getDateFormat());
452 public function setPref(
string $a_keyword, ?
string $a_value): void
454 if ($a_keyword !==
'') {
455 $this->user_settings[$a_keyword] = $a_value;
459 public function getPref(
string $keyword): ?string
461 return $this->user_settings[$keyword] ??
null;
469 return $this->user_settings;
474 $this->user_settings = $this->settings_data_repository->getFor($this->
id);
475 if (!isset($this->user_settings[
'style'])
476 || $this->user_settings[
'style'] ===
''
480 $this->user_settings[
'skin'] = $this->
ilias->ini->readVariable(
'layout',
'skin');
481 $this->user_settings[
'style'] = $this->
ilias->ini->readVariable(
'layout',
'style');
485 public function delete():
bool
487 $this->app_event_handler->raise(
490 [
'usr_id' => $this->
getId()]
503 $DIC[
'rbacadmin']->removeUser($this->
getId());
508 $mailbox->updateMailsOfDeletedUser($this->getLogin());
519 $this->cron_delete_user_reminder_mail->removeSingleUserFromTable($this->
getId());
521 $this->clipboardDeleteAll();
523 $this->settings_data_repository->deleteFor($this->
id);
524 $this->removeUserPicture();
525 $this->profile_data_repository->deleteForUser($this->
getId());
535 $clone = clone $this;
536 $clone->profile_data = $profile_data;
542 return $this->profile_data;
547 $this->profile_data = $this->profile_data->withAlias($login);
552 return $this->profile_data->getAlias();
557 $this->profile_data = $this->profile_data->withGender(Genders::tryFrom($gender_string));
562 return $this->profile_data->getGender()?->value ??
'';
570 $this->setFullname();
571 $this->profile_data = $this->profile_data->withTitle($user_title);
576 return $this->profile_data->getTitle();
581 $this->profile_data = $this->profile_data->withFirstname($firstname);
582 $this->setFullname();
587 return $this->profile_data->getFirstname();
592 $this->profile_data = $this->profile_data->withLastname($lastname);
593 $this->setFullname();
598 return $this->profile_data->getLastname();
603 if ($birthday ===
null || $birthday ===
'') {
604 $this->profile_data = $this->profile_data->withBirthday(
null);
608 $this->profile_data = $this->profile_data->withBirthday(
609 new \DateTimeImmutable($birthday,
new DateTimeZone(
'UTC'))
615 return $this->profile_data->getBirthday()?->format(
'Y-m-d');
620 $this->profile_data = $this->profile_data->withInstitution($instituion);
625 return $this->profile_data->getInstitution();
630 $this->profile_data = $this->profile_data->withDepartment($department);
635 return $this->profile_data->getDepartment();
640 $this->profile_data = $this->profile_data->withStreet($street);
645 return $this->profile_data->getStreet();
650 $this->profile_data = $this->profile_data->withCity($city);
655 return $this->profile_data->getCity();
660 $this->profile_data = $this->profile_data->withZipcode($zipcode);
665 return $this->profile_data->getZipcode();
670 $this->profile_data = $this->profile_data->withCountry($country);
675 return $this->profile_data->getCountry();
680 $this->profile_data = $this->profile_data->withPhoneOffice($phone);
685 return $this->profile_data->getPhoneOffice();
690 $this->profile_data = $this->profile_data->withPhoneHome($phone);
695 return $this->profile_data->getPhoneHome();
700 $this->profile_data = $this->profile_data->withPhoneMobile($phone);
705 return $this->profile_data->getPhoneMobile();
708 public function setFax(
string $fax): void
710 $this->profile_data = $this->profile_data->withFax($fax);
715 return $this->profile_data->getFax();
720 $this->profile_data = $this->profile_data->withMatriculation($matriculation);
725 return $this->profile_data->getMatriculation();
730 $this->profile_data = $this->profile_data->withEmail($email);
735 return $this->profile_data->getEmail();
740 $this->profile_data = $this->profile_data->withSecondEmail($email);
745 return $this->profile_data->getSecondEmail();
750 $this->profile_data = $this->profile_data->withHobby($hobby);
755 return $this->profile_data->getHobby();
760 $this->profile_data = $this->profile_data->withReferralComment($referral_comment);
765 return $this->profile_data->getReferralComment();
770 $coordinates = $this->profile_data->getGeoCoordinates();
771 $coordinates[
'latitude'] = $latitude;
772 $this->profile_data = $this->profile_data->withGeoCoordinates($coordinates);
777 return $this->profile_data->getGeoCoordinates()[
'latitude'] ??
null;
782 $coordinates = $this->profile_data->getGeoCoordinates();
783 $coordinates[
'longitude'] = $longitude;
784 $this->profile_data = $this->profile_data->withGeoCoordinates($coordinates);
789 return $this->profile_data->getGeoCoordinates()[
'longitude'] ??
null;
794 $coordinates = $this->profile_data->getGeoCoordinates();
795 $coordinates[
'zoom'] = $zoom;
796 $this->profile_data = $this->profile_data->withGeoCoordinates($coordinates);
801 return $this->profile_data->getGeoCoordinates()[
'zoom'] ??
null;
806 return $this->profile_data->getAvatarRid();
811 $this->profile_data = $this->profile_data->withAvatarRid($avatar_rid);
816 $this->client_ip = $a_str;
821 return $this->client_ip;
826 $this->setPref(
'language', $language);
832 return $this->user_settings[
'language'] ??
'';
837 return $this->password_encoding_type;
842 $this->password_encoding_type = $password_encryption_type;
847 return $this->password_salt;
852 $this->password_salt = $password_salt;
857 $title = $this->profile_data->getTitle() !==
'' ?
"{$this->profile_data->getTitle()} " :
'';
858 $this->fullname =
"{$title}{$this->profile_data->getFirstname()} {$this->profile_data->getLastname()}";
875 if ($max_strlen === 0) {
879 if (mb_strlen($this->fullname) <= $max_strlen) {
883 $length_lastname = mb_strlen($this->lastname);
884 if (mb_strlen($this->utitle) + $length_lastname + 4 <= $max_strlen) {
885 return ilUtil::stripSlashes($this->utitle .
' ' . substr($this->firstname, 0, 1) .
'. ' . $this->lastname);
888 if (mb_strlen($this->firstname) + $length_lastname + 1 <= $max_strlen) {
892 if ($length_lastname + 3 <= $max_strlen) {
903 $this->passwd = $a_str;
904 $this->passwd_type = $a_type;
912 return $this->passwd;
920 return $this->passwd_type;
925 $this->last_password_change_ts = $a_last_password_change_ts;
930 return $this->last_password_change_ts;
935 return $this->passwd_policy_reset;
940 $this->passwd_policy_reset = $status;
961 $this->last_login = $a_str;
966 return $this->last_login;
971 $this->last_login = $this->db->now();
973 $old_first_login = $this->first_login;
974 if ($old_first_login ===
'') {
975 $this->first_login = $this->db->now();
976 $this->app_event_handler->raise(
977 'components/ILIAS/User',
979 [
'user_obj' => $this]
986 $this->first_login = $date;
991 return $this->first_login;
996 $this->last_profile_prompt = $date;
1001 return $this->last_profile_prompt;
1006 $this->last_update = $date;
1011 return $this->last_update;
1016 return $this->last_visited;
1021 $this->last_visited = $last_visited;
1022 $this->profile_data_repository->storeLastVisitedFor($this->
id, $last_visited);
1031 $this->approve_date = $a_str;
1036 return $this->approve_date;
1041 return $this->agree_date;
1045 $this->agree_date = $date;
1056 $this->setOwner($owner);
1058 $current_active = $this->active;
1061 $this->setApproveDate(date(
'Y-m-d H:i:s'));
1062 $this->setInactivationDate(
null);
1063 $this->setOwner($owner);
1068 $this->setApproveDate(
null);
1070 if ($this->
getId() > 0 && $current_active !== $active) {
1077 return $this->active === 1;
1082 return $this->user_settings[
'skin'];
1087 $this->time_limit_owner = $a_owner;
1092 return $this->time_limit_owner;
1097 $this->time_limit_from = $a_from;
1102 return $this->time_limit_from;
1107 $this->time_limit_until = $a_until;
1112 return $this->time_limit_until;
1117 $this->time_limit_unlimited = $unlimited;
1122 return $this->time_limit_unlimited;
1127 $this->login_attempts = $a_login_attempts;
1132 return $this->login_attempts;
1137 if ($this->getTimeLimitUnlimited()) {
1140 if ($this->getTimeLimitFrom() < time() and $this->getTimeLimitUntil() > time()) {
1148 $this->profile_incomplete = $a_prof_inc;
1156 return $this->profile_incomplete;
1166 if (LocalUserPasswordManager::getInstance()->verifyPassword($this, base64_decode(
'aG9tZXI='))
1175 && ($this->getPasswordPolicyResetStatus()
1177 && $this->getLastPasswordChangeTS() === 0
1178 && $this->is_self_registered ===
false);
1184 || $this->getLastPasswordChangeTS() === 0) {
1189 if ($max_pass_age_in_seconds === 0) {
1193 if (time() - $this->getLastPasswordChangeTS() > $max_pass_age_in_seconds
1203 return (
int) floor((time() - $this->getLastPasswordChangeTS()) / 86400);
1208 $this->last_password_change_ts = time();
1213 $this->last_password_change_ts = 0;
1218 $this->auth_mode = $a_str;
1224 return $this->auth_mode;
1231 $this->ext_account = $a_str;
1236 return $this->ext_account;
1250 string $a_time =
'',
1257 if ($a_time ===
'') {
1258 $a_time = date(
'Y-m-d H:i:s');
1261 $item_set =
$ilDB->queryF(
1262 'SELECT * FROM personal_clipboard WHERE ' .
1263 'parent = %s AND item_id = %s AND type = %s AND user_id = %s',
1264 [
'integer',
'integer',
'text',
'integer'],
1265 [0, $a_item_id, $a_type, $this->
getId()]
1269 if (!$item_set->fetchRow()) {
1271 'INSERT INTO personal_clipboard ' .
1272 '(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ' .
1273 ' (%s,%s,%s,%s,%s,%s,%s)',
1274 [
'integer',
'text',
'integer',
'text',
'integer',
'timestamp',
'integer'],
1275 [$a_item_id, $a_type, $this->
getId(), $a_title, $a_parent, $a_time, $a_order_nr]
1279 'UPDATE personal_clipboard SET insert_time = %s ' .
1280 'WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0',
1281 [
'timestamp',
'integer',
'integer',
'text'],
1282 [$a_time, $this->
getId(), $a_item_id, $a_type]
1298 $a_time = date(
'Y-m-d H:i:s');
1301 $ilDB->insert(
'personal_pc_clipboard', [
1302 'user_id' => [
'integer', $this->
getId()],
1303 'content' => [
'clob', $a_content],
1304 'insert_time' => [
'timestamp', $a_time],
1305 'order_nr' => [
'integer', $a_nr]
1321 $set =
$ilDB->queryF(
'SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ' .
1322 ' WHERE user_id = %s', [
'integer'], [$this->
getId()]);
1323 $row =
$ilDB->fetchAssoc($set);
1325 $set =
$ilDB->queryF(
1326 'SELECT * FROM personal_pc_clipboard ' .
1327 ' WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC',
1328 [
'integer',
'timestamp'],
1329 [$this->
getId(), $row[
'mtime']]
1332 while ($row =
$ilDB->fetchAssoc($set)) {
1333 $content[] = $row[
'content'];
1348 $set =
$ilDB->queryF(
1349 'SELECT * FROM personal_clipboard WHERE ' .
1350 'parent = %s AND type = %s AND user_id = %s',
1351 [
'integer',
'text',
'integer'],
1352 [0, $a_type, $this->
getId()]
1354 if (
$ilDB->fetchAssoc($set)) {
1366 'DELETE FROM personal_clipboard WHERE ' .
1367 'type = %s AND user_id = %s',
1368 [
'text',
'integer'],
1369 [$a_type, $this->
getId()]
1379 $ilDB->manipulateF(
'DELETE FROM personal_clipboard WHERE ' .
1380 'user_id = %s', [
'integer'], [$this->
getId()]);
1387 string $a_type =
'',
1388 bool $a_top_nodes_only =
false
1395 if ($a_top_nodes_only) {
1396 $par =
' AND parent = ' .
$ilDB->quote(0,
'integer') .
' ';
1399 $type_str = ($a_type !=
'')
1400 ?
' AND type = ' .
$ilDB->quote($a_type,
'text') .
' '
1402 $q =
'SELECT * FROM personal_clipboard WHERE ' .
1403 'user_id = ' .
$ilDB->quote($this->
getId(),
'integer') .
' ' .
1405 ' ORDER BY order_nr';
1408 while ($obj =
$ilDB->fetchAssoc($objs)) {
1409 if ($obj[
'type'] ==
'mob') {
1415 if ($obj[
'type'] ==
'incl') {
1421 $objects[] = [
'id' => $obj[
'item_id'],
1422 'type' => $obj[
'type'],
'title' => $obj[
'title'],
1423 'insert_time' => $obj[
'insert_time']];
1433 string $a_insert_time
1438 $ilUser =
$DIC[
'ilUser'];
1440 $objs =
$ilDB->queryF(
1441 'SELECT * FROM personal_clipboard WHERE ' .
1442 'user_id = %s AND parent = %s AND insert_time = %s ' .
1443 ' ORDER BY order_nr',
1444 [
'integer',
'integer',
'timestamp'],
1445 [$ilUser->getId(), $a_parent, $a_insert_time]
1448 while ($obj =
$ilDB->fetchAssoc($objs)) {
1449 if ($obj[
'type'] ==
'mob') {
1452 $objects[] = [
'id' => $obj[
'item_id'],
1453 'type' => $obj[
'type'],
'title' => $obj[
'title'],
'insert_time' => $obj[
'insert_time']];
1464 $q =
'DELETE FROM personal_clipboard WHERE ' .
1465 'item_id = ' .
$ilDB->quote($a_item_id,
'integer') .
1466 ' AND type = ' .
$ilDB->quote($a_type,
'text') .
' ' .
1467 ' AND user_id = ' .
$ilDB->quote($this->
getId(),
'integer');
1473 return self::lookupOrgUnitsRepresentation($this->
getId());
1481 string $a_size =
'small',
1482 bool $a_force_pic =
false
1484 if (isset(self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic])) {
1485 return self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic];
1488 self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic] = self::_getPersonalPicturePath($this->
getId(), $a_size, $a_force_pic);
1490 return self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic];
1500 return self::_getAvatar($this->
getId());
1505 if ($this->getAvatarRid() !==
null) {
1509 $this->profile_data = $this->profile_data->withAvatarRid(
null);
1520 $rbacreview =
$DIC[
'rbacreview'];
1521 $profile =
$DIC[
'user']->getProfile();
1526 $body =
"{$language->txt('login')}: {$this->getLogin()}\n";
1528 if ($this->profile_data->getTitle() !==
'') {
1529 $body .=
"{$language->txt('title')}: {$this->profile_data->getTitle()}\n";
1531 if ($this->getGender() !==
'') {
1532 $body .= ($language->
txt(
'gender') .
': ' . $language->
txt(
'gender_' . strtolower($this->getGender())) .
"\n");
1534 if ($this->getFirstname() !==
'') {
1535 $body .= ($language->
txt(
'firstname') .
': ' . $this->getFirstname() .
"\n");
1537 if ($this->getLastname() !==
'') {
1538 $body .= ($language->
txt(
'lastname') .
': ' . $this->getLastname() .
"\n");
1540 if ($this->getInstitution() !==
'') {
1541 $body .= ($language->
txt(
'institution') .
': ' . $this->getInstitution() .
"\n");
1543 if ($this->getDepartment() !==
'') {
1544 $body .= ($language->
txt(
'department') .
': ' . $this->getDepartment() .
"\n");
1546 if ($this->getStreet() !==
'') {
1547 $body .= ($language->
txt(
'street') .
': ' . $this->getStreet() .
"\n");
1549 if ($this->getCity() !==
'') {
1550 $body .= ($language->
txt(
'city') .
': ' . $this->getCity() .
"\n");
1552 if ($this->getZipcode() !==
'') {
1553 $body .= ($language->
txt(
'zipcode') .
': ' . $this->getZipcode() .
"\n");
1555 if ($this->getCountry() !==
'') {
1556 $body .= ($language->
txt(
'country') .
': ' . $this->getCountry() .
"\n");
1558 if ($this->getPhoneOffice() !==
'') {
1559 $body .= ($language->
txt(
'phone_office') .
': ' . $this->getPhoneOffice() .
"\n");
1561 if ($this->getPhoneHome() !==
'') {
1562 $body .= ($language->
txt(
'phone_home') .
': ' . $this->getPhoneHome() .
"\n");
1564 if ($this->getPhoneMobile() !==
'') {
1565 $body .= ($language->
txt(
'phone_mobile') .
': ' . $this->getPhoneMobile() .
"\n");
1567 if ($this->getFax() !==
'') {
1568 $body .= ($language->
txt(
'fax') .
': ' . $this->getFax() .
"\n");
1570 if ($this->getEmail() !==
'') {
1571 $body .= ($language->
txt(
'email') .
': ' . $this->getEmail() .
"\n");
1573 if ($this->getSecondEmail() !==
null
1574 && $this->getSecondEmail() !==
'') {
1575 $body .= ($language->
txt(
'second_email') .
': ' . $this->getSecondEmail() .
"\n");
1577 if ($this->getHobby() !==
'') {
1578 $body .= ($language->
txt(
'hobby') .
': ' . $this->getHobby() .
"\n");
1580 if ($this->getComment() !==
'') {
1581 $body .= ($language->
txt(
'referral_comment') .
': ' . $this->getComment() .
"\n");
1583 if ($this->getMatriculation() !==
'') {
1584 $body .= ($language->
txt(
'matriculation') .
': ' . $this->getMatriculation() .
"\n");
1586 if ($this->getCreateDate() !==
'') {
1592 $body .= ($language->
txt(
'create_date') .
': ' . $date .
"\n");
1596 foreach ($rbacreview->getGlobalRoles() as $role) {
1597 if ($rbacreview->isAssigned($this->getId(), $role)) {
1602 $body .= ($language->
txt(
'reg_role_info') .
': ' . implode(
',', $gr) .
"\n");
1606 if ($this->getTimeLimitUnlimited()) {
1607 $body .= ($language->
txt(
'time_limit') .
': ' . $language->
txt(
'crs_unlimited') .
"\n");
1620 $body .= $language->
txt(
'time_limit') .
': ' .
1621 $language->
txt(
'from') .
' ' .
1626 foreach ($profile->getAllUserDefinedFields() as $field) {
1627 $data = $field->retrieveValueFromUser($this);
1629 $body .=
"{$field->getLabel($this->lng)}: {$data}\n";
1641 ($a_password ==
'') ?
'' : md5($a_password)
1647 return in_array($this->getPref(
'public_profile'), [
'y',
'g']);
1652 if ($this->hasPublicProfile()) {
1653 return $this->getFirstname() .
' ' . $this->getLastname() .
' (' . $this->getLogin() .
')';
1656 return $this->getLogin();
1663 $query =
'UPDATE object_data SET owner = 0 ' .
1664 'WHERE owner = ' .
$ilDB->quote($this->
getId(),
'integer');
1665 $ilDB->query($query);
1669 public function exportPersonalData(): void
1671 if (!isset($this->
user)) {
1673 $this->
user = $DIC->user();
1675 $export_consumer = (
new ExportFactory())->consumer()->handler();
1676 $configs = $export_consumer->exportConfig()->allExportConfigs();
1678 $config = $configs->getElementByClassName(
'ilUserExportConfig');
1679 $config->setExportType(
'personal_data');
1680 $export = $export_consumer->createStandardExportByObject(
1681 $this->
user->getId(),
1685 $stream = Streams::ofString($export->getIRSSInfo()->getStream()->getContents());
1686 $file_name = $export->getIRSSInfo()->getFileName();
1687 $export->getIRSS()->delete($export_consumer->exportStakeholderHandler());
1688 $this->delivery->deliver($stream, $file_name);
1694 if (!is_dir($dir)) {
1698 if (is_int(strpos($entry[
'entry'],
'.zip'))) {
1699 return $entry[
'entry'];
1709 '/' . $this->getPersonalDataExportFile();
1710 if (is_file($file)) {
1717 bool $a_profile_data,
1725 if (!$a_profile_data) {
1726 $imp->addSkipEntity(
'components/ILIAS/User',
'usr_profile');
1729 $imp->addSkipEntity(
'components/ILIAS/User',
'usr_setting');
1732 $imp->addSkipEntity(
'components/ILIAS/Notes',
'user_notes');
1735 $imp->addSkipEntity(
'components/ILIAS/Calendar',
'calendar');
1738 $a_file[
'tmp_name'],
1741 'components/ILIAS/User'
1747 $this->inactivation_date = $inactivation_date;
1752 return $this->inactivation_date;
1757 return self::_isAnonymous($this->
getId());
1767 $this->writePref(
'delete_flag',
true);
1772 $this->writePref(
'delete_flag',
false);
1777 return (
bool) $this->getPref(
'delete_flag');
1782 $this->is_self_registered = $status;
1787 return $this->is_self_registered;
1795 $this->profile_data = $this->profile_data->withAdditionalFieldByIdentifier(
1796 $this->profile_configuration_repository->getByClass(Interests::class)->getIdentifier(),
1806 return $this->profile_data->getAdditionalFieldByIdentifier(
1807 $this->profile_configuration_repository->getByClass(Interests::class)->getIdentifier()
1816 return $this->buildTextFromArray($this->getGeneralInterests());
1824 $this->profile_data = $this->profile_data->withAdditionalFieldByIdentifier(
1825 $this->profile_configuration_repository->getByClass(HelpOffered::class)->getIdentifier(),
1835 return $this->profile_data->getAdditionalFieldByIdentifier(
1836 $this->profile_configuration_repository->getByClass(HelpOffered::class)->getIdentifier()
1845 return $this->buildTextFromArray($this->getOfferingHelp());
1850 $this->profile_data = $this->profile_data->withAdditionalFieldByIdentifier(
1851 $this->profile_configuration_repository->getByClass(HelpLookedFor::class)->getIdentifier(),
1858 return $this->profile_data->getAdditionalFieldByIdentifier(
1859 $this->profile_configuration_repository->getByClass(HelpLookedFor::class)->getIdentifier()
1865 return $this->buildTextFromArray($this->getLookingForHelp());
1874 $stream = Streams::ofResource(fopen($tmp_file,
'rb'));
1876 if ($this->getAvatarRid() !==
null && $this->getAvatarRid() !== ilObjUser::NO_AVATAR_RID) {
1877 $rid = $this->irss->manage()->find($this->getAvatarRid());
1879 $this->irss->manage()->replaceWithStream(
1886 $rid = $this->irss->manage()->stream(
1892 $this->setAvatarRid($rid);
1899 if (count($a_attr) > 0) {
1900 return implode(
', ', $a_attr);
1916 $q =
'SELECT DISTINCT login, usr_id FROM usr_data ' .
1919 $values[] = $a_login;
1921 if ($a_user_id != 0) {
1922 $q .=
' AND usr_id != %s ';
1923 $types[] =
'integer';
1924 $values[] = $a_user_id;
1927 $r =
$ilDB->queryF(
$q, $types, $values);
1929 if (($row =
$ilDB->fetchAssoc($r))) {
1930 return (
int) $row[
'usr_id'];
1936 string $a_external_account,
1943 'SELECT * FROM usr_data ' .
1944 'WHERE ext_account = %s AND auth_mode = %s',
1946 [$a_external_account, $a_auth_mode]
1957 $rbacreview =
$DIC[
'rbacreview'];
1959 $ids = $rbacreview->assignedUsers($role_id);
1961 if (count($ids) == 0) {
1965 $query =
'SELECT usr_data.*, usr_pref.value AS language
1967 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
1968 WHERE ' .
$ilDB->in(
'usr_data.usr_id', $ids,
false,
'integer');
1969 $values[] =
'language';
1973 if (is_numeric($active) && $active > -1) {
1974 $query .=
' AND usr_data.active = %s';
1975 $values[] = $active;
1976 $types[] =
'integer';
1979 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
1981 $r =
$ilDB->queryF($query, $types, $values);
1983 while ($row =
$ilDB->fetchAssoc($r)) {
1996 $query =
'SELECT usr_data.*, usr_pref.value AS language FROM usr_data LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id and usr_pref.keyword = %s WHERE 1=1';
1998 $values[] =
'language';
2000 if (is_numeric($active) && $active > -1) {
2001 $query .=
' AND usr_data.active = %s';
2002 $values[] = $active;
2003 $types[] =
'integer';
2007 $query .=
' AND usr_data.time_limit_owner = %s';
2009 $types[] =
'integer';
2012 $query .=
' AND usr_data.usr_id != %s ';
2014 $types[] =
'integer';
2016 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2018 $result =
$ilDB->queryF($query, $types, $values);
2020 while ($row =
$ilDB->fetchAssoc($result)) {
2031 return self::_getUsersForIds($a_mem_ids, $active);
2037 int $timelimitowner = -1
2042 $query =
'SELECT usr_data.*, usr_pref.value AS language
2044 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
2045 WHERE ' .
$ilDB->in(
'usr_data.usr_id', $a_mem_ids,
false,
'integer') .
'
2046 AND usr_data.usr_id != %s';
2047 $values[] =
'language';
2050 $types[] =
'integer';
2052 if (is_numeric($active) && $active > -1) {
2053 $query .=
' AND active = %s';
2054 $values[] = $active;
2055 $types[] =
'integer';
2058 if ($timelimitowner !=
USER_FOLDER_ID && $timelimitowner != -1) {
2059 $query .=
' AND usr_data.time_limit_owner = %s';
2060 $values[] = $timelimitowner;
2061 $types[] =
'integer';
2064 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2066 $result =
$ilDB->queryF($query, $types, $values);
2068 while ($row =
$ilDB->fetchAssoc($result)) {
2081 if (is_array($a_internalids)) {
2082 foreach ($a_internalids as $internalid) {
2083 if (is_numeric($internalid)) {
2084 $ids[] = $internalid;
2087 if (is_numeric($parsedid) && $parsedid > 0) {
2093 if (count($ids) == 0) {
2097 $query =
'SELECT usr_data.*, usr_pref.value AS language
2100 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
2101 WHERE ' .
$ilDB->in(
'usr_data.usr_id', $ids,
false,
'integer');
2102 $values[] =
'language';
2105 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2108 $result =
$ilDB->queryF($query, $types, $values);
2109 while ($row =
$ilDB->fetchAssoc($result)) {
2124 $set =
$ilDB->query(
2125 'SELECT usr_id FROM usr_pref ' .
2126 ' WHERE keyword = ' .
$ilDB->quote($a_keyword,
'text') .
2127 ' AND ' .
$ilDB->in(
'usr_id', $a_user_ids,
false,
'integer') .
2128 ' AND value = ' .
$ilDB->quote($a_val,
'text')
2130 while ($rec =
$ilDB->fetchAssoc($set)) {
2131 $users[] = $rec[
'usr_id'];
2142 $query =
'SELECT login_attempts FROM usr_data WHERE usr_id = %s';
2143 $result =
$ilDB->queryF($query, [
'integer'], [$a_usr_id]);
2144 $record =
$ilDB->fetchAssoc($result);
2145 return (
int) ($record[
'login_attempts'] ?? 0);
2154 $query =
'UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s';
2155 $affected =
$ilDB->manipulateF($query, [
'integer'], [$a_usr_id]);
2170 $query =
'UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s';
2171 $affected =
$ilDB->manipulateF($query, [
'timestamp',
'integer'], [
ilUtil::now(), $a_usr_id]);
2182 bool $a_no_anonymous =
false
2190 $atime = $pd_set->get(
'user_activity_time') * 60;
2195 if ($a_user_id === 0) {
2196 $where[] =
'user_id > 0';
2198 $where[] =
'user_id = ' .
$ilDB->quote($a_user_id,
'integer');
2201 if ($a_no_anonymous) {
2209 $where[] =
'expires > ' .
$ilDB->quote($ctime,
'integer');
2210 $where[] =
'(p.value IS NULL OR NOT p.value = ' .
$ilDB->quote(
'y',
'text') .
')';
2212 $where =
'WHERE ' . implode(
' AND ', $where);
2216 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime, context, agree_date
2218 LEFT JOIN usr_data u
2219 ON user_id = u.usr_id
2220 LEFT JOIN usr_pref p
2221 ON (p.usr_id = u.usr_id AND p.keyword = %s)
2223 GROUP BY user_id, firstname, lastname, title, login, last_login, context, agree_date
2224 ORDER BY lastname, firstname
2227 [
'hide_own_online_status']
2230 $log->debug(
'Query: ' .
$q);
2233 while ($user =
$ilDB->fetchAssoc($r)) {
2234 if ($atime <= 0 || $user[
'ctime'] + $atime > $ctime) {
2235 $users[$user[
'user_id']] = $user;
2239 $log->debug(
'Found users: ' . count($users));
2241 $hide_users =
$DIC[
'legalDocuments']->usersWithHiddenOnlineStatus(array_map(intval(...), array_column($users,
'user_id')));
2242 $users = array_filter(
2244 fn($user) => !in_array((
int) $user[
'user_id'], $hide_users,
true)
2256 if ($periodInDays < 1) {
2260 $date = date(
'Y-m-d H:i:s', (time() - ($periodInDays * 24 * 60 * 60)));
2262 $query =
'SELECT usr_id FROM usr_data WHERE last_login IS NOT NULL AND last_login < %s';
2266 $types = [
'timestamp'];
2269 $res =
$ilDB->queryF($query, $types, $values);
2270 while ($row =
$ilDB->fetchAssoc(
$res)) {
2271 $ids[] = (
int) $row[
'usr_id'];
2278 int $thresholdInDays
2283 $date = date(
'Y-m-d H:i:s', (time() - ($thresholdInDays * 24 * 60 * 60)));
2285 $query =
'SELECT usr_id FROM usr_data WHERE last_login IS NULL AND create_date < %s';
2289 $types = [
'timestamp'];
2292 $res =
$ilDB->queryF($query, $types, $values);
2293 while ($row =
$ilDB->fetchAssoc(
$res)) {
2294 $ids[] = (
int) $row[
'usr_id'];
2311 'SELECT usr_id FROM usr_data WHERE inactivation_date < %s AND active = %s',
2312 [
'timestamp',
'integer'],
2314 date(
'Y-m-d H:i:s', (time() - ($period * 24 * 60 * 60))),
2320 while ($row = $db->fetchObject(
$res)) {
2321 $ids[] = (
int) $row->usr_id;
2328 ?array $user_ids =
null
2333 $q =
'SELECT DISTINCT ' .
$ilDB->upper(
$ilDB->substr(
'lastname', 1, 1)) .
' let' .
2336 ($user_ids !==
null ?
' AND ' .
$ilDB->in(
'usr_id', $user_ids,
false,
'integer') :
'') .
2341 while ($let_rec =
$ilDB->fetchAssoc($let_set)) {
2342 $let[$let_rec[
'let']] = $let_rec[
'let'];
2348 array $a_usr_ids = []
2353 $query =
'SELECT count(*) num FROM object_data od ' .
2354 'JOIN usr_data ud ON obj_id = usr_id ' .
2355 'WHERE ' .
$ilDB->in(
'obj_id', $a_usr_ids,
false,
'integer') .
' ';
2358 return $num_rows == count($a_usr_ids);
2368 SELECT * FROM loginname_history
2384 $query =
'SELECT * FROM usr_pref WHERE usr_id = ' .
$ilDB->quote($a_usr_id,
'integer') .
' ' .
2385 'AND keyword = ' .
$ilDB->quote($a_keyword,
'text');
2399 $query =
'SELECT matriculation FROM usr_data ' .
2400 'WHERE usr_id = ' .
$ilDB->quote($a_usr_id);
2403 return $row->matriculation ?:
'';
2408 ?
int $a_user_id =
null,
2409 ?
string $a_field_id =
null
2416 $sql =
'SELECT DISTINCT(value)' .
2417 ' FROM usr_profile_data' .
2418 ' WHERE ' .
$ilDB->like(
'value',
'text',
'%' . $a_term .
'%');
2420 $sql .=
' AND field_id = ' .
$ilDB->quote($a_field_id,
'text');
2423 $sql .=
' AND usr_id <> ' .
$ilDB->quote($a_user_id,
'integer');
2425 $sql .=
' ORDER BY value';
2426 $set =
$ilDB->query($sql);
2427 while ($row =
$ilDB->fetchAssoc($set)) {
2428 $res[] = $row[
'value'];
2440 $set =
$ilDB->query(
2441 'SELECT * FROM usr_pref ' .
2442 ' WHERE keyword = ' .
$ilDB->quote(
'public_profile',
'text') .
2443 ' AND ' .
$ilDB->in(
'usr_id', $a_user_ids,
false,
'integer')
2451 while ($rec =
$ilDB->fetchAssoc($set)) {
2452 if ($rec[
'value'] ==
'g') {
2453 $r[
'global'][] = $rec[
'usr_id'];
2454 $r[
'public'][] = $rec[
'usr_id'];
2456 if ($rec[
'value'] ==
'y') {
2457 $r[
'local'][] = $rec[
'usr_id'];
2458 $r[
'public'][] = $rec[
'usr_id'];
2461 foreach ($a_user_ids as
$id) {
2462 if (!in_array(
$id, $r[
'public'])) {
2463 $r[
'not_public'][] =
$id;
2478 'SELECT ' . $a_field .
' FROM usr_data WHERE usr_id = %s',
2483 while ($set =
$ilDB->fetchAssoc(
$res)) {
2484 return $set[$a_field];
2496 $set =
$ilDB->queryF(
2497 'SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s',
2502 if ($rec =
$ilDB->fetchAssoc($set)) {
2503 if ($rec[
'title']) {
2504 $fullname = $rec[
'title'] .
' ';
2506 if ($rec[
'firstname']) {
2507 $fullname .= $rec[
'firstname'] .
' ';
2509 if ($rec[
'lastname']) {
2510 $fullname .= $rec[
'lastname'];
2518 return self::_lookup($a_user_id,
'email') ??
'';
2523 return (
string) self::_lookup($a_user_id,
'gender') ??
'';
2528 return self::_lookup($a_user_id,
'client_ip') ??
'';
2537 'SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s',
2541 if (($user_rec =
$ilDB->fetchAssoc(
$res))) {
2542 return [
'user_id' => $a_user_id,
2543 'firstname' => $user_rec[
'firstname'],
2544 'lastname' => $user_rec[
'lastname'],
2545 'title' => $user_rec[
'title'],
2546 'login' => $user_rec[
'login']
2549 return [
'user_id' => 0,
2563 $q =
'SELECT value FROM usr_pref WHERE usr_id= ' .
2564 $ilDB->quote($a_usr_id,
'integer') .
' AND keyword = ' .
2565 $ilDB->quote(
'language',
'text');
2568 while ($row =
$ilDB->fetchAssoc($r)) {
2569 return (
string) $row[
'value'];
2571 if (is_object(
$lng)) {
2572 return $lng->getDefaultLanguage();
2585 'UPDATE usr_data ' .
2586 ' SET ext_account = %s WHERE usr_id = %s',
2587 [
'text',
'integer'],
2588 [$a_ext_id, $a_usr_id]
2598 'UPDATE usr_data ' .
2599 ' SET auth_mode = %s WHERE usr_id = %s',
2600 [
'text',
'integer'],
2601 [$a_auth_mode, $a_usr_id]
2614 'SELECT * FROM usr_data WHERE usr_id = %s',
2627 $query =
'SELECT usr_id FROM usr_data ' .
2628 'WHERE active = ' .
$ilDB->quote(1,
'integer') .
' ' .
2629 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'integer');
2639 return (
string) self::_lookup($a_user_id,
'login') ??
'';
2644 return (
string) self::_lookup($a_user_id,
'ext_account') ??
'';
2654 string $a_auth_mode,
2655 bool $a_read_auth_default =
false
2662 $q =
'SELECT login,usr_id,ext_account,auth_mode FROM usr_data ' .
2663 'WHERE auth_mode = %s';
2665 $values[] = $a_auth_mode;
2667 $q .=
' OR auth_mode = %s ';
2669 $values[] =
'default';
2674 while ($row =
$ilDB->fetchObject(
$res)) {
2675 if ($row->auth_mode ==
'default') {
2676 $accounts[$row->usr_id] = $row->login;
2678 $accounts[$row->usr_id] = $row->ext_account;
2693 $q =
'UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE ' .
2694 $ilDB->in(
'usr_id', $a_usr_ids,
false,
'integer');
2697 $usrId_IN_usrIds =
$ilDB->in(
'usr_id', $a_usr_ids,
false,
'integer');
2699 $q =
'UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds';
2704 SET inactivation_date = %s
2705 WHERE inactivation_date IS NULL
2706 AND $usrId_IN_usrIds
2714 return (
string) self::_lookup($a_usr_id,
'auth_mode');
2724 bool $tryFallback =
true
2727 $settings =
$GLOBALS[
'DIC']->settings();
2731 'SELECT * FROM usr_data WHERE ' .
2732 ' ext_account = %s AND auth_mode = %s',
2734 [$a_account, $a_auth]
2736 if ($usr = $db->fetchAssoc($r)) {
2737 return $usr[
'login'];
2740 if (!$tryFallback) {
2746 'SELECT login FROM usr_data ' .
2747 'WHERE login = %s AND auth_mode = %s AND (ext_account IS NULL OR ext_account = "") ',
2749 [$a_account, $a_auth]
2751 if ($usr = $db->fetchAssoc(
$res)) {
2752 return $usr[
'login'];
2758 'SELECT login FROM usr_data WHERE ' .
2759 ' ext_account = %s AND auth_mode = %s',
2761 [$a_account,
'default']
2763 if ($usr = $db->fetchAssoc(
$res)) {
2764 return $usr[
'login'];
2768 'SELECT login FROM usr_data ' .
2769 'WHERE login = %s AND (ext_account IS NULL OR ext_account = "") AND auth_mode = %s',
2771 [$a_account,
'default']
2773 if ($usr = $db->fetchAssoc(
$res)) {
2774 return $usr[
'login'];
2782 return (
int) self::_lookupId($a_login);
2791 'SELECT usr_id FROM usr_data ' .
2792 'WHERE email = %s and active = 1',
2797 while ($row =
$ilDB->fetchObject(
$res)) {
2798 $ids[] = (
int) $row->usr_id;
2810 'SELECT login FROM usr_data ' .
2811 'WHERE email = %s and active = 1',
2816 while ($row =
$ilDB->fetchObject(
$res)) {
2817 $ids[] = $row->login;
2824 string|array $a_user_str
2829 if (!is_array($a_user_str)) {
2831 'SELECT usr_id FROM usr_data WHERE login = %s',
2837 if (is_array($user_rec)) {
2838 return (
int) $user_rec[
'usr_id'];
2844 $set =
$ilDB->query(
2845 'SELECT usr_id FROM usr_data ' .
2846 ' WHERE ' .
$ilDB->in(
'login', $a_user_str,
false,
'text')
2850 while ($rec =
$ilDB->fetchAssoc($set)) {
2851 $ids[] = (
int) $rec[
'usr_id'];
2859 return self::_lookup($a_user_id,
'last_login') ??
'';
2864 return self::_lookup($a_user_id,
'first_login') ??
'';
2869 string $a_session_id
2874 $set =
$ilDB->queryf(
2876 SELECT COUNT(*) session_count
2877 FROM usr_session WHERE user_id = %s AND expires > %s AND session_id != %s ',
2878 [
'integer',
'integer',
'text'],
2879 [$a_user_id, time(), $a_session_id]
2881 $row =
$ilDB->fetchAssoc($set);
2882 return (
bool) $row[
'session_count'];
2890 $res =
$ilDB->query(
'SELECT * FROM usr_data WHERE ' .
2891 $ilDB->in(
'usr_id', $a_user_ids,
false,
'integer'));
2893 while ($row =
$ilDB->fetchAssoc(
$res)) {
2894 $user_data[$row[
'usr_id']] = $row;
2906 $q =
'SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ' .
2907 ' WHERE up1.keyword= ' .
$ilDB->quote(
'style',
'text') .
2908 ' AND up1.value= ' .
$ilDB->quote($a_style,
'text') .
2909 ' AND up2.keyword= ' .
$ilDB->quote(
'skin',
'text') .
2910 ' AND up2.value= ' .
$ilDB->quote($a_skin,
'text') .
2911 ' AND up1.usr_id = up2.usr_id ';
2915 $cnt_rec =
$ilDB->fetchAssoc($cnt_set);
2917 return (
int) $cnt_rec[
'cnt'];
2925 $q =
'SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ' .
2926 ' WHERE up1.keyword = ' .
$ilDB->quote(
'style',
'text') .
2927 ' AND up2.keyword = ' .
$ilDB->quote(
'skin',
'text') .
2928 ' AND up1.usr_id = up2.usr_id';
2933 while ($sty_rec =
$ilDB->fetchAssoc($sty_set)) {
2934 $styles[] = $sty_rec[
'skin'] .
':' . $sty_rec[
'style'];
2949 $r =
$ilDB->query(
'SELECT count(*) AS cnt, auth_mode FROM usr_data ' .
2950 'GROUP BY auth_mode');
2952 while ($cnt =
$ilDB->fetchAssoc($r)) {
2953 $cnt_arr[$cnt[
'auth_mode']] = (
int) $cnt[
'cnt'];
2968 $q =
'SELECT * FROM usr_data WHERE ' .
2969 ' email = %s AND (auth_mode = %s ';
2970 $types = [
'text',
'text'];
2971 $values = [$a_email,
'local'];
2974 $q .=
' OR auth_mode = %s';
2976 $values[] =
'default';
2982 $usr_set =
$ilDB->queryF(
$q, $types, $values);
2983 while ($usr_rec =
$ilDB->fetchAssoc($usr_set)) {
2984 $users[$usr_rec[
'usr_id']] = $usr_rec[
'login'];
2991 string $a_from_skin,
2992 string $a_from_style,
2999 $q =
'SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ' .
3000 ' WHERE up1.keyword= ' .
$ilDB->quote(
'style',
'text') .
3001 ' AND up1.value= ' .
$ilDB->quote($a_from_style,
'text') .
3002 ' AND up2.keyword= ' .
$ilDB->quote(
'skin',
'text') .
3003 ' AND up2.value= ' .
$ilDB->quote($a_from_skin,
'text') .
3004 ' AND up1.usr_id = up2.usr_id ';
3008 while ($usr_rec =
$ilDB->fetchAssoc($usr_set)) {
3039 $q =
'SELECT DISTINCT user_id FROM personal_clipboard WHERE ' .
3040 'item_id = ' .
$ilDB->quote($a_id,
'integer') .
' AND ' .
3041 'type = ' .
$ilDB->quote($a_type,
'text');
3044 while ($user_rec =
$ilDB->fetchAssoc($user_set)) {
3045 $users[] = (
int) $user_rec[
'user_id'];
3057 $query =
'SELECT obj_id FROM object_data WHERE import_id = ' .
3058 $ilDB->quote($i2_id,
'text');
3062 while ($row =
$ilDB->fetchObject(
$res)) {
3063 $id = (
int) $row->obj_id;
3077 $define->setSize(
'xsmall');
3078 return $define->getAvatar();
3083 string $size =
'small',
3084 bool $force_pic =
false
3088 $define->setSize($size);
3089 return $define->getLegacyPictureURL();
3097 $irss =
$DIC->resourceStorage();
3099 $clean_dir = trim(str_replace(
'..',
'', $a_dir));
3100 if ($clean_dir ==
'' || !is_dir($clean_dir)) {
3103 $avatar_rid = (
new ilObjUser($a_user_id))->getAvatarRid();
3104 if ($avatar_rid ===
null) {
3109 $clean_dir .
'/usr_' . $a_user_id .
'.jpg',
3110 $irss->
consume()->stream($avatar_rid)->getStream()->getContents()
3116 bool $a_create =
false
3121 if ($a_user_id > 0) {
3122 $set =
$ilDB->queryF(
3123 'SELECT feed_hash from usr_data WHERE usr_id = %s',
3127 if ($rec =
$ilDB->fetchAssoc($set)) {
3128 if (strlen($rec[
'feed_hash']) == 32) {
3129 return $rec[
'feed_hash'];
3130 } elseif ($a_create) {
3131 $hash = md5(random_int(1, 9999999) + str_replace(
' ',
'', microtime()));
3133 'UPDATE usr_data SET feed_hash = %s' .
3134 ' WHERE usr_id = %s',
3135 [
'text',
'integer'],
3148 if ($a_user_id > 0) {
3149 return self::_lookupPref($a_user_id,
'priv_feed_pass');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Class ResourceIdentification.
setOwner(int $user_id_of_owner)
static _needsExternalAccountByAuthMode($a_auth_mode)
Check if chosen auth mode needs an external account entry.
static _getAuthMode(?string $a_auth_mode)
static _getAuthModeName($a_auth_key)
static deleteByUserId(int $a_user_id)
static _deleteSettingsOfUser(int $a_user)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
static resetToDefaults()
reset to defaults
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
static setLanguage(ilLanguage $a_lng)
@classDescription Date and time handling
static _deleteByUser(int $a_usr_id)
Base class for ILIAS Exception handling.
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
@depricated Get export directory for an repository object
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
addSkipImporter(string $a_component, bool $skip=true)
static _getInstance()
Get singleton instance of this class.
static getLogger(string $a_component_id)
Get component logger.
static lookupTitle(int $a_page_id)
static removeForUser(int $user_id)
Remove all notifications for given user.
static _deleteUser(int $a_usr_id)
static deleteUserPortfolios(int $a_user_id)
Delete all portfolio data for user.
static _removeTrackingDataForUser(int $user_id)
to be called from IlObjUser
static _deleteUser(int $a_usr_id)
static _lookupLanguage(int $a_usr_id)
DataFactory $data_factory
__construct(int $a_user_id=0, bool $a_call_by_reference=false)
setLastProfilePrompt(string $date)
static getUserIdsNeverLoggedIn(int $thresholdInDays)
updateLastVisited(array $last_visited)
static _isAnonymous(int $usr_id)
getClipboardObjects(string $a_type='', bool $a_top_nodes_only=false)
get all clipboard objects of user and specified type
setGender(string $gender_string)
getPersonalPicturePath(string $a_size='small', bool $a_force_pic=false)
assignSystemInformationFromDB(array $data)
static _getUsersOnline(int $a_user_id=0, bool $a_no_anonymous=false)
static _lookup(int $a_user_id, string $a_field)
getLookingForHelpAsText()
setAvatarRid(?ResourceIdentification $avatar_rid)
getOfferingHelpAsText()
Get help offering as plain text.
setPhoneMobile(string $phone)
static lookupMatriculation(int $a_usr_id)
static getUserLoginsByEmail(string $a_email)
setIsSelfRegistered(bool $status)
setPref(string $a_keyword, ?string $a_value)
setLongitude(?string $longitude)
setLanguage(string $language)
buildTextFromArray(array $a_attr)
const DATABASE_DATE_FORMAT
setAuthMode(?string $a_str)
addToPCClipboard(string $a_content, string $a_time, int $a_nr)
Add a page content item to PC clipboard (should go to another class)
getAuthMode(bool $a_auth_key=false)
setStreet(string $street)
static _getUsersForIds(array $a_mem_ids, int $active=-1, int $timelimitowner=-1)
setLastLogin(string $a_str)
setFirstLogin(string $date)
static _getPersonalPicturePath(int $usr_id, string $size='small', bool $force_pic=false)
static userExists(array $a_usr_ids=[])
clipboardHasObjectsOfType(string $a_type)
Check whether clipboard has objects of a certain type.
string $password_encoding_type
resetLastPasswordChange()
writeHistory(string $login)
setInactivationDate(?string $inactivation_date)
setTimeLimitUntil(?int $a_until)
static _lookupActive(int $a_usr_id)
prepareAndRetrievePasswordForStorage()
static _externalAccountExists(string $a_external_account, string $a_auth_mode)
setPasswordSalt(?string $password_salt)
setLastPasswordChangeTS(int $a_last_password_change_ts)
setTimeLimitFrom(?int $a_from)
string $inactivation_date
getCurrentLanguage()
returns the current language (may differ from user's pref setting!)
setLatitude(?string $latitude)
static _getLoginAttempts(int $a_usr_id)
setPhoneHome(string $phone)
static _toggleActiveStatusOfUsers(array $a_usr_ids, bool $a_status)
setPasswordEncodingType(?string $password_encryption_type)
static _lookupFullname(int $a_user_id)
static _writeExternalAccount(int $a_usr_id, string $a_ext_id)
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
static _getLocalAccountsForEmail(string $a_email)
getProfileAsString(Language $language)
Get formatted mail body text of user profile data.
getFullname(int $max_strlen=0)
bool $time_limit_unlimited
bool $passwd_policy_reset
static _getUserData(array $a_internalids)
isPasswordChangeDemanded()
int $last_password_change_ts
setPasswordPolicyResetStatus(bool $status)
static _getAllUserAssignedStyles()
updateLogin(string $login, Context $context)
setMatriculation(string $matriculation)
setComment(string $referral_comment)
setPasswd(string $a_str, string $a_type=ilObjUser::PASSWD_PLAIN)
static getUserIdsByEmail(string $a_email)
static _lookupExternalAccount(int $a_user_id)
getPersonalDataExportFile()
ProfileConfigurationRepository $profile_configuration_repository
setActive(bool $active, int $owner=0)
set user active state and updates system fields appropriately
static _lookupFirstLogin(int $a_user_id)
static _getNumberOfUsersPerAuthMode()
get number of users per auth mode
static _lookupAuthMode(int $a_usr_id)
getPasswordPolicyResetStatus()
setSecondEmail(?string $email)
setZipcode(string $zipcode)
setTimeLimitOwner(int $a_owner)
setLastname(string $lastname)
static findInterests(string $a_term, ?int $a_user_id=null, ?string $a_field_id=null)
setLookingForHelp(?array $value=null)
setCountry(string $country)
static _getUsersForClipboadObject(string $a_type, int $a_id)
ilSetting $ilias_settings
static _incrementLoginAttempts(int $a_usr_id)
static _lookupName(int $a_user_id)
setBirthday(?string $birthday)
withProfileData(Data $profile_data)
static _lookupId(string|array $a_user_str)
static _lookupFeedHash(int $a_user_id, bool $a_create=false)
retrieveAgreeDateForStorage()
setLocationZoom(?int $zoom)
static _getUsersForFolder(int $ref_id, int $active)
static _moveUsersToStyle(string $a_from_skin, string $a_from_style, string $a_to_skin, string $a_to_style)
removeObjectFromClipboard(int $a_item_id, string $a_type)
writePref(string $key, string $value)
setDepartment(string $department)
static getProfileStatusOfUsers(array $a_user_ids)
static _lookupPref(int $a_usr_id, string $a_keyword)
clipboardDeleteObjectsOfType(string $a_type)
static _getImportedUserId(string $i2_id)
setPhoneOffice(string $phone)
getOrgUnitsRepresentation()
buildSystemInformationArrayForDB()
static _lookupLastLogin(int $a_user_id)
ilAuthSession $auth_session
setGeneralInterests(?array $value=null)
setProfileIncomplete(bool $a_prof_inc)
setLastUpdate(string $date)
getLastPasswordChangeTS()
setExternalAccount(string $a_str)
static hasActiveSession(int $a_user_id, string $a_session_id)
getPasswordEncodingType()
addObjectToClipboard(int $a_item_id, string $a_type, string $a_title, int $a_parent=0, string $a_time='', int $a_order_nr=0)
add an item to user's personal clipboard
static _getUsersForGroup(array $a_mem_ids, int $active=-1)
static _lookupFields(int $a_user_id)
setAgreeDate(?string $date)
string $last_profile_prompt
static _getExternalAccountsByAuthMode(string $a_auth_mode, bool $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
setTimeLimitUnlimited(bool $unlimited)
static getUserIdByLogin(string $a_login)
static _getFeedPass(int $a_user_id)
static _lookupClientIP(int $a_user_id)
static _lookupLogin(int $a_user_id)
resetPassword(string $new_raw_password)
setLastPasswordChangeToNow()
setLoginAttempts(int $a_login_attempts)
static _writeAuthMode(int $a_usr_id, string $a_auth_mode)
static _lookupGender(int $a_user_id)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
static _getUsersForRole(int $role_id, int $active=-1)
static _loginExists(string $a_login, int $a_user_id=0)
static lookupOrgUnitsRepresentation(int $a_usr_id)
getGeneralInterestsAsText()
Get general interests as plain text.
setFeedPass(string $a_password)
getPCClipboardContent()
Add a page content item to PC clipboard (should go to another class)
static _doesLoginnameExistInHistory(string $a_login)
static _setUserInactive(int $a_usr_id)
setOfferingHelp(?array $value=null)
getClipboardChilds(int $a_parent, string $a_insert_time)
Get children of an item.
uploadPersonalPicture(string $tmp_file)
static getUserSubsetByPreferenceValue(array $a_user_ids, string $a_keyword, string $a_val)
setClientIP(string $a_str)
setInstitution(string $instituion)
static getUserIdsByInactivityPeriod(int $periodInDays)
setFirstname(string $firstname)
static _readUsersProfileData(array $a_user_ids)
setCurrentLanguage(string $language)
Set current language.
static array $personal_image_cache
static getFirstLettersOfLastnames(?array $user_ids=null)
SettingsDataRepository $settings_data_repository
setUTitle(string $user_title)
This sets the USER's title NOT the OBJECT's title!
importPersonalData(array $a_file, bool $a_profile_data, bool $a_settings, bool $a_notes, bool $a_calendar)
static _getAvatar(int $a_usr_id)
static copyProfilePicturesToDirectory(int $a_user_id, string $a_dir)
ProfileDataRepository $profile_data_repository
setApproveDate(?string $a_str)
set date the user account was activated null indicates that the user has not yet been activated
ilCronDeleteInactiveUserReminderMail $cron_delete_user_reminder_mail
static _lookupEmail(int $a_user_id)
static _getUserIdsByInactivationPeriod(int $period)
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
updateOwner()
update owner of object in db
static _lookupTitle(int $obj_id)
Class ilOrgUnitPathStorage.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static _removeTrackingDataForUser(int $user_id)
static _getInstance()
Get instance of ilSecuritySettings.
static _destroyByUserId(int $a_user_id)
Destroy session.
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
static styleExists(string $style_id)
static styleExistsForSkinId(string $skin_id, string $style_id)
Class ilUserAvatarResolver.
setForcePicture(bool $force_image)
There are places where we want wo show the Profile Picture of a User, even if the user doesn't want t...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static now()
Return current timestamp in Y-m-d H:i:s format.
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
This describes how a letter or a picture avatar could be modified during construction of UI.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ilObjForumAdministration.
if(!file_exists('../ilias.ini.php'))