ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjUser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4define("IL_PASSWD_PLAIN", "plain");
5define("IL_PASSWD_CRYPTED", "crypted");
6
7
8require_once "./Services/Object/classes/class.ilObject.php";
9require_once './Services/User/exceptions/class.ilUserException.php';
10require_once './Modules/OrgUnit/classes/class.ilObjOrgUnit.php';
11require_once './Modules/OrgUnit/classes/class.ilObjOrgUnitTree.php';
12
25class ilObjUser extends ilObject
26{
31 // personal data
32
33 public $login; // username in system
34
38 protected $passwd; // password encoded in the format specified by $passwd_type
39
43 protected $passwd_type;
44 // specifies the password format.
45 // value: IL_PASSWD_PLAIN or IL_PASSWD_CRYPTED.
46
47 // Differences between password format in class ilObjUser and
48 // in table usr_data:
49 // Class ilObjUser supports two different password types
50 // (plain and crypted) and it uses the variables $passwd
51 // and $passwd_type to store them.
52 // Table usr_data supports only two different password types
53 // (md5 and bcrypt) and it uses the columns "passwd" and "passwd_type" to store them.
54 // The conversion between these two storage layouts is done
55 // in the methods that perform SQL statements. All other
56 // methods work exclusively with the $passwd and $passwd_type
57 // variables.
58
64
69 protected $password_salt = null;
70
71 public $gender; // 'm' or 'f'
72 public $utitle; // user title (keep in mind, that we derive $title from object also!)
73 public $firstname;
74 public $lastname;
75 protected $birthday;
76 public $fullname; // title + firstname + lastname in one string
77 //var $archive_dir = "./image"; // point to image file (should be flexible)
78 // address data
81 public $street;
82 public $city;
83 public $zipcode;
84 public $country;
89 public $fax;
90 public $email;
91 protected $second_email = null;
92 public $hobby;
95 public $approve_date = null;
96 public $agree_date = null;
97 public $active;
98 public $client_ip; // client ip to check before login
99 public $auth_mode; // authentication mode
100
101 public $latitude;
103 public $loc_zoom;
104
107
108 public $user_defined_data = array();
109
115 public $prefs;
116
122 public $skin;
123
124
131
137 public $ilias;
138
141
145 protected static $personal_image_cache = array();
146
152 protected $inactivation_date = null;
153
158 private $is_self_registered = false;
159
164 protected $org_units;
165
166 protected $interests_general; // [array]
167 protected $interests_help_offered; // [array]
168 protected $interests_help_looking; // [array]
169
173 protected $last_profile_prompt; // timestamp
174
178 protected $first_login; // timestamp
179
185 public function __construct($a_user_id = 0, $a_call_by_reference = false)
186 {
187 global $DIC;
188
189 $ilias = $DIC['ilias'];
190 $ilDB = $DIC['ilDB'];
191
192 // init variables
193 $this->ilias = &$ilias;
194 $this->db = &$ilDB;
195
196 $this->type = "usr";
197 parent::__construct($a_user_id, $a_call_by_reference);
198 $this->auth_mode = "default";
199 $this->passwd_type = IL_PASSWD_PLAIN;
200
201 // for gender selection. don't change this
202 /*$this->gender = array(
203 'n' => "salutation_n",
204 'm' => "salutation_m",
205 'f' => "salutation_f"
206 );*/
207 if ($a_user_id > 0) {
208 $this->setId($a_user_id);
209 $this->read();
210 } else {
211 // TODO: all code in else-structure doesn't belongs in class user !!!
212 //load default data
213 $this->prefs = array();
214 //language
215 $this->prefs["language"] = $this->ilias->ini->readVariable("language", "default");
216
217 //skin and pda support
218 $this->skin = $this->ilias->ini->readVariable("layout", "skin");
219
220 $this->prefs["skin"] = $this->skin;
221 // $this->prefs["show_users_online"] = "y";
222
223 //style (css)
224 $this->prefs["style"] = $this->ilias->ini->readVariable("layout", "style");
225 }
226 }
227
232 public function read()
233 {
234 global $DIC;
235
236 $ilErr = $DIC['ilErr'];
237 $ilDB = $DIC['ilDB'];
238
239 // Alex: I have removed the JOIN to rbac_ua, since there seems to be no
240 // use (3.11.0 alpha)
241 /*$q = "SELECT * FROM usr_data ".
242 "LEFT JOIN rbac_ua ON usr_data.usr_id=rbac_ua.usr_id ".
243 "WHERE usr_data.usr_id= ".$ilDB->quote($this->id); */
244 $r = $ilDB->queryF("SELECT * FROM usr_data " .
245 "WHERE usr_id= %s", array("integer"), array($this->id));
246
247 if ($data = $ilDB->fetchAssoc($r)) {
248 // convert password storage layout used by table usr_data into
249 // storage layout used by class ilObjUser
250 $data["passwd_type"] = IL_PASSWD_CRYPTED;
251
252 // this assign must not be set via $this->assignData($data)
253 // because this method will be called on profile updates and
254 // would set this values to 0, because they arent posted from form
255 $this->setLastPasswordChangeTS($data['last_password_change']);
256 $this->setLoginAttempts($data['login_attempts']);
257
258
259 // fill member vars in one shot
260 $this->assignData($data);
261
262 //get userpreferences from usr_pref table
263 $this->readPrefs();
264
265 //set language to default if not set
266 if ($this->prefs["language"] == "") {
267 $this->prefs["language"] = $this->oldPrefs["language"];
268 }
269
270 //check skin-setting
271 include_once("./Services/Style/System/classes/class.ilStyleDefinition.php");
272 if ($this->prefs["skin"] == "" ||
273 !ilStyleDefinition::skinExists($this->prefs["skin"])) {
274 $this->prefs["skin"] = $this->oldPrefs["skin"];
275 }
276
277 $this->skin = $this->prefs["skin"];
278
279 //check style-setting (skins could have more than one stylesheet
280 if ($this->prefs["style"] == "" ||
281 (!ilStyleDefinition::skinExists($this->skin) && ilStyleDefinition::styleExistsForSkinId($this->skin, $this->prefs["style"]))) {
282 //load default (css)
283 $this->prefs["style"] = $this->ilias->ini->readVariable("layout", "style");
284 }
285
286 if (empty($this->prefs["hits_per_page"])) {
287 $this->prefs["hits_per_page"] = 10;
288 }
289 } else {
290 $ilErr->raiseError("<b>Error: There is no dataset with id " .
291 $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ .
292 "<br />Line: " . __LINE__, $ilErr->FATAL);
293 }
294
295 $this->readMultiTextFields();
296 $this->readUserDefinedFields();
297
298 parent::read();
299 }
300
304 public function getPasswordEncodingType()
305 {
307 }
308
312 public function setPasswordEncodingType($password_encryption_type)
313 {
314 $this->password_encoding_type = $password_encryption_type;
315 }
316
320 public function getPasswordSalt()
321 {
323 }
324
329 {
330 $this->password_salt = $password_salt;
331 }
332
338 public function assignData($a_data)
339 {
340 global $DIC;
341
342 $ilErr = $DIC['ilErr'];
343 $ilDB = $DIC['ilDB'];
344 $lng = $DIC['lng'];
345
346 // basic personal data
347 $this->setLogin($a_data["login"]);
348 if (!$a_data["passwd_type"]) {
349 $ilErr->raiseError("<b>Error: passwd_type missing in function assignData(). " .
350 $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: "
351 . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
352 }
353 if ($a_data["passwd"] != "********" and strlen($a_data['passwd'])) {
354 $this->setPasswd($a_data["passwd"], $a_data["passwd_type"]);
355 }
356
357 $this->setGender($a_data["gender"]);
358 $this->setUTitle($a_data["title"]);
359 $this->setFirstname($a_data["firstname"]);
360 $this->setLastname($a_data["lastname"]);
361 $this->setFullname();
362 if (!is_array($a_data['birthday'])) {
363 $this->setBirthday($a_data['birthday']);
364 } else {
365 $this->setBirthday(null);
366 }
367
368 // address data
369 $this->setInstitution($a_data["institution"]);
370 $this->setDepartment($a_data["department"]);
371 $this->setStreet($a_data["street"]);
372 $this->setCity($a_data["city"]);
373 $this->setZipcode($a_data["zipcode"]);
374 $this->setCountry($a_data["country"]);
375 $this->setSelectedCountry($a_data["sel_country"]);
376 $this->setPhoneOffice($a_data["phone_office"]);
377 $this->setPhoneHome($a_data["phone_home"]);
378 $this->setPhoneMobile($a_data["phone_mobile"]);
379 $this->setFax($a_data["fax"]);
380 $this->setMatriculation($a_data["matriculation"]);
381 $this->setEmail($a_data["email"]);
382 $this->setSecondEmail($a_data["second_email"]);
383 $this->setHobby($a_data["hobby"]);
384 $this->setClientIP($a_data["client_ip"]);
385 $this->setPasswordEncodingType($a_data['passwd_enc_type']);
386 $this->setPasswordSalt($a_data['passwd_salt']);
387
388 // other data
389 $this->setLatitude($a_data["latitude"]);
390 $this->setLongitude($a_data["longitude"]);
391 $this->setLocationZoom($a_data["loc_zoom"]);
392
393 // system data
394 $this->setLastLogin($a_data["last_login"]);
395 $this->setFirstLogin($a_data["first_login"]);
396 $this->setLastProfilePrompt($a_data["last_profile_prompt"]);
397 $this->setLastUpdate($a_data["last_update"]);
398 $this->create_date = $a_data["create_date"];
399 $this->setComment($a_data["referral_comment"]);
400 $this->approve_date = $a_data["approve_date"];
401 $this->active = $a_data["active"];
402 $this->agree_date = $a_data["agree_date"];
403
404 $this->setInactivationDate($a_data["inactivation_date"]);
405
406 // time limitation
407 $this->setTimeLimitOwner($a_data["time_limit_owner"]);
408 $this->setTimeLimitUnlimited($a_data["time_limit_unlimited"]);
409 $this->setTimeLimitFrom($a_data["time_limit_from"]);
410 $this->setTimeLimitUntil($a_data["time_limit_until"]);
411 $this->setTimeLimitMessage($a_data['time_limit_message']);
412
413 // user profile incomplete?
414 $this->setProfileIncomplete($a_data["profile_incomplete"]);
415
416 //authentication
417 $this->setAuthMode($a_data['auth_mode']);
418 $this->setExternalAccount($a_data['ext_account']);
419
420 $this->setIsSelfRegistered((bool) $a_data['is_self_registered']);
421 }
422
429 public function saveAsNew($a_from_formular = true)
430 {
431 global $DIC;
432
433 $ilAppEventHandler = $DIC['ilAppEventHandler'];
434
439 global $DIC;
440
441 $ilErr = $DIC['ilErr'];
442 $ilDB = $DIC['ilDB'];
443
444 switch ($this->passwd_type) {
445 case IL_PASSWD_PLAIN:
446 if (strlen($this->passwd)) {
447 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
448 ilUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
449 $pw_value = $this->getPasswd();
450 } else {
451 $pw_value = $this->passwd;
452 }
453 break;
454
456 $pw_value = $this->passwd;
457 break;
458
459 default:
460 $ilErr->raiseError("<b>Error: passwd_type missing in function saveAsNew. " .
461 $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ .
462 "<br />Line: " . __LINE__, $ilErr->FATAL);
463 }
464
465 if (!$this->active) {
467 } else {
468 $this->setInactivationDate(null);
469 }
470
471 $insert_array = array(
472 "usr_id" => array("integer", $this->id),
473 "login" => array("text", $this->login),
474 "passwd" => array("text", $pw_value),
475 'passwd_enc_type' => array("text", $this->getPasswordEncodingType()),
476 'passwd_salt' => array("text", $this->getPasswordSalt()),
477 "firstname" => array("text", $this->firstname),
478 "lastname" => array("text", $this->lastname),
479 "title" => array("text", $this->utitle),
480 "gender" => array("text", $this->gender),
481 "email" => array("text", trim($this->email)),
482 "second_email" => array("text", trim($this->second_email)),
483 "hobby" => array("text", (string) $this->hobby),
484 "institution" => array("text", $this->institution),
485 "department" => array("text", $this->department),
486 "street" => array("text", $this->street),
487 "city" => array("text", $this->city),
488 "zipcode" => array("text", $this->zipcode),
489 "country" => array("text", $this->country),
490 "sel_country" => array("text", $this->sel_country),
491 "phone_office" => array("text", $this->phone_office),
492 "phone_home" => array("text", $this->phone_home),
493 "phone_mobile" => array("text", $this->phone_mobile),
494 "fax" => array("text", $this->fax),
495 "birthday" => array('date', $this->getBirthday()),
496 "last_login" => array("timestamp", null),
497 "first_login" => array("timestamp", null),
498 "last_profile_prompt" => array("timestamp", null),
499 "last_update" => array("timestamp", ilUtil::now()),
500 "create_date" => array("timestamp", ilUtil::now()),
501 "referral_comment" => array("text", $this->referral_comment),
502 "matriculation" => array("text", $this->matriculation),
503 "client_ip" => array("text", $this->client_ip),
504 "approve_date" => array("timestamp", $this->approve_date),
505 "agree_date" => array("timestamp", $this->agree_date),
506 "active" => array("integer", (int) $this->active),
507 "time_limit_unlimited" => array("integer", $this->getTimeLimitUnlimited()),
508 "time_limit_until" => array("integer", $this->getTimeLimitUntil()),
509 "time_limit_from" => array("integer", $this->getTimeLimitFrom()),
510 "time_limit_owner" => array("integer", $this->getTimeLimitOwner()),
511 "auth_mode" => array("text", $this->getAuthMode()),
512 "ext_account" => array("text", $this->getExternalAccount()),
513 "profile_incomplete" => array("integer", $this->getProfileIncomplete()),
514 "latitude" => array("text", $this->latitude),
515 "longitude" => array("text", $this->longitude),
516 "loc_zoom" => array("integer", (int) $this->loc_zoom),
517 "last_password_change" => array("integer", (int) $this->last_password_change_ts),
518 'inactivation_date' => array('timestamp', $this->inactivation_date),
519 'is_self_registered' => array('integer', (int) $this->is_self_registered),
520 );
521 $ilDB->insert("usr_data", $insert_array);
522
523 $this->updateMultiTextFields(true);
524
525 // add new entry in usr_defined_data
527 // ... and update
529
530 // CREATE ENTRIES FOR MAIL BOX
531 include_once("Services/Mail/classes/class.ilMailbox.php");
532 $mbox = new ilMailbox($this->id);
533 $mbox->createDefaultFolder();
534
535 include_once "Services/Mail/classes/class.ilMailOptions.php";
536 $mail_options = new ilMailOptions($this->id);
537 $mail_options->createMailOptionsEntry();
538
539 // create personal bookmark folder tree
540 include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
541 $bmf = new ilBookmarkFolder(0, $this->id);
542 $bmf->createNewBookmarkTree();
543
544 $ilAppEventHandler->raise(
545 "Services/User",
546 "afterCreate",
547 array("user_obj" => $this)
548 );
549 }
550
554 public function update()
555 {
561 global $DIC;
562
563 $ilErr = $DIC['ilErr'];
564 $ilDB = $DIC['ilDB'];
565 $ilAppEventHandler = $DIC['ilAppEventHandler'];
566
567 $this->syncActive();
568
569 if ($this->getStoredActive($this->id) && !$this->active) {
571 } elseif ($this->active) {
572 $this->setInactivationDate(null);
573 }
574
575 $update_array = array(
576 "gender" => array("text", $this->gender),
577 "title" => array("text", $this->utitle),
578 "firstname" => array("text", $this->firstname),
579 "lastname" => array("text", $this->lastname),
580 "email" => array("text", trim($this->email)),
581 "second_email" => array("text", trim($this->second_email)),
582 "birthday" => array('date', $this->getBirthday()),
583 "hobby" => array("text", $this->hobby),
584 "institution" => array("text", $this->institution),
585 "department" => array("text", $this->department),
586 "street" => array("text", $this->street),
587 "city" => array("text", $this->city),
588 "zipcode" => array("text", $this->zipcode),
589 "country" => array("text", $this->country),
590 "sel_country" => array("text", $this->sel_country),
591 "phone_office" => array("text", $this->phone_office),
592 "phone_home" => array("text", $this->phone_home),
593 "phone_mobile" => array("text", $this->phone_mobile),
594 "fax" => array("text", $this->fax),
595 "referral_comment" => array("text", $this->referral_comment),
596 "matriculation" => array("text", $this->matriculation),
597 "client_ip" => array("text", $this->client_ip),
598 "approve_date" => array("timestamp", $this->approve_date),
599 "active" => array("integer", $this->active),
600 "time_limit_unlimited" => array("integer", $this->getTimeLimitUnlimited()),
601 "time_limit_until" => array("integer", $this->getTimeLimitUntil()),
602 "time_limit_from" => array("integer", $this->getTimeLimitFrom()),
603 "time_limit_owner" => array("integer", $this->getTimeLimitOwner()),
604 "time_limit_message" => array("integer", $this->getTimeLimitMessage()),
605 "profile_incomplete" => array("integer", $this->getProfileIncomplete()),
606 "auth_mode" => array("text", $this->getAuthMode()),
607 "ext_account" => array("text", $this->getExternalAccount()),
608 "latitude" => array("text", $this->latitude),
609 "longitude" => array("text", $this->longitude),
610 "loc_zoom" => array("integer", (int) $this->loc_zoom),
611 "last_password_change" => array("integer", $this->last_password_change_ts),
612 "last_update" => array("timestamp", ilUtil::now()),
613 'inactivation_date' => array('timestamp', $this->inactivation_date)
614 );
615
616 if (isset($this->agree_date) && (strtotime($this->agree_date) !== false || $this->agree_date == null)) {
617 $update_array["agree_date"] = array("timestamp", $this->agree_date);
618 }
619 switch ($this->passwd_type) {
620 case IL_PASSWD_PLAIN:
621 if (strlen($this->passwd)) {
622 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
623 ilUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
624 $update_array['passwd'] = array('text', $this->getPasswd());
625 } else {
626 $update_array["passwd"] = array("text", (string) $this->passwd);
627 }
628 break;
629
631 $update_array["passwd"] = array("text", (string) $this->passwd);
632 break;
633
634 default:
635 $ilErr->raiseError("<b>Error: passwd_type missing in function update()" . $this->id . "!</b><br />class: " .
636 get_class($this) . "<br />Script: " . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
637 }
638
639 $update_array['passwd_enc_type'] = array('text', $this->getPasswordEncodingType());
640 $update_array['passwd_salt'] = array('text', $this->getPasswordSalt());
641
642 $ilDB->update("usr_data", $update_array, array("usr_id" => array("integer", $this->id)));
643
644 $this->updateMultiTextFields();
645
646 $this->writePrefs();
647
648 // update user defined fields
650
652 parent::updateOwner();
653
654 $this->read();
655
656 $ilAppEventHandler->raise(
657 "Services/User",
658 "afterUpdate",
659 array("user_obj" => $this)
660 );
661
662 return true;
663 }
664
668 public function writeAccepted()
669 {
670 global $DIC;
671
672 $ilDB = $DIC['ilDB'];
673
674 $ilDB->manipulateF("UPDATE usr_data SET agree_date = " . $ilDB->now() .
675 " WHERE usr_id = %s", array("integer"), array($this->getId()));
676 }
677
681 private static function _lookup($a_user_id, $a_field)
682 {
683 global $DIC;
684
685 $ilDB = $DIC['ilDB'];
686
687 $res = $ilDB->queryF(
688 "SELECT " . $a_field . " FROM usr_data WHERE usr_id = %s",
689 array("integer"),
690 array($a_user_id)
691 );
692
693 while ($set = $ilDB->fetchAssoc($res)) {
694 return $set[$a_field];
695 }
696 return false;
697 }
698
702 public static function _lookupFullname($a_user_id)
703 {
704 global $DIC;
705
706 $ilDB = $DIC['ilDB'];
707
708 $set = $ilDB->queryF(
709 "SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s",
710 array("integer"),
711 array($a_user_id)
712 );
713
714 if ($rec = $ilDB->fetchAssoc($set)) {
715 if ($rec["title"]) {
716 $fullname = $rec["title"] . " ";
717 }
718 if ($rec["firstname"]) {
719 $fullname .= $rec["firstname"] . " ";
720 }
721 if ($rec["lastname"]) {
722 $fullname .= $rec["lastname"];
723 }
724 }
725 return $fullname;
726 }
727
731 public static function _lookupEmail($a_user_id)
732 {
733 return ilObjUser::_lookup($a_user_id, "email");
734 }
735
741 public static function _lookupSecondEmail($a_user_id)
742 {
743 return ilObjUser::_lookup($a_user_id, "second_email");
744 }
745
749 public static function _lookupGender($a_user_id)
750 {
751 return ilObjUser::_lookup($a_user_id, "gender");
752 }
753
760 public static function _lookupClientIP($a_user_id)
761 {
762 return ilObjUser::_lookup($a_user_id, "client_ip");
763 }
764
765
771 public static function _lookupName($a_user_id)
772 {
773 global $DIC;
774
775 $ilDB = $DIC['ilDB'];
776
777 $res = $ilDB->queryF(
778 "SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
779 array("integer"),
780 array($a_user_id)
781 );
782 $user_rec = $ilDB->fetchAssoc($res);
783 return array("user_id" => $a_user_id,
784 "firstname" => $user_rec["firstname"],
785 "lastname" => $user_rec["lastname"],
786 "title" => $user_rec["title"],
787 "login" => $user_rec["login"]);
788 }
789
793 public static function _lookupFields($a_user_id)
794 {
795 global $DIC;
796
797 $ilDB = $DIC['ilDB'];
798
799 $res = $ilDB->queryF(
800 "SELECT * FROM usr_data WHERE usr_id = %s",
801 array("integer"),
802 array($a_user_id)
803 );
804 $user_rec = $ilDB->fetchAssoc($res);
805 return $user_rec;
806 }
807
811 public static function _lookupLogin($a_user_id)
812 {
813 return ilObjUser::_lookup($a_user_id, "login");
814 }
815
819 public static function _lookupExternalAccount($a_user_id)
820 {
821 return ilObjUser::_lookup($a_user_id, "ext_account");
822 }
823
827 public static function _lookupId($a_user_str)
828 {
829 global $DIC;
830
831 $ilDB = $DIC['ilDB'];
832
833 if (!is_array($a_user_str)) {
834 $res = $ilDB->queryF(
835 "SELECT usr_id FROM usr_data WHERE login = %s",
836 array("text"),
837 array($a_user_str)
838 );
839 $user_rec = $ilDB->fetchAssoc($res);
840 return $user_rec["usr_id"];
841 } else {
842 $set = $ilDB->query(
843 "SELECT usr_id FROM usr_data " .
844 " WHERE " . $ilDB->in("login", $a_user_str, false, "text")
845 );
846 $ids = array();
847 while ($rec = $ilDB->fetchAssoc($set)) {
848 $ids[] = $rec["usr_id"];
849 }
850 return $ids;
851 }
852 }
853
857 public static function _lookupLastLogin($a_user_id)
858 {
859 return ilObjUser::_lookup($a_user_id, "last_login");
860 }
861
865 public static function _lookupFirstLogin($a_user_id)
866 {
867 return ilObjUser::_lookup($a_user_id, "first_login");
868 }
869
870
876 public function refreshLogin()
877 {
878 global $DIC;
879
880 $ilDB = $DIC['ilDB'];
881
882 $ilDB->manipulateF(
883 "UPDATE usr_data SET " .
884 "last_login = " . $ilDB->now() .
885 " WHERE usr_id = %s",
886 array("integer"),
887 array($this->id)
888 );
889
890 if ($this->getFirstLogin() == "") {
891 $ilDB->manipulateF(
892 "UPDATE usr_data SET " .
893 "first_login = " . $ilDB->now() .
894 " WHERE usr_id = %s",
895 array("integer"),
896 array($this->id)
897 );
898 }
899 }
900
901
909 public function resetPassword($raw, $raw_retype)
910 {
914 global $DIC;
915
916 $ilDB = $DIC['ilDB'];
917
918 if (func_num_args() != 2) {
919 return false;
920 }
921
922 if (!isset($raw) || !isset($raw_retype)) {
923 return false;
924 }
925
926 if ($raw != $raw_retype) {
927 return false;
928 }
929
930 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
931 ilUserPasswordManager::getInstance()->encodePassword($this, $raw);
932
933 $ilDB->manipulateF(
934 'UPDATE usr_data
935 SET passwd = %s, passwd_enc_type = %s, passwd_salt = %s
936 WHERE usr_id = %s',
937 array('text', 'text', 'text', 'integer'),
938 array($this->getPasswd(), $this->getPasswordEncodingType(), $this->getPasswordSalt(), $this->getId())
939 );
940
941 return true;
942 }
943
954 public static function _doesLoginnameExistInHistory($a_login)
955 {
956 global $DIC;
957
958 $ilDB = $DIC['ilDB'];
959
960 $res = $ilDB->queryF(
961 '
962 SELECT * FROM loginname_history
963 WHERE login = %s',
964 array('text'),
965 array($a_login)
966 );
967
968 return $ilDB->fetchAssoc($res) ? true : false;
969 }
970
983 public static function _getLastHistoryDataByUserId($a_usr_id)
984 {
985 global $DIC;
986
987 $ilDB = $DIC['ilDB'];
988
989 $ilDB->setLimit(1, 0);
990 $res = $ilDB->queryF(
991 '
992 SELECT login, history_date FROM loginname_history
993 WHERE usr_id = %s ORDER BY history_date DESC',
994 array('integer'),
995 array($a_usr_id)
996 );
997 $row = $ilDB->fetchAssoc($res);
998 if (!is_array($row) || !count($row)) {
999 throw new ilUserException('');
1000 }
1001
1002 return array(
1003 $row['login'], $row['history_date']
1004 );
1005 }
1006
1014 public function updateLogin($a_login)
1015 {
1016 global $DIC;
1017
1018 $ilDB = $DIC['ilDB'];
1019 $ilSetting = $DIC['ilSetting'];
1020
1021 if (func_num_args() != 1) {
1022 return false;
1023 }
1024
1025 if (!isset($a_login)) {
1026 return false;
1027 }
1028
1029 $former_login = self::_lookupLogin($this->getId());
1030
1031 // Update not necessary
1032 if (0 == strcmp($a_login, $former_login)) {
1033 return false;
1034 }
1035
1036 try {
1037 $last_history_entry = ilObjUser::_getLastHistoryDataByUserId($this->getId());
1038 } catch (ilUserException $e) {
1039 $last_history_entry = null;
1040 }
1041
1042 // throw exception if the desired loginame is already in history and it is not allowed to reuse it
1043 if ((int) $ilSetting->get('allow_change_loginname') &&
1044 (int) $ilSetting->get('reuse_of_loginnames') == 0 &&
1045 self::_doesLoginnameExistInHistory($a_login)) {
1046 throw new ilUserException($this->lng->txt('loginname_already_exists'));
1047 } elseif ((int) $ilSetting->get('allow_change_loginname') &&
1048 (int) $ilSetting->get('loginname_change_blocking_time') &&
1049 is_array($last_history_entry) &&
1050 $last_history_entry[1] + (int) $ilSetting->get('loginname_change_blocking_time') > time()) {
1051 include_once 'Services/Calendar/classes/class.ilDate.php';
1052 throw new ilUserException(
1053 sprintf(
1054 $this->lng->txt('changing_loginname_not_possible_info'),
1056 new ilDateTime($last_history_entry[1], IL_CAL_UNIX)
1057 ),
1059 new ilDateTime(($last_history_entry[1] + (int) $ilSetting->get('loginname_change_blocking_time')), IL_CAL_UNIX)
1060 )
1061 )
1062 );
1063 } else {
1064 // log old loginname in history
1065 if ((int) $ilSetting->get('allow_change_loginname') &&
1066 (int) $ilSetting->get('create_history_loginname')) {
1067 ilObjUser::_writeHistory($this->getId(), $former_login);
1068 }
1069
1070 //update login
1071 $this->login = $a_login;
1072
1073 $ilDB->manipulateF(
1074 '
1075 UPDATE usr_data
1076 SET login = %s
1077 WHERE usr_id = %s',
1078 array('text', 'integer'),
1079 array($this->getLogin(), $this->getId())
1080 );
1081 }
1082
1083 return true;
1084 }
1085
1092 public function writePref($a_keyword, $a_value)
1093 {
1094 self::_writePref($this->id, $a_keyword, $a_value);
1095 $this->setPref($a_keyword, $a_value);
1096 }
1097
1098
1104 public function deletePref($a_keyword)
1105 {
1106 self::_deletePref($this->getId(), $a_keyword);
1107 }
1108
1114 public static function _deletePref($a_user_id, $a_keyword)
1115 {
1119 global $DIC;
1120
1121 $ilDB = $DIC['ilDB'];
1122
1123 $ilDB->manipulateF(
1124 'DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s',
1125 array('integer', 'text'),
1126 array($a_user_id, $a_keyword)
1127 );
1128 }
1129
1135 public static function _deleteAllPref($a_user_id)
1136 {
1137 global $DIC;
1138
1139 $ilDB = $DIC['ilDB'];
1140
1141 $ilDB->manipulateF(
1142 "DELETE FROM usr_pref WHERE usr_id = %s",
1143 array("integer"),
1144 array($a_user_id)
1145 );
1146 }
1147
1154 public static function _writePref($a_usr_id, $a_keyword, $a_value)
1155 {
1156 global $DIC;
1157
1158 $ilDB = $DIC['ilDB'];
1159 $ilDB->replace(
1160 "usr_pref",
1161 array(
1162 "usr_id" => array("integer", $a_usr_id),
1163 "keyword" => array("text", $a_keyword),
1164 ),
1165 array(
1166 "value" => array("text",$a_value)
1167 )
1168 );
1169
1170 /*
1171 self::_deletePref($a_usr_id, $a_keyword);
1172 if(strlen($a_value))
1173 {
1174 $ilDB->manipulateF(
1175 'INSERT INTO usr_pref (usr_id, keyword, value) VALUES (%s, %s, %s)',
1176 array('integer', 'text', 'text'),
1177 array($a_usr_id, $a_keyword, $a_value)
1178 );
1179 }*/
1180 }
1181
1186 public function writePrefs()
1187 {
1188 global $DIC;
1189
1190 $ilDB = $DIC['ilDB'];
1191
1192 ilObjUser::_deleteAllPref($this->id);
1193 foreach ($this->prefs as $keyword => $value) {
1194 self::_writePref($this->id, $keyword, $value);
1195 }
1196 }
1197
1204 public function getTimeZone()
1205 {
1206 if ($tz = $this->getPref('user_tz')) {
1207 return $tz;
1208 } else {
1209 include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
1211 return $settings->getDefaultTimeZone();
1212 }
1213 }
1214
1221 public function getTimeFormat()
1222 {
1223 if ($format = $this->getPref('time_format')) {
1224 return $format;
1225 } else {
1226 include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
1228 return $settings->getDefaultTimeFormat();
1229 }
1230 }
1231
1238 public function getDateFormat()
1239 {
1240 if ($format = $this->getPref('date_format')) {
1241 return $format;
1242 } else {
1243 include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
1245 return $settings->getDefaultDateFormat();
1246 }
1247 }
1248
1255 public function setPref($a_keyword, $a_value)
1256 {
1257 if ($a_keyword != "") {
1258 $this->prefs[$a_keyword] = $a_value;
1259 }
1260 }
1261
1267 public function getPref($a_keyword)
1268 {
1269 if (array_key_exists($a_keyword, $this->prefs)) {
1270 return $this->prefs[$a_keyword];
1271 } else {
1272 return false;
1273 }
1274 }
1275
1276 public static function _lookupPref($a_usr_id, $a_keyword)
1277 {
1278 global $DIC;
1279
1280 $ilDB = $DIC['ilDB'];
1281
1282 $query = "SELECT * FROM usr_pref WHERE usr_id = " . $ilDB->quote($a_usr_id, "integer") . " " .
1283 "AND keyword = " . $ilDB->quote($a_keyword, "text");
1284 $res = $ilDB->query($query);
1285
1286 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1287 return $row->value;
1288 }
1289 return false;
1290 }
1291
1296 public function readPrefs()
1297 {
1298 global $DIC;
1299
1300 $ilDB = $DIC['ilDB'];
1301
1302 if (is_array($this->prefs)) {
1303 $this->oldPrefs = $this->prefs;
1304 }
1305
1306 $this->prefs = ilObjUser::_getPreferences($this->id);
1307 }
1308
1314 public function delete()
1315 {
1316 global $DIC;
1317
1318 $rbacadmin = $DIC->rbac()->admin();
1319 $ilDB = $DIC['ilDB'];
1320
1321 // deassign from ldap groups
1322 include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1324 $mapping->deleteUser($this->getId());
1325
1326 // remove mailbox / update sent mails
1327 include_once("Services/Mail/classes/class.ilMailbox.php");
1328 $mailbox = new ilMailbox($this->getId());
1329 $mailbox->delete();
1330 $mailbox->updateMailsOfDeletedUser($this->getLogin());
1331
1332 // delete feed blocks on personal desktop
1333 include_once("./Services/Block/classes/class.ilCustomBlock.php");
1334 $costum_block = new ilCustomBlock();
1335 $costum_block->setContextObjId($this->getId());
1336 $costum_block->setContextObjType("user");
1337 $c_blocks = $costum_block->queryBlocksForContext();
1338 include_once("./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1339 foreach ($c_blocks as $c_block) {
1340 if ($c_block["type"] == "pdfeed") {
1341 $fb = new ilPDExternalFeedBlock($c_block["id"]);
1342 $fb->delete();
1343 }
1344 }
1345
1346
1347 // delete block settings
1348 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1350
1351 // delete user_account
1352 $ilDB->manipulateF(
1353 "DELETE FROM usr_data WHERE usr_id = %s",
1354 array("integer"),
1355 array($this->getId())
1356 );
1357
1358 $this->deleteMultiTextFields();
1359
1360 // delete user_prefs
1362
1363 $this->removeUserPicture(false); // #8597
1364
1365 // delete user_session
1366 include_once("./Services/Authentication/classes/class.ilSession.php");
1368
1369 // remove user from rbac
1370 $rbacadmin->removeUser($this->getId());
1371
1372 // remove bookmarks
1373 // TODO: move this to class.ilBookmarkFolder
1374 $q = "DELETE FROM bookmark_tree WHERE tree = " .
1375 $ilDB->quote($this->getId(), "integer");
1376 $ilDB->manipulate($q);
1377
1378 $q = "DELETE FROM bookmark_data WHERE user_id = " .
1379 $ilDB->quote($this->getId(), "integer");
1380 $ilDB->manipulate($q);
1381
1382 // DELETE FORUM ENTRIES (not complete in the moment)
1383 include_once './Modules/Forum/classes/class.ilObjForum.php';
1385
1386 // Delete link check notify entries
1387 include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1389
1390 // Delete crs entries
1391 include_once './Modules/Course/classes/class.ilObjCourse.php';
1393
1394 // Delete user tracking
1395 include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
1397
1398 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1400
1401 // Delete Tracking data SCORM 2004 RTE
1402 include_once 'Modules/Scorm2004/classes/ilSCORM13Package.php';
1404
1405 // Delete Tracking data SCORM 1.2 RTE
1406 include_once 'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
1408
1409 // remove all notifications
1410 include_once "./Services/Notification/classes/class.ilNotification.php";
1412
1413 // remove portfolios
1414 include_once "./Modules/Portfolio/classes/class.ilObjPortfolio.php";
1416
1417 // remove workspace
1418 include_once "./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1419 $tree = new ilWorkspaceTree($this->getId());
1420 $tree->cascadingDelete();
1421
1422 // remove disk quota entries
1423 include_once "./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1425
1426 // remove reminder entries
1427 require_once 'Services/User/classes/class.ilCronDeleteInactiveUserReminderMail.php';
1429
1430 // badges
1431 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
1433
1434 // remove org unit assignments
1435 $ilOrgUnitUserAssignmentQueries = ilOrgUnitUserAssignmentQueries::getInstance();
1436 $ilOrgUnitUserAssignmentQueries->deleteAllAssignmentsOfUser($this->getId());
1437
1438 // Delete user defined field entries
1440
1441 // Delete clipboard entries
1442 $this->clipboardDeleteAll();
1443
1444 // Reset owner
1445 $this->resetOwner();
1446
1447 // Trigger deleteUser Event
1448 global $DIC;
1449
1450 $ilAppEventHandler = $DIC['ilAppEventHandler'];
1451 $ilAppEventHandler->raise(
1452 'Services/User',
1453 'deleteUser',
1454 array('usr_id' => $this->getId())
1455 );
1456
1457 // delete object data
1458 parent::delete();
1459 return true;
1460 }
1461
1471 public function setFullname($a_title = "", $a_firstname = "", $a_lastname = "")
1472 {
1473 $this->fullname = "";
1474
1475 if ($a_title) {
1476 $fullname = $a_title . " ";
1477 } elseif ($this->utitle) {
1478 $this->fullname = $this->utitle . " ";
1479 }
1480
1481 if ($a_firstname) {
1482 $fullname .= $a_firstname . " ";
1483 } elseif ($this->firstname) {
1484 $this->fullname .= $this->firstname . " ";
1485 }
1486
1487 if ($a_lastname) {
1488 return $fullname . $a_lastname;
1489 }
1490
1491 $this->fullname .= $this->lastname;
1492 }
1493
1508 public function getFullname($a_max_strlen = 0)
1509 {
1510 if (!$a_max_strlen) {
1511 return ilUtil::stripSlashes($this->fullname);
1512 }
1513
1514 if (strlen($this->fullname) <= $a_max_strlen) {
1515 return ilUtil::stripSlashes($this->fullname);
1516 }
1517
1518 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen) {
1519 return ilUtil::stripSlashes($this->utitle . " " . substr($this->firstname, 0, 1) . ". " . $this->lastname);
1520 }
1521
1522 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen) {
1523 return ilUtil::stripSlashes($this->firstname . " " . $this->lastname);
1524 }
1525
1526 if ((strlen($this->lastname) + 3) <= $a_max_strlen) {
1527 return ilUtil::stripSlashes(substr($this->firstname, 0, 1) . ". " . $this->lastname);
1528 }
1529
1530 return ilUtil::stripSlashes(substr($this->lastname, 0, $a_max_strlen));
1531 }
1532
1538 public function setLogin($a_str)
1539 {
1540 $this->login = $a_str;
1541 }
1542
1547 public function getLogin()
1548 {
1549 return $this->login;
1550 }
1551
1557 public function setPasswd($a_str, $a_type = IL_PASSWD_PLAIN)
1558 {
1559 $this->passwd = $a_str;
1560 $this->passwd_type = $a_type;
1561 }
1562
1570 public function getPasswd()
1571 {
1572 return $this->passwd;
1573 }
1580 public function getPasswdType()
1581 {
1582 return $this->passwd_type;
1583 }
1584
1590 public function setGender($a_str)
1591 {
1592 $this->gender = substr($a_str, -1);
1593 }
1594
1599 public function getGender()
1600 {
1601 return $this->gender;
1602 }
1603
1611 public function setUTitle($a_str)
1612 {
1613 $this->utitle = $a_str;
1614 }
1615
1622 public function getUTitle()
1623 {
1624 return $this->utitle;
1625 }
1626
1632 public function setFirstname($a_str)
1633 {
1634 $this->firstname = $a_str;
1635 }
1636
1641 public function getFirstname()
1642 {
1643 return $this->firstname;
1644 }
1645
1651 public function setLastname($a_str)
1652 {
1653 $this->lastname = $a_str;
1654 }
1655
1660 public function getLastname()
1661 {
1662 return $this->lastname;
1663 }
1664
1670 public function setInstitution($a_str)
1671 {
1672 $this->institution = $a_str;
1673 }
1674
1679 public function getInstitution()
1680 {
1681 return $this->institution;
1682 }
1683
1689 public function setDepartment($a_str)
1690 {
1691 $this->department = $a_str;
1692 }
1693
1698 public function getDepartment()
1699 {
1700 return $this->department;
1701 }
1702
1708 public function setStreet($a_str)
1709 {
1710 $this->street = $a_str;
1711 }
1712
1717 public function getStreet()
1718 {
1719 return $this->street;
1720 }
1721
1727 public function setCity($a_str)
1728 {
1729 $this->city = $a_str;
1730 }
1731
1736 public function getCity()
1737 {
1738 return $this->city;
1739 }
1740
1746 public function setZipcode($a_str)
1747 {
1748 $this->zipcode = $a_str;
1749 }
1750
1755 public function getZipcode()
1756 {
1757 return $this->zipcode;
1758 }
1759
1766 public function setCountry($a_str)
1767 {
1768 $this->country = $a_str;
1769 }
1770
1776 public function getCountry()
1777 {
1778 return $this->country;
1779 }
1780
1786 public function setSelectedCountry($a_val)
1787 {
1788 $this->sel_country = $a_val;
1789 }
1790
1796 public function getSelectedCountry()
1797 {
1798 return $this->sel_country;
1799 }
1800
1806 public function setPhoneOffice($a_str)
1807 {
1808 $this->phone_office = $a_str;
1809 }
1810
1815 public function getPhoneOffice()
1816 {
1817 return $this->phone_office;
1818 }
1819
1825 public function setPhoneHome($a_str)
1826 {
1827 $this->phone_home = $a_str;
1828 }
1829
1834 public function getPhoneHome()
1835 {
1836 return $this->phone_home;
1837 }
1838
1844 public function setPhoneMobile($a_str)
1845 {
1846 $this->phone_mobile = $a_str;
1847 }
1848
1853 public function getPhoneMobile()
1854 {
1855 return $this->phone_mobile;
1856 }
1857
1863 public function setFax($a_str)
1864 {
1865 $this->fax = $a_str;
1866 }
1867
1872 public function getFax()
1873 {
1874 return $this->fax;
1875 }
1876
1882 public function setClientIP($a_str)
1883 {
1884 $this->client_ip = $a_str;
1885 }
1886
1891 public function getClientIP()
1892 {
1893 return $this->client_ip;
1894 }
1895
1901 public function setMatriculation($a_str)
1902 {
1903 $this->matriculation = $a_str;
1904 }
1905
1910 public function getMatriculation()
1911 {
1912 return $this->matriculation;
1913 }
1914
1921 public static function lookupMatriculation($a_usr_id)
1922 {
1923 global $DIC;
1924
1925 $ilDB = $DIC['ilDB'];
1926
1927 $query = "SELECT matriculation FROM usr_data " .
1928 "WHERE usr_id = " . $ilDB->quote($a_usr_id);
1929 $res = $ilDB->query($query);
1931 return $row->matriculation ? $row->matriculation : '';
1932 }
1933
1939 public function setEmail($a_str)
1940 {
1941 $this->email = $a_str;
1942 }
1943
1948 public function getEmail()
1949 {
1950 return $this->email;
1951 }
1952
1956 public function getSecondEmail()
1957 {
1958 return $this->second_email;
1959 }
1960
1965 {
1966 $this->second_email = $second_email;
1967 }
1968
1974 public function setHobby($a_str)
1975 {
1976 $this->hobby = $a_str;
1977 }
1978
1983 public function getHobby()
1984 {
1985 return $this->hobby;
1986 }
1987
1993 public function setLanguage($a_str)
1994 {
1995 $this->setPref("language", $a_str);
1996 unset($_SESSION['lang']);
1997 }
1998
2004 public function getLanguage()
2005 {
2006 return $this->prefs["language"];
2007 }
2008
2017 public function setDiskQuota($a_disk_quota)
2018 {
2019 $this->setPref("disk_quota", $a_disk_quota);
2020 }
2021
2031 public function getDiskQuota()
2032 {
2033 return $this->prefs["disk_quota"] ? $this->prefs["disk_quota"] : 0;
2034 }
2035
2037 {
2038 return $this->prefs["wsp_disk_quota"] ? $this->prefs["wsp_disk_quota"] : 0;
2039 }
2040
2041 public function setLastPasswordChangeTS($a_last_password_change_ts)
2042 {
2043 $this->last_password_change_ts = $a_last_password_change_ts;
2044 }
2045
2046 public function getLastPasswordChangeTS()
2047 {
2049 }
2050
2051
2052 public static function _lookupLanguage($a_usr_id)
2053 {
2054 global $DIC;
2055
2056 $ilDB = $DIC->database();
2057 $lng = $DIC->language();
2058
2059 $q = "SELECT value FROM usr_pref WHERE usr_id= " .
2060 $ilDB->quote($a_usr_id, "integer") . " AND keyword = " .
2061 $ilDB->quote('language', "text");
2062 $r = $ilDB->query($q);
2063
2064 while ($row = $ilDB->fetchAssoc($r)) {
2065 return $row['value'];
2066 }
2067 if (is_object($lng)) {
2068 return $lng->getDefaultLanguage();
2069 }
2070 return 'en';
2071 }
2072
2073 public static function _writeExternalAccount($a_usr_id, $a_ext_id)
2074 {
2075 global $DIC;
2076
2077 $ilDB = $DIC['ilDB'];
2078
2079 $ilDB->manipulateF(
2080 "UPDATE usr_data " .
2081 " SET ext_account = %s WHERE usr_id = %s",
2082 array("text", "integer"),
2083 array($a_ext_id, $a_usr_id)
2084 );
2085 }
2086
2087 public static function _writeAuthMode($a_usr_id, $a_auth_mode)
2088 {
2089 global $DIC;
2090
2091 $ilDB = $DIC['ilDB'];
2092
2093 $ilDB->manipulateF(
2094 "UPDATE usr_data " .
2095 " SET auth_mode = %s WHERE usr_id = %s",
2096 array("text", "integer"),
2097 array($a_auth_mode, $a_usr_id)
2098 );
2099 }
2100
2105 public function getCurrentLanguage()
2106 {
2107 return $_SESSION['lang'];
2108 }
2109
2115 public function setCurrentLanguage($a_val)
2116 {
2117 $_SESSION['lang'] = $a_val;
2118 }
2119
2125 public function setLastLogin($a_str)
2126 {
2127 $this->last_login = $a_str;
2128 }
2129
2135 public function getLastLogin()
2136 {
2137 return $this->last_login;
2138 }
2139
2144 public function setFirstLogin($a_str)
2145 {
2146 $this->first_login = $a_str;
2147 }
2148
2153 public function getFirstLogin()
2154 {
2155 return $this->first_login;
2156 }
2157
2162 public function setLastProfilePrompt($a_str)
2163 {
2164 $this->last_profile_prompt = $a_str;
2165 }
2166
2171 public function getLastProfilePrompt()
2172 {
2174 }
2175
2181 public function setLastUpdate($a_str)
2182 {
2183 $this->last_update = $a_str;
2184 }
2185 public function getLastUpdate()
2186 {
2187 return $this->last_update;
2188 }
2189
2195 public function setComment($a_str)
2196 {
2197 $this->referral_comment = $a_str;
2198 }
2199
2204 public function getComment()
2205 {
2207 }
2208
2215 public function setApproveDate($a_str)
2216 {
2217 $this->approve_date = $a_str;
2218 }
2219
2225 public function getApproveDate()
2226 {
2227 return $this->approve_date;
2228 }
2229
2230 // BEGIN DiskQuota: show when user accepted user agreement
2236 public function getAgreeDate()
2237 {
2238 return $this->agree_date;
2239 }
2246 public function setAgreeDate($a_str)
2247 {
2248 $this->agree_date = $a_str;
2249 }
2250 // END DiskQuota: show when user accepted user agreement
2251
2258 public function setActive($a_active, $a_owner = 0)
2259 {
2260 $this->setOwner($a_owner);
2261
2262 if ($a_active) {
2263 $this->active = 1;
2264 $this->setApproveDate(date('Y-m-d H:i:s'));
2265 $this->setOwner($a_owner);
2266 } else {
2267 $this->active = 0;
2268 $this->setApproveDate(null);
2269 }
2270 }
2271
2276 public function getActive()
2277 {
2278 return $this->active;
2279 }
2280
2284 public static function _lookupActive($a_usr_id)
2285 {
2286 global $DIC;
2287
2288 $ilDB = $DIC['ilDB'];
2289
2290 $query = 'SELECT usr_id FROM usr_data ' .
2291 'WHERE active = ' . $ilDB->quote(1, 'integer') . ' ' .
2292 'AND usr_id = ' . $ilDB->quote($a_usr_id, 'integer');
2293 $res = $ilDB->query($query);
2294 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
2295 return true;
2296 }
2297 return false;
2298 }
2299
2305 public function syncActive()
2306 {
2307 $storedActive = 0;
2308 if ($this->getStoredActive($this->id)) {
2309 $storedActive = 1;
2310 }
2311
2312 $currentActive = 0;
2313 if ($this->active) {
2314 $currentActive = 1;
2315 }
2316
2317 if ((!empty($storedActive) && empty($currentActive)) ||
2318 (empty($storedActive) && !empty($currentActive))) {
2319 $this->setActive($currentActive, self::getUserIdByLogin(ilObjUser::getLoginFromAuth()));
2320 }
2321 }
2322
2329 public function getStoredActive($a_id)
2330 {
2331 $active = ilObjUser::_lookup($a_id, "active");
2332 return $active ? true : false;
2333 }
2334
2340 public function setSkin($a_str)
2341 {
2342 // TODO: exception handling (dir exists)
2343 $this->skin = $a_str;
2344 }
2345
2346 public function setTimeLimitOwner($a_owner)
2347 {
2348 $this->time_limit_owner = $a_owner;
2349 }
2350 public function getTimeLimitOwner()
2351 {
2352 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2353 }
2354 public function setTimeLimitFrom($a_from)
2355 {
2356 $this->time_limit_from = $a_from;
2357 }
2358 public function getTimeLimitFrom()
2359 {
2360 return $this->time_limit_from;
2361 }
2362 public function setTimeLimitUntil($a_until)
2363 {
2364 $this->time_limit_until = $a_until;
2365 }
2366 public function getTimeLimitUntil()
2367 {
2368 return $this->time_limit_until;
2369 }
2370 public function setTimeLimitUnlimited($a_unlimited)
2371 {
2372 $this->time_limit_unlimited = $a_unlimited;
2373 }
2374 public function getTimeLimitUnlimited()
2375 {
2376 return $this->time_limit_unlimited;
2377 }
2378 public function setTimeLimitMessage($a_time_limit_message)
2379 {
2380 return $this->time_limit_message = $a_time_limit_message;
2381 }
2382 public function getTimeLimitMessage()
2383 {
2384 return $this->time_limit_message;
2385 }
2386
2387 public function setLoginAttempts($a_login_attempts)
2388 {
2389 $this->login_attempts = $a_login_attempts;
2390 }
2391
2392 public function getLoginAttempts()
2393 {
2394 return $this->login_attempts;
2395 }
2396
2397
2398 public function checkTimeLimit()
2399 {
2400 if ($this->getTimeLimitUnlimited()) {
2401 return true;
2402 }
2403 if ($this->getTimeLimitFrom() < time() and $this->getTimeLimitUntil() > time()) {
2404 return true;
2405 }
2406 return false;
2407 }
2408 public function setProfileIncomplete($a_prof_inc)
2409 {
2410 $this->profile_incomplete = (boolean) $a_prof_inc;
2411 }
2412 public function getProfileIncomplete()
2413 {
2414 if ($this->id == ANONYMOUS_USER_ID) {
2415 return false;
2416 }
2417 return $this->profile_incomplete;
2418 }
2419
2424 {
2425 if ($this->id == ANONYMOUS_USER_ID) {
2426 return false;
2427 }
2428
2429 if ($this->id == SYSTEM_USER_ID) {
2430 require_once './Services/User/classes/class.ilUserPasswordManager.php';
2431 if (
2432 \ilUserPasswordManager::getInstance()->verifyPassword($this, base64_decode('aG9tZXI=')) &&
2434 ) {
2435 return true;
2436 } else {
2437 return false;
2438 }
2439 }
2440
2441 require_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2443
2444 if (
2446 $security->isPasswordChangeOnFirstLoginEnabled() &&
2447 $this->getLastPasswordChangeTS() == 0 &&
2448 $this->is_self_registered == false
2449 ) {
2450 return true;
2451 }
2452
2453 return false;
2454 }
2455
2456 public function isPasswordExpired()
2457 {
2458 if ($this->id == ANONYMOUS_USER_ID) {
2459 return false;
2460 }
2461
2462 require_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2464 if ($this->getLastPasswordChangeTS() > 0) {
2465 $max_pass_age = $security->getPasswordMaxAge();
2466 if ($max_pass_age > 0) {
2467 $max_pass_age_ts = ($max_pass_age * 86400);
2468 $pass_change_ts = $this->getLastPasswordChangeTS();
2469 $current_ts = time();
2470
2471 if (($current_ts - $pass_change_ts) > $max_pass_age_ts) {
2473 return true;
2474 }
2475 }
2476 }
2477 }
2478
2479 return false;
2480 }
2481
2482 public function getPasswordAge()
2483 {
2484 $current_ts = time();
2485 $pass_change_ts = $this->getLastPasswordChangeTS();
2486 $password_age = (int) (($current_ts - $pass_change_ts) / 86400);
2487 return $password_age;
2488 }
2489
2491 {
2492 global $DIC;
2493
2494 $ilDB = $DIC['ilDB'];
2495
2496 $this->setLastPasswordChangeTS(time());
2497
2498 $query = "UPDATE usr_data SET last_password_change = %s " .
2499 "WHERE usr_id = %s";
2500 $affected = $ilDB->manipulateF(
2501 $query,
2502 array('integer','integer'),
2503 array($this->getLastPasswordChangeTS(),$this->id)
2504 );
2505 if ($affected) {
2506 return true;
2507 } else {
2508 return false;
2509 }
2510 }
2511
2512 public function resetLastPasswordChange()
2513 {
2514 global $DIC;
2515
2516 $ilDB = $DIC['ilDB'];
2517
2518 $query = "UPDATE usr_data SET last_password_change = 0 " .
2519 "WHERE usr_id = %s";
2520 $affected = $ilDB->manipulateF(
2521 $query,
2522 array('integer'),
2523 array($this->getId())
2524 );
2525 if ($affected) {
2526 return true;
2527 } else {
2528 return false;
2529 }
2530 }
2531
2537 public function setLatitude($a_latitude)
2538 {
2539 $this->latitude = $a_latitude;
2540 }
2541
2547 public function getLatitude()
2548 {
2549 return $this->latitude;
2550 }
2551
2557 public function setLongitude($a_longitude)
2558 {
2559 $this->longitude = $a_longitude;
2560 }
2561
2567 public function getLongitude()
2568 {
2569 return $this->longitude;
2570 }
2571
2577 public function setLocationZoom($a_locationzoom)
2578 {
2579 $this->loc_zoom = $a_locationzoom;
2580 }
2581
2587 public function getLocationZoom()
2588 {
2589 return $this->loc_zoom;
2590 }
2591
2592
2598 public static function hasActiveSession($a_user_id, $a_session_id)
2599 {
2600 global $DIC;
2601
2602 $ilDB = $DIC['ilDB'];
2603
2604 $set = $ilDB->queryf(
2605 '
2606 SELECT COUNT(*) session_count
2607 FROM usr_session WHERE user_id = %s AND expires > %s AND session_id != %s ',
2608 array('integer', 'integer', 'text'),
2609 array($a_user_id, time(), $a_session_id)
2610 );
2611 $row = $ilDB->fetchAssoc($set);
2612 return (bool) $row['session_count'];
2613 }
2614
2615 /*
2616 * check user id with login name
2617 * @access public
2618 */
2619 public function checkUserId()
2620 {
2621 global $DIC;
2622
2623 $ilSetting = $DIC['ilSetting'];
2624
2627 if ($id > 0) {
2628 return $id;
2629 }
2630 return false;
2631 }
2632
2636 private static function getLoginFromAuth()
2637 {
2638 $uid = $GLOBALS['DIC']['ilAuthSession']->getUserId();
2640
2641 // BEGIN WebDAV: Strip Microsoft Domain Names from logins
2642 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2645 }
2646 return $login;
2647 }
2648
2655 public static function toUsernameWithoutDomain($a_login)
2656 {
2657 // Remove all characters including the last slash or the last backslash
2658 // in the username
2659 $pos = strrpos($a_login, '/');
2660 $pos2 = strrpos($a_login, '\\');
2661 if ($pos === false || $pos < $pos2) {
2662 $pos = $pos2;
2663 }
2664 if ($pos !== false) {
2665 $a_login = substr($a_login, $pos + 1);
2666 }
2667 return $a_login;
2668 }
2669
2670 /*
2671 * check to see if current user has been made active
2672 * @access public
2673 * @return true if active, otherwise false
2674 */
2675 public function isCurrentUserActive()
2676 {
2677 global $DIC;
2678
2679 $ilDB = $DIC['ilDB'];
2680
2682 $set = $ilDB->queryF(
2683 "SELECT active FROM usr_data WHERE login= %s",
2684 array("text"),
2685 array($login)
2686 );
2687 //query has got a result
2688 if ($rec = $ilDB->fetchAssoc($set)) {
2689 if ($rec["active"]) {
2690 return true;
2691 }
2692 }
2693
2694 return false;
2695 }
2696
2697 /*
2698 * STATIC METHOD
2699 * get the user_id of a login name
2700 * @param string login name
2701 * @return integer id of user
2702 * @static
2703 * @access public
2704 */
2705 public static function getUserIdByLogin($a_login)
2706 {
2707 return (int) ilObjUser::_lookupId($a_login);
2708 }
2709
2718 public static function getUserIdsByEmail($a_email) : array
2719 {
2720 global $DIC;
2721
2722 $ilias = $DIC['ilias'];
2723 $ilDB = $DIC['ilDB'];
2724
2725 $res = $ilDB->queryF(
2726 "SELECT usr_id FROM usr_data " .
2727 "WHERE email = %s and active = 1",
2728 array("text"),
2729 array($a_email)
2730 );
2731 $ids = array();
2732 while ($row = $ilDB->fetchObject($res)) {
2733 $ids[] = $row->usr_id;
2734 }
2735
2736 return $ids;
2737 }
2738
2739
2746 public static function getUserLoginsByEmail($a_email) : array
2747 {
2748 global $DIC;
2749
2750 $ilDB = $DIC->database();
2751
2752 $res = $ilDB->queryF(
2753 "SELECT login FROM usr_data " .
2754 "WHERE email = %s and active = 1",
2755 array("text"),
2756 array($a_email)
2757 );
2758 $ids = array();
2759 while ($row = $ilDB->fetchObject($res)) {
2760 $ids[] = $row->login;
2761 }
2762
2763 return $ids;
2764 }
2765
2766 /*
2767 * STATIC METHOD
2768 * get the login name of a user_id
2769 * @param integer id of user
2770 * @return string login name; false if not found
2771 * @static
2772 * @access public
2773 */
2774 public function getLoginByUserId($a_userid)
2775 {
2776 $login = ilObjUser::_lookupLogin($a_userid);
2777 return $login ? $login : false;
2778 }
2779
2790 public static function searchUsers($a_search_str, $active = 1, $a_return_ids_only = false, $filter_settings = false)
2791 {
2792 global $DIC;
2793
2794 $ilias = $DIC['ilias'];
2795 $ilDB = $DIC['ilDB'];
2796 $ilLog = $DIC['ilLog'];
2797
2798
2799 $query = "SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2800
2801 $without_anonymous_users = true;
2802
2803 // determine join filter
2804 $join_filter = " WHERE ";
2805 if ($filter_settings !== false && strlen($filter_settings)) {
2806 switch ($filter_settings) {
2807 case 3:
2808 // show only users without courses
2809 $join_filter = " LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.usr_id IS NULL AND ";
2810 break;
2811 case 5:
2812 // show only users with a certain course membership
2813 $ref_id = $_SESSION["user_filter_data"];
2814 if ($ref_id) {
2815 $join_filter = " LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.obj_id = " .
2816 "(SELECT obj_id FROM object_reference WHERE ref_id = " . $ilDB->quote($ref_id, "integer") . ") AND ";
2817 }
2818 break;
2819 case 6:
2820 global $DIC;
2821
2822 $rbacreview = $DIC['rbacreview'];
2823 $ref_id = $_SESSION["user_filter_data"];
2824 if ($ref_id) {
2825 $local_roles = $rbacreview->getRolesOfRoleFolder($ref_id, false);
2826 if (is_array($local_roles) && count($local_roles)) {
2827 $join_filter = " LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE " .
2828 $ilDB->in("rbac_ua.rol_id", $local_roles, false, $local_roles) . " AND ";
2829 }
2830 }
2831 break;
2832 case 7:
2833 global $DIC;
2834
2835 $rbacreview = $DIC['rbacreview'];
2836 $rol_id = $_SESSION["user_filter_data"];
2837 if ($rol_id) {
2838 $join_filter = " LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = " .
2839 $ilDB->quote($rol_id, "integer") . " AND ";
2840 $without_anonymous_users = false;
2841 }
2842 break;
2843 }
2844 }
2845 // This is a temporary hack to search users by their role
2846 // See Mantis #338. This is a hack due to Mantis #337.
2847 if (strtolower(substr($a_search_str, 0, 5)) == "role:") {
2848 $query = "SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email " .
2849 "FROM object_data,rbac_ua,usr_data " .
2850 "WHERE " . $ilDB->like("object_data.title", "text", "%" . substr($a_search_str, 5) . "%") .
2851 " AND object_data.type = 'role' " .
2852 "AND rbac_ua.rol_id = object_data.obj_id " .
2853 "AND usr_data.usr_id = rbac_ua.usr_id " .
2854 "AND rbac_ua.usr_id != " . $ilDB->quote(ANONYMOUS_USER_ID, "integer");
2855 } else {
2856 $query .= $join_filter .
2857 "(" . $ilDB->like("usr_data.login", "text", "%" . $a_search_str . "%") . " " .
2858 "OR " . $ilDB->like("usr_data.firstname", "text", "%" . $a_search_str . "%") . " " .
2859 "OR " . $ilDB->like("usr_data.lastname", "text", "%" . $a_search_str . "%") . " " .
2860 "OR " . $ilDB->like("usr_data.email", "text", "%" . $a_search_str . "%") . ") ";
2861
2862 if ($filter_settings !== false && strlen($filter_settings)) {
2863 switch ($filter_settings) {
2864 case 0:
2865 $query .= " AND usr_data.active = " . $ilDB->quote(0, "integer") . " ";
2866 break;
2867 case 1:
2868 $query .= " AND usr_data.active = " . $ilDB->quote(1, "integer") . " ";
2869 break;
2870 case 2:
2871 $query .= " AND usr_data.time_limit_unlimited = " . $ilDB->quote(0, "integer") . " ";
2872 break;
2873 case 4:
2874 $date = strftime("%Y-%m-%d %H:%I:%S", mktime(0, 0, 0, $_SESSION["user_filter_data"]["m"], $_SESSION["user_filter_data"]["d"], $_SESSION["user_filter_data"]["y"]));
2875 $query .= " AND last_login < " . $ilDB->quote($date, "timestamp") . " ";
2876 break;
2877 }
2878 }
2879
2880 if ($without_anonymous_users) {
2881 $query .= "AND usr_data.usr_id != " . $ilDB->quote(ANONYMOUS_USER_ID, "integer");
2882 }
2883
2884 if (is_numeric($active) && $active > -1 && $filter_settings === false) {
2885 $query .= " AND active = " . $ilDB->quote($active, "integer") . " ";
2886 }
2887 }
2888 $ilLog->write($query);
2889 $res = $ilDB->query($query);
2890 while ($row = $ilDB->fetchObject($res)) {
2891 $users[] = array(
2892 "usr_id" => $row->usr_id,
2893 "login" => $row->login,
2894 "firstname" => $row->firstname,
2895 "lastname" => $row->lastname,
2896 "email" => $row->email,
2897 "active" => $row->active);
2898 $ids[] = $row->usr_id;
2899 }
2900 if ($a_return_ids_only) {
2901 return $ids ? $ids : array();
2902 } else {
2903 return $users ? $users : array();
2904 }
2905 }
2906
2910 public static function getAllUserLogins()
2911 {
2915 global $DIC;
2916
2917 $ilDB = $DIC['ilDB'];
2918
2919 $logins = array();
2920
2921 $res = $ilDB->query(
2922 "SELECT login FROM usr_data WHERE " . $ilDB->in('usr_id', array(ANONYMOUS_USER_ID), true, 'integer')
2923 );
2924 while ($row = $ilDB->fetchAssoc($res)) {
2925 $logins[] = $row['login'];
2926 }
2927
2928 return $logins;
2929 }
2930
2939 public static function _readUsersProfileData($a_user_ids)
2940 {
2941 global $DIC;
2942
2943 $ilDB = $DIC['ilDB'];
2944 $res = $ilDB->query("SELECT * FROM usr_data WHERE " .
2945 $ilDB->in("usr_id", $a_user_ids, false, "integer"));
2946 while ($row = $ilDB->fetchAssoc($res)) {
2947 $user_data["$row[usr_id]"] = $row;
2948 }
2949 return $user_data ? $user_data : array();
2950 }
2951
2960 public static function _getAllUserData($a_fields = null, $active = -1)
2961 {
2962 global $DIC;
2963
2964 $ilDB = $DIC['ilDB'];
2965
2966 $result_arr = array();
2967 $types = array();
2968 $values = array();
2969
2970 if ($a_fields !== null and is_array($a_fields)) {
2971 if (count($a_fields) == 0) {
2972 $select = "*";
2973 } else {
2974 if (($usr_id_field = array_search("usr_id", $a_fields)) !== false) {
2975 unset($a_fields[$usr_id_field]);
2976 }
2977
2978 $select = implode(",", $a_fields) . ",usr_data.usr_id";
2979 // online time
2980 if (in_array('online_time', $a_fields)) {
2981 $select .= ",ut_online.online_time ";
2982 }
2983 }
2984
2985 $q = "SELECT " . $select . " FROM usr_data ";
2986
2987 // Add online_time if desired
2988 // Need left join here to show users that never logged in
2989 if (in_array('online_time', $a_fields)) {
2990 $q .= "LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2991 }
2992
2993 switch ($active) {
2994 case 0:
2995 case 1:
2996 $q .= "WHERE active = " . $ilDB->quote($active, "integer");
2997 break;
2998 case 2:
2999 $q .= "WHERE time_limit_unlimited= " . $ilDB->quote(0, "integer");;
3000 break;
3001 case 3:
3002 $qtemp = $q . ", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND " .
3003 $ilDB->like("object_data.title", "text", "%crs%") . " AND usr_data.usr_id = rbac_ua.usr_id";
3004 $r = $ilDB->query($qtemp);
3005 $course_users = array();
3006 while ($row = $ilDB->fetchAssoc($r)) {
3007 array_push($course_users, $row["usr_id"]);
3008 }
3009 if (count($course_users)) {
3010 $q .= " WHERE " . $ilDB->in("usr_data.usr_id", $course_users, true, "integer") . " ";
3011 } else {
3012 return $result_arr;
3013 }
3014 break;
3015 case 4:
3016 $date = strftime("%Y-%m-%d %H:%I:%S", mktime(0, 0, 0, $_SESSION["user_filter_data"]["m"], $_SESSION["user_filter_data"]["d"], $_SESSION["user_filter_data"]["y"]));
3017 $q .= " AND last_login < " . $ilDB->quote($date, "timestamp");
3018 break;
3019 case 5:
3020 $ref_id = $_SESSION["user_filter_data"];
3021 if ($ref_id) {
3022 $q .= " LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id " .
3023 "WHERE obj_members.obj_id = (SELECT obj_id FROM object_reference " .
3024 "WHERE ref_id = " . $ilDB->quote($ref_id, "integer") . ") ";
3025 }
3026 break;
3027 case 6:
3028 global $DIC;
3029
3030 $rbacreview = $DIC['rbacreview'];
3031 $ref_id = $_SESSION["user_filter_data"];
3032 if ($ref_id) {
3033 $local_roles = $rbacreview->getRolesOfRoleFolder($ref_id, false);
3034 if (is_array($local_roles) && count($local_roles)) {
3035 $q .= " LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE " .
3036 $ilDB->in("rbac_ua.rol_id", $local_roles, false, "integer") . " ";
3037 }
3038 }
3039 break;
3040 case 7:
3041 $rol_id = $_SESSION["user_filter_data"];
3042 if ($rol_id) {
3043 $q .= " LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = " .
3044 $ilDB->quote($rol_id, "integer");
3045 }
3046 break;
3047 }
3048 $r = $ilDB->query($q);
3049
3050 while ($row = $ilDB->fetchAssoc($r)) {
3051 $result_arr[] = $row;
3052 }
3053 }
3054
3055 return $result_arr;
3056 }
3057
3061 public static function _getNumberOfUsersForStyle($a_skin, $a_style)
3062 {
3063 global $DIC;
3064
3065 $ilDB = $DIC['ilDB'];
3066
3067 $q = "SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 " .
3068 " WHERE up1.keyword= " . $ilDB->quote("style", "text") .
3069 " AND up1.value= " . $ilDB->quote($a_style, "text") .
3070 " AND up2.keyword= " . $ilDB->quote("skin", "text") .
3071 " AND up2.value= " . $ilDB->quote($a_skin, "text") .
3072 " AND up1.usr_id = up2.usr_id ";
3073
3074 $cnt_set = $ilDB->query($q);
3075
3076 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
3077
3078 return $cnt_rec["cnt"];
3079 }
3080
3084 public static function _getAllUserAssignedStyles()
3085 {
3086 global $DIC;
3087
3088 $ilDB = $DIC['ilDB'];
3089
3090 $q = "SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 " .
3091 " WHERE up1.keyword = " . $ilDB->quote("style", "text") .
3092 " AND up2.keyword = " . $ilDB->quote("skin", "text") .
3093 " AND up1.usr_id = up2.usr_id";
3094
3095 $sty_set = $ilDB->query($q);
3096
3097 $styles = array();
3098 while ($sty_rec = $ilDB->fetchAssoc($sty_set)) {
3099 $styles[] = $sty_rec["skin"] . ":" . $sty_rec["style"];
3100 }
3101
3102 return $styles;
3103 }
3104
3108 public static function _moveUsersToStyle($a_from_skin, $a_from_style, $a_to_skin, $a_to_style)
3109 {
3110 global $DIC;
3111
3112 $ilDB = $DIC['ilDB'];
3113
3114 $q = "SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 " .
3115 " WHERE up1.keyword= " . $ilDB->quote("style", "text") .
3116 " AND up1.value= " . $ilDB->quote($a_from_style, "text") .
3117 " AND up2.keyword= " . $ilDB->quote("skin", "text") .
3118 " AND up2.value= " . $ilDB->quote($a_from_skin, "text") .
3119 " AND up1.usr_id = up2.usr_id ";
3120
3121 $usr_set = $ilDB->query($q);
3122
3123 while ($usr_rec = $ilDB->fetchAssoc($usr_set)) {
3124 self::_writePref($usr_rec["usr_id"], "skin", $a_to_skin);
3125 self::_writePref($usr_rec["usr_id"], "style", $a_to_style);
3126 }
3127 }
3128
3129
3139 public static function _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par = "")
3140 {
3141 global $DIC;
3142
3143 $ilDB = $DIC['ilDB'];
3144
3145 $item_set = $ilDB->queryF(
3146 "SELECT * FROM desktop_item WHERE " .
3147 "item_id = %s AND type = %s AND user_id = %s",
3148 array("integer", "text", "integer"),
3149 array($a_item_id, $a_type, $a_usr_id)
3150 );
3151
3152 // only insert if item is not already on desktop
3153 if (!$ilDB->fetchAssoc($item_set)) {
3154 $ilDB->manipulateF(
3155 "INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES " .
3156 " (%s,%s,%s,%s)",
3157 array("integer", "text", "integer", "text"),
3158 array($a_item_id,$a_type,$a_usr_id,$a_par)
3159 );
3160 }
3161
3162 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
3164 }
3165
3173 public function addDesktopItem($a_item_id, $a_type, $a_par = "")
3174 {
3175 ilObjUser::_addDesktopItem($this->getId(), $a_item_id, $a_type, $a_par);
3176 }
3177
3186 public function setDesktopItemParameters($a_item_id, $a_type, $a_par)
3187 {
3188 global $DIC;
3189
3190 $ilDB = $DIC['ilDB'];
3191
3192 $ilDB->manipulateF(
3193 "UPDATE desktop_item SET parameters = %s " .
3194 " WHERE item_id = %s AND type = %s AND user_id = %s",
3195 array("text", "integer", "text", "integer"),
3196 array($a_par, $a_item_id, $a_type, $this->getId())
3197 );
3198 }
3199
3200
3210 public static function _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
3211 {
3212 global $DIC;
3213
3214 $ilDB = $DIC['ilDB'];
3215
3216 $ilDB->manipulateF(
3217 "DELETE FROM desktop_item WHERE " .
3218 " item_id = %s AND type = %s AND user_id = %s",
3219 array("integer", "text", "integer"),
3220 array($a_item_id, $a_type, $a_usr_id)
3221 );
3222
3223 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
3225 }
3226
3234 public function dropDesktopItem($a_item_id, $a_type)
3235 {
3236 ilObjUser::_dropDesktopItem($this->getId(), $a_item_id, $a_type);
3237 }
3238
3245 public static function _removeItemFromDesktops($a_id)
3246 {
3247 global $DIC;
3248
3249 $ilDB = $DIC['ilDB'];
3250
3251 $r = $ilDB->queryF(
3252 "SELECT user_id FROM desktop_item WHERE item_id = %s",
3253 array("integer"),
3254 array($a_id)
3255 );
3256
3257 $users = array();
3258
3259 while ($row = $ilDB->fetchObject($r)) {
3260 $users[] = $row->user_id;
3261 } // while
3262
3263 if (count($users) > 0) {
3264 $ilDB->manipulateF(
3265 "DELETE FROM desktop_item WHERE item_id = %s",
3266 array("integer"),
3267 array($a_id)
3268 );
3269 }
3270
3271 return $users;
3272 }
3273
3283 public static function _isDesktopItem($a_usr_id, $a_item_id, $a_type)
3284 {
3285 global $DIC;
3286
3287 $ilDB = $DIC['ilDB'];
3288
3289 if (self::$is_desktop_item_loaded[$a_usr_id . ":" . $a_item_id]) {
3290 return self::$is_desktop_item_cache[$a_usr_id . ":" . $a_item_id . ":" . $a_type];
3291 }
3292 $item_set = $ilDB->queryF(
3293 "SELECT item_id FROM desktop_item WHERE " .
3294 "item_id = %s AND type = %s AND user_id = %s",
3295 array("integer", "text", "integer"),
3296 array($a_item_id, $a_type, $a_usr_id)
3297 );
3298
3299 if ($ilDB->fetchAssoc($item_set)) {
3300 return true;
3301 } else {
3302 return false;
3303 }
3304 }
3305
3312 public static function preloadIsDesktopItem($a_usr_id, $a_item_ids)
3313 {
3314 global $DIC;
3315
3316 $ilDB = $DIC['ilDB'];
3317
3318 if (!is_array($a_item_ids)) {
3319 return;
3320 }
3321
3322 $item_ids = array();
3323 foreach ($a_item_ids as $id) {
3324 if (!self::$is_desktop_item_loaded[$a_usr_id . ":" . $id]) {
3325 $item_ids[] = $id;
3326 }
3327 self::$is_desktop_item_loaded[$a_usr_id . ":" . $id] = true;
3328 }
3329
3330 if (count($item_ids) > 0) {
3331 $item_set = $ilDB->query("SELECT item_id, type FROM desktop_item WHERE " .
3332 $ilDB->in("item_id", $item_ids, false, "integer") .
3333 " AND user_id = " . $ilDB->quote($a_usr_id, "integer"));
3334 while ($r = $ilDB->fetchAssoc($item_set)) {
3335 self::$is_desktop_item_cache[$a_usr_id . ":" . $r["item_id"] . ":" . $r["type"]]
3336 = true;
3337 }
3338 }
3339 }
3340
3348 public function isDesktopItem($a_item_id, $a_type)
3349 {
3350 return ilObjUser::_isDesktopItem($this->getId(), $a_item_id, $a_type);
3351 }
3352
3353 public function getDesktopItems($a_types = "")
3354 {
3355 return $this->_lookupDesktopItems($this->getId(), $a_types);
3356 }
3357
3364 public static function _lookupDesktopItems($user_id, $a_types = "")
3365 {
3366 global $DIC;
3367
3368 $ilUser = $DIC['ilUser'];
3369 $rbacsystem = $DIC['rbacsystem'];
3370 $tree = $DIC['tree'];
3371 $ilDB = $DIC['ilDB'];
3372
3373 if ($a_types == "") {
3374 $is_nested_set = ($tree->getTreeImplementation() instanceof ilNestedSetTree);
3375
3376 $item_set = $ilDB->queryF("SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type " .
3377 " FROM desktop_item it, object_reference oref " .
3378 ", object_data obj" .
3379 " WHERE " .
3380 "it.item_id = oref.ref_id AND " .
3381 "oref.obj_id = obj.obj_id AND " .
3382 "it.user_id = %s", array("integer"), array($user_id));
3383 $items = $all_parent_path = array();
3384 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
3385 if ($tree->isInTree($item_rec["ref_id"])
3386 && $item_rec["type"] != "rolf"
3387 && $item_rec["type"] != "itgr") { // due to bug 11508
3388 $parent_ref = $tree->getParentId($item_rec["ref_id"]);
3389
3390 if (!isset($all_parent_path[$parent_ref])) {
3391 // #15746
3392 //if($is_nested_set)
3393 //{
3394 // $par_left = $tree->getLeftValue($parent_ref);
3395 // $all_parent_path[$parent_ref] = sprintf("%010d", $par_left);
3396 //}
3397 //else
3398 //{
3399 if ($parent_ref > 0) { // workaround for #0023176
3400 $node = $tree->getNodeData($parent_ref);
3401 $all_parent_path[$parent_ref] = $node["title"];
3402 } else {
3403 $all_parent_path[$parent_ref] = "";
3404 }
3405 //}
3406 }
3407
3408 $parent_path = $all_parent_path[$parent_ref];
3409
3410 $title = ilObject::_lookupTitle($item_rec["obj_id"]);
3411 $desc = ilObject::_lookupDescription($item_rec["obj_id"]);
3412 $items[$parent_path . $title . $item_rec["ref_id"]] =
3413 array("ref_id" => $item_rec["ref_id"],
3414 "obj_id" => $item_rec["obj_id"],
3415 "type" => $item_rec["type"],
3416 "title" => $title,
3417 "description" => $desc,
3418 "parent_ref" => $parent_ref);
3419 }
3420 }
3421 ksort($items);
3422 } else {
3423 // due to bug 11508
3424 if (!is_array($a_types)) {
3425 $a_types = array($a_types);
3426 }
3427 $items = array();
3428 $foundsurveys = array();
3429 foreach ($a_types as $a_type) {
3430 if ($a_type == "itgr") {
3431 continue;
3432 }
3433 $item_set = $ilDB->queryF(
3434 "SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref " .
3435 ", object_data obj WHERE " .
3436 "it.item_id = oref.ref_id AND " .
3437 "oref.obj_id = obj.obj_id AND " .
3438 "it.type = %s AND " .
3439 "it.user_id = %s " .
3440 "ORDER BY title",
3441 array("text", "integer"),
3442 array($a_type, $user_id)
3443 );
3444
3445 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
3446 $title = ilObject::_lookupTitle($item_rec["obj_id"]);
3447 $desc = ilObject::_lookupDescription($item_rec["obj_id"]);
3448 $items[$title . $a_type . $item_rec["ref_id"]] =
3449 array("ref_id" => $item_rec["ref_id"],
3450 "obj_id" => $item_rec["obj_id"], "type" => $a_type,
3451 "title" => $title, "description" => $desc);
3452 }
3453 }
3454 ksort($items);
3455 }
3456
3457 return $items;
3458 }
3459
3465
3473 public function addObjectToClipboard(
3474 $a_item_id,
3475 $a_type,
3476 $a_title,
3477 $a_parent = 0,
3478 $a_time = 0,
3479 $a_order_nr = 0
3480 ) {
3481 global $DIC;
3482
3483 $ilDB = $DIC['ilDB'];
3484
3485 if ($a_time == 0) {
3486 $a_time = date("Y-m-d H:i:s", time());
3487 }
3488
3489 $item_set = $ilDB->queryF(
3490 "SELECT * FROM personal_clipboard WHERE " .
3491 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3492 array("integer", "integer", "text", "integer"),
3493 array(0, $a_item_id, $a_type, $this->getId())
3494 );
3495
3496 // only insert if item is not already in clipboard
3497 if (!$d = $item_set->fetchRow()) {
3498 $ilDB->manipulateF(
3499 "INSERT INTO personal_clipboard " .
3500 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES " .
3501 " (%s,%s,%s,%s,%s,%s,%s)",
3502 array("integer", "text", "integer", "text", "integer", "timestamp", "integer"),
3503 array($a_item_id, $a_type, $this->getId(), $a_title, (int) $a_parent, $a_time, (int) $a_order_nr)
3504 );
3505 } else {
3506 $ilDB->manipulateF(
3507 "UPDATE personal_clipboard SET insert_time = %s " .
3508 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3509 array("timestamp", "integer", "integer", "text"),
3510 array($a_time, $this->getId(), $a_item_id, $a_type)
3511 );
3512 }
3513 }
3514
3518 public function addToPCClipboard($a_content, $a_time, $a_nr)
3519 {
3520 global $DIC;
3521
3522 $ilDB = $DIC['ilDB'];
3523 if ($a_time == 0) {
3524 $a_time = date("Y-m-d H:i:s", time());
3525 }
3526 $ilDB->insert("personal_pc_clipboard", array(
3527 "user_id" => array("integer", $this->getId()),
3528 "content" => array("clob", $a_content),
3529 "insert_time" => array("timestamp", $a_time),
3530 "order_nr" => array("integer", $a_nr)
3531 ));
3532 }
3533
3537 public function getPCClipboardContent()
3538 {
3539 global $DIC;
3540
3541 $ilDB = $DIC['ilDB'];
3542
3543 $set = $ilDB->queryF("SELECT MAX(insert_time) mtime FROM personal_pc_clipboard " .
3544 " WHERE user_id = %s", array("integer"), array($this->getId()));
3545 $row = $ilDB->fetchAssoc($set);
3546
3547 $set = $ilDB->queryF(
3548 "SELECT * FROM personal_pc_clipboard " .
3549 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3550 array("integer", "timestamp"),
3551 array($this->getId(), $row["mtime"])
3552 );
3553 $content = array();
3554 while ($row = $ilDB->fetchAssoc($set)) {
3555 $content[] = $row["content"];
3556 }
3557
3558 return $content;
3559 }
3560
3565 {
3566 global $DIC;
3567
3568 $ilDB = $DIC['ilDB'];
3569
3570 $set = $ilDB->queryF(
3571 "SELECT * FROM personal_clipboard WHERE " .
3572 "parent = %s AND type = %s AND user_id = %s",
3573 array("integer", "text", "integer"),
3574 array(0, $a_type, $this->getId())
3575 );
3576 if ($rec = $ilDB->fetchAssoc($set)) {
3577 return true;
3578 }
3579
3580 return false;
3581 }
3582
3587 {
3588 global $DIC;
3589
3590 $ilDB = $DIC['ilDB'];
3591
3592 $ilDB->manipulateF(
3593 "DELETE FROM personal_clipboard WHERE " .
3594 "type = %s AND user_id = %s",
3595 array("text", "integer"),
3596 array($a_type, $this->getId())
3597 );
3598 }
3599
3603 public function clipboardDeleteAll()
3604 {
3605 global $DIC;
3606
3607 $ilDB = $DIC['ilDB'];
3608
3609 $ilDB->manipulateF("DELETE FROM personal_clipboard WHERE " .
3610 "user_id = %s", array("integer"), array($this->getId()));
3611 }
3612
3616 public function getClipboardObjects($a_type = "", $a_top_nodes_only = false)
3617 {
3618 global $DIC;
3619
3620 $ilDB = $DIC['ilDB'];
3621
3622 $par = "";
3623 if ($a_top_nodes_only) {
3624 $par = " AND parent = " . $ilDB->quote(0, "integer") . " ";
3625 }
3626
3627 $type_str = ($a_type != "")
3628 ? " AND type = " . $ilDB->quote($a_type, "text") . " "
3629 : "";
3630 $q = "SELECT * FROM personal_clipboard WHERE " .
3631 "user_id = " . $ilDB->quote($this->getId(), "integer") . " " .
3632 $type_str . $par .
3633 " ORDER BY order_nr";
3634 $objs = $ilDB->query($q);
3635 $objects = array();
3636 while ($obj = $ilDB->fetchAssoc($objs)) {
3637 if ($obj["type"] == "mob") {
3638 $obj["title"] = ilObject::_lookupTitle($obj["item_id"]);
3639 }
3640 if ($obj["type"] == "incl") {
3641 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3642 $obj["title"] = ilMediaPoolPage::lookupTitle($obj["item_id"]);
3643 }
3644 $objects[] = array("id" => $obj["item_id"],
3645 "type" => $obj["type"], "title" => $obj["title"],
3646 "insert_time" => $obj["insert_time"]);
3647 }
3648 return $objects;
3649 }
3650
3654 public function getClipboardChilds($a_parent, $a_insert_time)
3655 {
3656 global $DIC;
3657
3658 $ilDB = $DIC['ilDB'];
3659 $ilUser = $DIC['ilUser'];
3660
3661 $objs = $ilDB->queryF(
3662 "SELECT * FROM personal_clipboard WHERE " .
3663 "user_id = %s AND parent = %s AND insert_time = %s " .
3664 " ORDER BY order_nr",
3665 array("integer", "integer", "timestamp"),
3666 array($ilUser->getId(), (int) $a_parent, $a_insert_time)
3667 );
3668 $objects = array();
3669 while ($obj = $ilDB->fetchAssoc($objs)) {
3670 if ($obj["type"] == "mob") {
3671 $obj["title"] = ilObject::_lookupTitle($obj["item_id"]);
3672 }
3673 $objects[] = array("id" => $obj["item_id"],
3674 "type" => $obj["type"], "title" => $obj["title"], "insert_time" => $obj["insert_time"]);
3675 }
3676 return $objects;
3677 }
3678
3687 public static function _getUsersForClipboadObject($a_type, $a_id)
3688 {
3689 global $DIC;
3690
3691 $ilDB = $DIC['ilDB'];
3692
3693 $q = "SELECT DISTINCT user_id FROM personal_clipboard WHERE " .
3694 "item_id = " . $ilDB->quote($a_id, "integer") . " AND " .
3695 "type = " . $ilDB->quote($a_type, "text");
3696 $user_set = $ilDB->query($q);
3697 $users = array();
3698 while ($user_rec = $ilDB->fetchAssoc($user_set)) {
3699 $users[] = $user_rec["user_id"];
3700 }
3701
3702 return $users;
3703 }
3704
3712 public function removeObjectFromClipboard($a_item_id, $a_type)
3713 {
3714 global $DIC;
3715
3716 $ilDB = $DIC['ilDB'];
3717
3718 $q = "DELETE FROM personal_clipboard WHERE " .
3719 "item_id = " . $ilDB->quote($a_item_id, "integer") .
3720 " AND type = " . $ilDB->quote($a_type, "text") . " " .
3721 " AND user_id = " . $ilDB->quote($this->getId(), "integer");
3722 $ilDB->manipulate($q);
3723 }
3724
3725 public static function _getImportedUserId($i2_id)
3726 {
3727 global $DIC;
3728
3729 $ilDB = $DIC['ilDB'];
3730
3731 $query = "SELECT obj_id FROM object_data WHERE import_id = " .
3732 $ilDB->quote($i2_id, "text");
3733
3734 $res = $ilDB->query($query);
3735 while ($row = $ilDB->fetchObject($res)) {
3736 $id = $row->obj_id;
3737 }
3738 return $id ? $id : 0;
3739 }
3740
3746 public static function lookupOrgUnitsRepresentation($a_usr_id)
3747 {
3748 require_once('./Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php');
3749 return ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_usr_id);
3750 }
3751
3752
3757 {
3759 }
3760
3761
3766 public function setAuthMode($a_str)
3767 {
3768 $this->auth_mode = $a_str;
3769 }
3770
3775 public function getAuthMode($a_auth_key = false)
3776 {
3777 if (!$a_auth_key) {
3778 return $this->auth_mode;
3779 }
3780
3781 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
3782 return ilAuthUtils::_getAuthMode($this->auth_mode);
3783 }
3784
3792 public function setExternalAccount($a_str)
3793 {
3794 $this->ext_account = $a_str;
3795 }
3796
3804 public function getExternalAccount()
3805 {
3806 return $this->ext_account;
3807 }
3808
3820 public static function _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default = false)
3821 {
3822 global $DIC;
3823
3824 $ilDB = $DIC['ilDB'];
3825 $ilSetting = $DIC['ilSetting'];
3826
3827 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
3828 $q = "SELECT login,usr_id,ext_account,auth_mode FROM usr_data " .
3829 "WHERE auth_mode = %s";
3830 $types[] = "text";
3831 $values[] = $a_auth_mode;
3832 if ($a_read_auth_default and ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode', AUTH_LOCAL)) == $a_auth_mode) {
3833 $q .= " OR auth_mode = %s ";
3834 $types[] = "text";
3835 $values[] = 'default';
3836 }
3837
3838 $res = $ilDB->queryF($q, $types, $values);
3839 while ($row = $ilDB->fetchObject($res)) {
3840 if ($row->auth_mode == 'default') {
3841 $accounts[$row->usr_id] = $row->login;
3842 } else {
3843 $accounts[$row->usr_id] = $row->ext_account;
3844 }
3845 }
3846 return $accounts ? $accounts : array();
3847 }
3848
3856 public static function _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
3857 {
3858 global $DIC;
3859
3860 $ilDB = $DIC['ilDB'];
3861
3862 if (!is_array($a_usr_ids)) {
3863 return false;
3864 }
3865
3866
3867 if ($a_status) {
3868 $q = "UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE " .
3869 $ilDB->in("usr_id", $a_usr_ids, false, "integer");
3870 $ilDB->manipulate($q);
3871 } else {
3872 $usrId_IN_usrIds = $ilDB->in("usr_id", $a_usr_ids, false, "integer");
3873
3874 $q = "UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds";
3875 $ilDB->manipulate($q);
3876
3877 $queryString = "
3878 UPDATE usr_data
3879 SET inactivation_date = %s
3880 WHERE inactivation_date IS NULL
3881 AND $usrId_IN_usrIds
3882 ";
3883 $ilDB->manipulateF($queryString, array('timestamp'), array(ilUtil::now()));
3884 }
3885
3886 return true;
3887 }
3888
3889
3898 public static function _lookupAuthMode($a_usr_id)
3899 {
3900 return (string) ilObjUser::_lookup($a_usr_id, "auth_mode");
3901 }
3902
3909 public static function _checkExternalAuthAccount($a_auth, $a_account, $tryFallback = true)
3910 {
3911 $db = $GLOBALS['DIC']->database();
3912 $settings = $GLOBALS['DIC']->settings();
3913
3914 // Check directly with auth_mode
3915 $r = $db->queryF(
3916 "SELECT * FROM usr_data WHERE " .
3917 " ext_account = %s AND auth_mode = %s",
3918 array("text", "text"),
3919 array($a_account, $a_auth)
3920 );
3921 if ($usr = $db->fetchAssoc($r)) {
3922 return $usr["login"];
3923 }
3924
3925 if (!$tryFallback) {
3926 return false;
3927 }
3928
3929 // For compatibility, check for login (no ext_account entry given)
3930 $res = $db->queryF(
3931 "SELECT login FROM usr_data " .
3932 "WHERE login = %s AND auth_mode = %s AND (ext_account IS NULL OR ext_account = '') ",
3933 array("text", "text"),
3934 array($a_account, $a_auth)
3935 );
3936 if ($usr = $db->fetchAssoc($res)) {
3937 return $usr['login'];
3938 }
3939
3940 // If auth_default == $a_auth => check for login
3941 if (ilAuthUtils::_getAuthModeName($settings->get('auth_mode')) == $a_auth) {
3942 $res = $db->queryF(
3943 "SELECT login FROM usr_data WHERE " .
3944 " ext_account = %s AND auth_mode = %s",
3945 array("text", "text"),
3946 array($a_account, "default")
3947 );
3948 if ($usr = $db->fetchAssoc($res)) {
3949 return $usr["login"];
3950 }
3951 // Search for login (no ext_account given)
3952 $res = $db->queryF(
3953 "SELECT login FROM usr_data " .
3954 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3955 array("text", "text"),
3956 array($a_account, "default")
3957 );
3958 if ($usr = $db->fetchAssoc($res)) {
3959 return $usr["login"];
3960 }
3961 }
3962 return false;
3963 }
3964
3968 public static function _getNumberOfUsersPerAuthMode()
3969 {
3970 global $DIC;
3971
3972 $ilDB = $DIC['ilDB'];
3973
3974 $r = $ilDB->query("SELECT count(*) AS cnt, auth_mode FROM usr_data " .
3975 "GROUP BY auth_mode");
3976 $cnt_arr = array();
3977 while ($cnt = $ilDB->fetchAssoc($r)) {
3978 $cnt_arr[$cnt["auth_mode"]] = $cnt["cnt"];
3979 }
3980
3981 return $cnt_arr;
3982 }
3983
3989 public static function _getLocalAccountsForEmail($a_email)
3990 {
3991 global $DIC;
3992
3993 $ilDB = $DIC['ilDB'];
3994 $ilSetting = $DIC['ilSetting'];
3995
3996 // default set to local (1)?
3997
3998 $q = "SELECT * FROM usr_data WHERE " .
3999 " email = %s AND (auth_mode = %s ";
4000 $types = array("text", "text");
4001 $values = array($a_email, "local");
4002
4003 if ($ilSetting->get("auth_mode") == 1) {
4004 $q .= " OR auth_mode = %s";
4005 $types[] = "text";
4006 $values[] = "default";
4007 }
4008
4009 $q .= ")";
4010
4011 $users = array();
4012 $usr_set = $ilDB->queryF($q, $types, $values);
4013 while ($usr_rec = $ilDB->fetchAssoc($usr_set)) {
4014 $users[$usr_rec["usr_id"]] = $usr_rec["login"];
4015 }
4016
4017 return $users;
4018 }
4019
4020
4028 public static function _uploadPersonalPicture($tmp_file, $obj_id)
4029 {
4030 $webspace_dir = ilUtil::getWebspaceDir();
4031 $image_dir = $webspace_dir . "/usr_images";
4032 $store_file = "usr_" . $obj_id . "." . "jpg";
4033 $target_file = $image_dir . "/$store_file";
4034
4035 chmod($tmp_file, 0770);
4036
4037 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
4038 // taking only frame [0] to avoid problems with animated gifs
4039 $show_file = "$image_dir/usr_" . $obj_id . ".jpg";
4040 $thumb_file = "$image_dir/usr_" . $obj_id . "_small.jpg";
4041 $xthumb_file = "$image_dir/usr_" . $obj_id . "_xsmall.jpg";
4042 $xxthumb_file = "$image_dir/usr_" . $obj_id . "_xxsmall.jpg";
4043
4044 ilUtil::execConvert($tmp_file . "[0] -geometry 200x200 -quality 100 JPEG:" . $show_file);
4045 ilUtil::execConvert($tmp_file . "[0] -geometry 100x100 -quality 100 JPEG:" . $thumb_file);
4046 ilUtil::execConvert($tmp_file . "[0] -geometry 75x75 -quality 100 JPEG:" . $xthumb_file);
4047 ilUtil::execConvert($tmp_file . "[0] -geometry 30x30 -quality 100 JPEG:" . $xxthumb_file);
4048
4049 // store filename
4050 self::_writePref($obj_id, "profile_image", $store_file);
4051
4052 return true;
4053 }
4054
4055
4064 public function getPersonalPicturePath($a_size = "small", $a_force_pic = false)
4065 {
4066 if (isset(self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic])) {
4067 return self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic];
4068 }
4069
4070 self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic] = ilObjUser::_getPersonalPicturePath($this->getId(), $a_size, $a_force_pic);
4071
4072 return self::$personal_image_cache[$this->getId()][$a_size][(int) $a_force_pic];
4073 }
4074
4084 public static function _getPersonalPicturePath(
4085 $a_usr_id,
4086 $a_size = "small",
4087 $a_force_pic = false,
4088 $a_prevent_no_photo_image = false
4089 ) {
4090 global $DIC;
4091
4092 $login = $firstname = $lastname = '';
4093 $upload = $profile = false;
4094
4095 $in = $DIC->database()->in('usr_pref.keyword', array('public_upload', 'public_profile'), false, 'text');
4096 $res = $DIC->database()->queryF(
4097 "
4098 SELECT usr_pref.*, ud.login, ud.firstname, ud.lastname
4099 FROM usr_data ud LEFT JOIN usr_pref ON usr_pref.usr_id = ud.usr_id AND $in
4100 WHERE ud.usr_id = %s",
4101 array("integer"),
4102 array($a_usr_id)
4103 );
4104 while ($row = $DIC->database()->fetchAssoc($res)) {
4105 $login = $row['login'];
4106 $firstname = $row['firstname'];
4107 $lastname = $row['lastname'];
4108
4109 switch ($row['keyword']) {
4110 case 'public_upload':
4111 $upload = $row['value'] == 'y';
4112 break;
4113 case 'public_profile':
4114 $profile = ($row['value'] == 'y' ||
4115 $row['value'] == 'g');
4116 break;
4117 }
4118 }
4119
4120 // END DiskQuota: Fetch all user preferences in a single query
4121 $webspace_dir = "";
4122 if (defined('ILIAS_MODULE')) {
4123 $webspace_dir = ('.' . $webspace_dir);
4124 }
4125 $webspace_dir .= ('./' . ltrim(ilUtil::getWebspaceDir(), "./"));
4126
4127 $image_dir = $webspace_dir . "/usr_images";
4128 // BEGIN DiskQuota: Support 'big' user images
4129 if ($a_size == 'big') {
4130 $thumb_file = $image_dir . "/usr_" . $a_usr_id . ".jpg";
4131 } else {
4132 $thumb_file = $image_dir . "/usr_" . $a_usr_id . "_" . $a_size . ".jpg";
4133 }
4134 // END DiskQuota: Support 'big' user images
4135
4136 $random = new \ilRandom();
4137 if ((($upload && $profile) || $a_force_pic)
4138 && @is_file($thumb_file)) {
4139 $file = $thumb_file . "?t=" . $random->int(1, 99999);
4140 } else {
4141 if (!$a_prevent_no_photo_image) {
4142 // we only have xsmall and xxsmall for this
4143 if ($a_size == "small" || $a_size == "big") {
4144 $a_size = "xsmall";
4145 }
4146
4147 if ($profile) {
4148 $short = ilStr::subStr($firstname, 0, 1) . ilStr::subStr($lastname, 0, 1);
4149 } else {
4150 $short = ilStr::subStr($login, 0, 2);
4151 }
4152
4154 $avatar = $DIC["user.avatar.factory"]->avatar($a_size);
4155 $avatar->setName($short);
4156 $avatar->setUsrId($a_usr_id);
4157
4158 return $avatar->getUrl();
4159 }
4160 }
4161
4162 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
4163 return ilWACSignedPath::signFile($file);
4164 }
4165
4172 public static function copyProfilePicturesToDirectory($a_user_id, $a_dir)
4173 {
4174 $a_dir = trim(str_replace("..", "", $a_dir));
4175 if ($a_dir == "" || !is_dir($a_dir)) {
4176 return;
4177 }
4178
4179 $webspace_dir = ilUtil::getWebspaceDir();
4180 $image_dir = $webspace_dir . "/usr_images";
4181 $images = array(
4182 "upload_" . $a_user_id . "pic",
4183 "usr_" . $a_user_id . "." . "jpg",
4184 "usr_" . $a_user_id . "_small.jpg",
4185 "usr_" . $a_user_id . "_xsmall.jpg",
4186 "usr_" . $a_user_id . "_xxsmall.jpg",
4187 "upload_" . $a_user_id);
4188 foreach ($images as $image) {
4189 if (is_file($image_dir . "/" . $image)) {
4190 copy($image_dir . "/" . $image, $a_dir . "/" . $image);
4191 }
4192 }
4193 }
4194
4195
4199 public function removeUserPicture($a_do_update = true)
4200 {
4201 $webspace_dir = ilUtil::getWebspaceDir();
4202 $image_dir = $webspace_dir . "/usr_images";
4203 $file = $image_dir . "/usr_" . $this->getID() . "." . "jpg";
4204 $thumb_file = $image_dir . "/usr_" . $this->getID() . "_small.jpg";
4205 $xthumb_file = $image_dir . "/usr_" . $this->getID() . "_xsmall.jpg";
4206 $xxthumb_file = $image_dir . "/usr_" . $this->getID() . "_xxsmall.jpg";
4207 $upload_file = $image_dir . "/upload_" . $this->getID();
4208
4209 if ($a_do_update) {
4210 // remove user pref file name
4211 $this->setPref("profile_image", "");
4212 $this->update();
4213 }
4214
4215 if (@is_file($file)) {
4216 unlink($file);
4217 }
4218 if (@is_file($thumb_file)) {
4219 unlink($thumb_file);
4220 }
4221 if (@is_file($xthumb_file)) {
4222 unlink($xthumb_file);
4223 }
4224 if (@is_file($xxthumb_file)) {
4225 unlink($xxthumb_file);
4226 }
4227 if (@is_file($upload_file)) {
4228 unlink($upload_file);
4229 }
4230 }
4231
4232
4233 public function setUserDefinedData($a_data)
4234 {
4235 if (!is_array($a_data)) {
4236 return false;
4237 }
4238 foreach ($a_data as $field => $data) {
4239 #$new_data[$field] = ilUtil::stripSlashes($data);
4240 // Assign it directly to avoid update problems of unchangable fields
4241 $this->user_defined_data['f_' . $field] = $data;
4242 }
4243 #$this->user_defined_data = $new_data;
4244
4245 return true;
4246 }
4247
4248 public function getUserDefinedData()
4249 {
4250 return $this->user_defined_data ? $this->user_defined_data : array();
4251 }
4252
4253 public function updateUserDefinedFields()
4254 {
4255 global $DIC;
4256
4257 $ilDB = $DIC['ilDB'];
4258
4259 $fields = '';
4260
4261 $field_def = array();
4262
4263 include_once("./Services/User/classes/class.ilUserDefinedData.php");
4264 $udata = new ilUserDefinedData($this->getId());
4265
4266 foreach ($this->user_defined_data as $field => $value) {
4267 if ($field != 'usr_id') {
4268 // $field_def[$field] = array('text',$value);
4269 $udata->set($field, $value);
4270 }
4271 }
4272 $udata->update();
4273
4274 /* if(!$field_def)
4275 {
4276 return true;
4277 }
4278
4279 $query = "SELECT usr_id FROM udf_data WHERE usr_id = ".$ilDB->quote($this->getId(),'integer');
4280 $res = $ilDB->query($query);
4281
4282
4283 if($res->numRows())
4284 {
4285 // Update
4286 $ilDB->update('udf_data',$field_def,array('usr_id' => array('integer',$this->getId())));
4287 }
4288 else
4289 {
4290 $field_def['usr_id'] = array('integer',$this->getId());
4291 $ilDB->insert('udf_data',$field_def);
4292 }
4293 */
4294 return true;
4295 }
4296
4297 public function readUserDefinedFields()
4298 {
4299 global $DIC;
4300
4301 $ilDB = $DIC['ilDB'];
4302
4303 include_once("./Services/User/classes/class.ilUserDefinedData.php");
4304 $udata = new ilUserDefinedData($this->getId());
4305
4306 /* $query = "SELECT * FROM udf_data ".
4307 "WHERE usr_id = ".$ilDB->quote($this->getId(),'integer');
4308
4309 $res = $this->db->query($query);
4310 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
4311 {
4312 $this->user_defined_data = $row;
4313 }*/
4314
4315 $this->user_defined_data = $udata->getAll();
4316
4317 return true;
4318 }
4319
4321 {
4322 global $DIC;
4323
4324 $ilDB = $DIC['ilDB'];
4325
4326 // not needed. no entry in udf_text/udf_clob means no value
4327
4328 /* $query = "INSERT INTO udf_data (usr_id ) ".
4329 "VALUES( ".
4330 $ilDB->quote($this->getId(),'integer').
4331 ")";
4332 $res = $ilDB->manipulate($query);
4333 */
4334 return true;
4335 }
4336
4338 {
4339 global $DIC;
4340
4341 $ilDB = $DIC['ilDB'];
4342
4343 include_once("./Services/User/classes/class.ilUserDefinedData.php");
4345
4346 // wrong place...
4347 /* $query = "DELETE FROM udf_data ".
4348 "WHERE usr_id = ".$ilDB->quote($this->getId(),'integer');
4349 $res = $ilDB->manipulate($query);*/
4350
4351 return true;
4352 }
4353
4359 public function getProfileAsString(&$a_language)
4360 {
4361 include_once './Services/AccessControl/classes/class.ilObjRole.php';
4362
4363 global $DIC;
4364
4365 $lng = $DIC['lng'];
4366 $rbacreview = $DIC['rbacreview'];
4367
4368 $language = &$a_language;
4369 $language->loadLanguageModule('registration');
4370 $language->loadLanguageModule('crs');
4371
4372 $body = '';
4373 $body .= ($language->txt("login") . ": " . $this->getLogin() . "\n");
4374
4375 if (strlen($this->getUTitle())) {
4376 $body .= ($language->txt("title") . ": " . $this->getUTitle() . "\n");
4377 }
4378 if (1 === strlen($this->getGender())) {
4379 $body .= ($language->txt("gender") . ": " . $language->txt('gender_' . strtolower($this->getGender())) . "\n");
4380 }
4381 if (strlen($this->getFirstname())) {
4382 $body .= ($language->txt("firstname") . ": " . $this->getFirstname() . "\n");
4383 }
4384 if (strlen($this->getLastname())) {
4385 $body .= ($language->txt("lastname") . ": " . $this->getLastname() . "\n");
4386 }
4387 if (strlen($this->getInstitution())) {
4388 $body .= ($language->txt("institution") . ": " . $this->getInstitution() . "\n");
4389 }
4390 if (strlen($this->getDepartment())) {
4391 $body .= ($language->txt("department") . ": " . $this->getDepartment() . "\n");
4392 }
4393 if (strlen($this->getStreet())) {
4394 $body .= ($language->txt("street") . ": " . $this->getStreet() . "\n");
4395 }
4396 if (strlen($this->getCity())) {
4397 $body .= ($language->txt("city") . ": " . $this->getCity() . "\n");
4398 }
4399 if (strlen($this->getZipcode())) {
4400 $body .= ($language->txt("zipcode") . ": " . $this->getZipcode() . "\n");
4401 }
4402 if (strlen($this->getCountry())) {
4403 $body .= ($language->txt("country") . ": " . $this->getCountry() . "\n");
4404 }
4405 if (strlen($this->getSelectedCountry())) {
4406 $body .= ($language->txt("sel_country") . ": " . $this->getSelectedCountry() . "\n");
4407 }
4408 if (strlen($this->getPhoneOffice())) {
4409 $body .= ($language->txt("phone_office") . ": " . $this->getPhoneOffice() . "\n");
4410 }
4411 if (strlen($this->getPhoneHome())) {
4412 $body .= ($language->txt("phone_home") . ": " . $this->getPhoneHome() . "\n");
4413 }
4414 if (strlen($this->getPhoneMobile())) {
4415 $body .= ($language->txt("phone_mobile") . ": " . $this->getPhoneMobile() . "\n");
4416 }
4417 if (strlen($this->getFax())) {
4418 $body .= ($language->txt("fax") . ": " . $this->getFax() . "\n");
4419 }
4420 if (strlen($this->getEmail())) {
4421 $body .= ($language->txt("email") . ": " . $this->getEmail() . "\n");
4422 }
4423 if (strlen($this->getSecondEmail())) {
4424 $body .= ($language->txt("second_email") . ": " . $this->getSecondEmail() . "\n");
4425 }
4426 if (strlen($this->getHobby())) {
4427 $body .= ($language->txt("hobby") . ": " . $this->getHobby() . "\n");
4428 }
4429 if (strlen($this->getComment())) {
4430 $body .= ($language->txt("referral_comment") . ": " . $this->getComment() . "\n");
4431 }
4432 if (strlen($this->getMatriculation())) {
4433 $body .= ($language->txt("matriculation") . ": " . $this->getMatriculation() . "\n");
4434 }
4435 if (strlen($this->getCreateDate())) {
4440
4441 $body .= ($language->txt("create_date") . ": " . $date . "\n");
4442 }
4443
4444 foreach ($rbacreview->getGlobalRoles() as $role) {
4445 if ($rbacreview->isAssigned($this->getId(), $role)) {
4446 $gr[] = ilObjRole::_lookupTitle($role);
4447 }
4448 }
4449 if (count($gr)) {
4450 $body .= ($language->txt('reg_role_info') . ': ' . implode(',', $gr) . "\n");
4451 }
4452
4453 // Time limit
4454 if ($this->getTimeLimitUnlimited()) {
4455 $body .= ($language->txt('time_limit') . ": " . $language->txt('crs_unlimited') . "\n");
4456 } else {
4462 );
4464
4467
4468 $body .= $language->txt('time_limit') . ': ' . $start->get(IL_CAL_DATETIME);
4469 $body .= $language->txt('time_limit') . ': ' . $end->get(IL_CAL_DATETIME);
4470 }
4471
4472 include_once './Services/User/classes/class.ilUserDefinedFields.php';
4476 $user_defined_fields = ilUserDefinedFields::_getInstance();
4478
4479 foreach ($user_defined_fields->getDefinitions() as $field_id => $definition) {
4480 $data = $user_defined_data["f_" . $field_id];
4481 if (strlen($data)) {
4482 if ($definition['field_type'] == UDF_TYPE_WYSIWYG) {
4483 $data = preg_replace('/<br(\s*)?\/?>/i', "\n", $data);
4484 $data = strip_tags($data);
4485 }
4486
4487 $body .= $definition['field_name'] . ': ' . $data . "\n";
4488 }
4489 }
4490
4491 return $body;
4492 }
4493
4497 public static function _lookupFeedHash($a_user_id, $a_create = false)
4498 {
4499 global $DIC;
4500
4501 $ilDB = $DIC['ilDB'];
4502
4503 if ($a_user_id > 0) {
4504 $set = $ilDB->queryF(
4505 "SELECT feed_hash from usr_data WHERE usr_id = %s",
4506 array("integer"),
4507 array($a_user_id)
4508 );
4509 if ($rec = $ilDB->fetchAssoc($set)) {
4510 if (strlen($rec["feed_hash"]) == 32) {
4511 return $rec["feed_hash"];
4512 } elseif ($a_create) {
4513 $random = new \ilRandom();
4514 $hash = md5($random->int(1, 9999999) + str_replace(" ", "", (string) microtime()));
4515 $ilDB->manipulateF(
4516 "UPDATE usr_data SET feed_hash = %s" .
4517 " WHERE usr_id = %s",
4518 array("text", "integer"),
4519 array($hash, $a_user_id)
4520 );
4521 return $hash;
4522 }
4523 }
4524 }
4525
4526 return false;
4527 }
4528
4534 public static function _getFeedPass($a_user_id)
4535 {
4536 global $DIC;
4537
4538 $ilDB = $DIC['ilDB'];
4539
4540 if ($a_user_id > 0) {
4541 return ilObjUser::_lookupPref($a_user_id, "priv_feed_pass");
4542 }
4543 return false;
4544 }
4545
4551 public static function _setFeedPass($a_user_id, $a_password)
4552 {
4553 global $DIC;
4554
4555 $ilDB = $DIC['ilDB'];
4556
4558 $a_user_id,
4559 "priv_feed_pass",
4560 ($a_password == "") ? "" : md5($a_password)
4561 );
4562 }
4563
4573 public static function _loginExists($a_login, $a_user_id = 0)
4574 {
4575 global $DIC;
4576
4577 $ilDB = $DIC['ilDB'];
4578
4579 $q = "SELECT DISTINCT login, usr_id FROM usr_data " .
4580 "WHERE login = %s";
4581 $types[] = "text";
4582 $values[] = $a_login;
4583
4584 if ($a_user_id != 0) {
4585 $q .= " AND usr_id != %s ";
4586 $types[] = "integer";
4587 $values[] = $a_user_id;
4588 }
4589
4590 $r = $ilDB->queryF($q, $types, $values);
4591
4592 if ($row = $ilDB->fetchAssoc($r)) {
4593 return $row['usr_id'];
4594 }
4595 return false;
4596 }
4597
4608 public static function _externalAccountExists($a_external_account, $a_auth_mode)
4609 {
4610 global $DIC;
4611
4612 $ilDB = $DIC['ilDB'];
4613
4614 $res = $ilDB->queryF(
4615 "SELECT * FROM usr_data " .
4616 "WHERE ext_account = %s AND auth_mode = %s",
4617 array("text", "text"),
4618 array($a_external_account, $a_auth_mode)
4619 );
4620 return $ilDB->fetchAssoc($res) ? true :false;
4621 }
4622
4630 public static function _getUsersForRole($role_id, $active = -1)
4631 {
4632 global $DIC;
4633
4634 $ilDB = $DIC['ilDB'];
4635 $rbacreview = $DIC['rbacreview'];
4636 $data = array();
4637
4638 $ids = $rbacreview->assignedUsers($role_id);
4639
4640 if (count($ids) == 0) {
4641 $ids = array(-1);
4642 }
4643
4644 $query = "SELECT usr_data.*, usr_pref.value AS language
4645 FROM usr_data
4646 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4647 WHERE " . $ilDB->in("usr_data.usr_id", $ids, false, "integer");
4648 $values[] = "language";
4649 $types[] = "text";
4650
4651
4652 if (is_numeric($active) && $active > -1) {
4653 $query .= " AND usr_data.active = %s";
4654 $values[] = $active;
4655 $types[] = "integer";
4656 }
4657
4658 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
4659
4660 $r = $ilDB->queryF($query, $types, $values);
4661 $data = array();
4662 while ($row = $ilDB->fetchAssoc($r)) {
4663 $data[] = $row;
4664 }
4665 return $data;
4666 }
4667
4668
4674 public static function _getUsersForFolder($ref_id, $active)
4675 {
4676 global $DIC;
4677
4678 $ilDB = $DIC['ilDB'];
4679 $data = array();
4680 $query = "SELECT usr_data.*, usr_pref.value AS language FROM usr_data LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id and usr_pref.keyword = %s WHERE 1 = 1 ";
4681 $types[] = "text";
4682 $values[] = "language";
4683
4684 if (is_numeric($active) && $active > -1) {
4685 $query .= " AND usr_data.active = %s";
4686 $values[] = $active;
4687 $types[] = "integer";
4688 }
4689
4690 if ($ref_id != USER_FOLDER_ID) {
4691 $query .= " AND usr_data.time_limit_owner = %s";
4692 $values[] = $ref_id;
4693 $types[] = "integer";
4694 }
4695
4696 $query .= " AND usr_data.usr_id != %s ";
4697 $values[] = ANONYMOUS_USER_ID;
4698 $types[] = "integer";
4699
4700 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
4701
4702 $result = $ilDB->queryF($query, $types, $values);
4703 $data = array();
4704 while ($row = $ilDB->fetchAssoc($result)) {
4705 array_push($data, $row);
4706 }
4707
4708 return $data;
4709 }
4710
4711
4717 public static function _getUsersForGroup($a_mem_ids, $active = -1)
4718 {
4719 return ilObjUser::_getUsersForIds($a_mem_ids, $active);
4720 }
4721
4722
4728 public static function _getUsersForIds($a_mem_ids, $active = -1, $timelimitowner = -1)
4729 {
4730 global $DIC;
4731
4732 $rbacadmin = $DIC['rbacadmin'];
4733 $rbacreview = $DIC['rbacreview'];
4734 $ilDB = $DIC['ilDB'];
4735
4736 $query = "SELECT usr_data.*, usr_pref.value AS language
4737 FROM usr_data
4738 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4739 WHERE " . $ilDB->in("usr_data.usr_id", $a_mem_ids, false, "integer") . "
4740 AND usr_data.usr_id != %s";
4741 $values[] = "language";
4742 $types[] = "text";
4743 $values[] = ANONYMOUS_USER_ID;
4744 $types[] = "integer";
4745
4746 if (is_numeric($active) && $active > -1) {
4747 $query .= " AND active = %s";
4748 $values[] = $active;
4749 $types[] = "integer";
4750 }
4751
4752 if ($timelimitowner != USER_FOLDER_ID && $timelimitowner != -1) {
4753 $query .= " AND usr_data.time_limit_owner = %s";
4754 $values[] = $timelimitowner;
4755 $types[] = "integer";
4756 }
4757
4758 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
4759
4760 $result = $ilDB->queryF($query, $types, $values);
4761 while ($row = $ilDB->fetchAssoc($result)) {
4762 $mem_arr[] = $row;
4763 }
4764
4765 return $mem_arr ? $mem_arr : array();
4766 }
4767
4768
4769
4775 public static function _getUserData($a_internalids)
4776 {
4777 global $DIC;
4778
4779 $ilDB = $DIC['ilDB'];
4780
4781 $ids = array();
4782 if (is_array($a_internalids)) {
4783 foreach ($a_internalids as $internalid) {
4784 if (is_numeric($internalid)) {
4785 $ids[] = $internalid;
4786 } else {
4787 $parsedid = ilUtil::__extractId($internalid, IL_INST_ID);
4788 if (is_numeric($parsedid) && $parsedid > 0) {
4789 $ids[] = $parsedid;
4790 }
4791 }
4792 }
4793 }
4794 if (count($ids) == 0) {
4795 $ids [] = -1;
4796 }
4797
4798 $query = "SELECT usr_data.*, usr_pref.value AS language
4799 FROM usr_data
4800 LEFT JOIN usr_pref
4801 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4802 WHERE " . $ilDB->in("usr_data.usr_id", $ids, false, "integer");
4803 $values[] = "language";
4804 $types[] = "text";
4805
4806 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
4807
4808 $data = array();
4809 $result = $ilDB->queryF($query, $types, $values);
4810 while ($row = $ilDB->fetchAssoc($result)) {
4811 $data[] = $row;
4812 }
4813 return $data;
4814 }
4815
4822 public static function _getPreferences($user_id)
4823 {
4824 global $DIC;
4825
4826 $ilDB = $DIC['ilDB'];
4827
4828 $prefs = array();
4829
4830 $r = $ilDB->queryF(
4831 "SELECT * FROM usr_pref WHERE usr_id = %s",
4832 array("integer"),
4833 array($user_id)
4834 );
4835
4836 while ($row = $ilDB->fetchAssoc($r)) {
4837 $prefs[$row["keyword"]] = $row["value"];
4838 }
4839
4840 return $prefs;
4841 }
4842
4852 public static function getUserSubsetByPreferenceValue($a_user_ids, $a_keyword, $a_val)
4853 {
4854 global $DIC;
4855
4856 $ilDB = $DIC['ilDB'];
4857
4858 $users = array();
4859 $set = $ilDB->query(
4860 "SELECT usr_id FROM usr_pref " .
4861 " WHERE keyword = " . $ilDB->quote($a_keyword, "text") .
4862 " AND " . $ilDB->in("usr_id", $a_user_ids, false, "integer") .
4863 " AND value = " . $ilDB->quote($a_val, "text")
4864 );
4865 while ($rec = $ilDB->fetchAssoc($set)) {
4866 $users[] = $rec["usr_id"];
4867 }
4868 return $users;
4869 }
4870
4871
4872 public static function _resetLoginAttempts($a_usr_id)
4873 {
4874 global $DIC;
4875
4876 $ilDB = $DIC['ilDB'];
4877
4878 $query = "UPDATE usr_data SET login_attempts = 0 WHERE usr_id = %s";
4879 $affected = $ilDB->manipulateF($query, array('integer'), array($a_usr_id));
4880
4881 if ($affected) {
4882 return true;
4883 } else {
4884 return false;
4885 }
4886 }
4887
4888 public static function _getLoginAttempts($a_usr_id)
4889 {
4890 global $DIC;
4891
4892 $ilDB = $DIC['ilDB'];
4893
4894 $query = "SELECT login_attempts FROM usr_data WHERE usr_id = %s";
4895 $result = $ilDB->queryF($query, array('integer'), array($a_usr_id));
4896 $record = $ilDB->fetchAssoc($result);
4897 $login_attempts = $record['login_attempts'];
4898
4899 return $login_attempts;
4900 }
4901
4902 public static function _incrementLoginAttempts($a_usr_id)
4903 {
4904 global $DIC;
4905
4906 $ilDB = $DIC['ilDB'];
4907
4908 $query = "UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s";
4909 $affected = $ilDB->manipulateF($query, array('integer'), array($a_usr_id));
4910
4911 if ($affected) {
4912 return true;
4913 } else {
4914 return false;
4915 }
4916 }
4917
4918 public static function _setUserInactive($a_usr_id)
4919 {
4920 global $DIC;
4921
4922 $ilDB = $DIC['ilDB'];
4923
4924 $query = "UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s";
4925 $affected = $ilDB->manipulateF($query, array('timestamp', 'integer'), array(ilUtil::now(), $a_usr_id));
4926
4927 if ($affected) {
4928 return true;
4929 } else {
4930 return false;
4931 }
4932 }
4933
4939 public function hasPublicProfile()
4940 {
4941 return in_array($this->getPref("public_profile"), array("y", "g"));
4942 }
4943
4949 public function getPublicName()
4950 {
4951 if ($this->hasPublicProfile()) {
4952 return $this->getFirstname() . " " . $this->getLastname() . " (" . $this->getLogin() . ")";
4953 } else {
4954 return $this->getLogin();
4955 }
4956 }
4957
4958 public static function _writeHistory($a_usr_id, $a_login)
4959 {
4960 global $DIC;
4961
4962 $ilDB = $DIC['ilDB'];
4963
4964 $timestamp = time();
4965
4966 $res = $ilDB->queryF(
4967 'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4968 array('integer', 'text', 'integer'),
4969 array($a_usr_id, $a_login, $timestamp)
4970 );
4971
4972 if ($ilDB->numRows($res) == 0) {
4973 $ilDB->manipulateF(
4974 '
4975 INSERT INTO loginname_history
4976 (usr_id, login, history_date)
4977 VALUES (%s, %s, %s)',
4978 array('integer', 'text', 'integer'),
4979 array($a_usr_id, $a_login, $timestamp)
4980 );
4981 }
4982
4983 return true;
4984 }
4985
4993 public static function _getUsersOnline($a_user_id = 0, $a_no_anonymous = false)
4994 {
4998 global $DIC;
4999
5000 $ilDB = $DIC->database();
5001 $rbacreview = $DIC->rbac()->review();
5002
5004
5005 $pd_set = new ilSetting('pd');
5006 $atime = $pd_set->get('user_activity_time') * 60;
5007 $ctime = time();
5008
5009 $where = array();
5010
5011 if ($a_user_id == 0) {
5012 $where[] = 'user_id > 0';
5013 } elseif (is_array($a_user_id)) {
5014 $where[] = $ilDB->in("user_id", $a_user_id, false, "integer");
5015 } else {
5016 $where[] = 'user_id = ' . $ilDB->quote($a_user_id, 'integer');
5017 }
5018
5019 if ($a_no_anonymous) {
5020 $where[] = 'user_id != ' . $ilDB->quote(ANONYMOUS_USER_ID, 'integer');
5021 }
5022
5023 include_once 'Services/User/classes/class.ilUserAccountSettings.php';
5024 if (ilUserAccountSettings::getInstance()->isUserAccessRestricted()) {
5025 include_once 'Services/User/classes/class.ilUserFilter.php';
5026 $where[] = $ilDB->in('time_limit_owner', ilUserFilter::getInstance()->getFolderIds(), false, 'integer');
5027 }
5028
5029 $where[] = 'expires > ' . $ilDB->quote($ctime, 'integer');
5030 $where[] = '(p.value IS NULL OR NOT p.value = ' . $ilDB->quote('y', 'text') . ')';
5031
5032 $where = 'WHERE ' . implode(' AND ', $where);
5033
5034 $r = $ilDB->queryF(
5035 $q = "
5036 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime, context, agree_date
5037 FROM usr_session
5038 LEFT JOIN usr_data u
5039 ON user_id = u.usr_id
5040 LEFT JOIN usr_pref p
5041 ON (p.usr_id = u.usr_id AND p.keyword = %s)
5042 {$where}
5043 GROUP BY user_id, firstname, lastname, title, login, last_login, context, agree_date
5044 ORDER BY lastname, firstname
5045 ",
5046 array('text'),
5047 array('hide_own_online_status')
5048 );
5049
5050 $log->debug("Query: " . $q);
5051
5052 $users = array();
5053 while ($user = $ilDB->fetchAssoc($r)) {
5054 if ($atime <= 0 || $user['ctime'] + $atime > $ctime) {
5055 $users[$user['user_id']] = $user;
5056 }
5057 }
5058
5059 $log->debug("Found users: " . count($users));
5060
5061 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5063 $users = array_filter($users, function ($user) {
5064 if ($user['agree_date'] || $user['user_id'] == SYSTEM_USER_ID || 'root' === $user['login']) {
5065 return true;
5066 }
5067
5068 return false;
5069 });
5070
5071 $log->debug("TOS filtered to users: " . count($users));
5072 }
5073
5074 return $users;
5075 }
5076
5083 public static function _generateRegistrationHash($a_usr_id)
5084 {
5085 global $DIC;
5086
5087 $ilDB = $DIC['ilDB'];
5088
5089 do {
5090 $continue = false;
5091
5092 $random = new \ilRandom();
5093 $hashcode = substr(md5(uniqid($random->int(), true)), 0, 16);
5094
5095 $res = $ilDB->queryf(
5096 '
5097 SELECT COUNT(usr_id) cnt FROM usr_data
5098 WHERE reg_hash = %s',
5099 array('text'),
5100 array($hashcode)
5101 );
5102 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
5103 if ($row->cnt > 0) {
5104 $continue = true;
5105 }
5106 break;
5107 }
5108
5109 if ($continue) {
5110 continue;
5111 }
5112
5113 $ilDB->manipulateF(
5114 '
5115 UPDATE usr_data
5116 SET reg_hash = %s
5117 WHERE usr_id = %s',
5118 array('text', 'integer'),
5119 array($hashcode, (int) $a_usr_id)
5120 );
5121
5122 break;
5123 } while (true);
5124
5125 return $hashcode;
5126 }
5127
5136 public static function _verifyRegistrationHash($a_hash)
5137 {
5138 global $DIC;
5139
5140 $ilDB = $DIC['ilDB'];
5141
5142 $res = $ilDB->queryf(
5143 '
5144 SELECT usr_id, create_date FROM usr_data
5145 WHERE reg_hash = %s',
5146 array('text'),
5147 array($a_hash)
5148 );
5149 while ($row = $ilDB->fetchAssoc($res)) {
5150 require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
5151 $oRegSettigs = new ilRegistrationSettings();
5152
5153 if ((int) $oRegSettigs->getRegistrationHashLifetime() != 0 &&
5154 time() - (int) $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
5155 require_once 'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
5156 throw new ilRegConfirmationLinkExpiredException('reg_confirmation_hash_life_time_expired', $row['usr_id']);
5157 }
5158
5159 $ilDB->manipulateF(
5160 '
5161 UPDATE usr_data
5162 SET reg_hash = %s
5163 WHERE usr_id = %s',
5164 array('text', 'integer'),
5165 array('', (int) $row['usr_id'])
5166 );
5167
5168 return (int) $row['usr_id'];
5169 }
5170
5171 require_once 'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
5172 throw new ilRegistrationHashNotFoundException('reg_confirmation_hash_not_found');
5173 }
5174
5175 public function setBirthday($a_birthday)
5176 {
5177 if (strlen($a_birthday)) {
5178 $date = new ilDate($a_birthday, IL_CAL_DATE);
5179 $this->birthday = $date->get(IL_CAL_DATE);
5180 } else {
5181 $this->birthday = null;
5182 }
5183 }
5184
5185 public function getBirthday()
5186 {
5187 return $this->birthday;
5188 }
5189
5198 public static function _getUserIdsByInactivityPeriod($period)
5199 {
5200 if (!(int) $period) {
5201 throw new ilException('no valid period given');
5202 }
5203
5204 global $DIC;
5205
5206 $ilDB = $DIC['ilDB'];
5207
5208 $date = date('Y-m-d H:i:s', (time() - ((int) $period * 24 * 60 * 60)));
5209
5210 $query = "SELECT usr_id FROM usr_data WHERE last_login < %s OR (ISNULL(last_login) AND create_date < %s)";
5211
5212 $res = $ilDB->queryF($query, array('timestamp', 'timestamp'), array($date, $date));
5213
5214 $ids = array();
5215 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
5216 $ids[] = $row->usr_id;
5217 }
5218
5219 return $ids;
5220 }
5221
5230 public static function _getUserIdsByInactivationPeriod($period)
5231 {
5233 $field = 'inactivation_date';
5235
5236 if (!(int) $period) {
5237 throw new ilException('no valid period given');
5238 }
5239
5240 global $DIC;
5241
5242 $ilDB = $DIC['ilDB'];
5243
5244 $date = date('Y-m-d H:i:s', (time() - ((int) $period * 24 * 60 * 60)));
5245
5246 $query = "SELECT usr_id FROM usr_data WHERE $field < %s AND active = %s";
5247
5248 $res = $ilDB->queryF($query, array('timestamp', 'integer'), array($date, 0));
5249
5250 $ids = array();
5251 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
5252 $ids[] = $row->usr_id;
5253 }
5254
5255 return $ids;
5256 }
5257
5267 public static function _updateLastLogin($a_usr_id, $a_last_login = null)
5268 {
5269 if ($a_last_login !== null) {
5270 $last_login = $a_last_login;
5271 } else {
5272 $last_login = date('Y-m-d H:i:s');
5273 }
5274
5275 global $DIC;
5276
5277 $ilDB = $DIC['ilDB'];
5278
5279 $query = "UPDATE usr_data SET last_login = %s WHERE usr_id = %s";
5280 $affected = $ilDB->manipulateF($query, array('timestamp', 'integer'), array($last_login, $a_usr_id));
5281
5282 $query = "UPDATE usr_data SET first_login = %s WHERE usr_id = %s AND first_login IS NULL";
5283 $ilDB->manipulateF($query, array('timestamp', 'integer'), array($last_login, $a_usr_id));
5284
5285
5286 if ($affected) {
5287 return $last_login;
5288 } else {
5289 return false;
5290 }
5291 }
5292
5293 public function resetOwner()
5294 {
5295 global $DIC;
5296
5297 $ilDB = $DIC['ilDB'];
5298
5299 $query = "UPDATE object_data SET owner = 0 " .
5300 "WHERE owner = " . $ilDB->quote($this->getId(), 'integer');
5301 $ilDB->query($query);
5302
5303 return true;
5304 }
5305
5306
5313 public static function getFirstLettersOfLastnames()
5314 {
5315 global $DIC;
5316
5317 $ilDB = $DIC['ilDB'];
5318
5319 $q = "SELECT DISTINCT " . $ilDB->upper($ilDB->substr("lastname", 1, 1)) . " let" .
5320 " FROM usr_data" .
5321 " WHERE usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer") .
5322 " ORDER BY let";
5323 $let_set = $ilDB->query($q);
5324
5325 $lets = array();
5326 while ($let_rec = $ilDB->fetchAssoc($let_set)) {
5327 $let[$let_rec["let"]] = $let_rec["let"];
5328 }
5329 return $let;
5330 }
5331
5332 // begin-patch deleteProgress
5333 public static function userExists($a_usr_ids = array())
5334 {
5335 global $DIC;
5336
5337 $ilDB = $DIC['ilDB'];
5338
5339 $query = 'SELECT count(*) num FROM object_data od ' .
5340 'JOIN usr_data ud ON obj_id = usr_id ' .
5341 'WHERE ' . $ilDB->in('obj_id', $a_usr_ids, false, 'integer') . ' ';
5342 $res = $ilDB->query($query);
5343 $num_rows = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)->num;
5344 return $num_rows == count((array) $a_usr_ids);
5345 }
5346 // end-patch deleteProgress
5347
5351 public function isCaptchaVerified()
5352 {
5353 return (boolean) $_SESSION["user_captcha_verified"];
5354 }
5355
5361 public function setCaptchaVerified($a_val)
5362 {
5363 $_SESSION["user_captcha_verified"] = $a_val;
5364 }
5365
5372 public function exportPersonalData()
5373 {
5374 include_once("./Services/Export/classes/class.ilExport.php");
5375 $exp = new ilExport();
5376 $dir = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data");
5377 ilUtil::delDir($dir, true);
5378 $title = $this->getLastname() . ", " . $this->getLastname() . " [" . $this->getLogin() . "]";
5379 $exp->exportEntity(
5380 "personal_data",
5381 $this->getId(),
5382 "",
5383 "Services/User",
5384 $title,
5385 $dir
5386 );
5387 }
5388
5396 {
5397 include_once("./Services/Export/classes/class.ilExport.php");
5398 $dir = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data");
5399 if (!is_dir($dir)) {
5400 return "";
5401 }
5402 foreach (ilUtil::getDir($dir) as $entry) {
5403 if (is_int(strpos($entry["entry"], ".zip"))) {
5404 return $entry["entry"];
5405 }
5406 }
5407
5408 return "";
5409 }
5410
5417 public function sendPersonalDataFile()
5418 {
5419 include_once("./Services/Export/classes/class.ilExport.php");
5420 $file = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data") .
5421 "/" . $this->getPersonalDataExportFile();
5422 if (is_file($file)) {
5424 }
5425 }
5426
5433 public function importPersonalData(
5434 $a_file,
5435 $a_profile_data,
5436 $a_settings,
5437 $a_bookmarks,
5438 $a_notes,
5439 $a_calendar
5440 ) {
5441 include_once("./Services/Export/classes/class.ilImport.php");
5442 $imp = new ilImport();
5443 if (!$a_profile_data) {
5444 $imp->addSkipEntity("Services/User", "usr_profile");
5445 }
5446 if (!$a_settings) {
5447 $imp->addSkipEntity("Services/User", "usr_setting");
5448 }
5449 if (!$a_bookmarks) {
5450 $imp->addSkipEntity("Services/Bookmarks", "bookmarks");
5451 }
5452 if (!$a_notes) {
5453 $imp->addSkipEntity("Services/Notes", "user_notes");
5454 }
5455 if (!$a_calendar) {
5456 $imp->addSkipEntity("Services/Calendar", "calendar");
5457 }
5458 $imp->importEntity(
5459 $a_file["tmp_name"],
5460 $a_file["name"],
5461 "personal_data",
5462 "Services/User"
5463 );
5464 }
5465
5471 private static function initInactivationDate($usrIds)
5472 {
5473 global $DIC;
5474
5475 $ilDB = $DIC['ilDB'];
5476
5477 $NOW = $ilDB->now();
5478
5479 $usrId_IN_usrIds = $ilDB->in('usr_id', $usrIds, false, 'integer');
5480
5481 $queryString = "
5482 UPDATE usr_data
5483 SET inactivation_date = $NOW
5484 WHERE inactivation_date IS NULL
5485 AND $usrId_IN_usrIds
5486 ";
5487
5488 $ilDB->manipulate($queryString);
5489 }
5490
5496 private static function resetInactivationDate($usrIds)
5497 {
5498 global $DIC;
5499
5500 $ilDB = $DIC['ilDB'];
5501
5502 $usrId_IN_usrIds = $ilDB->in('usr_id', $usrIds, false, 'integer');
5503
5504 $queryString = "
5505 UPDATE usr_data
5506 SET inactivation_date = NULL
5507 WHERE $usrId_IN_usrIds
5508 ";
5509
5510 $ilDB->manipulate($queryString);
5511 }
5512
5519 {
5520 $this->inactivation_date = $inactivation_date;
5521 }
5522
5528 public function getInactivationDate()
5529 {
5531 }
5532
5537 {
5538 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5539
5540 if (
5542 null == $this->agree_date &&
5543 'root' != $this->login &&
5544 !in_array($this->getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID))
5545 ) {
5546 return true;
5547 }
5548
5549 return false;
5550 }
5551
5556 public static function hasUserToAcceptTermsOfService($a_username)
5557 {
5561 global $DIC;
5562
5563 $ilDB = $DIC['ilDB'];
5564
5565 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5566
5568 return false;
5569 }
5570
5571 $in = $ilDB->in('usr_id', array(ANONYMOUS_USER_ID, SYSTEM_USER_ID), true, 'integer');
5572 $res = $ilDB->queryF(
5573 "SELECT usr_id FROM usr_data WHERE login = %s AND agree_date IS NULL $in",
5574 array("text"),
5575 array($a_username)
5576 );
5577 return $ilDB->fetchAssoc($res) ? true : false;
5578 }
5579
5587 public static function getUsersAgreed($a_agreed = true, $a_users = null)
5588 {
5589 global $DIC;
5590
5591 $ilDB = $DIC['ilDB'];
5592
5593 $date_is = ($a_agreed)
5594 ? "IS NOT NULL"
5595 : "IS NULL";
5596
5597 $users = (is_array($a_users))
5598 ? " AND " . $ilDB->in("usr_id", $a_users, false, "integer")
5599 : "";
5600
5601 $set = $ilDB->query("SELECT usr_id FROM usr_data " .
5602 " WHERE agree_date " . $date_is .
5603 $users);
5604 $ret = array();
5605 while ($rec = $ilDB->fetchAssoc($set)) {
5606 $ret[] = $rec["usr_id"];
5607 }
5608 return $ret;
5609 }
5610
5611
5616 public function hasToAcceptTermsOfServiceInSession($status = null)
5617 {
5618 if (null === $status) {
5619 return ilSession::get('has_to_accept_agr_in_session');
5620 }
5621
5622 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5624 ilSession::set('has_to_accept_agr_in_session', (int) $status);
5625 }
5626 }
5627
5631 public function isAnonymous()
5632 {
5633 return self::_isAnonymous($this->getId());
5634 }
5635
5640 public static function _isAnonymous($usr_id)
5641 {
5642 return $usr_id == ANONYMOUS_USER_ID;
5643 }
5644
5645 public function activateDeletionFlag()
5646 {
5647 $this->writePref("delete_flag", true);
5648 }
5649
5650 public function removeDeletionFlag()
5651 {
5652 $this->writePref("delete_flag", false);
5653 }
5654
5655 public function hasDeletionFlag()
5656 {
5657 return (bool) $this->getPref("delete_flag");
5658 }
5659
5663 public function setIsSelfRegistered($status)
5664 {
5665 $this->is_self_registered = (bool) $status;
5666 }
5667
5668 public function isSelfRegistered()
5669 {
5670 return (bool) $this->is_self_registered;
5671 }
5672
5673
5674 //
5675 // MULTI-TEXT / INTERESTS
5676 //
5677
5683 public function setGeneralInterests(array $value = null)
5684 {
5685 $this->interests_general = $value;
5686 }
5687
5693 public function getGeneralInterests()
5694 {
5696 }
5697
5704 {
5705 return $this->buildTextFromArray("interests_general");
5706 }
5707
5713 public function setOfferingHelp(array $value = null)
5714 {
5715 $this->interests_help_offered = $value;
5716 }
5717
5723 public function getOfferingHelp()
5724 {
5726 }
5727
5733 public function getOfferingHelpAsText()
5734 {
5735 return $this->buildTextFromArray("interests_help_offered");
5736 }
5737
5743 public function setLookingForHelp(array $value = null)
5744 {
5745 $this->interests_help_looking = $value;
5746 }
5747
5753 public function getLookingForHelp()
5754 {
5756 }
5757
5763 public function getLookingForHelpAsText()
5764 {
5765 return $this->buildTextFromArray("interests_help_looking");
5766 }
5767
5774 protected function buildTextFromArray($a_attr)
5775 {
5776 $current = $this->$a_attr;
5777 if (is_array($current) && sizeof($current)) {
5778 return implode(", ", $current);
5779 }
5780 }
5781
5785 protected function readMultiTextFields()
5786 {
5787 global $DIC;
5788
5789 $ilDB = $DIC['ilDB'];
5790
5791 if (!$this->getId()) {
5792 return;
5793 }
5794
5795 $set = $ilDB->query("SELECT field_id,value" .
5796 " FROM usr_data_multi" .
5797 " WHERE usr_id = " . $ilDB->quote($this->getId(), "integer") .
5798 " ORDER BY value");
5799 while ($row = $ilDB->fetchAssoc($set)) {
5800 $values[$row["field_id"]][] = $row["value"];
5801 }
5802
5803 if (isset($values["interests_general"])) {
5804 $this->setGeneralInterests($values["interests_general"]);
5805 } else {
5806 $this->setGeneralInterests();
5807 }
5808 if (isset($values["interests_help_offered"])) {
5809 $this->setOfferingHelp($values["interests_help_offered"]);
5810 } else {
5811 $this->setOfferingHelp();
5812 }
5813 if (isset($values["interests_help_looking"])) {
5814 $this->setLookingForHelp($values["interests_help_looking"]);
5815 } else {
5816 $this->setLookingForHelp();
5817 }
5818 }
5819
5825 public function updateMultiTextFields($a_create = false)
5826 {
5827 global $DIC;
5828
5829 $ilDB = $DIC['ilDB'];
5830
5831 if (!$this->getId()) {
5832 return;
5833 }
5834
5835 if (!$a_create) {
5836 $this->deleteMultiTextFields();
5837 }
5838
5839 $map = array(
5840 "interests_general" => $this->getGeneralInterests(),
5841 "interests_help_offered" => $this->getOfferingHelp(),
5842 "interests_help_looking" => $this->getLookingForHelp()
5843 );
5844
5845 foreach ($map as $id => $values) {
5846 if (is_array($values) && sizeof($values)) {
5847 foreach ($values as $value) {
5848 $value = trim($value);
5849 if ($value) {
5850 $uniq_id = $ilDB->nextId('usr_data_multi');
5851
5852 $ilDB->manipulate("INSERT usr_data_multi" .
5853 " (id,usr_id,field_id,value) VALUES" .
5854 " (" . $ilDB->quote($uniq_id, "integer") .
5855 "," . $ilDB->quote($this->getId(), "integer") .
5856 "," . $ilDB->quote($id, "text") .
5857 "," . $ilDB->quote($value, "text") .
5858 ")");
5859 }
5860 }
5861 }
5862 }
5863 }
5864
5868 protected function deleteMultiTextFields()
5869 {
5870 global $DIC;
5871
5872 $ilDB = $DIC['ilDB'];
5873
5874 if (!$this->getId()) {
5875 return;
5876 }
5877
5878 $ilDB->manipulate("DELETE FROM usr_data_multi" .
5879 " WHERE usr_id = " . $ilDB->quote($this->getId(), "integer"));
5880 }
5881
5882 public static function findInterests($a_term, $a_user_id = null, $a_field_id = null)
5883 {
5884 global $DIC;
5885
5886 $ilDB = $DIC['ilDB'];
5887
5888 $res = array();
5889
5890 $sql = "SELECT DISTINCT(value)" .
5891 " FROM usr_data_multi" .
5892 " WHERE " . $ilDB->like("value", "text", "%" . $a_term . "%");
5893 if ($a_field_id) {
5894 $sql .= " AND field_id = " . $ilDB->quote($a_field_id, "text");
5895 }
5896 if ($a_user_id) {
5897 $sql .= " AND usr_id <> " . $ilDB->quote($a_user_id, "integer");
5898 }
5899 $sql .= " ORDER BY value";
5900 $set = $ilDB->query($sql);
5901 while ($row = $ilDB->fetchAssoc($set)) {
5902 $res[] = $row["value"];
5903 }
5904
5905 return $res;
5906 }
5907
5917 public static function getProfileStatusOfUsers($a_user_ids)
5918 {
5919 global $DIC;
5920
5921 $ilDB = $DIC->database();
5922
5923 $set = $ilDB->query(
5924 "SELECT * FROM usr_pref " .
5925 " WHERE keyword = " . $ilDB->quote("public_profile", "text") .
5926 " AND " . $ilDB->in("usr_id", $a_user_ids, false, "integer")
5927 );
5928 $r = array(
5929 "global" => array(),
5930 "local" => array(),
5931 "public" => array(),
5932 "not_public" => array()
5933 );
5934 while ($rec = $ilDB->fetchAssoc($set)) {
5935 if ($rec["value"] == "g") {
5936 $r["global"][] = $rec["usr_id"];
5937 $r["public"][] = $rec["usr_id"];
5938 }
5939 if ($rec["value"] == "y") {
5940 $r["local"][] = $rec["usr_id"];
5941 $r["public"][] = $rec["usr_id"];
5942 }
5943 }
5944 foreach ($a_user_ids as $id) {
5945 if (!in_array($id, $r["public"])) {
5946 $r["not_public"][] = $id;
5947 }
5948 }
5949
5950 return $r;
5951 }
5952} // END class ilObjUser
$result
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
$users
Definition: authpage.php:44
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const AUTH_LOCAL
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const USER_FOLDER_ID
Class ilObjUserFolder.
const IL_PASSWD_PLAIN
const IL_PASSWD_CRYPTED
const UDF_TYPE_WYSIWYG
static _getAuthMode($a_auth_mode, $a_db_handler='')
static _needsExternalAccountByAuthMode($a_auth_mode)
Check if chosen auth mode needs an external account entry.
static _getAuthModeName($a_auth_key)
static deleteByUserId($a_user_id)
static _deleteSettingsOfUser($a_user)
Delete block settings of user.
bookmark folder (note: this class handles personal bookmarks folders only)
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
static _getInstance()
get singleton instance
This is the super class of all custom blocks.
static resetToDefaults()
reset to defaults
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setLanguage($a_lng)
set language
static setUseRelativeDates($a_status)
set use relative dates
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
Class for single dates.
static deleteByOwner($a_owner_id)
Delete all entries for owner.
Base class for ILIAS Exception handling.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
Import class.
static _getInstance()
Get singleton instance of this class.
static _deleteUser($a_usr_id)
static getLogger($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($a_page_id)
Lookup title.
Base class for nested set path based trees.
static removeForUser($user_id)
Remove all notifications for given user.
static _deleteUser($a_usr_id)
static _deleteUser($a_usr_id)
static deleteUserPortfolios($a_user_id)
Delete all portfolio data for user.
static _deleteUser($a_usr_id)
updateMultiTextFields($a_create=false)
Write multi-text values to DB.
setCity($a_str)
set city @access public
static _resetLoginAttempts($a_usr_id)
updateLogin($a_login)
update login name
getPasswdType()
get password type
static lookupMatriculation($a_usr_id)
Lookup matriculation.
getPhoneHome()
get home phone @access public
deleteMultiTextFields()
Remove multi-text values from DB.
static _lookupFirstLogin($a_user_id)
lookup first login
static _writeExternalAccount($a_usr_id, $a_ext_id)
setCurrentLanguage($a_val)
Set current language.
getDiskQuota()
Returns the minimal disk quota imposed by this user account.
static _getUsersForIds($a_mem_ids, $active=-1, $timelimitowner=-1)
return user data for given user id
setUTitle($a_str)
set user title (note: don't mix up this method with setTitle() that is derived from ilObject and sets...
static copyProfilePicturesToDirectory($a_user_id, $a_dir)
Get profile picture direcotory.
setInactivationDate($inactivation_date)
setter for inactivation date
static _getUsersForRole($role_id, $active=-1)
return array of complete users which belong to a specific role
readMultiTextFields()
Fetch multi-text values from DB.
static _lookupPref($a_usr_id, $a_keyword)
static _getLastHistoryDataByUserId($a_usr_id)
Returns the last used loginname and the changedate of the passed user_id.
setSecondEmail($second_email)
addToPCClipboard($a_content, $a_time, $a_nr)
Add a page content item to PC clipboard (should go to another class)
getAgreeDate()
get the date when the user accepted the user agreement @access public
static _verifyRegistrationHash($a_hash)
Verifies a registration hash.
static _getImportedUserId($i2_id)
getLatitude()
Get Latitude.
addDesktopItem($a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
setLocationZoom($a_locationzoom)
Set Location Zoom.
static _lookupEmail($a_user_id)
Lookup email.
getLookingForHelpAsText()
Get help looking for as plain text.
getOfferingHelpAsText()
Get help offering as plain text.
setLanguage($a_str)
set user language @access public
setClientIP($a_str)
set client ip number @access public
getPhoneOffice()
get office phone @access public
setLatitude($a_latitude)
Set Latitude.
static searchUsers($a_search_str, $active=1, $a_return_ids_only=false, $filter_settings=false)
STATIC METHOD get the user_ids which correspond a search string.
static _getUserData($a_internalids)
return user data for given user ids
setInstitution($a_str)
set institution @access public
setLastUpdate($a_str)
set last update of user data set @access public
getClipboardObjects($a_type="", $a_top_nodes_only=false)
get all clipboard objects of user and specified type
static initInactivationDate($usrIds)
@global type $ilDB
getActive()
get user active state @access public
static $personal_image_cache
sendPersonalDataFile()
Send personal data file.
static _updateLastLogin($a_usr_id, $a_last_login=null)
STATIC METHOD updates the last_login field of user with given id to given or current date.
setAgreeDate($a_str)
set date the user account was accepted by the user nullindicates that the user has not accepted his a...
static _getAllUserData($a_fields=null, $active=-1)
STATIC METHOD get all user data.
setFirstname($a_str)
set firstname @access public
getGeneralInterests()
Get general interests.
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
$login
all user related data in single vars @access public
static _lookupLogin($a_user_id)
lookup login
setDepartment($a_str)
set department @access public
getCountry()
Get country (free text)
static _lookupSecondEmail($a_user_id)
Lookup second e-mail.
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
deletePref($a_keyword)
Deletes a userpref value of the user from the database @access public.
static getUserSubsetByPreferenceValue($a_user_ids, $a_keyword, $a_val)
For a given set of user IDs return a subset that has a given user preference set.
writeAccepted()
write accept date of user agreement to db
static getFirstLettersOfLastnames()
Get first letters of all lastnames.
getTimeZone()
get timezone of user
getFax()
get fax @access public
static getLoginFromAuth()
Gets the username from $ilAuth, and converts it into an ILIAS login name.
static getUserIdByLogin($a_login)
addObjectToClipboard( $a_item_id, $a_type, $a_title, $a_parent=0, $a_time=0, $a_order_nr=0)
add an item to user's personal clipboard
setDiskQuota($a_disk_quota)
Sets the minimal disk quota imposed by this user account.
getLastname()
get lastname @access public
removeUserPicture($a_do_update=true)
Remove user picture.
static getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.
getUTitle()
get user title (note: don't mix up this method with getTitle() that is derived from ilObject and gets...
getPersonalPicturePath($a_size="small", $a_force_pic=false)
Get path to personal picture.
setLookingForHelp(array $value=null)
Set help looking for.
static lookupOrgUnitsRepresentation($a_usr_id)
lokup org unit representation
static _writeAuthMode($a_usr_id, $a_auth_mode)
static _isDesktopItem($a_usr_id, $a_item_id, $a_type)
check wether an item is on the users desktop or not
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
getMatriculation()
get matriculation number @access public
setPasswordEncodingType($password_encryption_type)
static resetInactivationDate($usrIds)
@global type $ilDB
buildTextFromArray($a_attr)
Convert multi-text values to plain text.
static findInterests($a_term, $a_user_id=null, $a_field_id=null)
setExternalAccount($a_str)
set external account
setLogin($a_str)
set login / username @access public
static userExists($a_usr_ids=array())
getFirstLogin()
returns first login date
static _getPreferences($user_id)
get preferences for user
clipboardDeleteAll()
Delete objects of type for user.
setTimeLimitFrom($a_from)
readPrefs()
get all user preferences @access private
static _writePref($a_usr_id, $a_keyword, $a_value)
static _incrementLoginAttempts($a_usr_id)
importPersonalData( $a_file, $a_profile_data, $a_settings, $a_bookmarks, $a_notes, $a_calendar)
Import personal data.
hasPublicProfile()
returns true if public is profile, false otherwise
static _lookupFeedHash($a_user_id, $a_create=false)
Lookup news feed hash for user.
static _uploadPersonalPicture($tmp_file, $obj_id)
Create a personal picture image file from a temporary image file.
getDateFormat()
get date format
setSkin($a_str)
set user skin (template set) @access public
getHobby()
get hobby @access public
static _getUsersForFolder($ref_id, $active)
get users for a category or from system folder
getCurrentLanguage()
returns the current language (may differ from user's pref setting!)
setSelectedCountry($a_val)
Set selected country (selection drop down)
getLongitude()
Get Longitude.
getEmail()
get email address @access public
getLoginByUserId($a_userid)
isDesktopItem($a_item_id, $a_type)
check wether an item is on the users desktop or not
setCaptchaVerified($a_val)
Set captcha verified.
clipboardDeleteObjectsOfType($a_type)
Delete objects of type for user.
static preloadIsDesktopItem($a_usr_id, $a_item_ids)
Preload desktop item information.
static _lookupExternalAccount($a_user_id)
lookup external account for login and authmethod
setCountry($a_str)
Set country (free text)
setTimeLimitMessage($a_time_limit_message)
setPasswd($a_str, $a_type=IL_PASSWD_PLAIN)
set password @access public
static _lookupId($a_user_str)
Lookup id by login.
read()
loads a record "user" from database @access private
getLocationZoom()
Get Location Zoom.
getAuthMode($a_auth_key=false)
get auth mode @access public
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
static _getAllUserAssignedStyles()
skins and styles
static _deleteAllPref($a_user_id)
Deletes a userpref value of the user from the database @access public.
setComment($a_str)
set referral comment @access public
getComment()
get referral comment @access public
static getUsersAgreed($a_agreed=true, $a_users=null)
Get users that have or have not agreed to the user agreement.
getTimeFormat()
get time format
getPersonalDataExportFile()
Get personal data export file.
setAuthMode($a_str)
set auth mode @access public
setPhoneHome($a_str)
set home phone @access public
static _getUserIdsByInactivityPeriod($period)
get ids of all users that have been inactive for at least the given period
static _lookupGender($a_user_id)
Lookup gender.
setPasswordSalt($password_salt)
setFirstLogin($a_str)
set user's first login
setFax($a_str)
set fax @access public
setTimeLimitUntil($a_until)
static _lookupName($a_user_id)
lookup user name
static _getNumberOfUsersPerAuthMode()
get number of users per auth mode
getStreet()
get street @access public
getClipboardChilds($a_parent, $a_insert_time)
Get childs of an item.
static _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
Toggle active status of users.
getSelectedCountry()
Get selected country (selection drop down)
setTimeLimitOwner($a_owner)
getInstitution()
get institution @access public
getDesktopItems($a_types="")
getApproveDate()
get the date when the user account was approved @access public
getFirstname()
get firstname @access public
getZipcode()
get zipcode @access public
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
static _moveUsersToStyle($a_from_skin, $a_from_style, $a_to_skin, $a_to_style)
skins and styles
static _getUsersForClipboadObject($a_type, $a_id)
get all users, that have a certain object within their clipboard
setZipcode($a_str)
set zipcode @access public
setApproveDate($a_str)
set date the user account was activated null indicates that the user has not yet been activated @acce...
setLongitude($a_longitude)
Set Longitude.
getLogin()
get login / username @access public
getPasswd()
get password
getPref($a_keyword)
get a user preference
setFullname($a_title="", $a_firstname="", $a_lastname="")
builds a string with title + firstname + lastname method is used to build fullname in member variable...
setPref($a_keyword, $a_value)
set a user preference
getLastProfilePrompt()
returns user's last profile prompt
deleteUserDefinedFieldEntries()
setLastname($a_str)
set lastame @access public
hasToAcceptTermsOfServiceInSession($status=null)
static _getFeedPass($a_user_id)
Lookup news feed password for user.
setGeneralInterests(array $value=null)
Set general interests.
static _externalAccountExists($a_external_account, $a_auth_mode)
Check if an external account name already exists.
static _generateRegistrationHash($a_usr_id)
Generates a unique hashcode for activating a user profile after registration.
static _getUserIdsByInactivationPeriod($period)
get ids of all users that have been inactivated since at least the given period
static _setUserInactive($a_usr_id)
setBirthday($a_birthday)
static _lookupFullname($a_user_id)
Lookup Full Name.
setOfferingHelp(array $value=null)
Set help offering.
static _lookupAuthMode($a_usr_id)
lookup auth mode
getStoredActive($a_id)
get user active state
setStreet($a_str)
set street @access public
setLastPasswordChangeTS($a_last_password_change_ts)
getLastLogin()
returns last login date @access public
static $is_desktop_item_loaded
setActive($a_active, $a_owner=0)
set user active state and updates system fields appropriately @access public
refreshLogin()
updates the login data of a "user" // TODO set date with now() should be enough @access public
setGender($a_str)
set gender @access public
static _getUsersForGroup($a_mem_ids, $active=-1)
return user data for group members
static _lookupLastLogin($a_user_id)
lookup last login
setProfileIncomplete($a_prof_inc)
static _setFeedPass($a_user_id, $a_password)
Set news feed password for user.
setTimeLimitUnlimited($a_unlimited)
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
static _getLoginAttempts($a_usr_id)
static getProfileStatusOfUsers($a_user_ids)
Get profile status.
getPhoneMobile()
get mobile phone @access public
getPublicName()
returns firstname lastname and login if profile is public, login otherwise
setEmail($a_str)
set email @access public
getFullname($a_max_strlen=0)
get fullname @access public
static _lookup($a_user_id, $a_field)
Private function for lookup methods.
clipboardHasObjectsOfType($a_type)
Check whether clipboard has objects of a certain type.
setIsSelfRegistered($status)
getCity()
get city @access public
static _loginExists($a_login, $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...
getLanguage()
returns a 2char-language-string @access public
__construct($a_user_id=0, $a_call_by_reference=false)
Constructor @access public.
setMatriculation($a_str)
set matriculation number @access public
static _writeHistory($a_usr_id, $a_login)
getOfferingHelp()
Get help offering.
syncActive()
synchronizes current and stored user active values for the owner value to be set correctly,...
setLastLogin($a_str)
set user's last login @access public
writePrefs()
write all userprefs @access private
static _getLocalAccountsForEmail($a_email)
check whether external account and authentication method matches with a user
getInactivationDate()
getter for inactivation date
getDepartment()
get department @access public
setLastProfilePrompt($a_str)
set user's last profile prompt
assignData($a_data)
loads a record "user" from array @access public
getPersonalWorkspaceDiskQuota()
setLastPasswordChangeToNow()
setHobby($a_str)
set hobby @access public
getLookingForHelp()
Get help looking for.
static _isAnonymous($usr_id)
static _removeItemFromDesktops($a_id)
removes object from all user's desktops @access public
static _lookupLanguage($a_usr_id)
getGeneralInterestsAsText()
Get general interests as plain text.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
setPhoneOffice($a_str)
set office phone @access public
removeObjectFromClipboard($a_item_id, $a_type)
remove object from user's personal clipboard
getPCClipboardContent()
Add a page content item to PC clipboard (should go to another class)
dropDesktopItem($a_item_id, $a_type)
drop an item from user's personal desktop
exportPersonalData()
Export personal data.
setUserDefinedData($a_data)
static hasActiveSession($a_user_id, $a_session_id)
Check for simultaneous login.
setPhoneMobile($a_str)
set mobile phone @access public
static getUserLoginsByEmail($a_email)
get all user login names of an email address
isCaptchaVerified()
Is user captcha verified?
setLoginAttempts($a_login_attempts)
setDesktopItemParameters($a_item_id, $a_type, $a_par)
set parameters of a desktop item entry
getGender()
get gender @access public
getExternalAccount()
get external account
static $is_desktop_item_cache
static _lookupClientIP($a_user_id)
Lookup client ip.
static toUsernameWithoutDomain($a_login)
Static function removes Microsoft domain name from username webdav related.
static _getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
writePref($a_keyword, $a_value)
write userpref to user table @access private
static _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
static _lookupActive($a_usr_id)
Check user account active.
getClientIP()
get client ip number @access public
Class ilObject Basic functions for all objects.
setId($a_id)
set object id @access public
update()
update object in db
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
setOwner($a_owner)
set object owner
getId()
get object id @access public
getCreateDate()
get create date @access public
Custom block for external feeds on personal desktop.
Class for user related exception handling in ILIAS.
Class for user related exception handling in ILIAS.
Class ilObjAuthSettingsGUI.
static _removeTrackingDataForUser($user_id)
static _getInstance()
Get instance of ilSecuritySettings.
static set($a_var, $a_val)
Set a value.
static _destroyByUserId($a_user_id)
Destroy session.
static get($a_var)
Get a value.
ILIAS Setting Class.
static subStr($a_str, $a_start, $a_length=null)
Definition: class.ilStr.php:15
static skinExists($skin_id, ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
static styleExistsForSkinId($skin_id, $style_id)
static getInstance()
Singelton get instance.
Class ilUserDefinedData.
static deleteEntriesOfUser($a_user_id)
Delete data of user.
static _getInstance()
Get instance.
Class for user related exception handling in ILIAS.
static getInstance()
Singelton get instance.
static getInstance()
Single method to reduce footprint (included files, created instances)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static execConvert($args)
execute convert command
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static now()
Return current timestamp in Y-m-d H:i:s format.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static signFile($path_to_file)
Tree handler for personal workspace.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$r
Definition: example_031.php:79
$format
Definition: metadata.php:141
$user
Definition: migrateto20.php:57
$row
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
update($pash, $contents, Config $config)
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$query
$ilErr
Definition: raiseError.php:18
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$values
$ilUser
Definition: imgupload.php:18
$start
Definition: bench.php:8
$data
Definition: bench.php:6
$a_content
Definition: workflow.php:93
$a_type
Definition: workflow.php:92