4define (
"IL_PASSWD_PLAIN",
"plain");
5define (
"IL_PASSWD_CRYPTED",
"crypted");
8require_once
"./Services/Object/classes/class.ilObject.php";
9require_once
'./Services/User/exceptions/class.ilUserException.php';
175 public function __construct($a_user_id = 0, $a_call_by_reference =
false)
184 parent::__construct($a_user_id, $a_call_by_reference);
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");
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';
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';
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)));
670 parent::updateOwner();
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 static 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));
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));
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));
828 if (!is_array($a_user_str))
830 $res =
$ilDB->queryF(
"SELECT usr_id FROM usr_data WHERE login = %s",
831 array(
"text"), array($a_user_str));
833 return $user_rec[
"usr_id"];
837 $set =
$ilDB->query(
"SELECT usr_id FROM usr_data ".
838 " WHERE ".
$ilDB->in(
"login", $a_user_str,
false,
"text")
841 while ($rec =
$ilDB->fetchAssoc($set))
843 $ids[] = $rec[
"usr_id"];
867 $ilDB->manipulateF(
"UPDATE usr_data SET ".
868 "last_login = ".
$ilDB->now().
869 " WHERE usr_id = %s",
870 array(
"integer"), array($this->
id));
878 public function replacePassword($md5_encoded_password)
890 SET passwd = %s, passwd_enc_type = %s
892 array(
'text',
'text',
'integer'),
906 public function resetPassword($raw, $raw_retype)
913 if(func_num_args() != 2)
918 if(!isset($raw) || !isset($raw_retype))
923 if($raw != $raw_retype)
928 require_once
'Services/User/classes/class.ilUserPasswordManager.php';
933 SET passwd = %s, passwd_enc_type = %s, passwd_salt = %s
935 array(
'text',
'text',
'text',
'integer'),
957 SELECT * FROM loginname_history
959 array(
'text'), array($a_login));
961 return $ilDB->fetchAssoc(
$res) ? true :
false;
980 $ilDB->setLimit(1, 0);
982 SELECT login, history_date FROM loginname_history
983 WHERE usr_id = %s ORDER BY history_date DESC',
984 array(
'integer'), array($a_usr_id));
1004 if(func_num_args() != 1)
1009 if(!isset($a_login))
1017 if(0 == strcmp($a_login, $former_login))
1029 if((
int)
$ilSetting->get(
'allow_change_loginname') &&
1030 (
int)
$ilSetting->get(
'reuse_of_loginnames') == 0 &&
1031 self::_doesLoginnameExistInHistory($a_login))
1033 throw new ilUserException($this->lng->txt(
'loginname_already_exists'));
1035 else if((
int)
$ilSetting->get(
'allow_change_loginname') &&
1036 (
int)
$ilSetting->get(
'loginname_change_blocking_time') &&
1037 is_array($last_history_entry) &&
1038 $last_history_entry[1] + (
int)
$ilSetting->get(
'loginname_change_blocking_time') > time())
1040 include_once
'Services/Calendar/classes/class.ilDate.php';
1043 $this->lng->txt(
'changing_loginname_not_possible_info'),
1054 if((
int)
$ilSetting->get(
'allow_change_loginname') &&
1055 (
int)
$ilSetting->get(
'create_history_loginname'))
1061 $this->login = $a_login;
1063 $ilDB->manipulateF(
'
1067 array(
'text',
'integer'), array($this->
getLogin(), $this->
getId()));
1082 $this->
setPref($a_keyword, $a_value);
1093 self::_deletePref($this->
getId(), $a_keyword);
1101 public static function _deletePref($a_user_id, $a_keyword)
1109 'DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s',
1110 array(
'integer',
'text'),
1111 array($a_user_id, $a_keyword)
1124 $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s",
1125 array(
"integer"), array($a_user_id));
1134 public static function _writePref($a_usr_id, $a_keyword, $a_value)
1137 $ilDB->replace(
"usr_pref",
1139 "usr_id" => array(
"integer", $a_usr_id),
1140 "keyword" => array(
"text", $a_keyword),
1143 "value" => array(
"text",$a_value)
1168 foreach ($this->prefs as $keyword => $value)
1188 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1190 return $settings->getDefaultTimeZone();
1202 if($format = $this->
getPref(
'time_format'))
1208 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1210 return $settings->getDefaultTimeFormat();
1222 if($format = $this->
getPref(
'date_format'))
1228 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
1230 return $settings->getDefaultDateFormat();
1242 if ($a_keyword !=
"")
1244 $this->prefs[$a_keyword] = $a_value;
1255 if (array_key_exists($a_keyword, $this->prefs))
1257 return $this->prefs[$a_keyword];
1269 $query =
"SELECT * FROM usr_pref WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
" ".
1270 "AND keyword = ".$ilDB->quote($a_keyword,
"text");
1288 if (is_array($this->prefs))
1303 global $rbacadmin,
$ilDB;
1306 include_once(
'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1308 $mapping->deleteUser($this->
getId());
1311 include_once (
"Services/Mail/classes/class.ilMailbox.php");
1314 $mailbox->updateMailsOfDeletedUser($this->
getLogin());
1317 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1319 $costum_block->setContextObjId($this->
getId());
1320 $costum_block->setContextObjType(
"user");
1321 $c_blocks = $costum_block->queryBlocksForContext();
1322 include_once(
"./Services/Feeds/classes/class.ilPDExternalFeedBlock.php");
1323 foreach($c_blocks as $c_block)
1325 if ($c_block[
"type"] ==
"pdfeed")
1334 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1338 $ilDB->manipulateF(
"DELETE FROM usr_data WHERE usr_id = %s",
1339 array(
"integer"), array($this->
getId()));
1349 include_once(
"./Services/Authentication/classes/class.ilSession.php");
1353 $rbacadmin->removeUser($this->
getId());
1357 $q =
"DELETE FROM bookmark_tree WHERE tree = ".
1359 $ilDB->manipulate($q);
1361 $q =
"DELETE FROM bookmark_data WHERE user_id = ".
1363 $ilDB->manipulate($q);
1366 include_once
'./Modules/Forum/classes/class.ilObjForum.php';
1367 ilObjForum::_deleteUser($this->
getId());
1370 include_once
'./Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1374 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1378 include_once
'./Services/Tracking/classes/class.ilObjUserTracking.php';
1381 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
1385 include_once
'Modules/Scorm2004/classes/ilSCORM13Package.php';
1389 include_once
'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
1393 include_once
"./Services/Notification/classes/class.ilNotification.php";
1397 include_once
"./Modules/Portfolio/classes/class.ilObjPortfolio.php";
1401 include_once
"./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1403 $tree->cascadingDelete();
1406 include_once
"./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1410 require_once
'Services/User/classes/class.ilCronDeleteInactiveUserReminderMail.php';
1423 global $ilAppEventHandler;
1424 $ilAppEventHandler->raise(
1425 'Services/User',
'deleteUser', array(
'usr_id' => $this->
getId())
1442 function setFullname($a_title =
"",$a_firstname =
"",$a_lastname =
"")
1444 $this->fullname =
"";
1450 elseif ($this->utitle)
1452 $this->fullname = $this->utitle.
" ";
1459 elseif ($this->firstname)
1461 $this->fullname .= $this->firstname.
" ";
1493 if (strlen($this->fullname) <= $a_max_strlen)
1498 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
1500 return ilUtil::stripSlashes($this->utitle.
" ".substr($this->firstname,0,1).
". ".$this->lastname);
1503 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
1508 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
1523 $this->login = $a_str;
1542 $this->passwd = $a_str;
1543 $this->passwd_type = $a_type;
1575 $this->gender = substr($a_str,-1);
1596 $this->utitle = $a_str;
1617 $this->firstname = $a_str;
1636 $this->lastname = $a_str;
1655 $this->institution = $a_str;
1674 $this->department = $a_str;
1693 $this->street = $a_str;
1712 $this->city = $a_str;
1731 $this->zipcode = $a_str;
1751 $this->country = $a_str;
1771 $this->sel_country = $a_val;
1791 $this->phone_office = $a_str;
1810 $this->phone_home = $a_str;
1829 $this->phone_mobile = $a_str;
1848 $this->fax = $a_str;
1867 $this->client_ip = $a_str;
1886 $this->matriculation = $a_str;
1908 $query =
"SELECT matriculation FROM usr_data ".
1909 "WHERE usr_id = ".$ilDB->quote($a_usr_id);
1912 return $row->matriculation ?
$row->matriculation :
'';
1922 $this->email = $a_str;
1941 $this->hobby = $a_str;
1960 $this->
setPref(
"language",$a_str);
1971 return $this->prefs[
"language"];
1984 $this->
setPref(
"disk_quota",$a_disk_quota);
1998 return $this->prefs[
"disk_quota"] ? $this->prefs[
"disk_quota"] : 0;
2003 return $this->prefs[
"wsp_disk_quota"] ? $this->prefs[
"wsp_disk_quota"] : 0;
2008 $this->last_password_change_ts = $a_last_password_change_ts;
2021 $q =
"SELECT value FROM usr_pref WHERE usr_id= ".
2022 $ilDB->quote($a_usr_id,
"integer").
" AND keyword = ".
2023 $ilDB->quote(
'language',
"text");
2028 return $row[
'value'];
2037 $ilDB->manipulateF(
"UPDATE usr_data ".
2038 " SET ext_account = %s WHERE usr_id = %s",
2039 array(
"text",
"integer"),
2040 array($a_ext_id, $a_usr_id));
2047 $ilDB->manipulateF(
"UPDATE usr_data ".
2048 " SET auth_mode = %s WHERE usr_id = %s",
2049 array(
"text",
"integer"),
2050 array($a_auth_mode, $a_usr_id));
2079 $this->last_login = $a_str;
2089 return $this->last_login;
2099 $this->last_update = $a_str;
2113 $this->referral_comment = $a_str;
2133 $this->approve_date = $a_str;
2164 $this->agree_date = $a_str;
2207 $query =
'SELECT usr_id FROM usr_data '.
2208 'WHERE active = '.$ilDB->quote(1,
'integer').
' '.
2209 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer');
2239 if ((!empty($storedActive) && empty($currentActive)) ||
2240 (empty($storedActive) && !empty($currentActive)))
2255 return $active ? true :
false;
2266 $this->skin = $a_str;
2271 $this->time_limit_owner = $a_owner;
2275 return $this->time_limit_owner ? $this->time_limit_owner : 7;
2279 $this->time_limit_from = $a_from;
2283 return $this->time_limit_from ? $this->time_limit_from : time();
2287 $this->time_limit_until = $a_until;
2291 return $this->time_limit_until ? $this->time_limit_until : time();
2295 $this->time_limit_unlimited = $a_unlimited;
2299 return $this->time_limit_unlimited;
2303 return $this->time_limit_message = $a_time_limit_message;
2307 return $this->time_limit_message;
2312 $this->login_attempts = $a_login_attempts;
2335 $this->profile_incomplete = (boolean) $a_prof_inc;
2339 if($this->
id == ANONYMOUS_USER_ID)
2343 return $this->profile_incomplete;
2349 if( $this->
id == ANONYMOUS_USER_ID )
2352 if ($this->
id == SYSTEM_USER_ID) {
2353 require_once
'./Services/User/classes/class.ilUserPasswordManager.php';
2364 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2368 && $security->isPasswordChangeOnFirstLoginEnabled()
2369 && $this->getLastPasswordChangeTS() == 0
2370 && $this->is_self_registered ==
false
2380 if($this->
id == ANONYMOUS_USER_ID)
return false;
2382 require_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2386 $max_pass_age = $security->getPasswordMaxAge();
2387 if( $max_pass_age > 0 )
2389 $max_pass_age_ts = ( $max_pass_age * 86400 );
2391 $current_ts = time();
2393 if( ($current_ts - $pass_change_ts) > $max_pass_age_ts )
2402 $current_ts = time();
2404 $password_age = (int) ( ($current_ts - $pass_change_ts) / 86400 );
2405 return $password_age;
2414 $query =
"UPDATE usr_data SET last_password_change = %s " .
2415 "WHERE usr_id = %s";
2417 array(
'integer',
'integer'),
2419 if($affected)
return true;
2427 $query =
"UPDATE usr_data SET last_password_change = 0 " .
2428 "WHERE usr_id = %s";
2429 $affected =
$ilDB->manipulateF(
$query, array(
'integer'),
2430 array($this->
getId()) );
2431 if($affected)
return true;
2442 $this->latitude = $a_latitude;
2462 $this->longitude = $a_longitude;
2482 $this->loc_zoom = $a_locationzoom;
2497 $this->applied_users = array();
2500 return $this->applied_users ? $this->applied_users : array();
2505 if($a_usr_id == $this->
getId())
2510 $this->applied_users = array();
2513 return in_array($a_usr_id,$this->applied_users);
2520 $res =
$ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2521 "WHERE time_limit_owner = %s",
2523 array($a_parent_id));
2526 $this->applied_users[] =
$row->usr_id;
2543 $set =
$ilDB->queryf(
'
2544 SELECT COUNT(*) session_count
2545 FROM usr_session WHERE user_id = %s AND expires > %s',
2546 array(
'integer',
'integer'),
2547 array($a_user_id, time()));
2549 return (
bool)
$row[
'session_count'];
2576 require_once (
'Services/WebDAV/classes/class.ilDAVActivationChecker.php');
2579 require_once (
'Services/WebDAV/classes/class.ilDAVServer.php');
2580 require_once (
'Services/Database/classes/class.ilAuthContainerMDB2.php');
2585 $login =$ilAuth->getUsername();
2598 global
$ilDB,$ilAuth;
2601 $set =
$ilDB->queryF(
"SELECT active FROM usr_data WHERE login= %s",
2605 if ($rec =
$ilDB->fetchAssoc($set))
2641 $res =
$ilDB->queryF(
"SELECT login FROM usr_data ".
2642 "WHERE email = %s and active = 1",
2648 $ids[] =
$row->login;
2668 $res =
$ilDB->queryF(
"SELECT usr_id FROM usr_data ".
2669 "WHERE email = %s", array(
"text"), array($a_email));
2672 return $row->usr_id ?
$row->usr_id : 0;
2699 static function searchUsers($a_search_str,
$active = 1, $a_return_ids_only =
false, $filter_settings = FALSE)
2704 $query =
"SELECT usr_data.usr_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.email, usr_data.active FROM usr_data ";
2706 $without_anonymous_users =
true;
2709 $join_filter =
" WHERE ";
2710 if ($filter_settings !== FALSE && strlen($filter_settings))
2712 switch ($filter_settings)
2716 $join_filter =
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.usr_id IS NULL AND ";
2723 $join_filter =
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id WHERE obj_members.obj_id = ".
2724 "(SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") AND ";
2732 $local_roles = $rbacreview->getRolesOfRoleFolder(
$ref_id,
false);
2733 if (is_array($local_roles) && count($local_roles))
2735 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2736 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false, $local_roles).
" AND ";
2742 $rol_id =
$_SESSION[
"user_filter_data"];
2745 $join_filter =
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2746 $ilDB->quote($rol_id,
"integer").
" AND ";
2747 $without_anonymous_users =
false;
2754 if (strtolower(substr($a_search_str, 0, 5)) ==
"role:")
2756 $query =
"SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
2757 "FROM object_data,rbac_ua,usr_data ".
2758 "WHERE ".$ilDB->like(
"object_data.title",
"text",
"%".substr($a_search_str,5).
"%").
2759 " AND object_data.type = 'role' ".
2760 "AND rbac_ua.rol_id = object_data.obj_id ".
2761 "AND usr_data.usr_id = rbac_ua.usr_id ".
2762 "AND rbac_ua.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2767 "(".$ilDB->like(
"usr_data.login",
"text",
"%".$a_search_str.
"%").
" ".
2768 "OR ".$ilDB->like(
"usr_data.firstname",
"text",
"%".$a_search_str.
"%").
" ".
2769 "OR ".$ilDB->like(
"usr_data.lastname",
"text",
"%".$a_search_str.
"%").
" ".
2770 "OR ".$ilDB->like(
"usr_data.email",
"text",
"%".$a_search_str.
"%").
") ";
2772 if ($filter_settings !== FALSE && strlen($filter_settings))
2774 switch ($filter_settings)
2777 $query.=
" AND usr_data.active = ".$ilDB->quote(0,
"integer").
" ";
2780 $query.=
" AND usr_data.active = ".$ilDB->quote(1,
"integer").
" ";
2783 $query.=
" AND usr_data.time_limit_unlimited = ".$ilDB->quote(0,
"integer").
" ";
2786 $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"]));
2787 $query.=
" AND last_login < ".$ilDB->quote($date,
"timestamp").
" ";
2792 if ($without_anonymous_users)
2794 $query.=
"AND usr_data.usr_id != ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
2797 if (is_numeric(
$active) &&
$active > -1 && $filter_settings === FALSE)
2799 $query.=
" AND active = ".$ilDB->quote(
$active,
"integer").
" ";
2808 "usr_id" =>
$row->usr_id,
2809 "login" =>
$row->login,
2810 "firstname" =>
$row->firstname,
2811 "lastname" =>
$row->lastname,
2812 "email" =>
$row->email,
2813 "active" =>
$row->active);
2814 $ids[] =
$row->usr_id;
2816 if ($a_return_ids_only)
2817 return $ids ? $ids : array();
2819 return $users ? $users : array();
2834 $res =
$ilDB->query(
"SELECT login FROM usr_data");
2837 $logins[] =
$row->login;
2839 return $logins ? $logins : array();
2853 $res =
$ilDB->query(
"SELECT * FROM usr_data WHERE ".
2854 $ilDB->in(
"usr_id", $a_user_ids,
false,
"integer"));
2857 $user_data[
"$row[usr_id]"] =
$row;
2859 return $user_data ? $user_data : array();
2874 $result_arr = array();
2878 if ($a_fields !== NULL and is_array($a_fields))
2880 if (count($a_fields) == 0)
2886 if (($usr_id_field = array_search(
"usr_id",$a_fields)) !==
false)
2887 unset($a_fields[$usr_id_field]);
2889 $select = implode(
",",$a_fields).
",usr_data.usr_id";
2891 if(in_array(
'online_time',$a_fields))
2893 $select .=
",ut_online.online_time ";
2897 $q =
"SELECT ".$select.
" FROM usr_data ";
2901 if(in_array(
'online_time',$a_fields))
2903 $q .=
"LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
2910 $q .=
"WHERE active = ".$ilDB->quote(
$active,
"integer");
2913 $q .=
"WHERE time_limit_unlimited= ".$ilDB->quote(0,
"integer");;
2916 $qtemp = $q .
", rbac_ua, object_data WHERE rbac_ua.rol_id = object_data.obj_id AND ".
2917 $ilDB->like(
"object_data.title",
"text",
"%crs%").
" AND usr_data.usr_id = rbac_ua.usr_id";
2919 $course_users = array();
2922 array_push($course_users,
$row[
"usr_id"]);
2924 if (count($course_users))
2926 $q .=
" WHERE ".$ilDB->in(
"usr_data.usr_id", $course_users,
true,
"integer").
" ";
2934 $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"]));
2935 $q.=
" AND last_login < ".$ilDB->quote($date,
"timestamp");
2941 $q .=
" LEFT JOIN obj_members ON usr_data.usr_id = obj_members.usr_id ".
2942 "WHERE obj_members.obj_id = (SELECT obj_id FROM object_reference ".
2943 "WHERE ref_id = ".$ilDB->quote(
$ref_id,
"integer").
") ";
2951 $local_roles = $rbacreview->getRolesOfRoleFolder(
$ref_id,
false);
2952 if (is_array($local_roles) && count($local_roles))
2954 $q.=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE ".
2955 $ilDB->in(
"rbac_ua.rol_id", $local_roles,
false,
"integer").
" ";
2960 $rol_id =
$_SESSION[
"user_filter_data"];
2963 $q .=
" LEFT JOIN rbac_ua ON usr_data.usr_id = rbac_ua.usr_id WHERE rbac_ua.rol_id = ".
2964 $ilDB->quote($rol_id,
"integer");
2972 $result_arr[] =
$row;
2986 $q =
"SELECT count(*) as cnt FROM usr_pref up1, usr_pref up2 ".
2987 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
2988 " AND up1.value= ".$ilDB->quote($a_style,
"text").
2989 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
2990 " AND up2.value= ".$ilDB->quote($a_skin,
"text").
2991 " AND up1.usr_id = up2.usr_id ";
2993 $cnt_set =
$ilDB->query($q);
2995 $cnt_rec =
$ilDB->fetchAssoc($cnt_set);
2997 return $cnt_rec[
"cnt"];
3007 $q =
"SELECT DISTINCT up1.value style, up2.value skin FROM usr_pref up1, usr_pref up2 ".
3008 " WHERE up1.keyword = ".$ilDB->quote(
"style",
"text").
3009 " AND up2.keyword = ".$ilDB->quote(
"skin",
"text").
3010 " AND up1.usr_id = up2.usr_id";
3012 $sty_set =
$ilDB->query($q);
3015 while($sty_rec =
$ilDB->fetchAssoc($sty_set))
3017 $styles[] = $sty_rec[
"skin"].
":".$sty_rec[
"style"];
3030 $q =
"SELECT up1.usr_id usr_id FROM usr_pref up1, usr_pref up2 ".
3031 " WHERE up1.keyword= ".$ilDB->quote(
"style",
"text").
3032 " AND up1.value= ".$ilDB->quote($a_from_style,
"text").
3033 " AND up2.keyword= ".$ilDB->quote(
"skin",
"text").
3034 " AND up2.value= ".$ilDB->quote($a_from_skin,
"text").
3035 " AND up1.usr_id = up2.usr_id ";
3037 $usr_set =
$ilDB->query($q);
3039 while ($usr_rec =
$ilDB->fetchAssoc($usr_set))
3060 $item_set =
$ilDB->queryF(
"SELECT * FROM desktop_item WHERE ".
3061 "item_id = %s AND type = %s AND user_id = %s",
3062 array(
"integer",
"text",
"integer"),
3063 array($a_item_id, $a_type, $a_usr_id));
3066 if (!
$ilDB->fetchAssoc($item_set))
3068 $ilDB->manipulateF(
"INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
3069 " (%s,%s,%s,%s)", array(
"integer",
"text",
"integer",
"text"),
3070 array($a_item_id,$a_type,$a_usr_id,$a_par));
3073 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3101 $ilDB->manipulateF(
"UPDATE desktop_item SET parameters = %s ".
3102 " WHERE item_id = %s AND type = %s AND user_id = %s",
3103 array(
"text",
"integer",
"text",
"integer"),
3104 array($a_par, $a_item_id, $a_type, $this->
getId()));
3121 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE ".
3122 " item_id = %s AND type = %s AND user_id = %s",
3123 array(
"integer",
"text",
"integer"),
3124 array($a_item_id, $a_type, $a_usr_id));
3126 include_once
'./Services/Calendar/classes/class.ilCalendarCategories.php';
3152 $r =
$ilDB->queryF(
"SELECT user_id FROM desktop_item WHERE item_id = %s",
3153 array(
"integer"), array($a_id));
3159 $users[] =
$row->user_id;
3162 if (count($users) > 0)
3164 $ilDB->manipulateF(
"DELETE FROM desktop_item WHERE item_id = %s",
3165 array(
"integer"), array($a_id));
3184 if (self::$is_desktop_item_loaded[$a_usr_id.
":".$a_item_id])
3186 return self::$is_desktop_item_cache[$a_usr_id.
":".$a_item_id.
":".$a_type];
3188 $item_set =
$ilDB->queryF(
"SELECT item_id FROM desktop_item WHERE ".
3189 "item_id = %s AND type = %s AND user_id = %s",
3190 array(
"integer",
"text",
"integer"),
3191 array($a_item_id, $a_type, $a_usr_id));
3193 if (
$ilDB->fetchAssoc($item_set))
3213 if (!is_array($a_item_ids))
3218 $item_ids = array();
3219 foreach ($a_item_ids as
$id)
3221 if (!self::$is_desktop_item_loaded[$a_usr_id.
":".
$id])
3225 self::$is_desktop_item_loaded[$a_usr_id.
":".
$id] =
true;
3228 if (count($item_ids) > 0)
3230 $item_set =
$ilDB->query(
"SELECT item_id, type FROM desktop_item WHERE ".
3231 $ilDB->in(
"item_id", $item_ids,
false,
"integer").
3232 " AND user_id = ".$ilDB->quote($a_usr_id,
"integer"));
3233 while (
$r =
$ilDB->fetchAssoc($item_set))
3235 self::$is_desktop_item_cache[$a_usr_id.
":".
$r[
"item_id"].
":".
$r[
"type"]]
3270 $is_nested_set = ($tree->getTreeImplementation() instanceof
ilNestedSetTree);
3272 $item_set =
$ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
3273 " FROM desktop_item it, object_reference oref ".
3274 ", object_data obj".
3276 "it.item_id = oref.ref_id AND ".
3277 "oref.obj_id = obj.obj_id AND ".
3278 "it.user_id = %s", array(
"integer"), array($user_id));
3279 $items = $all_parent_path = array();
3280 while ($item_rec =
$ilDB->fetchAssoc($item_set))
3282 if ($tree->isInTree($item_rec[
"ref_id"])
3283 && $item_rec[
"type"] !=
"rolf"
3284 && $item_rec[
"type"] !=
"itgr")
3286 $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
3288 if(!isset($all_parent_path[$parent_ref]))
3298 $node = $tree->getNodeData($parent_ref);
3299 $all_parent_path[$parent_ref] = $node[
"title"];
3303 $parent_path = $all_parent_path[$parent_ref];
3307 $items[$parent_path.$title.$item_rec[
"ref_id"]] =
3308 array(
"ref_id" => $item_rec[
"ref_id"],
3309 "obj_id" => $item_rec[
"obj_id"],
3310 "type" => $item_rec[
"type"],
3312 "description" =>
$desc,
3313 "parent_ref" => $parent_ref);
3321 if (!is_array($a_types))
3323 $a_types = array($a_types);
3326 $foundsurveys = array();
3327 foreach($a_types as $a_type)
3329 if ($a_type ==
"itgr")
3333 $item_set =
$ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ".
3334 ", object_data obj WHERE ".
3335 "it.item_id = oref.ref_id AND ".
3336 "oref.obj_id = obj.obj_id AND ".
3337 "it.type = %s AND ".
3340 array(
"text",
"integer"),
3341 array($a_type, $user_id));
3343 while ($item_rec =
$ilDB->fetchAssoc($item_set))
3347 $items[
$title.$a_type.$item_rec[
"ref_id"]] =
3348 array(
"ref_id" => $item_rec[
"ref_id"],
3349 "obj_id" => $item_rec[
"obj_id"],
"type" => $a_type,
3374 $a_parent = 0, $a_time = 0, $a_order_nr = 0)
3380 $a_time = date(
"Y-m-d H:i:s", time());
3383 $item_set =
$ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3384 "parent = %s AND item_id = %s AND type = %s AND user_id = %s",
3385 array(
"integer",
"integer",
"text",
"integer"),
3386 array(0, $a_item_id, $a_type, $this->
getId()));
3389 if (!
$d = $item_set->fetchRow())
3391 $ilDB->manipulateF(
"INSERT INTO personal_clipboard ".
3392 "(item_id, type, user_id, title, parent, insert_time, order_nr) VALUES ".
3393 " (%s,%s,%s,%s,%s,%s,%s)",
3394 array(
"integer",
"text",
"integer",
"text",
"integer",
"timestamp",
"integer"),
3395 array($a_item_id, $a_type, $this->
getId(), $a_title, (
int) $a_parent, $a_time, (
int) $a_order_nr));
3399 $ilDB->manipulateF(
"UPDATE personal_clipboard SET insert_time = %s ".
3400 "WHERE user_id = %s AND item_id = %s AND type = %s AND parent = 0",
3401 array(
"timestamp",
"integer",
"integer",
"text"),
3402 array($a_time, $this->
getId(), $a_item_id, $a_type));
3414 $a_time = date(
"Y-m-d H:i:s", time());
3416 $ilDB->insert(
"personal_pc_clipboard", array(
3417 "user_id" => array(
"integer", $this->
getId()),
3418 "content" => array(
"clob", $a_content),
3419 "insert_time" => array(
"timestamp", $a_time),
3420 "order_nr" => array(
"integer", $a_nr)
3431 $set =
$ilDB->queryF(
"SELECT MAX(insert_time) mtime FROM personal_pc_clipboard ".
3432 " WHERE user_id = %s", array(
"integer"), array($this->
getId()));
3433 $row = $ilDB->fetchAssoc($set);
3435 $set =
$ilDB->queryF(
"SELECT * FROM personal_pc_clipboard ".
3436 " WHERE user_id = %s AND insert_time = %s ORDER BY order_nr ASC",
3437 array(
"integer",
"timestamp"),
3442 $content[] =
$row[
"content"];
3455 $set =
$ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3456 "parent = %s AND type = %s AND user_id = %s",
3457 array(
"integer",
"text",
"integer"),
3458 array(0, $a_type, $this->
getId()));
3459 if ($rec =
$ilDB->fetchAssoc($set))
3474 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3475 "type = %s AND user_id = %s",
3476 array(
"text",
"integer"),
3477 array($a_type, $this->
getId()));
3487 $ilDB->manipulateF(
"DELETE FROM personal_clipboard WHERE ".
3488 "user_id = %s", array(
"integer"), array($this->
getId()));
3499 if ($a_top_nodes_only)
3501 $par =
" AND parent = ".$ilDB->quote(0,
"integer").
" ";
3504 $type_str = ($a_type !=
"")
3505 ?
" AND type = ".
$ilDB->quote($a_type,
"text").
" "
3507 $q =
"SELECT * FROM personal_clipboard WHERE ".
3508 "user_id = ".$ilDB->quote($this->
getId(),
"integer").
" ".
3510 " ORDER BY order_nr";
3511 $objs =
$ilDB->query($q);
3513 while ($obj =
$ilDB->fetchAssoc($objs))
3515 if ($obj[
"type"] ==
"mob")
3519 if ($obj[
"type"] ==
"incl")
3521 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
3524 $objects[] = array (
"id" => $obj[
"item_id"],
3525 "type" => $obj[
"type"],
"title" => $obj[
"title"],
3526 "insert_time" => $obj[
"insert_time"]);
3538 $objs =
$ilDB->queryF(
"SELECT * FROM personal_clipboard WHERE ".
3539 "user_id = %s AND parent = %s AND insert_time = %s ".
3540 " ORDER BY order_nr",
3541 array(
"integer",
"integer",
"timestamp"),
3542 array(
$ilUser->getId(), (
int) $a_parent, $a_insert_time));
3544 while ($obj =
$ilDB->fetchAssoc($objs))
3546 if ($obj[
"type"] ==
"mob")
3550 $objects[] = array (
"id" => $obj[
"item_id"],
3551 "type" => $obj[
"type"],
"title" => $obj[
"title"],
"insert_time" => $obj[
"insert_time"]);
3568 $q =
"SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
3569 "item_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
3570 "type = ".$ilDB->quote($a_type,
"text");
3571 $user_set =
$ilDB->query($q);
3573 while ($user_rec =
$ilDB->fetchAssoc($user_set))
3575 $users[] = $user_rec[
"user_id"];
3592 $q =
"DELETE FROM personal_clipboard WHERE ".
3593 "item_id = ".$ilDB->quote($a_item_id,
"integer").
3594 " AND type = ".$ilDB->quote($a_type,
"text").
" ".
3595 " AND user_id = ".$ilDB->quote($this->
getId(),
"integer");
3596 $ilDB->manipulate($q);
3603 $query =
"SELECT obj_id FROM object_data WHERE import_id = ".
3604 $ilDB->quote($i2_id,
"text");
3620 $this->auth_mode = $a_str;
3634 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3647 $this->ext_account = $a_str;
3659 return $this->ext_account;
3677 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
3678 $q =
"SELECT login,usr_id,ext_account,auth_mode FROM usr_data ".
3679 "WHERE auth_mode = %s";
3681 $values[] = $a_auth_mode;
3684 $q.=
" OR auth_mode = %s ";
3686 $values[] =
'default';
3689 $res =
$ilDB->queryF($q, $types, $values);
3692 if(
$row->auth_mode ==
'default')
3694 $accounts[
$row->usr_id] =
$row->login;
3698 $accounts[
$row->usr_id] =
$row->ext_account;
3701 return $accounts ? $accounts : array();
3715 if(!is_array($a_usr_ids))
3723 $q =
"UPDATE usr_data SET active = 1, inactivation_date = NULL WHERE ".
3724 $ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3725 $ilDB->manipulate($q);
3729 $usrId_IN_usrIds =
$ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer");
3731 $q =
"UPDATE usr_data SET active = 0 WHERE $usrId_IN_usrIds";
3732 $ilDB->manipulate($q);
3736 SET inactivation_date = %s
3737 WHERE inactivation_date IS NULL
3738 AND $usrId_IN_usrIds
3740 $ilDB->manipulateF($queryString, array(
'timestamp'), array(
ilUtil::now()));
3771 $r =
$ilDB->queryF(
"SELECT * FROM usr_data WHERE ".
3772 " ext_account = %s AND auth_mode = %s",
3773 array(
"text",
"text"),
3774 array($a_account, $a_auth));
3775 if ($usr =
$ilDB->fetchAssoc(
$r))
3777 return $usr[
"login"];
3781 $res =
$ilDB->queryF(
"SELECT login FROM usr_data ".
3782 "WHERE login = %s AND auth_mode = %s AND ext_account IS NULL ",
3783 array(
"text",
"text"),
3784 array($a_account, $a_auth));
3787 return $usr[
'login'];
3793 $res =
$ilDB->queryF(
"SELECT login FROM usr_data WHERE ".
3794 " ext_account = %s AND auth_mode = %s",
3795 array(
"text",
"text"),
3796 array($a_account,
"default"));
3799 return $usr[
"login"];
3802 $res =
$ilDB->queryF(
"SELECT login FROM usr_data ".
3803 "WHERE login = %s AND (ext_account IS NULL OR ext_account = '') AND auth_mode = %s",
3804 array(
"text",
"text"),
3805 array($a_account,
"default"));
3808 return $usr[
"login"];
3821 $r =
$ilDB->query(
"SELECT count(*) AS cnt, auth_mode FROM usr_data ".
3822 "GROUP BY auth_mode");
3824 while($cnt =
$ilDB->fetchAssoc(
$r))
3826 $cnt_arr[$cnt[
"auth_mode"]] = $cnt[
"cnt"];
3843 $q =
"SELECT * FROM usr_data WHERE ".
3844 " email = %s AND (auth_mode = %s ";
3845 $types = array(
"text",
"text");
3846 $values = array($a_email,
"local");
3850 $q.=
" OR auth_mode = %s";
3852 $values[] =
"default";
3858 $usr_set =
$ilDB->queryF($q, $types, $values);
3859 while ($usr_rec =
$ilDB->fetchAssoc($usr_set))
3861 $users[$usr_rec[
"usr_id"]] = $usr_rec[
"login"];
3878 $image_dir = $webspace_dir.
"/usr_images";
3879 $store_file =
"usr_".$obj_id.
".".
"jpg";
3880 $target_file = $image_dir.
"/$store_file";
3882 chmod($tmp_file, 0770);
3886 $show_file =
"$image_dir/usr_".$obj_id.
".jpg";
3887 $thumb_file =
"$image_dir/usr_".$obj_id.
"_small.jpg";
3888 $xthumb_file =
"$image_dir/usr_".$obj_id.
"_xsmall.jpg";
3889 $xxthumb_file =
"$image_dir/usr_".$obj_id.
"_xxsmall.jpg";
3913 if(isset(self::$personal_image_cache[$this->
getId()][$a_size][(
int)$a_force_pic]))
3915 return self::$personal_image_cache[$this->
getId()][$a_size][(int)$a_force_pic];
3920 return self::$personal_image_cache[$this->
getId()][$a_size][(int)$a_force_pic];
3933 $a_prevent_no_photo_image =
false)
3938 $res =
$ilDB->queryF(
"SELECT * FROM usr_pref WHERE ".
3939 "keyword IN (%s,%s) ".
3941 array(
"text",
"text",
"integer"),
3942 array(
'public_upload',
'public_profile', $a_usr_id));
3945 switch (
$row[
'keyword'])
3947 case 'public_upload' :
3948 $upload =
$row[
'value'] ==
'y';
3950 case 'public_profile' :
3951 $profile = (
$row[
'value'] ==
'y' ||
3952 $row[
'value'] ==
'g');
3959 if(defined(
'ILIAS_MODULE'))
3961 $webspace_dir = (
'.'.$webspace_dir);
3963 $webspace_dir .= (
'./'.ilUtil::getWebspaceDir());
3965 $image_dir = $webspace_dir.
"/usr_images";
3967 if ($a_size ==
'big')
3969 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
".jpg";
3973 $thumb_file = $image_dir.
"/usr_".$a_usr_id.
"_".$a_size.
".jpg";
3977 if((($upload && $profile) || $a_force_pic)
3978 && @is_file($thumb_file))
3980 $file = $thumb_file.
"?t=".rand(1, 99999);
3984 if (!$a_prevent_no_photo_image)
3987 if($a_size ==
"small" || $a_size ==
"big")
3995 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
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);
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);
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 ";
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 ";
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));
4740 $set =
$ilDB->query(
"SELECT usr_id FROM usr_pref ".
4741 " WHERE keyword = ".
$ilDB->quote($a_keyword,
"text").
4742 " AND ".$ilDB->in(
"usr_id", $a_user_ids,
false,
"integer").
4743 " AND value = ".$ilDB->quote($a_val,
"text")
4745 while ($rec =
$ilDB->fetchAssoc($set))
4747 $users[] = $rec[
"usr_id"];
4757 $query =
"UPDATE usr_data SET login_attempts = 0 WHERE usr_id = %s";
4758 $affected =
$ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4760 if($affected)
return true;
4768 $query =
"SELECT login_attempts FROM usr_data WHERE usr_id = %s";
4780 $query =
"UPDATE usr_data SET login_attempts = (login_attempts + 1) WHERE usr_id = %s";
4781 $affected =
$ilDB->manipulateF(
$query, array(
'integer'), array($a_usr_id) );
4783 if($affected)
return true;
4791 $query =
"UPDATE usr_data SET active = 0, inactivation_date = %s WHERE usr_id = %s";
4792 $affected =
$ilDB->manipulateF(
$query, array(
'timestamp',
'integer'), array(
ilUtil::now(), $a_usr_id) );
4794 if($affected)
return true;
4804 return in_array($this->
getPref(
"public_profile"), array(
"y",
"g"));
4827 $res =
$ilDB->queryF(
'SELECT * FROM loginname_history WHERE usr_id = %s AND login = %s AND history_date = %s',
4828 array(
'integer',
'text',
'integer'),
4833 $ilDB->manipulateF(
'
4834 INSERT INTO loginname_history
4835 (usr_id, login, history_date)
4836 VALUES (%s, %s, %s)',
4837 array(
'integer',
'text',
'integer'),
4851 public static function _getUsersOnline($a_user_id = 0, $a_no_anonymous =
false)
4856 global
$ilDB, $rbacreview;
4859 $atime = $pd_set->get(
'user_activity_time') * 60;
4866 $where[] =
'user_id > 0';
4868 else if (is_array($a_user_id))
4870 $where[] =
$ilDB->in(
"user_id", $a_user_id,
false,
"integer");
4874 $where[] =
'user_id = ' .
$ilDB->quote($a_user_id,
'integer');
4879 $where[] =
'user_id != ' .
$ilDB->quote(ANONYMOUS_USER_ID,
'integer');
4882 include_once
'Services/User/classes/class.ilUserAccountSettings.php';
4885 include_once
'Services/User/classes/class.ilUserFilter.php';
4889 $where[] =
'expires > ' .
$ilDB->quote($ctime,
'integer');
4890 $where[] =
'(p.value IS NULL OR NOT p.value = ' .
$ilDB->quote(
'y',
'text') .
')';
4892 $where =
'WHERE ' . implode(
' AND ', $where);
4895 SELECT COUNT(user_id) num, user_id, firstname, lastname, title, login, last_login, MAX(ctime) ctime, agree_date
4897 LEFT JOIN usr_data u
4898 ON user_id = u.usr_id
4899 LEFT JOIN usr_pref p
4900 ON (p.usr_id = u.usr_id AND p.keyword = %s)
4902 GROUP BY user_id, firstname, lastname, title, login, last_login, agree_date
4903 ORDER BY lastname, firstname
4906 array(
'hide_own_online_status')
4910 while($user =
$ilDB->fetchAssoc(
$r))
4912 if($atime <= 0 || $user[
'ctime'] + $atime > $ctime)
4914 $users[$user[
'user_id']] = $user;
4918 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
4919 if (ilTermsOfServiceHelper::isEnabled()) {
4920 $users = array_filter($users,
function($user) {
4921 if ($user[
'agree_date'] || $user[
'user_id'] == SYSTEM_USER_ID ||
'root' === $user[
'login']) {
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.child ".
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").
")";
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";
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.child ".
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";
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);
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)
5087 SELECT usr_id, create_date FROM usr_data
5088 WHERE reg_hash = %s',
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 OR (ISNULL(last_login) AND create_date < %s)";
5154 $res =
$ilDB->queryF(
$query, array(
'timestamp',
'timestamp'), array($date, $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.5.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);
5451 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5454 ilTermsOfServiceHelper::isEnabled() &&
5455 null == $this->agree_date &&
5456 'root' != $this->login &&
5457 !in_array($this->
getId(), array(ANONYMOUS_USER_ID, SYSTEM_USER_ID))
5470 public static function hasUserToAcceptTermsOfService($a_username)
5477 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5479 if(!ilTermsOfServiceHelper::isEnabled())
5484 $in =
$ilDB->in(
'usr_id', array(ANONYMOUS_USER_ID, SYSTEM_USER_ID),
true,
'integer');
5486 "SELECT usr_id FROM usr_data WHERE login = %s AND agree_date IS NULL $in",
5490 return $ilDB->fetchAssoc(
$res) ? true :
false;
5504 $date_is = ($a_agreed)
5508 $users = (is_array($a_users))
5509 ?
" AND ".
$ilDB->in(
"usr_id", $a_users,
false,
"integer")
5512 $set =
$ilDB->query(
"SELECT usr_id FROM usr_data ".
5513 " WHERE agree_date ".$date_is.
5516 while ($rec =
$ilDB->fetchAssoc($set))
5518 $ret[] = $rec[
"usr_id"];
5530 if(
null === $status)
5535 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5536 if(ilTermsOfServiceHelper::isEnabled())
5556 return $usr_id == ANONYMOUS_USER_ID;
5571 return (
bool)$this->
getPref(
"delete_flag");
5579 $this->is_self_registered = (bool) $status;
5599 $this->interests_general = $value;
5629 $this->interests_help_offered = $value;
5659 $this->interests_help_looking = $value;
5690 $current = $this->$a_attr;
5691 if(is_array($current) &&
sizeof($current))
5693 return implode(
", ", $current);
5709 $set =
$ilDB->query(
"SELECT field_id,value".
5710 " FROM usr_data_multi".
5711 " WHERE usr_id = ".
$ilDB->quote($this->getId(),
"integer").
5715 $values[
$row[
"field_id"]][] =
$row[
"value"];
5718 if(isset($values[
"interests_general"]))
5726 if(isset($values[
"interests_help_offered"]))
5734 if(isset($values[
"interests_help_looking"]))
5769 foreach($map as
$id => $values)
5771 if(is_array($values) &&
sizeof($values))
5773 foreach($values as $value)
5775 $value = trim($value);
5778 $uniq_id =
$ilDB->nextId(
'usr_data_multi');
5780 $ilDB->manipulate(
"INSERT usr_data_multi".
5781 " (id,usr_id,field_id,value) VALUES".
5782 " (".
$ilDB->quote($uniq_id,
"integer").
5783 ",".$ilDB->quote($this->getId(),
"integer").
5784 ",".$ilDB->quote(
$id,
"text").
5785 ",".$ilDB->quote($value,
"text").
5805 $ilDB->manipulate(
"DELETE FROM usr_data_multi".
5806 " WHERE usr_id = ".
$ilDB->quote($this->getId(),
"integer"));
5809 public static function findInterests($a_term, $a_user_id =
null, $a_field_id =
null)
5815 $sql =
"SELECT DISTINCT(value)".
5816 " FROM usr_data_multi".
5817 " WHERE ".$ilDB->like(
"value",
"text",
"%".$a_term.
"%");
5820 $sql .=
" AND field_id = ".$ilDB->quote($a_field_id,
"text");
5824 $sql .=
" AND usr_id <> ".$ilDB->quote($a_user_id,
"integer");
5826 $sql .=
" ORDER BY value";
5827 $set =
$ilDB->query($sql);
foreach($mandatory_scripts as $file) $timestamp
const DB_FETCHMODE_OBJECT
const USER_FOLDER_ID
Class ilObjUserFolder.
static toUsernameWithoutDomain($username)
Static function removes Microsoft domain name from username.
_getAuthMode($a_auth_mode, $a_db_handler='')
static _needsExternalAccountByAuthMode($a_auth_mode)
Check if chosen auth mode needs an external account entry.
static _getAuthModeName($a_auth_key)
static _deleteSettingsOfUser($a_user)
Delete block settings of user.
bookmark folder (note: this class handles personal bookmarks folders only)
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
static _getInstance()
get singleton instance
static removeSingleUserFromTable($usr_id)
This is the super class of all custom blocks.
static _isActive()
Static getter.
static resetToDefaults()
reset to defaults
static setLanguage($a_lng)
set language
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static deleteByOwner($a_owner_id)
Delete all entries for owner.
Base class for ILIAS Exception handling.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static _getInstance()
Get singleton instance of this class.
Class UserMail this class handles user mails.
Mail Box class Base class for creating and handling mail boxes.
static lookupTitle($a_page_id)
Lookup title.
Base class for nested set path based trees.
static removeForUser($user_id)
Remove all notifications for given user.
static deleteUserPortfolios($a_user_id)
Delete all portfolio data for user.
static _removeTrackingDataForUser($user_id)
static _deleteUser($a_usr_id)
_lookupIm($a_user_id, $a_type)
Lookup IM.
updateMultiTextFields($a_create=false)
Write multi-text values to DB.
setCity($a_str)
set city @access public
static _resetLoginAttempts($a_usr_id)
updateLogin($a_login)
update login name
getPasswdType()
get password type
static lookupMatriculation($a_usr_id)
Lookup matriculation.
getPhoneHome()
get home phone @access public
deleteMultiTextFields()
Remove multi-text values from DB
setCurrentLanguage($a_val)
Set current language.
_lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
static _getUsersForIds($a_mem_ids, $active=-1, $timelimitowner=-1)
return user data for given user id
setUTitle($a_str)
set user title (note: don't mix up this method with setTitle() that is derived from ilObject and sets...
static copyProfilePicturesToDirectory($a_user_id, $a_dir)
Get profile picture direcotory.
setInactivationDate($inactivation_date)
setter for inactivation date
static _getUsersForRole($role_id, $active=-1)
return array of complete users which belong to a specific role
readMultiTextFields()
Fetch multi-text values from DB.
static _getLastHistoryDataByUserId($a_usr_id)
Returns the last used loginname and the changedate of the passed user_id.
addToPCClipboard($a_content, $a_time, $a_nr)
Add a page content item to PC clipboard (should go to another class)
getAgreeDate()
get the date when the user accepted the user agreement @access public
static _verifyRegistrationHash($a_hash)
Verifies a registration hash.
getLatitude()
Get Latitude.
addDesktopItem($a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
setLocationZoom($a_locationzoom)
Set Location Zoom.
_writeExternalAccount($a_usr_id, $a_ext_id)
setDelicious($a_delicious)
getLookingForHelpAsText()
Get help looking for as plain text.
getOfferingHelpAsText()
Get help offering as plain text.
setLanguage($a_str)
set user language @access public
setClientIP($a_str)
set client ip number @access public
getPhoneOffice()
get office phone @access public
setLatitude($a_latitude)
Set Latitude.
static _getUserData($a_internalids)
return user data for given user ids
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
setInstitution($a_str)
set institution @access public
hasToAcceptTermsOfService()
setLastUpdate($a_str)
set last update of user data set @access public
getClipboardObjects($a_type="", $a_top_nodes_only=false)
get all clipboard objects of user and specified type
static initInactivationDate($usrIds)
@global type $ilDB
getActive()
get user active state @access public
static $personal_image_cache
sendPersonalDataFile()
Send personal data file.
static _updateLastLogin($a_usr_id, $a_last_login=null)
STATIC METHOD updates the last_login field of user with given id to given or current date.
setAgreeDate($a_str)
set date the user account was accepted by the user nullindicates that the user has not accepted his a...
addObjectToClipboard($a_item_id, $a_type, $a_title, $a_parent=0, $a_time=0, $a_order_nr=0)
add an item to user's personal clipboard
getUserIdByEmail($a_email)
STATIC METHOD get the user_id of an email address.
setFirstname($a_str)
set firstname @access public
getGeneralInterests()
Get general interests.
$login
all user related data in single vars @access public
static _lookupLogin($a_user_id)
lookup login
setDepartment($a_str)
set department @access public
getCountry()
Get country (free text)
_lookupLastLogin($a_user_id)
lookup last login
deletePref($a_keyword)
Deletes a userpref value of the user from the database @access public.
getInstantMessengerId($a_im_type)
static getUserSubsetByPreferenceValue($a_user_ids, $a_keyword, $a_val)
For a given set of user IDs return a subset that has a given user preference set.
writeAccepted()
write accept date of user agreement to db
static getFirstLettersOfLastnames()
Get first letters of all lastnames.
getTimeZone()
get timezone of user
getFax()
get fax @access public
static getLoginFromAuth()
Gets the username from $ilAuth, and converts it into an ILIAS login name.
setDiskQuota($a_disk_quota)
getLastname()
get lastname @access public
removeUserPicture($a_do_update=true)
Remove user picture.
getUTitle()
get user title (note: don't mix up this method with getTitle() that is derived from ilObject and gets...
getPersonalPicturePath($a_size="small", $a_force_pic=false)
Get path to personal picture.
setLookingForHelp(array $value=null)
Set help looking for.
static _isDesktopItem($a_usr_id, $a_item_id, $a_type)
check wether an item is on the users desktop or not
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
getMatriculation()
get matriculation number @access public
setPasswordEncodingType($password_encryption_type)
static resetInactivationDate($usrIds)
@global type $ilDB
_moveUsersToStyle($a_from_skin, $a_from_style, $a_to_skin, $a_to_style)
skins and styles
resetLastPasswordChange()
buildTextFromArray($a_attr)
Convert multi-text values to plain text.
_getUsersForClipboadObject($a_type, $a_id)
get all users, that have a certain object within their clipboard
static findInterests($a_term, $a_user_id=null, $a_field_id=null)
static _getAssociatedUsersOnline($a_user_id, $a_no_anonymous=false)
setExternalAccount($a_str)
set external account
setLogin($a_str)
set login / username @access public
static userExists($a_usr_ids=array())
_lookupActive($a_usr_id)
Check user account active.
static _getPreferences($user_id)
get preferences for user
clipboardDeleteAll()
Delete objects of type for user.
setTimeLimitFrom($a_from)
readPrefs()
get all user preferences @access private
_uploadPersonalPicture($tmp_file, $obj_id)
Create a personal picture image file from a temporary image file.
static _writePref($a_usr_id, $a_keyword, $a_value)
static _incrementLoginAttempts($a_usr_id)
hasPublicProfile()
returns true if public is profile, false otherwise
_lookupExternalAccount($a_user_id)
lookup external account for login and authmethod
getDateFormat()
get date format
_getAllUserAssignedStyles()
skins and styles
setSkin($a_str)
set user skin (template set) @access public
getHobby()
get hobby @access public
_getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
static _getUsersForFolder($ref_id, $active)
getCurrentLanguage()
returns the current language (may differ from user's pref setting!)
setSelectedCountry($a_val)
Set selected country (selection drop down)
_getFeedPass($a_user_id)
Lookup news feed password for user.
getLongitude()
Get Longitude.
getEmail()
get email address @access public
getLoginByUserId($a_userid)
isDesktopItem($a_item_id, $a_type)
check wether an item is on the users desktop or not
setCaptchaVerified($a_val)
Set captcha verified.
static hasActiveSession($a_user_id)
Check for simultaneous login.
getUserIdByLogin($a_login)
clipboardDeleteObjectsOfType($a_type)
Delete objects of type for user.
static preloadIsDesktopItem($a_usr_id, $a_item_ids)
Preload desktop item information.
_getAllUserLogins(&$ilias)
STATIC METHOD get all user logins.
setCountry($a_str)
Set country (free text)
setTimeLimitMessage($a_time_limit_message)
setPasswd($a_str, $a_type=IL_PASSWD_PLAIN)
set password @access public
static _lookupId($a_user_str)
Lookup id by login.
isPasswordChangeDemanded()
read()
loads a record "user" from database @access private
getLocationZoom()
Get Location Zoom.
_lookupFullname($a_user_id)
Lookup Full Name.
getAuthMode($a_auth_key=false)
get auth mode @access public
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
setComment($a_str)
set referral comment @access public
getComment()
get referral comment @access public
static getUsersAgreed($a_agreed=true, $a_users=null)
Get users that have or have not agreed to the user agreement.
getTimeFormat()
get time format
getPersonalDataExportFile()
Get personal data export file.
setAuthMode($a_str)
set auth mode @access public
setPhoneHome($a_str)
set home phone @access public
static _getUserIdsByInactivityPeriod($period)
get ids of all users that have been inactive for at least the given period
static _lookupGender($a_user_id)
Lookup gender.
setPasswordSalt($password_salt)
setFax($a_str)
set fax @access public
setTimeLimitUntil($a_until)
static _lookupName($a_user_id)
lookup user name
getStreet()
get street @access public
_getAllUserData($a_fields=NULL, $active=-1)
STATIC METHOD get all user data.
getClipboardChilds($a_parent, $a_insert_time)
Get childs of an item.
static _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
Toggle active status of users.
getSelectedCountry()
Get selected country (selection drop down)
setTimeLimitOwner($a_owner)
static searchUsers($a_search_str, $active=1, $a_return_ids_only=false, $filter_settings=FALSE)
STATIC METHOD get the user_ids which correspond a search string.
getInstitution()
get institution @access public
getDesktopItems($a_types="")
getApproveDate()
get the date when the user account was approved @access public
getFirstname()
get firstname @access public
_lookupEmail($a_user_id)
Lookup email.
getZipcode()
get zipcode @access public
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
_getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.
setZipcode($a_str)
set zipcode @access public
setApproveDate($a_str)
set date the user account was activated null indicates that the user has not yet been activated @acce...
setLongitude($a_longitude)
Set Longitude.
getLogin()
get login / username @access public
getPref($a_keyword)
get a user preference
setFullname($a_title="", $a_firstname="", $a_lastname="")
builds a string with title + firstname + lastname method is used to build fullname in member variable...
setPref($a_keyword, $a_value)
set a user preference
deleteUserDefinedFieldEntries()
setLastname($a_str)
set lastame @access public
hasToAcceptTermsOfServiceInSession($status=null)
setGeneralInterests(array $value=null)
Set general interests.
static _externalAccountExists($a_external_account, $a_auth_mode)
Check if an external account name already exists.
static _generateRegistrationHash($a_usr_id)
Generates a unique hashcode for activating a user profile after registration.
static _getUserIdsByInactivationPeriod($period)
get ids of all users that have been inactivated since at least the given period
static _setUserInactive($a_usr_id)
_setFeedPass($a_user_id, $a_password)
Set news feed password for user.
setOfferingHelp(array $value=null)
Set help offering.
static _lookupAuthMode($a_usr_id)
lookup auth mode
_getNumberOfUsersPerAuthMode()
get number of users per auth mode
_getImportedUserId($i2_id)
getStoredActive($a_id)
get user active state
setStreet($a_str)
set street @access public
setLastPasswordChangeTS($a_last_password_change_ts)
getLastLogin()
returns last login date @access public
_lookupFeedHash($a_user_id, $a_create=false)
Lookup news feed hash for user.
static $is_desktop_item_loaded
setActive($a_active, $a_owner=0)
set user active state and updates system fields appropriately @access public
refreshLogin()
updates the login data of a "user" // TODO set date with now() should be enough @access public
setGender($a_str)
set gender @access public
_writeAuthMode($a_usr_id, $a_auth_mode)
static _getUsersForGroup($a_mem_ids, $active=-1)
return user data for group members
setProfileIncomplete($a_prof_inc)
setTimeLimitUnlimited($a_unlimited)
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
static _getLoginAttempts($a_usr_id)
getPhoneMobile()
get mobile phone @access public
getPublicName()
returns firstname lastname and login if profile is public, login otherwise
setEmail($a_str)
set email @access public
getFullname($a_max_strlen=0)
get fullname @access public
static _lookup($a_user_id, $a_field)
Private function for lookup methods.
clipboardHasObjectsOfType($a_type)
Check whether clipboard has objects of a certain type.
setIsSelfRegistered($status)
getCity()
get city @access public
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
getLastPasswordChangeTS()
getLanguage()
returns a 2char-language-string @access public
__construct($a_user_id=0, $a_call_by_reference=false)
Constructor @access public.
setMatriculation($a_str)
set matriculation number @access public
importPersonalData($a_file, $a_profile_data, $a_settings, $a_bookmarks, $a_notes, $a_calendar)
Import personal data.
static _writeHistory($a_usr_id, $a_login)
getOfferingHelp()
Get help offering.
addUserDefinedFieldEntry()
getPasswordEncodingType()
syncActive()
synchronizes current and stored user active values for the owner value to be set correctly,...
_lookupPref($a_usr_id, $a_keyword)
setLastLogin($a_str)
set user's last login @access public
writePrefs()
write all userprefs @access private
getInactivationDate()
getter for inactivation date
getDepartment()
get department @access public
assignData($a_data)
loads a record "user" from array @access public
getPersonalWorkspaceDiskQuota()
setLastPasswordChangeToNow()
_lookupClientIP($a_user_id)
Lookup client ip.
getLookingForHelp()
Get help looking for.
static _isAnonymous($usr_id)
static _removeItemFromDesktops($a_id)
removes object from all user's desktops @access public
static _lookupLanguage($a_usr_id)
getGeneralInterestsAsText()
Get general interests as plain text.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
setPhoneOffice($a_str)
set office phone @access public
removeObjectFromClipboard($a_item_id, $a_type)
remove object from user's personal clipboard
getPCClipboardContent()
Add a page content item to PC clipboard (should go to another class)
setInstantMessengerId($a_im_type, $a_im_id)
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
__readAppliedUsers($a_parent_id)
dropDesktopItem($a_item_id, $a_type)
drop an item from user's personal desktop
exportPersonalData()
Export personal data.
setUserDefinedData($a_data)
_getLocalAccountsForEmail($a_email)
check whether external account and authentication method matches with a user
setPhoneMobile($a_str)
set mobile phone @access public
isCaptchaVerified()
Is user captcha verified?
setLoginAttempts($a_login_attempts)
setDesktopItemParameters($a_item_id, $a_type, $a_par)
set parameters of a desktop item entry
_deleteAllPref($a_user_id)
Deletes a userpref value of the user from the database @access public.
getGender()
get gender @access public
getExternalAccount()
get external account
static $is_desktop_item_cache
updateUserDefinedFields()
writePref($a_keyword, $a_value)
write userpref to user table @access private
static _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
getClientIP()
get client ip number @access public
Class ilObject Basic functions for all objects.
setId($a_id)
set object id @access public
update()
update object in db
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
setOwner($a_owner)
set object owner
getId()
get object id @access public
getCreateDate()
get create date @access public
Custom block for external feeds on personal desktop.
Class for user related exception handling in ILIAS.
Class for user related exception handling in ILIAS.
Class ilObjAuthSettingsGUI.
static _removeTrackingDataForUser($user_id)
static _getInstance()
Get instance of ilSecuritySettings.
static set($a_var, $a_val)
Set a value.
static _destroyByUserId($a_user_id)
Destroy session.
static get($a_var)
Get a value.
static skinExists($skin)
Check wheter a skin exists.
static getInstance()
Singelton get instance.
static deleteEntriesOfUser($a_user_id)
Delete data of user.
static _getInstance()
Get instance.
Class for user related exception handling in ILIAS.
static getInstance()
Singelton get instance.
static getInstance()
Single method to reduce footprint (included files, created instances)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static execConvert($args)
execute convert command
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static now()
Return current timestamp in Y-m-d H:i:s format.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static signFile($path_to_file)
Tree handler for personal workspace.
redirection script todo: (a better solution should control the processing via a xml file)