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';
134 function ilObjUser($a_user_id = 0, $a_call_by_reference =
false)
143 $this->
ilObject($a_user_id, $a_call_by_reference);
144 $this->auth_mode =
"default";
154 $this->
setId($a_user_id);
161 $this->prefs = array();
163 $this->prefs[
"language"] = $this->ilias->ini->readVariable(
"language",
"default");
166 $this->skin = $this->ilias->ini->readVariable(
"layout",
"skin");
169 $this->prefs[
"show_users_online"] =
"y";
172 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
189 $r = $ilDB->queryF(
"SELECT * FROM usr_data ".
190 "WHERE usr_id= %s", array(
"integer"), array($this->
id));
192 if (
$data = $ilDB->fetchAssoc($r))
196 if (
$data[
"passwd"] ==
"" &&
$data[
"i2passwd"] !=
"")
206 unset(
$data[
"i2passw"]);
222 if ($this->prefs[
"language"] ==
"")
224 $this->prefs[
"language"] = $this->oldPrefs[
"language"];
228 include_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
229 if ($this->prefs[
"skin"] ==
"" ||
232 $this->prefs[
"skin"] = $this->oldPrefs[
"skin"];
235 $this->skin = $this->prefs[
"skin"];
238 if ($this->prefs[
"style"] ==
"" ||
242 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
245 if (empty($this->prefs[
"hits_per_page"]))
247 $this->prefs[
"hits_per_page"] = 10;
253 $ilErr->raiseError(
"<b>Error: There is no dataset with id ".
254 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
255 "<br />Line: ".__LINE__, $ilErr->FATAL);
274 if (! $a_data[
"passwd_type"])
276 $ilErr->raiseError(
"<b>Error: passwd_type missing in function assignData(). ".
277 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: "
278 .__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
280 if ($a_data[
"passwd"] !=
"********" and strlen($a_data[
'passwd']))
282 $this->
setPasswd($a_data[
"passwd"], $a_data[
"passwd_type"]);
290 if (!is_array($a_data[
'birthday']))
303 $this->
setCity($a_data[
"city"]);
309 $this->
setFax($a_data[
"fax"]);
333 $this->create_date = $a_data[
"create_date"];
334 $this->
setComment($a_data[
"referral_comment"]);
335 $this->approve_date = $a_data[
"approve_date"];
336 $this->active = $a_data[
"active"];
337 $this->agree_date = $a_data[
"agree_date"];
367 switch ($this->passwd_type)
370 $pw_field =
"passwd";
371 if(strlen($this->passwd))
373 $pw_value = md5($this->passwd);
382 $pw_field =
"passwd";
387 $pw_field =
"i2passwd";
392 $ilErr->raiseError(
"<b>Error: passwd_type missing in function saveAsNew. ".
393 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
394 "<br />Line: ".__LINE__, $ilErr->FATAL);
397 $insert_array = array(
398 "usr_id" => array(
"integer", $this->
id),
399 "login" => array(
"text", $this->login),
400 $pw_field => array(
"text", $pw_value),
401 "firstname" => array(
"text", $this->firstname),
402 "lastname" => array(
"text", $this->lastname),
403 "title" => array(
"text", $this->utitle),
404 "gender" => array(
"text", $this->gender),
405 "email" => array(
"text", $this->email),
406 "hobby" => array(
"text", (
string) $this->hobby),
407 "institution" => array(
"text", $this->institution),
408 "department" => array(
"text", $this->department),
409 "street" => array(
"text", $this->street),
410 "city" => array(
"text", $this->city),
411 "zipcode" => array(
"text", $this->zipcode),
412 "country" => array(
"text", $this->country),
413 "phone_office" => array(
"text", $this->phone_office),
414 "phone_home" => array(
"text", $this->phone_home),
415 "phone_mobile" => array(
"text", $this->phone_mobile),
416 "fax" => array(
"text", $this->fax),
418 "last_login" => array(
"timestamp", null),
419 "last_update" => array(
"timestamp",
ilUtil::now()),
420 "create_date" => array(
"timestamp",
ilUtil::now()),
421 "referral_comment" => array(
"text", $this->referral_comment),
422 "matriculation" => array(
"text", $this->matriculation),
423 "client_ip" => array(
"text", $this->client_ip),
424 "approve_date" => array(
"timestamp", $this->approve_date),
425 "agree_date" => array(
"timestamp", $this->agree_date),
426 "active" => array(
"integer", (
int) $this->active),
431 "auth_mode" => array(
"text", $this->
getAuthMode()),
434 "im_icq" => array(
"text", $this->im_icq),
435 "im_yahoo" => array(
"text", $this->im_yahoo),
436 "im_msn" => array(
"text", $this->im_msn),
437 "im_aim" => array(
"text", $this->im_aim),
438 "im_skype" => array(
"text", $this->im_skype),
439 "delicious" => array(
"text", $this->delicious),
440 "latitude" => array(
"text", $this->latitude),
441 "longitude" => array(
"text", $this->longitude),
442 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
443 "last_password_change" => array(
"integer", (
int) $this->last_password_change_ts),
444 "im_jabber" => array(
"text", $this->im_jabber),
445 "im_voip" => array(
"text", $this->im_voip)
447 $ilDB->insert(
"usr_data", $insert_array);
455 include_once (
"Services/Mail/classes/class.ilMailbox.php");
457 $mbox->createDefaultFolder();
459 include_once
"Services/Mail/classes/class.ilMailOptions.php";
461 $mail_options->createMailOptionsEntry();
464 include_once
"./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php";
466 $bmf->createNewBookmarkTree();
480 $update_array = array(
481 "gender" => array(
"text", $this->gender),
482 "title" => array(
"text", $this->utitle),
483 "firstname" => array(
"text", $this->firstname),
484 "lastname" => array(
"text", $this->lastname),
485 "email" => array(
"text", $this->email),
487 "hobby" => array(
"text", $this->hobby),
488 "institution" => array(
"text", $this->institution),
489 "department" => array(
"text", $this->department),
490 "street" => array(
"text", $this->street),
491 "city" => array(
"text", $this->city),
492 "zipcode" => array(
"text", $this->zipcode),
493 "country" => array(
"text", $this->country),
494 "phone_office" => array(
"text", $this->phone_office),
495 "phone_home" => array(
"text", $this->phone_home),
496 "phone_mobile" => array(
"text", $this->phone_mobile),
497 "fax" => array(
"text", $this->fax),
498 "referral_comment" => array(
"text", $this->referral_comment),
499 "matriculation" => array(
"text", $this->matriculation),
500 "client_ip" => array(
"text", $this->client_ip),
501 "approve_date" => array(
"timestamp", $this->approve_date),
502 "active" => array(
"integer", $this->active),
509 "auth_mode" => array(
"text", $this->
getAuthMode()),
511 "im_icq" => array(
"text", $this->im_icq),
512 "im_yahoo" => array(
"text", $this->im_yahoo),
513 "im_msn" => array(
"text", $this->im_msn),
514 "im_aim" => array(
"text", $this->im_aim),
515 "im_skype" => array(
"text", $this->im_skype),
516 "delicious" => array(
"text", $this->delicious),
517 "latitude" => array(
"text", $this->latitude),
518 "longitude" => array(
"text", $this->longitude),
519 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
520 "last_password_change" => array(
"integer", $this->last_password_change_ts),
521 "im_jabber" => array(
"text", $this->im_jabber),
522 "im_voip" => array(
"text", $this->im_voip),
526 if (isset($this->agree_date) && (strtotime($this->agree_date) !==
false || $this->agree_date == null))
528 $update_array[
"agree_date"] = array(
"timestamp", $this->agree_date);
530 switch ($this->passwd_type)
533 if(strlen($this->passwd))
535 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
536 $update_array[
"passwd"] = array(
"text", (
string) md5($this->passwd));
540 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
541 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
546 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
547 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
551 $update_array[
"i2passwd"] = array(
"text", (
string) $this->passwd);
552 $update_array[
"passwd"] = array(
"text", (
string)
"");
556 $ilErr->raiseError(
"<b>Error: passwd_type missing in function update()".$this->
id.
"!</b><br />class: ".
557 get_class($this).
"<br />Script: ".__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
560 $ilDB->update(
"usr_data", $update_array, array(
"usr_id" => array(
"integer", $this->
id)));
572 $ilAppEventHandler->raise(
"Services/User",
"afterUpdate",
573 array(
"user_obj" => $this));
585 $ilDB->manipulateF(
"UPDATE usr_data SET agree_date = ".$ilDB->now().
586 " WHERE usr_id = %s", array(
"integer"), array($this->
getId()));
592 private function _lookup($a_user_id, $a_field)
596 $res = $ilDB->queryF(
"SELECT ".$a_field.
" FROM usr_data WHERE usr_id = %s",
597 array(
"integer"), array($a_user_id));
599 while($set = $ilDB->fetchAssoc(
$res))
601 return $set[$a_field];
613 $set = $ilDB->queryF(
"SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s",
614 array(
"integer"), array($a_user_id));
616 if ($rec = $ilDB->fetchAssoc($set))
622 if ($rec[
"firstname"])
626 if ($rec[
"lastname"])
678 $res = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
679 array(
"integer"), array($a_user_id));
680 $user_rec = $ilDB->fetchAssoc(
$res);
681 return array(
"user_id" => $a_user_id,
682 "firstname" => $user_rec[
"firstname"],
683 "lastname" => $user_rec[
"lastname"],
684 "title" => $user_rec[
"title"],
685 "login" => $user_rec[
"login"]);
695 $res = $ilDB->queryF(
"SELECT * FROM usr_data WHERE usr_id = %s",
696 array(
"integer"), array($a_user_id));
697 $user_rec = $ilDB->fetchAssoc(
$res);
724 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data WHERE login = %s",
725 array(
"text"), array($a_user_str));
726 $user_rec = $ilDB->fetchAssoc(
$res);
727 return $user_rec[
"usr_id"];
748 $ilDB->manipulateF(
"UPDATE usr_data SET ".
749 "last_login = ".$ilDB->now().
750 " WHERE usr_id = %s",
751 array(
"integer"), array($this->
id));
765 $this->passwd = $new_md5;
767 $ilDB->manipulateF(
"UPDATE usr_data SET ".
770 array(
"text",
"integer"), array($this->passwd, $this->
id));
787 if (func_num_args() != 3)
792 if (!isset($a_old) or !isset($a_new1) or !isset($a_new2))
797 if ($a_new1 != $a_new2)
803 if ($a_new1 ==
"" || $a_old ==
"")
809 switch ($this->passwd_type)
812 if ($a_old != $this->passwd)
819 if (md5($a_old) != $this->passwd)
834 $this->passwd = md5($a_new1);
837 $ilDB->manipulateF(
"UPDATE usr_data SET ".
840 array(
"text",
"integer"), array($this->passwd, $this->
id));
856 if (func_num_args() != 2)
861 if (!isset($a_new1) or !isset($a_new2))
866 if ($a_new1 != $a_new2)
872 $this->passwd = md5($a_new1);
875 $ilDB->manipulateF(
"UPDATE usr_data SET ".
878 array(
"text",
"integer"),
879 array($this->passwd, $this->
id));
889 return (crypt($a_passwd,substr($a_passwd,0,2)));
899 $user_set = $ilDB->queryF(
"SELECT i2passwd FROM usr_data ".
900 "WHERE login = %s", array(
"text"), array($a_user_login));
901 if ($user_rec = $ilDB->fetchAssoc($user_set))
903 if ($user_rec[
"i2passwd"] !=
"")
919 $user_set = $ilDB->queryF(
"SELECT i2passwd FROM usr_data ".
920 "WHERE login = %s", array(
"text"), array($a_user_login));
921 if ($user_rec = $ilDB->fetchAssoc($user_set))
925 $ilDB->manipulateF(
"UPDATE usr_data SET passwd = %s, i2passwd = %s".
927 array(
"text",
"text",
"text"),
928 array(md5($a_pw),
"", $a_user));
950 $res = $ilDB->queryF(
'
951 SELECT * FROM loginname_history
953 array(
'text'), array($a_login));
955 return $ilDB->fetchAssoc(
$res) ?
true :
false;
974 $ilDB->setLimit(1, 0);
975 $res = $ilDB->queryF(
'
976 SELECT login, history_date FROM loginname_history
977 WHERE usr_id = %s ORDER BY history_date DESC',
978 array(
'integer'), array($a_usr_id));
998 if(func_num_args() != 1)
1003 if(!isset($a_login))
1009 if($a_login == self::_lookupLogin($this->
getId()))
1021 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1022 (int)$ilSetting->get(
'prevent_reuse_of_loginnames') &&
1025 throw new ilUserException($this->lng->txt(
'loginname_already_exists'));
1027 else if((
int)$ilSetting->get(
'allow_change_loginname') &&
1028 (int)$ilSetting->get(
'loginname_change_blocking_time') &&
1029 is_array($last_history_entry) &&
1030 $last_history_entry[1] + (int)$ilSetting->get(
'loginname_change_blocking_time') > time())
1032 include_once
'Services/Calendar/classes/class.ilDate.php';
1035 $this->lng->txt(
'changing_loginname_not_possible_info'),
1039 new ilDateTime(($last_history_entry[1] + (
int)$ilSetting->get(
'loginname_change_blocking_time')),
IL_CAL_UNIX))
1046 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1047 (int)$ilSetting->get(
'create_history_loginname'))
1053 $this->login = $a_login;
1055 $ilDB->manipulateF(
'
1059 array(
'text',
'integer'), array($this->
getLogin(), $this->
getId()));
1074 $this->
setPref($a_keyword, $a_value);
1097 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
1098 array(
"integer",
"text"), array($a_user_id, $a_keyword));
1110 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s",
1111 array(
"integer"), array($a_user_id));
1122 if (strlen($a_value))
1124 $ilDB->manipulateF(
"INSERT INTO usr_pref (usr_id, keyword, value) VALUES (%s,%s,%s)",
1125 array(
"integer",
"text",
"text"), array($a_usr_id, $a_keyword, $a_value));
1138 foreach ($this->prefs as $keyword => $value)
1152 if($tz = $this->
getPref(
'user_tz'))
1158 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1160 return $settings->getDefaultTimeZone();
1172 if($format = $this->
getPref(
'time_format'))
1178 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1180 return $settings->getDefaultTimeFormat();
1192 if ($a_keyword !=
"")
1194 $this->prefs[$a_keyword] = $a_value;
1205 if (array_key_exists($a_keyword, $this->prefs))
1207 return $this->prefs[$a_keyword];
1219 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
" ".
1220 "AND keyword = ".$ilDB->quote($a_keyword,
"text");
1239 if (is_array($this->prefs))
1255 global $rbacadmin,
$ilDB;
1258 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1260 $mapping->deleteUser($this->
getId());
1263 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1266 $mailbox->updateMailsOfDeletedUser();
1269 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1271 $costum_block->setContextObjId($this->
getId());
1272 $costum_block->setContextObjType(
"user");
1273 $c_blocks = $costum_block->queryBlocksForContext();
1274 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1275 foreach($c_blocks as $c_block)
1277 if ($c_block[
"type"] ==
"pdfeed")
1286 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1290 $ilDB->manipulateF(
"DELETE FROM usr_data WHERE usr_id = %s",
1291 array(
"integer"), array($this->
getId()));
1297 include_once(
"./Services/Authentication/classes/class.ilSession.php");
1301 $rbacadmin->removeUser($this->
getId());
1305 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1306 $ilDB->quote($this->
getId(),
"integer");
1307 $ilDB->manipulate(
$q);
1309 $q =
"DELETE FROM bookmark_data WHERE user_id = ".
1310 $ilDB->quote($this->
getId(),
"integer");
1311 $ilDB->manipulate(
$q);
1314 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1318 include_once
'./classes/class.ilLinkCheckNotify.php';
1322 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1326 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1329 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1352 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1354 $this->fullname =
"";
1362 $this->fullname = $this->utitle.
" ";
1369 elseif ($this->firstname)
1371 $this->fullname .= $this->firstname.
" ";
1403 if (strlen($this->fullname) <= $a_max_strlen)
1408 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1410 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1413 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1418 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1437 $q =
"SELECT * FROM lo_access ".
1438 "WHERE usr_id= ".$ilDB->quote((
int) $this->
id,
"integer").
" ".
1439 "ORDER BY timestamp DESC";
1440 $rst = $ilDB->query(
$q);
1444 while($record = $ilDB->fetchObject($rst))
1447 "timestamp" => $record->timestamp,
1448 "usr_id" => $record->usr_id,
1449 "lm_id" => $record->lm_id,
1450 "obj_id" => $record->obj_id,
1451 "lm_title" => $record->lm_title);
1467 $q =
"SELECT * FROM lo_access ".
1468 "WHERE usr_id= ".$ilDB->quote((
int) $this->
id,
"integer").
" ";
1469 $rst = $ilDB->query(
$q);
1476 "timestamp" => $record->timestamp,
1477 "usr_id" => $record->usr_id,
1478 "lm_id" => $record->lm_id,
1479 "obj_id" => $record->obj_id,
1480 "lm_title" => $record->lm_title);
1497 if($a_username ==
'root')
1502 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
1503 "WHERE login = %s AND NOT agree_date IS NULL",
1504 array(
"text"), array($a_username));
1505 return $ilDB->fetchAssoc(
$res) ?
true :
false;
1514 if ($this->agree_date != null || $this->login ==
"root")
1528 $this->login = $a_str;
1547 $this->passwd = $a_str;
1548 $this->passwd_type = $a_type;
1580 $this->gender = substr($a_str,-1);
1601 $this->utitle = $a_str;
1622 $this->firstname = $a_str;
1641 $this->lastname = $a_str;
1660 $this->institution = $a_str;
1679 $this->department = $a_str;
1698 $this->street = $a_str;
1717 $this->city = $a_str;
1736 $this->zipcode = $a_str;
1755 $this->country = $a_str;
1774 $this->phone_office = $a_str;
1793 $this->phone_home = $a_str;
1812 $this->phone_mobile = $a_str;
1831 $this->fax = $a_str;
1850 $this->client_ip = $a_str;
1869 $this->matriculation = $a_str;
1891 $query =
"SELECT matriculation FROM usr_data ".
1892 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1895 return $row->matriculation ?
$row->matriculation :
'';
1905 $this->email = $a_str;
1924 $this->hobby = $a_str;
1943 $this->
setPref(
"language",$a_str);
1954 return $this->prefs[
"language"];
1967 $this->
setPref(
"disk_quota",$a_disk_quota);
1981 return $this->prefs[
"disk_quota"] ? $this->prefs[
"disk_quota"] : 0;
1986 $this->last_password_change_ts = $a_last_password_change_ts;
1999 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
2000 $ilDB->quote($a_usr_id,
"integer").
" AND keyword = ".
2001 $ilDB->quote(
'language',
"text");
2002 $r = $ilDB->query(
$q);
2004 while(
$row = $ilDB->fetchAssoc($r))
2006 return $row[
'value'];
2017 if ($pw == md5($a_pw))
2028 $ilDB->manipulateF(
"UPDATE usr_data ".
2029 " SET ext_account = %s WHERE usr_id = %s",
2030 array(
"text",
"integer"),
2031 array($a_ext_id, $a_usr_id));
2038 $ilDB->manipulateF(
"UPDATE usr_data ".
2039 " SET auth_mode = %s WHERE usr_id = %s",
2040 array(
"text",
"integer"),
2041 array($a_auth_mode, $a_usr_id));
2060 $this->last_login = $a_str;
2070 return $this->last_login;
2080 $this->last_update = $a_str;
2094 $this->referral_comment = $a_str;
2114 $this->approve_date = $a_str;
2145 $this->agree_date = $a_str;
2157 if (empty($a_owner))
2206 if ((!empty($storedActive) && empty($currentActive)) ||
2207 (empty($storedActive) && !empty($currentActive)))
2222 return $active ?
true :
false;
2233 $this->skin = $a_str;
2238 $this->time_limit_owner = $a_owner;
2242 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2246 $this->time_limit_from = $a_from;
2250 return $this->time_limit_from ? $this->time_limit_from : time();
2254 $this->time_limit_until = $a_until;
2258 return $this->time_limit_until ? $this->time_limit_until : time();
2262 $this->time_limit_unlimited = $a_unlimited;
2266 return $this->time_limit_unlimited;
2270 return $this->time_limit_message = $a_time_limit_message;
2274 return $this->time_limit_message;
2279 $this->login_attempts = $a_login_attempts;
2302 $this->profile_incomplete = (boolean) $a_prof_inc;
2306 return $this->profile_incomplete;
2312 if( $this->
id == ANONYMOUS_USER_ID || $this->
id == SYSTEM_USER_ID )
2315 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2319 && $security->isPasswordChangeOnFirstLoginEnabled()
2330 if($this->
id == ANONYMOUS_USER_ID)
return false;
2332 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2337 $max_pass_age = $security->getPasswordMaxAge();
2338 if( $max_pass_age > 0 )
2340 $max_pass_age_ts = ( $max_pass_age * 86400 );
2342 $current_ts = time();
2344 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2353 $current_ts = time();
2355 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2356 return $password_age;
2365 $query =
"UPDATE usr_data SET usr_data.last_password_change = %s " .
2366 "WHERE usr_data.usr_id = %s";
2367 $affected = $ilDB->manipulateF(
$query,
2368 array(
'integer',
'integer'),
2370 if($affected)
return true;
2378 $query =
"UPDATE usr_data SET usr_data.last_password_change = 0 " .
2379 "WHERE usr_data.usr_id = %s";
2380 $affected = $ilDB->manipulateF(
$query, array(
'integer'),
2381 array($this->
getId()) );
2382 if($affected)
return true;
2393 $this->latitude = $a_latitude;
2413 $this->longitude = $a_longitude;
2433 $this->loc_zoom = $a_locationzoom;
2448 $this->applied_users = array();
2451 return $this->applied_users ? $this->applied_users : array();
2456 if($a_usr_id == $this->
getId())
2461 $this->applied_users = array();
2464 return in_array($a_usr_id,$this->applied_users);
2471 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2472 "WHERE time_limit_owner = %s",
2474 array($a_parent_id));
2475 while (
$row = $ilDB->fetchObject(
$res))
2477 $this->applied_users[] =
$row->usr_id;
2498 if(
$id != ANONYMOUS_USER_ID && (
int)$ilSetting->get(
'ps_prevent_simultaneous_logins') == 1 )
2500 $res = $ilDB->queryf(
'
2501 SELECT * FROM usr_session WHERE user_id = %s AND expires > %s',
2502 array(
'integer',
'integer'),
2503 array(
$id, time()));
2525 require_once (
'Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2528 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2529 require_once (
'Services/Database/classes/class.ilAuthContainerMDB2.php');
2534 $login =$ilAuth->getUsername();
2550 $set = $ilDB->queryF(
"SELECT active FROM usr_data WHERE login= %s",
2554 if ($rec = $ilDB->fetchAssoc($set))
2590 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
2591 "WHERE email = %s and active = 1",
2595 while(
$row = $ilDB->fetchObject(
$res))
2597 $ids[] =
$row->login;
2617 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2618 "WHERE email = %s", array(
"text"), array($a_email));
2621 return $row->usr_id ?
$row->usr_id : 0;
2648 static function searchUsers($a_search_str,
$active = 1, $a_return_ids_only =
false, $filter_settings = FALSE)
2653 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2655 $without_anonymous_users =
true;
2658 $join_filter =
" WHERE ";
2659 if ($filter_settings !== FALSE && strlen($filter_settings))
2661 switch ($filter_settings)
2665 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.usr_id IS NULL AND ";
2672 $join_filter =
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id WHERE crs_members.obj_id = ".
2673 "(SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") AND ";
2681 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2682 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2683 if (is_array($local_roles) && count($local_roles))
2685 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2686 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false, $local_roles).
" AND ";
2692 $rol_id =
$_SESSION[
"user_filter_data"];
2695 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2696 $ilDB->quote($rol_id,
"integer").
" AND ";
2697 $without_anonymous_users =
false;
2704 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2706 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2707 "FROM object_data,rbac_ua,usr_data ".
2708 "WHERE ".$ilDB->like(
"object_data.title",
"text",
"%".substr($a_search_str,5).
"%").
2709 " AND object_data.type = 'role' ".
2710 "AND rbac_ua.rol_id = object_data.obj_id ".
2711 "AND usr_data.usr_id = rbac_ua.usr_id ".
2712 "AND rbac_ua.usr_id != ".$illDB->quote(ANONYMOUS_USER_ID,
"integer");
2717 "(".$ilDB->like(
"usr_data.login",
"text",
"%".$a_search_str.
"%").
" ".
2718 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_search_str.
"%").
" ".
2719 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_search_str.
"%").
" ".
2720 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_search_str.
"%").
") ";
2722 if ($filter_settings !== FALSE && strlen($filter_settings))
2724 switch ($filter_settings)
2727 $query.=
" AND usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
2730 $query.=
" AND usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
2733 $query.=
" AND usr_data.time_limit_unlimited = ".$ilDB->quote(0,
"integer").
" ";
2736 $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"]));
2737 $query.=
" AND last_login < ".$ilDB->quote($date,
"timestamp").
" ";
2742 if ($without_anonymous_users)
2744 $query.=
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2747 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE)
2749 $query.=
" AND active = ".$ilDB->quote(
$active,
"integer").
" ";
2755 while (
$row = $ilDB->fetchObject(
$res))
2758 "usr_id" =>
$row->usr_id,
2759 "login" =>
$row->login,
2760 "firstname" =>
$row->firstname,
2761 "lastname" =>
$row->lastname,
2762 "email" =>
$row->email,
2763 "active" =>
$row->active);
2764 $ids[] =
$row->usr_id;
2766 if ($a_return_ids_only)
2767 return $ids ? $ids : array();
2769 return $users ? $users : array();
2784 $res = $ilDB->query(
"SELECT login FROM usr_data");
2785 while(
$row = $ilDB->fetchObject(
$res))
2787 $logins[] =
$row->login;
2789 return $logins ? $logins : array();
2803 $res = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
2804 $ilDB->in(
"usr_id", $a_user_ids,
false,
"integer"));
2805 while (
$row = $ilDB->fetchAssoc(
$res))
2807 $user_data[
"$row[usr_id]"] =
$row;
2809 return $user_data ? $user_data : array();
2824 $result_arr = array();
2828 if ($a_fields !== NULL and is_array($a_fields))
2830 if (count($a_fields) == 0)
2836 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2837 unset($a_fields[$usr_id_field]);
2839 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2841 if(in_array(
'online_time',$a_fields))
2843 $select .=
",ut_online.online_time ";
2847 $q =
"SELECT ".$select.
" FROM usr_data ";
2851 if(in_array(
'online_time',$a_fields))
2853 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2860 $q .=
"WHERE active = ".$ilDB->quote(
$active,
"integer");
2863 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
2866 $qtemp =
$q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
2867 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
2868 $r = $ilDB->query($qtemp);
2869 $course_users = array();
2870 while (
$row = $ilDB->fetchAssoc($r))
2872 array_push($course_users,
$row[
"usr_id"]);
2874 if (count($course_users))
2876 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
2884 $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"]));
2885 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
2891 $q .=
" LEFT JOIN crs_members ON usr_data.usr_id = crs_members.usr_id ".
2892 "WHERE crs_members.obj_id = (SELECT obj_id FROM object_reference ".
2893 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
2901 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2902 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2903 if (is_array($local_roles) && count($local_roles))
2905 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2906 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
2911 $rol_id =
$_SESSION[
"user_filter_data"];
2914 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2915 $ilDB->quote($rol_id,
"integer");
2920 $r = $ilDB->query(
$q);
2922 while (
$row = $ilDB->fetchAssoc($r))
2924 $result_arr[] =
$row;
2938 $q =
"SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ".
2939 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
2940 " AND up1.value= ".$ilDB->quote($a_style,
"text").
2941 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
2942 " AND up2.value= ".$ilDB->quote($a_skin,
"text").
2943 " AND up1.usr_id = up2.usr_id ";
2945 $cnt_set = $ilDB->query(
$q);
2947 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
2949 return $cnt_rec[
"cnt"];
2959 $q =
"SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ".
2960 " WHERE up1.keyword = ".$ilDB->quote(
"style",
"text").
2961 " AND up2.keyword = ".$ilDB->quote(
"skin",
"text").
2962 " AND up1.usr_id = up2.usr_id";
2964 $sty_set = $ilDB->query(
$q);
2967 while($sty_rec = $ilDB->fetchAssoc($sty_set))
2969 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
2982 $q =
"SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ".
2983 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
2984 " AND up1.value= ".$ilDB->quote($a_from_style,
"text").
2985 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
2986 " AND up2.value= ".$ilDB->quote($a_from_skin,
"text").
2987 " AND up1.usr_id = up2.usr_id ";
2989 $usr_set = $ilDB->query(
$q);
2991 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3012 $item_set = $ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3013 "item_id = %s AND type = %s AND user_id = %s",
3014 array(
"integer",
"text",
"integer"),
3015 array($a_item_id, $a_type, $a_usr_id));
3018 if (!$ilDB->fetchAssoc($item_set))
3020 $ilDB->manipulateF(
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3021 " (%s,%s,%s,%s)", array(
"integer",
"text",
"integer",
"text"),
3022 array($a_item_id,$a_type,$a_usr_id,$a_par));
3025 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3053 $ilDB->manipulateF(
"UPDATE desktop_item SET parameters = %s ".
3054 " WHERE item_id = %s AND type = %s AND user_id = %s",
3055 array(
"text",
"integer",
"text",
"integer"),
3056 array($a_par, $a_item_id, $a_type, $this->
getId()));
3073 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE ".
3074 " item_id = %s AND type = %s AND user_id = %s",
3075 array(
"integer",
"text",
"integer"),
3076 array($a_item_id, $a_type, $a_usr_id));
3078 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3104 $r = $ilDB->queryF(
"SELECT user_id FROM desktop_item WHERE item_id = %s",
3105 array(
"integer"), array($a_id));
3109 while (
$row = $ilDB->fetchObject($r))
3111 $users[] =
$row->user_id;
3114 if (count($users) > 0)
3116 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE item_id = %s",
3117 array(
"integer"), array($a_id));
3136 $item_set = $ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3137 "item_id = %s AND type = %s AND user_id = %s",
3138 array(
"integer",
"text",
"integer"),
3139 array($a_item_id, $a_type, $a_usr_id));
3141 if ($ilDB->fetchAssoc($item_set))
3176 global $ilUser, $rbacsystem, $tree,
$ilDB;
3180 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3181 " FROM desktop_item it, object_reference oref ".
3182 ", object_data obj".
3184 "it.item_id = oref.ref_id AND ".
3185 "oref.obj_id = obj.obj_id AND ".
3186 "it.user_id = %s", array(
"integer"), array($user_id));
3188 while ($item_rec = $ilDB->fetchAssoc($item_set))
3190 if ($tree->isInTree($item_rec[
"ref_id"])
3191 && $item_rec[
"type"] !=
"rolf")
3193 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3194 $par_left = $tree->getLeftValue($parent_ref);
3195 $par_left = sprintf(
"%010d", $par_left);
3200 $items[$par_left.$title.$item_rec[
"ref_id"]] =
3201 array(
"ref_id" => $item_rec[
"ref_id"],
3202 "obj_id" => $item_rec[
"obj_id"],
3203 "type" => $item_rec[
"type"],
3205 "description" =>
$desc,
3206 "parent_ref" => $parent_ref);
3213 if (!is_array($a_types))
3215 $a_types = array($a_types);
3218 $foundsurveys = array();
3219 foreach($a_types as $a_type)
3221 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ".
3222 ", object_data obj WHERE ".
3223 "it.item_id = oref.ref_id AND ".
3224 "oref.obj_id = obj.obj_id AND ".
3225 "it.type = %s AND ".
3228 array(
"text",
"integer"),
3229 array($a_type, $user_id));
3231 while ($item_rec = $ilDB->fetchAssoc($item_set))
3235 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3236 array(
"ref_id" => $item_rec[
"ref_id"],
3237 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3261 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3267 $a_time = date(
"Y-m-d H:i:s", time());
3270 $item_set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3271 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3272 array(
"integer",
"integer",
"text",
"integer"),
3273 array(0, $a_item_id, $a_type, $this->
getId()));
3276 if (!
$d = $item_set->fetchRow())
3278 $ilDB->manipulateF(
"INSERT INTO personal_clipboard ".
3279 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3280 " (%s,%s,%s,%s,%s,%s,%s)",
3281 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"),
3282 array($a_item_id, $a_type, $this->
getId(), $a_title, (
int) $a_parent, $a_time, (
int) $a_order_nr));
3286 $ilDB->manipulateF(
"UPDATE personal_clipboard SET insert_time = %s ".
3287 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3288 array(
"timestamp",
"integer",
"integer",
"text"),
3289 array($a_time, $this->
getId(), $a_item_id, $a_type));
3301 $a_time = date(
"Y-m-d H:i:s", time());
3303 $ilDB->insert(
"personal_pc_clipboard", array(
3304 "user_id" => array(
"integer", $this->
getId()),
3305 "content" => array(
"clob", $a_content),
3306 "insert_time" => array(
"timestamp", $a_time),
3307 "order_nr" => array(
"integer", $a_nr)
3318 $set = $ilDB->queryF(
"SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ".
3319 " WHERE user_id = %s", array(
"integer"), array($this->
getId()));
3320 $row = $ilDB->fetchAssoc($set);
3322 $set = $ilDB->queryF(
"SELECT * FROM personal_pc_clipboard ".
3323 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3324 array(
"integer",
"timestamp"),
3327 while (
$row = $ilDB->fetchAssoc($set))
3329 $content[] =
$row[
"content"];
3342 $set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3343 "parent = %s AND type = %s AND user_id = %s",
3344 array(
"integer",
"text",
"integer"),
3345 array(0, $a_type, $this->
getId()));
3346 if ($rec = $ilDB->fetchAssoc($set))
3361 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3362 "type = %s AND user_id = %s",
3363 array(
"text",
"integer"),
3364 array($a_type, $this->
getId()));
3374 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3375 "user_id = %s", array(
"integer"), array($this->
getId()));
3386 if ($a_top_nodes_only)
3388 $par =
" AND parent = ".$ilDB->quote(0,
"integer").
" ";
3391 $type_str = ($a_type !=
"")
3392 ?
" AND type = ".$ilDB->quote($a_type,
"text").
" "
3394 $q =
"SELECT * FROM personal_clipboard WHERE ".
3395 "user_id = ".$ilDB->quote($this->
getId(),
"integer").
" ".
3397 " ORDER BY order_nr";
3398 $objs = $ilDB->query(
$q);
3400 while ($obj = $ilDB->fetchAssoc($objs))
3402 if ($obj[
"type"] ==
"mob")
3406 if ($obj[
"type"] ==
"incl")
3408 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3411 $objects[] = array (
"id" => $obj[
"item_id"],
3412 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3413 "insert_time" => $obj[
"insert_time"]);
3423 global
$ilDB, $ilUser;
3425 $objs = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3426 "user_id = %s AND parent = %s AND insert_time = %s ".
3427 " ORDER BY order_nr",
3428 array(
"integer",
"integer",
"timestamp"),
3429 array($ilUser->getId(), (int) $a_parent, $a_insert_time));
3431 while ($obj = $ilDB->fetchAssoc($objs))
3433 if ($obj[
"type"] ==
"mob")
3437 $objects[] = array (
"id" => $obj[
"item_id"],
3438 "type" => $obj[
"type"],
"title" => $obj[
"title"]);
3455 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3456 "item_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
3457 "type = ".$ilDB->quote($a_type,
"text");
3458 $user_set = $ilDB->query(
$q);
3460 while ($user_rec = $ilDB->fetchAssoc($user_set))
3462 $users[] = $user_rec[
"user_id"];
3479 $q =
"DELETE FROM personal_clipboard WHERE ".
3480 "item_id = ".$ilDB->quote($a_item_id,
"integer").
3481 " AND type = ".$ilDB->quote($a_type,
"text").
" ".
3482 " AND user_id = ".$ilDB->quote($this->
getId(),
"integer");
3483 $ilDB->manipulate(
$q);
3490 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3491 $ilDB->quote($i2_id,
"text");
3494 while(
$row = $ilDB->fetchObject(
$res))
3525 $this->auth_mode = $a_str;
3539 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3552 $this->ext_account = $a_str;
3564 return $this->ext_account;
3582 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3583 $q =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3584 "WHERE auth_mode = %s";
3586 $values[] = $a_auth_mode;
3589 $q.=
" OR auth_mode = %s ";
3591 $values[] =
'default';
3594 $res = $ilDB->queryF(
$q, $types, $values);
3595 while (
$row = $ilDB->fetchObject(
$res))
3597 if(
$row->auth_mode ==
'default')
3599 $accounts[
$row->usr_id] =
$row->login;
3603 $accounts[
$row->usr_id] =
$row->ext_account;
3606 return $accounts ? $accounts : array();
3620 if(!is_array($a_usr_ids))
3624 $q =
"UPDATE usr_data SET active = %s WHERE ".
3625 $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3626 $ilDB->manipulateF(
$q, array(
"integer"), array(($a_status ? 1 : 0)));
3656 $r = $ilDB->queryF(
"SELECT * FROM usr_data WHERE ".
3657 " ext_account = %s AND auth_mode = %s",
3658 array(
"text",
"text"),
3659 array($a_account, $a_auth));
3660 if ($usr = $ilDB->fetchAssoc($r))
3662 return $usr[
"login"];
3666 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3667 "WHERE login = %s AND auth_mode = %s",
3668 array(
"text",
"text"),
3669 array($a_account, $a_auth));
3670 if($usr = $ilDB->fetchAssoc(
$res))
3672 return $usr[
'login'];
3678 $res = $ilDB->queryF(
"SELECT login FROM usr_data WHERE ".
3679 " ext_account = %s AND auth_mode = %s",
3680 array(
"text",
"text"),
3681 array($a_account,
"default"));
3682 if ($usr = $ilDB->fetchAssoc(
$res))
3684 return $usr[
"login"];
3687 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3688 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3689 array(
"text",
"text"),
3690 array($a_account,
"default"));
3691 if($usr = $ilDB->fetchAssoc(
$res))
3693 return $usr[
"login"];
3706 $r = $ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3707 "GROUP BY auth_mode");
3709 while($cnt = $ilDB->fetchAssoc($r))
3711 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3728 $q =
"SELECT * FROM usr_data WHERE ".
3729 " email = %s AND (auth_mode = %s ";
3730 $types = array(
"text",
"text");
3731 $values = array($a_email,
"local");
3733 if ($ilSetting->get(
"auth_mode") == 1)
3735 $q.=
" OR auth_mode = %s";
3737 $values[] =
"default";
3743 $usr_set = $ilDB->queryF(
$q, $types, $values);
3744 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3746 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3763 $image_dir = $webspace_dir.
"/usr_images";
3764 $store_file =
"usr_".$obj_id.
".".
"jpg";
3765 $target_file = $image_dir.
"/$store_file";
3767 chmod($tmp_file, 0770);
3771 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3772 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3773 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3774 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3776 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 200x200 -quality 100 JPEG:$show_file");
3777 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
3778 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
3779 system(
ilUtil::getConvertCmd().
" $tmp_file" .
"[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
3804 $a_prevent_no_photo_image =
false)
3809 $res = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE ".
3810 "keyword IN (%s,%s) ".
3812 array(
"text",
"text",
"integer"),
3813 array(
'public_upload',
'public_profile', $a_usr_id));
3814 while (
$row = $ilDB->fetchAssoc(
$res))
3816 switch (
$row[
'keyword'])
3818 case 'public_upload' :
3819 $upload =
$row[
'value'] ==
'y';
3821 case 'public_profile' :
3822 $profile = (
$row[
'value'] ==
'y' ||
3823 $row[
'value'] ==
'g');
3830 if(defined(
'ILIAS_MODULE'))
3832 $webspace_dir = (
'.'.$webspace_dir);
3834 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
3836 $image_dir = $webspace_dir.
"/usr_images";
3838 if ($a_size ==
'big')
3840 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
3844 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
3848 if((($upload && $profile) || $a_force_pic)
3849 && @is_file($thumb_file))
3851 $file = $thumb_file.
"?t=".rand(1, 99999);
3855 if (!$a_prevent_no_photo_image)
3870 $image_dir = $webspace_dir.
"/usr_images";
3871 $file = $image_dir.
"/usr_".$this->getID().
".".
"jpg";
3872 $thumb_file = $image_dir.
"/usr_".$this->getID().
"_small.jpg";
3873 $xthumb_file = $image_dir.
"/usr_".$this->getID().
"_xsmall.jpg";
3874 $xxthumb_file = $image_dir.
"/usr_".$this->getID().
"_xxsmall.jpg";
3875 $upload_file = $image_dir.
"/upload_".$this->getID();
3878 $this->
setPref(
"profile_image",
"");
3881 if (@is_file(
$file))
3885 if (@is_file($thumb_file))
3887 unlink($thumb_file);
3889 if (@is_file($xthumb_file))
3891 unlink($xthumb_file);
3893 if (@is_file($xxthumb_file))
3895 unlink($xxthumb_file);
3897 if (@is_file($upload_file))
3899 unlink($upload_file);
3906 if(!is_array($a_data))
3910 foreach($a_data as $field =>
$data)
3912 #$new_data[$field] = ilUtil::stripSlashes($data);
3914 $this->user_defined_data[
'f_'.$field] =
$data;
3916 #$this->user_defined_data = $new_data;
3923 return $this->user_defined_data ? $this->user_defined_data : array();
3932 $field_def = array();
3934 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
3937 foreach($this->user_defined_data as $field => $value)
3939 if($field !=
'usr_id')
3942 $udata->set($field, $value);
3974 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
3986 $this->user_defined_data = $udata->getAll();
4010 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4028 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
4029 include_once
'classes/class.ilFormat.php';
4031 global
$lng,$rbacreview;
4033 $language =& $a_language;
4034 $language->loadLanguageModule(
'registration');
4035 $language->loadLanguageModule(
'crs');
4038 $body .= ($language->txt(
"login").
": ".$this->
getLogin().
"\n");
4042 $body .= ($language->txt(
"title").
": ".$this->
getUTitle().
"\n");
4047 $language->txt(
'gender_m') :
4048 $language->txt(
'gender_f');
4049 $body .= ($language->txt(
"gender").
": ".
$gender.
"\n");
4053 $body .= ($language->txt(
"firstname").
": ".$this->
getFirstname().
"\n");
4057 $body .= ($language->txt(
"lastname").
": ".$this->
getLastname().
"\n");
4061 $body .= ($language->txt(
"institution").
": ".$this->
getInstitution().
"\n");
4065 $body .= ($language->txt(
"department").
": ".$this->
getDepartment().
"\n");
4069 $body .= ($language->txt(
"street").
": ".$this->
getStreet().
"\n");
4073 $body .= ($language->txt(
"city").
": ".$this->
getCity().
"\n");
4077 $body .= ($language->txt(
"zipcode").
": ".$this->
getZipcode().
"\n");
4081 $body .= ($language->txt(
"country").
": ".$this->
getCountry().
"\n");
4085 $body .= ($language->txt(
"phone_office").
": ".$this->
getPhoneOffice().
"\n");
4089 $body .= ($language->txt(
"phone_home").
": ".$this->
getPhoneHome().
"\n");
4093 $body .= ($language->txt(
"phone_mobile").
": ".$this->
getPhoneMobile().
"\n");
4095 if(strlen($this->
getFax()))
4097 $body .= ($language->txt(
"fax").
": ".$this->
getFax().
"\n");
4101 $body .= ($language->txt(
"email").
": ".$this->
getEmail().
"\n");
4105 $body .= ($language->txt(
"hobby").
": ".$this->
getHobby().
"\n");
4109 $body .= ($language->txt(
"referral_comment").
": ".$this->
getComment().
"\n");
4113 $body .= ($language->txt(
"matriculation").
": ".$this->
getMatriculation().
"\n");
4122 $body .= ($language->txt(
"create_date").
": ".$date.
"\n");
4125 foreach($rbacreview->getGlobalRoles() as $role)
4127 if($rbacreview->isAssigned($this->getId(),$role))
4134 $body .= ($language->txt(
'reg_role_info').
': '.implode(
',',$gr).
"\n");
4140 $body .= ($language->txt(
'time_limit').
": ".$language->txt(
'crs_unlimited').
"\n");
4150 $body .= $language->txt(
'time_limit').
': '.$period;
4163 $var =
"im_".$a_im_type;
4164 $this->$var = $a_im_id;
4169 $var =
"im_".$a_im_type;
4175 $this->delicious = $a_delicious;
4192 $set = $ilDB->queryF(
"SELECT feed_hash from usr_data WHERE usr_id = %s",
4193 array(
"integer"), array($a_user_id));
4194 if ($rec = $ilDB->fetchAssoc($set))
4196 if (strlen($rec[
"feed_hash"]) == 32)
4198 return $rec[
"feed_hash"];
4202 $hash = md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4203 $ilDB->manipulateF(
"UPDATE usr_data SET feed_hash = %s".
4204 " WHERE usr_id = %s",
4205 array(
"text",
"integer"),
4206 array($hash, $a_user_id));
4241 ($a_password==
"") ?
"" : md5($a_password));
4257 $q =
"SELECT DISTINCT login, usr_id FROM usr_data ".
4260 $values[] = $a_login;
4262 if ($a_user_id != 0)
4264 $q.=
" AND usr_id != %s ";
4265 $types[] =
"integer";
4266 $values[] = $a_user_id;
4269 $r = $ilDB->queryF(
$q, $types, $values);
4271 if (
$row = $ilDB->fetchAssoc($r))
4273 return $row[
'usr_id'];
4292 $res = $ilDB->queryF(
"SELECT * FROM usr_data ".
4293 "WHERE ext_account = %s AND auth_mode = %s",
4294 array(
"text",
"text"),
4295 array($a_external_account, $a_auth_mode));
4296 return $ilDB->fetchAssoc(
$res) ?
true :
false;
4307 global
$ilDB, $rbacreview;
4310 $ids = $rbacreview->assignedUsers($role_id);
4312 if (count ($ids) == 0)
4317 $query =
"SELECT usr_data.*, usr_pref.value AS language
4319 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4320 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4321 $values[] =
"language";
4327 $query .=
" AND usr_data.active = %s";
4329 $types[] =
"integer";
4332 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4334 $r = $ilDB->queryF(
$query, $types, $values);
4336 while (
$row = $ilDB->fetchAssoc($r))
4352 $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 ";
4354 $values[] =
"language";
4358 $query .=
" AND usr_data.active = %s";
4360 $types[] =
"integer";
4365 $query.=
" AND usr_data.time_limit_owner = %s";
4367 $types[] =
"integer";
4370 $query .=
" AND usr_data.usr_id != %s ";
4371 $values[] = ANONYMOUS_USER_ID;
4372 $types[] =
"integer";
4374 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4405 global $rbacadmin, $rbacreview,
$ilDB;
4409 foreach ($a_mem_ids as $mem_id) {
4410 $ids [] = $ilDB->quote($mem_id);
4413 $query =
"SELECT usr_data.*, usr_pref.value AS language
4415 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4416 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer").
"
4417 AND usr_data.usr_id != %s";
4418 $values[] =
"language";
4420 $values[] = ANONYMOUS_USER_ID;
4421 $types[] =
"integer";
4425 $query .=
" AND active = %s";
4427 $types[] =
"integer";
4432 $query.=
" AND usr_data.time_limit_owner = %s";
4433 $values[] = $timelimitowner;
4434 $types[] =
"integer";
4438 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4446 return $mem_arr ? $mem_arr : array();
4460 if (is_array($a_internalids)) {
4461 foreach ($a_internalids as $internalid) {
4462 if (is_numeric ($internalid))
4464 $ids[] = $internalid;
4469 if (is_numeric($parsedid) && $parsedid > 0)
4476 if (count($ids) == 0)
4479 $query =
"SELECT usr_data.*, usr_pref.value AS language
4482 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4483 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4484 $values[] =
"language";
4487 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4510 $r = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE usr_id = %s",
4511 array(
"integer"), array($user_id));
4513 while(
$row = $ilDB->fetchAssoc($r))
4526 $query =
"UPDATE usr_data SET usr_data.login_attempts = 0 WHERE usr_data.usr_id = %s";
4527 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4529 if($affected)
return true;
4537 $query =
"SELECT usr_data.login_attempts FROM usr_data WHERE usr_data.usr_id = %s";
4538 $result = $ilDB->queryF(
$query, array(
'integer'), array($a_usr_id) );
4539 $record = $ilDB->fetchAssoc(
$result );
4549 $query =
"UPDATE usr_data SET usr_data.login_attempts = (usr_data.login_attempts + 1) WHERE usr_data.usr_id = %s";
4550 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4552 if($affected)
return true;
4560 $query =
"UPDATE usr_data SET usr_data.active = 0 WHERE usr_data.usr_id = %s";
4561 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4563 if($affected)
return true;
4573 return in_array($this->
getPref(
"public_profile"), array(
"y",
"g"));
4596 $res = $ilDB->queryF(
'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4597 array(
'integer',
'text',
'integer'),
4600 if( $ilDB->numRows(
$res) == 0 )
4602 $ilDB->manipulateF(
'
4603 INSERT INTO loginname_history
4604 (usr_id, login, history_date)
4605 VALUES (%s, %s, %s)',
4606 array(
'integer',
'text',
'integer'),
4625 $atime = $pd_set->get(
"user_activity_time") * 60;
4628 if ($a_user_id == 0)
4630 $where =
"WHERE user_id != 0 AND NOT agree_date IS NULL ";
4631 $type_array = array(
"integer");
4632 $val_array = array(time());
4636 $where =
"WHERE user_id = %s ";
4637 $type_array = array(
"integer",
"integer");
4638 $val_array = array($a_user_id, time());
4641 $no_anonym = ($a_no_anonymous)
4642 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4645 $r = $ilDB->queryF(
"SELECT count(user_id) as num,user_id,firstname,lastname,title,login,last_login,max(ctime) AS ctime ".
4646 "FROM usr_session ".
4647 "LEFT JOIN usr_data u ON user_id = u.usr_id ".
4648 "LEFT JOIN usr_pref p ON (p.usr_id = u.usr_id AND p.keyword = ".
4649 $ilDB->quote(
"hide_own_online_status",
"text").
") ".$where.
4650 "AND expires > %s ".
4651 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4653 "GROUP BY user_id,firstname,lastname,title,login,last_login ".
4654 "ORDER BY lastname, firstname", $type_array, $val_array);
4656 while (
$user = $ilDB->fetchAssoc($r))
4659 ||
$user[
"ctime"] + $atime > $ctime)
4665 return $users ? $users : array();
4681 $atime = $pd_set->get(
"user_activity_time") * 60;
4683 $no_anonym = ($a_no_anonymous)
4684 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4691 $q =
"SELECT DISTINCT dat.obj_id as obj_id ".
4693 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4694 "JOIN object_reference r1 ON r1.ref_id = fa.parent ".
4695 "JOIN tree ON tree.child = r1.ref_id ".
4696 "JOIN object_reference r2 ON r2.ref_id = tree.parent ".
4697 "JOIN object_data dat ON dat.obj_id = r2.obj_id ".
4698 "WHERE ua.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4699 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4700 "AND dat.type IN (".$ilDB->quote(
"crs",
"text").
",".
4701 $ilDB->quote(
"grp",
"text").
")";
4702 $r = $ilDB->query(
$q);
4704 while (
$row = $ilDB->fetchAssoc($r))
4706 $groups_and_courses_of_user[] =
$row[
"obj_id"];
4709 if (count($groups_and_courses_of_user) == 0)
4711 $q =
"SELECT count(user_id) as num,ctime,user_id,firstname,lastname,title,login,last_login ".
4712 "FROM usr_session ".
4713 "JOIN usr_data ON user_id=usr_id ".
4714 "WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4716 " AND NOT agree_date IS NULL ".
4717 "AND expires > ".$ilDB->quote(time(),
"integer").
" ".
4718 "GROUP BY user_id,ctime,firstname,lastname,title,login,last_login";
4719 $r = $ilDB->query(
$q);
4723 $q =
"SELECT count(user_id) as num,s.ctime,s.user_id,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4724 "FROM usr_session s ".
4725 "JOIN usr_data ud ON ud.usr_id = s.user_id ".
4726 "JOIN rbac_ua ua ON ua.usr_id = s.user_id ".
4727 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4728 "JOIN tree ON tree.child = fa.parent ".
4729 "JOIN object_reference or1 ON or1.ref_id = tree.parent ".
4730 "JOIN object_data od ON od.obj_id = or1.obj_id ".
4731 "LEFT JOIN usr_pref p ON (p.usr_id = ud.usr_id AND p.keyword = ".
4732 $ilDB->quote(
"hide_own_online_status",
"text").
") ".
4733 "WHERE s.user_id != 0 ".
4735 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4736 "AND s.expires > ".$ilDB->quote(time(),
"integer").
" ".
4737 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4738 " AND NOT ud.agree_date IS NULL ".
4739 "AND ".$ilDB->in(
"od.obj_id", $groups_and_courses_of_user,
false,
"integer").
" ".
4740 "GROUP BY s.user_id,s.ctime,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4741 "ORDER BY ud.lastname, ud.firstname";
4742 $r = $ilDB->query(
$q);
4745 while (
$user = $ilDB->fetchAssoc($r))
4748 ||
$user[
"ctime"] + $atime > $ctime)
4754 return $users ? $users : array();
4771 $hashcode = substr(md5(uniqid(rand(),
true)), 0, 16);
4773 $res = $ilDB->queryf(
'
4774 SELECT COUNT(usr_id) cnt FROM usr_data
4775 WHERE reg_hash = %s',
4780 if(
$row->cnt > 0) $continue =
true;
4784 if($continue)
continue;
4786 $ilDB->manipulateF(
'
4790 array(
'text',
'integer'),
4791 array($hashcode, (
int)$a_usr_id)
4813 $res = $ilDB->queryf(
'
4814 SELECT usr_id, create_date FROM usr_data
4815 WHERE reg_hash = %s',
4820 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
4823 if((
int)$oRegSettigs->getRegistrationHashLifetime() != 0 &&
4824 time() - (int)$oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row->create_date))
4826 require_once
'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
4830 $ilDB->manipulateF(
'
4834 array(
'text',
'integer'),
4835 array(
'', (
int)
$row->usr_id)
4838 return $row->usr_id;
4841 require_once
'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
4847 if (strlen($a_birthday))
4854 $this->birthday = null;