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"])
687 $res = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
688 array(
"integer"), array($a_user_id));
689 $user_rec = $ilDB->fetchAssoc(
$res);
690 return array(
"user_id" => $a_user_id,
691 "firstname" => $user_rec[
"firstname"],
692 "lastname" => $user_rec[
"lastname"],
693 "title" => $user_rec[
"title"],
694 "login" => $user_rec[
"login"]);
704 $res = $ilDB->queryF(
"SELECT * FROM usr_data WHERE usr_id = %s",
705 array(
"integer"), array($a_user_id));
706 $user_rec = $ilDB->fetchAssoc(
$res);
733 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data WHERE login = %s",
734 array(
"text"), array($a_user_str));
735 $user_rec = $ilDB->fetchAssoc(
$res);
736 return $user_rec[
"usr_id"];
757 $ilDB->manipulateF(
"UPDATE usr_data SET ".
758 "last_login = ".$ilDB->now().
759 " WHERE usr_id = %s",
760 array(
"integer"), array($this->
id));
774 $this->passwd = $new_md5;
776 $ilDB->manipulateF(
"UPDATE usr_data SET ".
779 array(
"text",
"integer"), array($this->passwd, $this->
id));
796 if (func_num_args() != 3)
801 if (!isset($a_old) or !isset($a_new1) or !isset($a_new2))
806 if ($a_new1 != $a_new2)
812 if ($a_new1 ==
"" || $a_old ==
"")
818 switch ($this->passwd_type)
821 if ($a_old != $this->passwd)
828 if (md5($a_old) != $this->passwd)
843 $this->passwd = md5($a_new1);
846 $ilDB->manipulateF(
"UPDATE usr_data SET ".
849 array(
"text",
"integer"), array($this->passwd, $this->
id));
865 if (func_num_args() != 2)
870 if (!isset($a_new1) or !isset($a_new2))
875 if ($a_new1 != $a_new2)
881 $this->passwd = md5($a_new1);
884 $ilDB->manipulateF(
"UPDATE usr_data SET ".
887 array(
"text",
"integer"),
888 array($this->passwd, $this->
id));
898 return (crypt($a_passwd,substr($a_passwd,0,2)));
908 $user_set = $ilDB->queryF(
"SELECT i2passwd FROM usr_data ".
909 "WHERE login = %s", array(
"text"), array($a_user_login));
910 if ($user_rec = $ilDB->fetchAssoc($user_set))
912 if ($user_rec[
"i2passwd"] !=
"")
928 $user_set = $ilDB->queryF(
"SELECT i2passwd FROM usr_data ".
929 "WHERE login = %s", array(
"text"), array($a_user_login));
930 if ($user_rec = $ilDB->fetchAssoc($user_set))
934 $ilDB->manipulateF(
"UPDATE usr_data SET passwd = %s, i2passwd = %s".
936 array(
"text",
"text",
"text"),
937 array(md5($a_pw),
"", $a_user));
959 $res = $ilDB->queryF(
'
960 SELECT * FROM loginname_history
962 array(
'text'), array($a_login));
964 return $ilDB->fetchAssoc(
$res) ?
true :
false;
983 $ilDB->setLimit(1, 0);
984 $res = $ilDB->queryF(
'
985 SELECT login, history_date FROM loginname_history
986 WHERE usr_id = %s ORDER BY history_date DESC',
987 array(
'integer'), array($a_usr_id));
1007 if(func_num_args() != 1)
1012 if(!isset($a_login))
1018 if($a_login == self::_lookupLogin($this->
getId()))
1030 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1031 (int)$ilSetting->get(
'prevent_reuse_of_loginnames') &&
1034 throw new ilUserException($this->lng->txt(
'loginname_already_exists'));
1036 else if((
int)$ilSetting->get(
'allow_change_loginname') &&
1037 (int)$ilSetting->get(
'loginname_change_blocking_time') &&
1038 is_array($last_history_entry) &&
1039 $last_history_entry[1] + (int)$ilSetting->get(
'loginname_change_blocking_time') > time())
1041 include_once
'Services/Calendar/classes/class.ilDate.php';
1044 $this->lng->txt(
'changing_loginname_not_possible_info'),
1048 new ilDateTime(($last_history_entry[1] + (
int)$ilSetting->get(
'loginname_change_blocking_time')),
IL_CAL_UNIX))
1055 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1056 (int)$ilSetting->get(
'create_history_loginname'))
1062 $this->login = $a_login;
1064 $ilDB->manipulateF(
'
1068 array(
'text',
'integer'), array($this->
getLogin(), $this->
getId()));
1083 $this->
setPref($a_keyword, $a_value);
1106 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
1107 array(
"integer",
"text"), array($a_user_id, $a_keyword));
1119 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s",
1120 array(
"integer"), array($a_user_id));
1131 if (strlen($a_value))
1133 $ilDB->manipulateF(
"INSERT INTO usr_pref (usr_id, keyword, value) VALUES (%s,%s,%s)",
1134 array(
"integer",
"text",
"text"), array($a_usr_id, $a_keyword, $a_value));
1147 foreach ($this->prefs as $keyword => $value)
1161 if($tz = $this->
getPref(
'user_tz'))
1167 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1169 return $settings->getDefaultTimeZone();
1181 if($format = $this->
getPref(
'time_format'))
1187 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1189 return $settings->getDefaultTimeFormat();
1201 if($format = $this->
getPref(
'date_format'))
1207 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1209 return $settings->getDefaultDateFormat();
1221 if ($a_keyword !=
"")
1223 $this->prefs[$a_keyword] = $a_value;
1234 if (array_key_exists($a_keyword, $this->prefs))
1236 return $this->prefs[$a_keyword];
1248 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
" ".
1249 "AND keyword = ".$ilDB->quote($a_keyword,
"text");
1267 if (is_array($this->prefs))
1282 global $rbacadmin,
$ilDB;
1285 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1287 $mapping->deleteUser($this->
getId());
1290 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1293 $mailbox->updateMailsOfDeletedUser($this->
getLogin());
1296 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1298 $costum_block->setContextObjId($this->
getId());
1299 $costum_block->setContextObjType(
"user");
1300 $c_blocks = $costum_block->queryBlocksForContext();
1301 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1302 foreach($c_blocks as $c_block)
1304 if ($c_block[
"type"] ==
"pdfeed")
1313 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1317 $ilDB->manipulateF(
"DELETE FROM usr_data WHERE usr_id = %s",
1318 array(
"integer"), array($this->
getId()));
1326 include_once(
"./Services/Authentication/classes/class.ilSession.php");
1330 $rbacadmin->removeUser($this->
getId());
1334 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1335 $ilDB->quote($this->
getId(),
"integer");
1336 $ilDB->manipulate($q);
1338 $q =
"DELETE FROM bookmark_data WHERE user_id = ".
1339 $ilDB->quote($this->
getId(),
"integer");
1340 $ilDB->manipulate($q);
1343 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1347 include_once
'./classes/class.ilLinkCheckNotify.php';
1351 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1355 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1358 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1362 include_once
'Modules/Scorm2004/classes/ilSCORM13Package.php';
1366 include_once
'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
1370 include_once
"./Services/Notification/classes/class.ilNotification.php";
1374 include_once
"./Services/Portfolio/classes/class.ilObjPortfolio.php";
1378 include_once
"./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1380 $tree->cascadingDelete();
1393 global $ilAppEventHandler;
1394 $ilAppEventHandler->raise(
1395 'Services/User',
'deleteUser', array(
'usr_id' => $this->
getId())
1412 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1414 $this->fullname =
"";
1420 elseif ($this->utitle)
1422 $this->fullname = $this->utitle.
" ";
1429 elseif ($this->firstname)
1431 $this->fullname .= $this->firstname.
" ";
1463 if (strlen($this->fullname) <= $a_max_strlen)
1468 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1470 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1473 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1478 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1498 if($a_username ==
'root')
1503 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
1504 "WHERE login = %s AND NOT agree_date IS NULL",
1505 array(
"text"), array($a_username));
1506 return $ilDB->fetchAssoc(
$res) ?
true :
false;
1515 if ($this->agree_date != null || $this->login ==
"root")
1529 $this->login = $a_str;
1548 $this->passwd = $a_str;
1549 $this->passwd_type = $a_type;
1581 $this->gender = substr($a_str,-1);
1602 $this->utitle = $a_str;
1623 $this->firstname = $a_str;
1642 $this->lastname = $a_str;
1661 $this->institution = $a_str;
1680 $this->department = $a_str;
1699 $this->street = $a_str;
1718 $this->city = $a_str;
1737 $this->zipcode = $a_str;
1757 $this->country = $a_str;
1777 $this->sel_country = $a_val;
1797 $this->phone_office = $a_str;
1816 $this->phone_home = $a_str;
1835 $this->phone_mobile = $a_str;
1854 $this->fax = $a_str;
1873 $this->client_ip = $a_str;
1892 $this->matriculation = $a_str;
1914 $query =
"SELECT matriculation FROM usr_data ".
1915 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1918 return $row->matriculation ?
$row->matriculation :
'';
1928 $this->email = $a_str;
1947 $this->hobby = $a_str;
1966 $this->
setPref(
"language",$a_str);
1977 return $this->prefs[
"language"];
1990 $this->
setPref(
"disk_quota",$a_disk_quota);
2004 return $this->prefs[
"disk_quota"] ? $this->prefs[
"disk_quota"] : 0;
2009 $this->last_password_change_ts = $a_last_password_change_ts;
2022 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
2023 $ilDB->quote($a_usr_id,
"integer").
" AND keyword = ".
2024 $ilDB->quote(
'language',
"text");
2025 $r = $ilDB->query($q);
2027 while(
$row = $ilDB->fetchAssoc($r))
2029 return $row[
'value'];
2040 if ($pw == md5($a_pw))
2051 $ilDB->manipulateF(
"UPDATE usr_data ".
2052 " SET ext_account = %s WHERE usr_id = %s",
2053 array(
"text",
"integer"),
2054 array($a_ext_id, $a_usr_id));
2061 $ilDB->manipulateF(
"UPDATE usr_data ".
2062 " SET auth_mode = %s WHERE usr_id = %s",
2063 array(
"text",
"integer"),
2064 array($a_auth_mode, $a_usr_id));
2083 $this->last_login = $a_str;
2093 return $this->last_login;
2103 $this->last_update = $a_str;
2117 $this->referral_comment = $a_str;
2137 $this->approve_date = $a_str;
2168 $this->agree_date = $a_str;
2211 $query =
'SELECT usr_id FROM usr_data '.
2212 'WHERE active = '.$ilDB->quote(1,
'integer').
' '.
2213 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer');
2243 if ((!empty($storedActive) && empty($currentActive)) ||
2244 (empty($storedActive) && !empty($currentActive)))
2259 return $active ?
true :
false;
2270 $this->skin = $a_str;
2275 $this->time_limit_owner = $a_owner;
2279 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2283 $this->time_limit_from = $a_from;
2287 return $this->time_limit_from ? $this->time_limit_from : time();
2291 $this->time_limit_until = $a_until;
2295 return $this->time_limit_until ? $this->time_limit_until : time();
2299 $this->time_limit_unlimited = $a_unlimited;
2303 return $this->time_limit_unlimited;
2307 return $this->time_limit_message = $a_time_limit_message;
2311 return $this->time_limit_message;
2316 $this->login_attempts = $a_login_attempts;
2339 $this->profile_incomplete = (boolean) $a_prof_inc;
2343 if($this->
id == ANONYMOUS_USER_ID)
2347 return $this->profile_incomplete;
2353 if( $this->
id == ANONYMOUS_USER_ID || $this->
id == SYSTEM_USER_ID )
2356 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2360 && $security->isPasswordChangeOnFirstLoginEnabled()
2371 if($this->
id == ANONYMOUS_USER_ID)
return false;
2373 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2378 $max_pass_age = $security->getPasswordMaxAge();
2379 if( $max_pass_age > 0 )
2381 $max_pass_age_ts = ( $max_pass_age * 86400 );
2383 $current_ts = time();
2385 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2394 $current_ts = time();
2396 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2397 return $password_age;
2406 $query =
"UPDATE usr_data SET usr_data.last_password_change = %s " .
2407 "WHERE usr_data.usr_id = %s";
2408 $affected = $ilDB->manipulateF(
$query,
2409 array(
'integer',
'integer'),
2411 if($affected)
return true;
2419 $query =
"UPDATE usr_data SET usr_data.last_password_change = 0 " .
2420 "WHERE usr_data.usr_id = %s";
2421 $affected = $ilDB->manipulateF(
$query, array(
'integer'),
2422 array($this->
getId()) );
2423 if($affected)
return true;
2434 $this->latitude = $a_latitude;
2454 $this->longitude = $a_longitude;
2474 $this->loc_zoom = $a_locationzoom;
2489 $this->applied_users = array();
2492 return $this->applied_users ? $this->applied_users : array();
2497 if($a_usr_id == $this->
getId())
2502 $this->applied_users = array();
2505 return in_array($a_usr_id,$this->applied_users);
2512 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2513 "WHERE time_limit_owner = %s",
2515 array($a_parent_id));
2516 while (
$row = $ilDB->fetchObject(
$res))
2518 $this->applied_users[] =
$row->usr_id;
2539 if(
$id != ANONYMOUS_USER_ID && (
int)$ilSetting->get(
'ps_prevent_simultaneous_logins') == 1 )
2541 $res = $ilDB->queryf(
'
2542 SELECT * FROM usr_session WHERE user_id = %s AND expires > %s',
2543 array(
'integer',
'integer'),
2544 array(
$id, time()));
2566 require_once (
'Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2569 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2570 require_once (
'Services/Database/classes/class.ilAuthContainerMDB2.php');
2575 $login =$ilAuth->getUsername();
2588 global
$ilDB,$ilAuth;
2591 $set = $ilDB->queryF(
"SELECT active FROM usr_data WHERE login= %s",
2595 if ($rec = $ilDB->fetchAssoc($set))
2631 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
2632 "WHERE email = %s and active = 1",
2636 while(
$row = $ilDB->fetchObject(
$res))
2638 $ids[] =
$row->login;
2658 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2659 "WHERE email = %s", array(
"text"), array($a_email));
2662 return $row->usr_id ?
$row->usr_id : 0;
2689 static function searchUsers($a_search_str,
$active = 1, $a_return_ids_only =
false, $filter_settings = FALSE)
2694 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2696 $without_anonymous_users =
true;
2699 $join_filter =
" WHERE ";
2700 if ($filter_settings !== FALSE && strlen($filter_settings))
2702 switch ($filter_settings)
2706 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.usr_id IS NULL AND ";
2713 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.obj_id = ".
2714 "(SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") AND ";
2722 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2723 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2724 if (is_array($local_roles) && count($local_roles))
2726 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2727 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false, $local_roles).
" AND ";
2733 $rol_id =
$_SESSION[
"user_filter_data"];
2736 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2737 $ilDB->quote($rol_id,
"integer").
" AND ";
2738 $without_anonymous_users =
false;
2745 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2747 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2748 "FROM object_data,rbac_ua,usr_data ".
2749 "WHERE ".$ilDB->like(
"object_data.title",
"text",
"%".substr($a_search_str,5).
"%").
2750 " AND object_data.type = 'role' ".
2751 "AND rbac_ua.rol_id = object_data.obj_id ".
2752 "AND usr_data.usr_id = rbac_ua.usr_id ".
2753 "AND rbac_ua.usr_id != ".$illDB->quote(ANONYMOUS_USER_ID,
"integer");
2758 "(".$ilDB->like(
"usr_data.login",
"text",
"%".$a_search_str.
"%").
" ".
2759 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_search_str.
"%").
" ".
2760 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_search_str.
"%").
" ".
2761 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_search_str.
"%").
") ";
2763 if ($filter_settings !== FALSE && strlen($filter_settings))
2765 switch ($filter_settings)
2768 $query.=
" AND usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
2771 $query.=
" AND usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
2774 $query.=
" AND usr_data.time_limit_unlimited = ".$ilDB->quote(0,
"integer").
" ";
2777 $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"]));
2778 $query.=
" AND last_login < ".$ilDB->quote($date,
"timestamp").
" ";
2783 if ($without_anonymous_users)
2785 $query.=
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2788 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE)
2790 $query.=
" AND active = ".$ilDB->quote(
$active,
"integer").
" ";
2796 while (
$row = $ilDB->fetchObject(
$res))
2799 "usr_id" =>
$row->usr_id,
2800 "login" =>
$row->login,
2801 "firstname" =>
$row->firstname,
2802 "lastname" =>
$row->lastname,
2803 "email" =>
$row->email,
2804 "active" =>
$row->active);
2805 $ids[] =
$row->usr_id;
2807 if ($a_return_ids_only)
2808 return $ids ? $ids : array();
2810 return $users ? $users : array();
2825 $res = $ilDB->query(
"SELECT login FROM usr_data");
2826 while(
$row = $ilDB->fetchObject(
$res))
2828 $logins[] =
$row->login;
2830 return $logins ? $logins : array();
2844 $res = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
2845 $ilDB->in(
"usr_id", $a_user_ids,
false,
"integer"));
2846 while (
$row = $ilDB->fetchAssoc(
$res))
2848 $user_data[
"$row[usr_id]"] =
$row;
2850 return $user_data ? $user_data : array();
2865 $result_arr = array();
2869 if ($a_fields !== NULL and is_array($a_fields))
2871 if (count($a_fields) == 0)
2877 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2878 unset($a_fields[$usr_id_field]);
2880 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2882 if(in_array(
'online_time',$a_fields))
2884 $select .=
",ut_online.online_time ";
2888 $q =
"SELECT ".$select.
" FROM usr_data ";
2892 if(in_array(
'online_time',$a_fields))
2894 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2901 $q .=
"WHERE active = ".$ilDB->quote(
$active,
"integer");
2904 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
2907 $qtemp = $q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
2908 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
2909 $r = $ilDB->query($qtemp);
2910 $course_users = array();
2911 while (
$row = $ilDB->fetchAssoc($r))
2913 array_push($course_users,
$row[
"usr_id"]);
2915 if (count($course_users))
2917 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
2925 $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"]));
2926 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
2932 $q .=
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id ".
2933 "WHERE crs_members.obj_id = (SELECT obj_id FROM object_reference ".
2934 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
2942 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2943 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2944 if (is_array($local_roles) && count($local_roles))
2946 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2947 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
2952 $rol_id =
$_SESSION[
"user_filter_data"];
2955 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2956 $ilDB->quote($rol_id,
"integer");
2960 $r = $ilDB->query($q);
2962 while (
$row = $ilDB->fetchAssoc($r))
2964 $result_arr[] =
$row;
2978 $q =
"SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ".
2979 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
2980 " AND up1.value= ".$ilDB->quote($a_style,
"text").
2981 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
2982 " AND up2.value= ".$ilDB->quote($a_skin,
"text").
2983 " AND up1.usr_id = up2.usr_id ";
2985 $cnt_set = $ilDB->query($q);
2987 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
2989 return $cnt_rec[
"cnt"];
2999 $q =
"SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ".
3000 " WHERE up1.keyword = ".$ilDB->quote(
"style",
"text").
3001 " AND up2.keyword = ".$ilDB->quote(
"skin",
"text").
3002 " AND up1.usr_id = up2.usr_id";
3004 $sty_set = $ilDB->query($q);
3007 while($sty_rec = $ilDB->fetchAssoc($sty_set))
3009 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
3022 $q =
"SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ".
3023 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3024 " AND up1.value= ".$ilDB->quote($a_from_style,
"text").
3025 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3026 " AND up2.value= ".$ilDB->quote($a_from_skin,
"text").
3027 " AND up1.usr_id = up2.usr_id ";
3029 $usr_set = $ilDB->query($q);
3031 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3052 $item_set = $ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3053 "item_id = %s AND type = %s AND user_id = %s",
3054 array(
"integer",
"text",
"integer"),
3055 array($a_item_id, $a_type, $a_usr_id));
3058 if (!$ilDB->fetchAssoc($item_set))
3060 $ilDB->manipulateF(
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3061 " (%s,%s,%s,%s)", array(
"integer",
"text",
"integer",
"text"),
3062 array($a_item_id,$a_type,$a_usr_id,$a_par));
3065 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3093 $ilDB->manipulateF(
"UPDATE desktop_item SET parameters = %s ".
3094 " WHERE item_id = %s AND type = %s AND user_id = %s",
3095 array(
"text",
"integer",
"text",
"integer"),
3096 array($a_par, $a_item_id, $a_type, $this->
getId()));
3113 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE ".
3114 " item_id = %s AND type = %s AND user_id = %s",
3115 array(
"integer",
"text",
"integer"),
3116 array($a_item_id, $a_type, $a_usr_id));
3118 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3144 $r = $ilDB->queryF(
"SELECT user_id FROM desktop_item WHERE item_id = %s",
3145 array(
"integer"), array($a_id));
3149 while (
$row = $ilDB->fetchObject($r))
3151 $users[] =
$row->user_id;
3154 if (count($users) > 0)
3156 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE item_id = %s",
3157 array(
"integer"), array($a_id));
3176 if (self::$is_desktop_item_loaded[$a_usr_id.
":".$a_item_id])
3178 return self::$is_desktop_item_cache[$a_usr_id.
":".$a_item_id.
":".$a_type];
3180 $item_set = $ilDB->queryF(
"SELECT item_id FROM desktop_item WHERE ".
3181 "item_id = %s AND type = %s AND user_id = %s",
3182 array(
"integer",
"text",
"integer"),
3183 array($a_item_id, $a_type, $a_usr_id));
3185 if ($ilDB->fetchAssoc($item_set))
3205 if (!is_array($a_item_ids))
3210 $item_ids = array();
3211 foreach ($a_item_ids as
$id)
3213 if (!self::$is_desktop_item_loaded[$a_usr_id.
":".$id])
3217 self::$is_desktop_item_loaded[$a_usr_id.
":".
$id] =
true;
3220 if (count($item_ids) > 0)
3222 $item_set = $ilDB->query(
"SELECT item_id, type FROM desktop_item WHERE ".
3223 $ilDB->in(
"item_id", $item_ids,
false,
"integer").
3224 " AND user_id = ".$ilDB->quote($a_usr_id,
"integer"));
3225 while ($r = $ilDB->fetchAssoc($item_set))
3227 self::$is_desktop_item_cache[$a_usr_id.
":".$r[
"item_id"].
":".$r[
"type"]]
3258 global $ilUser, $rbacsystem, $tree,
$ilDB;
3262 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3263 " FROM desktop_item it, object_reference oref ".
3264 ", object_data obj".
3266 "it.item_id = oref.ref_id AND ".
3267 "oref.obj_id = obj.obj_id AND ".
3268 "it.user_id = %s", array(
"integer"), array($user_id));
3270 while ($item_rec = $ilDB->fetchAssoc($item_set))
3272 if ($tree->isInTree($item_rec[
"ref_id"])
3273 && $item_rec[
"type"] !=
"rolf")
3275 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3276 $par_left = $tree->getLeftValue($parent_ref);
3277 $par_left = sprintf(
"%010d", $par_left);
3282 $items[$par_left.$title.$item_rec[
"ref_id"]] =
3283 array(
"ref_id" => $item_rec[
"ref_id"],
3284 "obj_id" => $item_rec[
"obj_id"],
3285 "type" => $item_rec[
"type"],
3287 "description" =>
$desc,
3288 "parent_ref" => $parent_ref);
3295 if (!is_array($a_types))
3297 $a_types = array($a_types);
3300 $foundsurveys = array();
3301 foreach($a_types as $a_type)
3303 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ".
3304 ", object_data obj WHERE ".
3305 "it.item_id = oref.ref_id AND ".
3306 "oref.obj_id = obj.obj_id AND ".
3307 "it.type = %s AND ".
3310 array(
"text",
"integer"),
3311 array($a_type, $user_id));
3313 while ($item_rec = $ilDB->fetchAssoc($item_set))
3317 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3318 array(
"ref_id" => $item_rec[
"ref_id"],
3319 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3343 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3349 $a_time = date(
"Y-m-d H:i:s", time());
3352 $item_set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3353 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3354 array(
"integer",
"integer",
"text",
"integer"),
3355 array(0, $a_item_id, $a_type, $this->
getId()));
3358 if (!
$d = $item_set->fetchRow())
3360 $ilDB->manipulateF(
"INSERT INTO personal_clipboard ".
3361 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3362 " (%s,%s,%s,%s,%s,%s,%s)",
3363 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"),
3364 array($a_item_id, $a_type, $this->
getId(), $a_title, (
int) $a_parent, $a_time, (
int) $a_order_nr));
3368 $ilDB->manipulateF(
"UPDATE personal_clipboard SET insert_time = %s ".
3369 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3370 array(
"timestamp",
"integer",
"integer",
"text"),
3371 array($a_time, $this->
getId(), $a_item_id, $a_type));
3383 $a_time = date(
"Y-m-d H:i:s", time());
3385 $ilDB->insert(
"personal_pc_clipboard", array(
3386 "user_id" => array(
"integer", $this->
getId()),
3387 "content" => array(
"clob", $a_content),
3388 "insert_time" => array(
"timestamp", $a_time),
3389 "order_nr" => array(
"integer", $a_nr)
3400 $set = $ilDB->queryF(
"SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ".
3401 " WHERE user_id = %s", array(
"integer"), array($this->
getId()));
3402 $row = $ilDB->fetchAssoc($set);
3404 $set = $ilDB->queryF(
"SELECT * FROM personal_pc_clipboard ".
3405 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3406 array(
"integer",
"timestamp"),
3409 while (
$row = $ilDB->fetchAssoc($set))
3411 $content[] =
$row[
"content"];
3424 $set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3425 "parent = %s AND type = %s AND user_id = %s",
3426 array(
"integer",
"text",
"integer"),
3427 array(0, $a_type, $this->
getId()));
3428 if ($rec = $ilDB->fetchAssoc($set))
3443 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3444 "type = %s AND user_id = %s",
3445 array(
"text",
"integer"),
3446 array($a_type, $this->
getId()));
3456 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3457 "user_id = %s", array(
"integer"), array($this->
getId()));
3468 if ($a_top_nodes_only)
3470 $par =
" AND parent = ".$ilDB->quote(0,
"integer").
" ";
3473 $type_str = ($a_type !=
"")
3474 ?
" AND type = ".$ilDB->quote($a_type,
"text").
" "
3476 $q =
"SELECT * FROM personal_clipboard WHERE ".
3477 "user_id = ".$ilDB->quote($this->
getId(),
"integer").
" ".
3479 " ORDER BY order_nr";
3480 $objs = $ilDB->query($q);
3482 while ($obj = $ilDB->fetchAssoc($objs))
3484 if ($obj[
"type"] ==
"mob")
3488 if ($obj[
"type"] ==
"incl")
3490 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3493 $objects[] = array (
"id" => $obj[
"item_id"],
3494 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3495 "insert_time" => $obj[
"insert_time"]);
3505 global
$ilDB, $ilUser;
3507 $objs = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3508 "user_id = %s AND parent = %s AND insert_time = %s ".
3509 " ORDER BY order_nr",
3510 array(
"integer",
"integer",
"timestamp"),
3511 array($ilUser->getId(), (int) $a_parent, $a_insert_time));
3513 while ($obj = $ilDB->fetchAssoc($objs))
3515 if ($obj[
"type"] ==
"mob")
3519 $objects[] = array (
"id" => $obj[
"item_id"],
3520 "type" => $obj[
"type"],
"title" => $obj[
"title"]);
3537 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3538 "item_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
3539 "type = ".$ilDB->quote($a_type,
"text");
3540 $user_set = $ilDB->query($q);
3542 while ($user_rec = $ilDB->fetchAssoc($user_set))
3544 $users[] = $user_rec[
"user_id"];
3561 $q =
"DELETE FROM personal_clipboard WHERE ".
3562 "item_id = ".$ilDB->quote($a_item_id,
"integer").
3563 " AND type = ".$ilDB->quote($a_type,
"text").
" ".
3564 " AND user_id = ".$ilDB->quote($this->
getId(),
"integer");
3565 $ilDB->manipulate($q);
3572 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3573 $ilDB->quote($i2_id,
"text");
3576 while(
$row = $ilDB->fetchObject(
$res))
3607 $this->auth_mode = $a_str;
3621 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3634 $this->ext_account = $a_str;
3646 return $this->ext_account;
3664 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3665 $q =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3666 "WHERE auth_mode = %s";
3668 $values[] = $a_auth_mode;
3671 $q.=
" OR auth_mode = %s ";
3673 $values[] =
'default';
3676 $res = $ilDB->queryF($q, $types, $values);
3677 while (
$row = $ilDB->fetchObject(
$res))
3679 if(
$row->auth_mode ==
'default')
3681 $accounts[
$row->usr_id] =
$row->login;
3685 $accounts[
$row->usr_id] =
$row->ext_account;
3688 return $accounts ? $accounts : array();
3702 if(!is_array($a_usr_ids))
3706 $q =
"UPDATE usr_data SET active = %s WHERE ".
3707 $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3708 $ilDB->manipulateF($q, array(
"integer"), array(($a_status ? 1 : 0)));
3738 $r = $ilDB->queryF(
"SELECT * FROM usr_data WHERE ".
3739 " ext_account = %s AND auth_mode = %s",
3740 array(
"text",
"text"),
3741 array($a_account, $a_auth));
3742 if ($usr = $ilDB->fetchAssoc($r))
3744 return $usr[
"login"];
3748 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3749 "WHERE login = %s AND auth_mode = %s",
3750 array(
"text",
"text"),
3751 array($a_account, $a_auth));
3752 if($usr = $ilDB->fetchAssoc(
$res))
3754 return $usr[
'login'];
3760 $res = $ilDB->queryF(
"SELECT login FROM usr_data WHERE ".
3761 " ext_account = %s AND auth_mode = %s",
3762 array(
"text",
"text"),
3763 array($a_account,
"default"));
3764 if ($usr = $ilDB->fetchAssoc(
$res))
3766 return $usr[
"login"];
3769 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3770 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3771 array(
"text",
"text"),
3772 array($a_account,
"default"));
3773 if($usr = $ilDB->fetchAssoc(
$res))
3775 return $usr[
"login"];
3788 $r = $ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3789 "GROUP BY auth_mode");
3791 while($cnt = $ilDB->fetchAssoc($r))
3793 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3810 $q =
"SELECT * FROM usr_data WHERE ".
3811 " email = %s AND (auth_mode = %s ";
3812 $types = array(
"text",
"text");
3813 $values = array($a_email,
"local");
3815 if ($ilSetting->get(
"auth_mode") == 1)
3817 $q.=
" OR auth_mode = %s";
3819 $values[] =
"default";
3825 $usr_set = $ilDB->queryF($q, $types, $values);
3826 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3828 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3845 $image_dir = $webspace_dir.
"/usr_images";
3846 $store_file =
"usr_".$obj_id.
".".
"jpg";
3847 $target_file = $image_dir.
"/$store_file";
3849 chmod($tmp_file, 0770);
3853 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3854 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3855 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3856 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3886 $a_prevent_no_photo_image =
false)
3891 $res = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE ".
3892 "keyword IN (%s,%s) ".
3894 array(
"text",
"text",
"integer"),
3895 array(
'public_upload',
'public_profile', $a_usr_id));
3896 while (
$row = $ilDB->fetchAssoc(
$res))
3898 switch (
$row[
'keyword'])
3900 case 'public_upload' :
3901 $upload =
$row[
'value'] ==
'y';
3903 case 'public_profile' :
3904 $profile = (
$row[
'value'] ==
'y' ||
3905 $row[
'value'] ==
'g');
3912 if(defined(
'ILIAS_MODULE'))
3914 $webspace_dir = (
'.'.$webspace_dir);
3916 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
3918 $image_dir = $webspace_dir.
"/usr_images";
3920 if ($a_size ==
'big')
3922 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
3926 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
3930 if((($upload && $profile) || $a_force_pic)
3931 && @is_file($thumb_file))
3933 $file = $thumb_file.
"?t=".rand(1, 99999);
3937 if (!$a_prevent_no_photo_image)
3940 if($a_size ==
"small" || $a_size ==
"big")
3957 $image_dir = $webspace_dir.
"/usr_images";
3958 $file = $image_dir.
"/usr_".$this->getID().
".".
"jpg";
3959 $thumb_file = $image_dir.
"/usr_".$this->getID().
"_small.jpg";
3960 $xthumb_file = $image_dir.
"/usr_".$this->getID().
"_xsmall.jpg";
3961 $xxthumb_file = $image_dir.
"/usr_".$this->getID().
"_xxsmall.jpg";
3962 $upload_file = $image_dir.
"/upload_".$this->getID();
3967 $this->
setPref(
"profile_image",
"");
3971 if (@is_file(
$file))
3975 if (@is_file($thumb_file))
3977 unlink($thumb_file);
3979 if (@is_file($xthumb_file))
3981 unlink($xthumb_file);
3983 if (@is_file($xxthumb_file))
3985 unlink($xxthumb_file);
3987 if (@is_file($upload_file))
3989 unlink($upload_file);
3996 if(!is_array($a_data))
4000 foreach($a_data as $field =>
$data)
4002 #$new_data[$field] = ilUtil::stripSlashes($data);
4004 $this->user_defined_data[
'f_'.$field] =
$data;
4006 #$this->user_defined_data = $new_data;
4013 return $this->user_defined_data ? $this->user_defined_data : array();
4022 $field_def = array();
4024 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4027 foreach($this->user_defined_data as $field => $value)
4029 if($field !=
'usr_id')
4032 $udata->set($field, $value);
4064 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4076 $this->user_defined_data = $udata->getAll();
4100 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4118 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
4119 include_once
'classes/class.ilFormat.php';
4121 global
$lng,$rbacreview;
4123 $language =& $a_language;
4124 $language->loadLanguageModule(
'registration');
4125 $language->loadLanguageModule(
'crs');
4128 $body .= ($language->txt(
"login").
": ".$this->
getLogin().
"\n");
4132 $body .= ($language->txt(
"title").
": ".$this->
getUTitle().
"\n");
4137 $language->txt(
'gender_m') :
4138 $language->txt(
'gender_f');
4139 $body .= ($language->txt(
"gender").
": ".
$gender.
"\n");
4143 $body .= ($language->txt(
"firstname").
": ".$this->
getFirstname().
"\n");
4147 $body .= ($language->txt(
"lastname").
": ".$this->
getLastname().
"\n");
4151 $body .= ($language->txt(
"institution").
": ".$this->
getInstitution().
"\n");
4155 $body .= ($language->txt(
"department").
": ".$this->
getDepartment().
"\n");
4159 $body .= ($language->txt(
"street").
": ".$this->
getStreet().
"\n");
4163 $body .= ($language->txt(
"city").
": ".$this->
getCity().
"\n");
4167 $body .= ($language->txt(
"zipcode").
": ".$this->
getZipcode().
"\n");
4171 $body .= ($language->txt(
"country").
": ".$this->
getCountry().
"\n");
4179 $body .= ($language->txt(
"phone_office").
": ".$this->
getPhoneOffice().
"\n");
4183 $body .= ($language->txt(
"phone_home").
": ".$this->
getPhoneHome().
"\n");
4187 $body .= ($language->txt(
"phone_mobile").
": ".$this->
getPhoneMobile().
"\n");
4189 if(strlen($this->
getFax()))
4191 $body .= ($language->txt(
"fax").
": ".$this->
getFax().
"\n");
4195 $body .= ($language->txt(
"email").
": ".$this->
getEmail().
"\n");
4199 $body .= ($language->txt(
"hobby").
": ".$this->
getHobby().
"\n");
4203 $body .= ($language->txt(
"referral_comment").
": ".$this->
getComment().
"\n");
4207 $body .= ($language->txt(
"matriculation").
": ".$this->
getMatriculation().
"\n");
4216 $body .= ($language->txt(
"create_date").
": ".$date.
"\n");
4219 foreach($rbacreview->getGlobalRoles() as $role)
4221 if($rbacreview->isAssigned($this->getId(),$role))
4228 $body .= ($language->txt(
'reg_role_info').
': '.implode(
',',$gr).
"\n");
4234 $body .= ($language->txt(
'time_limit').
": ".$language->txt(
'crs_unlimited').
"\n");
4247 $body .= $language->txt(
'time_limit').
': '.$start->get(
IL_CAL_DATETIME);
4248 $body .= $language->txt(
'time_limit').
': '.$end->get(
IL_CAL_DATETIME);
4251 #$body .= $language->txt('time_limit').': '.$period;
4264 $var =
"im_".$a_im_type;
4265 $this->$var = $a_im_id;
4270 $var =
"im_".$a_im_type;
4276 $this->delicious = $a_delicious;
4293 $set = $ilDB->queryF(
"SELECT feed_hash from usr_data WHERE usr_id = %s",
4294 array(
"integer"), array($a_user_id));
4295 if ($rec = $ilDB->fetchAssoc($set))
4297 if (strlen($rec[
"feed_hash"]) == 32)
4299 return $rec[
"feed_hash"];
4303 $hash = md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4304 $ilDB->manipulateF(
"UPDATE usr_data SET feed_hash = %s".
4305 " WHERE usr_id = %s",
4306 array(
"text",
"integer"),
4307 array($hash, $a_user_id));
4342 ($a_password==
"") ?
"" : md5($a_password));
4358 $q =
"SELECT DISTINCT login, usr_id FROM usr_data ".
4361 $values[] = $a_login;
4363 if ($a_user_id != 0)
4365 $q.=
" AND usr_id != %s ";
4366 $types[] =
"integer";
4367 $values[] = $a_user_id;
4370 $r = $ilDB->queryF($q, $types, $values);
4372 if (
$row = $ilDB->fetchAssoc($r))
4374 return $row[
'usr_id'];
4393 $res = $ilDB->queryF(
"SELECT * FROM usr_data ".
4394 "WHERE ext_account = %s AND auth_mode = %s",
4395 array(
"text",
"text"),
4396 array($a_external_account, $a_auth_mode));
4397 return $ilDB->fetchAssoc(
$res) ?
true :
false;
4408 global
$ilDB, $rbacreview;
4411 $ids = $rbacreview->assignedUsers($role_id);
4413 if (count ($ids) == 0)
4418 $query =
"SELECT usr_data.*, usr_pref.value AS language
4420 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4421 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4422 $values[] =
"language";
4428 $query .=
" AND usr_data.active = %s";
4430 $types[] =
"integer";
4433 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4435 $r = $ilDB->queryF(
$query, $types, $values);
4437 while (
$row = $ilDB->fetchAssoc($r))
4453 $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 ";
4455 $values[] =
"language";
4459 $query .=
" AND usr_data.active = %s";
4461 $types[] =
"integer";
4466 $query.=
" AND usr_data.time_limit_owner = %s";
4468 $types[] =
"integer";
4471 $query .=
" AND usr_data.usr_id != %s ";
4472 $values[] = ANONYMOUS_USER_ID;
4473 $types[] =
"integer";
4475 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4506 global $rbacadmin, $rbacreview,
$ilDB;
4510 foreach ($a_mem_ids as $mem_id) {
4511 $ids [] = $ilDB->quote($mem_id);
4514 $query =
"SELECT usr_data.*, usr_pref.value AS language
4516 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4517 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer").
"
4518 AND usr_data.usr_id != %s";
4519 $values[] =
"language";
4521 $values[] = ANONYMOUS_USER_ID;
4522 $types[] =
"integer";
4526 $query .=
" AND active = %s";
4528 $types[] =
"integer";
4533 $query.=
" AND usr_data.time_limit_owner = %s";
4534 $values[] = $timelimitowner;
4535 $types[] =
"integer";
4539 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4547 return $mem_arr ? $mem_arr : array();
4561 if (is_array($a_internalids)) {
4562 foreach ($a_internalids as $internalid) {
4563 if (is_numeric ($internalid))
4565 $ids[] = $internalid;
4570 if (is_numeric($parsedid) && $parsedid > 0)
4577 if (count($ids) == 0)
4580 $query =
"SELECT usr_data.*, usr_pref.value AS language
4583 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4584 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4585 $values[] =
"language";
4588 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4611 $r = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE usr_id = %s",
4612 array(
"integer"), array($user_id));
4614 while(
$row = $ilDB->fetchAssoc($r))
4627 $query =
"UPDATE usr_data SET usr_data.login_attempts = 0 WHERE usr_data.usr_id = %s";
4628 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4630 if($affected)
return true;
4638 $query =
"SELECT usr_data.login_attempts FROM usr_data WHERE usr_data.usr_id = %s";
4639 $result = $ilDB->queryF(
$query, array(
'integer'), array($a_usr_id) );
4640 $record = $ilDB->fetchAssoc(
$result );
4650 $query =
"UPDATE usr_data SET usr_data.login_attempts = (usr_data.login_attempts + 1) WHERE usr_data.usr_id = %s";
4651 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4653 if($affected)
return true;
4661 $query =
"UPDATE usr_data SET usr_data.active = 0 WHERE usr_data.usr_id = %s";
4662 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4664 if($affected)
return true;
4674 return in_array($this->
getPref(
"public_profile"), array(
"y",
"g"));
4697 $res = $ilDB->queryF(
'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4698 array(
'integer',
'text',
'integer'),
4701 if( $ilDB->numRows(
$res) == 0 )
4703 $ilDB->manipulateF(
'
4704 INSERT INTO loginname_history
4705 (usr_id, login, history_date)
4706 VALUES (%s, %s, %s)',
4707 array(
'integer',
'text',
'integer'),
4726 $atime = $pd_set->get(
"user_activity_time") * 60;
4729 if ($a_user_id == 0)
4731 $where =
"WHERE user_id != 0 AND NOT agree_date IS NULL ";
4732 $type_array = array(
"integer");
4733 $val_array = array(time());
4737 $where =
"WHERE user_id = %s ";
4738 $type_array = array(
"integer",
"integer");
4739 $val_array = array($a_user_id, time());
4742 $no_anonym = ($a_no_anonymous)
4743 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4746 include_once
'./Services/User/classes/class.ilUserAccountSettings.php';
4749 include_once
'./Services/User/classes/class.ilUserFilter.php';
4756 $r = $ilDB->queryF($q =
"SELECT count(user_id) as num,user_id,firstname,lastname,title,login,last_login,max(ctime) AS ctime ".
4757 "FROM usr_session ".
4758 "LEFT JOIN usr_data u ON user_id = u.usr_id ".
4759 "LEFT JOIN usr_pref p ON (p.usr_id = u.usr_id AND p.keyword = ".
4760 $ilDB->quote(
"hide_own_online_status",
"text").
") ".$where.
4761 "AND expires > %s ".
4762 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4765 "GROUP BY user_id,firstname,lastname,title,login,last_login ".
4766 "ORDER BY lastname, firstname", $type_array, $val_array);
4768 while ($user = $ilDB->fetchAssoc($r))
4771 || $user[
"ctime"] + $atime > $ctime)
4773 $users[$user[
"user_id"]] = $user;
4777 return $users ? $users : array();
4793 $atime = $pd_set->get(
"user_activity_time") * 60;
4795 $no_anonym = ($a_no_anonymous)
4796 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4803 $q =
"SELECT DISTINCT dat.obj_id as obj_id ".
4805 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4806 "JOIN object_reference r1 ON r1.ref_id = fa.parent ".
4807 "JOIN tree ON tree.child = r1.ref_id ".
4808 "JOIN object_reference r2 ON r2.ref_id = tree.parent ".
4809 "JOIN object_data dat ON dat.obj_id = r2.obj_id ".
4810 "WHERE ua.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4811 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4812 "AND dat.type IN (".$ilDB->quote(
"crs",
"text").
",".
4813 $ilDB->quote(
"grp",
"text").
")";
4814 $r = $ilDB->query($q);
4816 while (
$row = $ilDB->fetchAssoc($r))
4818 $groups_and_courses_of_user[] =
$row[
"obj_id"];
4821 if (count($groups_and_courses_of_user) == 0)
4823 $q =
"SELECT count(user_id) as num,ctime,user_id,firstname,lastname,title,login,last_login ".
4824 "FROM usr_session ".
4825 "JOIN usr_data ON user_id=usr_id ".
4826 "WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4828 " AND NOT agree_date IS NULL ".
4829 "AND expires > ".$ilDB->quote(time(),
"integer").
" ".
4830 "GROUP BY user_id,ctime,firstname,lastname,title,login,last_login";
4831 $r = $ilDB->query($q);
4835 $q =
"SELECT count(user_id) as num,s.ctime,s.user_id,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4836 "FROM usr_session s ".
4837 "JOIN usr_data ud ON ud.usr_id = s.user_id ".
4838 "JOIN rbac_ua ua ON ua.usr_id = s.user_id ".
4839 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4840 "JOIN tree ON tree.child = fa.parent ".
4841 "JOIN object_reference or1 ON or1.ref_id = tree.parent ".
4842 "JOIN object_data od ON od.obj_id = or1.obj_id ".
4843 "LEFT JOIN usr_pref p ON (p.usr_id = ud.usr_id AND p.keyword = ".
4844 $ilDB->quote(
"hide_own_online_status",
"text").
") ".
4845 "WHERE s.user_id != 0 ".
4847 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4848 "AND s.expires > ".$ilDB->quote(time(),
"integer").
" ".
4849 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4850 " AND NOT ud.agree_date IS NULL ".
4851 "AND ".$ilDB->in(
"od.obj_id", $groups_and_courses_of_user,
false,
"integer").
" ".
4852 "GROUP BY s.user_id,s.ctime,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4853 "ORDER BY ud.lastname, ud.firstname";
4854 $r = $ilDB->query($q);
4857 while ($user = $ilDB->fetchAssoc($r))
4860 || $user[
"ctime"] + $atime > $ctime)
4862 $users[$user[
"user_id"]] = $user;
4866 return $users ? $users : array();
4883 $hashcode = substr(md5(uniqid(rand(),
true)), 0, 16);
4885 $res = $ilDB->queryf(
'
4886 SELECT COUNT(usr_id) cnt FROM usr_data
4887 WHERE reg_hash = %s',
4892 if(
$row->cnt > 0) $continue =
true;
4896 if($continue)
continue;
4898 $ilDB->manipulateF(
'
4902 array(
'text',
'integer'),
4903 array($hashcode, (
int)$a_usr_id)
4925 $res = $ilDB->queryf(
'
4926 SELECT usr_id, create_date FROM usr_data
4927 WHERE reg_hash = %s',
4930 while(
$row = $ilDB->fetchAssoc(
$res))
4932 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
4935 if((
int)$oRegSettigs->getRegistrationHashLifetime() != 0 &&
4936 time() - (int)$oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row[
'create_date']))
4938 require_once
'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
4942 $ilDB->manipulateF(
'
4946 array(
'text',
'integer'),
4947 array(
'', (
int)
$row[
'usr_id'])
4950 return (
int)$row[
'usr_id'];
4953 require_once
'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
4959 if (strlen($a_birthday))
4966 $this->birthday = null;
4985 if( !(
int)$period )
throw new ilException(
'no valid period given');
4989 $date = date(
'Y-m-d H:i:s', (time() - ((
int)$period * 24 * 60 * 60)) );
4991 $query =
"SELECT usr_id FROM usr_data WHERE last_login < %s";
4993 $res = $ilDB->queryF(
$query, array(
'timestamp'), array($date));
4998 $ids[] =
$row->usr_id;
5015 if($a_last_login !== null) $last_login = $a_last_login;
5016 else $last_login = date(
'Y-m-d H:i:s');
5020 $query =
"UPDATE usr_data SET usr_data.last_login = %s WHERE usr_data.usr_id = %s";
5021 $affected = $ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array($last_login, $a_usr_id) );
5023 if($affected)
return $last_login;
5031 $query =
"UPDATE object_data SET owner = 0 ".
5032 "WHERE owner = ".$ilDB->quote($this->
getId(),
'integer');
5049 $q =
"SELECT DISTINCT ".$ilDB->upper($ilDB->substr(
"lastname", 1, 1)).
" let FROM usr_data ORDER BY let";
5050 $let_set = $ilDB->query($q);
5053 while ($let_rec = $ilDB->fetchAssoc($let_set))
5055 $let[$let_rec[
"let"]] = $let_rec[
"let"];
5067 return $this->
getId() == ANONYMOUS_USER_ID;