4 define (
"IL_PASSWD_PLAIN",
"plain");
5 define (
"IL_PASSWD_MD5",
"md5");
6 define (
"IL_PASSWD_CRYPT",
"crypt");
9 require_once
"classes/class.ilObject.php";
10 require_once
'Services/User/exceptions/class.ilUserException.php';
138 function ilObjUser($a_user_id = 0, $a_call_by_reference =
false)
147 $this->
ilObject($a_user_id, $a_call_by_reference);
148 $this->auth_mode =
"default";
158 $this->
setId($a_user_id);
165 $this->prefs = array();
167 $this->prefs[
"language"] = $this->ilias->ini->readVariable(
"language",
"default");
170 $this->skin = $this->ilias->ini->readVariable(
"layout",
"skin");
173 $this->prefs[
"show_users_online"] =
"y";
176 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
193 $r = $ilDB->queryF(
"SELECT * FROM usr_data ".
194 "WHERE usr_id= %s", array(
"integer"), array($this->
id));
196 if (
$data = $ilDB->fetchAssoc($r))
200 if (
$data[
"passwd"] ==
"" &&
$data[
"i2passwd"] !=
"")
210 unset(
$data[
"i2passw"]);
226 if ($this->prefs[
"language"] ==
"")
228 $this->prefs[
"language"] = $this->oldPrefs[
"language"];
232 include_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
233 if ($this->prefs[
"skin"] ==
"" ||
236 $this->prefs[
"skin"] = $this->oldPrefs[
"skin"];
239 $this->skin = $this->prefs[
"skin"];
242 if ($this->prefs[
"style"] ==
"" ||
246 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
249 if (empty($this->prefs[
"hits_per_page"]))
251 $this->prefs[
"hits_per_page"] = 10;
257 $ilErr->raiseError(
"<b>Error: There is no dataset with id ".
258 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
259 "<br />Line: ".__LINE__, $ilErr->FATAL);
278 if (! $a_data[
"passwd_type"])
280 $ilErr->raiseError(
"<b>Error: passwd_type missing in function assignData(). ".
281 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: "
282 .__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
284 if ($a_data[
"passwd"] !=
"********" and strlen($a_data[
'passwd']))
286 $this->
setPasswd($a_data[
"passwd"], $a_data[
"passwd_type"]);
294 if (!is_array($a_data[
'birthday']))
307 $this->
setCity($a_data[
"city"]);
314 $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 $insert_array = array(
403 "usr_id" => array(
"integer", $this->
id),
404 "login" => array(
"text", $this->login),
405 $pw_field => array(
"text", $pw_value),
406 "firstname" => array(
"text", $this->firstname),
407 "lastname" => array(
"text", $this->lastname),
408 "title" => array(
"text", $this->utitle),
409 "gender" => array(
"text", $this->gender),
410 "email" => array(
"text", trim($this->email)),
411 "hobby" => array(
"text", (
string) $this->hobby),
412 "institution" => array(
"text", $this->institution),
413 "department" => array(
"text", $this->department),
414 "street" => array(
"text", $this->street),
415 "city" => array(
"text", $this->city),
416 "zipcode" => array(
"text", $this->zipcode),
417 "country" => array(
"text", $this->country),
418 "sel_country" => array(
"text", $this->sel_country),
419 "phone_office" => array(
"text", $this->phone_office),
420 "phone_home" => array(
"text", $this->phone_home),
421 "phone_mobile" => array(
"text", $this->phone_mobile),
422 "fax" => array(
"text", $this->fax),
424 "last_login" => array(
"timestamp", null),
425 "last_update" => array(
"timestamp",
ilUtil::now()),
426 "create_date" => array(
"timestamp",
ilUtil::now()),
427 "referral_comment" => array(
"text", $this->referral_comment),
428 "matriculation" => array(
"text", $this->matriculation),
429 "client_ip" => array(
"text", $this->client_ip),
430 "approve_date" => array(
"timestamp", $this->approve_date),
431 "agree_date" => array(
"timestamp", $this->agree_date),
432 "active" => array(
"integer", (
int) $this->active),
437 "auth_mode" => array(
"text", $this->
getAuthMode()),
440 "im_icq" => array(
"text", $this->im_icq),
441 "im_yahoo" => array(
"text", $this->im_yahoo),
442 "im_msn" => array(
"text", $this->im_msn),
443 "im_aim" => array(
"text", $this->im_aim),
444 "im_skype" => array(
"text", $this->im_skype),
445 "delicious" => array(
"text", $this->delicious),
446 "latitude" => array(
"text", $this->latitude),
447 "longitude" => array(
"text", $this->longitude),
448 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
449 "last_password_change" => array(
"integer", (
int) $this->last_password_change_ts),
450 "im_jabber" => array(
"text", $this->im_jabber),
451 "im_voip" => array(
"text", $this->im_voip)
453 $ilDB->insert(
"usr_data", $insert_array);
461 include_once (
"Services/Mail/classes/class.ilMailbox.php");
463 $mbox->createDefaultFolder();
465 include_once
"Services/Mail/classes/class.ilMailOptions.php";
467 $mail_options->createMailOptionsEntry();
470 include_once
"./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php";
472 $bmf->createNewBookmarkTree();
486 $update_array = array(
487 "gender" => array(
"text", $this->gender),
488 "title" => array(
"text", $this->utitle),
489 "firstname" => array(
"text", $this->firstname),
490 "lastname" => array(
"text", $this->lastname),
491 "email" => array(
"text", trim($this->email)),
493 "hobby" => array(
"text", $this->hobby),
494 "institution" => array(
"text", $this->institution),
495 "department" => array(
"text", $this->department),
496 "street" => array(
"text", $this->street),
497 "city" => array(
"text", $this->city),
498 "zipcode" => array(
"text", $this->zipcode),
499 "country" => array(
"text", $this->country),
500 "sel_country" => array(
"text", $this->sel_country),
501 "phone_office" => array(
"text", $this->phone_office),
502 "phone_home" => array(
"text", $this->phone_home),
503 "phone_mobile" => array(
"text", $this->phone_mobile),
504 "fax" => array(
"text", $this->fax),
505 "referral_comment" => array(
"text", $this->referral_comment),
506 "matriculation" => array(
"text", $this->matriculation),
507 "client_ip" => array(
"text", $this->client_ip),
508 "approve_date" => array(
"timestamp", $this->approve_date),
509 "active" => array(
"integer", $this->active),
516 "auth_mode" => array(
"text", $this->
getAuthMode()),
518 "im_icq" => array(
"text", $this->im_icq),
519 "im_yahoo" => array(
"text", $this->im_yahoo),
520 "im_msn" => array(
"text", $this->im_msn),
521 "im_aim" => array(
"text", $this->im_aim),
522 "im_skype" => array(
"text", $this->im_skype),
523 "delicious" => array(
"text", $this->delicious),
524 "latitude" => array(
"text", $this->latitude),
525 "longitude" => array(
"text", $this->longitude),
526 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
527 "last_password_change" => array(
"integer", $this->last_password_change_ts),
528 "im_jabber" => array(
"text", $this->im_jabber),
529 "im_voip" => array(
"text", $this->im_voip),
533 if (isset($this->agree_date) && (strtotime($this->agree_date) !==
false || $this->agree_date == null))
535 $update_array[
"agree_date"] = array(
"timestamp", $this->agree_date);
537 switch ($this->passwd_type)
540 if(strlen($this->passwd))
542 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
543 $update_array[
"passwd"] = array(
"text", (
string) md5($this->passwd));
547 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
548 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
553 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
554 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
558 $update_array[
"i2passwd"] = array(
"text", (
string) $this->passwd);
559 $update_array[
"passwd"] = array(
"text", (
string)
"");
563 $ilErr->raiseError(
"<b>Error: passwd_type missing in function update()".$this->
id.
"!</b><br />class: ".
564 get_class($this).
"<br />Script: ".__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
567 $ilDB->update(
"usr_data", $update_array, array(
"usr_id" => array(
"integer", $this->
id)));
579 $ilAppEventHandler->raise(
"Services/User",
"afterUpdate",
580 array(
"user_obj" => $this));
592 $ilDB->manipulateF(
"UPDATE usr_data SET agree_date = ".$ilDB->now().
593 " WHERE usr_id = %s", array(
"integer"), array($this->
getId()));
599 private function _lookup($a_user_id, $a_field)
603 $res = $ilDB->queryF(
"SELECT ".$a_field.
" FROM usr_data WHERE usr_id = %s",
604 array(
"integer"), array($a_user_id));
606 while($set = $ilDB->fetchAssoc(
$res))
608 return $set[$a_field];
620 $set = $ilDB->queryF(
"SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s",
621 array(
"integer"), array($a_user_id));
623 if ($rec = $ilDB->fetchAssoc($set))
629 if ($rec[
"firstname"])
633 if ($rec[
"lastname"])
685 $res = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
686 array(
"integer"), array($a_user_id));
687 $user_rec = $ilDB->fetchAssoc(
$res);
688 return array(
"user_id" => $a_user_id,
689 "firstname" => $user_rec[
"firstname"],
690 "lastname" => $user_rec[
"lastname"],
691 "title" => $user_rec[
"title"],
692 "login" => $user_rec[
"login"]);
702 $res = $ilDB->queryF(
"SELECT * FROM usr_data WHERE usr_id = %s",
703 array(
"integer"), array($a_user_id));
704 $user_rec = $ilDB->fetchAssoc(
$res);
731 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data WHERE login = %s",
732 array(
"text"), array($a_user_str));
733 $user_rec = $ilDB->fetchAssoc(
$res);
734 return $user_rec[
"usr_id"];
755 $ilDB->manipulateF(
"UPDATE usr_data SET ".
756 "last_login = ".$ilDB->now().
757 " WHERE usr_id = %s",
758 array(
"integer"), array($this->
id));
772 $this->passwd = $new_md5;
774 $ilDB->manipulateF(
"UPDATE usr_data SET ".
777 array(
"text",
"integer"), array($this->passwd, $this->
id));
794 if (func_num_args() != 3)
799 if (!isset($a_old) or !isset($a_new1) or !isset($a_new2))
804 if ($a_new1 != $a_new2)
810 if ($a_new1 ==
"" || $a_old ==
"")
816 switch ($this->passwd_type)
819 if ($a_old != $this->passwd)
826 if (md5($a_old) != $this->passwd)
841 $this->passwd = md5($a_new1);
844 $ilDB->manipulateF(
"UPDATE usr_data SET ".
847 array(
"text",
"integer"), array($this->passwd, $this->
id));
863 if (func_num_args() != 2)
868 if (!isset($a_new1) or !isset($a_new2))
873 if ($a_new1 != $a_new2)
879 $this->passwd = md5($a_new1);
882 $ilDB->manipulateF(
"UPDATE usr_data SET ".
885 array(
"text",
"integer"),
886 array($this->passwd, $this->
id));
896 return (crypt($a_passwd,substr($a_passwd,0,2)));
906 $user_set = $ilDB->queryF(
"SELECT i2passwd FROM usr_data ".
907 "WHERE login = %s", array(
"text"), array($a_user_login));
908 if ($user_rec = $ilDB->fetchAssoc($user_set))
910 if ($user_rec[
"i2passwd"] !=
"")
926 $user_set = $ilDB->queryF(
"SELECT i2passwd FROM usr_data ".
927 "WHERE login = %s", array(
"text"), array($a_user_login));
928 if ($user_rec = $ilDB->fetchAssoc($user_set))
932 $ilDB->manipulateF(
"UPDATE usr_data SET passwd = %s, i2passwd = %s".
934 array(
"text",
"text",
"text"),
935 array(md5($a_pw),
"", $a_user));
957 $res = $ilDB->queryF(
'
958 SELECT * FROM loginname_history
960 array(
'text'), array($a_login));
962 return $ilDB->fetchAssoc(
$res) ?
true :
false;
981 $ilDB->setLimit(1, 0);
982 $res = $ilDB->queryF(
'
983 SELECT login, history_date FROM loginname_history
984 WHERE usr_id = %s ORDER BY history_date DESC',
985 array(
'integer'), array($a_usr_id));
1005 if(func_num_args() != 1)
1010 if(!isset($a_login))
1016 if($a_login == self::_lookupLogin($this->
getId()))
1028 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1029 (int)$ilSetting->get(
'prevent_reuse_of_loginnames') &&
1032 throw new ilUserException($this->lng->txt(
'loginname_already_exists'));
1034 else if((
int)$ilSetting->get(
'allow_change_loginname') &&
1035 (int)$ilSetting->get(
'loginname_change_blocking_time') &&
1036 is_array($last_history_entry) &&
1037 $last_history_entry[1] + (int)$ilSetting->get(
'loginname_change_blocking_time') > time())
1039 include_once
'Services/Calendar/classes/class.ilDate.php';
1042 $this->lng->txt(
'changing_loginname_not_possible_info'),
1046 new ilDateTime(($last_history_entry[1] + (
int)$ilSetting->get(
'loginname_change_blocking_time')),
IL_CAL_UNIX))
1053 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1054 (int)$ilSetting->get(
'create_history_loginname'))
1060 $this->login = $a_login;
1062 $ilDB->manipulateF(
'
1066 array(
'text',
'integer'), array($this->
getLogin(), $this->
getId()));
1081 $this->
setPref($a_keyword, $a_value);
1104 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
1105 array(
"integer",
"text"), array($a_user_id, $a_keyword));
1117 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s",
1118 array(
"integer"), array($a_user_id));
1129 if (strlen($a_value))
1131 $ilDB->manipulateF(
"INSERT INTO usr_pref (usr_id, keyword, value) VALUES (%s,%s,%s)",
1132 array(
"integer",
"text",
"text"), array($a_usr_id, $a_keyword, $a_value));
1145 foreach ($this->prefs as $keyword => $value)
1159 if($tz = $this->
getPref(
'user_tz'))
1165 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1167 return $settings->getDefaultTimeZone();
1179 if($format = $this->
getPref(
'time_format'))
1185 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1187 return $settings->getDefaultTimeFormat();
1199 if($format = $this->
getPref(
'date_format'))
1205 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1207 return $settings->getDefaultDateFormat();
1219 if ($a_keyword !=
"")
1221 $this->prefs[$a_keyword] = $a_value;
1232 if (array_key_exists($a_keyword, $this->prefs))
1234 return $this->prefs[$a_keyword];
1246 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
" ".
1247 "AND keyword = ".$ilDB->quote($a_keyword,
"text");
1265 if (is_array($this->prefs))
1280 global $rbacadmin,
$ilDB;
1283 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1285 $mapping->deleteUser($this->
getId());
1288 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1291 $mailbox->updateMailsOfDeletedUser();
1294 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1296 $costum_block->setContextObjId($this->
getId());
1297 $costum_block->setContextObjType(
"user");
1298 $c_blocks = $costum_block->queryBlocksForContext();
1299 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1300 foreach($c_blocks as $c_block)
1302 if ($c_block[
"type"] ==
"pdfeed")
1311 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1315 $ilDB->manipulateF(
"DELETE FROM usr_data WHERE usr_id = %s",
1316 array(
"integer"), array($this->
getId()));
1322 include_once(
"./Services/Authentication/classes/class.ilSession.php");
1326 $rbacadmin->removeUser($this->
getId());
1330 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1331 $ilDB->quote($this->
getId(),
"integer");
1332 $ilDB->manipulate($q);
1334 $q =
"DELETE FROM bookmark_data WHERE user_id = ".
1335 $ilDB->quote($this->
getId(),
"integer");
1336 $ilDB->manipulate($q);
1339 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1343 include_once
'./classes/class.ilLinkCheckNotify.php';
1347 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1351 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1354 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1358 include_once
'Modules/Scorm2004/classes/ilSCORM13Package.php';
1362 include_once
'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
1366 include_once
"./Services/Notification/classes/class.ilNotification.php";
1380 global $ilAppEventHandler;
1381 $ilAppEventHandler->raise(
1382 'Services/User',
'deleteUser', array(
'usr_id' => $this->
getId())
1399 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1401 $this->fullname =
"";
1407 elseif ($this->utitle)
1409 $this->fullname = $this->utitle.
" ";
1416 elseif ($this->firstname)
1418 $this->fullname .= $this->firstname.
" ";
1450 if (strlen($this->fullname) <= $a_max_strlen)
1455 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1457 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1460 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1465 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1484 $q =
"SELECT * FROM lo_access ".
1485 "WHERE usr_id= ".$ilDB->quote((
int) $this->
id,
"integer").
" ".
1486 "ORDER BY timestamp DESC";
1487 $rst = $ilDB->query($q);
1491 while($record = $ilDB->fetchObject($rst))
1494 "timestamp" => $record->timestamp,
1495 "usr_id" => $record->usr_id,
1496 "lm_id" => $record->lm_id,
1497 "obj_id" => $record->obj_id,
1498 "lm_title" => $record->lm_title);
1514 $q =
"SELECT * FROM lo_access ".
1515 "WHERE usr_id= ".$ilDB->quote((
int) $this->
id,
"integer").
" ";
1516 $rst = $ilDB->query($q);
1523 "timestamp" => $record->timestamp,
1524 "usr_id" => $record->usr_id,
1525 "lm_id" => $record->lm_id,
1526 "obj_id" => $record->obj_id,
1527 "lm_title" => $record->lm_title);
1544 if($a_username ==
'root')
1549 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
1550 "WHERE login = %s AND NOT agree_date IS NULL",
1551 array(
"text"), array($a_username));
1552 return $ilDB->fetchAssoc(
$res) ?
true :
false;
1561 if ($this->agree_date != null || $this->login ==
"root")
1575 $this->login = $a_str;
1594 $this->passwd = $a_str;
1595 $this->passwd_type = $a_type;
1627 $this->gender = substr($a_str,-1);
1648 $this->utitle = $a_str;
1669 $this->firstname = $a_str;
1688 $this->lastname = $a_str;
1707 $this->institution = $a_str;
1726 $this->department = $a_str;
1745 $this->street = $a_str;
1764 $this->city = $a_str;
1783 $this->zipcode = $a_str;
1803 $this->country = $a_str;
1823 $this->sel_country = $a_val;
1843 $this->phone_office = $a_str;
1862 $this->phone_home = $a_str;
1881 $this->phone_mobile = $a_str;
1900 $this->fax = $a_str;
1919 $this->client_ip = $a_str;
1938 $this->matriculation = $a_str;
1960 $query =
"SELECT matriculation FROM usr_data ".
1961 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1964 return $row->matriculation ?
$row->matriculation :
'';
1974 $this->email = $a_str;
1993 $this->hobby = $a_str;
2012 $this->
setPref(
"language",$a_str);
2023 return $this->prefs[
"language"];
2036 $this->
setPref(
"disk_quota",$a_disk_quota);
2050 return $this->prefs[
"disk_quota"] ? $this->prefs[
"disk_quota"] : 0;
2055 $this->last_password_change_ts = $a_last_password_change_ts;
2068 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
2069 $ilDB->quote($a_usr_id,
"integer").
" AND keyword = ".
2070 $ilDB->quote(
'language',
"text");
2071 $r = $ilDB->query($q);
2073 while(
$row = $ilDB->fetchAssoc($r))
2075 return $row[
'value'];
2086 if ($pw == md5($a_pw))
2097 $ilDB->manipulateF(
"UPDATE usr_data ".
2098 " SET ext_account = %s WHERE usr_id = %s",
2099 array(
"text",
"integer"),
2100 array($a_ext_id, $a_usr_id));
2107 $ilDB->manipulateF(
"UPDATE usr_data ".
2108 " SET auth_mode = %s WHERE usr_id = %s",
2109 array(
"text",
"integer"),
2110 array($a_auth_mode, $a_usr_id));
2129 $this->last_login = $a_str;
2139 return $this->last_login;
2149 $this->last_update = $a_str;
2163 $this->referral_comment = $a_str;
2183 $this->approve_date = $a_str;
2214 $this->agree_date = $a_str;
2257 $query =
'SELECT usr_id FROM usr_data '.
2258 'WHERE active = '.$ilDB->quote(1,
'integer').
' '.
2259 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer');
2289 if ((!empty($storedActive) && empty($currentActive)) ||
2290 (empty($storedActive) && !empty($currentActive)))
2305 return $active ?
true :
false;
2316 $this->skin = $a_str;
2321 $this->time_limit_owner = $a_owner;
2325 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2329 $this->time_limit_from = $a_from;
2333 return $this->time_limit_from ? $this->time_limit_from : time();
2337 $this->time_limit_until = $a_until;
2341 return $this->time_limit_until ? $this->time_limit_until : time();
2345 $this->time_limit_unlimited = $a_unlimited;
2349 return $this->time_limit_unlimited;
2353 return $this->time_limit_message = $a_time_limit_message;
2357 return $this->time_limit_message;
2362 $this->login_attempts = $a_login_attempts;
2385 $this->profile_incomplete = (boolean) $a_prof_inc;
2389 return $this->profile_incomplete;
2395 if( $this->
id == ANONYMOUS_USER_ID || $this->
id == SYSTEM_USER_ID )
2398 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2402 && $security->isPasswordChangeOnFirstLoginEnabled()
2413 if($this->
id == ANONYMOUS_USER_ID)
return false;
2415 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2420 $max_pass_age = $security->getPasswordMaxAge();
2421 if( $max_pass_age > 0 )
2423 $max_pass_age_ts = ( $max_pass_age * 86400 );
2425 $current_ts = time();
2427 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2436 $current_ts = time();
2438 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2439 return $password_age;
2448 $query =
"UPDATE usr_data SET usr_data.last_password_change = %s " .
2449 "WHERE usr_data.usr_id = %s";
2450 $affected = $ilDB->manipulateF(
$query,
2451 array(
'integer',
'integer'),
2453 if($affected)
return true;
2461 $query =
"UPDATE usr_data SET usr_data.last_password_change = 0 " .
2462 "WHERE usr_data.usr_id = %s";
2463 $affected = $ilDB->manipulateF(
$query, array(
'integer'),
2464 array($this->
getId()) );
2465 if($affected)
return true;
2476 $this->latitude = $a_latitude;
2496 $this->longitude = $a_longitude;
2516 $this->loc_zoom = $a_locationzoom;
2531 $this->applied_users = array();
2534 return $this->applied_users ? $this->applied_users : array();
2539 if($a_usr_id == $this->
getId())
2544 $this->applied_users = array();
2547 return in_array($a_usr_id,$this->applied_users);
2554 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2555 "WHERE time_limit_owner = %s",
2557 array($a_parent_id));
2558 while (
$row = $ilDB->fetchObject(
$res))
2560 $this->applied_users[] =
$row->usr_id;
2581 if(
$id != ANONYMOUS_USER_ID && (
int)$ilSetting->get(
'ps_prevent_simultaneous_logins') == 1 )
2583 $res = $ilDB->queryf(
'
2584 SELECT * FROM usr_session WHERE user_id = %s AND expires > %s',
2585 array(
'integer',
'integer'),
2586 array(
$id, time()));
2608 require_once (
'Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2611 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2612 require_once (
'Services/Database/classes/class.ilAuthContainerMDB2.php');
2617 $login =$ilAuth->getUsername();
2633 $set = $ilDB->queryF(
"SELECT active FROM usr_data WHERE login= %s",
2637 if ($rec = $ilDB->fetchAssoc($set))
2673 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
2674 "WHERE email = %s and active = 1",
2678 while(
$row = $ilDB->fetchObject(
$res))
2680 $ids[] =
$row->login;
2700 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2701 "WHERE email = %s", array(
"text"), array($a_email));
2704 return $row->usr_id ?
$row->usr_id : 0;
2731 static function searchUsers($a_search_str,
$active = 1, $a_return_ids_only =
false, $filter_settings = FALSE)
2736 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2738 $without_anonymous_users =
true;
2741 $join_filter =
" WHERE ";
2742 if ($filter_settings !== FALSE && strlen($filter_settings))
2744 switch ($filter_settings)
2748 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.usr_id IS NULL AND ";
2755 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.obj_id = ".
2756 "(SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") AND ";
2764 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2765 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2766 if (is_array($local_roles) && count($local_roles))
2768 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2769 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false, $local_roles).
" AND ";
2775 $rol_id =
$_SESSION[
"user_filter_data"];
2778 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2779 $ilDB->quote($rol_id,
"integer").
" AND ";
2780 $without_anonymous_users =
false;
2787 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2789 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2790 "FROM object_data,rbac_ua,usr_data ".
2791 "WHERE ".$ilDB->like(
"object_data.title",
"text",
"%".substr($a_search_str,5).
"%").
2792 " AND object_data.type = 'role' ".
2793 "AND rbac_ua.rol_id = object_data.obj_id ".
2794 "AND usr_data.usr_id = rbac_ua.usr_id ".
2795 "AND rbac_ua.usr_id != ".$illDB->quote(ANONYMOUS_USER_ID,
"integer");
2800 "(".$ilDB->like(
"usr_data.login",
"text",
"%".$a_search_str.
"%").
" ".
2801 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_search_str.
"%").
" ".
2802 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_search_str.
"%").
" ".
2803 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_search_str.
"%").
") ";
2805 if ($filter_settings !== FALSE && strlen($filter_settings))
2807 switch ($filter_settings)
2810 $query.=
" AND usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
2813 $query.=
" AND usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
2816 $query.=
" AND usr_data.time_limit_unlimited = ".$ilDB->quote(0,
"integer").
" ";
2819 $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"]));
2820 $query.=
" AND last_login < ".$ilDB->quote($date,
"timestamp").
" ";
2825 if ($without_anonymous_users)
2827 $query.=
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2830 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE)
2832 $query.=
" AND active = ".$ilDB->quote(
$active,
"integer").
" ";
2838 while (
$row = $ilDB->fetchObject(
$res))
2841 "usr_id" =>
$row->usr_id,
2842 "login" =>
$row->login,
2843 "firstname" =>
$row->firstname,
2844 "lastname" =>
$row->lastname,
2845 "email" =>
$row->email,
2846 "active" =>
$row->active);
2847 $ids[] =
$row->usr_id;
2849 if ($a_return_ids_only)
2850 return $ids ? $ids : array();
2852 return $users ? $users : array();
2867 $res = $ilDB->query(
"SELECT login FROM usr_data");
2868 while(
$row = $ilDB->fetchObject(
$res))
2870 $logins[] =
$row->login;
2872 return $logins ? $logins : array();
2886 $res = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
2887 $ilDB->in(
"usr_id", $a_user_ids,
false,
"integer"));
2888 while (
$row = $ilDB->fetchAssoc(
$res))
2890 $user_data[
"$row[usr_id]"] =
$row;
2892 return $user_data ? $user_data : array();
2907 $result_arr = array();
2911 if ($a_fields !== NULL and is_array($a_fields))
2913 if (count($a_fields) == 0)
2919 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2920 unset($a_fields[$usr_id_field]);
2922 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2924 if(in_array(
'online_time',$a_fields))
2926 $select .=
",ut_online.online_time ";
2930 $q =
"SELECT ".$select.
" FROM usr_data ";
2934 if(in_array(
'online_time',$a_fields))
2936 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2943 $q .=
"WHERE active = ".$ilDB->quote(
$active,
"integer");
2946 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
2949 $qtemp = $q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
2950 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
2951 $r = $ilDB->query($qtemp);
2952 $course_users = array();
2953 while (
$row = $ilDB->fetchAssoc($r))
2955 array_push($course_users,
$row[
"usr_id"]);
2957 if (count($course_users))
2959 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
2967 $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"]));
2968 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
2974 $q .=
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id ".
2975 "WHERE crs_members.obj_id = (SELECT obj_id FROM object_reference ".
2976 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
2984 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2985 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2986 if (is_array($local_roles) && count($local_roles))
2988 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2989 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
2994 $rol_id =
$_SESSION[
"user_filter_data"];
2997 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2998 $ilDB->quote($rol_id,
"integer");
3002 $r = $ilDB->query($q);
3004 while (
$row = $ilDB->fetchAssoc($r))
3006 $result_arr[] =
$row;
3020 $q =
"SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ".
3021 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3022 " AND up1.value= ".$ilDB->quote($a_style,
"text").
3023 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3024 " AND up2.value= ".$ilDB->quote($a_skin,
"text").
3025 " AND up1.usr_id = up2.usr_id ";
3027 $cnt_set = $ilDB->query($q);
3029 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
3031 return $cnt_rec[
"cnt"];
3041 $q =
"SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ".
3042 " WHERE up1.keyword = ".$ilDB->quote(
"style",
"text").
3043 " AND up2.keyword = ".$ilDB->quote(
"skin",
"text").
3044 " AND up1.usr_id = up2.usr_id";
3046 $sty_set = $ilDB->query($q);
3049 while($sty_rec = $ilDB->fetchAssoc($sty_set))
3051 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
3064 $q =
"SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ".
3065 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3066 " AND up1.value= ".$ilDB->quote($a_from_style,
"text").
3067 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3068 " AND up2.value= ".$ilDB->quote($a_from_skin,
"text").
3069 " AND up1.usr_id = up2.usr_id ";
3071 $usr_set = $ilDB->query($q);
3073 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3094 $item_set = $ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3095 "item_id = %s AND type = %s AND user_id = %s",
3096 array(
"integer",
"text",
"integer"),
3097 array($a_item_id, $a_type, $a_usr_id));
3100 if (!$ilDB->fetchAssoc($item_set))
3102 $ilDB->manipulateF(
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3103 " (%s,%s,%s,%s)", array(
"integer",
"text",
"integer",
"text"),
3104 array($a_item_id,$a_type,$a_usr_id,$a_par));
3107 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3135 $ilDB->manipulateF(
"UPDATE desktop_item SET parameters = %s ".
3136 " WHERE item_id = %s AND type = %s AND user_id = %s",
3137 array(
"text",
"integer",
"text",
"integer"),
3138 array($a_par, $a_item_id, $a_type, $this->
getId()));
3155 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE ".
3156 " item_id = %s AND type = %s AND user_id = %s",
3157 array(
"integer",
"text",
"integer"),
3158 array($a_item_id, $a_type, $a_usr_id));
3160 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3186 $r = $ilDB->queryF(
"SELECT user_id FROM desktop_item WHERE item_id = %s",
3187 array(
"integer"), array($a_id));
3191 while (
$row = $ilDB->fetchObject($r))
3193 $users[] =
$row->user_id;
3196 if (count($users) > 0)
3198 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE item_id = %s",
3199 array(
"integer"), array($a_id));
3218 if (self::$is_desktop_item_loaded[$a_usr_id.
":".$a_item_id])
3220 return self::$is_desktop_item_cache[$a_usr_id.
":".$a_item_id.
":".$a_type];
3222 $item_set = $ilDB->queryF(
"SELECT item_id FROM desktop_item WHERE ".
3223 "item_id = %s AND type = %s AND user_id = %s",
3224 array(
"integer",
"text",
"integer"),
3225 array($a_item_id, $a_type, $a_usr_id));
3227 if ($ilDB->fetchAssoc($item_set))
3247 if (!is_array($a_item_ids))
3252 $item_ids = array();
3253 foreach ($a_item_ids as
$id)
3255 if (!self::$is_desktop_item_loaded[$a_usr_id.
":".$id])
3259 self::$is_desktop_item_loaded[$a_usr_id.
":".
$id] =
true;
3262 if (count($item_ids) > 0)
3264 $item_set = $ilDB->query(
"SELECT item_id, type FROM desktop_item WHERE ".
3265 $ilDB->in(
"item_id", $item_ids,
false,
"integer").
3266 " AND user_id = ".$ilDB->quote($a_usr_id,
"integer"));
3267 while ($r = $ilDB->fetchAssoc($item_set))
3269 self::$is_desktop_item_cache[$a_usr_id.
":".$r[
"item_id"].
":".$r[
"type"]]
3300 global $ilUser, $rbacsystem, $tree,
$ilDB;
3304 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3305 " FROM desktop_item it, object_reference oref ".
3306 ", object_data obj".
3308 "it.item_id = oref.ref_id AND ".
3309 "oref.obj_id = obj.obj_id AND ".
3310 "it.user_id = %s", array(
"integer"), array($user_id));
3312 while ($item_rec = $ilDB->fetchAssoc($item_set))
3314 if ($tree->isInTree($item_rec[
"ref_id"])
3315 && $item_rec[
"type"] !=
"rolf")
3317 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3318 $par_left = $tree->getLeftValue($parent_ref);
3319 $par_left = sprintf(
"%010d", $par_left);
3324 $items[$par_left.$title.$item_rec[
"ref_id"]] =
3325 array(
"ref_id" => $item_rec[
"ref_id"],
3326 "obj_id" => $item_rec[
"obj_id"],
3327 "type" => $item_rec[
"type"],
3329 "description" =>
$desc,
3330 "parent_ref" => $parent_ref);
3337 if (!is_array($a_types))
3339 $a_types = array($a_types);
3342 $foundsurveys = array();
3343 foreach($a_types as $a_type)
3345 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ".
3346 ", object_data obj WHERE ".
3347 "it.item_id = oref.ref_id AND ".
3348 "oref.obj_id = obj.obj_id AND ".
3349 "it.type = %s AND ".
3352 array(
"text",
"integer"),
3353 array($a_type, $user_id));
3355 while ($item_rec = $ilDB->fetchAssoc($item_set))
3359 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3360 array(
"ref_id" => $item_rec[
"ref_id"],
3361 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3385 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3391 $a_time = date(
"Y-m-d H:i:s", time());
3394 $item_set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3395 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3396 array(
"integer",
"integer",
"text",
"integer"),
3397 array(0, $a_item_id, $a_type, $this->
getId()));
3400 if (!
$d = $item_set->fetchRow())
3402 $ilDB->manipulateF(
"INSERT INTO personal_clipboard ".
3403 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3404 " (%s,%s,%s,%s,%s,%s,%s)",
3405 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"),
3406 array($a_item_id, $a_type, $this->
getId(), $a_title, (
int) $a_parent, $a_time, (
int) $a_order_nr));
3410 $ilDB->manipulateF(
"UPDATE personal_clipboard SET insert_time = %s ".
3411 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3412 array(
"timestamp",
"integer",
"integer",
"text"),
3413 array($a_time, $this->
getId(), $a_item_id, $a_type));
3425 $a_time = date(
"Y-m-d H:i:s", time());
3427 $ilDB->insert(
"personal_pc_clipboard", array(
3428 "user_id" => array(
"integer", $this->
getId()),
3429 "content" => array(
"clob", $a_content),
3430 "insert_time" => array(
"timestamp", $a_time),
3431 "order_nr" => array(
"integer", $a_nr)
3442 $set = $ilDB->queryF(
"SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ".
3443 " WHERE user_id = %s", array(
"integer"), array($this->
getId()));
3444 $row = $ilDB->fetchAssoc($set);
3446 $set = $ilDB->queryF(
"SELECT * FROM personal_pc_clipboard ".
3447 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3448 array(
"integer",
"timestamp"),
3451 while (
$row = $ilDB->fetchAssoc($set))
3453 $content[] =
$row[
"content"];
3466 $set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3467 "parent = %s AND type = %s AND user_id = %s",
3468 array(
"integer",
"text",
"integer"),
3469 array(0, $a_type, $this->
getId()));
3470 if ($rec = $ilDB->fetchAssoc($set))
3485 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3486 "type = %s AND user_id = %s",
3487 array(
"text",
"integer"),
3488 array($a_type, $this->
getId()));
3498 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3499 "user_id = %s", array(
"integer"), array($this->
getId()));
3510 if ($a_top_nodes_only)
3512 $par =
" AND parent = ".$ilDB->quote(0,
"integer").
" ";
3515 $type_str = ($a_type !=
"")
3516 ?
" AND type = ".$ilDB->quote($a_type,
"text").
" "
3518 $q =
"SELECT * FROM personal_clipboard WHERE ".
3519 "user_id = ".$ilDB->quote($this->
getId(),
"integer").
" ".
3521 " ORDER BY order_nr";
3522 $objs = $ilDB->query($q);
3524 while ($obj = $ilDB->fetchAssoc($objs))
3526 if ($obj[
"type"] ==
"mob")
3530 if ($obj[
"type"] ==
"incl")
3532 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3535 $objects[] = array (
"id" => $obj[
"item_id"],
3536 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3537 "insert_time" => $obj[
"insert_time"]);
3547 global
$ilDB, $ilUser;
3549 $objs = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3550 "user_id = %s AND parent = %s AND insert_time = %s ".
3551 " ORDER BY order_nr",
3552 array(
"integer",
"integer",
"timestamp"),
3553 array($ilUser->getId(), (int) $a_parent, $a_insert_time));
3555 while ($obj = $ilDB->fetchAssoc($objs))
3557 if ($obj[
"type"] ==
"mob")
3561 $objects[] = array (
"id" => $obj[
"item_id"],
3562 "type" => $obj[
"type"],
"title" => $obj[
"title"]);
3579 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3580 "item_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
3581 "type = ".$ilDB->quote($a_type,
"text");
3582 $user_set = $ilDB->query($q);
3584 while ($user_rec = $ilDB->fetchAssoc($user_set))
3586 $users[] = $user_rec[
"user_id"];
3603 $q =
"DELETE FROM personal_clipboard WHERE ".
3604 "item_id = ".$ilDB->quote($a_item_id,
"integer").
3605 " AND type = ".$ilDB->quote($a_type,
"text").
" ".
3606 " AND user_id = ".$ilDB->quote($this->
getId(),
"integer");
3607 $ilDB->manipulate($q);
3614 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3615 $ilDB->quote($i2_id,
"text");
3618 while(
$row = $ilDB->fetchObject(
$res))
3649 $this->auth_mode = $a_str;
3663 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3676 $this->ext_account = $a_str;
3688 return $this->ext_account;
3706 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3707 $q =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3708 "WHERE auth_mode = %s";
3710 $values[] = $a_auth_mode;
3713 $q.=
" OR auth_mode = %s ";
3715 $values[] =
'default';
3718 $res = $ilDB->queryF($q, $types, $values);
3719 while (
$row = $ilDB->fetchObject(
$res))
3721 if(
$row->auth_mode ==
'default')
3723 $accounts[
$row->usr_id] =
$row->login;
3727 $accounts[
$row->usr_id] =
$row->ext_account;
3730 return $accounts ? $accounts : array();
3744 if(!is_array($a_usr_ids))
3748 $q =
"UPDATE usr_data SET active = %s WHERE ".
3749 $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3750 $ilDB->manipulateF($q, array(
"integer"), array(($a_status ? 1 : 0)));
3780 $r = $ilDB->queryF(
"SELECT * FROM usr_data WHERE ".
3781 " ext_account = %s AND auth_mode = %s",
3782 array(
"text",
"text"),
3783 array($a_account, $a_auth));
3784 if ($usr = $ilDB->fetchAssoc($r))
3786 return $usr[
"login"];
3790 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3791 "WHERE login = %s AND auth_mode = %s",
3792 array(
"text",
"text"),
3793 array($a_account, $a_auth));
3794 if($usr = $ilDB->fetchAssoc(
$res))
3796 return $usr[
'login'];
3802 $res = $ilDB->queryF(
"SELECT login FROM usr_data WHERE ".
3803 " ext_account = %s AND auth_mode = %s",
3804 array(
"text",
"text"),
3805 array($a_account,
"default"));
3806 if ($usr = $ilDB->fetchAssoc(
$res))
3808 return $usr[
"login"];
3811 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3812 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3813 array(
"text",
"text"),
3814 array($a_account,
"default"));
3815 if($usr = $ilDB->fetchAssoc(
$res))
3817 return $usr[
"login"];
3830 $r = $ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3831 "GROUP BY auth_mode");
3833 while($cnt = $ilDB->fetchAssoc($r))
3835 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3852 $q =
"SELECT * FROM usr_data WHERE ".
3853 " email = %s AND (auth_mode = %s ";
3854 $types = array(
"text",
"text");
3855 $values = array($a_email,
"local");
3857 if ($ilSetting->get(
"auth_mode") == 1)
3859 $q.=
" OR auth_mode = %s";
3861 $values[] =
"default";
3867 $usr_set = $ilDB->queryF($q, $types, $values);
3868 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3870 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3887 $image_dir = $webspace_dir.
"/usr_images";
3888 $store_file =
"usr_".$obj_id.
".".
"jpg";
3889 $target_file = $image_dir.
"/$store_file";
3891 chmod($tmp_file, 0770);
3895 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3896 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3897 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3898 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3928 $a_prevent_no_photo_image =
false)
3933 $res = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE ".
3934 "keyword IN (%s,%s) ".
3936 array(
"text",
"text",
"integer"),
3937 array(
'public_upload',
'public_profile', $a_usr_id));
3938 while (
$row = $ilDB->fetchAssoc(
$res))
3940 switch (
$row[
'keyword'])
3942 case 'public_upload' :
3943 $upload =
$row[
'value'] ==
'y';
3945 case 'public_profile' :
3946 $profile = (
$row[
'value'] ==
'y' ||
3947 $row[
'value'] ==
'g');
3954 if(defined(
'ILIAS_MODULE'))
3956 $webspace_dir = (
'.'.$webspace_dir);
3958 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
3960 $image_dir = $webspace_dir.
"/usr_images";
3962 if ($a_size ==
'big')
3964 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
3968 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
3972 if((($upload && $profile) || $a_force_pic)
3973 && @is_file($thumb_file))
3975 $file = $thumb_file.
"?t=".rand(1, 99999);
3979 if (!$a_prevent_no_photo_image)
3994 $image_dir = $webspace_dir.
"/usr_images";
3995 $file = $image_dir.
"/usr_".$this->getID().
".".
"jpg";
3996 $thumb_file = $image_dir.
"/usr_".$this->getID().
"_small.jpg";
3997 $xthumb_file = $image_dir.
"/usr_".$this->getID().
"_xsmall.jpg";
3998 $xxthumb_file = $image_dir.
"/usr_".$this->getID().
"_xxsmall.jpg";
3999 $upload_file = $image_dir.
"/upload_".$this->getID();
4002 $this->
setPref(
"profile_image",
"");
4005 if (@is_file(
$file))
4009 if (@is_file($thumb_file))
4011 unlink($thumb_file);
4013 if (@is_file($xthumb_file))
4015 unlink($xthumb_file);
4017 if (@is_file($xxthumb_file))
4019 unlink($xxthumb_file);
4021 if (@is_file($upload_file))
4023 unlink($upload_file);
4030 if(!is_array($a_data))
4034 foreach($a_data as $field =>
$data)
4036 #$new_data[$field] = ilUtil::stripSlashes($data);
4038 $this->user_defined_data[
'f_'.$field] =
$data;
4040 #$this->user_defined_data = $new_data;
4047 return $this->user_defined_data ? $this->user_defined_data : array();
4056 $field_def = array();
4058 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4061 foreach($this->user_defined_data as $field => $value)
4063 if($field !=
'usr_id')
4066 $udata->set($field, $value);
4098 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4110 $this->user_defined_data = $udata->getAll();
4134 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4152 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
4153 include_once
'classes/class.ilFormat.php';
4155 global
$lng,$rbacreview;
4157 $language =& $a_language;
4158 $language->loadLanguageModule(
'registration');
4159 $language->loadLanguageModule(
'crs');
4162 $body .= ($language->txt(
"login").
": ".$this->
getLogin().
"\n");
4166 $body .= ($language->txt(
"title").
": ".$this->
getUTitle().
"\n");
4171 $language->txt(
'gender_m') :
4172 $language->txt(
'gender_f');
4173 $body .= ($language->txt(
"gender").
": ".
$gender.
"\n");
4177 $body .= ($language->txt(
"firstname").
": ".$this->
getFirstname().
"\n");
4181 $body .= ($language->txt(
"lastname").
": ".$this->
getLastname().
"\n");
4185 $body .= ($language->txt(
"institution").
": ".$this->
getInstitution().
"\n");
4189 $body .= ($language->txt(
"department").
": ".$this->
getDepartment().
"\n");
4193 $body .= ($language->txt(
"street").
": ".$this->
getStreet().
"\n");
4197 $body .= ($language->txt(
"city").
": ".$this->
getCity().
"\n");
4201 $body .= ($language->txt(
"zipcode").
": ".$this->
getZipcode().
"\n");
4205 $body .= ($language->txt(
"country").
": ".$this->
getCountry().
"\n");
4213 $body .= ($language->txt(
"phone_office").
": ".$this->
getPhoneOffice().
"\n");
4217 $body .= ($language->txt(
"phone_home").
": ".$this->
getPhoneHome().
"\n");
4221 $body .= ($language->txt(
"phone_mobile").
": ".$this->
getPhoneMobile().
"\n");
4223 if(strlen($this->
getFax()))
4225 $body .= ($language->txt(
"fax").
": ".$this->
getFax().
"\n");
4229 $body .= ($language->txt(
"email").
": ".$this->
getEmail().
"\n");
4233 $body .= ($language->txt(
"hobby").
": ".$this->
getHobby().
"\n");
4237 $body .= ($language->txt(
"referral_comment").
": ".$this->
getComment().
"\n");
4241 $body .= ($language->txt(
"matriculation").
": ".$this->
getMatriculation().
"\n");
4250 $body .= ($language->txt(
"create_date").
": ".$date.
"\n");
4253 foreach($rbacreview->getGlobalRoles() as $role)
4255 if($rbacreview->isAssigned($this->getId(),$role))
4262 $body .= ($language->txt(
'reg_role_info').
': '.implode(
',',$gr).
"\n");
4268 $body .= ($language->txt(
'time_limit').
": ".$language->txt(
'crs_unlimited').
"\n");
4281 $body .= $language->txt(
'time_limit').
': '.$start->get(
IL_CAL_DATETIME);
4282 $body .= $language->txt(
'time_limit').
': '.$end->get(
IL_CAL_DATETIME);
4285 #$body .= $language->txt('time_limit').': '.$period;
4298 $var =
"im_".$a_im_type;
4299 $this->$var = $a_im_id;
4304 $var =
"im_".$a_im_type;
4310 $this->delicious = $a_delicious;
4327 $set = $ilDB->queryF(
"SELECT feed_hash from usr_data WHERE usr_id = %s",
4328 array(
"integer"), array($a_user_id));
4329 if ($rec = $ilDB->fetchAssoc($set))
4331 if (strlen($rec[
"feed_hash"]) == 32)
4333 return $rec[
"feed_hash"];
4337 $hash = md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4338 $ilDB->manipulateF(
"UPDATE usr_data SET feed_hash = %s".
4339 " WHERE usr_id = %s",
4340 array(
"text",
"integer"),
4341 array($hash, $a_user_id));
4376 ($a_password==
"") ?
"" : md5($a_password));
4392 $q =
"SELECT DISTINCT login, usr_id FROM usr_data ".
4395 $values[] = $a_login;
4397 if ($a_user_id != 0)
4399 $q.=
" AND usr_id != %s ";
4400 $types[] =
"integer";
4401 $values[] = $a_user_id;
4404 $r = $ilDB->queryF($q, $types, $values);
4406 if (
$row = $ilDB->fetchAssoc($r))
4408 return $row[
'usr_id'];
4427 $res = $ilDB->queryF(
"SELECT * FROM usr_data ".
4428 "WHERE ext_account = %s AND auth_mode = %s",
4429 array(
"text",
"text"),
4430 array($a_external_account, $a_auth_mode));
4431 return $ilDB->fetchAssoc(
$res) ?
true :
false;
4442 global
$ilDB, $rbacreview;
4445 $ids = $rbacreview->assignedUsers($role_id);
4447 if (count ($ids) == 0)
4452 $query =
"SELECT usr_data.*, usr_pref.value AS language
4454 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4455 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4456 $values[] =
"language";
4462 $query .=
" AND usr_data.active = %s";
4464 $types[] =
"integer";
4467 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4469 $r = $ilDB->queryF(
$query, $types, $values);
4471 while (
$row = $ilDB->fetchAssoc($r))
4487 $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 ";
4489 $values[] =
"language";
4493 $query .=
" AND usr_data.active = %s";
4495 $types[] =
"integer";
4500 $query.=
" AND usr_data.time_limit_owner = %s";
4502 $types[] =
"integer";
4505 $query .=
" AND usr_data.usr_id != %s ";
4506 $values[] = ANONYMOUS_USER_ID;
4507 $types[] =
"integer";
4509 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4540 global $rbacadmin, $rbacreview,
$ilDB;
4544 foreach ($a_mem_ids as $mem_id) {
4545 $ids [] = $ilDB->quote($mem_id);
4548 $query =
"SELECT usr_data.*, usr_pref.value AS language
4550 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4551 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer").
"
4552 AND usr_data.usr_id != %s";
4553 $values[] =
"language";
4555 $values[] = ANONYMOUS_USER_ID;
4556 $types[] =
"integer";
4560 $query .=
" AND active = %s";
4562 $types[] =
"integer";
4567 $query.=
" AND usr_data.time_limit_owner = %s";
4568 $values[] = $timelimitowner;
4569 $types[] =
"integer";
4573 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4581 return $mem_arr ? $mem_arr : array();
4595 if (is_array($a_internalids)) {
4596 foreach ($a_internalids as $internalid) {
4597 if (is_numeric ($internalid))
4599 $ids[] = $internalid;
4604 if (is_numeric($parsedid) && $parsedid > 0)
4611 if (count($ids) == 0)
4614 $query =
"SELECT usr_data.*, usr_pref.value AS language
4617 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4618 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4619 $values[] =
"language";
4622 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4645 $r = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE usr_id = %s",
4646 array(
"integer"), array($user_id));
4648 while(
$row = $ilDB->fetchAssoc($r))
4661 $query =
"UPDATE usr_data SET usr_data.login_attempts = 0 WHERE usr_data.usr_id = %s";
4662 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4664 if($affected)
return true;
4672 $query =
"SELECT usr_data.login_attempts FROM usr_data WHERE usr_data.usr_id = %s";
4673 $result = $ilDB->queryF(
$query, array(
'integer'), array($a_usr_id) );
4674 $record = $ilDB->fetchAssoc(
$result );
4684 $query =
"UPDATE usr_data SET usr_data.login_attempts = (usr_data.login_attempts + 1) WHERE usr_data.usr_id = %s";
4685 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4687 if($affected)
return true;
4695 $query =
"UPDATE usr_data SET usr_data.active = 0 WHERE usr_data.usr_id = %s";
4696 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4698 if($affected)
return true;
4708 return in_array($this->
getPref(
"public_profile"), array(
"y",
"g"));
4731 $res = $ilDB->queryF(
'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4732 array(
'integer',
'text',
'integer'),
4735 if( $ilDB->numRows(
$res) == 0 )
4737 $ilDB->manipulateF(
'
4738 INSERT INTO loginname_history
4739 (usr_id, login, history_date)
4740 VALUES (%s, %s, %s)',
4741 array(
'integer',
'text',
'integer'),
4760 $atime = $pd_set->get(
"user_activity_time") * 60;
4763 if ($a_user_id == 0)
4765 $where =
"WHERE user_id != 0 AND NOT agree_date IS NULL ";
4766 $type_array = array(
"integer");
4767 $val_array = array(time());
4771 $where =
"WHERE user_id = %s ";
4772 $type_array = array(
"integer",
"integer");
4773 $val_array = array($a_user_id, time());
4776 $no_anonym = ($a_no_anonymous)
4777 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4780 include_once
'./Services/User/classes/class.ilUserAccountSettings.php';
4783 include_once
'./Services/User/classes/class.ilUserFilter.php';
4790 $r = $ilDB->queryF($q =
"SELECT count(user_id) as num,user_id,firstname,lastname,title,login,last_login,max(ctime) AS ctime ".
4791 "FROM usr_session ".
4792 "LEFT JOIN usr_data u ON user_id = u.usr_id ".
4793 "LEFT JOIN usr_pref p ON (p.usr_id = u.usr_id AND p.keyword = ".
4794 $ilDB->quote(
"hide_own_online_status",
"text").
") ".$where.
4795 "AND expires > %s ".
4796 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4799 "GROUP BY user_id,firstname,lastname,title,login,last_login ".
4800 "ORDER BY lastname, firstname", $type_array, $val_array);
4802 while (
$user = $ilDB->fetchAssoc($r))
4805 ||
$user[
"ctime"] + $atime > $ctime)
4811 return $users ? $users : array();
4827 $atime = $pd_set->get(
"user_activity_time") * 60;
4829 $no_anonym = ($a_no_anonymous)
4830 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4837 $q =
"SELECT DISTINCT dat.obj_id as obj_id ".
4839 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4840 "JOIN object_reference r1 ON r1.ref_id = fa.parent ".
4841 "JOIN tree ON tree.child = r1.ref_id ".
4842 "JOIN object_reference r2 ON r2.ref_id = tree.parent ".
4843 "JOIN object_data dat ON dat.obj_id = r2.obj_id ".
4844 "WHERE ua.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4845 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4846 "AND dat.type IN (".$ilDB->quote(
"crs",
"text").
",".
4847 $ilDB->quote(
"grp",
"text").
")";
4848 $r = $ilDB->query($q);
4850 while (
$row = $ilDB->fetchAssoc($r))
4852 $groups_and_courses_of_user[] =
$row[
"obj_id"];
4855 if (count($groups_and_courses_of_user) == 0)
4857 $q =
"SELECT count(user_id) as num,ctime,user_id,firstname,lastname,title,login,last_login ".
4858 "FROM usr_session ".
4859 "JOIN usr_data ON user_id=usr_id ".
4860 "WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4862 " AND NOT agree_date IS NULL ".
4863 "AND expires > ".$ilDB->quote(time(),
"integer").
" ".
4864 "GROUP BY user_id,ctime,firstname,lastname,title,login,last_login";
4865 $r = $ilDB->query($q);
4869 $q =
"SELECT count(user_id) as num,s.ctime,s.user_id,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4870 "FROM usr_session s ".
4871 "JOIN usr_data ud ON ud.usr_id = s.user_id ".
4872 "JOIN rbac_ua ua ON ua.usr_id = s.user_id ".
4873 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4874 "JOIN tree ON tree.child = fa.parent ".
4875 "JOIN object_reference or1 ON or1.ref_id = tree.parent ".
4876 "JOIN object_data od ON od.obj_id = or1.obj_id ".
4877 "LEFT JOIN usr_pref p ON (p.usr_id = ud.usr_id AND p.keyword = ".
4878 $ilDB->quote(
"hide_own_online_status",
"text").
") ".
4879 "WHERE s.user_id != 0 ".
4881 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4882 "AND s.expires > ".$ilDB->quote(time(),
"integer").
" ".
4883 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4884 " AND NOT ud.agree_date IS NULL ".
4885 "AND ".$ilDB->in(
"od.obj_id", $groups_and_courses_of_user,
false,
"integer").
" ".
4886 "GROUP BY s.user_id,s.ctime,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4887 "ORDER BY ud.lastname, ud.firstname";
4888 $r = $ilDB->query($q);
4891 while (
$user = $ilDB->fetchAssoc($r))
4894 ||
$user[
"ctime"] + $atime > $ctime)
4900 return $users ? $users : array();
4917 $hashcode = substr(md5(uniqid(rand(),
true)), 0, 16);
4919 $res = $ilDB->queryf(
'
4920 SELECT COUNT(usr_id) cnt FROM usr_data
4921 WHERE reg_hash = %s',
4926 if(
$row->cnt > 0) $continue =
true;
4930 if($continue)
continue;
4932 $ilDB->manipulateF(
'
4936 array(
'text',
'integer'),
4937 array($hashcode, (
int)$a_usr_id)
4959 $res = $ilDB->queryf(
'
4960 SELECT usr_id, create_date FROM usr_data
4961 WHERE reg_hash = %s',
4964 while(
$row = $ilDB->fetchAssoc(
$res))
4966 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
4969 if((
int)$oRegSettigs->getRegistrationHashLifetime() != 0 &&
4970 time() - (int)$oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row[
'create_date']))
4972 require_once
'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
4976 $ilDB->manipulateF(
'
4980 array(
'text',
'integer'),
4981 array(
'', (
int)
$row[
'usr_id'])
4984 return (
int)$row[
'usr_id'];
4987 require_once
'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
4993 if (strlen($a_birthday))
5000 $this->birthday = null;
5019 if( !(
int)$period )
throw new ilException(
'no valid period given');
5023 $date = date(
'Y-m-d H:i:s', (time() - ((
int)$period * 24 * 60 * 60)) );
5025 $query =
"SELECT usr_id FROM usr_data WHERE last_login < %s";
5027 $res = $ilDB->queryF(
$query, array(
'timestamp'), array($date));
5032 $ids[] =
$row->usr_id;
5049 if($a_last_login !== null) $last_login = $a_last_login;
5050 else $last_login = date(
'Y-m-d H:i:s');
5054 $query =
"UPDATE usr_data SET usr_data.last_login = %s WHERE usr_data.usr_id = %s";
5055 $affected = $ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array($last_login, $a_usr_id) );
5057 if($affected)
return $last_login;
5065 $query =
"UPDATE object_data SET owner = 0 ".
5066 "WHERE owner = ".$ilDB->quote($this->
getId(),
'integer');
5083 $q =
"SELECT DISTINCT ".$ilDB->upper($ilDB->substr(
"lastname", 1, 1)).
" let FROM usr_data ORDER BY let";
5084 $let_set = $ilDB->query($q);
5087 while ($let_rec = $ilDB->fetchAssoc($let_set))
5089 $let[$let_rec[
"let"]] = $let_rec[
"let"];