4 define (
"IL_PASSWD_PLAIN",
"plain");
5 define (
"IL_PASSWD_MD5",
"md5");
6 define (
"IL_PASSWD_CRYPT",
"crypt");
9 require_once
"./Services/Object/classes/class.ilObject.php";
10 require_once
'./Services/User/exceptions/class.ilUserException.php';
155 function ilObjUser($a_user_id = 0, $a_call_by_reference =
false)
164 $this->
ilObject($a_user_id, $a_call_by_reference);
165 $this->auth_mode =
"default";
175 $this->
setId($a_user_id);
182 $this->prefs = array();
184 $this->prefs[
"language"] = $this->ilias->ini->readVariable(
"language",
"default");
187 $this->skin = $this->ilias->ini->readVariable(
"layout",
"skin");
190 $this->prefs[
"show_users_online"] =
"y";
193 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
210 $r = $ilDB->queryF(
"SELECT * FROM usr_data ".
211 "WHERE usr_id= %s", array(
"integer"), array($this->
id));
213 if ($data = $ilDB->fetchAssoc($r))
217 if ($data[
"passwd"] ==
"" && $data[
"i2passwd"] !=
"")
220 $data[
"passwd"] = $data[
"i2passwd"];
227 unset($data[
"i2passw"]);
243 if ($this->prefs[
"language"] ==
"")
245 $this->prefs[
"language"] = $this->oldPrefs[
"language"];
249 include_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
250 if ($this->prefs[
"skin"] ==
"" ||
253 $this->prefs[
"skin"] = $this->oldPrefs[
"skin"];
256 $this->skin = $this->prefs[
"skin"];
259 if ($this->prefs[
"style"] ==
"" ||
263 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
266 if (empty($this->prefs[
"hits_per_page"]))
268 $this->prefs[
"hits_per_page"] = 10;
274 $ilErr->raiseError(
"<b>Error: There is no dataset with id ".
275 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
276 "<br />Line: ".__LINE__, $ilErr->FATAL);
295 if (! $a_data[
"passwd_type"])
297 $ilErr->raiseError(
"<b>Error: passwd_type missing in function assignData(). ".
298 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: "
299 .__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
301 if ($a_data[
"passwd"] !=
"********" and strlen($a_data[
'passwd']))
303 $this->
setPasswd($a_data[
"passwd"], $a_data[
"passwd_type"]);
311 if (!is_array($a_data[
'birthday']))
324 $this->
setCity($a_data[
"city"]);
331 $this->
setFax($a_data[
"fax"]);
355 $this->create_date = $a_data[
"create_date"];
356 $this->
setComment($a_data[
"referral_comment"]);
357 $this->approve_date = $a_data[
"approve_date"];
358 $this->active = $a_data[
"active"];
359 $this->agree_date = $a_data[
"agree_date"];
393 switch ($this->passwd_type)
396 $pw_field =
"passwd";
397 if(strlen($this->passwd))
399 $pw_value = md5($this->passwd);
408 $pw_field =
"passwd";
413 $pw_field =
"i2passwd";
418 $ilErr->raiseError(
"<b>Error: passwd_type missing in function saveAsNew. ".
419 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
420 "<br />Line: ".__LINE__, $ilErr->FATAL);
432 $insert_array = array(
433 "usr_id" => array(
"integer", $this->
id),
434 "login" => array(
"text", $this->login),
435 $pw_field => array(
"text", $pw_value),
436 "firstname" => array(
"text", $this->firstname),
437 "lastname" => array(
"text", $this->lastname),
438 "title" => array(
"text", $this->utitle),
439 "gender" => array(
"text", $this->gender),
440 "email" => array(
"text", trim($this->email)),
441 "hobby" => array(
"text", (
string) $this->hobby),
442 "institution" => array(
"text", $this->institution),
443 "department" => array(
"text", $this->department),
444 "street" => array(
"text", $this->street),
445 "city" => array(
"text", $this->city),
446 "zipcode" => array(
"text", $this->zipcode),
447 "country" => array(
"text", $this->country),
448 "sel_country" => array(
"text", $this->sel_country),
449 "phone_office" => array(
"text", $this->phone_office),
450 "phone_home" => array(
"text", $this->phone_home),
451 "phone_mobile" => array(
"text", $this->phone_mobile),
452 "fax" => array(
"text", $this->fax),
454 "last_login" => array(
"timestamp", null),
455 "last_update" => array(
"timestamp",
ilUtil::now()),
456 "create_date" => array(
"timestamp",
ilUtil::now()),
457 "referral_comment" => array(
"text", $this->referral_comment),
458 "matriculation" => array(
"text", $this->matriculation),
459 "client_ip" => array(
"text", $this->client_ip),
460 "approve_date" => array(
"timestamp", $this->approve_date),
461 "agree_date" => array(
"timestamp", $this->agree_date),
462 "active" => array(
"integer", (
int) $this->active),
467 "auth_mode" => array(
"text", $this->
getAuthMode()),
470 "im_icq" => array(
"text", $this->im_icq),
471 "im_yahoo" => array(
"text", $this->im_yahoo),
472 "im_msn" => array(
"text", $this->im_msn),
473 "im_aim" => array(
"text", $this->im_aim),
474 "im_skype" => array(
"text", $this->im_skype),
475 "delicious" => array(
"text", $this->delicious),
476 "latitude" => array(
"text", $this->latitude),
477 "longitude" => array(
"text", $this->longitude),
478 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
479 "last_password_change" => array(
"integer", (
int) $this->last_password_change_ts),
480 "im_jabber" => array(
"text", $this->im_jabber),
481 "im_voip" => array(
"text", $this->im_voip),
482 'inactivation_date' => array(
'timestamp', $this->inactivation_date),
483 'is_self_registered' => array(
'integer', (
int)$this->is_self_registered)
485 $ilDB->insert(
"usr_data", $insert_array);
493 include_once (
"Services/Mail/classes/class.ilMailbox.php");
495 $mbox->createDefaultFolder();
497 include_once
"Services/Mail/classes/class.ilMailOptions.php";
499 $mail_options->createMailOptionsEntry();
502 include_once
"./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
504 $bmf->createNewBookmarkTree();
513 global
$ilErr, $ilDB, $ilAppEventHandler;
521 else if($this->active)
526 $update_array = array(
527 "gender" => array(
"text", $this->gender),
528 "title" => array(
"text", $this->utitle),
529 "firstname" => array(
"text", $this->firstname),
530 "lastname" => array(
"text", $this->lastname),
531 "email" => array(
"text", trim($this->email)),
533 "hobby" => array(
"text", $this->hobby),
534 "institution" => array(
"text", $this->institution),
535 "department" => array(
"text", $this->department),
536 "street" => array(
"text", $this->street),
537 "city" => array(
"text", $this->city),
538 "zipcode" => array(
"text", $this->zipcode),
539 "country" => array(
"text", $this->country),
540 "sel_country" => array(
"text", $this->sel_country),
541 "phone_office" => array(
"text", $this->phone_office),
542 "phone_home" => array(
"text", $this->phone_home),
543 "phone_mobile" => array(
"text", $this->phone_mobile),
544 "fax" => array(
"text", $this->fax),
545 "referral_comment" => array(
"text", $this->referral_comment),
546 "matriculation" => array(
"text", $this->matriculation),
547 "client_ip" => array(
"text", $this->client_ip),
548 "approve_date" => array(
"timestamp", $this->approve_date),
549 "active" => array(
"integer", $this->active),
556 "auth_mode" => array(
"text", $this->
getAuthMode()),
558 "im_icq" => array(
"text", $this->im_icq),
559 "im_yahoo" => array(
"text", $this->im_yahoo),
560 "im_msn" => array(
"text", $this->im_msn),
561 "im_aim" => array(
"text", $this->im_aim),
562 "im_skype" => array(
"text", $this->im_skype),
563 "delicious" => array(
"text", $this->delicious),
564 "latitude" => array(
"text", $this->latitude),
565 "longitude" => array(
"text", $this->longitude),
566 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
567 "last_password_change" => array(
"integer", $this->last_password_change_ts),
568 "im_jabber" => array(
"text", $this->im_jabber),
569 "im_voip" => array(
"text", $this->im_voip),
570 "last_update" => array(
"timestamp",
ilUtil::now()),
571 'inactivation_date' => array(
'timestamp', $this->inactivation_date)
574 if (isset($this->agree_date) && (strtotime($this->agree_date) !==
false || $this->agree_date == null))
576 $update_array[
"agree_date"] = array(
"timestamp", $this->agree_date);
578 switch ($this->passwd_type)
581 if(strlen($this->passwd))
583 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
584 $update_array[
"passwd"] = array(
"text", (
string) md5($this->passwd));
588 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
589 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
594 $update_array[
"i2passwd"] = array(
"text", (
string)
"");
595 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
599 $update_array[
"i2passwd"] = array(
"text", (
string) $this->passwd);
600 $update_array[
"passwd"] = array(
"text", (
string)
"");
604 $ilErr->raiseError(
"<b>Error: passwd_type missing in function update()".$this->
id.
"!</b><br />class: ".
605 get_class($this).
"<br />Script: ".__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
608 $ilDB->update(
"usr_data", $update_array, array(
"usr_id" => array(
"integer", $this->
id)));
620 $ilAppEventHandler->raise(
"Services/User",
"afterUpdate",
621 array(
"user_obj" => $this));
633 $ilDB->manipulateF(
"UPDATE usr_data SET agree_date = ".$ilDB->now().
634 " WHERE usr_id = %s", array(
"integer"), array($this->
getId()));
640 private function _lookup($a_user_id, $a_field)
644 $res = $ilDB->queryF(
"SELECT ".$a_field.
" FROM usr_data WHERE usr_id = %s",
645 array(
"integer"), array($a_user_id));
647 while($set = $ilDB->fetchAssoc(
$res))
649 return $set[$a_field];
661 $set = $ilDB->queryF(
"SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s",
662 array(
"integer"), array($a_user_id));
664 if ($rec = $ilDB->fetchAssoc($set))
670 if ($rec[
"firstname"])
674 if ($rec[
"lastname"])
728 $res = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
729 array(
"integer"), array($a_user_id));
730 $user_rec = $ilDB->fetchAssoc(
$res);
731 return array(
"user_id" => $a_user_id,
732 "firstname" => $user_rec[
"firstname"],
733 "lastname" => $user_rec[
"lastname"],
734 "title" => $user_rec[
"title"],
735 "login" => $user_rec[
"login"]);
745 $res = $ilDB->queryF(
"SELECT * FROM usr_data WHERE usr_id = %s",
746 array(
"integer"), array($a_user_id));
747 $user_rec = $ilDB->fetchAssoc(
$res);
774 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data WHERE login = %s",
775 array(
"text"), array($a_user_str));
776 $user_rec = $ilDB->fetchAssoc(
$res);
777 return $user_rec[
"usr_id"];
798 $ilDB->manipulateF(
"UPDATE usr_data SET ".
799 "last_login = ".$ilDB->now().
800 " WHERE usr_id = %s",
801 array(
"integer"), array($this->
id));
815 $this->passwd = $new_md5;
817 $ilDB->manipulateF(
"UPDATE usr_data SET ".
820 array(
"text",
"integer"), array($this->passwd, $this->
id));
837 if (func_num_args() != 3)
842 if (!isset($a_old) or !isset($a_new1) or !isset($a_new2))
847 if ($a_new1 != $a_new2)
853 if ($a_new1 ==
"" || $a_old ==
"")
859 switch ($this->passwd_type)
862 if ($a_old != $this->passwd)
869 if (md5($a_old) != $this->passwd)
876 if (self::_makeIlias2Password($a_old) != $this->passwd)
884 $this->passwd = md5($a_new1);
887 $ilDB->manipulateF(
"UPDATE usr_data SET ".
890 array(
"text",
"integer"), array($this->passwd, $this->
id));
906 if (func_num_args() != 2)
911 if (!isset($a_new1) or !isset($a_new2))
916 if ($a_new1 != $a_new2)
922 $this->passwd = md5($a_new1);
925 $ilDB->manipulateF(
"UPDATE usr_data SET ".
928 array(
"text",
"integer"),
929 array($this->passwd, $this->
id));
940 return (crypt($a_passwd,substr($a_passwd,0,2)));
957 $res = $ilDB->queryF(
'
958 SELECT * FROM loginname_history
960 array(
'text'), array($a_login));
962 return $ilDB->fetchAssoc(
$res) ?
true :
false;
981 $ilDB->setLimit(1, 0);
982 $res = $ilDB->queryF(
'
983 SELECT login, history_date FROM loginname_history
984 WHERE usr_id = %s ORDER BY history_date DESC',
985 array(
'integer'), array($a_usr_id));
1005 if(func_num_args() != 1)
1010 if(!isset($a_login))
1018 if(0 == strcmp($a_login, $former_login))
1030 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1031 (int)$ilSetting->get(
'reuse_of_loginnames') == 0 &&
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()));
1070 include_once
'Services/Contact/classes/class.ilAddressbook.php';
1071 ilAddressbook::onLoginNameChange($former_login, $this->
getLogin());
1085 self::_writePref($this->
id, $a_keyword, $a_value);
1086 $this->
setPref($a_keyword, $a_value);
1097 self::_deletePref($this->
getId(), $a_keyword);
1105 public static function _deletePref($a_user_id, $a_keyword)
1113 'DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s',
1114 array(
'integer',
'text'),
1115 array($a_user_id, $a_keyword)
1128 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s",
1129 array(
"integer"), array($a_user_id));
1138 public static function _writePref($a_usr_id, $a_keyword, $a_value)
1145 self::_deletePref($a_usr_id, $a_keyword);
1146 if(strlen($a_value))
1149 'INSERT INTO usr_pref (usr_id, keyword, value) VALUES (%s, %s, %s)',
1150 array(
'integer',
'text',
'text'),
1151 array($a_usr_id, $a_keyword, $a_value)
1165 foreach ($this->prefs as $keyword => $value)
1167 self::_writePref($this->
id, $keyword, $value);
1179 if($tz = $this->
getPref(
'user_tz'))
1185 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1187 return $settings->getDefaultTimeZone();
1199 if($format = $this->
getPref(
'time_format'))
1205 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1207 return $settings->getDefaultTimeFormat();
1219 if($format = $this->
getPref(
'date_format'))
1225 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1227 return $settings->getDefaultDateFormat();
1239 if ($a_keyword !=
"")
1241 $this->prefs[$a_keyword] = $a_value;
1252 if (array_key_exists($a_keyword, $this->prefs))
1254 return $this->prefs[$a_keyword];
1266 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
" ".
1267 "AND keyword = ".$ilDB->quote($a_keyword,
"text");
1285 if (is_array($this->prefs))
1300 global $rbacadmin, $ilDB;
1303 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1305 $mapping->deleteUser($this->
getId());
1308 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1311 $mailbox->updateMailsOfDeletedUser($this->
getLogin());
1314 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1316 $costum_block->setContextObjId($this->
getId());
1317 $costum_block->setContextObjType(
"user");
1318 $c_blocks = $costum_block->queryBlocksForContext();
1319 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1320 foreach($c_blocks as $c_block)
1322 if ($c_block[
"type"] ==
"pdfeed")
1331 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1335 $ilDB->manipulateF(
"DELETE FROM usr_data WHERE usr_id = %s",
1336 array(
"integer"), array($this->
getId()));
1344 include_once(
"./Services/Authentication/classes/class.ilSession.php");
1348 $rbacadmin->removeUser($this->
getId());
1352 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1353 $ilDB->quote($this->
getId(),
"integer");
1354 $ilDB->manipulate($q);
1356 $q =
"DELETE FROM bookmark_data WHERE user_id = ".
1357 $ilDB->quote($this->
getId(),
"integer");
1358 $ilDB->manipulate($q);
1361 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1362 ilObjForum::_deleteUser($this->
getId());
1365 include_once
'./Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1369 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1373 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1376 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1380 include_once
'Modules/Scorm2004/classes/ilSCORM13Package.php';
1384 include_once
'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
1388 include_once
"./Services/Notification/classes/class.ilNotification.php";
1392 include_once
"./Modules/Portfolio/classes/class.ilObjPortfolio.php";
1396 include_once
"./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1398 $tree->cascadingDelete();
1401 include_once
"./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1413 include_once
'Services/Contact/classes/class.ilAddressbook.php';
1414 ilAddressbook::onUserDeletion($this);
1417 global $ilAppEventHandler;
1418 $ilAppEventHandler->raise(
1419 'Services/User',
'deleteUser', array(
'usr_id' => $this->
getId())
1436 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1438 $this->fullname =
"";
1444 elseif ($this->utitle)
1446 $this->fullname = $this->utitle.
" ";
1453 elseif ($this->firstname)
1455 $this->fullname .= $this->firstname.
" ";
1487 if (strlen($this->fullname) <= $a_max_strlen)
1492 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1494 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1497 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1502 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1513 function hasAcceptedUserAgreement()
1521 null != $this->agree_date ||
1522 'root' == $this->login ||
1523 in_array($this->
getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID)) ||
1524 $rbacreview->isAssigned($this->getId(), SYSTEM_ROLE_ID)
1539 $this->login = $a_str;
1558 $this->passwd = $a_str;
1559 $this->passwd_type = $a_type;
1591 $this->gender = substr($a_str,-1);
1612 $this->utitle = $a_str;
1633 $this->firstname = $a_str;
1652 $this->lastname = $a_str;
1671 $this->institution = $a_str;
1690 $this->department = $a_str;
1709 $this->street = $a_str;
1728 $this->city = $a_str;
1747 $this->zipcode = $a_str;
1767 $this->country = $a_str;
1787 $this->sel_country = $a_val;
1807 $this->phone_office = $a_str;
1826 $this->phone_home = $a_str;
1845 $this->phone_mobile = $a_str;
1864 $this->fax = $a_str;
1883 $this->client_ip = $a_str;
1902 $this->matriculation = $a_str;
1924 $query =
"SELECT matriculation FROM usr_data ".
1925 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1928 return $row->matriculation ?
$row->matriculation :
'';
1938 $this->email = $a_str;
1957 $this->hobby = $a_str;
1976 $this->
setPref(
"language",$a_str);
1987 return $this->prefs[
"language"];
2000 $this->
setPref(
"disk_quota",$a_disk_quota);
2014 return $this->prefs[
"disk_quota"] ? $this->prefs[
"disk_quota"] : 0;
2019 return $this->prefs[
"wsp_disk_quota"] ? $this->prefs[
"wsp_disk_quota"] : 0;
2024 $this->last_password_change_ts = $a_last_password_change_ts;
2037 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
2038 $ilDB->quote($a_usr_id,
"integer").
" AND keyword = ".
2039 $ilDB->quote(
'language',
"text");
2040 $r = $ilDB->query($q);
2042 while(
$row = $ilDB->fetchAssoc($r))
2044 return $row[
'value'];
2055 if ($pw == md5($a_pw))
2066 $ilDB->manipulateF(
"UPDATE usr_data ".
2067 " SET ext_account = %s WHERE usr_id = %s",
2068 array(
"text",
"integer"),
2069 array($a_ext_id, $a_usr_id));
2076 $ilDB->manipulateF(
"UPDATE usr_data ".
2077 " SET auth_mode = %s WHERE usr_id = %s",
2078 array(
"text",
"integer"),
2079 array($a_auth_mode, $a_usr_id));
2108 $this->last_login = $a_str;
2118 return $this->last_login;
2128 $this->last_update = $a_str;
2142 $this->referral_comment = $a_str;
2162 $this->approve_date = $a_str;
2193 $this->agree_date = $a_str;
2236 $query =
'SELECT usr_id FROM usr_data '.
2237 'WHERE active = '.$ilDB->quote(1,
'integer').
' '.
2238 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer');
2268 if ((!empty($storedActive) && empty($currentActive)) ||
2269 (empty($storedActive) && !empty($currentActive)))
2284 return $active ?
true :
false;
2295 $this->skin = $a_str;
2300 $this->time_limit_owner = $a_owner;
2304 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2308 $this->time_limit_from = $a_from;
2312 return $this->time_limit_from ? $this->time_limit_from : time();
2316 $this->time_limit_until = $a_until;
2320 return $this->time_limit_until ? $this->time_limit_until : time();
2324 $this->time_limit_unlimited = $a_unlimited;
2328 return $this->time_limit_unlimited;
2332 return $this->time_limit_message = $a_time_limit_message;
2336 return $this->time_limit_message;
2341 $this->login_attempts = $a_login_attempts;
2364 $this->profile_incomplete = (boolean) $a_prof_inc;
2368 if($this->
id == ANONYMOUS_USER_ID)
2372 return $this->profile_incomplete;
2378 if( $this->
id == ANONYMOUS_USER_ID || $this->
id == SYSTEM_USER_ID )
2381 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2385 && $security->isPasswordChangeOnFirstLoginEnabled()
2387 && $this->is_self_registered == false
2397 if($this->
id == ANONYMOUS_USER_ID)
return false;
2399 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2403 $max_pass_age = $security->getPasswordMaxAge();
2404 if( $max_pass_age > 0 )
2406 $max_pass_age_ts = ( $max_pass_age * 86400 );
2408 $current_ts = time();
2410 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2419 $current_ts = time();
2421 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2422 return $password_age;
2431 $query =
"UPDATE usr_data SET last_password_change = %s " .
2432 "WHERE usr_id = %s";
2433 $affected = $ilDB->manipulateF(
$query,
2434 array(
'integer',
'integer'),
2436 if($affected)
return true;
2444 $query =
"UPDATE usr_data SET last_password_change = 0 " .
2445 "WHERE usr_id = %s";
2446 $affected = $ilDB->manipulateF(
$query, array(
'integer'),
2447 array($this->
getId()) );
2448 if($affected)
return true;
2459 $this->latitude = $a_latitude;
2479 $this->longitude = $a_longitude;
2499 $this->loc_zoom = $a_locationzoom;
2514 $this->applied_users = array();
2517 return $this->applied_users ? $this->applied_users : array();
2522 if($a_usr_id == $this->
getId())
2527 $this->applied_users = array();
2530 return in_array($a_usr_id,$this->applied_users);
2537 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2538 "WHERE time_limit_owner = %s",
2540 array($a_parent_id));
2541 while (
$row = $ilDB->fetchObject(
$res))
2543 $this->applied_users[] =
$row->usr_id;
2560 $set = $ilDB->queryf(
'
2561 SELECT COUNT(*) session_count
2562 FROM usr_session WHERE user_id = %s AND expires > %s',
2563 array(
'integer',
'integer'),
2564 array($a_user_id, time()));
2565 $row = $ilDB->fetchAssoc($set);
2566 return (
bool)
$row[
'session_count'];
2593 require_once (
'Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2596 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2597 require_once (
'Services/Database/classes/class.ilAuthContainerMDB2.php');
2602 $login =$ilAuth->getUsername();
2615 global $ilDB,$ilAuth;
2618 $set = $ilDB->queryF(
"SELECT active FROM usr_data WHERE login= %s",
2622 if ($rec = $ilDB->fetchAssoc($set))
2658 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
2659 "WHERE email = %s and active = 1",
2663 while(
$row = $ilDB->fetchObject(
$res))
2665 $ids[] =
$row->login;
2685 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2686 "WHERE email = %s", array(
"text"), array($a_email));
2689 return $row->usr_id ?
$row->usr_id : 0;
2716 static function searchUsers($a_search_str,
$active = 1, $a_return_ids_only =
false, $filter_settings = FALSE)
2721 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2723 $without_anonymous_users =
true;
2726 $join_filter =
" WHERE ";
2727 if ($filter_settings !== FALSE && strlen($filter_settings))
2729 switch ($filter_settings)
2733 $join_filter =
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.usr_id IS NULL AND ";
2740 $join_filter =
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.obj_id = ".
2741 "(SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") AND ";
2749 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2750 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2751 if (is_array($local_roles) && count($local_roles))
2753 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2754 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false, $local_roles).
" AND ";
2760 $rol_id =
$_SESSION[
"user_filter_data"];
2763 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2764 $ilDB->quote($rol_id,
"integer").
" AND ";
2765 $without_anonymous_users =
false;
2772 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2774 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2775 "FROM object_data,rbac_ua,usr_data ".
2776 "WHERE ".$ilDB->like(
"object_data.title",
"text",
"%".substr($a_search_str,5).
"%").
2777 " AND object_data.type = 'role' ".
2778 "AND rbac_ua.rol_id = object_data.obj_id ".
2779 "AND usr_data.usr_id = rbac_ua.usr_id ".
2780 "AND rbac_ua.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2785 "(".$ilDB->like(
"usr_data.login",
"text",
"%".$a_search_str.
"%").
" ".
2786 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_search_str.
"%").
" ".
2787 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_search_str.
"%").
" ".
2788 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_search_str.
"%").
") ";
2790 if ($filter_settings !== FALSE && strlen($filter_settings))
2792 switch ($filter_settings)
2795 $query.=
" AND usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
2798 $query.=
" AND usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
2801 $query.=
" AND usr_data.time_limit_unlimited = ".$ilDB->quote(0,
"integer").
" ";
2804 $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"]));
2805 $query.=
" AND last_login < ".$ilDB->quote($date,
"timestamp").
" ";
2810 if ($without_anonymous_users)
2812 $query.=
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2815 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE)
2817 $query.=
" AND active = ".$ilDB->quote(
$active,
"integer").
" ";
2823 while (
$row = $ilDB->fetchObject(
$res))
2826 "usr_id" =>
$row->usr_id,
2827 "login" =>
$row->login,
2828 "firstname" =>
$row->firstname,
2829 "lastname" =>
$row->lastname,
2830 "email" =>
$row->email,
2831 "active" =>
$row->active);
2832 $ids[] =
$row->usr_id;
2834 if ($a_return_ids_only)
2835 return $ids ? $ids : array();
2837 return $users ? $users : array();
2852 $res = $ilDB->query(
"SELECT login FROM usr_data");
2853 while(
$row = $ilDB->fetchObject(
$res))
2855 $logins[] =
$row->login;
2857 return $logins ? $logins : array();
2871 $res = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
2872 $ilDB->in(
"usr_id", $a_user_ids,
false,
"integer"));
2873 while (
$row = $ilDB->fetchAssoc(
$res))
2875 $user_data[
"$row[usr_id]"] =
$row;
2877 return $user_data ? $user_data : array();
2892 $result_arr = array();
2896 if ($a_fields !== NULL and is_array($a_fields))
2898 if (count($a_fields) == 0)
2904 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2905 unset($a_fields[$usr_id_field]);
2907 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2909 if(in_array(
'online_time',$a_fields))
2911 $select .=
",ut_online.online_time ";
2915 $q =
"SELECT ".$select.
" FROM usr_data ";
2919 if(in_array(
'online_time',$a_fields))
2921 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2928 $q .=
"WHERE active = ".$ilDB->quote(
$active,
"integer");
2931 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
2934 $qtemp = $q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
2935 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
2936 $r = $ilDB->query($qtemp);
2937 $course_users = array();
2938 while (
$row = $ilDB->fetchAssoc($r))
2940 array_push($course_users,
$row[
"usr_id"]);
2942 if (count($course_users))
2944 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
2952 $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"]));
2953 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
2959 $q .=
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id ".
2960 "WHERE obj_members.obj_id = (SELECT obj_id FROM object_reference ".
2961 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
2969 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
2970 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
2971 if (is_array($local_roles) && count($local_roles))
2973 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2974 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
2979 $rol_id =
$_SESSION[
"user_filter_data"];
2982 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2983 $ilDB->quote($rol_id,
"integer");
2987 $r = $ilDB->query($q);
2989 while (
$row = $ilDB->fetchAssoc($r))
2991 $result_arr[] =
$row;
3005 $q =
"SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ".
3006 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3007 " AND up1.value= ".$ilDB->quote($a_style,
"text").
3008 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3009 " AND up2.value= ".$ilDB->quote($a_skin,
"text").
3010 " AND up1.usr_id = up2.usr_id ";
3012 $cnt_set = $ilDB->query($q);
3014 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
3016 return $cnt_rec[
"cnt"];
3026 $q =
"SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ".
3027 " WHERE up1.keyword = ".$ilDB->quote(
"style",
"text").
3028 " AND up2.keyword = ".$ilDB->quote(
"skin",
"text").
3029 " AND up1.usr_id = up2.usr_id";
3031 $sty_set = $ilDB->query($q);
3034 while($sty_rec = $ilDB->fetchAssoc($sty_set))
3036 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
3049 $q =
"SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ".
3050 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3051 " AND up1.value= ".$ilDB->quote($a_from_style,
"text").
3052 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3053 " AND up2.value= ".$ilDB->quote($a_from_skin,
"text").
3054 " AND up1.usr_id = up2.usr_id ";
3056 $usr_set = $ilDB->query($q);
3058 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3060 self::_writePref($usr_rec[
"usr_id"],
"skin", $a_to_skin);
3061 self::_writePref($usr_rec[
"usr_id"],
"style", $a_to_style);
3079 $item_set = $ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3080 "item_id = %s AND type = %s AND user_id = %s",
3081 array(
"integer",
"text",
"integer"),
3082 array($a_item_id, $a_type, $a_usr_id));
3085 if (!$ilDB->fetchAssoc($item_set))
3087 $ilDB->manipulateF(
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3088 " (%s,%s,%s,%s)", array(
"integer",
"text",
"integer",
"text"),
3089 array($a_item_id,$a_type,$a_usr_id,$a_par));
3092 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3120 $ilDB->manipulateF(
"UPDATE desktop_item SET parameters = %s ".
3121 " WHERE item_id = %s AND type = %s AND user_id = %s",
3122 array(
"text",
"integer",
"text",
"integer"),
3123 array($a_par, $a_item_id, $a_type, $this->
getId()));
3140 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE ".
3141 " item_id = %s AND type = %s AND user_id = %s",
3142 array(
"integer",
"text",
"integer"),
3143 array($a_item_id, $a_type, $a_usr_id));
3145 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3171 $r = $ilDB->queryF(
"SELECT user_id FROM desktop_item WHERE item_id = %s",
3172 array(
"integer"), array($a_id));
3176 while (
$row = $ilDB->fetchObject($r))
3178 $users[] =
$row->user_id;
3181 if (count($users) > 0)
3183 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE item_id = %s",
3184 array(
"integer"), array($a_id));
3203 if (self::$is_desktop_item_loaded[$a_usr_id.
":".$a_item_id])
3205 return self::$is_desktop_item_cache[$a_usr_id.
":".$a_item_id.
":".$a_type];
3207 $item_set = $ilDB->queryF(
"SELECT item_id FROM desktop_item WHERE ".
3208 "item_id = %s AND type = %s AND user_id = %s",
3209 array(
"integer",
"text",
"integer"),
3210 array($a_item_id, $a_type, $a_usr_id));
3212 if ($ilDB->fetchAssoc($item_set))
3232 if (!is_array($a_item_ids))
3237 $item_ids = array();
3238 foreach ($a_item_ids as
$id)
3240 if (!self::$is_desktop_item_loaded[$a_usr_id.
":".$id])
3244 self::$is_desktop_item_loaded[$a_usr_id.
":".
$id] =
true;
3247 if (count($item_ids) > 0)
3249 $item_set = $ilDB->query(
"SELECT item_id, type FROM desktop_item WHERE ".
3250 $ilDB->in(
"item_id", $item_ids,
false,
"integer").
3251 " AND user_id = ".$ilDB->quote($a_usr_id,
"integer"));
3252 while ($r = $ilDB->fetchAssoc($item_set))
3254 self::$is_desktop_item_cache[$a_usr_id.
":".$r[
"item_id"].
":".$r[
"type"]]
3285 global
$ilUser, $rbacsystem, $tree, $ilDB;
3289 $is_nested_set = ($tree->getTreeImplementation() instanceof
ilNestedSetTree);
3291 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3292 " FROM desktop_item it, object_reference oref ".
3293 ", object_data obj".
3295 "it.item_id = oref.ref_id AND ".
3296 "oref.obj_id = obj.obj_id AND ".
3297 "it.user_id = %s", array(
"integer"), array($user_id));
3298 $items = $all_parent_path = array();
3299 while ($item_rec = $ilDB->fetchAssoc($item_set))
3301 if ($tree->isInTree($item_rec[
"ref_id"])
3302 && $item_rec[
"type"] !=
"rolf"
3303 && $item_rec[
"type"] !=
"itgr")
3305 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3307 if(!isset($all_parent_path[$parent_ref]))
3312 $par_left = $tree->getLeftValue($parent_ref);
3313 $all_parent_path[$parent_ref] = sprintf(
"%010d", $par_left);
3317 $node = $tree->getNodeData($parent_ref);
3318 $all_parent_path[$parent_ref] = $node[
"path"];
3322 $parent_path = $all_parent_path[$parent_ref];
3326 $items[$parent_path.$title.$item_rec[
"ref_id"]] =
3327 array(
"ref_id" => $item_rec[
"ref_id"],
3328 "obj_id" => $item_rec[
"obj_id"],
3329 "type" => $item_rec[
"type"],
3331 "description" =>
$desc,
3332 "parent_ref" => $parent_ref);
3340 if (!is_array($a_types))
3342 $a_types = array($a_types);
3345 $foundsurveys = array();
3346 foreach($a_types as $a_type)
3348 if ($a_type ==
"itgr")
3352 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ".
3353 ", object_data obj WHERE ".
3354 "it.item_id = oref.ref_id AND ".
3355 "oref.obj_id = obj.obj_id AND ".
3356 "it.type = %s AND ".
3359 array(
"text",
"integer"),
3360 array($a_type, $user_id));
3362 while ($item_rec = $ilDB->fetchAssoc($item_set))
3366 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3367 array(
"ref_id" => $item_rec[
"ref_id"],
3368 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3393 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3399 $a_time = date(
"Y-m-d H:i:s", time());
3402 $item_set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3403 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3404 array(
"integer",
"integer",
"text",
"integer"),
3405 array(0, $a_item_id, $a_type, $this->
getId()));
3408 if (!
$d = $item_set->fetchRow())
3410 $ilDB->manipulateF(
"INSERT INTO personal_clipboard ".
3411 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3412 " (%s,%s,%s,%s,%s,%s,%s)",
3413 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"),
3414 array($a_item_id, $a_type, $this->
getId(), $a_title, (
int) $a_parent, $a_time, (
int) $a_order_nr));
3418 $ilDB->manipulateF(
"UPDATE personal_clipboard SET insert_time = %s ".
3419 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3420 array(
"timestamp",
"integer",
"integer",
"text"),
3421 array($a_time, $this->
getId(), $a_item_id, $a_type));
3433 $a_time = date(
"Y-m-d H:i:s", time());
3435 $ilDB->insert(
"personal_pc_clipboard", array(
3436 "user_id" => array(
"integer", $this->
getId()),
3437 "content" => array(
"clob", $a_content),
3438 "insert_time" => array(
"timestamp", $a_time),
3439 "order_nr" => array(
"integer", $a_nr)
3450 $set = $ilDB->queryF(
"SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ".
3451 " WHERE user_id = %s", array(
"integer"), array($this->
getId()));
3452 $row = $ilDB->fetchAssoc($set);
3454 $set = $ilDB->queryF(
"SELECT * FROM personal_pc_clipboard ".
3455 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3456 array(
"integer",
"timestamp"),
3459 while (
$row = $ilDB->fetchAssoc($set))
3461 $content[] =
$row[
"content"];
3474 $set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3475 "parent = %s AND type = %s AND user_id = %s",
3476 array(
"integer",
"text",
"integer"),
3477 array(0, $a_type, $this->
getId()));
3478 if ($rec = $ilDB->fetchAssoc($set))
3493 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3494 "type = %s AND user_id = %s",
3495 array(
"text",
"integer"),
3496 array($a_type, $this->
getId()));
3506 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3507 "user_id = %s", array(
"integer"), array($this->
getId()));
3518 if ($a_top_nodes_only)
3520 $par =
" AND parent = ".$ilDB->quote(0,
"integer").
" ";
3523 $type_str = ($a_type !=
"")
3524 ?
" AND type = ".$ilDB->quote($a_type,
"text").
" "
3526 $q =
"SELECT * FROM personal_clipboard WHERE ".
3527 "user_id = ".$ilDB->quote($this->
getId(),
"integer").
" ".
3529 " ORDER BY order_nr";
3530 $objs = $ilDB->query($q);
3532 while ($obj = $ilDB->fetchAssoc($objs))
3534 if ($obj[
"type"] ==
"mob")
3538 if ($obj[
"type"] ==
"incl")
3540 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3543 $objects[] = array (
"id" => $obj[
"item_id"],
3544 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3545 "insert_time" => $obj[
"insert_time"]);
3557 $objs = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3558 "user_id = %s AND parent = %s AND insert_time = %s ".
3559 " ORDER BY order_nr",
3560 array(
"integer",
"integer",
"timestamp"),
3561 array($ilUser->getId(), (int) $a_parent, $a_insert_time));
3563 while ($obj = $ilDB->fetchAssoc($objs))
3565 if ($obj[
"type"] ==
"mob")
3569 $objects[] = array (
"id" => $obj[
"item_id"],
3570 "type" => $obj[
"type"],
"title" => $obj[
"title"]);
3587 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3588 "item_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
3589 "type = ".$ilDB->quote($a_type,
"text");
3590 $user_set = $ilDB->query($q);
3592 while ($user_rec = $ilDB->fetchAssoc($user_set))
3594 $users[] = $user_rec[
"user_id"];
3611 $q =
"DELETE FROM personal_clipboard WHERE ".
3612 "item_id = ".$ilDB->quote($a_item_id,
"integer").
3613 " AND type = ".$ilDB->quote($a_type,
"text").
" ".
3614 " AND user_id = ".$ilDB->quote($this->
getId(),
"integer");
3615 $ilDB->manipulate($q);
3622 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3623 $ilDB->quote($i2_id,
"text");
3626 while(
$row = $ilDB->fetchObject(
$res))
3657 $this->auth_mode = $a_str;
3671 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3684 $this->ext_account = $a_str;
3696 return $this->ext_account;
3714 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3715 $q =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3716 "WHERE auth_mode = %s";
3718 $values[] = $a_auth_mode;
3721 $q.=
" OR auth_mode = %s ";
3723 $values[] =
'default';
3726 $res = $ilDB->queryF($q, $types, $values);
3727 while (
$row = $ilDB->fetchObject(
$res))
3729 if(
$row->auth_mode ==
'default')
3731 $accounts[
$row->usr_id] =
$row->login;
3735 $accounts[
$row->usr_id] =
$row->ext_account;
3738 return $accounts ? $accounts : array();
3752 if(!is_array($a_usr_ids))
3760 $q =
"UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE ".
3761 $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3762 $ilDB->manipulate($q);
3766 $usrId_IN_usrIds = $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3768 $q =
"UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds";
3769 $ilDB->manipulate($q);
3773 SET inactivation_date = %s
3774 WHERE inactivation_date IS NULL
3775 AND $usrId_IN_usrIds
3777 $ilDB->manipulateF($queryString, array(
'timestamp'), array(
ilUtil::now()));
3808 $r = $ilDB->queryF(
"SELECT * FROM usr_data WHERE ".
3809 " ext_account = %s AND auth_mode = %s",
3810 array(
"text",
"text"),
3811 array($a_account, $a_auth));
3812 if ($usr = $ilDB->fetchAssoc($r))
3814 return $usr[
"login"];
3818 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3819 "WHERE login = %s AND auth_mode = %s",
3820 array(
"text",
"text"),
3821 array($a_account, $a_auth));
3822 if($usr = $ilDB->fetchAssoc(
$res))
3824 return $usr[
'login'];
3830 $res = $ilDB->queryF(
"SELECT login FROM usr_data WHERE ".
3831 " ext_account = %s AND auth_mode = %s",
3832 array(
"text",
"text"),
3833 array($a_account,
"default"));
3834 if ($usr = $ilDB->fetchAssoc(
$res))
3836 return $usr[
"login"];
3839 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3840 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3841 array(
"text",
"text"),
3842 array($a_account,
"default"));
3843 if($usr = $ilDB->fetchAssoc(
$res))
3845 return $usr[
"login"];
3858 $r = $ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3859 "GROUP BY auth_mode");
3861 while($cnt = $ilDB->fetchAssoc($r))
3863 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3880 $q =
"SELECT * FROM usr_data WHERE ".
3881 " email = %s AND (auth_mode = %s ";
3882 $types = array(
"text",
"text");
3883 $values = array($a_email,
"local");
3885 if ($ilSetting->get(
"auth_mode") == 1)
3887 $q.=
" OR auth_mode = %s";
3889 $values[] =
"default";
3895 $usr_set = $ilDB->queryF($q, $types, $values);
3896 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3898 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3915 $image_dir = $webspace_dir.
"/usr_images";
3916 $store_file =
"usr_".$obj_id.
".".
"jpg";
3917 $target_file = $image_dir.
"/$store_file";
3919 chmod($tmp_file, 0770);
3923 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3924 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3925 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3926 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3934 self::_writePref($obj_id,
"profile_image", $store_file);
3950 if(isset(self::$personal_image_cache[$this->
getId()][$a_size][(
int)$a_force_pic]))
3952 return self::$personal_image_cache[$this->
getId()][$a_size][(int)$a_force_pic];
3957 return self::$personal_image_cache[$this->
getId()][$a_size][(int)$a_force_pic];
3970 $a_prevent_no_photo_image =
false)
3975 $res = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE ".
3976 "keyword IN (%s,%s) ".
3978 array(
"text",
"text",
"integer"),
3979 array(
'public_upload',
'public_profile', $a_usr_id));
3980 while (
$row = $ilDB->fetchAssoc(
$res))
3982 switch (
$row[
'keyword'])
3984 case 'public_upload' :
3985 $upload =
$row[
'value'] ==
'y';
3987 case 'public_profile' :
3988 $profile = (
$row[
'value'] ==
'y' ||
3989 $row[
'value'] ==
'g');
3996 if(defined(
'ILIAS_MODULE'))
3998 $webspace_dir = (
'.'.$webspace_dir);
4000 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
4002 $image_dir = $webspace_dir.
"/usr_images";
4004 if ($a_size ==
'big')
4006 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
4010 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
4014 if((($upload && $profile) || $a_force_pic)
4015 && @is_file($thumb_file))
4017 $file = $thumb_file.
"?t=".rand(1, 99999);
4021 if (!$a_prevent_no_photo_image)
4024 if($a_size ==
"small" || $a_size ==
"big")
4043 $a_dir = trim(str_replace(
"..",
"", $a_dir));
4044 if ($a_dir ==
"" || !is_dir($a_dir))
4050 $image_dir = $webspace_dir.
"/usr_images";
4052 "upload_".$a_user_id.
"pic",
4053 "usr_".$a_user_id.
".".
"jpg",
4054 "usr_".$a_user_id.
"_small.jpg",
4055 "usr_".$a_user_id.
"_xsmall.jpg",
4056 "usr_".$a_user_id.
"_xxsmall.jpg",
4057 "upload_".$a_user_id);
4058 foreach ($images as $image)
4060 if (is_file($image_dir.
"/".$image))
4062 copy($image_dir.
"/".$image, $a_dir.
"/".$image);
4074 $image_dir = $webspace_dir.
"/usr_images";
4075 $file = $image_dir.
"/usr_".$this->getID().
".".
"jpg";
4076 $thumb_file = $image_dir.
"/usr_".$this->getID().
"_small.jpg";
4077 $xthumb_file = $image_dir.
"/usr_".$this->getID().
"_xsmall.jpg";
4078 $xxthumb_file = $image_dir.
"/usr_".$this->getID().
"_xxsmall.jpg";
4079 $upload_file = $image_dir.
"/upload_".$this->getID();
4084 $this->
setPref(
"profile_image",
"");
4088 if (@is_file(
$file))
4092 if (@is_file($thumb_file))
4094 unlink($thumb_file);
4096 if (@is_file($xthumb_file))
4098 unlink($xthumb_file);
4100 if (@is_file($xxthumb_file))
4102 unlink($xxthumb_file);
4104 if (@is_file($upload_file))
4106 unlink($upload_file);
4113 if(!is_array($a_data))
4117 foreach($a_data as $field => $data)
4119 #$new_data[$field] = ilUtil::stripSlashes($data);
4121 $this->user_defined_data[
'f_'.$field] = $data;
4123 #$this->user_defined_data = $new_data;
4130 return $this->user_defined_data ? $this->user_defined_data : array();
4139 $field_def = array();
4141 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4144 foreach($this->user_defined_data as $field => $value)
4146 if($field !=
'usr_id')
4149 $udata->set($field, $value);
4181 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4193 $this->user_defined_data = $udata->getAll();
4217 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4233 function getProfileAsString(&$a_language)
4235 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
4236 include_once
'./Services/Utilities/classes/class.ilFormat.php';
4238 global
$lng,$rbacreview;
4240 $language =& $a_language;
4241 $language->loadLanguageModule(
'registration');
4242 $language->loadLanguageModule(
'crs');
4245 $body .= ($language->txt(
"login").
": ".$this->
getLogin().
"\n");
4249 $body .= ($language->txt(
"title").
": ".$this->
getUTitle().
"\n");
4254 $language->txt(
'gender_m') :
4255 $language->txt(
'gender_f');
4256 $body .= ($language->txt(
"gender").
": ".
$gender.
"\n");
4260 $body .= ($language->txt(
"firstname").
": ".$this->
getFirstname().
"\n");
4264 $body .= ($language->txt(
"lastname").
": ".$this->
getLastname().
"\n");
4268 $body .= ($language->txt(
"institution").
": ".$this->
getInstitution().
"\n");
4272 $body .= ($language->txt(
"department").
": ".$this->
getDepartment().
"\n");
4276 $body .= ($language->txt(
"street").
": ".$this->
getStreet().
"\n");
4280 $body .= ($language->txt(
"city").
": ".$this->
getCity().
"\n");
4284 $body .= ($language->txt(
"zipcode").
": ".$this->
getZipcode().
"\n");
4288 $body .= ($language->txt(
"country").
": ".$this->
getCountry().
"\n");
4296 $body .= ($language->txt(
"phone_office").
": ".$this->
getPhoneOffice().
"\n");
4300 $body .= ($language->txt(
"phone_home").
": ".$this->
getPhoneHome().
"\n");
4304 $body .= ($language->txt(
"phone_mobile").
": ".$this->
getPhoneMobile().
"\n");
4306 if(strlen($this->
getFax()))
4308 $body .= ($language->txt(
"fax").
": ".$this->
getFax().
"\n");
4312 $body .= ($language->txt(
"email").
": ".$this->
getEmail().
"\n");
4316 $body .= ($language->txt(
"hobby").
": ".$this->
getHobby().
"\n");
4320 $body .= ($language->txt(
"referral_comment").
": ".$this->
getComment().
"\n");
4324 $body .= ($language->txt(
"matriculation").
": ".$this->
getMatriculation().
"\n");
4333 $body .= ($language->txt(
"create_date").
": ".$date.
"\n");
4336 foreach($rbacreview->getGlobalRoles() as $role)
4338 if($rbacreview->isAssigned($this->getId(),$role))
4345 $body .= ($language->txt(
'reg_role_info').
': '.implode(
',',$gr).
"\n");
4351 $body .= ($language->txt(
'time_limit').
": ".$language->txt(
'crs_unlimited').
"\n");
4364 $body .= $language->txt(
'time_limit').
': '.$start->get(
IL_CAL_DATETIME);
4365 $body .= $language->txt(
'time_limit').
': '.$end->get(
IL_CAL_DATETIME);
4368 #$body .= $language->txt('time_limit').': '.$period;
4377 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
4384 foreach($user_defined_fields->getDefinitions() as $field_id => $definition)
4391 $data = preg_replace(
'/<br(\s*)?\/?>/i',
"\n", $data);
4392 $data = strip_tags($data);
4395 $body .= $definition[
'field_name'].
': '. $data .
"\n";
4404 $var =
"im_".$a_im_type;
4405 $this->$var = $a_im_id;
4410 $var =
"im_".$a_im_type;
4416 $this->delicious = $a_delicious;
4433 $set = $ilDB->queryF(
"SELECT feed_hash from usr_data WHERE usr_id = %s",
4434 array(
"integer"), array($a_user_id));
4435 if ($rec = $ilDB->fetchAssoc($set))
4437 if (strlen($rec[
"feed_hash"]) == 32)
4439 return $rec[
"feed_hash"];
4443 $hash = md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4444 $ilDB->manipulateF(
"UPDATE usr_data SET feed_hash = %s".
4445 " WHERE usr_id = %s",
4446 array(
"text",
"integer"),
4447 array($hash, $a_user_id));
4481 self::_writePref($a_user_id,
"priv_feed_pass",
4482 ($a_password==
"") ?
"" : md5($a_password));
4498 $q =
"SELECT DISTINCT login, usr_id FROM usr_data ".
4501 $values[] = $a_login;
4503 if ($a_user_id != 0)
4505 $q.=
" AND usr_id != %s ";
4506 $types[] =
"integer";
4507 $values[] = $a_user_id;
4510 $r = $ilDB->queryF($q, $types, $values);
4512 if (
$row = $ilDB->fetchAssoc($r))
4514 return $row[
'usr_id'];
4533 $res = $ilDB->queryF(
"SELECT * FROM usr_data ".
4534 "WHERE ext_account = %s AND auth_mode = %s",
4535 array(
"text",
"text"),
4536 array($a_external_account, $a_auth_mode));
4537 return $ilDB->fetchAssoc(
$res) ?
true :
false;
4548 global $ilDB, $rbacreview;
4551 $ids = $rbacreview->assignedUsers($role_id);
4553 if (count ($ids) == 0)
4558 $query =
"SELECT usr_data.*, usr_pref.value AS language
4560 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4561 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4562 $values[] =
"language";
4568 $query .=
" AND usr_data.active = %s";
4570 $types[] =
"integer";
4573 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4575 $r = $ilDB->queryF(
$query, $types, $values);
4577 while (
$row = $ilDB->fetchAssoc($r))
4593 $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 ";
4595 $values[] =
"language";
4599 $query .=
" AND usr_data.active = %s";
4601 $types[] =
"integer";
4606 $query.=
" AND usr_data.time_limit_owner = %s";
4608 $types[] =
"integer";
4611 $query .=
" AND usr_data.usr_id != %s ";
4612 $values[] = ANONYMOUS_USER_ID;
4613 $types[] =
"integer";
4615 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4621 array_push($data,
$row);
4646 global $rbacadmin, $rbacreview, $ilDB;
4650 foreach ($a_mem_ids as $mem_id) {
4651 $ids [] = $ilDB->quote($mem_id);
4654 $query =
"SELECT usr_data.*, usr_pref.value AS language
4656 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4657 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer").
"
4658 AND usr_data.usr_id != %s";
4659 $values[] =
"language";
4661 $values[] = ANONYMOUS_USER_ID;
4662 $types[] =
"integer";
4666 $query .=
" AND active = %s";
4668 $types[] =
"integer";
4673 $query.=
" AND usr_data.time_limit_owner = %s";
4674 $values[] = $timelimitowner;
4675 $types[] =
"integer";
4679 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4687 return $mem_arr ? $mem_arr : array();
4701 if (is_array($a_internalids)) {
4702 foreach ($a_internalids as $internalid) {
4703 if (is_numeric ($internalid))
4705 $ids[] = $internalid;
4710 if (is_numeric($parsedid) && $parsedid > 0)
4717 if (count($ids) == 0)
4720 $query =
"SELECT usr_data.*, usr_pref.value AS language
4723 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4724 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4725 $values[] =
"language";
4728 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4751 $r = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE usr_id = %s",
4752 array(
"integer"), array($user_id));
4754 while(
$row = $ilDB->fetchAssoc($r))
4767 $query =
"UPDATE usr_data SET login_attempts = 0 WHERE usr_id = %s";
4768 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4770 if($affected)
return true;
4778 $query =
"SELECT login_attempts FROM usr_data WHERE usr_id = %s";
4779 $result = $ilDB->queryF(
$query, array(
'integer'), array($a_usr_id) );
4780 $record = $ilDB->fetchAssoc(
$result );
4790 $query =
"UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s";
4791 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4793 if($affected)
return true;
4801 $query =
"UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s";
4802 $affected = $ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array(
ilUtil::now(), $a_usr_id) );
4804 if($affected)
return true;
4814 return in_array($this->
getPref(
"public_profile"), array(
"y",
"g"));
4837 $res = $ilDB->queryF(
'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4838 array(
'integer',
'text',
'integer'),
4841 if( $ilDB->numRows(
$res) == 0 )
4843 $ilDB->manipulateF(
'
4844 INSERT INTO loginname_history
4845 (usr_id, login, history_date)
4846 VALUES (%s, %s, %s)',
4847 array(
'integer',
'text',
'integer'),
4861 public static function _getUsersOnline($a_user_id = 0, $a_no_anonymous =
false)
4869 $atime = $pd_set->get(
'user_activity_time') * 60;
4876 $where[] =
'user_id > 0';
4878 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
4879 if(ilTermsOfServiceHelper::isEnabled())
4881 $where[] =
'(agree_date IS NOT NULL OR user_id = ' . $ilDB->quote(SYSTEM_USER_ID,
'integer') .
')';
4886 $where[] =
'user_id = ' . $ilDB->quote($a_user_id,
'integer');
4891 $where[] =
'user_id != ' . $ilDB->quote(ANONYMOUS_USER_ID,
'integer');
4894 include_once
'Services/User/classes/class.ilUserAccountSettings.php';
4897 include_once
'Services/User/classes/class.ilUserFilter.php';
4901 $where[] =
'expires > ' . $ilDB->quote($ctime,
'integer');
4902 $where[] =
'(p.value IS NULL OR NOT p.value = ' . $ilDB->quote(
'y',
'text') .
')';
4904 $where =
'WHERE ' . implode(
' AND ', $where);
4906 $r = $ilDB->queryF(
"
4907 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime
4909 LEFT JOIN usr_data u
4910 ON user_id = u.usr_id
4911 LEFT JOIN usr_pref p
4912 ON (p.usr_id = u.usr_id AND p.keyword = %s)
4914 GROUP BY user_id, firstname, lastname, title, login, last_login
4915 ORDER BY lastname, firstname
4918 array(
'hide_own_online_status')
4922 while($user = $ilDB->fetchAssoc($r))
4924 if($atime <= 0 || $user[
'ctime'] + $atime > $ctime)
4926 $users[$user[
'user_id']] = $user;
4946 $atime = $pd_set->get(
"user_activity_time") * 60;
4948 $no_anonym = ($a_no_anonymous)
4949 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4956 $q =
"SELECT DISTINCT dat.obj_id as obj_id ".
4958 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4959 "JOIN object_reference r1 ON r1.ref_id = fa.parent ".
4960 "JOIN tree ON tree.child = r1.ref_id ".
4961 "JOIN object_reference r2 ON r2.ref_id = tree.parent ".
4962 "JOIN object_data dat ON dat.obj_id = r2.obj_id ".
4963 "WHERE ua.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4964 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4965 "AND dat.type IN (".$ilDB->quote(
"crs",
"text").
",".
4966 $ilDB->quote(
"grp",
"text").
")";
4967 $r = $ilDB->query($q);
4969 while (
$row = $ilDB->fetchAssoc($r))
4971 $groups_and_courses_of_user[] =
$row[
"obj_id"];
4974 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
4975 $tos_condition =
'';
4976 if(ilTermsOfServiceHelper::isEnabled())
4978 $tos_condition =
" AND (agree_date IS NOT NULL OR ud.usr_id = " . $ilDB->quote(SYSTEM_USER_ID,
'integer') .
") ";
4982 if (count($groups_and_courses_of_user) == 0)
4984 $q =
"SELECT count(user_id) as num,ctime,user_id,firstname,lastname,title,login,last_login ".
4985 "FROM usr_session ".
4986 "JOIN usr_data ud ON user_id = ud.usr_id ".
4987 "WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4990 "AND expires > ".$ilDB->quote(time(),
"integer").
" ".
4991 "GROUP BY user_id,ctime,firstname,lastname,title,login,last_login";
4992 $r = $ilDB->query($q);
4996 $q =
"SELECT count(user_id) as num,s.ctime,s.user_id,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4997 "FROM usr_session s ".
4998 "JOIN usr_data ud ON ud.usr_id = s.user_id ".
4999 "JOIN rbac_ua ua ON ua.usr_id = s.user_id ".
5000 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
5001 "JOIN tree ON tree.child = fa.parent ".
5002 "JOIN object_reference or1 ON or1.ref_id = tree.parent ".
5003 "JOIN object_data od ON od.obj_id = or1.obj_id ".
5004 "LEFT JOIN usr_pref p ON (p.usr_id = ud.usr_id AND p.keyword = ".
5005 $ilDB->quote(
"hide_own_online_status",
"text").
") ".
5006 "WHERE s.user_id != 0 ".
5008 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
5009 "AND s.expires > ".$ilDB->quote(time(),
"integer").
" ".
5010 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
5012 "AND ".$ilDB->in(
"od.obj_id", $groups_and_courses_of_user,
false,
"integer").
" ".
5013 "GROUP BY s.user_id,s.ctime,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
5014 "ORDER BY ud.lastname, ud.firstname";
5015 $r = $ilDB->query($q);
5018 while ($user = $ilDB->fetchAssoc($r))
5021 || $user[
"ctime"] + $atime > $ctime)
5023 $users[$user[
"user_id"]] = $user;
5027 return $users ? $users : array();
5044 $hashcode = substr(md5(uniqid(rand(),
true)), 0, 16);
5046 $res = $ilDB->queryf(
'
5047 SELECT COUNT(usr_id) cnt FROM usr_data
5048 WHERE reg_hash = %s',
5053 if(
$row->cnt > 0) $continue =
true;
5057 if($continue)
continue;
5059 $ilDB->manipulateF(
'
5063 array(
'text',
'integer'),
5064 array($hashcode, (
int)$a_usr_id)
5086 $res = $ilDB->queryf(
'
5087 SELECT usr_id, create_date FROM usr_data
5088 WHERE reg_hash = %s',
5091 while(
$row = $ilDB->fetchAssoc(
$res))
5093 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
5096 if((
int)$oRegSettigs->getRegistrationHashLifetime() != 0 &&
5097 time() - (int)$oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row[
'create_date']))
5099 require_once
'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
5103 $ilDB->manipulateF(
'
5107 array(
'text',
'integer'),
5108 array(
'', (
int)
$row[
'usr_id'])
5111 return (
int)$row[
'usr_id'];
5114 require_once
'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
5120 if (strlen($a_birthday))
5127 $this->birthday = null;
5146 if( !(
int)$period )
throw new ilException(
'no valid period given');
5150 $date = date(
'Y-m-d H:i:s', (time() - ((
int)$period * 24 * 60 * 60)) );
5152 $query =
"SELECT usr_id FROM usr_data WHERE last_login < %s";
5154 $res = $ilDB->queryF(
$query, array(
'timestamp'), array($date));
5159 $ids[] =
$row->usr_id;
5176 $field =
'inactivation_date';
5179 if( !(
int)$period )
throw new ilException(
'no valid period given');
5183 $date = date(
'Y-m-d H:i:s', (time() - ((
int)$period * 24 * 60 * 60)) );
5185 $query =
"SELECT usr_id FROM usr_data WHERE $field < %s AND active = %s";
5187 $res = $ilDB->queryF(
$query, array(
'timestamp',
'integer'), array($date, 0));
5192 $ids[] =
$row->usr_id;
5209 if($a_last_login !== null) $last_login = $a_last_login;
5210 else $last_login = date(
'Y-m-d H:i:s');
5214 $query =
"UPDATE usr_data SET last_login = %s WHERE usr_id = %s";
5215 $affected = $ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array($last_login, $a_usr_id) );
5217 if($affected)
return $last_login;
5225 $query =
"UPDATE object_data SET owner = 0 ".
5226 "WHERE owner = ".$ilDB->quote($this->
getId(),
'integer');
5243 $q =
"SELECT DISTINCT ".$ilDB->upper($ilDB->substr(
"lastname", 1, 1)).
" let".
5245 " WHERE usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
5247 $let_set = $ilDB->query($q);
5250 while ($let_rec = $ilDB->fetchAssoc($let_set))
5252 $let[$let_rec[
"let"]] = $let_rec[
"let"];
5262 $query =
'SELECT count(*) num FROM object_data od '.
5263 'JOIN usr_data ud ON obj_id = usr_id '.
5264 'WHERE '.$ilDB->in(
'obj_id',$a_usr_ids,
false,
'integer').
' ';
5267 return $num_rows == count((array) $a_usr_ids);
5276 return (
boolean)
$_SESSION[
"user_captcha_verified"];
5286 $_SESSION[
"user_captcha_verified"] = $a_val;
5297 include_once(
"./Services/Export/classes/class.ilExport.php");
5302 $exp->exportEntity(
"personal_data", $this->
getId(),
"4.3.0",
5303 "Services/User",
$title, $dir);
5314 include_once(
"./Services/Export/classes/class.ilExport.php");
5322 if (is_int(strpos($entry[
"entry"],
".zip")))
5324 return $entry[
"entry"];
5339 include_once(
"./Services/Export/classes/class.ilExport.php");
5341 "/".$this->getPersonalDataExportFile();
5355 $a_bookmarks, $a_notes, $a_calendar)
5357 include_once(
"./Services/Export/classes/class.ilImport.php");
5359 if (!$a_profile_data)
5361 $imp->addSkipEntity(
"Services/User",
"usr_profile");
5365 $imp->addSkipEntity(
"Services/User",
"usr_setting");
5369 $imp->addSkipEntity(
"Services/Bookmarks",
"bookmarks");
5373 $imp->addSkipEntity(
"Services/Notes",
"user_notes");
5377 $imp->addSkipEntity(
"Services/Calendar",
"calendar");
5379 $imp->importEntity($a_file[
"tmp_name"], $a_file[
"name"],
"personal_data",
5392 $NOW = $ilDB->now();
5394 $usrId_IN_usrIds = $ilDB->in(
'usr_id', $usrIds,
false,
'integer');
5398 SET inactivation_date = $NOW
5399 WHERE inactivation_date IS NULL
5400 AND $usrId_IN_usrIds
5403 $ilDB->manipulate($queryString);
5415 $usrId_IN_usrIds = $ilDB->in(
'usr_id', $usrIds,
false,
'integer');
5419 SET inactivation_date = NULL
5420 WHERE $usrId_IN_usrIds
5423 $ilDB->manipulate($queryString);
5449 public function hasToAcceptTermsOfService()
5456 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5459 ilTermsOfServiceHelper::isEnabled() &&
5460 null == $this->agree_date &&
5461 'root' != $this->agree_date &&
5462 !in_array($this->
getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID)) &&
5463 !$rbacreview->isAssigned($this->getId(), SYSTEM_ROLE_ID)
5476 public static function hasUserToAcceptTermsOfService($a_username)
5483 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5485 if(!ilTermsOfServiceHelper::isEnabled())
5490 $in = $ilDB->in(
'usr_id', array(ANONYMOUS_USER_ID, SYSTEM_USER_ID),
true,
'integer');
5491 $res = $ilDB->queryF(
5492 "SELECT usr_id FROM usr_data WHERE login = %s AND agree_date IS NULL $in",
5496 return $ilDB->fetchAssoc(
$res) ?
true :
false;
5505 if(null === $status)
5510 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5511 if(ilTermsOfServiceHelper::isEnabled())
5522 return $this->
getId() == ANONYMOUS_USER_ID;
5537 return (
bool)$this->
getPref(
"delete_flag");
5545 $this->is_self_registered = (bool) $status;