4 define (
"IL_PASSWD_PLAIN",
"plain");
5 define (
"IL_PASSWD_CRYPTED",
"crypted");
8 require_once
"./Services/Object/classes/class.ilObject.php";
9 require_once
'./Services/User/exceptions/class.ilUserException.php';
175 public function __construct($a_user_id = 0, $a_call_by_reference =
false)
185 $this->auth_mode =
"default";
195 $this->
setId($a_user_id);
202 $this->prefs = array();
204 $this->prefs[
"language"] = $this->ilias->ini->readVariable(
"language",
"default");
207 $this->skin = $this->ilias->ini->readVariable(
"layout",
"skin");
210 $this->prefs[
"show_users_online"] =
"y";
213 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
230 $r = $ilDB->queryF(
"SELECT * FROM usr_data ".
231 "WHERE usr_id= %s", array(
"integer"), array($this->
id));
233 if ($data = $ilDB->fetchAssoc($r))
253 if ($this->prefs[
"language"] ==
"")
255 $this->prefs[
"language"] = $this->oldPrefs[
"language"];
259 include_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
260 if ($this->prefs[
"skin"] ==
"" ||
263 $this->prefs[
"skin"] = $this->oldPrefs[
"skin"];
266 $this->skin = $this->prefs[
"skin"];
269 if ($this->prefs[
"style"] ==
"" ||
273 $this->prefs[
"style"] = $this->ilias->ini->readVariable(
"layout",
"style");
276 if (empty($this->prefs[
"hits_per_page"]))
278 $this->prefs[
"hits_per_page"] = 10;
284 $ilErr->raiseError(
"<b>Error: There is no dataset with id ".
285 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
286 "<br />Line: ".__LINE__, $ilErr->FATAL);
308 $this->password_encoding_type = $password_encryption_type;
338 if (! $a_data[
"passwd_type"])
340 $ilErr->raiseError(
"<b>Error: passwd_type missing in function assignData(). ".
341 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: "
342 .__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
344 if ($a_data[
"passwd"] !=
"********" and strlen($a_data[
'passwd']))
346 $this->
setPasswd($a_data[
"passwd"], $a_data[
"passwd_type"]);
354 if (!is_array($a_data[
'birthday']))
367 $this->
setCity($a_data[
"city"]);
374 $this->
setFax($a_data[
"fax"]);
400 $this->create_date = $a_data[
"create_date"];
401 $this->
setComment($a_data[
"referral_comment"]);
402 $this->approve_date = $a_data[
"approve_date"];
403 $this->active = $a_data[
"active"];
404 $this->agree_date = $a_data[
"agree_date"];
431 public function saveAsNew($a_from_formular =
true)
433 global $ilAppEventHandler;
441 switch ($this->passwd_type)
444 if(strlen($this->passwd))
446 require_once
'Services/User/classes/class.ilUserPasswordManager.php';
447 ilUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
461 $ilErr->raiseError(
"<b>Error: passwd_type missing in function saveAsNew. ".
462 $this->
id.
"!</b><br />class: ".get_class($this).
"<br />Script: ".__FILE__.
463 "<br />Line: ".__LINE__, $ilErr->FATAL);
475 $insert_array = array(
476 "usr_id" => array(
"integer", $this->
id),
477 "login" => array(
"text", $this->login),
478 "passwd" => array(
"text", $pw_value),
481 "firstname" => array(
"text", $this->firstname),
482 "lastname" => array(
"text", $this->lastname),
483 "title" => array(
"text", $this->utitle),
484 "gender" => array(
"text", $this->gender),
485 "email" => array(
"text", trim($this->email)),
486 "hobby" => array(
"text", (
string) $this->hobby),
487 "institution" => array(
"text", $this->institution),
488 "department" => array(
"text", $this->department),
489 "street" => array(
"text", $this->street),
490 "city" => array(
"text", $this->city),
491 "zipcode" => array(
"text", $this->zipcode),
492 "country" => array(
"text", $this->country),
493 "sel_country" => array(
"text", $this->sel_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),
499 "last_login" => array(
"timestamp", null),
500 "last_update" => array(
"timestamp",
ilUtil::now()),
501 "create_date" => array(
"timestamp",
ilUtil::now()),
502 "referral_comment" => array(
"text", $this->referral_comment),
503 "matriculation" => array(
"text", $this->matriculation),
504 "client_ip" => array(
"text", $this->client_ip),
505 "approve_date" => array(
"timestamp", $this->approve_date),
506 "agree_date" => array(
"timestamp", $this->agree_date),
507 "active" => array(
"integer", (
int) $this->active),
512 "auth_mode" => array(
"text", $this->
getAuthMode()),
515 "im_icq" => array(
"text", $this->im_icq),
516 "im_yahoo" => array(
"text", $this->im_yahoo),
517 "im_msn" => array(
"text", $this->im_msn),
518 "im_aim" => array(
"text", $this->im_aim),
519 "im_skype" => array(
"text", $this->im_skype),
520 "delicious" => array(
"text", $this->delicious),
521 "latitude" => array(
"text", $this->latitude),
522 "longitude" => array(
"text", $this->longitude),
523 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
524 "last_password_change" => array(
"integer", (
int) $this->last_password_change_ts),
525 "im_jabber" => array(
"text", $this->im_jabber),
526 "im_voip" => array(
"text", $this->im_voip),
527 'inactivation_date' => array(
'timestamp', $this->inactivation_date),
528 'is_self_registered' => array(
'integer', (
int)$this->is_self_registered)
530 $ilDB->insert(
"usr_data", $insert_array);
540 include_once (
"Services/Mail/classes/class.ilMailbox.php");
542 $mbox->createDefaultFolder();
544 include_once
"Services/Mail/classes/class.ilMailOptions.php";
546 $mail_options->createMailOptionsEntry();
549 include_once
"./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
551 $bmf->createNewBookmarkTree();
553 $ilAppEventHandler->raise(
"Services/User",
"afterCreate",
554 array(
"user_obj" => $this));
576 else if($this->active)
581 $update_array = array(
582 "gender" => array(
"text", $this->gender),
583 "title" => array(
"text", $this->utitle),
584 "firstname" => array(
"text", $this->firstname),
585 "lastname" => array(
"text", $this->lastname),
586 "email" => array(
"text", trim($this->email)),
588 "hobby" => array(
"text", $this->hobby),
589 "institution" => array(
"text", $this->institution),
590 "department" => array(
"text", $this->department),
591 "street" => array(
"text", $this->street),
592 "city" => array(
"text", $this->city),
593 "zipcode" => array(
"text", $this->zipcode),
594 "country" => array(
"text", $this->country),
595 "sel_country" => array(
"text", $this->sel_country),
596 "phone_office" => array(
"text", $this->phone_office),
597 "phone_home" => array(
"text", $this->phone_home),
598 "phone_mobile" => array(
"text", $this->phone_mobile),
599 "fax" => array(
"text", $this->fax),
600 "referral_comment" => array(
"text", $this->referral_comment),
601 "matriculation" => array(
"text", $this->matriculation),
602 "client_ip" => array(
"text", $this->client_ip),
603 "approve_date" => array(
"timestamp", $this->approve_date),
604 "active" => array(
"integer", $this->active),
611 "auth_mode" => array(
"text", $this->
getAuthMode()),
613 "im_icq" => array(
"text", $this->im_icq),
614 "im_yahoo" => array(
"text", $this->im_yahoo),
615 "im_msn" => array(
"text", $this->im_msn),
616 "im_aim" => array(
"text", $this->im_aim),
617 "im_skype" => array(
"text", $this->im_skype),
618 "delicious" => array(
"text", $this->delicious),
619 "latitude" => array(
"text", $this->latitude),
620 "longitude" => array(
"text", $this->longitude),
621 "loc_zoom" => array(
"integer", (
int) $this->loc_zoom),
622 "last_password_change" => array(
"integer", $this->last_password_change_ts),
623 "im_jabber" => array(
"text", $this->im_jabber),
624 "im_voip" => array(
"text", $this->im_voip),
625 "last_update" => array(
"timestamp",
ilUtil::now()),
626 'inactivation_date' => array(
'timestamp', $this->inactivation_date)
629 if (isset($this->agree_date) && (strtotime($this->agree_date) !==
false || $this->agree_date == null))
631 $update_array[
"agree_date"] = array(
"timestamp", $this->agree_date);
633 switch ($this->passwd_type)
636 if(strlen($this->passwd))
638 require_once
'Services/User/classes/class.ilUserPasswordManager.php';
639 ilUserPasswordManager::getInstance()->encodePassword($this, $this->passwd);
640 $update_array[
'passwd'] = array(
'text', $this->
getPasswd());
644 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
649 $update_array[
"passwd"] = array(
"text", (
string) $this->passwd);
653 $ilErr->raiseError(
"<b>Error: passwd_type missing in function update()".$this->
id.
"!</b><br />class: ".
654 get_class($this).
"<br />Script: ".__FILE__.
"<br />Line: ".__LINE__, $ilErr->FATAL);
658 $update_array[
'passwd_salt'] = array(
'text', $this->
getPasswordSalt());
660 $ilDB->update(
"usr_data", $update_array, array(
"usr_id" => array(
"integer", $this->
id)));
674 $ilAppEventHandler->raise(
"Services/User",
"afterUpdate",
675 array(
"user_obj" => $this));
687 $ilDB->manipulateF(
"UPDATE usr_data SET agree_date = ".$ilDB->now().
688 " WHERE usr_id = %s", array(
"integer"), array($this->
getId()));
694 private function _lookup($a_user_id, $a_field)
698 $res = $ilDB->queryF(
"SELECT ".$a_field.
" FROM usr_data WHERE usr_id = %s",
699 array(
"integer"), array($a_user_id));
701 while($set = $ilDB->fetchAssoc(
$res))
703 return $set[$a_field];
715 $set = $ilDB->queryF(
"SELECT title, firstname, lastname FROM usr_data WHERE usr_id = %s",
716 array(
"integer"), array($a_user_id));
718 if ($rec = $ilDB->fetchAssoc($set))
724 if ($rec[
"firstname"])
728 if ($rec[
"lastname"])
782 $res = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
783 array(
"integer"), array($a_user_id));
784 $user_rec = $ilDB->fetchAssoc(
$res);
785 return array(
"user_id" => $a_user_id,
786 "firstname" => $user_rec[
"firstname"],
787 "lastname" => $user_rec[
"lastname"],
788 "title" => $user_rec[
"title"],
789 "login" => $user_rec[
"login"]);
799 $res = $ilDB->queryF(
"SELECT * FROM usr_data WHERE usr_id = %s",
800 array(
"integer"), array($a_user_id));
801 $user_rec = $ilDB->fetchAssoc(
$res);
828 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data WHERE login = %s",
829 array(
"text"), array($a_user_str));
830 $user_rec = $ilDB->fetchAssoc(
$res);
831 return $user_rec[
"usr_id"];
852 $ilDB->manipulateF(
"UPDATE usr_data SET ".
853 "last_login = ".$ilDB->now().
854 " WHERE usr_id = %s",
855 array(
"integer"), array($this->
id));
863 public function replacePassword($md5_encoded_password)
875 SET passwd = %s, passwd_enc_type = %s
877 array(
'text',
'text',
'integer'),
891 public function resetPassword($raw, $raw_retype)
898 if(func_num_args() != 2)
903 if(!isset($raw) || !isset($raw_retype))
908 if($raw != $raw_retype)
913 require_once
'Services/User/classes/class.ilUserPasswordManager.php';
914 ilUserPasswordManager::getInstance()->encodePassword($this, $raw);
918 SET passwd = %s, passwd_enc_type = %s, passwd_salt = %s
920 array(
'text',
'text',
'text',
'integer'),
941 $res = $ilDB->queryF(
'
942 SELECT * FROM loginname_history
944 array(
'text'), array($a_login));
946 return $ilDB->fetchAssoc(
$res) ?
true :
false;
965 $ilDB->setLimit(1, 0);
966 $res = $ilDB->queryF(
'
967 SELECT login, history_date FROM loginname_history
968 WHERE usr_id = %s ORDER BY history_date DESC',
969 array(
'integer'), array($a_usr_id));
989 if(func_num_args() != 1)
1002 if(0 == strcmp($a_login, $former_login))
1014 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1015 (int)$ilSetting->get(
'reuse_of_loginnames') == 0 &&
1018 throw new ilUserException($this->lng->txt(
'loginname_already_exists'));
1020 else if((
int)$ilSetting->get(
'allow_change_loginname') &&
1021 (int)$ilSetting->get(
'loginname_change_blocking_time') &&
1022 is_array($last_history_entry) &&
1023 $last_history_entry[1] + (int)$ilSetting->get(
'loginname_change_blocking_time') > time())
1025 include_once
'Services/Calendar/classes/class.ilDate.php';
1028 $this->lng->txt(
'changing_loginname_not_possible_info'),
1032 new ilDateTime(($last_history_entry[1] + (
int)$ilSetting->get(
'loginname_change_blocking_time')),
IL_CAL_UNIX))
1039 if((
int)$ilSetting->get(
'allow_change_loginname') &&
1040 (int)$ilSetting->get(
'create_history_loginname'))
1046 $this->login = $a_login;
1048 $ilDB->manipulateF(
'
1052 array(
'text',
'integer'), array($this->
getLogin(), $this->
getId()));
1054 include_once
'Services/Contact/classes/class.ilAddressbook.php';
1055 ilAddressbook::onLoginNameChange($former_login, $this->
getLogin());
1070 $this->
setPref($a_keyword, $a_value);
1081 self::_deletePref($this->
getId(), $a_keyword);
1089 public static function _deletePref($a_user_id, $a_keyword)
1097 'DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s',
1098 array(
'integer',
'text'),
1099 array($a_user_id, $a_keyword)
1112 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s",
1113 array(
"integer"), array($a_user_id));
1122 public static function _writePref($a_usr_id, $a_keyword, $a_value)
1125 $ilDB->replace(
"usr_pref",
1127 "usr_id" => array(
"integer", $a_usr_id),
1128 "keyword" => array(
"text", $a_keyword),
1131 "value" => array(
"text",$a_value)
1156 foreach ($this->prefs as $keyword => $value)
1170 if($tz = $this->
getPref(
'user_tz'))
1176 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1178 return $settings->getDefaultTimeZone();
1190 if($format = $this->
getPref(
'time_format'))
1196 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1198 return $settings->getDefaultTimeFormat();
1210 if($format = $this->
getPref(
'date_format'))
1216 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1218 return $settings->getDefaultDateFormat();
1230 if ($a_keyword !=
"")
1232 $this->prefs[$a_keyword] = $a_value;
1243 if (array_key_exists($a_keyword, $this->prefs))
1245 return $this->prefs[$a_keyword];
1257 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
" ".
1258 "AND keyword = ".$ilDB->quote($a_keyword,
"text");
1276 if (is_array($this->prefs))
1291 global $rbacadmin,
$ilDB;
1294 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1296 $mapping->deleteUser($this->
getId());
1299 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1302 $mailbox->updateMailsOfDeletedUser($this->
getLogin());
1305 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1307 $costum_block->setContextObjId($this->
getId());
1308 $costum_block->setContextObjType(
"user");
1309 $c_blocks = $costum_block->queryBlocksForContext();
1310 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1311 foreach($c_blocks as $c_block)
1313 if ($c_block[
"type"] ==
"pdfeed")
1322 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1326 $ilDB->manipulateF(
"DELETE FROM usr_data WHERE usr_id = %s",
1327 array(
"integer"), array($this->
getId()));
1337 include_once(
"./Services/Authentication/classes/class.ilSession.php");
1341 $rbacadmin->removeUser($this->
getId());
1345 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1346 $ilDB->quote($this->
getId(),
"integer");
1347 $ilDB->manipulate($q);
1349 $q =
"DELETE FROM bookmark_data WHERE user_id = ".
1350 $ilDB->quote($this->
getId(),
"integer");
1351 $ilDB->manipulate($q);
1354 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1355 ilObjForum::_deleteUser($this->
getId());
1358 include_once
'./Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1362 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1366 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1369 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1373 include_once
'Modules/Scorm2004/classes/ilSCORM13Package.php';
1377 include_once
'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
1381 include_once
"./Services/Notification/classes/class.ilNotification.php";
1385 include_once
"./Modules/Portfolio/classes/class.ilObjPortfolio.php";
1389 include_once
"./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1391 $tree->cascadingDelete();
1394 include_once
"./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1398 require_once
'Services/User/classes/class.ilCronDeleteInactiveUserReminderMail.php';
1410 include_once
'Services/Contact/classes/class.ilAddressbook.php';
1411 ilAddressbook::onUserDeletion($this);
1414 global $ilAppEventHandler;
1415 $ilAppEventHandler->raise(
1416 'Services/User',
'deleteUser', array(
'usr_id' => $this->
getId())
1433 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1435 $this->fullname =
"";
1441 elseif ($this->utitle)
1443 $this->fullname = $this->utitle.
" ";
1450 elseif ($this->firstname)
1452 $this->fullname .= $this->firstname.
" ";
1484 if (strlen($this->fullname) <= $a_max_strlen)
1489 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1491 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1494 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1499 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1510 function hasAcceptedUserAgreement()
1518 null != $this->agree_date ||
1519 'root' == $this->login ||
1520 in_array($this->
getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID)) ||
1521 $rbacreview->isAssigned($this->getId(), SYSTEM_ROLE_ID)
1536 $this->login = $a_str;
1555 $this->passwd = $a_str;
1556 $this->passwd_type = $a_type;
1588 $this->gender = substr($a_str,-1);
1609 $this->utitle = $a_str;
1630 $this->firstname = $a_str;
1649 $this->lastname = $a_str;
1668 $this->institution = $a_str;
1687 $this->department = $a_str;
1706 $this->street = $a_str;
1725 $this->city = $a_str;
1744 $this->zipcode = $a_str;
1764 $this->country = $a_str;
1784 $this->sel_country = $a_val;
1804 $this->phone_office = $a_str;
1823 $this->phone_home = $a_str;
1842 $this->phone_mobile = $a_str;
1861 $this->fax = $a_str;
1880 $this->client_ip = $a_str;
1899 $this->matriculation = $a_str;
1921 $query =
"SELECT matriculation FROM usr_data ".
1922 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1925 return $row->matriculation ?
$row->matriculation :
'';
1935 $this->email = $a_str;
1954 $this->hobby = $a_str;
1973 $this->
setPref(
"language",$a_str);
1984 return $this->prefs[
"language"];
1997 $this->
setPref(
"disk_quota",$a_disk_quota);
2011 return $this->prefs[
"disk_quota"] ? $this->prefs[
"disk_quota"] : 0;
2016 return $this->prefs[
"wsp_disk_quota"] ? $this->prefs[
"wsp_disk_quota"] : 0;
2021 $this->last_password_change_ts = $a_last_password_change_ts;
2034 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
2035 $ilDB->quote($a_usr_id,
"integer").
" AND keyword = ".
2036 $ilDB->quote(
'language',
"text");
2037 $r = $ilDB->query($q);
2039 while(
$row = $ilDB->fetchAssoc($r))
2041 return $row[
'value'];
2050 $ilDB->manipulateF(
"UPDATE usr_data ".
2051 " SET ext_account = %s WHERE usr_id = %s",
2052 array(
"text",
"integer"),
2053 array($a_ext_id, $a_usr_id));
2060 $ilDB->manipulateF(
"UPDATE usr_data ".
2061 " SET auth_mode = %s WHERE usr_id = %s",
2062 array(
"text",
"integer"),
2063 array($a_auth_mode, $a_usr_id));
2092 $this->last_login = $a_str;
2102 return $this->last_login;
2112 $this->last_update = $a_str;
2126 $this->referral_comment = $a_str;
2146 $this->approve_date = $a_str;
2177 $this->agree_date = $a_str;
2220 $query =
'SELECT usr_id FROM usr_data '.
2221 'WHERE active = '.$ilDB->quote(1,
'integer').
' '.
2222 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer');
2252 if ((!empty($storedActive) && empty($currentActive)) ||
2253 (empty($storedActive) && !empty($currentActive)))
2268 return $active ?
true :
false;
2279 $this->skin = $a_str;
2284 $this->time_limit_owner = $a_owner;
2288 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2292 $this->time_limit_from = $a_from;
2296 return $this->time_limit_from ? $this->time_limit_from : time();
2300 $this->time_limit_until = $a_until;
2304 return $this->time_limit_until ? $this->time_limit_until : time();
2308 $this->time_limit_unlimited = $a_unlimited;
2312 return $this->time_limit_unlimited;
2316 return $this->time_limit_message = $a_time_limit_message;
2320 return $this->time_limit_message;
2325 $this->login_attempts = $a_login_attempts;
2348 $this->profile_incomplete = (boolean) $a_prof_inc;
2352 if($this->
id == ANONYMOUS_USER_ID)
2356 return $this->profile_incomplete;
2362 if( $this->
id == ANONYMOUS_USER_ID || $this->
id == SYSTEM_USER_ID )
2365 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2369 && $security->isPasswordChangeOnFirstLoginEnabled()
2371 && $this->is_self_registered == false
2381 if($this->
id == ANONYMOUS_USER_ID)
return false;
2383 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2387 $max_pass_age = $security->getPasswordMaxAge();
2388 if( $max_pass_age > 0 )
2390 $max_pass_age_ts = ( $max_pass_age * 86400 );
2392 $current_ts = time();
2394 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2403 $current_ts = time();
2405 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2406 return $password_age;
2415 $query =
"UPDATE usr_data SET last_password_change = %s " .
2416 "WHERE usr_id = %s";
2417 $affected = $ilDB->manipulateF(
$query,
2418 array(
'integer',
'integer'),
2420 if($affected)
return true;
2428 $query =
"UPDATE usr_data SET last_password_change = 0 " .
2429 "WHERE usr_id = %s";
2430 $affected = $ilDB->manipulateF(
$query, array(
'integer'),
2431 array($this->
getId()) );
2432 if($affected)
return true;
2443 $this->latitude = $a_latitude;
2463 $this->longitude = $a_longitude;
2483 $this->loc_zoom = $a_locationzoom;
2498 $this->applied_users = array();
2501 return $this->applied_users ? $this->applied_users : array();
2506 if($a_usr_id == $this->
getId())
2511 $this->applied_users = array();
2514 return in_array($a_usr_id,$this->applied_users);
2521 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2522 "WHERE time_limit_owner = %s",
2524 array($a_parent_id));
2525 while (
$row = $ilDB->fetchObject(
$res))
2527 $this->applied_users[] =
$row->usr_id;
2544 $set = $ilDB->queryf(
'
2545 SELECT COUNT(*) session_count
2546 FROM usr_session WHERE user_id = %s AND expires > %s',
2547 array(
'integer',
'integer'),
2548 array($a_user_id, time()));
2549 $row = $ilDB->fetchAssoc($set);
2550 return (
bool)
$row[
'session_count'];
2577 require_once (
'Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2580 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2581 require_once (
'Services/Database/classes/class.ilAuthContainerMDB2.php');
2586 $login =$ilAuth->getUsername();
2599 global
$ilDB,$ilAuth;
2602 $set = $ilDB->queryF(
"SELECT active FROM usr_data WHERE login= %s",
2606 if ($rec = $ilDB->fetchAssoc($set))
2642 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
2643 "WHERE email = %s and active = 1",
2647 while(
$row = $ilDB->fetchObject(
$res))
2649 $ids[] =
$row->login;
2669 $res = $ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2670 "WHERE email = %s", array(
"text"), array($a_email));
2673 return $row->usr_id ?
$row->usr_id : 0;
2700 static function searchUsers($a_search_str,
$active = 1, $a_return_ids_only =
false, $filter_settings = FALSE)
2705 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2707 $without_anonymous_users =
true;
2710 $join_filter =
" WHERE ";
2711 if ($filter_settings !== FALSE && strlen($filter_settings))
2713 switch ($filter_settings)
2717 $join_filter =
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.usr_id IS NULL AND ";
2724 $join_filter =
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.obj_id = ".
2725 "(SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") AND ";
2733 $local_roles = $rbacreview->getRolesOfRoleFolder(
$ref_id,
false);
2734 if (is_array($local_roles) && count($local_roles))
2736 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2737 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false, $local_roles).
" AND ";
2743 $rol_id =
$_SESSION[
"user_filter_data"];
2746 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2747 $ilDB->quote($rol_id,
"integer").
" AND ";
2748 $without_anonymous_users =
false;
2755 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2757 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2758 "FROM object_data,rbac_ua,usr_data ".
2759 "WHERE ".$ilDB->like(
"object_data.title",
"text",
"%".substr($a_search_str,5).
"%").
2760 " AND object_data.type = 'role' ".
2761 "AND rbac_ua.rol_id = object_data.obj_id ".
2762 "AND usr_data.usr_id = rbac_ua.usr_id ".
2763 "AND rbac_ua.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2768 "(".$ilDB->like(
"usr_data.login",
"text",
"%".$a_search_str.
"%").
" ".
2769 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_search_str.
"%").
" ".
2770 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_search_str.
"%").
" ".
2771 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_search_str.
"%").
") ";
2773 if ($filter_settings !== FALSE && strlen($filter_settings))
2775 switch ($filter_settings)
2778 $query.=
" AND usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
2781 $query.=
" AND usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
2784 $query.=
" AND usr_data.time_limit_unlimited = ".$ilDB->quote(0,
"integer").
" ";
2787 $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"]));
2788 $query.=
" AND last_login < ".$ilDB->quote($date,
"timestamp").
" ";
2793 if ($without_anonymous_users)
2795 $query.=
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2798 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE)
2800 $query.=
" AND active = ".$ilDB->quote(
$active,
"integer").
" ";
2806 while (
$row = $ilDB->fetchObject(
$res))
2809 "usr_id" =>
$row->usr_id,
2810 "login" =>
$row->login,
2811 "firstname" =>
$row->firstname,
2812 "lastname" =>
$row->lastname,
2813 "email" =>
$row->email,
2814 "active" =>
$row->active);
2815 $ids[] =
$row->usr_id;
2817 if ($a_return_ids_only)
2818 return $ids ? $ids : array();
2820 return $users ? $users : array();
2835 $res = $ilDB->query(
"SELECT login FROM usr_data");
2836 while(
$row = $ilDB->fetchObject(
$res))
2838 $logins[] =
$row->login;
2840 return $logins ? $logins : array();
2854 $res = $ilDB->query(
"SELECT * FROM usr_data WHERE ".
2855 $ilDB->in(
"usr_id", $a_user_ids,
false,
"integer"));
2856 while (
$row = $ilDB->fetchAssoc(
$res))
2858 $user_data[
"$row[usr_id]"] =
$row;
2860 return $user_data ? $user_data : array();
2875 $result_arr = array();
2879 if ($a_fields !== NULL and is_array($a_fields))
2881 if (count($a_fields) == 0)
2887 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2888 unset($a_fields[$usr_id_field]);
2890 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2892 if(in_array(
'online_time',$a_fields))
2894 $select .=
",ut_online.online_time ";
2898 $q =
"SELECT ".$select.
" FROM usr_data ";
2902 if(in_array(
'online_time',$a_fields))
2904 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2911 $q .=
"WHERE active = ".$ilDB->quote(
$active,
"integer");
2914 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
2917 $qtemp = $q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
2918 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
2919 $r = $ilDB->query($qtemp);
2920 $course_users = array();
2921 while (
$row = $ilDB->fetchAssoc($r))
2923 array_push($course_users,
$row[
"usr_id"]);
2925 if (count($course_users))
2927 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
2935 $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"]));
2936 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
2942 $q .=
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id ".
2943 "WHERE obj_members.obj_id = (SELECT obj_id FROM object_reference ".
2944 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
2952 $local_roles = $rbacreview->getRolesOfRoleFolder(
$ref_id,
false);
2953 if (is_array($local_roles) && count($local_roles))
2955 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2956 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
2961 $rol_id =
$_SESSION[
"user_filter_data"];
2964 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2965 $ilDB->quote($rol_id,
"integer");
2969 $r = $ilDB->query($q);
2971 while (
$row = $ilDB->fetchAssoc($r))
2973 $result_arr[] =
$row;
2987 $q =
"SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ".
2988 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
2989 " AND up1.value= ".$ilDB->quote($a_style,
"text").
2990 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
2991 " AND up2.value= ".$ilDB->quote($a_skin,
"text").
2992 " AND up1.usr_id = up2.usr_id ";
2994 $cnt_set = $ilDB->query($q);
2996 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
2998 return $cnt_rec[
"cnt"];
3008 $q =
"SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ".
3009 " WHERE up1.keyword = ".$ilDB->quote(
"style",
"text").
3010 " AND up2.keyword = ".$ilDB->quote(
"skin",
"text").
3011 " AND up1.usr_id = up2.usr_id";
3013 $sty_set = $ilDB->query($q);
3016 while($sty_rec = $ilDB->fetchAssoc($sty_set))
3018 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
3031 $q =
"SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ".
3032 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3033 " AND up1.value= ".$ilDB->quote($a_from_style,
"text").
3034 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3035 " AND up2.value= ".$ilDB->quote($a_from_skin,
"text").
3036 " AND up1.usr_id = up2.usr_id ";
3038 $usr_set = $ilDB->query($q);
3040 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3061 $item_set = $ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3062 "item_id = %s AND type = %s AND user_id = %s",
3063 array(
"integer",
"text",
"integer"),
3064 array($a_item_id, $a_type, $a_usr_id));
3067 if (!$ilDB->fetchAssoc($item_set))
3069 $ilDB->manipulateF(
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3070 " (%s,%s,%s,%s)", array(
"integer",
"text",
"integer",
"text"),
3071 array($a_item_id,$a_type,$a_usr_id,$a_par));
3074 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3102 $ilDB->manipulateF(
"UPDATE desktop_item SET parameters = %s ".
3103 " WHERE item_id = %s AND type = %s AND user_id = %s",
3104 array(
"text",
"integer",
"text",
"integer"),
3105 array($a_par, $a_item_id, $a_type, $this->
getId()));
3122 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE ".
3123 " item_id = %s AND type = %s AND user_id = %s",
3124 array(
"integer",
"text",
"integer"),
3125 array($a_item_id, $a_type, $a_usr_id));
3127 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3153 $r = $ilDB->queryF(
"SELECT user_id FROM desktop_item WHERE item_id = %s",
3154 array(
"integer"), array($a_id));
3158 while (
$row = $ilDB->fetchObject($r))
3160 $users[] =
$row->user_id;
3163 if (count($users) > 0)
3165 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE item_id = %s",
3166 array(
"integer"), array($a_id));
3185 if (self::$is_desktop_item_loaded[$a_usr_id.
":".$a_item_id])
3187 return self::$is_desktop_item_cache[$a_usr_id.
":".$a_item_id.
":".$a_type];
3189 $item_set = $ilDB->queryF(
"SELECT item_id FROM desktop_item WHERE ".
3190 "item_id = %s AND type = %s AND user_id = %s",
3191 array(
"integer",
"text",
"integer"),
3192 array($a_item_id, $a_type, $a_usr_id));
3194 if ($ilDB->fetchAssoc($item_set))
3214 if (!is_array($a_item_ids))
3219 $item_ids = array();
3220 foreach ($a_item_ids as
$id)
3222 if (!self::$is_desktop_item_loaded[$a_usr_id.
":".$id])
3226 self::$is_desktop_item_loaded[$a_usr_id.
":".
$id] =
true;
3229 if (count($item_ids) > 0)
3231 $item_set = $ilDB->query(
"SELECT item_id, type FROM desktop_item WHERE ".
3232 $ilDB->in(
"item_id", $item_ids,
false,
"integer").
3233 " AND user_id = ".$ilDB->quote($a_usr_id,
"integer"));
3234 while ($r = $ilDB->fetchAssoc($item_set))
3236 self::$is_desktop_item_cache[$a_usr_id.
":".$r[
"item_id"].
":".$r[
"type"]]
3271 $is_nested_set = ($tree->getTreeImplementation() instanceof
ilNestedSetTree);
3273 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3274 " FROM desktop_item it, object_reference oref ".
3275 ", object_data obj".
3277 "it.item_id = oref.ref_id AND ".
3278 "oref.obj_id = obj.obj_id AND ".
3279 "it.user_id = %s", array(
"integer"), array($user_id));
3280 $items = $all_parent_path = array();
3281 while ($item_rec = $ilDB->fetchAssoc($item_set))
3283 if ($tree->isInTree($item_rec[
"ref_id"])
3284 && $item_rec[
"type"] !=
"rolf"
3285 && $item_rec[
"type"] !=
"itgr")
3287 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3289 if(!isset($all_parent_path[$parent_ref]))
3299 $node = $tree->getNodeData($parent_ref);
3300 $all_parent_path[$parent_ref] = $node[
"title"];
3304 $parent_path = $all_parent_path[$parent_ref];
3308 $items[$parent_path.$title.$item_rec[
"ref_id"]] =
3309 array(
"ref_id" => $item_rec[
"ref_id"],
3310 "obj_id" => $item_rec[
"obj_id"],
3311 "type" => $item_rec[
"type"],
3313 "description" =>
$desc,
3314 "parent_ref" => $parent_ref);
3322 if (!is_array($a_types))
3324 $a_types = array($a_types);
3327 $foundsurveys = array();
3328 foreach($a_types as $a_type)
3330 if ($a_type ==
"itgr")
3334 $item_set = $ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ".
3335 ", object_data obj WHERE ".
3336 "it.item_id = oref.ref_id AND ".
3337 "oref.obj_id = obj.obj_id AND ".
3338 "it.type = %s AND ".
3341 array(
"text",
"integer"),
3342 array($a_type, $user_id));
3344 while ($item_rec = $ilDB->fetchAssoc($item_set))
3348 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3349 array(
"ref_id" => $item_rec[
"ref_id"],
3350 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3375 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3381 $a_time = date(
"Y-m-d H:i:s", time());
3384 $item_set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3385 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3386 array(
"integer",
"integer",
"text",
"integer"),
3387 array(0, $a_item_id, $a_type, $this->
getId()));
3390 if (!
$d = $item_set->fetchRow())
3392 $ilDB->manipulateF(
"INSERT INTO personal_clipboard ".
3393 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3394 " (%s,%s,%s,%s,%s,%s,%s)",
3395 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"),
3396 array($a_item_id, $a_type, $this->
getId(), $a_title, (
int) $a_parent, $a_time, (
int) $a_order_nr));
3400 $ilDB->manipulateF(
"UPDATE personal_clipboard SET insert_time = %s ".
3401 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3402 array(
"timestamp",
"integer",
"integer",
"text"),
3403 array($a_time, $this->
getId(), $a_item_id, $a_type));
3415 $a_time = date(
"Y-m-d H:i:s", time());
3417 $ilDB->insert(
"personal_pc_clipboard", array(
3418 "user_id" => array(
"integer", $this->
getId()),
3419 "content" => array(
"clob", $a_content),
3420 "insert_time" => array(
"timestamp", $a_time),
3421 "order_nr" => array(
"integer", $a_nr)
3432 $set = $ilDB->queryF(
"SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ".
3433 " WHERE user_id = %s", array(
"integer"), array($this->
getId()));
3434 $row = $ilDB->fetchAssoc($set);
3436 $set = $ilDB->queryF(
"SELECT * FROM personal_pc_clipboard ".
3437 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3438 array(
"integer",
"timestamp"),
3441 while (
$row = $ilDB->fetchAssoc($set))
3443 $content[] =
$row[
"content"];
3456 $set = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3457 "parent = %s AND type = %s AND user_id = %s",
3458 array(
"integer",
"text",
"integer"),
3459 array(0, $a_type, $this->
getId()));
3460 if ($rec = $ilDB->fetchAssoc($set))
3475 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3476 "type = %s AND user_id = %s",
3477 array(
"text",
"integer"),
3478 array($a_type, $this->
getId()));
3488 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3489 "user_id = %s", array(
"integer"), array($this->
getId()));
3500 if ($a_top_nodes_only)
3502 $par =
" AND parent = ".$ilDB->quote(0,
"integer").
" ";
3505 $type_str = ($a_type !=
"")
3506 ?
" AND type = ".$ilDB->quote($a_type,
"text").
" "
3508 $q =
"SELECT * FROM personal_clipboard WHERE ".
3509 "user_id = ".$ilDB->quote($this->
getId(),
"integer").
" ".
3511 " ORDER BY order_nr";
3512 $objs = $ilDB->query($q);
3514 while ($obj = $ilDB->fetchAssoc($objs))
3516 if ($obj[
"type"] ==
"mob")
3520 if ($obj[
"type"] ==
"incl")
3522 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3525 $objects[] = array (
"id" => $obj[
"item_id"],
3526 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3527 "insert_time" => $obj[
"insert_time"]);
3539 $objs = $ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3540 "user_id = %s AND parent = %s AND insert_time = %s ".
3541 " ORDER BY order_nr",
3542 array(
"integer",
"integer",
"timestamp"),
3543 array($ilUser->getId(), (int) $a_parent, $a_insert_time));
3545 while ($obj = $ilDB->fetchAssoc($objs))
3547 if ($obj[
"type"] ==
"mob")
3551 $objects[] = array (
"id" => $obj[
"item_id"],
3552 "type" => $obj[
"type"],
"title" => $obj[
"title"]);
3569 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3570 "item_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
3571 "type = ".$ilDB->quote($a_type,
"text");
3572 $user_set = $ilDB->query($q);
3574 while ($user_rec = $ilDB->fetchAssoc($user_set))
3576 $users[] = $user_rec[
"user_id"];
3593 $q =
"DELETE FROM personal_clipboard WHERE ".
3594 "item_id = ".$ilDB->quote($a_item_id,
"integer").
3595 " AND type = ".$ilDB->quote($a_type,
"text").
" ".
3596 " AND user_id = ".$ilDB->quote($this->
getId(),
"integer");
3597 $ilDB->manipulate($q);
3604 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3605 $ilDB->quote($i2_id,
"text");
3608 while(
$row = $ilDB->fetchObject(
$res))
3621 $this->auth_mode = $a_str;
3635 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3648 $this->ext_account = $a_str;
3660 return $this->ext_account;
3678 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3679 $q =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3680 "WHERE auth_mode = %s";
3682 $values[] = $a_auth_mode;
3685 $q.=
" OR auth_mode = %s ";
3687 $values[] =
'default';
3690 $res = $ilDB->queryF($q, $types, $values);
3691 while (
$row = $ilDB->fetchObject(
$res))
3693 if(
$row->auth_mode ==
'default')
3695 $accounts[
$row->usr_id] =
$row->login;
3699 $accounts[
$row->usr_id] =
$row->ext_account;
3702 return $accounts ? $accounts : array();
3716 if(!is_array($a_usr_ids))
3724 $q =
"UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE ".
3725 $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3726 $ilDB->manipulate($q);
3730 $usrId_IN_usrIds = $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3732 $q =
"UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds";
3733 $ilDB->manipulate($q);
3737 SET inactivation_date = %s
3738 WHERE inactivation_date IS NULL
3739 AND $usrId_IN_usrIds
3741 $ilDB->manipulateF($queryString, array(
'timestamp'), array(
ilUtil::now()));
3772 $r = $ilDB->queryF(
"SELECT * FROM usr_data WHERE ".
3773 " ext_account = %s AND auth_mode = %s",
3774 array(
"text",
"text"),
3775 array($a_account, $a_auth));
3776 if ($usr = $ilDB->fetchAssoc($r))
3778 return $usr[
"login"];
3782 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3783 "WHERE login = %s AND auth_mode = %s",
3784 array(
"text",
"text"),
3785 array($a_account, $a_auth));
3786 if($usr = $ilDB->fetchAssoc(
$res))
3788 return $usr[
'login'];
3794 $res = $ilDB->queryF(
"SELECT login FROM usr_data WHERE ".
3795 " ext_account = %s AND auth_mode = %s",
3796 array(
"text",
"text"),
3797 array($a_account,
"default"));
3798 if ($usr = $ilDB->fetchAssoc(
$res))
3800 return $usr[
"login"];
3803 $res = $ilDB->queryF(
"SELECT login FROM usr_data ".
3804 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3805 array(
"text",
"text"),
3806 array($a_account,
"default"));
3807 if($usr = $ilDB->fetchAssoc(
$res))
3809 return $usr[
"login"];
3822 $r = $ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3823 "GROUP BY auth_mode");
3825 while($cnt = $ilDB->fetchAssoc($r))
3827 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3844 $q =
"SELECT * FROM usr_data WHERE ".
3845 " email = %s AND (auth_mode = %s ";
3846 $types = array(
"text",
"text");
3847 $values = array($a_email,
"local");
3849 if ($ilSetting->get(
"auth_mode") == 1)
3851 $q.=
" OR auth_mode = %s";
3853 $values[] =
"default";
3859 $usr_set = $ilDB->queryF($q, $types, $values);
3860 while ($usr_rec = $ilDB->fetchAssoc($usr_set))
3862 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3879 $image_dir = $webspace_dir.
"/usr_images";
3880 $store_file =
"usr_".$obj_id.
".".
"jpg";
3881 $target_file = $image_dir.
"/$store_file";
3883 chmod($tmp_file, 0770);
3887 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3888 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3889 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3890 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3914 if(isset(self::$personal_image_cache[$this->
getId()][$a_size][(
int)$a_force_pic]))
3916 return self::$personal_image_cache[$this->
getId()][$a_size][(int)$a_force_pic];
3921 return self::$personal_image_cache[$this->
getId()][$a_size][(int)$a_force_pic];
3934 $a_prevent_no_photo_image =
false)
3939 $res = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE ".
3940 "keyword IN (%s,%s) ".
3942 array(
"text",
"text",
"integer"),
3943 array(
'public_upload',
'public_profile', $a_usr_id));
3944 while (
$row = $ilDB->fetchAssoc(
$res))
3946 switch (
$row[
'keyword'])
3948 case 'public_upload' :
3949 $upload =
$row[
'value'] ==
'y';
3951 case 'public_profile' :
3952 $profile = (
$row[
'value'] ==
'y' ||
3953 $row[
'value'] ==
'g');
3960 if(defined(
'ILIAS_MODULE'))
3962 $webspace_dir = (
'.'.$webspace_dir);
3964 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
3966 $image_dir = $webspace_dir.
"/usr_images";
3968 if ($a_size ==
'big')
3970 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
3974 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
3978 if((($upload && $profile) || $a_force_pic)
3979 && @is_file($thumb_file))
3981 $file = $thumb_file.
"?t=".rand(1, 99999);
3985 if (!$a_prevent_no_photo_image)
3988 if($a_size ==
"small" || $a_size ==
"big")
4007 $a_dir = trim(str_replace(
"..",
"", $a_dir));
4008 if ($a_dir ==
"" || !is_dir($a_dir))
4014 $image_dir = $webspace_dir.
"/usr_images";
4016 "upload_".$a_user_id.
"pic",
4017 "usr_".$a_user_id.
".".
"jpg",
4018 "usr_".$a_user_id.
"_small.jpg",
4019 "usr_".$a_user_id.
"_xsmall.jpg",
4020 "usr_".$a_user_id.
"_xxsmall.jpg",
4021 "upload_".$a_user_id);
4022 foreach ($images as $image)
4024 if (is_file($image_dir.
"/".$image))
4026 copy($image_dir.
"/".$image, $a_dir.
"/".$image);
4038 $image_dir = $webspace_dir.
"/usr_images";
4039 $file = $image_dir.
"/usr_".$this->getID().
".".
"jpg";
4040 $thumb_file = $image_dir.
"/usr_".$this->getID().
"_small.jpg";
4041 $xthumb_file = $image_dir.
"/usr_".$this->getID().
"_xsmall.jpg";
4042 $xxthumb_file = $image_dir.
"/usr_".$this->getID().
"_xxsmall.jpg";
4043 $upload_file = $image_dir.
"/upload_".$this->getID();
4048 $this->
setPref(
"profile_image",
"");
4052 if (@is_file(
$file))
4056 if (@is_file($thumb_file))
4058 unlink($thumb_file);
4060 if (@is_file($xthumb_file))
4062 unlink($xthumb_file);
4064 if (@is_file($xxthumb_file))
4066 unlink($xxthumb_file);
4068 if (@is_file($upload_file))
4070 unlink($upload_file);
4077 if(!is_array($a_data))
4081 foreach($a_data as $field => $data)
4083 #$new_data[$field] = ilUtil::stripSlashes($data);
4085 $this->user_defined_data[
'f_'.$field] = $data;
4087 #$this->user_defined_data = $new_data;
4094 return $this->user_defined_data ? $this->user_defined_data : array();
4103 $field_def = array();
4105 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4108 foreach($this->user_defined_data as $field => $value)
4110 if($field !=
'usr_id')
4113 $udata->set($field, $value);
4145 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4157 $this->user_defined_data = $udata->getAll();
4181 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
4197 function getProfileAsString(&$a_language)
4199 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
4200 include_once
'./Services/Utilities/classes/class.ilFormat.php';
4202 global
$lng,$rbacreview;
4204 $language =& $a_language;
4205 $language->loadLanguageModule(
'registration');
4206 $language->loadLanguageModule(
'crs');
4209 $body .= ($language->txt(
"login").
": ".$this->
getLogin().
"\n");
4213 $body .= ($language->txt(
"title").
": ".$this->
getUTitle().
"\n");
4218 $language->txt(
'gender_m') :
4219 $language->txt(
'gender_f');
4220 $body .= ($language->txt(
"gender").
": ".
$gender.
"\n");
4224 $body .= ($language->txt(
"firstname").
": ".$this->
getFirstname().
"\n");
4228 $body .= ($language->txt(
"lastname").
": ".$this->
getLastname().
"\n");
4232 $body .= ($language->txt(
"institution").
": ".$this->
getInstitution().
"\n");
4236 $body .= ($language->txt(
"department").
": ".$this->
getDepartment().
"\n");
4240 $body .= ($language->txt(
"street").
": ".$this->
getStreet().
"\n");
4244 $body .= ($language->txt(
"city").
": ".$this->
getCity().
"\n");
4248 $body .= ($language->txt(
"zipcode").
": ".$this->
getZipcode().
"\n");
4252 $body .= ($language->txt(
"country").
": ".$this->
getCountry().
"\n");
4260 $body .= ($language->txt(
"phone_office").
": ".$this->
getPhoneOffice().
"\n");
4264 $body .= ($language->txt(
"phone_home").
": ".$this->
getPhoneHome().
"\n");
4268 $body .= ($language->txt(
"phone_mobile").
": ".$this->
getPhoneMobile().
"\n");
4270 if(strlen($this->
getFax()))
4272 $body .= ($language->txt(
"fax").
": ".$this->
getFax().
"\n");
4276 $body .= ($language->txt(
"email").
": ".$this->
getEmail().
"\n");
4280 $body .= ($language->txt(
"hobby").
": ".$this->
getHobby().
"\n");
4284 $body .= ($language->txt(
"referral_comment").
": ".$this->
getComment().
"\n");
4288 $body .= ($language->txt(
"matriculation").
": ".$this->
getMatriculation().
"\n");
4297 $body .= ($language->txt(
"create_date").
": ".$date.
"\n");
4300 foreach($rbacreview->getGlobalRoles() as $role)
4302 if($rbacreview->isAssigned($this->getId(),$role))
4309 $body .= ($language->txt(
'reg_role_info').
': '.implode(
',',$gr).
"\n");
4315 $body .= ($language->txt(
'time_limit').
": ".$language->txt(
'crs_unlimited').
"\n");
4328 $body .= $language->txt(
'time_limit').
': '.$start->get(
IL_CAL_DATETIME);
4329 $body .= $language->txt(
'time_limit').
': '.$end->get(
IL_CAL_DATETIME);
4332 #$body .= $language->txt('time_limit').': '.$period;
4341 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
4348 foreach($user_defined_fields->getDefinitions() as $field_id => $definition)
4355 $data = preg_replace(
'/<br(\s*)?\/?>/i',
"\n", $data);
4356 $data = strip_tags($data);
4359 $body .= $definition[
'field_name'].
': '. $data .
"\n";
4368 $var =
"im_".$a_im_type;
4369 $this->$var = $a_im_id;
4374 $var =
"im_".$a_im_type;
4380 $this->delicious = $a_delicious;
4397 $set = $ilDB->queryF(
"SELECT feed_hash from usr_data WHERE usr_id = %s",
4398 array(
"integer"), array($a_user_id));
4399 if ($rec = $ilDB->fetchAssoc($set))
4401 if (strlen($rec[
"feed_hash"]) == 32)
4403 return $rec[
"feed_hash"];
4407 $hash = md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4408 $ilDB->manipulateF(
"UPDATE usr_data SET feed_hash = %s".
4409 " WHERE usr_id = %s",
4410 array(
"text",
"integer"),
4411 array($hash, $a_user_id));
4446 ($a_password==
"") ?
"" : md5($a_password));
4462 $q =
"SELECT DISTINCT login, usr_id FROM usr_data ".
4465 $values[] = $a_login;
4467 if ($a_user_id != 0)
4469 $q.=
" AND usr_id != %s ";
4470 $types[] =
"integer";
4471 $values[] = $a_user_id;
4474 $r = $ilDB->queryF($q, $types, $values);
4476 if (
$row = $ilDB->fetchAssoc($r))
4478 return $row[
'usr_id'];
4497 $res = $ilDB->queryF(
"SELECT * FROM usr_data ".
4498 "WHERE ext_account = %s AND auth_mode = %s",
4499 array(
"text",
"text"),
4500 array($a_external_account, $a_auth_mode));
4501 return $ilDB->fetchAssoc(
$res) ?
true :
false;
4512 global
$ilDB, $rbacreview;
4515 $ids = $rbacreview->assignedUsers($role_id);
4517 if (count ($ids) == 0)
4522 $query =
"SELECT usr_data.*, usr_pref.value AS language
4524 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4525 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4526 $values[] =
"language";
4532 $query .=
" AND usr_data.active = %s";
4534 $types[] =
"integer";
4537 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4539 $r = $ilDB->queryF(
$query, $types, $values);
4541 while (
$row = $ilDB->fetchAssoc($r))
4557 $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 ";
4559 $values[] =
"language";
4563 $query .=
" AND usr_data.active = %s";
4565 $types[] =
"integer";
4570 $query.=
" AND usr_data.time_limit_owner = %s";
4572 $types[] =
"integer";
4575 $query .=
" AND usr_data.usr_id != %s ";
4576 $values[] = ANONYMOUS_USER_ID;
4577 $types[] =
"integer";
4579 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4585 array_push($data,
$row);
4610 global $rbacadmin, $rbacreview,
$ilDB;
4614 foreach ($a_mem_ids as $mem_id) {
4615 $ids [] = $ilDB->quote($mem_id);
4618 $query =
"SELECT usr_data.*, usr_pref.value AS language
4620 LEFT JOIN usr_pref ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4621 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer").
"
4622 AND usr_data.usr_id != %s";
4623 $values[] =
"language";
4625 $values[] = ANONYMOUS_USER_ID;
4626 $types[] =
"integer";
4630 $query .=
" AND active = %s";
4632 $types[] =
"integer";
4637 $query.=
" AND usr_data.time_limit_owner = %s";
4638 $values[] = $timelimitowner;
4639 $types[] =
"integer";
4643 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4651 return $mem_arr ? $mem_arr : array();
4665 if (is_array($a_internalids)) {
4666 foreach ($a_internalids as $internalid) {
4667 if (is_numeric ($internalid))
4669 $ids[] = $internalid;
4674 if (is_numeric($parsedid) && $parsedid > 0)
4681 if (count($ids) == 0)
4684 $query =
"SELECT usr_data.*, usr_pref.value AS language
4687 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = %s
4688 WHERE ".$ilDB->in(
"usr_data.usr_id", $ids,
false,
"integer");
4689 $values[] =
"language";
4692 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
4715 $r = $ilDB->queryF(
"SELECT * FROM usr_pref WHERE usr_id = %s",
4716 array(
"integer"), array($user_id));
4718 while(
$row = $ilDB->fetchAssoc($r))
4731 $query =
"UPDATE usr_data SET login_attempts = 0 WHERE usr_id = %s";
4732 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4734 if($affected)
return true;
4742 $query =
"SELECT login_attempts FROM usr_data WHERE usr_id = %s";
4743 $result = $ilDB->queryF(
$query, array(
'integer'), array($a_usr_id) );
4744 $record = $ilDB->fetchAssoc(
$result );
4754 $query =
"UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s";
4755 $affected = $ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4757 if($affected)
return true;
4765 $query =
"UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s";
4766 $affected = $ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array(
ilUtil::now(), $a_usr_id) );
4768 if($affected)
return true;
4778 return in_array($this->
getPref(
"public_profile"), array(
"y",
"g"));
4801 $res = $ilDB->queryF(
'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4802 array(
'integer',
'text',
'integer'),
4805 if( $ilDB->numRows(
$res) == 0 )
4807 $ilDB->manipulateF(
'
4808 INSERT INTO loginname_history
4809 (usr_id, login, history_date)
4810 VALUES (%s, %s, %s)',
4811 array(
'integer',
'text',
'integer'),
4825 public static function _getUsersOnline($a_user_id = 0, $a_no_anonymous =
false)
4833 $atime = $pd_set->get(
'user_activity_time') * 60;
4840 $where[] =
'user_id > 0';
4842 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
4843 if(ilTermsOfServiceHelper::isEnabled())
4845 $where[] =
'(agree_date IS NOT NULL OR user_id = ' . $ilDB->quote(SYSTEM_USER_ID,
'integer') .
')';
4850 $where[] =
'user_id = ' . $ilDB->quote($a_user_id,
'integer');
4855 $where[] =
'user_id != ' . $ilDB->quote(ANONYMOUS_USER_ID,
'integer');
4858 include_once
'Services/User/classes/class.ilUserAccountSettings.php';
4861 include_once
'Services/User/classes/class.ilUserFilter.php';
4865 $where[] =
'expires > ' . $ilDB->quote($ctime,
'integer');
4866 $where[] =
'(p.value IS NULL OR NOT p.value = ' . $ilDB->quote(
'y',
'text') .
')';
4868 $where =
'WHERE ' . implode(
' AND ', $where);
4870 $r = $ilDB->queryF(
"
4871 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime
4873 LEFT JOIN usr_data u
4874 ON user_id = u.usr_id
4875 LEFT JOIN usr_pref p
4876 ON (p.usr_id = u.usr_id AND p.keyword = %s)
4878 GROUP BY user_id, firstname, lastname, title, login, last_login
4879 ORDER BY lastname, firstname
4882 array(
'hide_own_online_status')
4886 while($user = $ilDB->fetchAssoc($r))
4888 if($atime <= 0 || $user[
'ctime'] + $atime > $ctime)
4890 $users[$user[
'user_id']] = $user;
4910 $atime = $pd_set->get(
"user_activity_time") * 60;
4912 $no_anonym = ($a_no_anonymous)
4913 ?
"AND user_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
" "
4920 $q =
"SELECT DISTINCT dat.obj_id as obj_id ".
4922 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4923 "JOIN object_reference r1 ON r1.ref_id = fa.parent ".
4924 "JOIN tree ON tree.child = r1.ref_id ".
4925 "JOIN object_reference r2 ON r2.ref_id = tree.child ".
4926 "JOIN object_data dat ON dat.obj_id = r2.obj_id ".
4927 "WHERE ua.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4928 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4929 "AND dat.type IN (".$ilDB->quote(
"crs",
"text").
",".
4930 $ilDB->quote(
"grp",
"text").
")";
4931 $r = $ilDB->query($q);
4933 while (
$row = $ilDB->fetchAssoc($r))
4935 $groups_and_courses_of_user[] =
$row[
"obj_id"];
4938 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
4939 $tos_condition =
'';
4940 if(ilTermsOfServiceHelper::isEnabled())
4942 $tos_condition =
" AND (agree_date IS NOT NULL OR ud.usr_id = " . $ilDB->quote(SYSTEM_USER_ID,
'integer') .
") ";
4946 if (count($groups_and_courses_of_user) == 0)
4948 $q =
"SELECT count(user_id) as num,ctime,user_id,firstname,lastname,title,login,last_login ".
4949 "FROM usr_session ".
4950 "JOIN usr_data ud ON user_id = ud.usr_id ".
4951 "WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
" ".
4954 "AND expires > ".$ilDB->quote(time(),
"integer").
" ".
4955 "GROUP BY user_id,ctime,firstname,lastname,title,login,last_login";
4956 $r = $ilDB->query($q);
4960 $q =
"SELECT count(user_id) as num,s.ctime,s.user_id,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4961 "FROM usr_session s ".
4962 "JOIN usr_data ud ON ud.usr_id = s.user_id ".
4963 "JOIN rbac_ua ua ON ua.usr_id = s.user_id ".
4964 "JOIN rbac_fa fa ON fa.rol_id = ua.rol_id ".
4965 "JOIN tree ON tree.child = fa.parent ".
4966 "JOIN object_reference or1 ON or1.ref_id = tree.child ".
4967 "JOIN object_data od ON od.obj_id = or1.obj_id ".
4968 "LEFT JOIN usr_pref p ON (p.usr_id = ud.usr_id AND p.keyword = ".
4969 $ilDB->quote(
"hide_own_online_status",
"text").
") ".
4970 "WHERE s.user_id != 0 ".
4972 "AND (p.value IS NULL OR NOT p.value = ".$ilDB->quote(
"y",
"text").
") ".
4973 "AND s.expires > ".$ilDB->quote(time(),
"integer").
" ".
4974 "AND fa.assign = ".$ilDB->quote(
"y",
"text").
" ".
4976 "AND ".$ilDB->in(
"od.obj_id", $groups_and_courses_of_user,
false,
"integer").
" ".
4977 "GROUP BY s.user_id,s.ctime,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
4978 "ORDER BY ud.lastname, ud.firstname";
4979 $r = $ilDB->query($q);
4982 while ($user = $ilDB->fetchAssoc($r))
4985 || $user[
"ctime"] + $atime > $ctime)
4987 $users[$user[
"user_id"]] = $user;
4991 return $users ? $users : array();
5008 $hashcode = substr(md5(uniqid(rand(),
true)), 0, 16);
5010 $res = $ilDB->queryf(
'
5011 SELECT COUNT(usr_id) cnt FROM usr_data
5012 WHERE reg_hash = %s',
5017 if(
$row->cnt > 0) $continue =
true;
5021 if($continue)
continue;
5023 $ilDB->manipulateF(
'
5027 array(
'text',
'integer'),
5028 array($hashcode, (
int)$a_usr_id)
5050 $res = $ilDB->queryf(
'
5051 SELECT usr_id, create_date FROM usr_data
5052 WHERE reg_hash = %s',
5055 while(
$row = $ilDB->fetchAssoc(
$res))
5057 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
5060 if((
int)$oRegSettigs->getRegistrationHashLifetime() != 0 &&
5061 time() - (int)$oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row[
'create_date']))
5063 require_once
'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
5067 $ilDB->manipulateF(
'
5071 array(
'text',
'integer'),
5072 array(
'', (
int)
$row[
'usr_id'])
5075 return (
int)$row[
'usr_id'];
5078 require_once
'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
5084 if (strlen($a_birthday))
5091 $this->birthday = null;
5110 if( !(
int)$period )
throw new ilException(
'no valid period given');
5114 $date = date(
'Y-m-d H:i:s', (time() - ((
int)$period * 24 * 60 * 60)) );
5116 $query =
"SELECT usr_id FROM usr_data WHERE last_login < %s";
5118 $res = $ilDB->queryF(
$query, array(
'timestamp'), array($date));
5123 $ids[] =
$row->usr_id;
5140 $field =
'inactivation_date';
5143 if( !(
int)$period )
throw new ilException(
'no valid period given');
5147 $date = date(
'Y-m-d H:i:s', (time() - ((
int)$period * 24 * 60 * 60)) );
5149 $query =
"SELECT usr_id FROM usr_data WHERE $field < %s AND active = %s";
5151 $res = $ilDB->queryF(
$query, array(
'timestamp',
'integer'), array($date, 0));
5156 $ids[] =
$row->usr_id;
5173 if($a_last_login !== null) $last_login = $a_last_login;
5174 else $last_login = date(
'Y-m-d H:i:s');
5178 $query =
"UPDATE usr_data SET last_login = %s WHERE usr_id = %s";
5179 $affected = $ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array($last_login, $a_usr_id) );
5181 if($affected)
return $last_login;
5189 $query =
"UPDATE object_data SET owner = 0 ".
5190 "WHERE owner = ".$ilDB->quote($this->
getId(),
'integer');
5207 $q =
"SELECT DISTINCT ".$ilDB->upper($ilDB->substr(
"lastname", 1, 1)).
" let".
5209 " WHERE usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer").
5211 $let_set = $ilDB->query($q);
5214 while ($let_rec = $ilDB->fetchAssoc($let_set))
5216 $let[$let_rec[
"let"]] = $let_rec[
"let"];
5226 $query =
'SELECT count(*) num FROM object_data od '.
5227 'JOIN usr_data ud ON obj_id = usr_id '.
5228 'WHERE '.$ilDB->in(
'obj_id',$a_usr_ids,
false,
'integer').
' ';
5231 return $num_rows == count((array) $a_usr_ids);
5240 return (
boolean)
$_SESSION[
"user_captcha_verified"];
5250 $_SESSION[
"user_captcha_verified"] = $a_val;
5261 include_once(
"./Services/Export/classes/class.ilExport.php");
5266 $exp->exportEntity(
"personal_data", $this->
getId(),
"4.5.0",
5267 "Services/User",
$title, $dir);
5278 include_once(
"./Services/Export/classes/class.ilExport.php");
5286 if (is_int(strpos($entry[
"entry"],
".zip")))
5288 return $entry[
"entry"];
5303 include_once(
"./Services/Export/classes/class.ilExport.php");
5305 "/".$this->getPersonalDataExportFile();
5319 $a_bookmarks, $a_notes, $a_calendar)
5321 include_once(
"./Services/Export/classes/class.ilImport.php");
5323 if (!$a_profile_data)
5325 $imp->addSkipEntity(
"Services/User",
"usr_profile");
5329 $imp->addSkipEntity(
"Services/User",
"usr_setting");
5333 $imp->addSkipEntity(
"Services/Bookmarks",
"bookmarks");
5337 $imp->addSkipEntity(
"Services/Notes",
"user_notes");
5341 $imp->addSkipEntity(
"Services/Calendar",
"calendar");
5343 $imp->importEntity($a_file[
"tmp_name"], $a_file[
"name"],
"personal_data",
5356 $NOW = $ilDB->now();
5358 $usrId_IN_usrIds = $ilDB->in(
'usr_id', $usrIds,
false,
'integer');
5362 SET inactivation_date = $NOW
5363 WHERE inactivation_date IS NULL
5364 AND $usrId_IN_usrIds
5367 $ilDB->manipulate($queryString);
5379 $usrId_IN_usrIds = $ilDB->in(
'usr_id', $usrIds,
false,
'integer');
5383 SET inactivation_date = NULL
5384 WHERE $usrId_IN_usrIds
5387 $ilDB->manipulate($queryString);
5413 public function hasToAcceptTermsOfService()
5420 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5423 ilTermsOfServiceHelper::isEnabled() &&
5424 null == $this->agree_date &&
5425 'root' != $this->agree_date &&
5426 !in_array($this->
getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID)) &&
5427 !$rbacreview->isAssigned($this->getId(), SYSTEM_ROLE_ID)
5440 public static function hasUserToAcceptTermsOfService($a_username)
5447 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5449 if(!ilTermsOfServiceHelper::isEnabled())
5454 $in = $ilDB->in(
'usr_id', array(ANONYMOUS_USER_ID, SYSTEM_USER_ID),
true,
'integer');
5455 $res = $ilDB->queryF(
5456 "SELECT usr_id FROM usr_data WHERE login = %s AND agree_date IS NULL $in",
5460 return $ilDB->fetchAssoc(
$res) ?
true :
false;
5469 if(null === $status)
5474 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5475 if(ilTermsOfServiceHelper::isEnabled())
5486 return $this->
getId() == ANONYMOUS_USER_ID;
5501 return (
bool)$this->
getPref(
"delete_flag");
5509 $this->is_self_registered = (bool) $status;
5529 $this->interests_general = $value;
5559 $this->interests_help_offered = $value;
5589 $this->interests_help_looking = $value;
5620 $current = $this->$a_attr;
5621 if(is_array($current) &&
sizeof($current))
5623 return implode(
", ", $current);
5639 $set = $ilDB->query(
"SELECT field_id,value".
5640 " FROM usr_data_multi".
5641 " WHERE usr_id = ".$ilDB->quote($this->getId(),
"integer").
5643 while(
$row = $ilDB->fetchAssoc($set))
5645 $values[
$row[
"field_id"]][] = $row[
"value"];
5648 if(isset($values[
"interests_general"]))
5656 if(isset($values[
"interests_help_offered"]))
5664 if(isset($values[
"interests_help_looking"]))
5699 foreach($map as
$id => $values)
5701 if(is_array($values) &&
sizeof($values))
5703 foreach($values as $value)
5705 $value = trim($value);
5708 $ilDB->manipulate(
"INSERT usr_data_multi".
5709 " (usr_id,field_id,value) VALUES".
5710 " (".$ilDB->quote($this->getId(),
"integer").
5711 ",".$ilDB->quote(
$id,
"text").
5712 ",".$ilDB->quote($value,
"text").
5732 $ilDB->manipulate(
"DELETE FROM usr_data_multi".
5733 " WHERE usr_id = ".$ilDB->quote($this->getId(),
"integer"));
5736 public static function findInterests($a_term, $a_user_id = null, $a_field_id = null)
5742 $sql =
"SELECT DISTINCT(value)".
5743 " FROM usr_data_multi".
5744 " WHERE ".$ilDB->like(
"value",
"text",
"%".$a_term.
"%");
5747 $sql .=
" AND field_id = ".$ilDB->quote($a_field_id,
"text");
5751 $sql .=
" AND usr_id <> ".$ilDB->quote($a_user_id,
"integer");
5753 $sql .=
" ORDER BY value";
5754 $set = $ilDB->query($sql);
5755 while(
$row = $ilDB->fetchAssoc($set))