24 define (
"IL_PASSWD_PLAIN",
"plain");
25 define (
"IL_PASSWD_MD5",
"md5");
26 define (
"IL_PASSWD_CRYPT",
"crypt");
29 require_once
"classes/class.ilObject.php";
149 function ilObjUser($a_user_id = 0, $a_call_by_reference =
false)
158 $this->
ilObject($a_user_id, $a_call_by_reference);
159 $this->auth_mode =
"default";
167 if (!empty($a_user_id))
169 $this->
setId($a_user_id);
176 $this->prefs = array();
178 $this->prefs[
"language"] = $this->ilias->ini->readVariable(
"language",
"default");
181 $this->skin = $this->ilias->ini->readVariable(
"layout",
"skin");
184 $this->prefs[
"show_users_online"] =
"y";
187 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
200 $q =
"SELECT * FROM usr_data ".
201 "LEFT JOIN rbac_ua ON usr_data.usr_id=rbac_ua.usr_id ".
202 "WHERE usr_data.usr_id= ".$ilDB->quote($this->
id);
203 $r = $this->ilias->db->query($q);
205 if ($r->numRows() > 0)
211 if (
$data[
"passwd"] ==
"" &&
$data[
"i2passwd"] !=
"")
221 unset(
$data[
"i2passw"]);
237 if ($this->prefs[
"language"] ==
"")
239 $this->prefs[
"language"] = $this->oldPrefs[
"language"];
243 include_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
244 if ($this->prefs[
"skin"] ==
"" ||
247 $this->prefs[
"skin"] = $this->oldPrefs[
"skin"];
250 $this->skin = $this->prefs[
"skin"];
253 if ($this->prefs[
"style"] ==
"" ||
257 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
260 if (empty($this->prefs[
"hits_per_page"]))
262 $this->prefs[
"hits_per_page"] = 10;
268 $ilErr->raiseError(
"<b>Error: There is no dataset with id ".
269 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
270 "<br />Line: ".__LINE__, $ilErr->FATAL);
289 if (! $a_data[
"passwd_type"])
291 $ilErr->raiseError(
"<b>Error: passwd_type missing in function assignData(). ".
292 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: "
293 .__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
295 if ($a_data[
"passwd"] !=
"********" and strlen($a_data[
'passwd']))
297 $this->
setPasswd($a_data[
"passwd"], $a_data[
"passwd_type"]);
310 $this->
setCity($a_data[
"city"]);
316 $this->
setFax($a_data[
"fax"]);
338 $this->create_date = $a_data[
"create_date"];
339 $this->
setComment($a_data[
"referral_comment"]);
340 $this->approve_date = $a_data[
"approve_date"];
341 $this->active = $a_data[
"active"];
342 $this->agree_date = $a_data[
"agree_date"];
372 switch ($this->passwd_type)
375 $pw_field =
"passwd";
376 if(strlen($this->passwd))
378 $pw_value = md5($this->passwd);
387 $pw_field =
"passwd";
392 $pw_field =
"i2passwd";
397 $ilErr->raiseError(
"<b>Error: passwd_type missing in function saveAsNew. ".
398 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
399 "<br />Line: ".__LINE__, $ilErr->FATAL);
402 if ($a_from_formular)
404 $q =
"INSERT INTO usr_data "
405 .
"(usr_id,login,".$pw_field.
",firstname,lastname,title,gender,"
406 .
"email,hobby,institution,department,street,city,zipcode,country,"
407 .
"phone_office,phone_home,phone_mobile,fax,last_login,last_update,create_date,"
408 .
"referral_comment,matriculation,client_ip, approve_date,agree_date,active,"
409 .
"time_limit_unlimited,time_limit_until,time_limit_from,time_limit_owner,auth_mode,ext_account,profile_incomplete,"
410 .
"im_icq,im_yahoo,im_msn,im_aim,im_skype,delicious,latitude,longitude,loc_zoom,last_password_change) "
413 $ilDB->quote($this->
id).
",".
414 $ilDB->quote($this->login).
",".
415 $ilDB->quote($pw_value).
",".
416 $ilDB->quote($this->firstname).
",".
417 $ilDB->quote($this->lastname).
",".
418 $ilDB->quote($this->utitle).
",".
419 $ilDB->quote($this->gender).
",".
420 $ilDB->quote($this->email).
",".
421 $ilDB->quote($this->hobby).
",".
422 $ilDB->quote($this->institution).
",".
423 $ilDB->quote($this->department).
",".
424 $ilDB->quote($this->street).
",".
425 $ilDB->quote($this->city).
",".
426 $ilDB->quote($this->zipcode).
",".
427 $ilDB->quote($this->country).
",".
428 $ilDB->quote($this->phone_office).
",".
429 $ilDB->quote($this->phone_home).
",".
430 $ilDB->quote($this->phone_mobile).
",".
431 $ilDB->quote($this->fax).
", 0, now(), now(),".
432 $ilDB->quote($this->referral_comment).
",".
433 $ilDB->quote($this->matriculation).
",".
434 $ilDB->quote($this->client_ip).
",".
435 $ilDB->quote($this->approve_date).
",".
436 $ilDB->quote($this->agree_date).
",".
437 $ilDB->quote($this->active).
",".
445 $ilDB->quote($this->im_icq).
",".
446 $ilDB->quote($this->im_yahoo).
",".
447 $ilDB->quote($this->im_msn).
",".
448 $ilDB->quote($this->im_aim).
",".
449 $ilDB->quote($this->im_skype).
",".
450 $ilDB->quote($this->delicious).
",".
451 $ilDB->quote($this->latitude).
",".
452 $ilDB->quote($this->longitude).
",".
453 $ilDB->quote($this->loc_zoom).
",".
454 $ilDB->quote($this->last_password_change_ts).
459 $q =
"INSERT INTO usr_data ".
460 "(usr_id,login,".$pw_field.
",firstname,lastname,title,gender,"
461 .
"email,hobby,institution,department,street,city,zipcode,country,"
462 .
"phone_office,phone_home,phone_mobile,fax,last_login,last_update,create_date,"
463 .
"referral_comment,matriculation,client_ip, approve_date,agree_date,active,"
464 .
"time_limit_unlimited,time_limit_until,time_limit_from,time_limit_owner,auth_mode,ext_account,profile_incomplete,"
465 .
"im_icq,im_yahoo,im_msn,im_aim,im_skype,delicious,latitude,longitude,loc_zoom,last_password_change) "
468 $ilDB->quote($this->
id).
",".
469 $ilDB->quote($this->login).
",".
470 $ilDB->quote($pw_value).
",".
471 $ilDB->quote($this->firstname).
",".
472 $ilDB->quote($this->lastname).
",".
473 $ilDB->quote($this->utitle).
",".
474 $ilDB->quote($this->gender).
",".
475 $ilDB->quote($this->email).
",".
476 $ilDB->quote($this->hobby).
",".
477 $ilDB->quote($this->institution).
",".
478 $ilDB->quote($this->department).
",".
479 $ilDB->quote($this->street).
",".
480 $ilDB->quote($this->city).
",".
481 $ilDB->quote($this->zipcode).
",".
482 $ilDB->quote($this->country).
",".
483 $ilDB->quote($this->phone_office).
",".
484 $ilDB->quote($this->phone_home).
",".
485 $ilDB->quote($this->phone_mobile).
",".
486 $ilDB->quote($this->fax).
", 0, now(), now(),".
487 $ilDB->quote($this->referral_comment).
",".
488 $ilDB->quote($this->matriculation).
",".
489 $ilDB->quote($this->client_ip).
",".
490 $ilDB->quote($this->approve_date).
",".
491 $ilDB->quote($this->agree_date).
",".
492 $ilDB->quote($this->active).
",".
500 $ilDB->quote($this->im_icq).
",".
501 $ilDB->quote($this->im_yahoo).
",".
502 $ilDB->quote($this->im_msn).
",".
503 $ilDB->quote($this->im_aim).
",".
504 $ilDB->quote($this->im_skype).
",".
505 $ilDB->quote($this->delicious).
",".
506 $ilDB->quote($this->latitude).
",".
507 $ilDB->quote($this->longitude).
",".
508 $ilDB->quote($this->loc_zoom).
",".
509 $ilDB->quote($this->last_password_change_ts).
513 $this->ilias->db->query($q);
521 include_once (
"Services/Mail/classes/class.ilMailbox.php");
523 $mbox->createDefaultFolder();
525 include_once
"Services/Mail/classes/class.ilMailOptions.php";
527 $mail_options->createMailOptionsEntry();
530 include_once
"./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php";
532 $bmf->createNewBookmarkTree();
548 if (isset($this->agree_date) && (strtotime($this->agree_date) !==
false || $this->agree_date ==
"0000-00-00 00:00:00"))
550 $agreedate_update =
"agree_date= ".$ilDB->quote($this->agree_date).
",";
553 $agreedate_update =
"";
557 switch ($this->passwd_type)
560 if(strlen($this->passwd))
562 $pw_update =
"i2passwd='', passwd='".md5($this->passwd).
"'";
566 $pw_update =
"i2passwd='', passwd='".$this->passwd.
"'";
571 $pw_update =
"i2passwd='', passwd='".$this->passwd.
"'";
575 $pw_update =
"passwd='', i2passwd='".$this->passwd.
"'";
579 $ilErr->raiseError(
"<b>Error: passwd_type missing in function update()".$this->
id.
"!</b><br />class: ".
580 get_class($this).
"<br />Script: ".__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
582 $q =
"UPDATE usr_data SET ".
583 "gender = ".$ilDB->quote($this->gender).
",".
584 "title= ".$ilDB->quote($this->utitle).
",".
585 "firstname= ".$ilDB->quote($this->firstname).
",".
586 "lastname= ".$ilDB->quote($this->lastname).
",".
587 "email= ".$ilDB->quote($this->email).
",".
588 "hobby= ".$ilDB->quote($this->hobby).
",".
589 "institution= ".$ilDB->quote($this->institution).
",".
590 "department= ".$ilDB->quote($this->department).
",".
591 "street= ".$ilDB->quote($this->street).
",".
592 "city= ".$ilDB->quote($this->city).
",".
593 "zipcode= ".$ilDB->quote($this->zipcode).
",".
594 "country= ".$ilDB->quote($this->country).
",".
595 "phone_office= ".$ilDB->quote($this->phone_office).
",".
596 "phone_home= ".$ilDB->quote($this->phone_home).
",".
597 "phone_mobile= ".$ilDB->quote($this->phone_mobile).
",".
598 "fax= ".$ilDB->quote($this->fax).
",".
599 "referral_comment= ".$ilDB->quote($this->referral_comment).
",".
600 "matriculation= ".$ilDB->quote($this->matriculation).
",".
601 "client_ip= ".$ilDB->quote($this->client_ip).
",".
602 "approve_date= ".$ilDB->quote($this->approve_date).
",".
604 "active= ".$ilDB->quote($this->active).
",".
611 "auth_mode= ".$ilDB->quote($this->
getAuthMode()).
", ".
620 "latitude= ".$ilDB->quote($this->
getLatitude()).
",".
623 "last_update=now()".
",".
628 " WHERE usr_id= ".$ilDB->quote($this->
id);
630 $this->ilias->db->query($q);
652 $q =
"UPDATE usr_data SET agree_date = now()".
653 "WHERE usr_id = ".$ilDB->quote($this->
getId());
662 $query =
"SELECT email FROM usr_data WHERE usr_id = ".$ilDB->quote((
int) $a_user_id);
663 $res = $ilDB->query($query);
676 $query =
"SELECT gender FROM usr_data WHERE usr_id = ".
677 $ilDB->quote((
int) $a_user_id);
678 $res = $ilDB->query($query);
691 $query =
"SELECT client_ip FROM usr_data WHERE usr_id = ".
692 $ilDB->quote((
int) $a_user_id);
693 $res = $ilDB->query($query);
697 return $row->client_ip;
710 $q =
"SELECT firstname, lastname, title FROM usr_data".
711 " WHERE usr_id =".$ilDB->quote($a_user_id);
712 $user_set = $ilDB->query($q);
714 return array(
"user_id" => $a_user_id,
715 "firstname" => $user_rec[
"firstname"],
716 "lastname" => $user_rec[
"lastname"],
717 "title" => $user_rec[
"title"]);
727 $q =
"SELECT * FROM usr_data".
728 " WHERE usr_id =".$ilDB->quote($a_user_id);
729 $user_set = $ilDB->query($q);
741 $q =
"SELECT login FROM usr_data".
742 " WHERE usr_id =".$ilDB->quote($a_user_id);
743 $user_set = $ilDB->query($q);
745 return $user_rec[
"login"];
755 $q =
"SELECT ext_account FROM usr_data".
756 " WHERE usr_id =".$ilDB->quote($a_user_id);
757 $user_set = $ilDB->query($q);
759 return $user_rec[
"ext_account"];
769 $q =
"SELECT usr_id FROM usr_data".
770 " WHERE login =".$ilDB->quote($a_user_str);
771 $user_set = $ilDB->query($q);
773 return $user_rec[
"usr_id"];
783 $q =
"SELECT last_login FROM usr_data".
784 " WHERE usr_id =".$ilDB->quote($a_user_id);
785 $user_set = $ilDB->query($q);
787 return $user_rec[
"last_login"];
800 $q =
"UPDATE usr_data SET ".
801 "last_login = now() ".
802 "WHERE usr_id = ".$ilDB->quote($this->
id);
804 $this->ilias->db->query($q);
818 $this->passwd = $new_md5;
820 $q =
"UPDATE usr_data SET ".
821 "passwd= ".$ilDB->quote($this->passwd).
" ".
822 "WHERE usr_id= ".$ilDB->quote($this->
id);
824 $this->ilias->db->query($q);
841 if (func_num_args() != 3)
846 if (!isset($a_old) or !isset($a_new1) or !isset($a_new2))
851 if ($a_new1 != $a_new2)
857 if ($a_new1 ==
"" || $a_old ==
"")
863 switch ($this->passwd_type)
866 if ($a_old != $this->passwd)
873 if (md5($a_old) != $this->passwd)
888 $this->passwd = md5($a_new1);
891 $q =
"UPDATE usr_data SET ".
892 "passwd= ".$ilDB->quote($this->passwd).
" ".
893 "WHERE usr_id= ".$ilDB->quote($this->
id).
" ";
894 $this->ilias->db->query($q);
910 if (func_num_args() != 2)
915 if (!isset($a_new1) or !isset($a_new2))
920 if ($a_new1 != $a_new2)
926 $this->passwd = md5($a_new1);
929 $q =
"UPDATE usr_data SET ".
930 "passwd= ".$ilDB->quote($this->passwd).
" ".
931 "WHERE usr_id= ".$ilDB->quote($this->
id);
932 $this->ilias->db->query($q);
942 return (crypt($a_passwd,substr($a_passwd,0,2)));
952 $q =
"SELECT i2passwd FROM usr_data ".
953 "WHERE login = ".$ilDB->quote($a_user_login).
"";
954 $user_set = $ilias->db->query($q);
958 if ($user_rec[
"i2passwd"] !=
"")
971 $q =
"SELECT i2passwd FROM usr_data ".
972 "WHERE login = ".$ilDB->quote($a_user);
974 $user_set = $ilias->db->query($q);
980 $q =
"UPDATE usr_data SET passwd= ".$ilDB->quote(md5($a_pw)).
", i2passwd=''".
981 "WHERE login = ".$ilDB->quote($a_user);
982 $ilias->db->query($q);
1000 if (func_num_args() != 1)
1005 if (!isset($a_login))
1011 $this->login = $a_login;
1013 $q =
"UPDATE usr_data SET ".
1014 "login= ".$ilDB->quote($this->login).
" ".
1015 "WHERE usr_id= ".$ilDB->quote($this->
id);
1016 $this->ilias->db->query($q);
1030 $this->
setPref($a_keyword, $a_value);
1043 $query = sprintf(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
1044 $ilDB->quote($this->getId() .
""),
1045 $ilDB->quote($a_keyword .
"")
1047 $ilDB->query($query);
1055 if (strlen($a_value))
1057 $query = sprintf(
"REPLACE INTO usr_pref VALUES (%s, %s, %s)",
1058 $ilDB->quote($a_usr_id),
1059 $ilDB->quote($a_keyword),
1060 $ilDB->quote($a_value)
1065 $query = sprintf(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
1066 $ilDB->quote($a_usr_id),
1067 $ilDB->quote($a_keyword)
1070 $ilDB->query($query);
1082 $q =
"DELETE FROM usr_pref ".
1083 "WHERE usr_id= ".$ilDB->quote($this->
id);
1084 $this->ilias->db->query($q);
1086 foreach ($this->prefs as $keyword => $value)
1089 $q =
"INSERT INTO usr_pref ".
1090 "(usr_id, keyword, value) ".
1092 "(".$ilDB->quote($this->
id).
",".$ilDB->quote($keyword).
",".
1093 $ilDB->quote($value).
")";
1094 $this->ilias->db->query($q);
1106 if($tz = $this->
getPref(
'user_tz'))
1112 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1114 return $settings->getDefaultTimeZone();
1126 if($format = $this->
getPref(
'time_format'))
1132 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1134 return $settings->getDefaultTimeFormat();
1146 if ($a_keyword !=
"")
1148 $this->prefs[$a_keyword] = $a_value;
1159 if (array_key_exists($a_keyword, $this->prefs))
1161 return $this->prefs[$a_keyword];
1173 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ".
1174 "AND keyword = ".$ilDB->quote($a_keyword);
1175 $res = $ilDB->query($query);
1193 if (is_array($this->prefs))
1209 global $rbacadmin, $ilDB;
1212 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1214 $mapping->deleteUser($this->
getId());
1217 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1220 $mailbox->updateMailsOfDeletedUser();
1223 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1225 $costum_block->setContextObjId($this->
getId());
1226 $costum_block->setContextObjType(
"user");
1227 $c_blocks = $costum_block->queryBlocksForContext();
1228 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1229 foreach($c_blocks as $c_block)
1231 if ($c_block[
"type"] ==
"pdfeed")
1240 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1244 $this->ilias->db->query(
"DELETE FROM usr_data WHERE usr_id = ".
1245 $ilDB->quote($this->getId()));
1248 $this->ilias->db->query(
"DELETE FROM usr_pref WHERE usr_id= ".
1249 $ilDB->quote($this->getId()));
1252 $this->ilias->db->query(
"DELETE FROM usr_session WHERE user_id= ".
1253 $ilDB->quote($this->getId()));
1256 $rbacadmin->removeUser($this->
getId());
1260 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1261 $ilDB->quote($this->
getId());
1262 $this->ilias->db->query($q);
1264 $q =
"DELETE FROM bookmark_data WHERE user_id= ".
1265 $ilDB->quote($this->
getId());
1266 $this->ilias->db->query($q);
1269 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1273 include_once
'./classes/class.ilLinkCheckNotify.php';
1277 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1281 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1284 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1304 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1306 $this->fullname =
"";
1312 elseif ($this->utitle)
1314 $this->fullname = $this->utitle.
" ";
1321 elseif ($this->firstname)
1323 $this->fullname .= $this->firstname.
" ";
1355 if (strlen($this->fullname) <= $a_max_strlen)
1360 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1362 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1365 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1370 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1389 $q =
"SELECT * FROM lo_access ".
1390 "WHERE usr_id= ".$ilDB->quote($this->
id).
" ".
1391 "ORDER BY timestamp DESC";
1392 $rst = $this->ilias->db->query($q);
1399 "timestamp" => $record->timestamp,
1400 "usr_id" => $record->usr_id,
1401 "lm_id" => $record->lm_id,
1402 "obj_id" => $record->obj_id,
1403 "lm_title" => $record->lm_title);
1419 $q =
"SELECT * FROM lo_access ".
1420 "WHERE usr_id= ".$ilDB->quote($this->
id).
" ";
1421 $rst = $this->ilias->db->query($q);
1428 "timestamp" => $record->timestamp,
1429 "usr_id" => $record->usr_id,
1430 "lm_id" => $record->lm_id,
1431 "obj_id" => $record->obj_id,
1432 "lm_title" => $record->lm_title);
1449 if($a_username ==
'root')
1454 $query =
"SELECT usr_id FROM usr_data ".
1455 "WHERE login = ".$ilDB->quote($a_username).
" ".
1456 "AND agree_date != '0000-00-00 00:00:00'";
1457 $res = $ilDB->query($query);
1458 return $res->numRows() ?
true :
false;
1467 if ($this->agree_date !=
"0000-00-00 00:00:00" || $this->login ==
"root")
1481 $this->login = $a_str;
1500 $this->passwd = $a_str;
1501 $this->passwd_type = $a_type;
1533 $this->gender = substr($a_str,-1);
1554 $this->utitle = $a_str;
1575 $this->firstname = $a_str;
1594 $this->lastname = $a_str;
1613 $this->institution = $a_str;
1632 $this->department = $a_str;
1651 $this->street = $a_str;
1670 $this->city = $a_str;
1689 $this->zipcode = $a_str;
1708 $this->country = $a_str;
1727 $this->phone_office = $a_str;
1746 $this->phone_home = $a_str;
1765 $this->phone_mobile = $a_str;
1784 $this->fax = $a_str;
1803 $this->client_ip = $a_str;
1822 $this->matriculation = $a_str;
1844 $query =
"SELECT matriculation FROM usr_data ".
1845 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1846 $res = $ilDB->query($query);
1848 return $row->matriculation ? $row->matriculation :
'';
1858 $this->email = $a_str;
1877 $this->hobby = $a_str;
1896 $this->
setPref(
"language",$a_str);
1907 return $this->prefs[
"language"];
1912 $this->last_password_change_ts = $a_last_password_change_ts;
1925 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
1926 $ilDB->quote($a_usr_id).
" AND keyword = 'language'";
1927 $r = $ilDB->query($q);
1931 return $row[
'value'];
1941 $q =
"SELECT passwd FROM usr_data ".
1942 " WHERE usr_id = ".$ilDB->quote($a_usr_id);
1943 $usr_set = $ilDB->query($q);
1947 if ($usr_rec[
"passwd"] == md5($a_pw))
1959 $q =
"UPDATE usr_data ".
1960 " SET ext_account = ".$ilDB->quote($a_ext_id).
1961 " WHERE usr_id = ".$ilDB->quote($a_usr_id);
1962 $usr_set = $ilDB->query($q);
1969 $q =
"UPDATE usr_data ".
1970 " SET auth_mode = ".$ilDB->quote($a_auth_mode).
1971 " WHERE usr_id = ".$ilDB->quote($a_usr_id);
1972 $usr_set = $ilDB->query($q);
1991 $this->last_login = $a_str;
2001 return $this->last_login;
2011 $this->last_update = $a_str;
2025 $this->referral_comment = $a_str;
2045 $this->approve_date = $a_str;
2066 return $this->agree_date;
2076 $this->agree_date = $a_str;
2088 if (empty($a_owner))
2137 if ((!empty($storedActive) && empty($currentActive)) ||
2138 (empty($storedActive) && !empty($currentActive)))
2154 $query =
"SELECT active FROM usr_data ".
2155 "WHERE usr_id = ".$ilDB->quote($a_id);
2159 return $row->active ?
true :
false;
2170 $this->skin = $a_str;
2175 $this->time_limit_owner = $a_owner;
2179 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2183 $this->time_limit_from = $a_from;
2187 return $this->time_limit_from ? $this->time_limit_from : time();
2191 $this->time_limit_until = $a_until;
2195 return $this->time_limit_until ? $this->time_limit_until : time();
2199 $this->time_limit_unlimited = $a_unlimited;
2203 return $this->time_limit_unlimited;
2207 return $this->time_limit_message = $a_time_limit_message;
2211 return $this->time_limit_message;
2216 $this->login_attempts = $a_login_attempts;
2239 $this->profile_incomplete = (boolean) $a_prof_inc;
2243 return $this->profile_incomplete;
2249 if( $this->
id == ANONYMOUS_USER_ID || $this->
id == SYSTEM_USER_ID )
2252 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2254 if( $security->isPasswordChangeOnFirstLoginEnabled() &&
2265 if($this->
id == ANONYMOUS_USER_ID)
return false;
2267 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2272 $max_pass_age = $security->getPasswordMaxAge();
2273 if( $max_pass_age > 0 )
2275 $max_pass_age_ts = ( $max_pass_age * 86400 );
2277 $current_ts = time();
2279 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2288 $current_ts = time();
2290 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2291 return $password_age;
2298 $query =
"UPDATE usr_data SET usr_data.last_password_change = ? " .
2299 "WHERE usr_data.usr_id = ?";
2300 $statement = $this->db->prepareManip( $query, array(
'integer',
'integer') );
2302 if($affected)
return true;
2308 $query =
"UPDATE usr_data SET usr_data.last_password_change = 0 " .
2309 "WHERE usr_data.usr_id = ?";
2310 $statement = $this->db->prepareManip( $query, array(
'integer') );
2311 $affected = $this->db->execute( $statement, array($this->
getId()) );
2312 if($affected)
return true;
2323 $this->latitude = $a_latitude;
2343 $this->longitude = $a_longitude;
2363 $this->loc_zoom = $a_locationzoom;
2378 $this->applied_users = array();
2381 return $this->applied_users ? $this->applied_users : array();
2386 if($a_usr_id == $this->
getId())
2391 $this->applied_users = array();
2394 return in_array($a_usr_id,$this->applied_users);
2401 $query =
"SELECT usr_id FROM usr_data ".
2402 "WHERE time_limit_owner = ".$ilDB->quote($a_parent_id);
2404 $res = $this->ilias->db->query($query);
2407 $this->applied_users[] = $row->usr_id;
2424 $r = $this->ilias->db->query(
"SELECT usr_id FROM usr_data WHERE login = ".
2428 if ($r->numRows() > 0)
2430 $data = $r->fetchRow();
2431 $this->
id =
$data[0];
2446 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2449 require_once (
'Services/Authentication/classes/class.ilAuthContainerMDB2.php');
2454 $login =$ilAuth->getUsername();
2470 $r = $this->ilias->db->query(
"SELECT active FROM usr_data WHERE login= ".
2473 if ($r->numRows() > 0)
2475 $data = $r->fetchRow();
2476 if (!empty(
$data[0]))
2497 $query =
"SELECT usr_id FROM usr_data ".
2498 "WHERE login = ".$ilDB->quote($a_login);
2502 return $row->usr_id ? $row->usr_id : 0;
2517 $query =
"SELECT login FROM usr_data ".
2518 "WHERE email = ".$ilDB->quote($a_email).
" and active=1";
2520 $res = $ilias->db->query($query);
2524 $ids[] = $row->login;
2544 $query =
"SELECT usr_id FROM usr_data ".
2545 "WHERE email = ".$ilDB->quote($a_email);
2548 return $row->usr_id ? $row->usr_id : 0;
2563 $query =
"SELECT login FROM usr_data ".
2564 "WHERE usr_id = ".$ilDB->quote($a_userid);
2568 return $row->login ? $row->login :
false;
2586 $active_filter =
"";
2587 $time_limit_filter =
"";
2588 $join_filter =
" WHERE ";
2589 $last_login_filter =
"";
2590 $without_anonymous_users =
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID);
2591 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE) $active_filter =
" AND active = ".$ilDB->quote(
$active);
2592 global
$ilLog; $ilLog->write(
"active = $active, filter settings = $filter_settings, active_filter = $active_filter");
2595 if ($filter_settings !== FALSE && strlen($filter_settings))
2597 switch ($filter_settings)
2600 $active_filter =
"";
2604 $active_filter =
" AND usr_data.active = " . $ilDB->quote(
"0");
2608 $active_filter =
" AND usr_data.active = " . $ilDB->quote(
"1");
2612 $time_limit_filter =
" AND usr_data.time_limit_unlimited = " . $ilDB->quote(
"0");
2617 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.usr_id IS NULL AND ";
2620 $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"]));
2621 $last_login_filter = sprintf(
" AND last_login < %s", $ilDB->quote($date));
2628 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.obj_id = (SELECT obj_id FROM object_reference WHERE ref_id = " .
2629 $ilDB->quote(
$ref_id) .
") AND ";
2637 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2638 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2639 if (is_array($local_roles) && count($local_roles))
2641 $role_ids = join(
"','", $local_roles);
2642 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id IN ('" . $role_ids .
"') AND ";
2648 $rol_id =
$_SESSION[
"user_filter_data"];
2651 $join_filter = sprintf(
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = %s AND ", $ilDB->quote($rol_id));
2652 $without_anonymous_users =
"";
2659 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2661 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2662 "FROM object_data,rbac_ua,usr_data ".
2663 "WHERE object_data.title LIKE ".$ilDB->quote(
"%".substr($a_search_str,5).
"%").
2664 " and object_data.type = 'role' ".
2665 "and rbac_ua.rol_id = object_data.obj_id ".
2666 "and usr_data.usr_id = rbac_ua.usr_id ".
2667 "AND rbac_ua.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID);
2671 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ".
2673 "(usr_data.login LIKE ".$ilDB->quote(
"%".$a_search_str.
"%").
" ".
2674 "OR usr_data.firstname LIKE ".$ilDB->quote(
"%".$a_search_str.
"%").
" ".
2675 "OR usr_data.lastname LIKE ".$ilDB->quote(
"%".$a_search_str.
"%").
" ".
2676 "OR usr_data.email LIKE ".$ilDB->quote(
"%".$a_search_str.
"%").
") ".
2677 $without_anonymous_users .
2678 $active_filter . $time_limit_filter . $last_login_filter;
2680 $ilLog->write($query);
2681 $res = $ilias->db->query($query);
2685 "usr_id" => $row->usr_id,
2686 "login" => $row->login,
2687 "firstname" => $row->firstname,
2688 "lastname" => $row->lastname,
2689 "email" => $row->email,
2690 "active" => $row->active);
2691 $ids[] = $row->usr_id;
2693 if ($a_return_ids_only)
2694 return $ids ? $ids : array();
2696 return $users ? $users : array();
2714 $where_condition = $a_search_obj->getWhereCondition(
"like",array(
"login",
"firstname",
"lastname",
"title",
2715 "email",
"institution",
"street",
"city",
2716 "zipcode",
"country",
"phone_home",
"fax"));
2717 $in = $a_search_obj->getInStatement(
"usr_data.usr_id");
2719 $query =
"SELECT DISTINCT(usr_data.usr_id) FROM usr_data ".
2720 "LEFT JOIN usr_pref USING (usr_id) ".
2721 $where_condition.
" ".
2723 "AND usr_data.usr_id != '".ANONYMOUS_USER_ID.
"' ";
2724 # "AND usr_pref.keyword = 'public_profile' ";
2725 # "AND usr_pref.value = 'y'";
2728 $query .=
"AND active = ".$ilDB->quote(
$active);
2730 $ilBench->start(
"Search",
"ilObjUser_search");
2731 $res = $a_search_obj->ilias->db->query($query);
2732 $ilBench->stop(
"Search",
"ilObjUser_search");
2738 $result_data[$counter++][
"id"] = $row->usr_id;
2741 return $result_data ? $result_data : array();
2751 global $rbacreview, $tree;
2753 if (strlen($a_user_id) > 0)
2755 $user_id = $a_user_id;
2759 $user_id = $this->
getId();
2762 $grp_memberships = array();
2765 $roles = $rbacreview->assignedRoles($user_id);
2767 foreach ($roles as $role)
2769 $ass_rolefolders = $rbacreview->getFoldersAssignedToRole($role);
2771 foreach ($ass_rolefolders as $role_folder)
2773 $node = $tree->getParentNodeData($role_folder);
2775 if ($node[
"type"] ==
"grp")
2777 $group =& $this->ilias->obj_factory->getInstanceByRefId($node[
"child"]);
2779 if ($group->isMember($user_id) ==
true && !in_array($group->getId(), $grp_memberships) )
2781 array_push($grp_memberships, $group->getId());
2789 return $grp_memberships;
2799 global $rbacreview, $tree;
2801 if (strlen($a_user_id) > 0)
2803 $user_id = $a_user_id;
2807 $user_id = $this->
getId();
2810 $crs_memberships = array();
2813 $roles = $rbacreview->assignedRoles($user_id);
2815 foreach ($roles as $role)
2817 $ass_rolefolders = $rbacreview->getFoldersAssignedToRole($role);
2819 foreach ($ass_rolefolders as $role_folder)
2821 $node = $tree->getParentNodeData($role_folder);
2823 if ($node[
"type"] ==
"crs")
2825 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
2828 if ($crsmem->isAssigned($user_id) && !in_array($node[
'obj_id'], $crs_memberships))
2830 array_push($crs_memberships, $node[
'obj_id']);
2836 return $crs_memberships ? $crs_memberships : array();
2850 $query =
"SELECT login FROM usr_data ";
2855 $logins[] = $row->login;
2857 return $logins ? $logins : array();
2873 $query =
"SELECT * FROM usr_data ".$where;
2874 $res = $ilDB->query($query);
2877 $user_data[
"$row[usr_id]"] = $row;
2879 return $user_data ? $user_data : array();
2894 $result_arr = array();
2896 if ($a_fields !== NULL and is_array($a_fields))
2898 if (count($a_fields) == 0)
2904 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2905 unset($a_fields[$usr_id_field]);
2907 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2909 if(in_array(
'online_time',$a_fields))
2911 $select .=
",ut_online.online_time ";
2915 $q =
"SELECT ".$select.
" FROM usr_data ";
2919 if(in_array(
'online_time',$a_fields))
2921 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2928 $q .=
"WHERE active= ".$ilDB->quote(
$active);
2931 $q .=
"WHERE time_limit_unlimited='0'";
2934 $qtemp = $q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND object_data.title LIKE '%crs%' AND usr_data.usr_id = rbac_ua.usr_id";
2935 $r = $ilDB->query($qtemp);
2936 $course_users = array();
2939 array_push($course_users, $row[
"usr_id"]);
2941 if (count($course_users))
2943 $q .=
" WHERE usr_data.usr_id NOT IN ('" . join($course_users,
"','") .
"')";
2951 $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"]));
2952 $q .= sprintf(
"WHERE last_login < %s", $ilDB->quote($date));
2958 $q .=
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.obj_id = (SELECT obj_id FROM object_reference WHERE ref_id = " .
2967 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2968 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2969 if (is_array($local_roles) && count($local_roles))
2971 $role_ids = join(
"','", $local_roles);
2972 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id IN ('" . $role_ids .
"')";
2977 $rol_id =
$_SESSION[
"user_filter_data"];
2980 $q .= sprintf(
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = %s", $ilDB->quote($rol_id));;
2985 $r = $ilDB->query($q);
2989 $result_arr[] = $row;
3003 $q =
"SELECT count(*) as cnt FROM usr_pref AS up1, usr_pref AS up2 ".
3004 " WHERE up1.keyword= ".$ilDB->quote(
"style").
" AND up1.value= ".$ilDB->quote($a_style).
3005 " AND up2.keyword= ".$ilDB->quote(
"skin").
" AND up2.value= ".$ilDB->quote($a_skin).
3006 " AND up1.usr_id = up2.usr_id ";
3008 $cnt_set = $ilDB->query($q);
3012 return $cnt_rec[
"cnt"];
3022 $q =
"SELECT DISTINCT up1.value as style, up2.value as skin FROM usr_pref AS up1, usr_pref AS up2 ".
3023 " WHERE up1.keyword= ".$ilDB->quote(
"style").
3024 " AND up2.keyword= ".$ilDB->quote(
"skin").
3025 " AND up1.usr_id = up2.usr_id ";
3028 $sty_set = $ilDB->query($q);
3033 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
3046 $q =
"SELECT up1.usr_id as usr_id FROM usr_pref AS up1, usr_pref AS up2 ".
3047 " WHERE up1.keyword= ".$ilDB->quote(
"style").
" AND up1.value= ".$ilDB->quote($a_from_style).
3048 " AND up2.keyword= ".$ilDB->quote(
"skin").
" AND up2.value= ".$ilDB->quote($a_from_skin).
3049 " AND up1.usr_id = up2.usr_id ";
3051 $usr_set = $ilDB->query($q);
3074 $q =
"SELECT * FROM desktop_item WHERE ".
3075 "item_id = ".$ilDB->quote($a_item_id).
" AND type = ".
3076 $ilDB->quote($a_type).
" AND user_id = ".
3077 $ilDB->quote($a_usr_id);
3078 $item_set = $ilDB->query($q);
3081 if (!
$d = $item_set->fetchRow())
3083 $q =
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3084 " (".$ilDB->quote($a_item_id).
",".
3085 $ilDB->quote($a_type).
",".
3086 $ilDB->quote($a_usr_id).
",".
3087 $ilDB->quote($a_par).
")";
3134 $q =
"UPDATE desktop_item SET parameters = ".$ilDB->quote($a_par).
" ".
3135 " WHERE item_id = ".$ilDB->quote($a_item_id).
" AND type = ".
3136 $ilDB->quote($a_type).
" ".
3137 " AND user_id = ".$ilDB->quote($this->
getId()).
" ";
3138 $this->ilias->db->query($q);
3155 $q =
"DELETE FROM desktop_item WHERE ".
3156 " item_id = ".$ilDB->quote($a_item_id).
" AND ".
3157 " type = ".$ilDB->quote($a_type).
" AND ".
3158 " user_id = ".$ilDB->quote($a_usr_id);
3195 $q =
"SELECT * FROM desktop_item WHERE ".
3196 "item_id = ".$ilDB->quote($a_item_id).
" AND type = ".
3197 $ilDB->quote($a_type).
" AND user_id = ".
3198 $ilDB->quote($a_usr_id);
3199 $item_set = $ilDB->query($q);
3201 if (
$d = $item_set->fetchRow())
3252 global $ilUser, $rbacsystem, $tree, $ilDB;
3256 $q =
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3257 " FROM desktop_item AS it, object_reference AS oref ".
3258 ", object_data AS obj".
3260 "it.item_id = oref.ref_id AND ".
3261 "oref.obj_id = obj.obj_id AND ".
3262 "it.user_id = ".$ilDB->quote($user_id);
3264 $item_set = $ilDB->query($q);
3268 if ($tree->isInTree($item_rec[
"ref_id"])
3269 && $item_rec[
"type"] !=
"rolf")
3271 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3272 $par_left = $tree->getLeftValue($parent_ref);
3273 $par_left = sprintf(
"%010d", $par_left);
3278 $items[$par_left.$title.$item_rec[
"ref_id"]] =
3279 array(
"ref_id" => $item_rec[
"ref_id"],
3280 "obj_id" => $item_rec[
"obj_id"],
3281 "type" => $item_rec[
"type"],
3283 "description" =>
$desc,
3284 "parent_ref" => $parent_ref);
3291 if (!is_array($a_types))
3293 $a_types = array($a_types);
3296 $foundsurveys = array();
3297 foreach($a_types as $a_type)
3299 $q =
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item AS it, object_reference AS oref ".
3300 ", object_data AS obj WHERE ".
3301 "it.item_id = oref.ref_id AND ".
3302 "oref.obj_id = obj.obj_id AND ".
3303 "it.type = ".$ilDB->quote($a_type).
" AND ".
3304 "it.user_id = ".$ilDB->quote($user_id).
" ".
3307 $item_set = $ilDB->query($q);
3312 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3313 array(
"ref_id" => $item_rec[
"ref_id"],
3314 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3332 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3338 $a_time = date(
"Y-m-d H:i:s", time());
3341 $st = $ilDB->prepare(
"SELECT * FROM personal_clipboard WHERE ".
3342 "parent = ? AND item_id = ? AND type = ? AND user_id = ?",
3343 array(
"integer",
"integer",
"text",
"integer"));
3344 $item_set = $ilDB->execute($st,
3345 array(0, $a_item_id, $a_type, $this->
getId()));
3348 if (!
$d = $item_set->fetchRow())
3350 $st = $ilDB->prepareManip(
"INSERT INTO personal_clipboard ".
3351 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3353 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"));
3355 array($a_item_id, $a_type, $this->
getId(), $a_title, $a_parent, $a_time, $a_order_nr));
3359 $st = $ilDB->prepareManip(
"UPDATE personal_clipboard SET insert_time = ? ".
3360 "WHERE user_id = ? AND item_id = ? AND type = ? AND parent = 0",
3361 array(
"timestamp",
"integer",
"integer",
"text"));
3362 $ilDB->execute($st, array($a_time, $this->
getId(), $a_item_id, $a_type));
3373 $st = $ilDB->prepare(
"SELECT * FROM personal_clipboard WHERE ".
3374 "parent = ? AND type = ? AND user_id = ?",
3375 array(
"integer",
"text",
"integer"));
3376 $set = $ilDB->execute($st,
3377 array(0, $a_type, $this->
getId()));
3378 if ($rec = $ilDB->fetchAssoc($set))
3393 $st = $ilDB->prepareManip(
"DELETE FROM personal_clipboard WHERE ".
3394 "type = ? AND user_id = ?",
3395 array(
"text",
"integer"));
3397 array($a_type, $this->
getId()));
3408 if ($a_top_nodes_only)
3410 $par =
" AND parent = ".$ilDB->quote(0).
" ";
3413 $type_str = ($a_type !=
"")
3414 ?
" AND type = ".$ilDB->quote($a_type).
" "
3416 $q =
"SELECT * FROM personal_clipboard WHERE ".
3417 "user_id = ".$ilDB->quote($this->
getId()).
" ".
3419 " ORDER BY order_nr";
3420 $objs = $this->ilias->db->query($q);
3424 if ($obj[
"type"] ==
"mob")
3428 $objects[] = array (
"id" => $obj[
"item_id"],
3429 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3430 "insert_time" => $obj[
"insert_time"]);
3440 global $ilDB, $ilUser;
3442 $st = $ilDB->prepare(
"SELECT * FROM personal_clipboard WHERE ".
3443 "user_id = ? AND parent = ? AND insert_time = ? ".
3444 " ORDER BY order_nr",
3445 array(
"integer",
"integer",
"timestamp"));
3446 $objs = $ilDB->execute($st,
3447 array($ilUser->getId(), $a_parent, $a_insert_time));
3451 if ($obj[
"type"] ==
"mob")
3455 $objects[] = array (
"id" => $obj[
"item_id"],
3456 "type" => $obj[
"type"],
"title" => $obj[
"title"]);
3473 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3474 "item_id = ".$ilDB->quote($a_id).
" AND ".
3475 "type = ".$ilDB->quote($a_type);
3476 $user_set = $ilDB->query($q);
3480 $users[] = $user_rec[
"user_id"];
3497 $q =
"DELETE FROM personal_clipboard WHERE ".
3498 "item_id = ".$ilDB->quote($a_item_id).
" AND type = ".$ilDB->quote($a_type).
" ".
3499 " AND user_id = ".$ilDB->quote($this->
getId());
3500 $this->ilias->db->query($q);
3507 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3508 $ilDB->quote($i2_id);
3510 $res = $this->ilias->db->query($query);
3542 $this->auth_mode = $a_str;
3556 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3569 $this->ext_account = $a_str;
3581 return $this->ext_account;
3599 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3602 $or =
"OR auth_mode = 'default' ";
3608 $query =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3609 "WHERE auth_mode = ".$ilDB->quote($a_auth_mode).
" ".
3612 $res = $ilDB->query($query);
3615 if($row->auth_mode ==
'default')
3617 $accounts[$row->usr_id] = $row->login;
3621 $accounts[$row->usr_id] = $row->ext_account;
3624 return $accounts ? $accounts : array();
3638 if(!is_array($a_usr_ids))
3643 $query =
"UPDATE usr_data SET active = ".$ilDB->quote($a_status ? 1 : 0).
" ".
3645 $ilDB->query($query);
3663 $query =
"SELECT auth_mode FROM usr_data ".
3664 "WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ";
3665 $res = $ilDB->query($query);
3668 return $row->auth_mode;
3684 $r = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
3685 " ext_account = ".$ilDB->quote($a_account).
" AND ".
3686 " auth_mode = ".$ilDB->quote($a_auth));
3689 return $usr[
"login"];
3693 $query =
"SELECT login FROM usr_data ".
3694 "WHERE login = ".$ilDB->quote($a_account).
" ".
3695 "AND auth_mode = ".$ilDB->quote($a_auth).
" ";
3696 $res = $ilDB->query($query);
3700 return $usr[
'login'];
3707 $query =
"SELECT login FROM usr_data ".
3708 "WHERE ext_account = ".$ilDB->quote($a_account).
" ".
3709 "AND auth_mode = 'default'";
3711 $res = $ilDB->query($query);
3714 return $usr[
"login"];
3718 $query =
"SELECT login FROM usr_data ".
3719 "WHERE (login =".$ilDB->quote($a_account).
" AND ext_account = '') ".
3720 "AND auth_mode = 'default'";
3722 $res = $ilDB->query($query);
3725 return $usr[
"login"];
3738 $r = $ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3739 "GROUP BY auth_mode");
3743 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3760 if ($ilSetting->get(
"auth_mode") == 1)
3762 $or_str =
" OR auth_mode = ".$ilDB->quote(
"default");
3765 $usr_set = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
3766 " email = ".$ilDB->quote($a_email).
" AND ".
3767 " (auth_mode = ".$ilDB->quote(
"local").$or_str.
")");
3773 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3790 $image_dir = $webspace_dir.
"/usr_images";
3791 $store_file =
"usr_".$obj_id.
".".
"jpg";
3792 $target_file = $image_dir.
"/$store_file";
3794 chmod($tmp_file, 0770);
3798 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3799 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3800 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3801 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3803 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 200x200 -quality 100 JPEG:$show_file");
3804 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
3805 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
3806 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
3831 $a_prevent_no_photo_image =
false)
3836 $query =
"SELECT * FROM usr_pref WHERE ".
3837 "keyword IN ('public_upload','public_profile') ".
3838 "AND usr_id = ".$ilDB->quote($a_usr_id);
3840 $res = $ilDB->query($query);
3843 switch ($row[
'keyword'])
3845 case 'public_upload' :
3846 $upload = $row[
'value'] ==
'y';
3848 case 'public_profile' :
3849 $profile = $row[
'value'] ==
'y';
3855 if(defined(
'ILIAS_MODULE'))
3857 $webspace_dir = (
'.'.$webspace_dir);
3859 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
3861 $image_dir = $webspace_dir.
"/usr_images";
3863 if ($a_size ==
'big')
3865 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
3869 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
3873 if((($upload && $profile) || $a_force_pic)
3874 && @is_file($thumb_file))
3876 $file = $thumb_file.
"?t=".rand(1, 99999);
3880 if (!$a_prevent_no_photo_image)
3895 $image_dir = $webspace_dir.
"/usr_images";
3896 $file = $image_dir.
"/usr_".$this->getID().
".".
"jpg";
3897 $thumb_file = $image_dir.
"/usr_".$this->getID().
"_small.jpg";
3898 $xthumb_file = $image_dir.
"/usr_".$this->getID().
"_xsmall.jpg";
3899 $xxthumb_file = $image_dir.
"/usr_".$this->getID().
"_xxsmall.jpg";
3900 $upload_file = $image_dir.
"/upload_".$this->getID();
3903 $this->
setPref(
"profile_image",
"");
3906 if (@is_file(
$file))
3910 if (@is_file($thumb_file))
3912 unlink($thumb_file);
3914 if (@is_file($xthumb_file))
3916 unlink($xthumb_file);
3918 if (@is_file($xxthumb_file))
3920 unlink($xxthumb_file);
3922 if (@is_file($upload_file))
3924 unlink($upload_file);
3931 if(!is_array($a_data))
3935 foreach($a_data as $field =>
$data)
3937 #$new_data[$field] = ilUtil::stripSlashes($data);
3939 $this->user_defined_data[$field] =
$data;
3941 #$this->user_defined_data = $new_data;
3948 return $this->user_defined_data ? $this->user_defined_data : array();
3957 foreach($this->user_defined_data as $field => $value)
3959 if($field !=
'usr_id')
3961 $fields .= (
"`".$field.
"` = ".$ilDB->quote($value).
", ");
3965 $query =
"REPLACE INTO usr_defined_data ".
3967 "usr_id = ".$ilDB->quote($this->
getId());
3969 $this->db->query($query);
3977 $query =
"SELECT * FROM usr_defined_data ".
3978 "WHERE usr_id = ".$ilDB->quote($this->
getId());
3980 $res = $this->db->query($query);
3983 $this->user_defined_data = $row;
3992 $query =
"INSERT INTO usr_defined_data ".
3993 "SET usr_id = ".$ilDB->quote($this->
getId());
3994 $this->db->query($query);
4003 $query =
"DELETE FROM usr_defined_data ".
4004 "WHERE usr_id = ".$ilDB->quote($this->
getId());
4005 $this->db->query($query);
4017 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
4018 include_once
'classes/class.ilFormat.php';
4020 global
$lng,$rbacreview;
4022 $language =& $a_language;
4023 $language->loadLanguageModule(
'registration');
4024 $language->loadLanguageModule(
'crs');
4027 $body .= ($language->txt(
"login").
": ".$this->
getLogin().
"\n");
4031 $body .= ($language->txt(
"title").
": ".$this->
getUTitle().
"\n");
4036 $language->txt(
'gender_m') :
4037 $language->txt(
'gender_f');
4038 $body .= ($language->txt(
"gender").
": ".
$gender.
"\n");
4042 $body .= ($language->txt(
"firstname").
": ".$this->
getFirstname().
"\n");
4046 $body .= ($language->txt(
"lastname").
": ".$this->
getLastname().
"\n");
4050 $body .= ($language->txt(
"institution").
": ".$this->
getInstitution().
"\n");
4054 $body .= ($language->txt(
"department").
": ".$this->
getDepartment().
"\n");
4058 $body .= ($language->txt(
"street").
": ".$this->
getStreet().
"\n");
4062 $body .= ($language->txt(
"city").
": ".$this->
getCity().
"\n");
4066 $body .= ($language->txt(
"zipcode").
": ".$this->
getZipcode().
"\n");
4070 $body .= ($language->txt(
"country").
": ".$this->
getCountry().
"\n");
4074 $body .= ($language->txt(
"phone_office").
": ".$this->
getPhoneOffice().
"\n");
4078 $body .= ($language->txt(
"phone_home").
": ".$this->
getPhoneHome().
"\n");
4082 $body .= ($language->txt(
"phone_mobile").
": ".$this->
getPhoneMobile().
"\n");
4084 if(strlen($this->
getFax()))
4086 $body .= ($language->txt(
"fax").
": ".$this->
getFax().
"\n");
4090 $body .= ($language->txt(
"email").
": ".$this->
getEmail().
"\n");
4094 $body .= ($language->txt(
"hobby").
": ".$this->
getHobby().
"\n");
4098 $body .= ($language->txt(
"referral_comment").
": ".$this->
getComment().
"\n");
4102 $body .= ($language->txt(
"matriculation").
": ".$this->
getMatriculation().
"\n");
4111 $body .= ($language->txt(
"create_date").
": ".$date.
"\n");
4114 foreach($rbacreview->getGlobalRoles() as $role)
4116 if($rbacreview->isAssigned($this->getId(),$role))
4123 $body .= ($language->txt(
'reg_role_info').
': '.implode(
',',$gr).
"\n");
4129 $body .= ($language->txt(
'time_limit').
": ".$language->txt(
'crs_unlimited').
"\n");
4139 $body .= $language->txt(
'time_limit').
': '.$period;
4152 $var =
"im_".$a_im_type;
4153 $this->$var = $a_im_id;
4158 $var =
"im_".$a_im_type;
4164 $this->delicious = $a_delicious;
4181 $query =
"SELECT feed_hash from usr_data WHERE usr_id = ".
4182 $ilDB->quote($a_user_id);
4183 $set = $ilDB->query($query);
4186 if (strlen($rec[
"feed_hash"]) == 32)
4188 return $rec[
"feed_hash"];
4192 $hash = md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4193 $query =
"UPDATE usr_data SET feed_hash = ".
4194 $ilDB->quote($hash).
4195 " WHERE usr_id = ".$ilDB->quote($a_user_id);
4196 $ilDB->query($query);
4216 $query =
"SELECT value from usr_pref WHERE usr_id = ".
4217 $ilDB->quote($a_user_id) .
" AND keyword=\"priv_feed_pass\"";
4218 $set = $ilDB->query($query);
4222 return $rec[
"value"];
4237 if ($a_user_id > 0 )
4239 if ($a_password==
"")
4241 $statement = $ilDB->prepare(
"REPLACE INTO usr_pref (usr_id,keyword,value) VALUES (? ,? , ?)");
4242 $data = array($a_user_id,
"priv_feed_pass",
"");
4246 $statement = $ilDB->prepare(
"REPLACE INTO usr_pref (usr_id,keyword,value) VALUES (? ,? , ?)");
4247 $data = array($a_user_id,
"priv_feed_pass", md5($a_password));
4249 $statement->execute(
$data);
4266 if ($a_user_id == 0)
4272 $clause =
"AND usr_id != ".$ilDB->quote($a_user_id).
" ";
4275 $q =
"SELECT DISTINCT login FROM usr_data ".
4276 "WHERE login = ".$ilDB->quote($a_login).
" ".$clause;
4277 $r = $ilDB->query($q);
4279 if ($r->numRows() == 1)
4300 $query =
"SELECT * FROM usr_data ".
4301 "WHERE ext_account = ".$ilDB->quote($a_external_account).
" ".
4302 "AND auth_mode = ".$ilDB->quote($a_auth_mode);
4303 $res = $ilDB->query($query);
4304 return $res->numRows() ?
true :
false;
4315 global $ilDB, $rbacreview;
4318 $ids = $rbacreview->assignedUsers($role_id);
4320 if (count ($ids) == 0)
4323 $query =
"SELECT usr_data.*, usr_pref.value AS language
4325 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = 'language'
4326 WHERE usr_data.usr_id IN (".implode(
',',$ids).
")";
4330 $query .=
" AND usr_data.active = ".$ilDB->quote(
$active);
4332 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4336 $r = $ilDB->query($query);
4355 $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 = 'language' WHERE 1 ";
4358 $query .=
" AND usr_data.active = ".$ilDB->quote(
$active);
4361 $query .=
" AND usr_data.time_limit_owner = ".$ilDB->quote(
$ref_id);
4363 $query .=
" AND usr_data.usr_id != '".ANONYMOUS_USER_ID.
"'";
4365 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4367 $result = $ilDB->query($query);
4371 array_push(
$data, $row);
4396 global $rbacadmin, $rbacreview, $ilDB;
4400 foreach ($a_mem_ids as $mem_id) {
4401 $ids [] = $ilDB->quote($mem_id);
4404 $query =
"SELECT usr_data.*, usr_pref.value AS language
4406 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = 'language'
4407 WHERE usr_data.usr_id IN (".implode(
',',$ids).
")
4408 AND usr_data.usr_id != '".ANONYMOUS_USER_ID.
"'";
4411 $query .=
" AND active = '$active'";
4414 $query .=
" AND usr_data.time_limit_owner = ".$ilDB->quote($timelimitowner);
4416 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4418 $r = $ilDB->query($query);
4425 return $mem_arr ? $mem_arr : array();
4439 if (is_array($a_internalids)) {
4440 foreach ($a_internalids as $internalid) {
4441 if (is_numeric ($internalid))
4443 $ids[] = $internalid;
4448 if (is_numeric($parsedid) && $parsedid > 0)
4455 if (count($ids) == 0)
4458 $query =
"SELECT usr_data.*, usr_pref.value AS language
4461 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = 'language'
4462 WHERE usr_data.usr_id IN (".join(
",",$ids).
")";
4464 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4467 $r = $ilDB->query($query);
4488 $q =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($user_id);
4489 $r = $ilDB->query($q);
4493 $prefs[$row[
"keyword"]] = $row[
"value"];
4504 $query =
"UPDATE usr_data SET usr_data.login_attempts = 0 WHERE usr_data.usr_id = ?";
4505 $statement = $ilDB->prepareManip( $query, array(
'integer') );
4506 $affected = $ilDB->execute( $statement, array($a_usr_id) );
4508 if($affected)
return true;
4516 $query =
"SELECT usr_data.login_attempts FROM usr_data WHERE usr_data.usr_id = ?";
4517 $statement = $ilDB->prepare( $query, array(
'integer') );
4518 $result = $ilDB->execute( $statement, array($a_usr_id) );
4519 $record = $ilDB->fetchAssoc(
$result );
4529 $query =
"UPDATE usr_data SET usr_data.login_attempts = (usr_data.login_attempts + 1) WHERE usr_data.usr_id = ?";
4530 $statement = $ilDB->prepareManip( $query, array(
'integer') );
4531 $affected = $ilDB->execute( $statement, array($a_usr_id) );
4533 if($affected)
return true;
4541 $query =
"UPDATE usr_data SET usr_data.active = 0 WHERE usr_data.usr_id = ?";
4542 $statement = $ilDB->prepareManip( $query, array(
'integer') );
4543 $affected = $ilDB->execute( $statement, array($a_usr_id) );
4545 if($affected)
return true;
4555 return $this->
getPref(
"public_profile") ==
"y";