94 bool $a_call_by_reference =
false
97 $this->irss =
$DIC[
'resource_storage'];
99 $this->auth_session =
$DIC[
'ilAuthSession'];
100 $this->
ctrl = $DIC[
'ilCtrl'];
101 $this->app_event_handler =
$DIC[
'ilAppEventHandler'];
102 $this->delivery =
$DIC[
'file_delivery']->delivery();
104 if (defined(
'USER_FOLDER_ID')) {
108 $local_dic = LocalDIC::dic();
109 $this->profile_data_repository = $local_dic[ProfileDataRepository::class];
110 $this->profile_data = $this->profile_data_repository->getDefault();
111 $this->profile_configuration_repository = $local_dic[ProfileConfigurationRepository::class];
113 $this->data_factory = (
new DataFactory());
120 $this->auth_mode =
'default';
122 if ($a_user_id > 0) {
123 $this->
setId($a_user_id);
129 $this->prefs[
'language'] = $this->
ilias->ini->readVariable(
'language',
'default');
130 $this->prefs[
'skin'] = $this->
ilias->ini->readVariable(
'layout',
'skin');
131 $this->prefs[
'style'] = $this->
ilias->ini->readVariable(
'layout',
'style');
141 $this->profile_data = $this->profile_data_repository->getSingle($this->
id);
152 $this->inactivation_date =
null;
153 if ($this->active === 0) {
154 $this->inactivation_date = date(
'Y-m-d H:i:s');
158 $system_information[
'create_date'] = $this->data_factory->clock()->utc()->now()
159 ->format(self::DATABASE_DATE_FORMAT);
161 $this->profile_data = $this->profile_data->withId($this->
id);
162 $this->profile_data_repository->store(
163 $this->profile_data->withSystemInformation($this->buildSystemInformationArrayForDB())
168 $mbox->createDefaultFolder();
171 $mail_options->createMailOptionsEntry();
173 $this->app_event_handler->raise(
174 'components/ILIAS/User',
176 [
'user_obj' => $this]
182 $this->profile_data_repository->store(
183 $this->profile_data->withSystemInformation($this->buildSystemInformationArrayForDB())
193 $this->app_event_handler->raise(
194 'components/ILIAS/User',
196 [
'user_obj' => $this]
204 if (!empty(
$data[
'passwd'])) {
205 $this->
setPasswd($data[
'passwd'], self::PASSWD_CRYPTED);
208 $this->password_salt =
$data[
'passwd_salt'];
209 $this->password_encoding_type =
$data[
'passwd_enc_type'];
210 $this->last_password_change_ts =
$data[
'last_password_change'];
211 $this->login_attempts =
$data[
'login_attempts'];
212 $this->passwd_policy_reset =
$data[
'passwd_policy_reset'];
213 $this->client_ip =
$data[
'client_ip'];
214 $this->last_login =
$data[
'last_login'];
215 $this->first_login =
$data[
'first_login'];
216 $this->last_profile_prompt =
$data[
'last_profile_prompt'];
217 $this->last_update =
$data[
'last_update'];
218 $this->create_date =
$data[
'create_date'];
219 $this->approve_date =
$data[
'approve_date'];
220 $this->active =
$data[
'active'];
221 $this->agree_date =
$data[
'agree_date'];
222 $this->inactivation_date =
$data[
'inactivation_date'];
224 $this->time_limit_owner =
$data[
'time_limit_owner'];
225 $this->time_limit_unlimited =
$data[
'time_limit_unlimited'];
226 $this->time_limit_from =
$data[
'time_limit_from'];
227 $this->time_limit_until =
$data[
'time_limit_until'];
229 $this->profile_incomplete =
$data[
'profile_incomplete'];
231 $this->auth_mode =
$data[
'auth_mode'];
232 $this->ext_account =
$data[
'ext_account'] ??
'';
233 $this->is_self_registered =
$data[
'is_self_registered'];
259 'ext_account' => $this->ext_account ??
'',
268 if ($this->passwd_type === self::PASSWD_PLAIN
269 && $this->passwd !==
'') {
270 LocalUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
278 if (is_string($this->agree_date && strtotime($this->agree_date) ===
false)) {
286 LocalUserPasswordManager::getInstance()->encodePassword($this, $new_raw_password);
287 $this->profile_data_repository->storePasswordFor(
290 $this->password_encoding_type,
298 $this->db->setLimit(1, 0);
299 $res = $this->db->queryF(
301 SELECT login, history_date FROM loginname_history
302 WHERE usr_id = %s ORDER BY history_date DESC',
306 $row = $this->db->fetchAssoc(
$res);
319 if ($login ===
'' || $login === $this->profile_data->getAlias()) {
325 if (!$this->profile_configuration_repository
326 ->getByClass(Alias::class)->isChangeableByUser()) {
331 if ($this->
settings->get(
'reuse_of_loginnames') ===
'0'
332 && self::_doesLoginnameExistInHistory($login)) {
336 if ((
int) $this->
settings->get(
'loginname_change_blocking_time') > 0
337 && is_array($last_history_entry)
338 && $last_history_entry[1] + (
int) $this->
settings->get(
'loginname_change_blocking_time') > time()) {
341 $this->
lng->txt(
'changing_loginname_not_possible_info'),
352 if ($this->
settings->get(
'create_history_loginname') ===
'1') {
356 $this->profile_data = $this->profile_data->withAlias($login);
357 $this->profile_data_repository->storeLoginFor($this->
id, $this->profile_data->getAlias());
364 $res = $this->db->queryF(
365 'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
366 [
'integer',
'text',
'integer'],
367 [$this->
id, $login, time()]
370 if ($this->db->numRows(
$res) == 0) {
371 $this->db->manipulateF(
373 INSERT INTO loginname_history
374 (usr_id, login, history_date)
375 VALUES (%s, %s, %s)',
376 [
'integer',
'text',
'integer'],
377 [$this->
id, $login, time()]
396 $this->
setPref($keyword, $value);
401 $this->db->manipulateF(
402 'DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s',
404 [$this->
id, $keyword]
406 unset($this->prefs[$keyword]);
411 $this->db->manipulateF(
412 'DELETE FROM usr_pref WHERE usr_id = %s',
420 $this->deleteAllPrefs();
421 foreach ($this->prefs as $keyword => $value) {
422 $this->writePref($keyword, (
string) $value);
428 $tz = $this->getPref(
'user_tz');
437 $format = $this->getPref(
'time_format');
438 if ($format !==
null) {
446 $format = $this->getPref(
'date_format');
447 if ($format ===
null) {
451 return match ((
int) $format) {
455 default => $this->data_factory->dateFormat()->standard()
462 return $this->data_factory->dateFormat()->withTime24($this->getDateFormat());
464 return $this->data_factory->dateFormat()->withTime12($this->getDateFormat());
467 public function setPref(
string $a_keyword, ?
string $a_value): void
469 if ($a_keyword !==
'') {
470 $this->prefs[$a_keyword] = $a_value;
474 public function getPref(
string $a_keyword): ?string
476 return $this->prefs[$a_keyword] ??
null;
489 $this->prefs = self::_getPreferences($this->
id);
490 if (!isset($this->prefs[
'style'])
491 || $this->prefs[
'style'] ===
''
495 $this->prefs[
'skin'] = $this->
ilias->ini->readVariable(
'layout',
'skin');
496 $this->prefs[
'style'] = $this->
ilias->ini->readVariable(
'layout',
'style');
500 public function delete():
bool
502 $this->app_event_handler->raise(
505 [
'usr_id' => $this->
getId()]
510 $this->rbac_admin->removeUser($this->
getId());
515 $mailbox->updateMailsOfDeletedUser($this->getLogin());
526 $this->cron_delete_user_reminder_mail->removeSingleUserFromTable($this->
getId());
528 $this->clipboardDeleteAll();
530 $this->deleteAllPrefs();
531 $this->removeUserPicture();
532 $this->profile_data_repository->deleteForUser($this->
getId());
542 $clone = clone $this;
543 $clone->profile_data = $profile_data;
549 return $this->profile_data;
554 $this->profile_data = $this->profile_data->withAlias($login);
559 return $this->profile_data->getAlias();
564 $this->profile_data = $this->profile_data->withGender(Genders::tryFrom($gender_string));
569 return $this->profile_data->getGender()?->value ??
'';
577 $this->setFullname();
578 $this->profile_data = $this->profile_data->withTitle($user_title);
583 return $this->profile_data->getTitle();
588 $this->profile_data = $this->profile_data->withFirstname($firstname);
589 $this->setFullname();
594 return $this->profile_data->getFirstname();
599 $this->profile_data = $this->profile_data->withLastname($lastname);
600 $this->setFullname();
605 return $this->profile_data->getLastname();
610 if ($birthday ===
null || $birthday ===
'') {
611 $this->profile_data = $this->profile_data->withBirthday(
null);
615 $this->profile_data = $this->profile_data->withBirthday(
616 new \DateTimeImmutable($birthday,
new DateTimeZone(
'UTC'))
622 return $this->profile_data->getBirthday()?->format(
'Y-m-d');
627 $this->profile_data = $this->profile_data->withInstitution($instituion);
632 return $this->profile_data->getInstitution();
637 $this->profile_data = $this->profile_data->withDepartment($department);
642 return $this->profile_data->getDepartment();
647 $this->profile_data = $this->profile_data->withStreet($street);
652 return $this->profile_data->getStreet();
657 $this->profile_data = $this->profile_data->withCity($city);
662 return $this->profile_data->getCity();
667 $this->profile_data = $this->profile_data->withZipcode($zipcode);
672 return $this->profile_data->getZipcode();
677 $this->profile_data = $this->profile_data->withCountry($country);
682 return $this->profile_data->getCountry();
687 $this->profile_data = $this->profile_data->withPhoneOffice($phone);
692 return $this->profile_data->getPhoneOffice();
697 $this->profile_data = $this->profile_data->withPhoneHome($phone);
702 return $this->profile_data->getPhoneHome();
707 $this->profile_data = $this->profile_data->withPhoneMobile($phone);
712 return $this->profile_data->getPhoneMobile();
715 public function setFax(
string $fax): void
717 $this->profile_data = $this->profile_data->withFax($fax);
722 return $this->profile_data->getFax();
727 $this->profile_data = $this->profile_data->withMatriculation($matriculation);
732 return $this->profile_data->getMatriculation();
737 $this->profile_data = $this->profile_data->withEmail($email);
742 return $this->profile_data->getEmail();
747 $this->profile_data = $this->profile_data->withSecondEmail($email);
752 return $this->profile_data->getSecondEmail();
757 $this->profile_data = $this->profile_data->withHobby($hobby);
762 return $this->profile_data->getHobby();
767 $this->profile_data = $this->profile_data->withReferralComment($referral_comment);
772 return $this->profile_data->getReferralComment();
777 $coordinates = $this->profile_data->getGeoCoordinates();
778 $coordinates[
'latitude'] = $latitude;
779 $this->profile_data = $this->profile_data->withGeoCoordinates($coordinates);
784 return $this->profile_data->getGeoCoordinates()[
'latitude'] ??
null;
789 $coordinates = $this->profile_data->getGeoCoordinates();
790 $coordinates[
'longitude'] = $longitude;
791 $this->profile_data = $this->profile_data->withGeoCoordinates($coordinates);
796 return $this->profile_data->getGeoCoordinates()[
'longitude'] ??
null;
801 $coordinates = $this->profile_data->getGeoCoordinates();
802 $coordinates[
'zoom'] = $zoom;
803 $this->profile_data = $this->profile_data->withGeoCoordinates($coordinates);
808 return $this->profile_data->getGeoCoordinates()[
'zoom'] ??
null;
813 return $this->profile_data->getAvatarRid();
818 $this->profile_data = $this->profile_data->withAvatarRid($avatar_rid);
823 $this->client_ip = $a_str;
828 return $this->client_ip;
833 $this->setPref(
'language', $language);
839 return $this->prefs[
'language'] ??
'';
844 return $this->password_encoding_type;
849 $this->password_encoding_type = $password_encryption_type;
854 return $this->password_salt;
859 $this->password_salt = $password_salt;
864 $title = $this->profile_data->getTitle() !==
'' ?
"{$this->profile_data->getTitle()} " :
'';
865 $this->fullname =
"{$title}{$this->profile_data->getFirstname()} {$this->profile_data->getLastname()}";
882 if ($max_strlen === 0) {
886 if (mb_strlen($this->fullname) <= $max_strlen) {
890 $length_lastname = mb_strlen($this->lastname);
891 if (mb_strlen($this->utitle) + $length_lastname + 4 <= $max_strlen) {
892 return ilUtil::stripSlashes($this->utitle .
' ' . substr($this->firstname, 0, 1) .
'. ' . $this->lastname);
895 if (mb_strlen($this->firstname) + $length_lastname + 1 <= $max_strlen) {
899 if ($length_lastname + 3 <= $max_strlen) {
910 $this->passwd = $a_str;
911 $this->passwd_type = $a_type;
919 return $this->passwd;
927 return $this->passwd_type;
932 $this->last_password_change_ts = $a_last_password_change_ts;
937 return $this->last_password_change_ts;
942 return $this->passwd_policy_reset;
947 $this->passwd_policy_reset = $status;
968 $this->last_login = $a_str;
973 return $this->last_login;
978 $this->last_login = $this->db->now();
980 $old_first_login = $this->first_login;
981 if ($old_first_login ===
'') {
982 $this->first_login = $this->db->now();
983 $this->app_event_handler->raise(
984 'components/ILIAS/User',
986 [
'user_obj' => $this]
993 $this->first_login = $date;
998 return $this->first_login;
1003 $this->last_profile_prompt = $date;
1008 return $this->last_profile_prompt;
1013 $this->last_update = $date;
1018 return $this->last_update;
1027 $this->approve_date = $a_str;
1032 return $this->approve_date;
1037 return $this->agree_date;
1041 $this->agree_date = $date;
1052 $this->setOwner($owner);
1054 $current_active = $this->active;
1057 $this->setApproveDate(date(
'Y-m-d H:i:s'));
1058 $this->setInactivationDate(
null);
1059 $this->setOwner($owner);
1064 $this->setApproveDate(
null);
1066 if ($this->
getId() > 0 && $current_active !== $active) {
1073 return $this->active === 1;
1078 return $this->prefs[
'skin'];
1083 $this->time_limit_owner = $a_owner;
1088 return $this->time_limit_owner;
1093 $this->time_limit_from = $a_from;
1098 return $this->time_limit_from;
1103 $this->time_limit_until = $a_until;
1108 return $this->time_limit_until;
1113 $this->time_limit_unlimited = $unlimited;
1118 return $this->time_limit_unlimited;
1123 $this->login_attempts = $a_login_attempts;
1128 return $this->login_attempts;
1133 if ($this->getTimeLimitUnlimited()) {
1136 if ($this->getTimeLimitFrom() < time() and $this->getTimeLimitUntil() > time()) {
1144 $this->profile_incomplete = $a_prof_inc;
1152 return $this->profile_incomplete;
1162 if (LocalUserPasswordManager::getInstance()->verifyPassword($this, base64_decode(
'aG9tZXI='))
1171 && ($this->getPasswordPolicyResetStatus()
1173 && $this->getLastPasswordChangeTS() === 0
1174 && $this->is_self_registered ===
false);
1180 || $this->getLastPasswordChangeTS() === 0) {
1185 if ($max_pass_age_in_seconds === 0) {
1189 if (time() - $this->getLastPasswordChangeTS() > $max_pass_age_in_seconds
1199 return (
int) (time() - $this->getLastPasswordChangeTS() / 86400);
1204 $this->last_password_change_ts = time();
1209 $this->last_password_change_ts = 0;
1214 $this->auth_mode = $a_str;
1220 return $this->auth_mode;
1227 $this->ext_account = $a_str;
1232 return $this->ext_account;
1246 string $a_time =
'',
1253 if ($a_time ===
'') {
1254 $a_time = date(
'Y-m-d H:i:s');
1257 $item_set =
$ilDB->queryF(
1258 'SELECT * FROM personal_clipboard WHERE ' .
1259 'parent = %s AND item_id = %s AND type = %s AND user_id = %s',
1260 [
'integer',
'integer',
'text',
'integer'],
1261 [0, $a_item_id, $a_type, $this->
getId()]
1265 if (!$item_set->fetchRow()) {
1267 'INSERT INTO personal_clipboard ' .
1268 '(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ' .
1269 ' (%s,%s,%s,%s,%s,%s,%s)',
1270 [
'integer',
'text',
'integer',
'text',
'integer',
'timestamp',
'integer'],
1271 [$a_item_id, $a_type, $this->
getId(), $a_title, $a_parent, $a_time, $a_order_nr]
1275 'UPDATE personal_clipboard SET insert_time = %s ' .
1276 'WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0',
1277 [
'timestamp',
'integer',
'integer',
'text'],
1278 [$a_time, $this->
getId(), $a_item_id, $a_type]
1294 $a_time = date(
'Y-m-d H:i:s');
1297 $ilDB->insert(
'personal_pc_clipboard', [
1298 'user_id' => [
'integer', $this->
getId()],
1299 'content' => [
'clob', $a_content],
1300 'insert_time' => [
'timestamp', $a_time],
1301 'order_nr' => [
'integer', $a_nr]
1317 $set =
$ilDB->queryF(
'SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ' .
1318 ' WHERE user_id = %s', [
'integer'], [$this->
getId()]);
1319 $row =
$ilDB->fetchAssoc($set);
1321 $set =
$ilDB->queryF(
1322 'SELECT * FROM personal_pc_clipboard ' .
1323 ' WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC',
1324 [
'integer',
'timestamp'],
1325 [$this->
getId(), $row[
'mtime']]
1328 while ($row =
$ilDB->fetchAssoc($set)) {
1329 $content[] = $row[
'content'];
1344 $set =
$ilDB->queryF(
1345 'SELECT * FROM personal_clipboard WHERE ' .
1346 'parent = %s AND type = %s AND user_id = %s',
1347 [
'integer',
'text',
'integer'],
1348 [0, $a_type, $this->
getId()]
1350 if (
$ilDB->fetchAssoc($set)) {
1362 'DELETE FROM personal_clipboard WHERE ' .
1363 'type = %s AND user_id = %s',
1364 [
'text',
'integer'],
1365 [$a_type, $this->
getId()]
1375 $ilDB->manipulateF(
'DELETE FROM personal_clipboard WHERE ' .
1376 'user_id = %s', [
'integer'], [$this->
getId()]);
1383 string $a_type =
'',
1384 bool $a_top_nodes_only =
false
1391 if ($a_top_nodes_only) {
1392 $par =
' AND parent = ' .
$ilDB->quote(0,
'integer') .
' ';
1395 $type_str = ($a_type !=
'')
1396 ?
' AND type = ' .
$ilDB->quote($a_type,
'text') .
' '
1398 $q =
'SELECT * FROM personal_clipboard WHERE ' .
1399 'user_id = ' .
$ilDB->quote($this->
getId(),
'integer') .
' ' .
1401 ' ORDER BY order_nr';
1404 while ($obj =
$ilDB->fetchAssoc($objs)) {
1405 if ($obj[
'type'] ==
'mob') {
1411 if ($obj[
'type'] ==
'incl') {
1417 $objects[] = [
'id' => $obj[
'item_id'],
1418 'type' => $obj[
'type'],
'title' => $obj[
'title'],
1419 'insert_time' => $obj[
'insert_time']];
1429 string $a_insert_time
1434 $ilUser =
$DIC[
'ilUser'];
1436 $objs =
$ilDB->queryF(
1437 'SELECT * FROM personal_clipboard WHERE ' .
1438 'user_id = %s AND parent = %s AND insert_time = %s ' .
1439 ' ORDER BY order_nr',
1440 [
'integer',
'integer',
'timestamp'],
1441 [$ilUser->getId(), $a_parent, $a_insert_time]
1444 while ($obj =
$ilDB->fetchAssoc($objs)) {
1445 if ($obj[
'type'] ==
'mob') {
1448 $objects[] = [
'id' => $obj[
'item_id'],
1449 'type' => $obj[
'type'],
'title' => $obj[
'title'],
'insert_time' => $obj[
'insert_time']];
1460 $q =
'DELETE FROM personal_clipboard WHERE ' .
1461 'item_id = ' .
$ilDB->quote($a_item_id,
'integer') .
1462 ' AND type = ' .
$ilDB->quote($a_type,
'text') .
' ' .
1463 ' AND user_id = ' .
$ilDB->quote($this->
getId(),
'integer');
1469 return self::lookupOrgUnitsRepresentation($this->
getId());
1477 string $a_size =
'small',
1478 bool $a_force_pic =
false
1480 if (isset(self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic])) {
1481 return self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic];
1484 self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic] = self::_getPersonalPicturePath($this->
getId(), $a_size, $a_force_pic);
1486 return self::$personal_image_cache[$this->
getId()][$a_size][(
int) $a_force_pic];
1496 return self::_getAvatar($this->
getId());
1501 if ($this->getAvatarRid() !==
null) {
1505 $this->profile_data = $this->profile_data->withAvatarRid(
null);
1516 $rbacreview =
$DIC[
'rbacreview'];
1517 $profile =
$DIC[
'user']->getProfile();
1522 $body =
"{$language->txt('login')}: {$this->getLogin()}\n";
1524 if ($this->profile_data->getTitle() !==
'') {
1525 $body .=
"{$language->txt('title')}: {$this->profile_data->getTitle()}\n";
1527 if ($this->getGender() !==
'') {
1528 $body .= ($language->
txt(
'gender') .
': ' . $language->
txt(
'gender_' . strtolower($this->getGender())) .
"\n");
1530 if ($this->getFirstname() !==
'') {
1531 $body .= ($language->
txt(
'firstname') .
': ' . $this->getFirstname() .
"\n");
1533 if ($this->getLastname() !==
'') {
1534 $body .= ($language->
txt(
'lastname') .
': ' . $this->getLastname() .
"\n");
1536 if ($this->getInstitution() !==
'') {
1537 $body .= ($language->
txt(
'institution') .
': ' . $this->getInstitution() .
"\n");
1539 if ($this->getDepartment() !==
'') {
1540 $body .= ($language->
txt(
'department') .
': ' . $this->getDepartment() .
"\n");
1542 if ($this->getStreet() !==
'') {
1543 $body .= ($language->
txt(
'street') .
': ' . $this->getStreet() .
"\n");
1545 if ($this->getCity() !==
'') {
1546 $body .= ($language->
txt(
'city') .
': ' . $this->getCity() .
"\n");
1548 if ($this->getZipcode() !==
'') {
1549 $body .= ($language->
txt(
'zipcode') .
': ' . $this->getZipcode() .
"\n");
1551 if ($this->getCountry() !==
'') {
1552 $body .= ($language->
txt(
'country') .
': ' . $this->getCountry() .
"\n");
1554 if ($this->getPhoneOffice() !==
'') {
1555 $body .= ($language->
txt(
'phone_office') .
': ' . $this->getPhoneOffice() .
"\n");
1557 if ($this->getPhoneHome() !==
'') {
1558 $body .= ($language->
txt(
'phone_home') .
': ' . $this->getPhoneHome() .
"\n");
1560 if ($this->getPhoneMobile() !==
'') {
1561 $body .= ($language->
txt(
'phone_mobile') .
': ' . $this->getPhoneMobile() .
"\n");
1563 if ($this->getFax() !==
'') {
1564 $body .= ($language->
txt(
'fax') .
': ' . $this->getFax() .
"\n");
1566 if ($this->getEmail() !==
'') {
1567 $body .= ($language->
txt(
'email') .
': ' . $this->getEmail() .
"\n");
1569 if ($this->getSecondEmail() !==
null
1570 && $this->getSecondEmail() !==
'') {
1571 $body .= ($language->
txt(
'second_email') .
': ' . $this->getSecondEmail() .
"\n");
1573 if ($this->getHobby() !==
'') {
1574 $body .= ($language->
txt(
'hobby') .
': ' . $this->getHobby() .
"\n");
1576 if ($this->getComment() !==
'') {
1577 $body .= ($language->
txt(
'referral_comment') .
': ' . $this->getComment() .
"\n");
1579 if ($this->getMatriculation() !==
'') {
1580 $body .= ($language->
txt(
'matriculation') .
': ' . $this->getMatriculation() .
"\n");
1582 if ($this->getCreateDate() !==
'') {
1588 $body .= ($language->
txt(
'create_date') .
': ' . $date .
"\n");
1592 foreach ($rbacreview->getGlobalRoles() as $role) {
1593 if ($rbacreview->isAssigned($this->getId(), $role)) {
1598 $body .= ($language->
txt(
'reg_role_info') .
': ' . implode(
',', $gr) .
"\n");
1602 if ($this->getTimeLimitUnlimited()) {
1603 $body .= ($language->
txt(
'time_limit') .
': ' . $language->
txt(
'crs_unlimited') .
"\n");
1616 $body .= $language->
txt(
'time_limit') .
': ' .
1617 $language->
txt(
'from') .
' ' .
1622 foreach ($profile->getAllUserDefinedFields() as $field) {
1623 $data = $field->retrieveValueFromUser($this);
1625 $body .=
"{$field->getLabel($this->lng)}: {$data}\n";
1637 ($a_password ==
'') ?
'' : md5($a_password)
1643 return in_array($this->getPref(
'public_profile'), [
'y',
'g']);
1648 if ($this->hasPublicProfile()) {
1649 return $this->getFirstname() .
' ' . $this->getLastname() .
' (' . $this->getLogin() .
')';
1652 return $this->getLogin();
1659 $query =
'UPDATE object_data SET owner = 0 ' .
1660 'WHERE owner = ' .
$ilDB->quote($this->
getId(),
'integer');
1661 $ilDB->query($query);
1665 public function exportPersonalData(): void
1667 if (!isset($this->
user)) {
1669 $this->
user = $DIC->user();
1671 $export_consumer = (
new ExportFactory())->consumer()->handler();
1672 $configs = $export_consumer->exportConfig()->allExportConfigs();
1674 $config = $configs->getElementByClassName(
'ilUserExportConfig');
1675 $config->setExportType(
'personal_data');
1676 $export = $export_consumer->createStandardExportByObject(
1677 $this->
user->getId(),
1681 $stream = Streams::ofString($export->getIRSSInfo()->getStream()->getContents());
1682 $file_name = $export->getIRSSInfo()->getFileName();
1683 $export->getIRSS()->delete($export_consumer->exportStakeholderHandler());
1684 $this->delivery->deliver($stream, $file_name);
1690 if (!is_dir($dir)) {
1694 if (is_int(strpos($entry[
'entry'],
'.zip'))) {
1695 return $entry[
'entry'];
1705 '/' . $this->getPersonalDataExportFile();
1706 if (is_file($file)) {
1713 bool $a_profile_data,
1721 if (!$a_profile_data) {
1722 $imp->addSkipEntity(
'components/ILIAS/User',
'usr_profile');
1725 $imp->addSkipEntity(
'components/ILIAS/User',
'usr_setting');
1728 $imp->addSkipEntity(
'components/ILIAS/Notes',
'user_notes');
1731 $imp->addSkipEntity(
'components/ILIAS/Calendar',
'calendar');
1734 $a_file[
'tmp_name'],
1737 'components/ILIAS/User'
1743 $this->inactivation_date = $inactivation_date;
1748 return $this->inactivation_date;
1753 return self::_isAnonymous($this->
getId());
1763 $this->writePref(
'delete_flag',
true);
1768 $this->writePref(
'delete_flag',
false);
1773 return (
bool) $this->getPref(
'delete_flag');
1778 $this->is_self_registered = $status;
1783 return $this->is_self_registered;
1791 $this->profile_data = $this->profile_data->withAdditionalFieldByIdentifier(
1792 $this->profile_configuration_repository->getByClass(Interests::class)->getIdentifier(),
1802 return $this->profile_data->getAdditionalFieldByIdentifier(
1803 $this->profile_configuration_repository->getByClass(Interests::class)->getIdentifier()
1812 return $this->buildTextFromArray($this->getGeneralInterests());
1820 $this->profile_data = $this->profile_data->withAdditionalFieldByIdentifier(
1821 $this->profile_configuration_repository->getByClass(HelpOffered::class)->getIdentifier(),
1831 return $this->profile_data->getAdditionalFieldByIdentifier(
1832 $this->profile_configuration_repository->getByClass(HelpOffered::class)->getIdentifier()
1841 return $this->buildTextFromArray($this->getOfferingHelp());
1846 $this->profile_data = $this->profile_data->withAdditionalFieldByIdentifier(
1847 $this->profile_configuration_repository->getByClass(HelpLookedFor::class)->getIdentifier(),
1854 return $this->profile_data->getAdditionalFieldByIdentifier(
1855 $this->profile_configuration_repository->getByClass(HelpLookedFor::class)->getIdentifier()
1861 return $this->buildTextFromArray($this->getLookingForHelp());
1870 $stream = Streams::ofResource(fopen($tmp_file,
'rb'));
1872 if ($this->getAvatarRid() !==
null && $this->getAvatarRid() !== ilObjUser::NO_AVATAR_RID) {
1873 $rid = $this->irss->manage()->find($this->getAvatarRid());
1875 $this->irss->manage()->replaceWithStream(
1882 $rid = $this->irss->manage()->stream(
1888 $this->setAvatarRid($rid);
1896 $hashcode = substr(md5(uniqid(mt_rand(),
true)), 0, 16);
1898 $res = $this->db->queryf(
1899 'SELECT COUNT(usr_id) cnt FROM usr_data WHERE reg_hash = %s',
1904 if ($row->cnt > 0) {
1910 $this->db->manipulateF(
1911 'UPDATE usr_data SET reg_hash = %s WHERE usr_id = %s',
1913 [$hashcode, $this->
id]
1924 if (count($a_attr) > 0) {
1925 return implode(
', ', $a_attr);
1941 $q =
'SELECT DISTINCT login, usr_id FROM usr_data ' .
1944 $values[] = $a_login;
1946 if ($a_user_id != 0) {
1947 $q .=
' AND usr_id != %s ';
1948 $types[] =
'integer';
1949 $values[] = $a_user_id;
1952 $r =
$ilDB->queryF(
$q, $types, $values);
1954 if (($row =
$ilDB->fetchAssoc($r))) {
1955 return (
int) $row[
'usr_id'];
1961 string $a_external_account,
1968 'SELECT * FROM usr_data ' .
1969 'WHERE ext_account = %s AND auth_mode = %s',
1971 [$a_external_account, $a_auth_mode]
1982 $rbacreview =
$DIC[
'rbacreview'];
1984 $ids = $rbacreview->assignedUsers($role_id);
1986 if (count($ids) == 0) {
1990 $query =
'SELECT usr_data.*, usr_pref.value AS language
1992 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
1993 WHERE ' .
$ilDB->in(
'usr_data.usr_id', $ids,
false,
'integer');
1994 $values[] =
'language';
1998 if (is_numeric($active) && $active > -1) {
1999 $query .=
' AND usr_data.active = %s';
2000 $values[] = $active;
2001 $types[] =
'integer';
2004 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2006 $r =
$ilDB->queryF($query, $types, $values);
2008 while ($row =
$ilDB->fetchAssoc($r)) {
2021 $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';
2023 $values[] =
'language';
2025 if (is_numeric($active) && $active > -1) {
2026 $query .=
' AND usr_data.active = %s';
2027 $values[] = $active;
2028 $types[] =
'integer';
2032 $query .=
' AND usr_data.time_limit_owner = %s';
2034 $types[] =
'integer';
2037 $query .=
' AND usr_data.usr_id != %s ';
2039 $types[] =
'integer';
2041 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2043 $result =
$ilDB->queryF($query, $types, $values);
2045 while ($row =
$ilDB->fetchAssoc($result)) {
2056 return self::_getUsersForIds($a_mem_ids, $active);
2062 int $timelimitowner = -1
2067 $query =
'SELECT usr_data.*, usr_pref.value AS language
2069 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
2070 WHERE ' .
$ilDB->in(
'usr_data.usr_id', $a_mem_ids,
false,
'integer') .
'
2071 AND usr_data.usr_id != %s';
2072 $values[] =
'language';
2075 $types[] =
'integer';
2077 if (is_numeric($active) && $active > -1) {
2078 $query .=
' AND active = %s';
2079 $values[] = $active;
2080 $types[] =
'integer';
2083 if ($timelimitowner !=
USER_FOLDER_ID && $timelimitowner != -1) {
2084 $query .=
' AND usr_data.time_limit_owner = %s';
2085 $values[] = $timelimitowner;
2086 $types[] =
'integer';
2089 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2091 $result =
$ilDB->queryF($query, $types, $values);
2093 while ($row =
$ilDB->fetchAssoc($result)) {
2106 if (is_array($a_internalids)) {
2107 foreach ($a_internalids as $internalid) {
2108 if (is_numeric($internalid)) {
2109 $ids[] = $internalid;
2112 if (is_numeric($parsedid) && $parsedid > 0) {
2118 if (count($ids) == 0) {
2122 $query =
'SELECT usr_data.*, usr_pref.value AS language
2125 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
2126 WHERE ' .
$ilDB->in(
'usr_data.usr_id', $ids,
false,
'integer');
2127 $values[] =
'language';
2130 $query .=
' ORDER BY usr_data.lastname, usr_data.firstname ';
2133 $result =
$ilDB->queryF($query, $types, $values);
2134 while ($row =
$ilDB->fetchAssoc($result)) {
2148 'SELECT * FROM usr_pref WHERE usr_id = %s',
2153 while ($row =
$ilDB->fetchAssoc($r)) {
2154 $prefs[$row[
'keyword']] = $row[
'value'];
2169 $set =
$ilDB->query(
2170 'SELECT usr_id FROM usr_pref ' .
2171 ' WHERE keyword = ' .
$ilDB->quote($a_keyword,
'text') .
2172 ' AND ' .
$ilDB->in(
'usr_id', $a_user_ids,
false,
'integer') .
2173 ' AND value = ' .
$ilDB->quote($a_val,
'text')
2175 while ($rec =
$ilDB->fetchAssoc($set)) {
2176 $users[] = $rec[
'usr_id'];
2187 $query =
'SELECT login_attempts FROM usr_data WHERE usr_id = %s';
2188 $result =
$ilDB->queryF($query, [
'integer'], [$a_usr_id]);
2189 $record =
$ilDB->fetchAssoc($result);
2190 return (
int) ($record[
'login_attempts'] ?? 0);
2199 $query =
'UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s';
2200 $affected =
$ilDB->manipulateF($query, [
'integer'], [$a_usr_id]);
2215 $query =
'UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s';
2216 $affected =
$ilDB->manipulateF($query, [
'timestamp',
'integer'], [
ilUtil::now(), $a_usr_id]);
2227 bool $a_no_anonymous =
false
2235 $atime = $pd_set->get(
'user_activity_time') * 60;
2240 if ($a_user_id === 0) {
2241 $where[] =
'user_id > 0';
2243 $where[] =
'user_id = ' .
$ilDB->quote($a_user_id,
'integer');
2246 if ($a_no_anonymous) {
2254 $where[] =
'expires > ' .
$ilDB->quote($ctime,
'integer');
2255 $where[] =
'(p.value IS NULL OR NOT p.value = ' .
$ilDB->quote(
'y',
'text') .
')';
2257 $where =
'WHERE ' . implode(
' AND ', $where);
2261 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime, context, agree_date
2263 LEFT JOIN usr_data u
2264 ON user_id = u.usr_id
2265 LEFT JOIN usr_pref p
2266 ON (p.usr_id = u.usr_id AND p.keyword = %s)
2268 GROUP BY user_id, firstname, lastname, title, login, last_login, context, agree_date
2269 ORDER BY lastname, firstname
2272 [
'hide_own_online_status']
2275 $log->debug(
'Query: ' .
$q);
2278 while ($user =
$ilDB->fetchAssoc($r)) {
2279 if ($atime <= 0 || $user[
'ctime'] + $atime > $ctime) {
2280 $users[$user[
'user_id']] = $user;
2284 $log->debug(
'Found users: ' . count($users));
2286 $hide_users =
$DIC[
'legalDocuments']->usersWithHiddenOnlineStatus(array_map(intval(...), array_column($users,
'user_id')));
2287 $users = array_filter(
2289 fn($user) => !in_array((
int) $user[
'user_id'], $hide_users,
true)
2302 'SELECT usr_id, create_date FROM usr_data WHERE reg_hash = %s',
2307 $row = $db->fetchAssoc(
$res);
2313 if ($lifetime > 0) {
2314 $cutoff = (
new DataFactory())->clock()->utc()
2316 new DateInterval(
"PT{$lifetime}S")
2319 $created = DateTimeImmutable::createFromFormat(
2320 self::DATABASE_DATE_FORMAT,
2321 (
string) $row[
'create_date'],
2322 new DateTimeZone(
'UTC')
2325 if ($created ===
false || $created < $cutoff) {
2327 'reg_confirmation_hash_life_time_expired',
2328 (
int) $row[
'usr_id']
2334 'UPDATE usr_data SET reg_hash = NULL WHERE usr_id = %s',
2336 [(
int) $row[
'usr_id']]
2339 return (
int) $row[
'usr_id'];
2348 if ($periodInDays < 1) {
2352 $date = date(
'Y-m-d H:i:s', (time() - ($periodInDays * 24 * 60 * 60)));
2354 $query =
'SELECT usr_id FROM usr_data WHERE last_login IS NOT NULL AND last_login < %s';
2358 $types = [
'timestamp'];
2361 $res =
$ilDB->queryF($query, $types, $values);
2362 while ($row =
$ilDB->fetchAssoc(
$res)) {
2363 $ids[] = (
int) $row[
'usr_id'];
2370 int $thresholdInDays
2375 $date = date(
'Y-m-d H:i:s', (time() - ($thresholdInDays * 24 * 60 * 60)));
2377 $query =
'SELECT usr_id FROM usr_data WHERE last_login IS NULL AND create_date < %s';
2381 $types = [
'timestamp'];
2384 $res =
$ilDB->queryF($query, $types, $values);
2385 while ($row =
$ilDB->fetchAssoc(
$res)) {
2386 $ids[] = (
int) $row[
'usr_id'];
2403 'SELECT usr_id FROM usr_data WHERE inactivation_date < %s AND active = %s',
2404 [
'timestamp',
'integer'],
2406 date(
'Y-m-d H:i:s', (time() - ($period * 24 * 60 * 60))),
2412 while ($row = $db->fetchObject(
$res)) {
2413 $ids[] = (
int) $row->usr_id;
2420 ?array $user_ids =
null
2425 $q =
'SELECT DISTINCT ' .
$ilDB->upper(
$ilDB->substr(
'lastname', 1, 1)) .
' let' .
2428 ($user_ids !==
null ?
' AND ' .
$ilDB->in(
'usr_id', $user_ids,
false,
'integer') :
'') .
2433 while ($let_rec =
$ilDB->fetchAssoc($let_set)) {
2434 $let[$let_rec[
'let']] = $let_rec[
'let'];
2440 array $a_usr_ids = []
2445 $query =
'SELECT count(*) num FROM object_data od ' .
2446 'JOIN usr_data ud ON obj_id = usr_id ' .
2447 'WHERE ' .
$ilDB->in(
'obj_id', $a_usr_ids,
false,
'integer') .
' ';
2450 return $num_rows == count($a_usr_ids);
2460 SELECT * FROM loginname_history
2476 $query =
'SELECT * FROM usr_pref WHERE usr_id = ' .
$ilDB->quote($a_usr_id,
'integer') .
' ' .
2477 'AND keyword = ' .
$ilDB->quote($a_keyword,
'text');
2491 $query =
'SELECT matriculation FROM usr_data ' .
2492 'WHERE usr_id = ' .
$ilDB->quote($a_usr_id);
2495 return $row->matriculation ?:
'';
2500 ?
int $a_user_id =
null,
2501 ?
string $a_field_id =
null
2508 $sql =
'SELECT DISTINCT(value)' .
2509 ' FROM usr_profile_data' .
2510 ' WHERE ' .
$ilDB->like(
'value',
'text',
'%' . $a_term .
'%');
2512 $sql .=
' AND field_id = ' .
$ilDB->quote($a_field_id,
'text');
2515 $sql .=
' AND usr_id <> ' .
$ilDB->quote($a_user_id,
'integer');
2517 $sql .=
' ORDER BY value';
2518 $set =
$ilDB->query($sql);
2519 while ($row =
$ilDB->fetchAssoc($set)) {
2520 $res[] = $row[
'value'];
2532 $set =
$ilDB->query(
2533 'SELECT * FROM usr_pref ' .
2534 ' WHERE keyword = ' .
$ilDB->quote(
'public_profile',
'text') .
2535 ' AND ' .
$ilDB->in(
'usr_id', $a_user_ids,
false,
'integer')
2543 while ($rec =
$ilDB->fetchAssoc($set)) {
2544 if ($rec[
'value'] ==
'g') {
2545 $r[
'global'][] = $rec[
'usr_id'];
2546 $r[
'public'][] = $rec[
'usr_id'];
2548 if ($rec[
'value'] ==
'y') {
2549 $r[
'local'][] = $rec[
'usr_id'];
2550 $r[
'public'][] = $rec[
'usr_id'];
2553 foreach ($a_user_ids as
$id) {
2554 if (!in_array(
$id, $r[
'public'])) {
2555 $r[
'not_public'][] =
$id;
2570 'SELECT ' . $a_field .
' FROM usr_data WHERE usr_id = %s',
2575 while ($set =
$ilDB->fetchAssoc(
$res)) {
2576 return $set[$a_field];
2588 $set =
$ilDB->queryF(
2589 'SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s',
2594 if ($rec =
$ilDB->fetchAssoc($set)) {
2595 if ($rec[
'title']) {
2596 $fullname = $rec[
'title'] .
' ';
2598 if ($rec[
'firstname']) {
2599 $fullname .= $rec[
'firstname'] .
' ';
2601 if ($rec[
'lastname']) {
2602 $fullname .= $rec[
'lastname'];
2610 return self::_lookup($a_user_id,
'email') ??
'';
2615 return (
string) self::_lookup($a_user_id,
'gender') ??
'';
2620 return self::_lookup($a_user_id,
'client_ip') ??
'';
2629 'SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s',
2633 if (($user_rec =
$ilDB->fetchAssoc(
$res))) {
2634 return [
'user_id' => $a_user_id,
2635 'firstname' => $user_rec[
'firstname'],
2636 'lastname' => $user_rec[
'lastname'],
2637 'title' => $user_rec[
'title'],
2638 'login' => $user_rec[
'login']
2641 return [
'user_id' => 0,
2655 $q =
'SELECT value FROM usr_pref WHERE usr_id= ' .
2656 $ilDB->quote($a_usr_id,
'integer') .
' AND keyword = ' .
2657 $ilDB->quote(
'language',
'text');
2660 while ($row =
$ilDB->fetchAssoc($r)) {
2661 return (
string) $row[
'value'];
2663 if (is_object(
$lng)) {
2664 return $lng->getDefaultLanguage();
2677 'UPDATE usr_data ' .
2678 ' SET ext_account = %s WHERE usr_id = %s',
2679 [
'text',
'integer'],
2680 [$a_ext_id, $a_usr_id]
2690 'UPDATE usr_data ' .
2691 ' SET auth_mode = %s WHERE usr_id = %s',
2692 [
'text',
'integer'],
2693 [$a_auth_mode, $a_usr_id]
2706 'SELECT * FROM usr_data WHERE usr_id = %s',
2719 $query =
'SELECT usr_id FROM usr_data ' .
2720 'WHERE active = ' .
$ilDB->quote(1,
'integer') .
' ' .
2721 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'integer');
2731 return (
string) self::_lookup($a_user_id,
'login') ??
'';
2736 return (
string) self::_lookup($a_user_id,
'ext_account') ??
'';
2746 string $a_auth_mode,
2747 bool $a_read_auth_default =
false
2754 $q =
'SELECT login,usr_id,ext_account,auth_mode FROM usr_data ' .
2755 'WHERE auth_mode = %s';
2757 $values[] = $a_auth_mode;
2759 $q .=
' OR auth_mode = %s ';
2761 $values[] =
'default';
2766 while ($row =
$ilDB->fetchObject(
$res)) {
2767 if ($row->auth_mode ==
'default') {
2768 $accounts[$row->usr_id] = $row->login;
2770 $accounts[$row->usr_id] = $row->ext_account;
2785 $q =
'UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE ' .
2786 $ilDB->in(
'usr_id', $a_usr_ids,
false,
'integer');
2789 $usrId_IN_usrIds =
$ilDB->in(
'usr_id', $a_usr_ids,
false,
'integer');
2791 $q =
'UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds';
2796 SET inactivation_date = %s
2797 WHERE inactivation_date IS NULL
2798 AND $usrId_IN_usrIds
2806 return (
string) self::_lookup($a_usr_id,
'auth_mode');
2816 bool $tryFallback =
true
2819 $settings =
$GLOBALS[
'DIC']->settings();
2823 'SELECT * FROM usr_data WHERE ' .
2824 ' ext_account = %s AND auth_mode = %s',
2826 [$a_account, $a_auth]
2828 if ($usr = $db->fetchAssoc($r)) {
2829 return $usr[
'login'];
2832 if (!$tryFallback) {
2838 'SELECT login FROM usr_data ' .
2839 'WHERE login = %s AND auth_mode = %s AND (ext_account IS NULL OR ext_account = "") ',
2841 [$a_account, $a_auth]
2843 if ($usr = $db->fetchAssoc(
$res)) {
2844 return $usr[
'login'];
2850 'SELECT login FROM usr_data WHERE ' .
2851 ' ext_account = %s AND auth_mode = %s',
2853 [$a_account,
'default']
2855 if ($usr = $db->fetchAssoc(
$res)) {
2856 return $usr[
'login'];
2860 'SELECT login FROM usr_data ' .
2861 'WHERE login = %s AND (ext_account IS NULL OR ext_account = "") AND auth_mode = %s',
2863 [$a_account,
'default']
2865 if ($usr = $db->fetchAssoc(
$res)) {
2866 return $usr[
'login'];
2874 return (
int) self::_lookupId($a_login);
2883 'SELECT usr_id FROM usr_data ' .
2884 'WHERE email = %s and active = 1',
2889 while ($row =
$ilDB->fetchObject(
$res)) {
2890 $ids[] = (
int) $row->usr_id;
2902 'SELECT login FROM usr_data ' .
2903 'WHERE email = %s and active = 1',
2908 while ($row =
$ilDB->fetchObject(
$res)) {
2909 $ids[] = $row->login;
2916 string|array $a_user_str
2921 if (!is_array($a_user_str)) {
2923 'SELECT usr_id FROM usr_data WHERE login = %s',
2929 if (is_array($user_rec)) {
2930 return (
int) $user_rec[
'usr_id'];
2936 $set =
$ilDB->query(
2937 'SELECT usr_id FROM usr_data ' .
2938 ' WHERE ' .
$ilDB->in(
'login', $a_user_str,
false,
'text')
2942 while ($rec =
$ilDB->fetchAssoc($set)) {
2943 $ids[] = (
int) $rec[
'usr_id'];
2951 return self::_lookup($a_user_id,
'last_login') ??
'';
2956 return self::_lookup($a_user_id,
'first_login') ??
'';
2961 string $a_session_id
2966 $set =
$ilDB->queryf(
2968 SELECT COUNT(*) session_count
2969 FROM usr_session WHERE user_id = %s AND expires > %s AND session_id != %s ',
2970 [
'integer',
'integer',
'text'],
2971 [$a_user_id, time(), $a_session_id]
2973 $row =
$ilDB->fetchAssoc($set);
2974 return (
bool) $row[
'session_count'];
2982 $res =
$ilDB->query(
'SELECT * FROM usr_data WHERE ' .
2983 $ilDB->in(
'usr_id', $a_user_ids,
false,
'integer'));
2985 while ($row =
$ilDB->fetchAssoc(
$res)) {
2986 $user_data[$row[
'usr_id']] = $row;
2998 $q =
'SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ' .
2999 ' WHERE up1.keyword= ' .
$ilDB->quote(
'style',
'text') .
3000 ' AND up1.value= ' .
$ilDB->quote($a_style,
'text') .
3001 ' AND up2.keyword= ' .
$ilDB->quote(
'skin',
'text') .
3002 ' AND up2.value= ' .
$ilDB->quote($a_skin,
'text') .
3003 ' AND up1.usr_id = up2.usr_id ';
3007 $cnt_rec =
$ilDB->fetchAssoc($cnt_set);
3009 return (
int) $cnt_rec[
'cnt'];
3017 $q =
'SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ' .
3018 ' WHERE up1.keyword = ' .
$ilDB->quote(
'style',
'text') .
3019 ' AND up2.keyword = ' .
$ilDB->quote(
'skin',
'text') .
3020 ' AND up1.usr_id = up2.usr_id';
3025 while ($sty_rec =
$ilDB->fetchAssoc($sty_set)) {
3026 $styles[] = $sty_rec[
'skin'] .
':' . $sty_rec[
'style'];
3041 $r =
$ilDB->query(
'SELECT count(*) AS cnt, auth_mode FROM usr_data ' .
3042 'GROUP BY auth_mode');
3044 while ($cnt =
$ilDB->fetchAssoc($r)) {
3045 $cnt_arr[$cnt[
'auth_mode']] = (
int) $cnt[
'cnt'];
3060 $q =
'SELECT * FROM usr_data WHERE ' .
3061 ' email = %s AND (auth_mode = %s ';
3062 $types = [
'text',
'text'];
3063 $values = [$a_email,
'local'];
3066 $q .=
' OR auth_mode = %s';
3068 $values[] =
'default';
3074 $usr_set =
$ilDB->queryF(
$q, $types, $values);
3075 while ($usr_rec =
$ilDB->fetchAssoc($usr_set)) {
3076 $users[$usr_rec[
'usr_id']] = $usr_rec[
'login'];
3083 string $a_from_skin,
3084 string $a_from_style,
3091 $q =
'SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ' .
3092 ' WHERE up1.keyword= ' .
$ilDB->quote(
'style',
'text') .
3093 ' AND up1.value= ' .
$ilDB->quote($a_from_style,
'text') .
3094 ' AND up2.keyword= ' .
$ilDB->quote(
'skin',
'text') .
3095 ' AND up2.value= ' .
$ilDB->quote($a_from_skin,
'text') .
3096 ' AND up1.usr_id = up2.usr_id ';
3100 while ($usr_rec =
$ilDB->fetchAssoc($usr_set)) {
3131 $q =
'SELECT DISTINCT user_id FROM personal_clipboard WHERE ' .
3132 'item_id = ' .
$ilDB->quote($a_id,
'integer') .
' AND ' .
3133 'type = ' .
$ilDB->quote($a_type,
'text');
3136 while ($user_rec =
$ilDB->fetchAssoc($user_set)) {
3137 $users[] = (
int) $user_rec[
'user_id'];
3149 $query =
'SELECT obj_id FROM object_data WHERE import_id = ' .
3150 $ilDB->quote($i2_id,
'text');
3154 while ($row =
$ilDB->fetchObject(
$res)) {
3155 $id = (
int) $row->obj_id;
3169 $define->setSize(
'xsmall');
3170 return $define->getAvatar();
3175 string $a_size =
'small',
3176 bool $a_force_pic =
false
3180 $define->setSize($a_size);
3181 return $define->getLegacyPictureURL();
3189 $irss =
$DIC->resourceStorage();
3191 $clean_dir = trim(str_replace(
'..',
'', $a_dir));
3192 if ($clean_dir ==
'' || !is_dir($clean_dir)) {
3195 $avatar_rid = (
new ilObjUser($a_user_id))->getAvatarRid();
3196 if ($avatar_rid ===
null) {
3201 $clean_dir .
'/usr_' . $a_user_id .
'.jpg',
3202 $irss->
consume()->stream($avatar_rid)->getStream()->getContents()
3208 bool $a_create =
false
3213 if ($a_user_id > 0) {
3214 $set =
$ilDB->queryF(
3215 'SELECT feed_hash from usr_data WHERE usr_id = %s',
3219 if ($rec =
$ilDB->fetchAssoc($set)) {
3220 if (strlen($rec[
'feed_hash']) == 32) {
3221 return $rec[
'feed_hash'];
3222 } elseif ($a_create) {
3223 $hash = md5(random_int(1, 9999999) + str_replace(
' ',
'', microtime()));
3225 'UPDATE usr_data SET feed_hash = %s' .
3226 ' WHERE usr_id = %s',
3227 [
'text',
'integer'],
3240 if ($a_user_id > 0) {
3241 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)
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)
updateLogin(string $login)
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)
getPref(string $a_keyword)
setStreet(string $street)
static _getUsersForIds(array $a_mem_ids, int $active=-1, int $timelimitowner=-1)
setLastLogin(string $a_str)
static _verifyRegistrationHash(string $a_hash)
setFirstLogin(string $date)
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()
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)
deletePref(string $keyword)
setCountry(string $country)
static _getUsersForClipboadObject(string $a_type, int $a_id)
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)
setDepartment(string $department)
static _getPreferences(int $user_id)
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()
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false)
writePref(string $keyword, string $value)
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)
generateRegistrationHash()
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)
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.
Class for user related exception handling in ILIAS.
Class for user related exception handling in ILIAS.
Class ilObjAuthSettingsGUI.
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.
get(string $a_keyword, ?string $a_default_value=null)
get setting
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'))