ILIAS  release_8 Revision v8.24
class.ilObjUser.php
Go to the documentation of this file.
1<?php
2
20
27class ilObjUser extends ilObject
28{
29 public const PASSWD_PLAIN = "plain";
30 public const PASSWD_CRYPTED = "crypted";
31 protected string $ext_account = "";
32 protected string $time_limit_message = "";
33 protected bool $time_limit_unlimited = false;
34 protected ?int $time_limit_until = null;
35 protected ?int $time_limit_from = null;
36 protected ?int $time_limit_owner = null;
37 protected string $last_login = "";
38
39 public string $login = '';
40 protected string $passwd = ""; // password encoded in the format specified by $passwd_type
41 protected string $passwd_type = "";
42 // specifies the password format.
43 // value: ilObjUser::PASSWD_PLAIN or ilObjUser::PASSWD_CRYPTED.
44 // Differences between password format in class ilObjUser and
45 // in table usr_data:
46 // Class ilObjUser supports two different password types
47 // (plain and crypted) and it uses the variables $passwd
48 // and $passwd_type to store them.
49 // Table usr_data supports only two different password types
50 // (md5 and bcrypt) and it uses the columns "passwd" and "passwd_type" to store them.
51 // The conversion between these two storage layouts is done
52 // in the methods that perform SQL statements. All other
53 // methods work exclusively with the $passwd and $passwd_type
54 // variables.
55 protected ?string $password_encoding_type = null; // The encoding algorithm of the user's password stored in the database
56 // A salt used to encrypt the user's password
57 protected ?string $password_salt = null;
58 public string $gender = ""; // 'm' or 'f'
59 public string $utitle = ""; // user title (keep in mind, that we derive $title from object also!)
60 public string $firstname = "";
61 public string $lastname = "";
62 protected ?string $birthday = null;
63 public string $fullname = ""; // title + firstname + lastname in one string
64 public string $institution = "";
65 public string $department = "";
66 public string $street = "";
67 public string $city = "";
68 public string $zipcode = "";
69 public string $country = "";
70 public string $sel_country = "";
71 public string $phone_office = "";
72 public string $phone_home = "";
73 public string $phone_mobile = "";
74 public string $fax = "";
75 public string $email = "";
76 protected ?string $second_email = null;
77 public string $hobby = "";
78 public string $matriculation = "";
79 public string $referral_comment = "";
80 public ?string $approve_date = null;
81 public ?string $agree_date = null;
82 public int $active = 0;
83 public string $client_ip = ""; // client ip to check before login
84 public ?string $auth_mode = null; // authentication mode
85 public ?string $latitude = null;
86 public ?string $longitude = null;
87 public ?string $loc_zoom = null;
89 protected bool $passwd_policy_reset = false;
90 public int $login_attempts = 0;
91 public array $user_defined_data = array(); // Missing array type.
93 protected array $oldPrefs = [];
95 public array $prefs = [];
96 public string $skin = "";
97 protected static array $personal_image_cache = array();
98 protected ?string $inactivation_date = null;
99 private bool $is_self_registered = false; // flag for self registered users
100 protected string $org_units = ""; // ids of assigned org-units, comma seperated
102 protected array $interests_general = [];
104 protected array $interests_help_offered = [];
106 protected array $interests_help_looking = [];
107 protected string $last_profile_prompt = ""; // timestamp
108 protected string $first_login = ""; // timestamp
109 protected bool $profile_incomplete = false;
110
111 public function __construct(
112 int $a_user_id = 0,
113 bool $a_call_by_reference = false
114 ) {
115 global $DIC;
116
117 $ilias = $DIC['ilias'];
118 $this->ilias = $ilias;
119 $this->db = $DIC->database();
120 $this->type = "usr";
121 parent::__construct($a_user_id, $a_call_by_reference);
122 $this->auth_mode = "default";
123 $this->passwd_type = self::PASSWD_PLAIN;
124 if ($a_user_id > 0) {
125 $this->setId($a_user_id);
126 $this->read();
127 } else {
128 $this->prefs = array();
129 $this->prefs["language"] = $this->ilias->ini->readVariable("language", "default");
130 $this->skin = $this->ilias->ini->readVariable("layout", "skin");
131 $this->prefs["skin"] = $this->skin;
132 $this->prefs["style"] = $this->ilias->ini->readVariable("layout", "style");
133 }
134
135 $this->app_event_handler = $DIC['ilAppEventHandler'];
136 }
137
143 public function read(): void
144 {
145 global $DIC;
146
147 $ilErr = $DIC['ilErr'];
149
150 $r = $ilDB->queryF("SELECT * FROM usr_data " .
151 'WHERE usr_id= %s', ['integer'], [$this->id]);
152
153 if ($data = $ilDB->fetchAssoc($r)) {
154 // convert password storage layout used by table usr_data into
155 // storage layout used by class ilObjUser
156 $data["passwd_type"] = self::PASSWD_CRYPTED;
157
158 // this assign must not be set via $this->assignData($data)
159 // because this method will be called on profile updates and
160 // would set this values to 0, because they arent posted from form
161 $this->setLastPasswordChangeTS($data['last_password_change']);
162 $this->setLoginAttempts($data['login_attempts']);
163 $this->setPasswordPolicyResetStatus((bool) $data['passwd_policy_reset']);
164
165 // fill member vars in one shot
166 $this->assignData($data);
167
168 //get userpreferences from usr_pref table
169 $this->readPrefs();
170
171 if (!isset($this->prefs['language']) || $this->prefs['language'] === '') {
172 $this->prefs['language'] = $this->oldPrefs['language'] ?? '';
173 }
174
175 if (
176 !isset($this->prefs['skin']) || $this->prefs['skin'] === '' ||
177 !ilStyleDefinition::skinExists($this->prefs['skin'])
178 ) {
179 $this->prefs['skin'] = $this->oldPrefs['skin'] ?? '';
180 }
181
182 $this->skin = $this->prefs["skin"];
183
184 if (
185 !isset($this->prefs['style']) ||
186 $this->prefs['style'] === '' ||
187 !ilStyleDefinition::styleExists($this->prefs['style']) ||
188 (
189 !ilStyleDefinition::skinExists($this->skin) &&
190 ilStyleDefinition::styleExistsForSkinId($this->skin, $this->prefs['style'])
191 )
192 ) {
193 //load default (css)
194 $this->prefs["style"] = $this->ilias->ini->readVariable("layout", "style");
195 }
196
197 if (empty($this->prefs["hits_per_page"])) {
198 $this->prefs["hits_per_page"] = 10;
199 }
200 } else {
201 $ilErr->raiseError("<b>Error: There is no dataset with id " .
202 $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ .
203 "<br />Line: " . __LINE__, $ilErr->FATAL);
204 }
205
206 $this->readMultiTextFields();
207 $this->readUserDefinedFields();
208
209 parent::read();
210 }
211
212 public function getPasswordEncodingType(): ?string
213 {
215 }
216
217 public function setPasswordEncodingType(?string $password_encryption_type): void
218 {
219 $this->password_encoding_type = $password_encryption_type;
220 }
221
222 public function getPasswordSalt(): ?string
223 {
225 }
226
227 public function setPasswordSalt(?string $password_salt): void
228 {
229 $this->password_salt = $password_salt;
230 }
231
236 public function assignData(array $a_data): void
237 {
238 global $DIC;
239
240 $ilErr = $DIC['ilErr'];
241
242 // basic personal data
243 $this->setLogin($a_data["login"] ?? '');
244 if (!($a_data["passwd_type"] ?? false)) {
245 $ilErr->raiseError("<b>Error: passwd_type missing in function assignData(). " .
246 $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: "
247 . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
248 }
249 if (($a_data["passwd"] ?? '') != "********" && strlen($a_data['passwd'] ?? '')) {
250 $this->setPasswd($a_data["passwd"] ?? '', $a_data["passwd_type"] ?? '');
251 }
252
253 $this->setGender((string) ($a_data["gender"] ?? ''));
254 $this->setUTitle((string) ($a_data["title"] ?? ''));
255 $this->setFirstname((string) ($a_data["firstname"] ?? ''));
256 $this->setLastname((string) ($a_data["lastname"] ?? ''));
257 $this->setFullname();
258 if (isset($a_data['birthday']) && is_string($a_data['birthday'])) {
259 $this->setBirthday($a_data['birthday']);
260 } else {
261 $this->setBirthday(null);
262 }
263
264 // address data
265 $this->setInstitution((string) ($a_data["institution"] ?? ''));
266 $this->setDepartment((string) ($a_data["department"] ?? ''));
267 $this->setStreet((string) ($a_data["street"] ?? ''));
268 $this->setCity((string) ($a_data["city"] ?? ''));
269 $this->setZipcode((string) ($a_data["zipcode"] ?? ''));
270 $this->setCountry((string) ($a_data["country"] ?? ''));
271 $this->setSelectedCountry((string) ($a_data["sel_country"] ?? ''));
272 $this->setPhoneOffice((string) ($a_data["phone_office"] ?? ''));
273 $this->setPhoneHome((string) ($a_data["phone_home"] ?? ''));
274 $this->setPhoneMobile((string) ($a_data["phone_mobile"] ?? ''));
275 $this->setFax((string) ($a_data["fax"] ?? ''));
276 $this->setMatriculation((string) ($a_data["matriculation"] ?? ''));
277 $this->setEmail((string) ($a_data["email"] ?? ''));
278 $this->setSecondEmail((string) ($a_data["second_email"] ?? null));
279 $this->setHobby((string) ($a_data["hobby"] ?? ''));
280 $this->setClientIP((string) ($a_data["client_ip"] ?? ''));
281 $this->setPasswordEncodingType($a_data['passwd_enc_type'] ?? null);
282 $this->setPasswordSalt($a_data['passwd_salt'] ?? null);
283
284 // other data
285 $this->setLatitude($a_data["latitude"] ?? null);
286 $this->setLongitude($a_data["longitude"] ?? null);
287 $this->setLocationZoom($a_data["loc_zoom"] ?? null);
288
289 // system data
290 $this->setLastLogin((string) ($a_data["last_login"] ?? ''));
291 $this->setFirstLogin((string) ($a_data["first_login"] ?? ''));
292 $this->setLastProfilePrompt((string) ($a_data["last_profile_prompt"] ?? ''));
293 $this->setLastUpdate((string) ($a_data["last_update"] ?? ''));
294 $this->create_date = $a_data["create_date"] ?? "";
295 $this->setComment((string) ($a_data["referral_comment"] ?? ''));
296 $this->approve_date = ($a_data["approve_date"] ?? null);
297 $this->active = ($a_data["active"] ?? 0);
298 $this->agree_date = ($a_data["agree_date"] ?? null);
299
300 $this->setInactivationDate((string) ($a_data["inactivation_date"] ?? null));
301
302 // time limitation
303 $this->setTimeLimitOwner((int) ($a_data["time_limit_owner"] ?? 0));
304 $this->setTimeLimitUnlimited((bool) ($a_data["time_limit_unlimited"] ?? false));
305 $this->setTimeLimitFrom((int) ($a_data["time_limit_from"] ?? 0));
306 $this->setTimeLimitUntil((int) ($a_data["time_limit_until"] ?? 0));
307 $this->setTimeLimitMessage((string) ($a_data['time_limit_message'] ?? ''));
308
309 // user profile incomplete?
310 $this->setProfileIncomplete((bool) ($a_data["profile_incomplete"] ?? false));
311
312 //authentication
313 $this->setAuthMode((string) ($a_data['auth_mode'] ?? null));
314 $this->setExternalAccount((string) ($a_data['ext_account'] ?? ''));
315
316 $this->setIsSelfRegistered((bool) ($a_data['is_self_registered'] ?? false));
317 }
318
324 public function saveAsNew(): void
325 {
326 global $DIC;
327
328 $ilAppEventHandler = $DIC['ilAppEventHandler'];
329
330 $ilErr = $DIC['ilErr'];
332 $pw_value = "";
333
334 switch ($this->passwd_type) {
336 if (strlen($this->passwd)) {
337 ilUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
338 $pw_value = $this->getPasswd();
339 } else {
340 $pw_value = $this->passwd;
341 }
342 break;
343
345 $pw_value = $this->passwd;
346 break;
347
348 default:
349 $ilErr->raiseError("<b>Error: passwd_type missing in function saveAsNew. " .
350 $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ .
351 "<br />Line: " . __LINE__, $ilErr->FATAL);
352 }
353
354 if (!$this->active) {
356 } else {
357 $this->setInactivationDate(null);
358 }
359
360 $insert_array = array(
361 "usr_id" => array("integer", $this->id),
362 "login" => array("text", $this->login),
363 "passwd" => array("text", $pw_value),
364 'passwd_enc_type' => array("text", $this->getPasswordEncodingType()),
365 'passwd_salt' => array("text", $this->getPasswordSalt()),
366 "firstname" => array("text", $this->firstname),
367 "lastname" => array("text", $this->lastname),
368 "title" => array("text", $this->utitle),
369 "gender" => array("text", $this->gender),
370 "email" => array("text", trim($this->email)),
371 "second_email" => array("text", trim($this->second_email)),
372 "hobby" => array("text", $this->hobby),
373 "institution" => array("text", $this->institution),
374 "department" => array("text", $this->department),
375 "street" => array("text", $this->street),
376 "city" => array("text", $this->city),
377 "zipcode" => array("text", $this->zipcode),
378 "country" => array("text", $this->country),
379 "sel_country" => array("text", $this->sel_country),
380 "phone_office" => array("text", $this->phone_office),
381 "phone_home" => array("text", $this->phone_home),
382 "phone_mobile" => array("text", $this->phone_mobile),
383 "fax" => array("text", $this->fax),
384 "birthday" => array('date', $this->getBirthday()),
385 "last_login" => array("timestamp", null),
386 "first_login" => array("timestamp", null),
387 "last_profile_prompt" => array("timestamp", null),
388 "last_update" => array("timestamp", ilUtil::now()),
389 "create_date" => array("timestamp", ilUtil::now()),
390 "referral_comment" => array("text", $this->referral_comment),
391 "matriculation" => array("text", $this->matriculation),
392 "client_ip" => array("text", $this->client_ip),
393 "approve_date" => array("timestamp", $this->approve_date),
394 "agree_date" => array("timestamp", $this->agree_date),
395 "active" => array("integer", $this->active),
396 "time_limit_unlimited" => array("integer", $this->getTimeLimitUnlimited()),
397 "time_limit_until" => array("integer", $this->getTimeLimitUntil()),
398 "time_limit_from" => array("integer", $this->getTimeLimitFrom()),
399 "time_limit_owner" => array("integer", $this->getTimeLimitOwner()),
400 "auth_mode" => array("text", $this->getAuthMode()),
401 "ext_account" => array("text", $this->getExternalAccount()),
402 "profile_incomplete" => array("integer", $this->getProfileIncomplete()),
403 "latitude" => array("text", $this->latitude),
404 "longitude" => array("text", $this->longitude),
405 "loc_zoom" => array("integer", (int) $this->loc_zoom),
406 "last_password_change" => array("integer", $this->last_password_change_ts),
407 "passwd_policy_reset" => array("integer", (int) $this->passwd_policy_reset),
408 'inactivation_date' => array('timestamp', $this->inactivation_date),
409 'is_self_registered' => array('integer', (int) $this->is_self_registered),
410 );
411 $ilDB->insert("usr_data", $insert_array);
412
413 $this->updateMultiTextFields(true);
415
416 // CREATE ENTRIES FOR MAIL BOX
417 $mbox = new ilMailbox($this->id);
418 $mbox->createDefaultFolder();
419
420 $mail_options = new ilMailOptions($this->id);
421 $mail_options->createMailOptionsEntry();
422
423 $ilAppEventHandler->raise(
424 "Services/User",
425 "afterCreate",
426 array("user_obj" => $this)
427 );
428 }
429
430 public function update(): bool
431 {
432 global $DIC;
433
434 $ilErr = $DIC['ilErr'];
436 $ilAppEventHandler = $this->app_event_handler;
437
438 $this->syncActive();
439
440 if ($this->getStoredActive($this->id) && !$this->active) {
442 } elseif ($this->active) {
443 $this->setInactivationDate(null);
444 }
445
446 $update_array = [
447 "gender" => ["text", $this->gender],
448 "title" => ["text", $this->utitle],
449 "firstname" => ["text", substr($this->firstname, 0, 128)],
450 "lastname" => ["text", substr($this->lastname, 0, 128)],
451 "email" => ["text", substr(trim($this->email), 0, 128)],
452 "second_email" => ["text", trim($this->second_email)],
453 "birthday" => ['date', $this->getBirthday()],
454 "hobby" => ["text", $this->hobby],
455 "institution" => ["text", $this->institution],
456 "department" => ["text", $this->department],
457 "street" => ["text", $this->street],
458 "city" => ["text", $this->city],
459 "zipcode" => ["text", $this->zipcode],
460 "country" => ["text", $this->country],
461 "sel_country" => ["text", $this->sel_country],
462 "phone_office" => ["text", $this->phone_office],
463 "phone_home" => ["text", $this->phone_home],
464 "phone_mobile" => ["text", $this->phone_mobile],
465 "fax" => ["text", $this->fax],
466 "referral_comment" => ["text", $this->referral_comment],
467 "matriculation" => ["text", $this->matriculation],
468 "client_ip" => ["text", $this->client_ip],
469 "approve_date" => ["timestamp", $this->approve_date],
470 "active" => ["integer", $this->active],
471 "time_limit_unlimited" => ["integer", $this->getTimeLimitUnlimited()],
472 "time_limit_until" => ["integer", $this->getTimeLimitUntil()],
473 "time_limit_from" => ["integer", $this->getTimeLimitFrom()],
474 "time_limit_owner" => ["integer", $this->getTimeLimitOwner()],
475 "time_limit_message" => ["integer", $this->getTimeLimitMessage()],
476 "profile_incomplete" => ["integer", $this->getProfileIncomplete()],
477 "auth_mode" => ["text", $this->getAuthMode()],
478 "ext_account" => ["text", $this->getExternalAccount()],
479 "latitude" => ["text", $this->latitude],
480 "longitude" => ["text", $this->longitude],
481 "loc_zoom" => ["integer", (int) $this->loc_zoom],
482 'login_attempts' => ['integer', $this->login_attempts],
483 "last_password_change" => ["integer", $this->last_password_change_ts],
484 "passwd_policy_reset" => ["integer", $this->passwd_policy_reset],
485 "last_update" => ["timestamp", ilUtil::now()],
486 'inactivation_date' => ['timestamp', $this->inactivation_date],
487 'reg_hash' => ['text', null]
488 ];
489
490 if ($this->agree_date === null || (is_string($this->agree_date) && strtotime($this->agree_date) !== false)) {
491 $update_array["agree_date"] = ["timestamp", $this->agree_date];
492 }
493 switch ($this->passwd_type) {
495 if (strlen($this->passwd)) {
496 ilUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
497 $update_array['passwd'] = ['text', $this->getPasswd()];
498 } else {
499 $update_array["passwd"] = ["text", $this->passwd];
500 }
501 break;
502
504 $update_array["passwd"] = ["text", $this->passwd];
505 break;
506
507 default:
508 $ilErr->raiseError("<b>Error: passwd_type missing in function update()" . $this->id . "!</b><br />class: " .
509 get_class($this) . "<br />Script: " . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
510 }
511
512 $update_array['passwd_enc_type'] = ['text', $this->getPasswordEncodingType()];
513 $update_array['passwd_salt'] = ['text', $this->getPasswordSalt()];
514
515 $ilDB->update("usr_data", $update_array, ["usr_id" => ["integer", $this->id]]);
516
517 $this->updateMultiTextFields();
518
519 $this->writePrefs();
520
521 // update user defined fields
523
524 parent::update();
525 $this->updateOwner();
526
527 $this->read();
528
529 $ilAppEventHandler->raise(
530 "Services/User",
531 "afterUpdate",
532 ["user_obj" => $this]
533 );
534
535 return true;
536 }
537
541 public function writeAccepted(): void
542 {
544 $ilDB->manipulateF("UPDATE usr_data SET agree_date = " . $ilDB->now() .
545 " WHERE usr_id = %s", array("integer"), array($this->getId()));
546 }
547
548 private static function _lookup(
549 int $a_user_id,
550 string $a_field
551 ): ?string {
552 global $DIC;
553
554 $ilDB = $DIC->database();
555
556 $res = $ilDB->queryF(
557 "SELECT " . $a_field . " FROM usr_data WHERE usr_id = %s",
558 array("integer"),
559 array($a_user_id)
560 );
561
562 while ($set = $ilDB->fetchAssoc($res)) {
563 return $set[$a_field];
564 }
565 return null;
566 }
567
568 public static function _lookupFullname(int $a_user_id): string
569 {
570 global $DIC;
571
572 $fullname = "";
573 $ilDB = $DIC['ilDB'];
574
575 $set = $ilDB->queryF(
576 "SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s",
577 array("integer"),
578 array($a_user_id)
579 );
580
581 if ($rec = $ilDB->fetchAssoc($set)) {
582 if ($rec["title"]) {
583 $fullname = $rec["title"] . " ";
584 }
585 if ($rec["firstname"]) {
586 $fullname .= $rec["firstname"] . " ";
587 }
588 if ($rec["lastname"]) {
589 $fullname .= $rec["lastname"];
590 }
591 }
592 return $fullname;
593 }
594
595 public static function _lookupEmail(int $a_user_id): string
596 {
597 return self::_lookup($a_user_id, "email") ?? '';
598 }
599
600 public static function _lookupGender(int $a_user_id): string
601 {
602 return (string) self::_lookup($a_user_id, "gender") ?? '';
603 }
604
605 public static function _lookupClientIP(int $a_user_id): string
606 {
607 return self::_lookup($a_user_id, "client_ip") ?? '';
608 }
609
614 public static function _lookupName(int $a_user_id): array
615 {
616 global $DIC;
617
618 $ilDB = $DIC['ilDB'];
619
620 $res = $ilDB->queryF(
621 "SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
622 array("integer"),
623 array($a_user_id)
624 );
625 if ($user_rec = $ilDB->fetchAssoc($res)) {
626 return array("user_id" => $a_user_id,
627 "firstname" => $user_rec["firstname"],
628 "lastname" => $user_rec["lastname"],
629 "title" => $user_rec["title"],
630 "login" => $user_rec["login"]
631 );
632 }
633 return array("user_id" => 0,
634 "firstname" => "",
635 "lastname" => "",
636 "title" => "",
637 "login" => ""
638 );
639 }
640
645 public static function _lookupFields(int $a_user_id): array // Missing array type.
646 {
647 global $DIC;
648
649 $ilDB = $DIC['ilDB'];
650
651 $res = $ilDB->queryF(
652 "SELECT * FROM usr_data WHERE usr_id = %s",
653 array("integer"),
654 array($a_user_id)
655 );
656 $user_rec = $ilDB->fetchAssoc($res);
657 return $user_rec;
658 }
659
660 public static function _lookupLogin(int $a_user_id): string
661 {
662 return (string) self::_lookup($a_user_id, "login") ?? '';
663 }
664
665 public static function _lookupExternalAccount(int $a_user_id): string
666 {
667 return (string) self::_lookup($a_user_id, "ext_account") ?? '';
668 }
669
674 public static function _lookupId($a_user_str)
675 {
676 global $DIC;
677
678 $ilDB = $DIC['ilDB'];
679
680 if (!is_array($a_user_str)) {
681 $res = $ilDB->queryF(
682 "SELECT usr_id FROM usr_data WHERE login = %s",
683 array("text"),
684 array($a_user_str)
685 );
686
687 $user_rec = $ilDB->fetchAssoc($res);
688 if (is_array($user_rec)) {
689 return (int) $user_rec["usr_id"];
690 }
691
692 return null;
693 }
694
695 $set = $ilDB->query(
696 "SELECT usr_id FROM usr_data " .
697 " WHERE " . $ilDB->in("login", $a_user_str, false, "text")
698 );
699
700 $ids = [];
701 while ($rec = $ilDB->fetchAssoc($set)) {
702 $ids[] = (int) $rec['usr_id'];
703 }
704
705 return $ids;
706 }
707
708 public static function _lookupLastLogin(int $a_user_id): string
709 {
710 return self::_lookup($a_user_id, "last_login") ?? '';
711 }
712
713 public static function _lookupFirstLogin(int $a_user_id): string
714 {
715 return self::_lookup($a_user_id, "first_login") ?? '';
716 }
717
718
723 public function refreshLogin(): void
724 {
725 $ilDB = $this->db;
726
727 $ilDB->manipulateF(
728 "UPDATE usr_data SET " .
729 "last_login = " . $ilDB->now() .
730 " WHERE usr_id = %s",
731 array("integer"),
732 array($this->id)
733 );
734
735 if ($this->getFirstLogin() == "") {
736 $ilDB->manipulateF(
737 "UPDATE usr_data SET " .
738 "first_login = " . $ilDB->now() .
739 " WHERE usr_id = %s",
740 array("integer"),
741 array($this->id)
742 );
743 $this->app_event_handler->raise(
744 "Services/User",
745 "firstLogin",
746 array("user_obj" => $this)
747 );
748 }
749 }
750
751
760 public function resetPassword(
761 string $raw,
762 string $raw_retype
763 ): bool {
764 $ilDB = $this->db;
765
766 if (func_num_args() != 2) {
767 return false;
768 }
769
770 if (!isset($raw) || !isset($raw_retype)) {
771 return false;
772 }
773
774 if ($raw != $raw_retype) {
775 return false;
776 }
777
778 ilUserPasswordManager::getInstance()->encodePassword($this, $raw);
779
780 $ilDB->manipulateF(
781 'UPDATE usr_data
782 SET passwd = %s, passwd_enc_type = %s, passwd_salt = %s
783 WHERE usr_id = %s',
784 array('text', 'text', 'text', 'integer'),
785 array($this->getPasswd(), $this->getPasswordEncodingType(), $this->getPasswordSalt(), $this->getId())
786 );
787
788 return true;
789 }
790
794 public static function _doesLoginnameExistInHistory(string $a_login): bool
795 {
796 global $DIC;
797
798 $ilDB = $DIC->database();
799
800 $res = $ilDB->queryF(
801 '
802 SELECT * FROM loginname_history
803 WHERE login = %s',
804 array('text'),
805 array($a_login)
806 );
807
808 return (bool) $ilDB->fetchAssoc($res);
809 }
810
817 public static function _getLastHistoryDataByUserId(int $a_usr_id): array
818 {
819 global $DIC;
820
821 $ilDB = $DIC['ilDB'];
822
823 $ilDB->setLimit(1, 0);
824 $res = $ilDB->queryF(
825 '
826 SELECT login, history_date FROM loginname_history
827 WHERE usr_id = %s ORDER BY history_date DESC',
828 array('integer'),
829 array($a_usr_id)
830 );
831 $row = $ilDB->fetchAssoc($res);
832 if (!is_array($row) || !count($row)) {
833 throw new ilUserException('');
834 }
835
836 return array(
837 $row['login'], $row['history_date']
838 );
839 }
840
848 public function updateLogin(string $a_login): bool
849 {
850 global $DIC;
851
852 $ilDB = $this->db;
853 $ilSetting = $DIC['ilSetting'];
854 $lng = $DIC->language();
855
856 if (func_num_args() != 1) {
857 return false;
858 }
859
860 if (!isset($a_login)) {
861 return false;
862 }
863
864 $former_login = self::_lookupLogin($this->getId());
865
866 // Update not necessary
867 if (0 == strcmp($a_login, $former_login)) {
868 return false;
869 }
870
871 try {
872 $last_history_entry = self::_getLastHistoryDataByUserId($this->getId());
873 } catch (ilUserException $e) {
874 $last_history_entry = null;
875 }
876
877 // throw exception if the desired loginame is already in history and it is not allowed to reuse it
878 if ((int) $ilSetting->get('allow_change_loginname') &&
879 (int) $ilSetting->get('reuse_of_loginnames') == 0 &&
880 self::_doesLoginnameExistInHistory($a_login)) {
881 throw new ilUserException($lng->txt('loginname_already_exists'));
882 } elseif ((int) $ilSetting->get('allow_change_loginname') &&
883 (int) $ilSetting->get('loginname_change_blocking_time') &&
884 is_array($last_history_entry) &&
885 $last_history_entry[1] + (int) $ilSetting->get('loginname_change_blocking_time') > time()) {
886 throw new ilUserException(
887 sprintf(
888 $lng->txt('changing_loginname_not_possible_info'),
890 new ilDateTime($last_history_entry[1], IL_CAL_UNIX)
891 ),
893 new ilDateTime(($last_history_entry[1] + (int) $ilSetting->get('loginname_change_blocking_time')), IL_CAL_UNIX)
894 )
895 )
896 );
897 } else {
898 // log old loginname in history
899 if ((int) $ilSetting->get('allow_change_loginname') &&
900 (int) $ilSetting->get('create_history_loginname')) {
901 self::_writeHistory($this->getId(), $former_login);
902 }
903
904 //update login
905 $this->login = $a_login;
906
907 $ilDB->manipulateF(
908 '
909 UPDATE usr_data
910 SET login = %s
911 WHERE usr_id = %s',
912 array('text', 'integer'),
913 array($this->getLogin(), $this->getId())
914 );
915 }
916
917 return true;
918 }
919
920 public function writePref(
921 string $a_keyword,
922 string $a_value
923 ): void {
924 self::_writePref($this->id, $a_keyword, $a_value);
925 $this->setPref($a_keyword, $a_value);
926 }
927
928 public function deletePref(string $a_keyword): void
929 {
930 self::_deletePref($this->getId(), $a_keyword);
931 }
932
933 public static function _deletePref(int $a_user_id, string $a_keyword): void
934 {
935 global $DIC;
936
937 $ilDB = $DIC->database();
938
939 $ilDB->manipulateF(
940 'DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s',
941 array('integer', 'text'),
942 array($a_user_id, $a_keyword)
943 );
944 }
945
949 public static function _deleteAllPref(int $a_user_id): void
950 {
951 global $DIC;
952
953 $ilDB = $DIC->database();
954
955 $ilDB->manipulateF(
956 "DELETE FROM usr_pref WHERE usr_id = %s",
957 array("integer"),
958 array($a_user_id)
959 );
960 }
961
962 public static function _writePref(
963 int $a_usr_id,
964 string $a_keyword,
965 string $a_value
966 ): void {
967 global $DIC;
968
969 $ilDB = $DIC->database();
970 $ilDB->replace(
971 "usr_pref",
972 array(
973 "usr_id" => array("integer", $a_usr_id),
974 "keyword" => array("text", $a_keyword),
975 ),
976 array(
977 "value" => array("text",$a_value)
978 )
979 );
980 }
981
982 public function writePrefs(): void
983 {
984 self::_deleteAllPref($this->id);
985 foreach ($this->prefs as $keyword => $value) {
986 self::_writePref($this->id, $keyword, (string) $value);
987 }
988 }
989
990 public function getTimeZone(): string
991 {
992 if ($tz = $this->getPref('user_tz')) {
993 return $tz;
994 } else {
996 return $settings->getDefaultTimeZone();
997 }
998 }
999
1000 public function getTimeFormat(): string
1001 {
1002 if ($format = $this->getPref('time_format')) {
1003 return $format;
1004 } else {
1006 return $settings->getDefaultTimeFormat();
1007 }
1008 }
1009
1010 public function getDateFormat(): string
1011 {
1012 if ($format = $this->getPref('date_format')) {
1013 return $format;
1014 } else {
1016 return $settings->getDefaultDateFormat();
1017 }
1018 }
1019
1020 public function setPref(string $a_keyword, ?string $a_value): void
1021 {
1022 if ($a_keyword != "") {
1023 $this->prefs[$a_keyword] = $a_value;
1024 }
1025 }
1026
1027 public function getPref(string $a_keyword): ?string
1028 {
1029 return $this->prefs[$a_keyword] ?? null;
1030 }
1031
1032 public function existsPref(string $a_keyword): bool
1033 {
1034 return (array_key_exists($a_keyword, $this->prefs));
1035 }
1036
1037 public static function _lookupPref(
1038 int $a_usr_id,
1039 string $a_keyword
1040 ): ?string {
1041 global $DIC;
1042
1043 $ilDB = $DIC['ilDB'];
1044
1045 $query = "SELECT * FROM usr_pref WHERE usr_id = " . $ilDB->quote($a_usr_id, "integer") . " " .
1046 "AND keyword = " . $ilDB->quote($a_keyword, "text");
1047 $res = $ilDB->query($query);
1048
1049 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1050 return $row->value;
1051 }
1052 return null;
1053 }
1054
1055 public function readPrefs(): void
1056 {
1057 if (is_array($this->prefs)) {
1058 $this->oldPrefs = $this->prefs;
1059 }
1060 $this->prefs = self::_getPreferences($this->id);
1061 }
1062
1063 public function delete(): bool
1064 {
1065 global $DIC;
1066
1067 $rbacadmin = $DIC->rbac()->admin();
1068 $ilDB = $this->db;
1069
1070 // deassign from ldap groups
1072 $mapping->deleteUser($this->getId());
1073
1074 // remove mailbox / update sent mails
1075 $mailbox = new ilMailbox($this->getId());
1076 $mailbox->delete();
1077 $mailbox->updateMailsOfDeletedUser($this->getLogin());
1078
1079 // delete block settings
1081
1082 // delete user_account
1083 $ilDB->manipulateF(
1084 "DELETE FROM usr_data WHERE usr_id = %s",
1085 array("integer"),
1086 array($this->getId())
1087 );
1088
1089 $this->deleteMultiTextFields();
1090
1091 // delete user_prefs
1092 self::_deleteAllPref($this->getId());
1093
1094 $this->removeUserPicture(false); // #8597
1095
1096 // delete user_session
1098
1099 // remove user from rbac
1100 $rbacadmin->removeUser($this->getId());
1101
1102 // remove bookmarks
1103 // TODO: move this to class.ilBookmarkFolder
1104 $q = "DELETE FROM bookmark_tree WHERE tree = " .
1105 $ilDB->quote($this->getId(), "integer");
1106 $ilDB->manipulate($q);
1107
1108 $q = "DELETE FROM bookmark_data WHERE user_id = " .
1109 $ilDB->quote($this->getId(), "integer");
1110 $ilDB->manipulate($q);
1111
1112 // Delete crs entries
1114
1115 // Delete user tracking
1117
1119
1120 // Delete Tracking data SCORM 2004 RTE
1122
1123 // Delete Tracking data SCORM 1.2 RTE
1125
1126 // remove all notifications
1128
1129 // remove portfolios
1131
1132 // remove workspace
1133 $tree = new ilWorkspaceTree($this->getId());
1134 $tree->cascadingDelete();
1135
1136 // remove reminder entries
1138
1139 // badges
1141
1142 // remove org unit assignments
1143 $ilOrgUnitUserAssignmentQueries = ilOrgUnitUserAssignmentQueries::getInstance();
1144 $ilOrgUnitUserAssignmentQueries->deleteAllAssignmentsOfUser($this->getId());
1145
1146 // Delete user defined field entries
1147 $this->deleteUserDefinedFieldEntries();
1148
1149 // Delete clipboard entries
1150 $this->clipboardDeleteAll();
1151
1152 // Reset owner
1153 $this->resetOwner();
1154
1155 // Trigger deleteUser Event
1156 global $DIC;
1157
1158 $ilAppEventHandler = $DIC['ilAppEventHandler'];
1159 $ilAppEventHandler->raise(
1160 'Services/User',
1161 'deleteUser',
1162 array('usr_id' => $this->getId())
1163 );
1164
1165 // delete object data
1166 parent::delete();
1167 return true;
1168 }
1169
1175 public function setFullname(): void
1176 {
1177 $this->fullname = ($this->utitle != "")
1178 ? $this->utitle . " "
1179 : "";
1180 $this->fullname .= $this->firstname . " ";
1181 $this->fullname .= $this->lastname;
1182 }
1183
1196 public function getFullname(int $a_max_strlen = 0): string
1197 {
1198 if (!$a_max_strlen) {
1199 return ilUtil::stripSlashes($this->fullname);
1200 }
1201
1202 if (strlen($this->fullname) <= $a_max_strlen) {
1203 return ilUtil::stripSlashes($this->fullname);
1204 }
1205
1206 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen) {
1207 return ilUtil::stripSlashes($this->utitle . " " . substr($this->firstname, 0, 1) . ". " . $this->lastname);
1208 }
1209
1210 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen) {
1211 return ilUtil::stripSlashes($this->firstname . " " . $this->lastname);
1212 }
1213
1214 if ((strlen($this->lastname) + 3) <= $a_max_strlen) {
1215 return ilUtil::stripSlashes(substr($this->firstname, 0, 1) . ". " . $this->lastname);
1216 }
1217
1218 return ilUtil::stripSlashes(substr($this->lastname, 0, $a_max_strlen));
1219 }
1220
1221 public function setLogin(string $a_str): void
1222 {
1223 $this->login = $a_str;
1224 }
1225
1226 public function getLogin(): string
1227 {
1228 return $this->login;
1229 }
1230
1231 public function setPasswd(
1232 string $a_str,
1233 string $a_type = ilObjUser::PASSWD_PLAIN
1234 ): void {
1235 $this->passwd = $a_str;
1236 $this->passwd_type = $a_type;
1237 }
1238
1242 public function getPasswd(): string
1243 {
1244 return $this->passwd;
1245 }
1246
1250 public function getPasswdType(): string
1251 {
1252 return $this->passwd_type;
1253 }
1254
1255 public function setGender(string $a_str): void
1256 {
1257 $this->gender = substr($a_str, -1);
1258 }
1259
1260 public function getGender(): string
1261 {
1262 return $this->gender;
1263 }
1264
1270 public function setUTitle(string $a_str): void
1271 {
1272 $this->utitle = $a_str;
1273 }
1274
1275 public function getUTitle(): string
1276 {
1277 return $this->utitle;
1278 }
1279
1280 public function setFirstname(string $a_str): void
1281 {
1282 $this->firstname = $a_str;
1283 }
1284
1285 public function getFirstname(): string
1286 {
1287 return $this->firstname;
1288 }
1289
1290 public function setLastname(string $a_str): void
1291 {
1292 $this->lastname = $a_str;
1293 }
1294
1295 public function getLastname(): string
1296 {
1297 return $this->lastname;
1298 }
1299
1300 public function setInstitution(string $a_str): void
1301 {
1302 $this->institution = $a_str;
1303 }
1304
1305 public function getInstitution(): string
1306 {
1307 return $this->institution;
1308 }
1309
1310 public function setDepartment(string $a_str): void
1311 {
1312 $this->department = $a_str;
1313 }
1314
1315 public function getDepartment(): string
1316 {
1317 return $this->department;
1318 }
1319
1320 public function setStreet(string $a_str): void
1321 {
1322 $this->street = $a_str;
1323 }
1324
1325 public function getStreet(): string
1326 {
1327 return $this->street;
1328 }
1329
1330 public function setCity(string $a_str): void
1331 {
1332 $this->city = $a_str;
1333 }
1334
1335 public function getCity(): string
1336 {
1337 return $this->city;
1338 }
1339
1340 public function setZipcode(string $a_str): void
1341 {
1342 $this->zipcode = $a_str;
1343 }
1344
1345 public function getZipcode(): string
1346 {
1347 return $this->zipcode;
1348 }
1349
1350 public function setCountry(string $a_str): void
1351 {
1352 $this->country = $a_str;
1353 }
1354
1355 public function getCountry(): string
1356 {
1357 return $this->country;
1358 }
1359
1363 public function setSelectedCountry(string $a_val): void
1364 {
1365 $this->sel_country = $a_val;
1366 }
1367
1371 public function getSelectedCountry(): string
1372 {
1373 return $this->sel_country;
1374 }
1375
1376 public function setPhoneOffice(string $a_str): void
1377 {
1378 $this->phone_office = $a_str;
1379 }
1380
1381 public function getPhoneOffice(): string
1382 {
1383 return $this->phone_office;
1384 }
1385
1386 public function setPhoneHome(string $a_str): void
1387 {
1388 $this->phone_home = $a_str;
1389 }
1390
1391 public function getPhoneHome(): string
1392 {
1393 return $this->phone_home;
1394 }
1395
1396 public function setPhoneMobile(string $a_str): void
1397 {
1398 $this->phone_mobile = $a_str;
1399 }
1400
1401 public function getPhoneMobile(): string
1402 {
1403 return $this->phone_mobile;
1404 }
1405
1406 public function setFax(string $a_str): void
1407 {
1408 $this->fax = $a_str;
1409 }
1410
1411 public function getFax(): string
1412 {
1413 return $this->fax;
1414 }
1415
1416 public function setClientIP(string $a_str): void
1417 {
1418 $this->client_ip = $a_str;
1419 }
1420
1421 public function getClientIP(): string
1422 {
1423 return $this->client_ip;
1424 }
1425
1426 public function setMatriculation(string $a_str): void
1427 {
1428 $this->matriculation = $a_str;
1429 }
1430
1431 public function getMatriculation(): string
1432 {
1433 return $this->matriculation;
1434 }
1435
1436 public static function lookupMatriculation(int $a_usr_id): string
1437 {
1438 global $DIC;
1439
1440 $ilDB = $DIC['ilDB'];
1441
1442 $query = "SELECT matriculation FROM usr_data " .
1443 "WHERE usr_id = " . $ilDB->quote($a_usr_id);
1444 $res = $ilDB->query($query);
1445 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
1446 return $row->matriculation ?: '';
1447 }
1448
1449 public function setEmail(string $a_str): void
1450 {
1451 $this->email = $a_str;
1452 }
1453
1454 public function getEmail(): string
1455 {
1456 return $this->email;
1457 }
1458
1459 public function getSecondEmail(): ?string
1460 {
1461 return $this->second_email;
1462 }
1463
1464 public function setSecondEmail(?string $second_email): void
1465 {
1466 $this->second_email = $second_email;
1467 }
1468
1469 public function setHobby(string $a_str): void
1470 {
1471 $this->hobby = $a_str;
1472 }
1473
1474 public function getHobby(): string
1475 {
1476 return $this->hobby;
1477 }
1478
1479 public function setLanguage(string $a_str): void
1480 {
1481 $this->setPref("language", $a_str);
1482 ilSession::clear('lang');
1483 }
1484
1485 public function getLanguage(): string
1486 {
1487 return $this->prefs["language"];
1488 }
1489
1490 public function setLastPasswordChangeTS(int $a_last_password_change_ts): void
1491 {
1492 $this->last_password_change_ts = $a_last_password_change_ts;
1493 }
1494
1495 public function getLastPasswordChangeTS(): int
1496 {
1497 return $this->last_password_change_ts;
1498 }
1499
1500 public function getPasswordPolicyResetStatus(): bool
1501 {
1502 return $this->passwd_policy_reset;
1503 }
1504
1505 public function setPasswordPolicyResetStatus(bool $status): void
1506 {
1507 $this->passwd_policy_reset = $status;
1508 }
1509
1510 public static function _lookupLanguage(int $a_usr_id): string
1511 {
1512 global $DIC;
1513
1514 $ilDB = $DIC->database();
1515 $lng = $DIC->language();
1516
1517 $q = "SELECT value FROM usr_pref WHERE usr_id= " .
1518 $ilDB->quote($a_usr_id, "integer") . " AND keyword = " .
1519 $ilDB->quote('language', "text");
1520 $r = $ilDB->query($q);
1521
1522 while ($row = $ilDB->fetchAssoc($r)) {
1523 return (string) $row['value'];
1524 }
1525 if (is_object($lng)) {
1526 return $lng->getDefaultLanguage();
1527 }
1528 return 'en';
1529 }
1530
1531 public static function _writeExternalAccount(
1532 int $a_usr_id,
1533 string $a_ext_id
1534 ): void {
1535 global $DIC;
1536
1537 $ilDB = $DIC['ilDB'];
1538
1539 $ilDB->manipulateF(
1540 "UPDATE usr_data " .
1541 " SET ext_account = %s WHERE usr_id = %s",
1542 array("text", "integer"),
1543 array($a_ext_id, $a_usr_id)
1544 );
1545 }
1546
1547 public static function _writeAuthMode(int $a_usr_id, string $a_auth_mode): void
1548 {
1549 global $DIC;
1550
1551 $ilDB = $DIC['ilDB'];
1552
1553 $ilDB->manipulateF(
1554 "UPDATE usr_data " .
1555 " SET auth_mode = %s WHERE usr_id = %s",
1556 array("text", "integer"),
1557 array($a_auth_mode, $a_usr_id)
1558 );
1559 }
1560
1564 public function getCurrentLanguage(): string
1565 {
1566 return (string) ilSession::get('lang');
1567 }
1568
1572 public function setCurrentLanguage(string $a_val): void
1573 {
1574 ilSession::set('lang', $a_val);
1575 }
1576
1577 public function setLastLogin(string $a_str): void
1578 {
1579 $this->last_login = $a_str;
1580 }
1581
1582 public function getLastLogin(): string
1583 {
1584 return $this->last_login;
1585 }
1586
1587 public function setFirstLogin(string $a_str): void
1588 {
1589 $this->first_login = $a_str;
1590 }
1591
1592 public function getFirstLogin(): string
1593 {
1594 return $this->first_login;
1595 }
1596
1597 public function setLastProfilePrompt(string $a_str): void
1598 {
1599 $this->last_profile_prompt = $a_str;
1600 }
1601
1602 public function getLastProfilePrompt(): string
1603 {
1604 return $this->last_profile_prompt;
1605 }
1606
1607 public function setLastUpdate(string $a_str): void
1608 {
1609 $this->last_update = $a_str;
1610 }
1611
1612 public function getLastUpdate(): string
1613 {
1614 return $this->last_update;
1615 }
1616
1617 public function setComment(string $a_str): void
1618 {
1619 $this->referral_comment = $a_str;
1620 }
1621
1622 public function getComment(): string
1623 {
1624 return $this->referral_comment;
1625 }
1626
1631 public function setApproveDate(?string $a_str): void
1632 {
1633 $this->approve_date = $a_str;
1634 }
1635
1636 public function getApproveDate(): ?string
1637 {
1638 return $this->approve_date;
1639 }
1640
1641 public function getAgreeDate(): ?string
1642 {
1643 return $this->agree_date;
1644 }
1645 public function setAgreeDate(?string $a_str): void
1646 {
1647 $this->agree_date = $a_str;
1648 }
1649
1654 public function setActive(
1655 bool $a_active,
1656 int $a_owner = 0
1657 ): void {
1658 $this->setOwner($a_owner);
1659
1660 if ($a_active) {
1661 $this->active = 1;
1662 $this->setApproveDate(date('Y-m-d H:i:s'));
1663 $this->setOwner($a_owner);
1664 } else {
1665 $this->active = 0;
1666 $this->setApproveDate(null);
1667 }
1668 }
1669
1670 public function getActive(): bool
1671 {
1672 return (bool) $this->active;
1673 }
1674
1675 public static function _lookupActive(int $a_usr_id): bool
1676 {
1677 global $DIC;
1678
1679 $ilDB = $DIC['ilDB'];
1680
1681 $query = 'SELECT usr_id FROM usr_data ' .
1682 'WHERE active = ' . $ilDB->quote(1, 'integer') . ' ' .
1683 'AND usr_id = ' . $ilDB->quote($a_usr_id, 'integer');
1684 $res = $ilDB->query($query);
1685 while ($res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1686 return true;
1687 }
1688 return false;
1689 }
1690
1696 public function syncActive(): void
1697 {
1698 $storedActive = 0;
1699 if ($this->getStoredActive($this->id)) {
1700 $storedActive = 1;
1701 }
1702
1703 $currentActive = 0;
1704 if ($this->active) {
1705 $currentActive = 1;
1706 }
1707
1708 if ((!empty($storedActive) && empty($currentActive)) ||
1709 (empty($storedActive) && !empty($currentActive))) {
1710 $this->setActive($currentActive, self::getUserIdByLogin(self::getLoginFromAuth()));
1711 }
1712 }
1713
1717 public function getStoredActive(int $a_id): bool
1718 {
1719 return (bool) self::_lookup($a_id, "active");
1720 }
1721
1722 public function setSkin(string $a_str): void
1723 {
1724 $this->skin = $a_str;
1725 }
1726
1727 public function setTimeLimitOwner(int $a_owner): void
1728 {
1729 $this->time_limit_owner = $a_owner;
1730 }
1731
1732 public function getTimeLimitOwner(): int
1733 {
1734 return $this->time_limit_owner ?: 7;
1735 }
1736
1737 public function setTimeLimitFrom(?int $a_from): void
1738 {
1739 $this->time_limit_from = $a_from;
1740 }
1741
1742 public function getTimeLimitFrom(): ?int
1743 {
1744 return $this->time_limit_from;
1745 }
1746
1747 public function setTimeLimitUntil(?int $a_until): void
1748 {
1749 $this->time_limit_until = $a_until;
1750 }
1751
1752 public function getTimeLimitUntil(): ?int
1753 {
1754 return $this->time_limit_until;
1755 }
1756
1757 public function setTimeLimitUnlimited(bool $a_unlimited): void
1758 {
1759 $this->time_limit_unlimited = $a_unlimited;
1760 }
1761
1762 public function getTimeLimitUnlimited(): bool
1763 {
1764 return $this->time_limit_unlimited;
1765 }
1766
1767 public function setTimeLimitMessage(string $a_time_limit_message): void
1768 {
1769 $this->time_limit_message = $a_time_limit_message;
1770 }
1771
1772 public function getTimeLimitMessage(): string
1773 {
1774 return $this->time_limit_message;
1775 }
1776
1777 public function setLoginAttempts(int $a_login_attempts): void
1778 {
1779 $this->login_attempts = $a_login_attempts;
1780 }
1781
1782 public function getLoginAttempts(): int
1783 {
1784 return $this->login_attempts;
1785 }
1786
1787 public function checkTimeLimit(): bool
1788 {
1789 if ($this->getTimeLimitUnlimited()) {
1790 return true;
1791 }
1792 if ($this->getTimeLimitFrom() < time() and $this->getTimeLimitUntil() > time()) {
1793 return true;
1794 }
1795 return false;
1796 }
1797
1798 public function setProfileIncomplete(bool $a_prof_inc): void
1799 {
1800 $this->profile_incomplete = $a_prof_inc;
1801 }
1802
1803 public function getProfileIncomplete(): bool
1804 {
1805 if ($this->id == ANONYMOUS_USER_ID) {
1806 return false;
1807 }
1808 return $this->profile_incomplete;
1809 }
1810
1811 public function isPasswordChangeDemanded(): bool
1812 {
1813 if ($this->id == ANONYMOUS_USER_ID) {
1814 return false;
1815 }
1816
1817 if ($this->id == SYSTEM_USER_ID) {
1818 if (
1819 \ilUserPasswordManager::getInstance()->verifyPassword($this, base64_decode('aG9tZXI=')) &&
1820 !ilAuthUtils::_needsExternalAccountByAuthMode($this->getAuthMode(true))
1821 ) {
1822 return true;
1823 } else {
1824 return false;
1825 }
1826 }
1827
1829
1830 $authModeAllowsPasswordChange = !ilAuthUtils::_needsExternalAccountByAuthMode($this->getAuthMode(true));
1831 $passwordResetOnFirstLogin = (
1832 $security->isPasswordChangeOnFirstLoginEnabled() &&
1833 $this->getLastPasswordChangeTS() == 0 && $this->is_self_registered == false
1834 );
1835 $passwordResetOnChangedPolicy = $this->getPasswordPolicyResetStatus();
1836
1837 return ($authModeAllowsPasswordChange && ($passwordResetOnFirstLogin || $passwordResetOnChangedPolicy));
1838 }
1839
1840 public function isPasswordExpired(): bool
1841 {
1842 if ($this->id == ANONYMOUS_USER_ID) {
1843 return false;
1844 }
1845
1847 if ($this->getLastPasswordChangeTS() > 0) {
1848 $max_pass_age = $security->getPasswordMaxAge();
1849 if ($max_pass_age > 0) {
1850 $max_pass_age_ts = ($max_pass_age * 86400);
1851 $pass_change_ts = $this->getLastPasswordChangeTS();
1852 $current_ts = time();
1853
1854 if (($current_ts - $pass_change_ts) > $max_pass_age_ts) {
1855 if (!ilAuthUtils::_needsExternalAccountByAuthMode($this->getAuthMode(true))) {
1856 return true;
1857 }
1858 }
1859 }
1860 }
1861
1862 return false;
1863 }
1864
1865 public function getPasswordAge(): int
1866 {
1867 $current_ts = time();
1868 $pass_change_ts = $this->getLastPasswordChangeTS();
1869 $password_age = (int) (($current_ts - $pass_change_ts) / 86400);
1870 return $password_age;
1871 }
1872
1873 public function setLastPasswordChangeToNow(): bool
1874 {
1875 global $DIC;
1876
1877 $ilDB = $DIC['ilDB'];
1878
1879 $this->setLastPasswordChangeTS(time());
1880
1881 $query = "UPDATE usr_data SET last_password_change = %s " .
1882 "WHERE usr_id = %s";
1883 $affected = $ilDB->manipulateF(
1884 $query,
1885 array('integer','integer'),
1886 array($this->getLastPasswordChangeTS(),$this->id)
1887 );
1888 if ($affected) {
1889 return true;
1890 } else {
1891 return false;
1892 }
1893 }
1894
1895 public function resetLastPasswordChange(): bool
1896 {
1897 $ilDB = $this->db;
1898
1899 $query = "UPDATE usr_data SET last_password_change = 0 " .
1900 "WHERE usr_id = %s";
1901 $affected = $ilDB->manipulateF(
1902 $query,
1903 array('integer'),
1904 array($this->getId())
1905 );
1906 if ($affected) {
1907 return true;
1908 } else {
1909 return false;
1910 }
1911 }
1912
1913 public function setLatitude(?string $a_latitude): void
1914 {
1915 $this->latitude = $a_latitude;
1916 }
1917
1918 public function getLatitude(): ?string
1919 {
1920 return $this->latitude;
1921 }
1922
1923 public function setLongitude(?string $a_longitude): void
1924 {
1925 $this->longitude = $a_longitude;
1926 }
1927
1928 public function getLongitude(): ?string
1929 {
1930 return $this->longitude;
1931 }
1932
1933 public function setLocationZoom(?int $a_locationzoom): void
1934 {
1935 $this->loc_zoom = $a_locationzoom;
1936 }
1937
1938 public function getLocationZoom(): ?int
1939 {
1940 return $this->loc_zoom;
1941 }
1942
1943
1944 public static function hasActiveSession(
1945 int $a_user_id,
1946 string $a_session_id
1947 ): bool {
1948 global $DIC;
1949
1950 $ilDB = $DIC['ilDB'];
1951
1952 $set = $ilDB->queryf(
1953 '
1954 SELECT COUNT(*) session_count
1955 FROM usr_session WHERE user_id = %s AND expires > %s AND session_id != %s ',
1956 array('integer', 'integer', 'text'),
1957 array($a_user_id, time(), $a_session_id)
1958 );
1959 $row = $ilDB->fetchAssoc($set);
1960 return (bool) $row['session_count'];
1961 }
1962
1966 public function checkUserId(): bool
1967 {
1968 $login = self::getLoginFromAuth();
1969 $id = self::_lookupId($login);
1970 if ($id > 0) {
1971 return $id;
1972 }
1973 return false;
1974 }
1975
1979 private static function getLoginFromAuth(): string
1980 {
1981 $uid = $GLOBALS['DIC']['ilAuthSession']->getUserId();
1982 $login = self::_lookupLogin($uid);
1983
1984 // BEGIN WebDAV: Strip Microsoft Domain Names from logins
1986 $login = self::toUsernameWithoutDomain($login);
1987 }
1988 return $login;
1989 }
1990
1995 public static function toUsernameWithoutDomain(string $a_login): string
1996 {
1997 // Remove all characters including the last slash or the last backslash
1998 // in the username
1999 $pos = strrpos($a_login, '/');
2000 $pos2 = strrpos($a_login, '\\');
2001 if ($pos === false || $pos < $pos2) {
2002 $pos = $pos2;
2003 }
2004 if (is_int($pos)) {
2005 $a_login = substr($a_login, $pos + 1);
2006 }
2007 return $a_login;
2008 }
2009
2010 /*
2011 * check to see if current user has been made active
2012 */
2013 public function isCurrentUserActive(): bool
2014 {
2015 $ilDB = $this->db;
2016
2017 $login = self::getLoginFromAuth();
2018 $set = $ilDB->queryF(
2019 "SELECT active FROM usr_data WHERE login= %s",
2020 array("text"),
2021 array($login)
2022 );
2023 //query has got a result
2024 if ($rec = $ilDB->fetchAssoc($set)) {
2025 if ($rec["active"]) {
2026 return true;
2027 }
2028 }
2029
2030 return false;
2031 }
2032
2033 public static function getUserIdByLogin(string $a_login): int
2034 {
2035 return (int) self::_lookupId($a_login);
2036 }
2037
2041 public static function getUserIdsByEmail(string $a_email): array
2042 {
2043 global $DIC;
2044
2045 $ilDB = $DIC->database();
2046
2047 $res = $ilDB->queryF(
2048 "SELECT usr_id FROM usr_data " .
2049 "WHERE email = %s and active = 1",
2050 array("text"),
2051 array($a_email)
2052 );
2053 $ids = array();
2054 while ($row = $ilDB->fetchObject($res)) {
2055 $ids[] = (int) $row->usr_id;
2056 }
2057
2058 return $ids;
2059 }
2060
2061
2065 public static function getUserLoginsByEmail(string $a_email): array
2066 {
2067 global $DIC;
2068
2069 $ilDB = $DIC->database();
2070
2071 $res = $ilDB->queryF(
2072 "SELECT login FROM usr_data " .
2073 "WHERE email = %s and active = 1",
2074 array("text"),
2075 array($a_email)
2076 );
2077 $ids = array();
2078 while ($row = $ilDB->fetchObject($res)) {
2079 $ids[] = $row->login;
2080 }
2081
2082 return $ids;
2083 }
2084
2085 public function getLoginByUserId(int $a_userid): ?string
2086 {
2087 $login = self::_lookupLogin($a_userid);
2088 return $login ?: null;
2089 }
2090
2094 public static function getAllUserLogins(): array
2095 {
2099 global $DIC;
2100
2101 $ilDB = $DIC['ilDB'];
2102
2103 $logins = array();
2104
2105 $res = $ilDB->query(
2106 "SELECT login FROM usr_data WHERE " . $ilDB->in('usr_id', array(ANONYMOUS_USER_ID), true, 'integer')
2107 );
2108 while ($row = $ilDB->fetchAssoc($res)) {
2109 $logins[] = $row['login'];
2110 }
2111
2112 return $logins;
2113 }
2114
2119 public static function _readUsersProfileData(array $a_user_ids): array
2120 {
2121 global $DIC;
2122
2123 $ilDB = $DIC['ilDB'];
2124 $res = $ilDB->query("SELECT * FROM usr_data WHERE " .
2125 $ilDB->in("usr_id", $a_user_ids, false, "integer"));
2126 $user_data = [];
2127 while ($row = $ilDB->fetchAssoc($res)) {
2128 $user_data[$row['usr_id']] = $row;
2129 }
2130 return $user_data;
2131 }
2132
2138 public static function _getAllUserData(
2139 ?array $a_fields = null,
2140 int $active = -1
2141 ): array {
2142 global $DIC;
2143
2144 $ilDB = $DIC['ilDB'];
2145
2146 $result_arr = array();
2147
2148 if ($a_fields !== null and is_array($a_fields)) {
2149 if (count($a_fields) == 0) {
2150 $select = "*";
2151 } else {
2152 if (($usr_id_field = array_search("usr_id", $a_fields)) !== false) {
2153 unset($a_fields[$usr_id_field]);
2154 }
2155
2156 $select = implode(",", $a_fields) . ",usr_data.usr_id";
2157 // online time
2158 if (in_array('online_time', $a_fields)) {
2159 $select .= ",ut_online.online_time ";
2160 }
2161 }
2162
2163 $q = "SELECT " . $select . " FROM usr_data ";
2164
2165 // Add online_time if desired
2166 // Need left join here to show users that never logged in
2167 if (in_array('online_time', $a_fields)) {
2168 $q .= "LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2169 }
2170
2171 switch ($active) {
2172 case 0:
2173 case 1:
2174 $q .= "WHERE active = " . $ilDB->quote($active, "integer");
2175 break;
2176 case 2:
2177 $q .= "WHERE time_limit_unlimited= " . $ilDB->quote(0, "integer");
2178 break;
2179 case 3:
2180 $qtemp = $q . ", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND " .
2181 $ilDB->like("object_data.title", "text", "%crs%") . " AND usr_data.usr_id = rbac_ua.usr_id";
2182 $r = $ilDB->query($qtemp);
2183 $course_users = array();
2184 while ($row = $ilDB->fetchAssoc($r)) {
2185 $course_users[] = $row["usr_id"];
2186 }
2187 if (count($course_users)) {
2188 $q .= " WHERE " . $ilDB->in("usr_data.usr_id", $course_users, true, "integer") . " ";
2189 } else {
2190 return $result_arr;
2191 }
2192 break;
2193 case 4:
2194 $session_data = ilSession::get('user_filter_data');
2195 $date = strftime("%Y-%m-%d %H:%I:%S", mktime(0, 0, 0, $session_data["m"], $session_data["d"], $session_data["y"]));
2196 $q .= " AND last_login < " . $ilDB->quote($date, "timestamp");
2197 break;
2198 case 5:
2199 $ref_id = ilSession::get('user_filter_data');
2200 if ($ref_id) {
2201 $q .= " LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id " .
2202 "WHERE obj_members.obj_id = (SELECT obj_id FROM object_reference " .
2203 "WHERE ref_id = " . $ilDB->quote($ref_id, "integer") . ") ";
2204 }
2205 break;
2206 case 6:
2207 global $DIC;
2208
2209 $rbacreview = $DIC['rbacreview'];
2210 $ref_id = ilSession::get('user_filter_data');
2211 if ($ref_id) {
2212 $local_roles = $rbacreview->getRolesOfRoleFolder($ref_id, false);
2213 if (is_array($local_roles) && count($local_roles)) {
2214 $q .= " LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE " .
2215 $ilDB->in("rbac_ua.rol_id", $local_roles, false, "integer") . " ";
2216 }
2217 }
2218 break;
2219 case 7:
2220 $rol_id = ilSession::get('user_filter_data');
2221 if ($rol_id) {
2222 $q .= " LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = " .
2223 $ilDB->quote($rol_id, "integer");
2224 }
2225 break;
2226 }
2227 $r = $ilDB->query($q);
2228
2229 while ($row = $ilDB->fetchAssoc($r)) {
2230 $result_arr[] = $row;
2231 }
2232 }
2233
2234 return $result_arr;
2235 }
2236
2237 public static function _getNumberOfUsersForStyle(
2238 string $a_skin,
2239 string $a_style
2240 ): int {
2241 global $DIC;
2242
2243 $ilDB = $DIC['ilDB'];
2244
2245 $q = "SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 " .
2246 " WHERE up1.keyword= " . $ilDB->quote("style", "text") .
2247 " AND up1.value= " . $ilDB->quote($a_style, "text") .
2248 " AND up2.keyword= " . $ilDB->quote("skin", "text") .
2249 " AND up2.value= " . $ilDB->quote($a_skin, "text") .
2250 " AND up1.usr_id = up2.usr_id ";
2251
2252 $cnt_set = $ilDB->query($q);
2253
2254 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
2255
2256 return (int) $cnt_rec["cnt"];
2257 }
2258
2262 public static function _getAllUserAssignedStyles(): array
2263 {
2264 global $DIC;
2265
2266 $ilDB = $DIC['ilDB'];
2267
2268 $q = "SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 " .
2269 " WHERE up1.keyword = " . $ilDB->quote("style", "text") .
2270 " AND up2.keyword = " . $ilDB->quote("skin", "text") .
2271 " AND up1.usr_id = up2.usr_id";
2272
2273 $sty_set = $ilDB->query($q);
2274
2275 $styles = array();
2276 while ($sty_rec = $ilDB->fetchAssoc($sty_set)) {
2277 $styles[] = $sty_rec["skin"] . ":" . $sty_rec["style"];
2278 }
2279
2280 return $styles;
2281 }
2282
2283 public static function _moveUsersToStyle(
2284 string $a_from_skin,
2285 string $a_from_style,
2286 string $a_to_skin,
2287 string $a_to_style
2288 ): void {
2289 global $DIC;
2290
2291 $ilDB = $DIC['ilDB'];
2292
2293 $q = "SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 " .
2294 " WHERE up1.keyword= " . $ilDB->quote("style", "text") .
2295 " AND up1.value= " . $ilDB->quote($a_from_style, "text") .
2296 " AND up2.keyword= " . $ilDB->quote("skin", "text") .
2297 " AND up2.value= " . $ilDB->quote($a_from_skin, "text") .
2298 " AND up1.usr_id = up2.usr_id ";
2299
2300 $usr_set = $ilDB->query($q);
2301
2302 while ($usr_rec = $ilDB->fetchAssoc($usr_set)) {
2303 self::_writePref($usr_rec["usr_id"], "skin", $a_to_skin);
2304 self::_writePref($usr_rec["usr_id"], "style", $a_to_style);
2305 }
2306 }
2307
2308
2314
2321 public function addObjectToClipboard(
2322 int $a_item_id,
2323 string $a_type,
2324 string $a_title,
2325 int $a_parent = 0,
2326 string $a_time = "",
2327 int $a_order_nr = 0
2328 ): void {
2329 global $DIC;
2330
2331 $ilDB = $DIC['ilDB'];
2332
2333 if ($a_time === "") {
2334 $a_time = date("Y-m-d H:i:s");
2335 }
2336
2337 $item_set = $ilDB->queryF(
2338 "SELECT * FROM personal_clipboard WHERE " .
2339 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
2340 array("integer", "integer", "text", "integer"),
2341 array(0, $a_item_id, $a_type, $this->getId())
2342 );
2343
2344 // only insert if item is not already in clipboard
2345 if (!$item_set->fetchRow()) {
2346 $ilDB->manipulateF(
2347 "INSERT INTO personal_clipboard " .
2348 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES " .
2349 " (%s,%s,%s,%s,%s,%s,%s)",
2350 array("integer", "text", "integer", "text", "integer", "timestamp", "integer"),
2351 array($a_item_id, $a_type, $this->getId(), $a_title, $a_parent, $a_time, $a_order_nr)
2352 );
2353 } else {
2354 $ilDB->manipulateF(
2355 "UPDATE personal_clipboard SET insert_time = %s " .
2356 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
2357 array("timestamp", "integer", "integer", "text"),
2358 array($a_time, $this->getId(), $a_item_id, $a_type)
2359 );
2360 }
2361 }
2362
2367 public function addToPCClipboard(
2368 string $a_content,
2369 string $a_time,
2370 int $a_nr
2371 ): void {
2372 $ilDB = $this->db;
2373 if ($a_time == 0) {
2374 $a_time = date("Y-m-d H:i:s");
2375 }
2376 ilSession::set("user_pc_clip", true);
2377 $ilDB->insert("personal_pc_clipboard", array(
2378 "user_id" => array("integer", $this->getId()),
2379 "content" => array("clob", $a_content),
2380 "insert_time" => array("timestamp", $a_time),
2381 "order_nr" => array("integer", $a_nr)
2382 ));
2383 }
2384
2389 public function getPCClipboardContent(): array // Missing array type.
2390 {
2391 $ilDB = $this->db;
2392
2393 if (!ilSession::get("user_pc_clip")) {
2394 return [];
2395 }
2396
2397 $set = $ilDB->queryF("SELECT MAX(insert_time) mtime FROM personal_pc_clipboard " .
2398 " WHERE user_id = %s", array("integer"), array($this->getId()));
2399 $row = $ilDB->fetchAssoc($set);
2400
2401 $set = $ilDB->queryF(
2402 "SELECT * FROM personal_pc_clipboard " .
2403 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
2404 array("integer", "timestamp"),
2405 array($this->getId(), $row["mtime"])
2406 );
2407 $content = array();
2408 while ($row = $ilDB->fetchAssoc($set)) {
2409 $content[] = $row["content"];
2410 }
2411
2412 return $content;
2413 }
2414
2418 public function clipboardHasObjectsOfType(string $a_type): bool
2419 {
2420 global $DIC;
2421
2422 $ilDB = $DIC['ilDB'];
2423
2424 $set = $ilDB->queryF(
2425 "SELECT * FROM personal_clipboard WHERE " .
2426 "parent = %s AND type = %s AND user_id = %s",
2427 array("integer", "text", "integer"),
2428 array(0, $a_type, $this->getId())
2429 );
2430 if ($ilDB->fetchAssoc($set)) {
2431 return true;
2432 }
2433
2434 return false;
2435 }
2436
2437 public function clipboardDeleteObjectsOfType(string $a_type): void
2438 {
2439 $ilDB = $this->db;
2440
2441 $ilDB->manipulateF(
2442 "DELETE FROM personal_clipboard WHERE " .
2443 "type = %s AND user_id = %s",
2444 array("text", "integer"),
2445 array($a_type, $this->getId())
2446 );
2447 }
2448
2449 public function clipboardDeleteAll(): void
2450 {
2451 global $DIC;
2452
2453 $ilDB = $DIC['ilDB'];
2454
2455 $ilDB->manipulateF("DELETE FROM personal_clipboard WHERE " .
2456 "user_id = %s", array("integer"), array($this->getId()));
2457 }
2458
2462 public function getClipboardObjects(
2463 string $a_type = "",
2464 bool $a_top_nodes_only = false
2465 ): array {
2466 global $DIC;
2467
2468 $ilDB = $DIC['ilDB'];
2469
2470 $par = "";
2471 if ($a_top_nodes_only) {
2472 $par = " AND parent = " . $ilDB->quote(0, "integer") . " ";
2473 }
2474
2475 $type_str = ($a_type != "")
2476 ? " AND type = " . $ilDB->quote($a_type, "text") . " "
2477 : "";
2478 $q = "SELECT * FROM personal_clipboard WHERE " .
2479 "user_id = " . $ilDB->quote($this->getId(), "integer") . " " .
2480 $type_str . $par .
2481 " ORDER BY order_nr";
2482 $objs = $ilDB->query($q);
2483 $objects = array();
2484 while ($obj = $ilDB->fetchAssoc($objs)) {
2485 if ($obj["type"] == "mob") {
2486 $obj["title"] = ilObject::_lookupTitle($obj["item_id"]);
2487 if (ilObject::_lookupType((int) $obj["item_id"]) !== "mob") {
2488 continue;
2489 }
2490 }
2491 if ($obj["type"] == "incl") {
2492 $obj["title"] = ilMediaPoolPage::lookupTitle($obj["item_id"]);
2493 if (!ilPageObject::_exists("mep", (int) $obj["item_id"], "-")) {
2494 continue;
2495 }
2496 }
2497 $objects[] = array("id" => $obj["item_id"],
2498 "type" => $obj["type"], "title" => $obj["title"],
2499 "insert_time" => $obj["insert_time"]);
2500 }
2501 return $objects;
2502 }
2503
2507 public function getClipboardChilds(
2508 int $a_parent,
2509 string $a_insert_time
2510 ): array {
2511 global $DIC;
2512
2513 $ilDB = $DIC['ilDB'];
2514 $ilUser = $DIC['ilUser'];
2515
2516 $objs = $ilDB->queryF(
2517 "SELECT * FROM personal_clipboard WHERE " .
2518 "user_id = %s AND parent = %s AND insert_time = %s " .
2519 " ORDER BY order_nr",
2520 array("integer", "integer", "timestamp"),
2521 array($ilUser->getId(), $a_parent, $a_insert_time)
2522 );
2523 $objects = array();
2524 while ($obj = $ilDB->fetchAssoc($objs)) {
2525 if ($obj["type"] == "mob") {
2526 $obj["title"] = ilObject::_lookupTitle($obj["item_id"]);
2527 }
2528 $objects[] = array("id" => $obj["item_id"],
2529 "type" => $obj["type"], "title" => $obj["title"], "insert_time" => $obj["insert_time"]);
2530 }
2531 return $objects;
2532 }
2533
2538 public static function _getUsersForClipboadObject(
2539 string $a_type,
2540 int $a_id
2541 ): array {
2542 global $DIC;
2543
2544 $ilDB = $DIC['ilDB'];
2545
2546 $q = "SELECT DISTINCT user_id FROM personal_clipboard WHERE " .
2547 "item_id = " . $ilDB->quote($a_id, "integer") . " AND " .
2548 "type = " . $ilDB->quote($a_type, "text");
2549 $user_set = $ilDB->query($q);
2550 $users = array();
2551 while ($user_rec = $ilDB->fetchAssoc($user_set)) {
2552 $users[] = (int) $user_rec["user_id"];
2553 }
2554
2555 return $users;
2556 }
2557
2559 int $a_item_id,
2560 string $a_type
2561 ): void {
2562 $ilDB = $this->db;
2563
2564 $q = "DELETE FROM personal_clipboard WHERE " .
2565 "item_id = " . $ilDB->quote($a_item_id, "integer") .
2566 " AND type = " . $ilDB->quote($a_type, "text") . " " .
2567 " AND user_id = " . $ilDB->quote($this->getId(), "integer");
2568 $ilDB->manipulate($q);
2569 }
2570
2571 public static function _getImportedUserId(
2572 string $i2_id
2573 ): int {
2574 global $DIC;
2575
2576 $ilDB = $DIC['ilDB'];
2577
2578 $query = "SELECT obj_id FROM object_data WHERE import_id = " .
2579 $ilDB->quote($i2_id, "text");
2580
2581 $res = $ilDB->query($query);
2582 $id = 0;
2583 while ($row = $ilDB->fetchObject($res)) {
2584 $id = (int) $row->obj_id;
2585 }
2586 return $id;
2587 }
2588
2592 public static function lookupOrgUnitsRepresentation(
2593 int $a_usr_id
2594 ): string {
2595 return ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_usr_id);
2596 }
2597
2598 public function getOrgUnitsRepresentation(): string
2599 {
2600 return self::lookupOrgUnitsRepresentation($this->getId());
2601 }
2602
2603 public function setAuthMode(?string $a_str): void
2604 {
2605 $this->auth_mode = $a_str;
2606 }
2607
2608 public function getAuthMode(bool $a_auth_key = false): ?string
2609 {
2610 if (!$a_auth_key) {
2611 return $this->auth_mode;
2612 }
2613 return ilAuthUtils::_getAuthMode($this->auth_mode);
2614 }
2615
2616 public function setExternalAccount(string $a_str): void
2617 {
2618 $this->ext_account = $a_str;
2619 }
2620
2621 public function getExternalAccount(): string
2622 {
2623 return $this->ext_account;
2624 }
2625
2632 public static function _getExternalAccountsByAuthMode(
2633 string $a_auth_mode,
2634 bool $a_read_auth_default = false
2635 ): array {
2636 global $DIC;
2637
2638 $ilDB = $DIC['ilDB'];
2639 $ilSetting = $DIC['ilSetting'];
2640
2641 $q = "SELECT login,usr_id,ext_account,auth_mode FROM usr_data " .
2642 "WHERE auth_mode = %s";
2643 $types[] = "text";
2644 $values[] = $a_auth_mode;
2645 if ($a_read_auth_default and ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode', ilAuthUtils::AUTH_LOCAL)) == $a_auth_mode) {
2646 $q .= " OR auth_mode = %s ";
2647 $types[] = "text";
2648 $values[] = 'default';
2649 }
2650
2651 $res = $ilDB->queryF($q, $types, $values);
2652 $accounts = [];
2653 while ($row = $ilDB->fetchObject($res)) {
2654 if ($row->auth_mode == 'default') {
2655 $accounts[$row->usr_id] = $row->login;
2656 } else {
2657 $accounts[$row->usr_id] = $row->ext_account;
2658 }
2659 }
2660 return $accounts;
2661 }
2662
2663 public static function _toggleActiveStatusOfUsers(
2664 array $a_usr_ids,
2665 bool $a_status
2666 ): void {
2667 global $DIC;
2668
2669 $ilDB = $DIC['ilDB'];
2670
2671 if ($a_status) {
2672 $q = "UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE " .
2673 $ilDB->in("usr_id", $a_usr_ids, false, "integer");
2674 $ilDB->manipulate($q);
2675 } else {
2676 $usrId_IN_usrIds = $ilDB->in("usr_id", $a_usr_ids, false, "integer");
2677
2678 $q = "UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds";
2679 $ilDB->manipulate($q);
2680
2681 $queryString = "
2682 UPDATE usr_data
2683 SET inactivation_date = %s
2684 WHERE inactivation_date IS NULL
2685 AND $usrId_IN_usrIds
2686 ";
2687 $ilDB->manipulateF($queryString, array('timestamp'), array(ilUtil::now()));
2688 }
2689 }
2690
2691 public static function _lookupAuthMode(int $a_usr_id): string
2692 {
2693 return (string) self::_lookup($a_usr_id, "auth_mode");
2694 }
2695
2700 public static function _checkExternalAuthAccount(
2701 string $a_auth,
2702 string $a_account,
2703 bool $tryFallback = true
2704 ): ?string {
2705 $db = $GLOBALS['DIC']->database();
2706 $settings = $GLOBALS['DIC']->settings();
2707
2708 // Check directly with auth_mode
2709 $r = $db->queryF(
2710 "SELECT * FROM usr_data WHERE " .
2711 " ext_account = %s AND auth_mode = %s",
2712 array("text", "text"),
2713 array($a_account, $a_auth)
2714 );
2715 if ($usr = $db->fetchAssoc($r)) {
2716 return $usr["login"];
2717 }
2718
2719 if (!$tryFallback) {
2720 return null;
2721 }
2722
2723 // For compatibility, check for login (no ext_account entry given)
2724 $res = $db->queryF(
2725 "SELECT login FROM usr_data " .
2726 "WHERE login = %s AND auth_mode = %s AND (ext_account IS NULL OR ext_account = '') ",
2727 array("text", "text"),
2728 array($a_account, $a_auth)
2729 );
2730 if ($usr = $db->fetchAssoc($res)) {
2731 return $usr['login'];
2732 }
2733
2734 // If auth_default == $a_auth => check for login
2735 if (ilAuthUtils::_getAuthModeName($settings->get('auth_mode')) == $a_auth) {
2736 $res = $db->queryF(
2737 "SELECT login FROM usr_data WHERE " .
2738 " ext_account = %s AND auth_mode = %s",
2739 array("text", "text"),
2740 array($a_account, "default")
2741 );
2742 if ($usr = $db->fetchAssoc($res)) {
2743 return $usr["login"];
2744 }
2745 // Search for login (no ext_account given)
2746 $res = $db->queryF(
2747 "SELECT login FROM usr_data " .
2748 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
2749 array("text", "text"),
2750 array($a_account, "default")
2751 );
2752 if ($usr = $db->fetchAssoc($res)) {
2753 return $usr["login"];
2754 }
2755 }
2756 return null;
2757 }
2758
2762 public static function _getNumberOfUsersPerAuthMode(): array // Missing array type.
2763 {
2764 global $DIC;
2765
2766 $ilDB = $DIC['ilDB'];
2767
2768 $r = $ilDB->query("SELECT count(*) AS cnt, auth_mode FROM usr_data " .
2769 "GROUP BY auth_mode");
2770 $cnt_arr = array();
2771 while ($cnt = $ilDB->fetchAssoc($r)) {
2772 $cnt_arr[$cnt["auth_mode"]] = (int) $cnt["cnt"];
2773 }
2774
2775 return $cnt_arr;
2776 }
2777
2778 public static function _getLocalAccountsForEmail(string $a_email): array // Missing array type.
2779 {
2780 global $DIC;
2781
2782 $ilDB = $DIC['ilDB'];
2783 $ilSetting = $DIC['ilSetting'];
2784
2785 // default set to local (1)?
2786
2787 $q = "SELECT * FROM usr_data WHERE " .
2788 " email = %s AND (auth_mode = %s ";
2789 $types = array("text", "text");
2790 $values = array($a_email, "local");
2791
2792 if ($ilSetting->get("auth_mode") == 1) {
2793 $q .= " OR auth_mode = %s";
2794 $types[] = "text";
2795 $values[] = "default";
2796 }
2797
2798 $q .= ")";
2799
2800 $users = array();
2801 $usr_set = $ilDB->queryF($q, $types, $values);
2802 while ($usr_rec = $ilDB->fetchAssoc($usr_set)) {
2803 $users[$usr_rec["usr_id"]] = $usr_rec["login"];
2804 }
2805
2806 return $users;
2807 }
2808
2809
2814 public static function _uploadPersonalPicture(
2815 string $tmp_file,
2816 int $obj_id
2817 ): bool {
2818 $webspace_dir = ilFileUtils::getWebspaceDir();
2819 $image_dir = $webspace_dir . "/usr_images";
2820 ilFileUtils::makeDir($image_dir);
2821 $store_file = "usr_" . $obj_id . "." . "jpg";
2822
2823 chmod($tmp_file, 0770);
2824
2825 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
2826 // taking only frame [0] to avoid problems with animated gifs
2827 $show_file = "$image_dir/usr_" . $obj_id . ".jpg";
2828 $thumb_file = "$image_dir/usr_" . $obj_id . "_small.jpg";
2829 $xthumb_file = "$image_dir/usr_" . $obj_id . "_xsmall.jpg";
2830 $xxthumb_file = "$image_dir/usr_" . $obj_id . "_xxsmall.jpg";
2831
2832 if (ilShellUtil::isConvertVersionAtLeast("6.3.8-3")) {
2834 $tmp_file . "[0] -geometry 200x200^ -gravity center -extent 200x200 -quality 100 JPEG:" . $show_file
2835 );
2837 $tmp_file . "[0] -geometry 100x100^ -gravity center -extent 100x100 -quality 100 JPEG:" . $thumb_file
2838 );
2840 $tmp_file . "[0] -geometry 75x75^ -gravity center -extent 75x75 -quality 100 JPEG:" . $xthumb_file
2841 );
2843 $tmp_file . "[0] -geometry 30x30^ -gravity center -extent 30x30 -quality 100 JPEG:" . $xxthumb_file
2844 );
2845 } else {
2846 ilShellUtil::execConvert($tmp_file . "[0] -geometry 200x200 -quality 100 JPEG:" . $show_file);
2847 ilShellUtil::execConvert($tmp_file . "[0] -geometry 100x100 -quality 100 JPEG:" . $thumb_file);
2848 ilShellUtil::execConvert($tmp_file . "[0] -geometry 75x75 -quality 100 JPEG:" . $xthumb_file);
2849 ilShellUtil::execConvert($tmp_file . "[0] -geometry 30x30 -quality 100 JPEG:" . $xxthumb_file);
2850 }
2851
2852 // store filename
2853 self::_writePref($obj_id, "profile_image", $store_file);
2854
2855 return true;
2856 }
2857
2858
2863 public function getPersonalPicturePath(
2864 string $a_size = "small",
2865 bool $a_force_pic = false
2866 ): string {
2867 if (isset(self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic])) {
2868 return self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic];
2869 }
2870
2871 self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic] = self::_getPersonalPicturePath($this->getId(), $a_size, $a_force_pic);
2872
2873 return self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic];
2874 }
2875
2876 public function getAvatar(): Avatar
2877 {
2878 return self::_getAvatar($this->getId());
2879 }
2880
2881 public static function _getAvatar(int $a_usr_id): Avatar
2882 {
2883 $define = new ilUserAvatarResolver($a_usr_id ?: ANONYMOUS_USER_ID);
2884 return $define->getAvatar();
2885 }
2886
2891 public static function _getPersonalPicturePath(
2892 int $a_usr_id,
2893 string $a_size = "small",
2894 bool $a_force_pic = false,
2895 bool $a_prevent_no_photo_image = false,
2896 bool $html_export = false
2897 ): string {
2898 $define = new ilUserAvatarResolver($a_usr_id);
2899 $define->setForcePicture($a_force_pic);
2900 $define->setSize($a_size);
2901 return ilWACSignedPath::signFile($define->getLegacyPictureURL());
2902 }
2903
2904 public static function copyProfilePicturesToDirectory(
2905 int $a_user_id,
2906 string $a_dir
2907 ): void {
2908 $a_dir = trim(str_replace("..", "", $a_dir));
2909 if ($a_dir == "" || !is_dir($a_dir)) {
2910 return;
2911 }
2912
2913 $webspace_dir = ilFileUtils::getWebspaceDir();
2914 $image_dir = $webspace_dir . "/usr_images";
2915 $images = array(
2916 "upload_" . $a_user_id . "pic",
2917 "usr_" . $a_user_id . "." . "jpg",
2918 "usr_" . $a_user_id . "_small.jpg",
2919 "usr_" . $a_user_id . "_xsmall.jpg",
2920 "usr_" . $a_user_id . "_xxsmall.jpg",
2921 "upload_" . $a_user_id);
2922 foreach ($images as $image) {
2923 if (is_file($image_dir . "/" . $image)) {
2924 copy($image_dir . "/" . $image, $a_dir . "/" . $image);
2925 }
2926 }
2927 }
2928
2929
2930 public function removeUserPicture(
2931 bool $a_do_update = true
2932 ): void {
2933 $webspace_dir = ilFileUtils::getWebspaceDir();
2934 $image_dir = $webspace_dir . "/usr_images";
2935 $file = $image_dir . "/usr_" . $this->getId() . "." . "jpg";
2936 $thumb_file = $image_dir . "/usr_" . $this->getId() . "_small.jpg";
2937 $xthumb_file = $image_dir . "/usr_" . $this->getId() . "_xsmall.jpg";
2938 $xxthumb_file = $image_dir . "/usr_" . $this->getId() . "_xxsmall.jpg";
2939 $upload_file = $image_dir . "/upload_" . $this->getId();
2940
2941 if ($a_do_update) {
2942 // remove user pref file name
2943 $this->setPref("profile_image", "");
2944 $this->update();
2945 }
2946
2947 if (is_file($file)) {
2948 unlink($file);
2949 }
2950 if (is_file($thumb_file)) {
2951 unlink($thumb_file);
2952 }
2953 if (is_file($xthumb_file)) {
2954 unlink($xthumb_file);
2955 }
2956 if (is_file($xxthumb_file)) {
2957 unlink($xxthumb_file);
2958 }
2959 if (is_file($upload_file)) {
2960 unlink($upload_file);
2961 }
2962 }
2963
2964
2965 public function setUserDefinedData(array $a_data): void // Missing array type.
2966 {
2967 foreach ($a_data as $field => $data) {
2968 $this->user_defined_data['f_' . $field] = $data;
2969 }
2970 }
2971
2972 public function getUserDefinedData(): array // Missing array type.
2973 {
2974 return $this->user_defined_data ?: array();
2975 }
2976
2977 public function updateUserDefinedFields(): void
2978 {
2979 $udata = new ilUserDefinedData($this->getId());
2980 foreach ($this->user_defined_data as $field => $value) {
2981 if ($field !== 'usr_id' && $value !== null) {
2982 $udata->set($field, $value);
2983 }
2984 }
2985 $udata->update();
2986 }
2987
2988 public function readUserDefinedFields(): void
2989 {
2990 $udata = new ilUserDefinedData($this->getId());
2991 $this->user_defined_data = $udata->getAll();
2992 }
2993
2994 public function deleteUserDefinedFieldEntries(): void
2995 {
2997 }
2998
3003 public function getProfileAsString(ilLanguage $language): string
3004 {
3005 global $DIC;
3006
3007 $rbacreview = $DIC['rbacreview'];
3008
3009 $language->loadLanguageModule('registration');
3010 $language->loadLanguageModule('crs');
3011
3012 $body = ($language->txt("login") . ": " . $this->getLogin() . "\n");
3013
3014 if (strlen($this->getUTitle())) {
3015 $body .= ($language->txt("title") . ": " . $this->getUTitle() . "\n");
3016 }
3017 if (1 === strlen($this->getGender())) {
3018 $body .= ($language->txt("gender") . ": " . $language->txt('gender_' . strtolower($this->getGender())) . "\n");
3019 }
3020 if (strlen($this->getFirstname())) {
3021 $body .= ($language->txt("firstname") . ": " . $this->getFirstname() . "\n");
3022 }
3023 if (strlen($this->getLastname())) {
3024 $body .= ($language->txt("lastname") . ": " . $this->getLastname() . "\n");
3025 }
3026 if (strlen($this->getInstitution())) {
3027 $body .= ($language->txt("institution") . ": " . $this->getInstitution() . "\n");
3028 }
3029 if (strlen($this->getDepartment())) {
3030 $body .= ($language->txt("department") . ": " . $this->getDepartment() . "\n");
3031 }
3032 if (strlen($this->getStreet())) {
3033 $body .= ($language->txt("street") . ": " . $this->getStreet() . "\n");
3034 }
3035 if (strlen($this->getCity())) {
3036 $body .= ($language->txt("city") . ": " . $this->getCity() . "\n");
3037 }
3038 if (strlen($this->getZipcode())) {
3039 $body .= ($language->txt("zipcode") . ": " . $this->getZipcode() . "\n");
3040 }
3041 if (strlen($this->getCountry())) {
3042 $body .= ($language->txt("country") . ": " . $this->getCountry() . "\n");
3043 }
3044 if (strlen($this->getSelectedCountry())) {
3045 $body .= ($language->txt("sel_country") . ": " . $this->getSelectedCountry() . "\n");
3046 }
3047 if (strlen($this->getPhoneOffice())) {
3048 $body .= ($language->txt("phone_office") . ": " . $this->getPhoneOffice() . "\n");
3049 }
3050 if (strlen($this->getPhoneHome())) {
3051 $body .= ($language->txt("phone_home") . ": " . $this->getPhoneHome() . "\n");
3052 }
3053 if (strlen($this->getPhoneMobile())) {
3054 $body .= ($language->txt("phone_mobile") . ": " . $this->getPhoneMobile() . "\n");
3055 }
3056 if (strlen($this->getFax())) {
3057 $body .= ($language->txt("fax") . ": " . $this->getFax() . "\n");
3058 }
3059 if (strlen($this->getEmail())) {
3060 $body .= ($language->txt("email") . ": " . $this->getEmail() . "\n");
3061 }
3062 if (strlen($this->getSecondEmail())) {
3063 $body .= ($language->txt("second_email") . ": " . $this->getSecondEmail() . "\n");
3064 }
3065 if (strlen($this->getHobby())) {
3066 $body .= ($language->txt("hobby") . ": " . $this->getHobby() . "\n");
3067 }
3068 if (strlen($this->getComment())) {
3069 $body .= ($language->txt("referral_comment") . ": " . $this->getComment() . "\n");
3070 }
3071 if (strlen($this->getMatriculation())) {
3072 $body .= ($language->txt("matriculation") . ": " . $this->getMatriculation() . "\n");
3073 }
3074 if (strlen($this->getCreateDate())) {
3077 $date = ilDatePresentation::formatDate(new ilDateTime($this->getCreateDate(), IL_CAL_DATETIME));
3079
3080 $body .= ($language->txt("create_date") . ": " . $date . "\n");
3081 }
3082
3083 $gr = [];
3084 foreach ($rbacreview->getGlobalRoles() as $role) {
3085 if ($rbacreview->isAssigned($this->getId(), $role)) {
3086 $gr[] = ilObjRole::_lookupTitle($role);
3087 }
3088 }
3089 if (count($gr)) {
3090 $body .= ($language->txt('reg_role_info') . ': ' . implode(',', $gr) . "\n");
3091 }
3092
3093 // Time limit
3094 if ($this->getTimeLimitUnlimited()) {
3095 $body .= ($language->txt('time_limit') . ": " . $language->txt('crs_unlimited') . "\n");
3096 } else {
3100 new ilDateTime($this->getTimeLimitFrom(), IL_CAL_UNIX),
3101 new ilDateTime($this->getTimeLimitUntil(), IL_CAL_UNIX)
3102 );
3104
3105 $start = new ilDateTime($this->getTimeLimitFrom(), IL_CAL_UNIX);
3106 $end = new ilDateTime($this->getTimeLimitUntil(), IL_CAL_UNIX);
3107
3108 $body .= $language->txt('time_limit') . ': ' .
3109 $language->txt('from') . " " .
3110 $start->get(IL_CAL_DATETIME) . " ";
3111 $body .= $language->txt('to') . ' ' . $end->get(IL_CAL_DATETIME) . "\n";
3112 }
3113
3117 $user_defined_fields = ilUserDefinedFields::_getInstance();
3118 $user_defined_data = $this->getUserDefinedData();
3119
3120 foreach ($user_defined_fields->getDefinitions() as $field_id => $definition) {
3121 $data = $user_defined_data["f_" . $field_id] ?? '';
3122 if ($data !== '') {
3123 if ($definition['field_type'] == UDF_TYPE_WYSIWYG) {
3124 $data = strip_tags(
3125 preg_replace('/<br(\s*)?\/?>/i', "\n", $data)
3126 );
3127 }
3128
3129 $body .= $definition['field_name'] . ': ' . $data . "\n";
3130 }
3131 }
3132
3133 return $body;
3134 }
3135
3139 public static function _lookupFeedHash(
3140 int $a_user_id,
3141 bool $a_create = false
3142 ): ?string {
3143 global $DIC;
3144
3145 $ilDB = $DIC['ilDB'];
3146
3147 if ($a_user_id > 0) {
3148 $set = $ilDB->queryF(
3149 "SELECT feed_hash from usr_data WHERE usr_id = %s",
3150 array("integer"),
3151 array($a_user_id)
3152 );
3153 if ($rec = $ilDB->fetchAssoc($set)) {
3154 if (strlen($rec["feed_hash"]) == 32) {
3155 return $rec["feed_hash"];
3156 } elseif ($a_create) {
3157 $hash = md5(random_int(1, 9999999) + str_replace(" ", "", microtime()));
3158 $ilDB->manipulateF(
3159 "UPDATE usr_data SET feed_hash = %s" .
3160 " WHERE usr_id = %s",
3161 array("text", "integer"),
3162 array($hash, $a_user_id)
3163 );
3164 return $hash;
3165 }
3166 }
3167 }
3168 return null;
3169 }
3170
3176 public static function _getFeedPass(
3177 int $a_user_id
3178 ): ?string {
3179 if ($a_user_id > 0) {
3180 return self::_lookupPref($a_user_id, "priv_feed_pass");
3181 }
3182 return null;
3183 }
3184
3189 public static function _setFeedPass(
3190 int $a_user_id,
3191 string $a_password
3192 ): void {
3193 self::_writePref(
3194 $a_user_id,
3195 "priv_feed_pass",
3196 ($a_password == "") ? "" : md5($a_password)
3197 );
3198 }
3199
3204 public static function _loginExists(
3205 string $a_login,
3206 int $a_user_id = 0
3207 ): ?int {
3208 global $DIC;
3209
3210 $ilDB = $DIC['ilDB'];
3211
3212 $q = "SELECT DISTINCT login, usr_id FROM usr_data " .
3213 "WHERE login = %s";
3214 $types[] = "text";
3215 $values[] = $a_login;
3216
3217 if ($a_user_id != 0) {
3218 $q .= " AND usr_id != %s ";
3219 $types[] = "integer";
3220 $values[] = $a_user_id;
3221 }
3222
3223 $r = $ilDB->queryF($q, $types, $values);
3224
3225 if ($row = $ilDB->fetchAssoc($r)) {
3226 return (int) $row['usr_id'];
3227 }
3228 return null;
3229 }
3230
3234 public static function _externalAccountExists(
3235 string $a_external_account,
3236 string $a_auth_mode
3237 ): bool {
3238 global $DIC;
3239
3240 $ilDB = $DIC['ilDB'];
3241
3242 $res = $ilDB->queryF(
3243 "SELECT * FROM usr_data " .
3244 "WHERE ext_account = %s AND auth_mode = %s",
3245 array("text", "text"),
3246 array($a_external_account, $a_auth_mode)
3247 );
3248 return (bool) $ilDB->fetchAssoc($res);
3249 }
3250
3255 public static function _getUsersForRole(
3256 int $role_id,
3257 int $active = -1
3258 ): array {
3259 global $DIC;
3260
3261 $ilDB = $DIC['ilDB'];
3262 $rbacreview = $DIC['rbacreview'];
3263 $ids = $rbacreview->assignedUsers($role_id);
3264
3265 if (count($ids) == 0) {
3266 $ids = array(-1);
3267 }
3268
3269 $query = "SELECT usr_data.*, usr_pref.value AS language
3270 FROM usr_data
3271 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
3272 WHERE " . $ilDB->in("usr_data.usr_id", $ids, false, "integer");
3273 $values[] = "language";
3274 $types[] = "text";
3275
3276
3277 if (is_numeric($active) && $active > -1) {
3278 $query .= " AND usr_data.active = %s";
3279 $values[] = $active;
3280 $types[] = "integer";
3281 }
3282
3283 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
3284
3285 $r = $ilDB->queryF($query, $types, $values);
3286 $data = array();
3287 while ($row = $ilDB->fetchAssoc($r)) {
3288 $data[] = $row;
3289 }
3290 return $data;
3291 }
3292
3293
3298 public static function _getUsersForFolder(
3299 int $ref_id,
3300 int $active
3301 ): array {
3302 global $DIC;
3303
3304 $ilDB = $DIC['ilDB'];
3305 $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";
3306 $types[] = "text";
3307 $values[] = "language";
3308
3309 if (is_numeric($active) && $active > -1) {
3310 $query .= " AND usr_data.active = %s";
3311 $values[] = $active;
3312 $types[] = "integer";
3313 }
3314
3315 if ($ref_id != USER_FOLDER_ID) {
3316 $query .= " AND usr_data.time_limit_owner = %s";
3317 $values[] = $ref_id;
3318 $types[] = "integer";
3319 }
3320
3321 $query .= " AND usr_data.usr_id != %s ";
3322 $values[] = ANONYMOUS_USER_ID;
3323 $types[] = "integer";
3324
3325 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
3326
3327 $result = $ilDB->queryF($query, $types, $values);
3328 $data = array();
3329 while ($row = $ilDB->fetchAssoc($result)) {
3330 $data[] = $row;
3331 }
3332
3333 return $data;
3334 }
3335
3336
3342 public static function _getUsersForGroup(
3343 array $a_mem_ids,
3344 int $active = -1
3345 ): array {
3346 return self::_getUsersForIds($a_mem_ids, $active);
3347 }
3348
3349
3355 public static function _getUsersForIds(
3356 array $a_mem_ids,
3357 int $active = -1,
3358 int $timelimitowner = -1
3359 ): array {
3360 global $DIC;
3361
3362 $ilDB = $DIC['ilDB'];
3363
3364 $query = "SELECT usr_data.*, usr_pref.value AS language
3365 FROM usr_data
3366 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
3367 WHERE " . $ilDB->in("usr_data.usr_id", $a_mem_ids, false, "integer") . "
3368 AND usr_data.usr_id != %s";
3369 $values[] = "language";
3370 $types[] = "text";
3371 $values[] = ANONYMOUS_USER_ID;
3372 $types[] = "integer";
3373
3374 if (is_numeric($active) && $active > -1) {
3375 $query .= " AND active = %s";
3376 $values[] = $active;
3377 $types[] = "integer";
3378 }
3379
3380 if ($timelimitowner != USER_FOLDER_ID && $timelimitowner != -1) {
3381 $query .= " AND usr_data.time_limit_owner = %s";
3382 $values[] = $timelimitowner;
3383 $types[] = "integer";
3384 }
3385
3386 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
3387
3388 $result = $ilDB->queryF($query, $types, $values);
3389 $mem_arr = [];
3390 while ($row = $ilDB->fetchAssoc($result)) {
3391 $mem_arr[] = $row;
3392 }
3393
3394 return $mem_arr;
3395 }
3396
3397
3398
3403 public static function _getUserData(array $a_internalids): array
3404 {
3405 global $DIC;
3406
3407 $ilDB = $DIC['ilDB'];
3408
3409 $ids = array();
3410 if (is_array($a_internalids)) {
3411 foreach ($a_internalids as $internalid) {
3412 if (is_numeric($internalid)) {
3413 $ids[] = $internalid;
3414 } else {
3415 $parsedid = ilUtil::__extractId($internalid, IL_INST_ID);
3416 if (is_numeric($parsedid) && $parsedid > 0) {
3417 $ids[] = $parsedid;
3418 }
3419 }
3420 }
3421 }
3422 if (count($ids) == 0) {
3423 $ids [] = -1;
3424 }
3425
3426 $query = "SELECT usr_data.*, usr_pref.value AS language
3427 FROM usr_data
3428 LEFT JOIN usr_pref
3429 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
3430 WHERE " . $ilDB->in("usr_data.usr_id", $ids, false, "integer");
3431 $values[] = "language";
3432 $types[] = "text";
3433
3434 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
3435
3436 $data = array();
3437 $result = $ilDB->queryF($query, $types, $values);
3438 while ($row = $ilDB->fetchAssoc($result)) {
3439 $data[] = $row;
3440 }
3441 return $data;
3442 }
3443
3450 public static function _getPreferences(int $user_id): array
3451 {
3452 global $DIC;
3453
3454 $ilDB = $DIC['ilDB'];
3455
3456 $prefs = array();
3457
3458 $r = $ilDB->queryF(
3459 "SELECT * FROM usr_pref WHERE usr_id = %s",
3460 array("integer"),
3461 array($user_id)
3462 );
3463
3464 while ($row = $ilDB->fetchAssoc($r)) {
3465 $prefs[$row["keyword"]] = $row["value"];
3466 }
3467
3468 return $prefs;
3469 }
3470
3475 public static function getUserSubsetByPreferenceValue(
3476 array $a_user_ids,
3477 string $a_keyword,
3478 string $a_val
3479 ): array {
3480 global $DIC;
3481
3482 $ilDB = $DIC['ilDB'];
3483
3484 $users = array();
3485 $set = $ilDB->query(
3486 "SELECT usr_id FROM usr_pref " .
3487 " WHERE keyword = " . $ilDB->quote($a_keyword, "text") .
3488 " AND " . $ilDB->in("usr_id", $a_user_ids, false, "integer") .
3489 " AND value = " . $ilDB->quote($a_val, "text")
3490 );
3491 while ($rec = $ilDB->fetchAssoc($set)) {
3492 $users[] = $rec["usr_id"];
3493 }
3494 return $users;
3495 }
3496
3497 public static function _getLoginAttempts(
3498 int $a_usr_id
3499 ): int {
3500 global $DIC;
3501
3502 $ilDB = $DIC['ilDB'];
3503
3504 $query = "SELECT login_attempts FROM usr_data WHERE usr_id = %s";
3505 $result = $ilDB->queryF($query, array('integer'), array($a_usr_id));
3506 $record = $ilDB->fetchAssoc($result);
3507 return (int) ($record['login_attempts'] ?? 0);
3508 }
3509
3510 public static function _incrementLoginAttempts(
3511 int $a_usr_id
3512 ): bool {
3513 global $DIC;
3514
3515 $ilDB = $DIC['ilDB'];
3516
3517 $query = "UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s";
3518 $affected = $ilDB->manipulateF($query, array('integer'), array($a_usr_id));
3519
3520 if ($affected) {
3521 return true;
3522 } else {
3523 return false;
3524 }
3525 }
3526
3527 public static function _setUserInactive(
3528 int $a_usr_id
3529 ): bool {
3530 global $DIC;
3531
3532 $ilDB = $DIC['ilDB'];
3533
3534 $query = "UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s";
3535 $affected = $ilDB->manipulateF($query, array('timestamp', 'integer'), array(ilUtil::now(), $a_usr_id));
3536
3537 if ($affected) {
3538 return true;
3539 } else {
3540 return false;
3541 }
3542 }
3543
3547 public function hasPublicProfile(): bool
3548 {
3549 return in_array($this->getPref("public_profile"), array("y", "g"));
3550 }
3551
3555 public function getPublicName(): string
3556 {
3557 if ($this->hasPublicProfile()) {
3558 return $this->getFirstname() . " " . $this->getLastname() . " (" . $this->getLogin() . ")";
3559 } else {
3560 return $this->getLogin();
3561 }
3562 }
3563
3564 public static function _writeHistory(
3565 int $a_usr_id,
3566 string $a_login
3567 ): void {
3568 global $DIC;
3569
3570 $ilDB = $DIC['ilDB'];
3571
3572 $timestamp = time();
3573
3574 $res = $ilDB->queryF(
3575 'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
3576 array('integer', 'text', 'integer'),
3577 array($a_usr_id, $a_login, $timestamp)
3578 );
3579
3580 if ($ilDB->numRows($res) == 0) {
3581 $ilDB->manipulateF(
3582 '
3583 INSERT INTO loginname_history
3584 (usr_id, login, history_date)
3585 VALUES (%s, %s, %s)',
3586 array('integer', 'text', 'integer'),
3587 array($a_usr_id, $a_login, $timestamp)
3588 );
3589 }
3590 }
3591
3596 public static function _getUsersOnline(
3597 int $a_user_id = 0,
3598 bool $a_no_anonymous = false
3599 ): array {
3600 global $DIC;
3601
3602 $ilDB = $DIC->database();
3603
3605
3606 $pd_set = new ilSetting('pd');
3607 $atime = $pd_set->get('user_activity_time') * 60;
3608 $ctime = time();
3609
3610 $where = array();
3611
3612 if ($a_user_id === 0) {
3613 $where[] = 'user_id > 0';
3614 } else {
3615 $where[] = 'user_id = ' . $ilDB->quote($a_user_id, 'integer');
3616 }
3617
3618 if ($a_no_anonymous) {
3619 $where[] = 'user_id != ' . $ilDB->quote(ANONYMOUS_USER_ID, 'integer');
3620 }
3621
3622 if (ilUserAccountSettings::getInstance()->isUserAccessRestricted()) {
3623 $where[] = $ilDB->in('time_limit_owner', ilUserFilter::getInstance()->getFolderIds(), false, 'integer');
3624 }
3625
3626 $where[] = 'expires > ' . $ilDB->quote($ctime, 'integer');
3627 $where[] = '(p.value IS NULL OR NOT p.value = ' . $ilDB->quote('y', 'text') . ')';
3628
3629 $where = 'WHERE ' . implode(' AND ', $where);
3630
3631 $r = $ilDB->queryF(
3632 $q = "
3633 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime, context, agree_date
3634 FROM usr_session
3635 LEFT JOIN usr_data u
3636 ON user_id = u.usr_id
3637 LEFT JOIN usr_pref p
3638 ON (p.usr_id = u.usr_id AND p.keyword = %s)
3639 $where
3640 GROUP BY user_id, firstname, lastname, title, login, last_login, context, agree_date
3641 ORDER BY lastname, firstname
3642 ",
3643 array('text'),
3644 array('hide_own_online_status')
3645 );
3646
3647 $log->debug("Query: " . $q);
3648
3649 $users = array();
3650 while ($user = $ilDB->fetchAssoc($r)) {
3651 if ($atime <= 0 || $user['ctime'] + $atime > $ctime) {
3652 $users[$user['user_id']] = $user;
3653 }
3654 }
3655
3656 $log->debug("Found users: " . count($users));
3657
3659 $users = array_filter($users, static function (array $user) {
3660 if ($user['agree_date'] || $user['user_id'] == SYSTEM_USER_ID || 'root' === $user['login']) {
3661 return true;
3662 }
3663
3664 return false;
3665 });
3666
3667 $log->debug("TOS filtered to users: " . count($users));
3668 }
3669
3670 return $users;
3671 }
3672
3677 public static function _generateRegistrationHash(int $a_usr_id): string
3678 {
3679 global $DIC;
3680
3681 $ilDB = $DIC['ilDB'];
3682
3683 do {
3684 $continue = false;
3685
3686 $hashcode = substr(md5(uniqid(mt_rand(), true)), 0, 16);
3687
3688 $res = $ilDB->queryf(
3689 '
3690 SELECT COUNT(usr_id) cnt FROM usr_data
3691 WHERE reg_hash = %s',
3692 array('text'),
3693 array($hashcode)
3694 );
3695 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
3696 if ($row->cnt > 0) {
3697 $continue = true;
3698 }
3699 break;
3700 }
3701
3702 if ($continue) {
3703 continue;
3704 }
3705
3706 $ilDB->manipulateF(
3707 '
3708 UPDATE usr_data
3709 SET reg_hash = %s
3710 WHERE usr_id = %s',
3711 array('text', 'integer'),
3712 array($hashcode, $a_usr_id)
3713 );
3714
3715 break;
3716 } while (true);
3717
3718 return $hashcode;
3719 }
3720
3726 public static function _verifyRegistrationHash(
3727 string $a_hash
3728 ): int {
3729 global $DIC;
3730
3731 $ilDB = $DIC['ilDB'];
3732
3733 $res = $ilDB->queryf(
3734 '
3735 SELECT usr_id, create_date FROM usr_data
3736 WHERE reg_hash = %s',
3737 array('text'),
3738 array($a_hash)
3739 );
3740 while ($row = $ilDB->fetchAssoc($res)) {
3741 $oRegSettigs = new ilRegistrationSettings();
3742
3743 if ($oRegSettigs->getRegistrationHashLifetime() != 0 &&
3744 time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
3746 'reg_confirmation_hash_life_time_expired',
3747 (int) $row['usr_id']
3748 );
3749 }
3750
3751 $ilDB->manipulateF(
3752 '
3753 UPDATE usr_data
3754 SET reg_hash = %s
3755 WHERE usr_id = %s',
3756 array('text', 'integer'),
3757 array('', (int) $row['usr_id'])
3758 );
3759
3760 return (int) $row['usr_id'];
3761 }
3762
3763 throw new ilRegistrationHashNotFoundException('reg_confirmation_hash_not_found');
3764 }
3765
3766 public function setBirthday(?string $a_birthday): void
3767 {
3768 if (strlen($a_birthday)) {
3769 $date = new ilDate($a_birthday, IL_CAL_DATE);
3770 $this->birthday = $date->get(IL_CAL_DATE);
3771 } else {
3772 $this->birthday = null;
3773 }
3774 }
3775
3776 public function getBirthday(): ?string
3777 {
3778 return $this->birthday;
3779 }
3780
3787 public static function getUserIdsByInactivityPeriod(
3788 int $periodInDays
3789 ): array {
3790 global $DIC;
3791
3792 if ($periodInDays < 1) {
3793 throw new ilException('Invalid period given');
3794 }
3795
3796 $date = date('Y-m-d H:i:s', (time() - ($periodInDays * 24 * 60 * 60)));
3797
3798 $query = "SELECT usr_id FROM usr_data WHERE last_login IS NOT NULL AND last_login < %s";
3799
3800 $ids = [];
3801
3802 $types = ['timestamp'];
3803 $values = [$date];
3804
3805 $res = $DIC->database()->queryF($query, $types, $values);
3806 while ($row = $DIC->database()->fetchAssoc($res)) {
3807 $ids[] = (int) $row['usr_id'];
3808 }
3809
3810 return $ids;
3811 }
3812
3818 public static function getUserIdsNeverLoggedIn(
3819 int $thresholdInDays
3820 ): array {
3821 global $DIC;
3822
3823 $date = date('Y-m-d H:i:s', (time() - ($thresholdInDays * 24 * 60 * 60)));
3824
3825 $query = "SELECT usr_id FROM usr_data WHERE last_login IS NULL AND create_date < %s";
3826
3827 $ids = [];
3828
3829 $types = ['timestamp'];
3830 $values = [$date];
3831
3832 $res = $DIC->database()->queryF($query, $types, $values);
3833 while ($row = $DIC->database()->fetchAssoc($res)) {
3834 $ids[] = (int) $row['usr_id'];
3835 }
3836
3837 return $ids;
3838 }
3839
3846 public static function _getUserIdsByInactivationPeriod(
3847 int $period
3848 ): array {
3850 $field = 'inactivation_date';
3852
3853 if (!$period) {
3854 throw new ilException('no valid period given');
3855 }
3856
3857 global $DIC;
3858
3859 $ilDB = $DIC['ilDB'];
3860
3861 $date = date('Y-m-d H:i:s', (time() - ($period * 24 * 60 * 60)));
3862
3863 $query = "SELECT usr_id FROM usr_data WHERE $field < %s AND active = %s";
3864
3865 $res = $ilDB->queryF($query, ['timestamp', 'integer'], [$date, 0]);
3866
3867 $ids = [];
3868 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
3869 $ids[] = (int) $row->usr_id;
3870 }
3871
3872 return $ids;
3873 }
3874
3875 public function resetOwner(): void
3876 {
3877 $ilDB = $this->db;
3878
3879 $query = "UPDATE object_data SET owner = 0 " .
3880 "WHERE owner = " . $ilDB->quote($this->getId(), 'integer');
3881 $ilDB->query($query);
3882 }
3883
3888 public static function getFirstLettersOfLastnames(
3889 ?array $user_ids = null
3890 ): array {
3891 global $DIC;
3892
3893 $ilDB = $DIC->database();
3894
3895 $q = "SELECT DISTINCT " . $ilDB->upper($ilDB->substr("lastname", 1, 1)) . " let" .
3896 " FROM usr_data" .
3897 " WHERE usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer") .
3898 ($user_ids !== null ? " AND " . $ilDB->in('usr_id', $user_ids, false, "integer") : "") .
3899 " ORDER BY let";
3900 $let_set = $ilDB->query($q);
3901
3902 $let = array();
3903 while ($let_rec = $ilDB->fetchAssoc($let_set)) {
3904 $let[$let_rec["let"]] = $let_rec["let"];
3905 }
3906 return $let;
3907 }
3908
3909 public static function userExists(
3910 array $a_usr_ids = array()
3911 ): bool {
3912 global $DIC;
3913
3914 $ilDB = $DIC['ilDB'];
3915
3916 $query = 'SELECT count(*) num FROM object_data od ' .
3917 'JOIN usr_data ud ON obj_id = usr_id ' .
3918 'WHERE ' . $ilDB->in('obj_id', $a_usr_ids, false, 'integer') . ' ';
3919 $res = $ilDB->query($query);
3920 $num_rows = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)->num;
3921 return $num_rows == count($a_usr_ids);
3922 }
3923
3924 public function exportPersonalData(): void
3925 {
3926 $exp = new ilExport();
3927 $dir = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data");
3928 ilFileUtils::delDir($dir, true);
3929 $title = $this->getLastname() . ", " . $this->getLastname() . " [" . $this->getLogin() . "]";
3930 $exp->exportEntity(
3931 "personal_data",
3932 $this->getId(),
3933 "",
3934 "Services/User",
3935 $title,
3936 $dir
3937 );
3938 }
3939
3940 public function getPersonalDataExportFile(): string
3941 {
3942 $dir = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data");
3943 if (!is_dir($dir)) {
3944 return "";
3945 }
3946 foreach (ilFileUtils::getDir($dir) as $entry) {
3947 if (is_int(strpos($entry["entry"], ".zip"))) {
3948 return $entry["entry"];
3949 }
3950 }
3951
3952 return "";
3953 }
3954
3955 public function sendPersonalDataFile(): void
3956 {
3957 $file = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data") .
3958 "/" . $this->getPersonalDataExportFile();
3959 if (is_file($file)) {
3960 ilFileDelivery::deliverFileLegacy($file, $this->getPersonalDataExportFile());
3961 }
3962 }
3963
3964 public function importPersonalData(
3965 array $a_file,
3966 bool $a_profile_data,
3967 bool $a_settings,
3968 bool $a_notes,
3969 bool $a_calendar
3970 ): void {
3971 $imp = new ilImport();
3972 // bookmarks need to be skipped, importer does not exist anymore
3973 $imp->addSkipImporter("Services/Bookmarks");
3974 if (!$a_profile_data) {
3975 $imp->addSkipEntity("Services/User", "usr_profile");
3976 }
3977 if (!$a_settings) {
3978 $imp->addSkipEntity("Services/User", "usr_setting");
3979 }
3980 if (!$a_notes) {
3981 $imp->addSkipEntity("Services/Notes", "user_notes");
3982 }
3983 if (!$a_calendar) {
3984 $imp->addSkipEntity("Services/Calendar", "calendar");
3985 }
3986 $imp->importEntity(
3987 $a_file["tmp_name"],
3988 $a_file["name"],
3989 "personal_data",
3990 "Services/User"
3991 );
3992 }
3993
3994 public function setInactivationDate(?string $inactivation_date): void
3995 {
3996 $this->inactivation_date = $inactivation_date;
3997 }
3998
3999 public function getInactivationDate(): ?string
4000 {
4001 return $this->inactivation_date;
4002 }
4003
4004 public function hasToAcceptTermsOfService(): bool
4005 {
4006 if (
4008 null == $this->agree_date &&
4009 'root' != $this->login &&
4010 !in_array($this->getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID))
4011 ) {
4012 return true;
4013 }
4014
4015 return false;
4016 }
4017
4024 public static function getUsersAgreed(
4025 bool $a_agreed = true,
4026 ?array $a_users = null
4027 ): array {
4028 global $DIC;
4029
4030 $ilDB = $DIC['ilDB'];
4031
4032 $date_is = ($a_agreed)
4033 ? "IS NOT NULL"
4034 : "IS NULL";
4035
4036 $users = (is_array($a_users))
4037 ? " AND " . $ilDB->in("usr_id", $a_users, false, "integer")
4038 : "";
4039
4040 $set = $ilDB->query("SELECT usr_id FROM usr_data " .
4041 " WHERE agree_date " . $date_is .
4042 $users);
4043 $ret = array();
4044 while ($rec = $ilDB->fetchAssoc($set)) {
4045 $ret[] = (int) $rec["usr_id"];
4046 }
4047 return $ret;
4048 }
4049
4051 ?bool $status = null
4052 ): bool {
4053 if (null === $status) {
4054 return (bool) ilSession::get('has_to_accept_agr_in_session');
4055 }
4056
4058 ilSession::set('has_to_accept_agr_in_session', $status);
4059 }
4060 return $status;
4061 }
4062
4063 public function isAnonymous(): bool
4064 {
4065 return self::_isAnonymous($this->getId());
4066 }
4067
4068 public static function _isAnonymous(int $usr_id): bool
4069 {
4070 return $usr_id == ANONYMOUS_USER_ID;
4071 }
4072
4073 public function activateDeletionFlag(): void
4074 {
4075 $this->writePref("delete_flag", true);
4076 }
4077
4078 public function removeDeletionFlag(): void
4079 {
4080 $this->writePref("delete_flag", false);
4081 }
4082
4083 public function hasDeletionFlag(): bool
4084 {
4085 return (bool) $this->getPref("delete_flag");
4086 }
4087
4088 public function setIsSelfRegistered(bool $status): void
4089 {
4090 $this->is_self_registered = $status;
4091 }
4092
4093 public function isSelfRegistered(): bool
4094 {
4095 return $this->is_self_registered;
4096 }
4097
4098
4099 //
4100 // MULTI-TEXT / INTERESTS
4101 //
4102
4106 public function setGeneralInterests(?array $value = null): void
4107 {
4108 $this->interests_general = $value ?? [];
4109 }
4110
4114 public function getGeneralInterests(): array
4115 {
4116 return $this->interests_general;
4117 }
4118
4122 public function getGeneralInterestsAsText(): string
4123 {
4124 return $this->buildTextFromArray($this->interests_general);
4125 }
4126
4130 public function setOfferingHelp(?array $value = null): void
4131 {
4132 $this->interests_help_offered = $value ?? [];
4133 }
4134
4138 public function getOfferingHelp(): array
4139 {
4140 return $this->interests_help_offered;
4141 }
4142
4146 public function getOfferingHelpAsText(): string
4147 {
4148 return $this->buildTextFromArray($this->interests_help_offered);
4149 }
4150
4154 public function setLookingForHelp(?array $value = null): void
4155 {
4156 $this->interests_help_looking = $value ?? [];
4157 }
4158
4162 public function getLookingForHelp(): array
4163 {
4164 return $this->interests_help_looking;
4165 }
4166
4170 public function getLookingForHelpAsText(): string
4171 {
4172 return $this->buildTextFromArray($this->interests_help_looking);
4173 }
4174
4180 protected function buildTextFromArray(array $a_attr): string
4181 {
4182 if (count($a_attr) > 0) {
4183 return implode(", ", $a_attr);
4184 }
4185 return "";
4186 }
4187
4188 protected function readMultiTextFields(): void
4189 {
4190 global $DIC;
4191
4192 $ilDB = $DIC['ilDB'];
4193
4194 if (!$this->getId()) {
4195 return;
4196 }
4197
4198 $set = $ilDB->query("SELECT field_id,value" .
4199 " FROM usr_data_multi" .
4200 " WHERE usr_id = " . $ilDB->quote($this->getId(), "integer") .
4201 " ORDER BY value");
4202 while ($row = $ilDB->fetchAssoc($set)) {
4203 $values[$row["field_id"]][] = $row["value"];
4204 }
4205
4206 if (isset($values["interests_general"])) {
4207 $this->setGeneralInterests($values["interests_general"]);
4208 } else {
4209 $this->setGeneralInterests();
4210 }
4211 if (isset($values["interests_help_offered"])) {
4212 $this->setOfferingHelp($values["interests_help_offered"]);
4213 } else {
4214 $this->setOfferingHelp();
4215 }
4216 if (isset($values["interests_help_looking"])) {
4217 $this->setLookingForHelp($values["interests_help_looking"]);
4218 } else {
4219 $this->setLookingForHelp();
4220 }
4221 }
4222
4223 public function updateMultiTextFields(bool $a_create = false): void
4224 {
4225 global $DIC;
4226
4227 $ilDB = $DIC['ilDB'];
4228
4229 if (!$this->getId()) {
4230 return;
4231 }
4232
4233 if (!$a_create) {
4234 $this->deleteMultiTextFields();
4235 }
4236
4237 $map = array(
4238 "interests_general" => $this->getGeneralInterests(),
4239 "interests_help_offered" => $this->getOfferingHelp(),
4240 "interests_help_looking" => $this->getLookingForHelp()
4241 );
4242
4243 foreach ($map as $id => $values) {
4244 if (is_array($values) && count($values)) {
4245 foreach ($values as $value) {
4246 $value = trim($value);
4247 if ($value) {
4248 $uniq_id = $ilDB->nextId('usr_data_multi');
4249
4250 $ilDB->manipulate("INSERT usr_data_multi" .
4251 " (id,usr_id,field_id,value) VALUES" .
4252 " (" . $ilDB->quote($uniq_id, "integer") .
4253 "," . $ilDB->quote($this->getId(), "integer") .
4254 "," . $ilDB->quote($id, "text") .
4255 "," . $ilDB->quote($value, "text") .
4256 ")");
4257 }
4258 }
4259 }
4260 }
4261 }
4262
4263 protected function deleteMultiTextFields(): void
4264 {
4265 global $DIC;
4266
4267 $ilDB = $DIC['ilDB'];
4268
4269 if (!$this->getId()) {
4270 return;
4271 }
4272
4273 $ilDB->manipulate("DELETE FROM usr_data_multi" .
4274 " WHERE usr_id = " . $ilDB->quote($this->getId(), "integer"));
4275 }
4276
4277 public static function findInterests(
4278 string $a_term,
4279 ?int $a_user_id = null,
4280 string $a_field_id = null
4281 ): array {
4282 global $DIC;
4283
4284 $ilDB = $DIC['ilDB'];
4285
4286 $res = array();
4287
4288 $sql = "SELECT DISTINCT(value)" .
4289 " FROM usr_data_multi" .
4290 " WHERE " . $ilDB->like("value", "text", "%" . $a_term . "%");
4291 if ($a_field_id) {
4292 $sql .= " AND field_id = " . $ilDB->quote($a_field_id, "text");
4293 }
4294 if ($a_user_id) {
4295 $sql .= " AND usr_id <> " . $ilDB->quote($a_user_id, "integer");
4296 }
4297 $sql .= " ORDER BY value";
4298 $set = $ilDB->query($sql);
4299 while ($row = $ilDB->fetchAssoc($set)) {
4300 $res[] = $row["value"];
4301 }
4302
4303 return $res;
4304 }
4305
4314 public static function getProfileStatusOfUsers(
4315 array $a_user_ids
4316 ): array {
4317 global $DIC;
4318
4319 $ilDB = $DIC->database();
4320
4321 $set = $ilDB->query(
4322 "SELECT * FROM usr_pref " .
4323 " WHERE keyword = " . $ilDB->quote("public_profile", "text") .
4324 " AND " . $ilDB->in("usr_id", $a_user_ids, false, "integer")
4325 );
4326 $r = array(
4327 "global" => array(),
4328 "local" => array(),
4329 "public" => array(),
4330 "not_public" => array()
4331 );
4332 while ($rec = $ilDB->fetchAssoc($set)) {
4333 if ($rec["value"] == "g") {
4334 $r["global"][] = $rec["usr_id"];
4335 $r["public"][] = $rec["usr_id"];
4336 }
4337 if ($rec["value"] == "y") {
4338 $r["local"][] = $rec["usr_id"];
4339 $r["public"][] = $rec["usr_id"];
4340 }
4341 }
4342 foreach ($a_user_ids as $id) {
4343 if (!in_array($id, $r["public"])) {
4344 $r["not_public"][] = $id;
4345 }
4346 }
4347
4348 return $r;
4349 }
4350}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const UDF_TYPE_WYSIWYG
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)
static resetToDefaults()
reset to defaults
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static setUseRelativeDates(bool $a_status)
set use relative dates
static setLanguage(ilLanguage $a_lng)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
Class for single dates.
static _deleteByUser(int $a_usr_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
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)
Class ilFileUtils.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addSkipImporter(string $a_component, bool $skip=true)
static _getInstance()
Get singleton instance of this class.
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
Class ilMailOptions this class handles user mails.
Mail Box class Base class for creating and handling mail boxes.
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)
User class.
static _lookupLanguage(int $a_usr_id)
setUserDefinedData(array $a_data)
__construct(int $a_user_id=0, bool $a_call_by_reference=false)
setFullname()
builds a string with title + firstname + lastname method is used to build fullname in member variable...
setPhoneMobile(string $a_str)
string $utitle
string $longitude
setPhoneOffice(string $a_str)
static getUserIdsNeverLoggedIn(int $thresholdInDays)
Get ids of all users that have never logged in.
static _isAnonymous(int $usr_id)
string $phone_mobile
static _deleteAllPref(int $a_user_id)
Deletes a userpref value of the user from the database.
string $org_units
string $last_login
static _getUsersOnline(int $a_user_id=0, bool $a_no_anonymous=false)
reads all active sessions from db and returns users that are online OR returns only one active user i...
static _lookup(int $a_user_id, string $a_field)
setSelectedCountry(string $a_val)
Set selected country (selection drop down)
getLookingForHelpAsText()
Get help looking for as plain text.
updateMultiTextFields(bool $a_create=false)
getOfferingHelpAsText()
Get help offering as plain text.
removeUserPicture(bool $a_do_update=true)
getClipboardObjects(string $a_type="", bool $a_top_nodes_only=false)
get all clipboard objects of user and specified type
static lookupMatriculation(int $a_usr_id)
setCurrentLanguage(string $a_val)
Set current language.
array $interests_help_looking
static getUserLoginsByEmail(string $a_email)
string $client_ip
setIsSelfRegistered(bool $status)
setBirthday(?string $a_birthday)
setPref(string $a_keyword, ?string $a_value)
string $latitude
setLastname(string $a_str)
string $time_limit_message
static toUsernameWithoutDomain(string $a_login)
Static function removes Microsoft domain name from username webdav related.
setGender(string $a_str)
buildTextFromArray(array $a_attr)
Convert multi-text values to plain text.
setActive(bool $a_active, int $a_owner=0)
set user active state and updates system fields appropriately
resetPassword(string $raw, string $raw_retype)
Resets the user password.
static _deletePref(int $a_user_id, string $a_keyword)
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)
getFullname(int $a_max_strlen=0)
string $matriculation
getAuthMode(bool $a_auth_key=false)
setInstitution(string $a_str)
getPref(string $a_keyword)
static getUsersAgreed(bool $a_agreed=true, ?array $a_users=null)
Get users that have or have not agreed to the user agreement.
writeAccepted()
write accept date of user agreement
static _getLastHistoryDataByUserId(int $a_usr_id)
Returns the last used loginname and the changedate of the passed user_id.
static getLoginFromAuth()
Gets the username from $ilAuth, and converts it into an ILIAS login name.
setDepartment(string $a_str)
static _getUsersForIds(array $a_mem_ids, int $active=-1, int $timelimitowner=-1)
return user data for given user id
string $referral_comment
setLastLogin(string $a_str)
static _verifyRegistrationHash(string $a_hash)
Verifies a registration hash.
setCountry(string $a_str)
array $interests_general
static _writeHistory(int $a_usr_id, string $a_login)
clipboardHasObjectsOfType(string $a_type)
Check whether clipboard has objects of a certain type.
getLoginByUserId(int $a_userid)
string $password_encoding_type
updateLogin(string $a_login)
update login name
string $firstname
string $zipcode
setInactivationDate(?string $inactivation_date)
setTimeLimitUntil(?int $a_until)
static _lookupActive(int $a_usr_id)
static _externalAccountExists(string $a_external_account, string $a_auth_mode)
Check if an external account name already exists.
setPasswordSalt(?string $password_salt)
setTimeLimitMessage(string $a_time_limit_message)
setLastPasswordChangeTS(int $a_last_password_change_ts)
setZipcode(string $a_str)
string $agree_date
hasPublicProfile()
returns true if public is profile, false otherwise
setLastUpdate(string $a_str)
setMatriculation(string $a_str)
bool $is_self_registered
setTimeLimitFrom(?int $a_from)
static findInterests(string $a_term, ?int $a_user_id=null, string $a_field_id=null)
string $inactivation_date
static _uploadPersonalPicture(string $tmp_file, int $obj_id)
Create a personal picture image file from a temporary image file.
getCurrentLanguage()
returns the current language (may differ from user's pref setting!)
static _getLoginAttempts(int $a_usr_id)
getPersonalPicturePath(string $a_size="small", bool $a_force_pic=false)
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)
string $department
const PASSWD_CRYPTED
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
static _getLocalAccountsForEmail(string $a_email)
setLogin(string $a_str)
setStreet(string $a_str)
array $interests_help_offered
string $street
bool $time_limit_unlimited
static _writePref(int $a_usr_id, string $a_keyword, string $a_value)
deletePref(string $a_keyword)
bool $passwd_policy_reset
static _lookupId($a_user_str)
static _getUserData(array $a_internalids)
return user data for given user ids
static _getAllUserData(?array $a_fields=null, int $active=-1)
int $time_limit_from
int $last_password_change_ts
setPasswordPolicyResetStatus(bool $status)
string $first_login
static _getAllUserAssignedStyles()
setLatitude(?string $a_latitude)
string $lastname
setPasswd(string $a_str, string $a_type=ilObjUser::PASSWD_PLAIN)
string $ext_account
setLanguage(string $a_str)
static getUserIdsByEmail(string $a_email)
static _lookupExternalAccount(int $a_user_id)
string $approve_date
string $second_email
static _lookupFirstLogin(int $a_user_id)
string $passwd_type
static _getNumberOfUsersPerAuthMode()
get number of users per auth mode
static _lookupAuthMode(int $a_usr_id)
getPasswordPolicyResetStatus()
setSkin(string $a_str)
static _generateRegistrationHash(int $a_usr_id)
Generates a unique hashcode for activating a user profile after registration.
getSelectedCountry()
Get selected country (selection drop down)
setTimeLimitOwner(int $a_owner)
string $gender
array $user_defined_data
setLookingForHelp(?array $value=null)
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
const PASSWD_PLAIN
static _getUsersForClipboadObject(string $a_type, int $a_id)
get all users, that have a certain object within their clipboard
int $time_limit_until
string $country
static _incrementLoginAttempts(int $a_usr_id)
static _lookupName(int $a_user_id)
lookup user name
deleteUserDefinedFieldEntries()
static _getPersonalPicturePath(int $a_usr_id, string $a_size="small", bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
string $password_salt
static _lookupFeedHash(int $a_user_id, bool $a_create=false)
Lookup news feed hash for user.
setHobby(string $a_str)
setCity(string $a_str)
setLocationZoom(?int $a_locationzoom)
static _getUsersForFolder(int $ref_id, int $active)
get users for a category or from system folder
existsPref(string $a_keyword)
static _moveUsersToStyle(string $a_from_skin, string $a_from_style, string $a_to_skin, string $a_to_style)
int $time_limit_owner
removeObjectFromClipboard(int $a_item_id, string $a_type)
static _getPreferences(int $user_id)
get preferences for user
static getProfileStatusOfUsers(array $a_user_ids)
Get profile status.
static _lookupPref(int $a_usr_id, string $a_keyword)
writePref(string $a_keyword, string $a_value)
clipboardDeleteObjectsOfType(string $a_type)
refreshLogin()
updates the login data of a "user"
static _getImportedUserId(string $i2_id)
hasToAcceptTermsOfServiceInSession(?bool $status=null)
setFirstLogin(string $a_str)
string $birthday
checkUserId()
check user id with login name
getPublicName()
returns firstname lastname and login if profile is public, login otherwise
static _lookupLastLogin(int $a_user_id)
setLongitude(?string $a_longitude)
string $passwd
setGeneralInterests(?array $value=null)
setProfileIncomplete(bool $a_prof_inc)
setExternalAccount(string $a_str)
setLastProfilePrompt(string $a_str)
string $phone_office
setPhoneHome(string $a_str)
static hasActiveSession(int $a_user_id, string $a_session_id)
static _getUsersForGroup(array $a_mem_ids, int $active=-1)
return user data for group members
static _lookupFields(int $a_user_id)
lookup fields (deprecated; use more specific methods instead)
syncActive()
synchronizes current and stored user active values for the owner value to be set correctly,...
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...
static _setFeedPass(int $a_user_id, string $a_password)
Set news feed password for user.
getStoredActive(int $a_id)
get user active state
assignData(array $a_data)
loads a record "user" from array
static getUserIdByLogin(string $a_login)
setEmail(string $a_str)
static _getFeedPass(int $a_user_id)
Lookup news feed password for user.
static _lookupClientIP(int $a_user_id)
setTimeLimitUnlimited(bool $a_unlimited)
setFax(string $a_str)
static _lookupLogin(int $a_user_id)
string $fullname
string $auth_mode
bool $profile_incomplete
setLastPasswordChangeToNow()
setLoginAttempts(int $a_login_attempts)
string $phone_home
static _writeAuthMode(int $a_usr_id, string $a_auth_mode)
static _lookupGender(int $a_user_id)
string $loc_zoom
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)
return array of complete users which belong to a specific role
static _loginExists(string $a_login, int $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static lookupOrgUnitsRepresentation(int $a_usr_id)
lookup org unit representation
setUTitle(string $a_str)
set user title (note: don't mix up this method with setTitle() that is derived from ilObject and sets...
getGeneralInterestsAsText()
Get general interests as plain text.
getPCClipboardContent()
Add a page content item to PC clipboard (should go to another class)
static _doesLoginnameExistInHistory(string $a_login)
Checks whether the passed loginname already exists in history.
setComment(string $a_str)
static _setUserInactive(int $a_usr_id)
setOfferingHelp(?array $value=null)
getClipboardChilds(int $a_parent, string $a_insert_time)
Get children of an item.
setAgreeDate(?string $a_str)
static getUserSubsetByPreferenceValue(array $a_user_ids, string $a_keyword, string $a_val)
For a given set of user IDs return a subset that has a given user preference set.
setClientIP(string $a_str)
static getUserIdsByInactivityPeriod(int $periodInDays)
Get ids of all users that have been inactive for at least the given period.
static _readUsersProfileData(array $a_user_ids)
static array $personal_image_cache
static getFirstLettersOfLastnames(?array $user_ids=null)
Get first letters of all lastnames.
setFirstname(string $a_str)
string $sel_country
importPersonalData(array $a_file, bool $a_profile_data, bool $a_settings, bool $a_notes, bool $a_calendar)
string $institution
static _getAvatar(int $a_usr_id)
static copyProfilePicturesToDirectory(int $a_user_id, string $a_dir)
setSecondEmail(?string $second_email)
setApproveDate(?string $a_str)
set date the user account was activated null indicates that the user has not yet been activated
static userExists(array $a_usr_ids=array())
static _lookupEmail(int $a_user_id)
static _getUserIdsByInactivationPeriod(int $period)
get ids of all users that have been inactivated since at least the given period
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
updateOwner()
update owner of object in db
ilAppEventHandler $app_event_handler
setId(int $id)
ILIAS $ilias
static _lookupTitle(int $obj_id)
ilDBInterface $db
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isConvertVersionAtLeast(string $a_version)
Compare convert version numbers.
static execConvert(string $args)
execute convert command
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deleteEntriesOfUser(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance()
Singleton method to reduce footprint (included files, created instances)
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.
static signFile(string $path_to_file)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const USER_FOLDER_ID
Definition: constants.php:33
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
const IL_INST_ID
Definition: constants.php:40
const ANONYMOUS_USER_ID
Definition: constants.php:27
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This describes how a letter or a picture avatar could be modified during construction of UI.
Definition: Avatar.php:29
$ref_id
Definition: ltiauth.php:67
$res
Definition: ltiservices.php:69
$format
Definition: metadata.php:235
if( $orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:302
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
header include for all ilias files.
global $ilSetting
Definition: privfeed.php:17
$query
$ilErr
Definition: raiseError.php:17
$log
Definition: result.php:33
$lng