00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 define ("IL_PASSWD_PLAIN", "plain");
00025 define ("IL_PASSWD_MD5", "md5");
00026 define ("IL_PASSWD_CRYPT", "crypt");
00027
00028
00029 require_once "classes/class.ilObject.php";
00030
00040 class ilObjUser extends ilObject
00041 {
00046
00047
00048 var $login;
00049
00050 var $passwd;
00051 var $passwd_type;
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 var $gender;
00069 var $utitle;
00070 var $firstname;
00071 var $lastname;
00072 var $fullname;
00073
00074
00075 var $institution;
00076 var $department;
00077 var $street;
00078 var $city;
00079 var $zipcode;
00080 var $country;
00081 var $phone_office;
00082 var $phone_home;
00083 var $phone_mobile;
00084 var $fax;
00085 var $email;
00086 var $hobby;
00087 var $matriculation;
00088 var $referral_comment;
00089 var $approve_date;
00090 var $active;
00091
00092 var $client_ip;
00093 var $auth_mode;
00094
00095 var $user_defined_data = array();
00096
00102 var $prefs;
00103
00109 var $skin;
00110
00111
00117 var $default_role;
00118
00124 var $ilias;
00125
00126
00132 function ilObjUser($a_user_id = 0, $a_call_by_reference = false)
00133 {
00134 global $ilias,$ilDB;
00135
00136
00137 $this->ilias =& $ilias;
00138 $this->db =& $ilDB;
00139
00140 $this->type = "usr";
00141 $this->ilObject($a_user_id, $a_call_by_reference);
00142 $this->auth_mode = "default";
00143 $this->passwd_type = IL_PASSWD_PLAIN;
00144
00145
00146
00147
00148
00149
00150 if (!empty($a_user_id))
00151 {
00152 $this->setId($a_user_id);
00153 $this->read();
00154 }
00155 else
00156 {
00157
00158
00159 $this->prefs = array();
00160
00161 $this->prefs["language"] = $this->ilias->ini->readVariable("language","default");
00162
00163
00164 $this->skin = $this->ilias->ini->readVariable("layout","skin");
00165
00166 $this->prefs["skin"] = $this->skin;
00167 $this->prefs["show_users_online"] = "y";
00168
00169
00170 $this->prefs["style"] = $this->ilias->ini->readVariable("layout","style");
00171 }
00172 }
00173
00178 function read()
00179 {
00180 global $ilErr;
00181
00182
00183 $q = "SELECT * FROM usr_data ".
00184 "LEFT JOIN rbac_ua ON usr_data.usr_id=rbac_ua.usr_id ".
00185 "WHERE usr_data.usr_id='".$this->id."'";
00186 $r = $this->ilias->db->query($q);
00187
00188 if ($r->numRows() > 0)
00189 {
00190 $data = $r->fetchRow(DB_FETCHMODE_ASSOC);
00191
00192
00193
00194 if ($data["passwd"] == "" && $data["i2passwd"] != "")
00195 {
00196 $data["passwd_type"] = IL_PASSWD_CRYPT;
00197 $data["passwd"] = $data["i2passwd"];
00198 }
00199 else
00200 {
00201 $data["passwd_type"] = IL_PASSWD_MD5;
00202
00203 }
00204 unset($data["i2passw"]);
00205
00206
00207
00208 $this->assignData($data);
00209
00210
00211 $this->readPrefs();
00212
00213
00214 if ($this->prefs["language"] == "")
00215 {
00216 $this->prefs["language"] = $this->oldPrefs["language"];
00217 }
00218
00219
00220 if ($this->prefs["skin"] == "" || file_exists($this->ilias->tplPath."/".$this->prefs["skin"]) == false)
00221 {
00222 $this->prefs["skin"] = $this->oldPrefs["skin"];
00223 }
00224
00225 $this->skin = $this->prefs["skin"];
00226
00227
00228 if ($this->prefs["style"] == "" || !file_exists($this->ilias->tplPath."/".$this->skin."/".$this->prefs["style"].".css"))
00229 {
00230
00231 $this->prefs["style"] = $this->ilias->ini->readVariable("layout","style");
00232 }
00233
00234 if (empty($this->prefs["hits_per_page"]))
00235 {
00236 $this->prefs["hits_per_page"] = 10;
00237 }
00238
00239 }
00240 else
00241 {
00242 $ilErr->raiseError("<b>Error: There is no dataset with id ".
00243 $this->id."!</b><br />class: ".get_class($this)."<br />Script: ".__FILE__.
00244 "<br />Line: ".__LINE__, $ilErr->FATAL);
00245 }
00246
00247 $this->readUserDefinedFields();
00248
00249 parent::read();
00250 }
00251
00257 function assignData($a_data)
00258 {
00259 global $ilErr;
00260
00261
00262 $this->setLogin($a_data["login"]);
00263 if (! $a_data["passwd_type"])
00264 {
00265 $ilErr->raiseError("<b>Error: passwd_type missing in function assignData(). ".
00266 $this->id."!</b><br />class: ".get_class($this)."<br />Script: "
00267 .__FILE__."<br />Line: ".__LINE__, $ilErr->FATAL);
00268 }
00269
00270 if ($a_data["passwd"] != "********")
00271 {
00272 $this->setPasswd($a_data["passwd"], $a_data["passwd_type"]);
00273 }
00274
00275 $this->setGender($a_data["gender"]);
00276 $this->setUTitle($a_data["title"]);
00277 $this->setFirstname($a_data["firstname"]);
00278 $this->setLastname($a_data["lastname"]);
00279 $this->setFullname();
00280
00281
00282 $this->setInstitution($a_data["institution"]);
00283 $this->setDepartment($a_data["department"]);
00284 $this->setStreet($a_data["street"]);
00285 $this->setCity($a_data["city"]);
00286 $this->setZipcode($a_data["zipcode"]);
00287 $this->setCountry($a_data["country"]);
00288 $this->setPhoneOffice($a_data["phone_office"]);
00289 $this->setPhoneHome($a_data["phone_home"]);
00290 $this->setPhoneMobile($a_data["phone_mobile"]);
00291 $this->setFax($a_data["fax"]);
00292 $this->setMatriculation($a_data["matriculation"]);
00293 $this->setEmail($a_data["email"]);
00294 $this->setHobby($a_data["hobby"]);
00295 $this->setClientIP($a_data["client_ip"]);
00296
00297
00298 $this->setLastLogin($a_data["last_login"]);
00299 $this->setLastUpdate($a_data["last_update"]);
00300 $this->create_date = $a_data["create_date"];
00301 $this->setComment($a_data["referral_comment"]);
00302 $this->approve_date = $a_data["approve_date"];
00303 $this->active = $a_data["active"];
00304 $this->accept_date = $a_data["agree_date"];
00305
00306
00307 $this->setTimeLimitOwner($a_data["time_limit_owner"]);
00308 $this->setTimeLimitUnlimited($a_data["time_limit_unlimited"]);
00309 $this->setTimeLimitFrom($a_data["time_limit_from"]);
00310 $this->setTimeLimitUntil($a_data["time_limit_until"]);
00311 $this->setTimeLimitMessage($a_data['time_limit_message']);
00312
00313
00314 $this->setProfileIncomplete($a_data["profile_incomplete"]);
00315
00316
00317
00318
00319
00320 $this->setAuthMode($a_data['auth_mode']);
00321 $this->setExternalAccount($a_data['ext_account']);
00322 }
00323
00330 function saveAsNew($a_from_formular = true)
00331 {
00332 global $ilErr;
00333
00334 switch ($this->passwd_type)
00335 {
00336 case IL_PASSWD_PLAIN:
00337 $pw_field = "passwd";
00338 $pw_value = md5($this->passwd);
00339 break;
00340
00341 case IL_PASSWD_MD5:
00342 $pw_field = "passwd";
00343 $pw_value = $this->passwd;
00344 break;
00345
00346 case IL_PASSWD_CRYPT:
00347 $pw_field = "i2passwd";
00348 $pw_value = $this->passwd;
00349 break;
00350
00351 default :
00352 $ilErr->raiseError("<b>Error: passwd_type missing in function saveAsNew. ".
00353 $this->id."!</b><br />class: ".get_class($this)."<br />Script: ".__FILE__.
00354 "<br />Line: ".__LINE__, $ilErr->FATAL);
00355 }
00356
00357 if ($a_from_formular)
00358 {
00359 $q = "INSERT INTO usr_data "
00360 . "(usr_id,login,".$pw_field.",firstname,lastname,title,gender,"
00361 . "email,hobby,institution,department,street,city,zipcode,country,"
00362 . "phone_office,phone_home,phone_mobile,fax,last_login,last_update,create_date,"
00363 . "referral_comment,matriculation,client_ip, approve_date,active,"
00364 . "time_limit_unlimited,time_limit_until,time_limit_from,time_limit_owner,auth_mode,ext_account,profile_incomplete) "
00365 . "VALUES "
00366 . "('".$this->id."','".$this->login."','".$pw_value."', "
00367 . "'".ilUtil::addSlashes($this->firstname)."','".ilUtil::addSlashes($this->lastname)."', "
00368 . "'".ilUtil::addSlashes($this->utitle)."','".ilUtil::addSlashes($this->gender)."', "
00369 . "'".ilUtil::addSlashes($this->email)."','".ilUtil::addSlashes($this->hobby)."', "
00370 . "'".ilUtil::addSlashes($this->institution)."','".ilUtil::addSlashes($this->department)."', "
00371 . "'".ilUtil::addSlashes($this->street)."', "
00372 . "'".ilUtil::addSlashes($this->city)."','".ilUtil::addSlashes($this->zipcode)."','".
00373 ilUtil::addSlashes($this->country)."', "
00374 . "'".ilUtil::addSlashes($this->phone_office)."','".ilUtil::addSlashes($this->phone_home)."', "
00375 . "'".ilUtil::addSlashes($this->phone_mobile)."','".ilUtil::addSlashes($this->fax)."', 0, now(), now(), "
00376 . "'".ilUtil::addSlashes($this->referral_comment)."', '". ilUtil::addSlashes($this->matriculation) . "', '".
00377 ilUtil::addSlashes($this->client_ip) . "', '" .$this->approve_date."', '".$this->active."', "
00378 . "'".$this->getTimeLimitUnlimited()."','" . $this->getTimeLimitUntil()."','".$this->getTimeLimitFrom()."','".
00379 $this->getTimeLimitOwner()."', "
00380 . "'".$this->getAuthMode()."', "
00381 . "'".$this->getExternalAccount()."', "
00382 . "'".$this->getProfileIncomplete()."')";
00383 }
00384 else
00385 {
00386 $q = "INSERT INTO usr_data ".
00387 "(usr_id,login,".$pw_field.",firstname,lastname,title,gender,"
00388 . "email,hobby,institution,department,street,city,zipcode,country,"
00389 . "phone_office,phone_home,phone_mobile,fax,last_login,last_update,create_date,"
00390 . "referral_comment,matriculation,client_ip, approve_date,active,"
00391 . "time_limit_unlimited,time_limit_until,time_limit_from,time_limit_owner,auth_mode,ext_account,profile_incomplete) "
00392 . "VALUES "
00393 . "('".$this->id."','".$this->login."','".$pw_value."', "
00394 . "'".ilUtil::prepareDBString($this->firstname)."','".ilUtil::prepareDBString($this->lastname)."', "
00395 . "'".ilUtil::prepareDBString($this->utitle)."','".ilUtil::prepareDBString($this->gender)."', "
00396 . "'".ilUtil::prepareDBString($this->email)."','".ilUtil::prepareDBString($this->hobby)."', "
00397 . "'".ilUtil::prepareDBString($this->institution)."','".ilUtil::prepareDBString($this->department)."', "
00398 . "'".ilUtil::prepareDBString($this->street)."', "
00399 . "'".ilUtil::prepareDBString($this->city)."','".ilUtil::prepareDBString($this->zipcode)."','".
00400 ilUtil::prepareDBString($this->country)."', "
00401 . "'".ilUtil::prepareDBString($this->phone_office)."','".ilUtil::prepareDBString($this->phone_home)."', "
00402 . "'".ilUtil::prepareDBString($this->phone_mobile)."','".ilUtil::prepareDBString($this->fax)."', 0, now(), now(), "
00403 . "'".ilUtil::prepareDBString($this->referral_comment)."', '".ilUtil::prepareDBString($this->matriculation)."', '".
00404 ilUtil::prepareDBString($this->client_ip)."', '".$this->approve_date."','".$this->active."', "
00405 . "'".$this->getTimeLimitUnlimited()."','".$this->getTimeLimitUntil()."','".$this->getTimeLimitFrom()."','".
00406 $this->getTimeLimitOwner()."',"
00407 ."'".$this->getAuthMode()."', "
00408 ."'".$this->getExternalAccount()."', "
00409 ."'".$this->getProfileIncomplete()."'"
00410 . ")";
00411 }
00412
00413 $this->ilias->db->query($q);
00414
00415
00416 $this->addUserDefinedFieldEntry();
00417
00418 $this->updateUserDefinedFields();
00419
00420
00421 include_once ("classes/class.ilMailbox.php");
00422 $mbox = new ilMailbox($this->id);
00423 $mbox->createDefaultFolder();
00424
00425 include_once "classes/class.ilMailOptions.php";
00426 $mail_options = new ilMailOptions($this->id);
00427 $mail_options->createMailOptionsEntry();
00428
00429
00430 include_once "classes/class.ilBookmarkFolder.php";
00431 $bmf = new ilBookmarkFolder(0, $this->id);
00432 $bmf->createNewBookmarkTree();
00433
00434 }
00435
00440 function update()
00441 {
00442 global $ilErr, $ilDB;
00443
00444
00445
00446 $this->syncActive();
00447
00448 $pw_udpate = '';
00449 switch ($this->passwd_type)
00450 {
00451 case IL_PASSWD_PLAIN:
00452 $pw_update = "i2passwd='', passwd='".md5($this->passwd)."'";
00453 break;
00454
00455 case IL_PASSWD_MD5:
00456 $pw_update = "i2passwd='', passwd='".$this->passwd."'";
00457 break;
00458
00459 case IL_PASSWD_CRYPT:
00460 $pw_update = "passwd='', i2passwd='".$this->passwd."'";
00461 break;
00462
00463 default :
00464 $ilErr->raiseError("<b>Error: passwd_type missing in function update()".$this->id."!</b><br />class: ".
00465 get_class($this)."<br />Script: ".__FILE__."<br />Line: ".__LINE__, $ilErr->FATAL);
00466 }
00467 $q = "UPDATE usr_data SET ".
00468 "gender='".$this->gender."', ".
00469 "title='".ilUtil::prepareDBString($this->utitle)."', ".
00470 "firstname='".ilUtil::prepareDBString($this->firstname)."', ".
00471 "lastname='".ilUtil::prepareDBString($this->lastname)."', ".
00472 "email='".ilUtil::prepareDBString($this->email)."', ".
00473 "hobby='".ilUtil::prepareDBString($this->hobby)."', ".
00474 "institution='".ilUtil::prepareDBString($this->institution)."', ".
00475 "department='".ilUtil::prepareDBString($this->department)."', ".
00476 "street='".ilUtil::prepareDBString($this->street)."', ".
00477 "city='".ilUtil::prepareDBString($this->city)."', ".
00478 "zipcode='".ilUtil::prepareDBString($this->zipcode)."', ".
00479 "country='".ilUtil::prepareDBString($this->country)."', ".
00480 "phone_office='".ilUtil::prepareDBString($this->phone_office)."', ".
00481 "phone_home='".ilUtil::prepareDBString($this->phone_home)."', ".
00482 "phone_mobile='".ilUtil::prepareDBString($this->phone_mobile)."', ".
00483 "fax='".ilUtil::prepareDBString($this->fax)."', ".
00484 "referral_comment='".ilUtil::prepareDBString($this->referral_comment)."', ".
00485 "matriculation='".ilUtil::prepareDBString($this->matriculation)."', ".
00486 "client_ip='".ilUtil::prepareDBString($this->client_ip)."', ".
00487 "approve_date='".ilUtil::prepareDBString($this->approve_date)."', ".
00488 "active='".ilUtil::prepareDBString($this->active)."', ".
00489 "time_limit_owner='".ilUtil::prepareDBString($this->getTimeLimitOwner())."', ".
00490 "time_limit_unlimited='".ilUtil::prepareDBString($this->getTimeLimitUnlimited())."', ".
00491 "time_limit_from='".ilUtil::prepareDBString($this->getTimeLimitFrom())."', ".
00492 "time_limit_until='".ilUtil::prepareDBString($this->getTimeLimitUntil())."', ".
00493 "time_limit_message='".$this->getTimeLimitMessage()."', ".
00494 "profile_incomplete = ".$ilDB->quote($this->getProfileIncomplete()).", ".
00495 "auth_mode='".ilUtil::prepareDBString($this->getAuthMode())."', ".
00496 "ext_account='".ilUtil::prepareDBString($this->getExternalAccount())."', ".
00497 $pw_update.", ".
00498 "last_update=now() ".
00499
00500
00501
00502 "WHERE usr_id='".$this->id."'";
00503
00504 $this->ilias->db->query($q);
00505 $this->writePrefs();
00506
00507
00508 $this->updateUserDefinedFields();
00509
00510
00511 parent::update();
00512 parent::updateOwner();
00513
00514 $this->read();
00515
00516 return true;
00517 }
00518
00522 function writeAccepted()
00523 {
00524 global $ilDB;
00525
00526 $q = "UPDATE usr_data SET agree_date = now()".
00527 "WHERE usr_id = ".$ilDB->quote($this->getId());
00528 $ilDB->query($q);
00529
00530 }
00531
00532 function _lookupEmail($a_user_id)
00533 {
00534 global $ilDB;
00535
00536 $query = "SELECT email FROM usr_data WHERE usr_id = '".(int) $a_user_id."'";
00537 $res = $ilDB->query($query);
00538
00539 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00540 {
00541 return $row->email;
00542 }
00543 return false;
00544 }
00545
00546 function _lookupClientIP($a_user_id)
00547 {
00548 global $ilDB;
00549
00550 $query = "SELECT client_ip FROM usr_data WHERE usr_id = '".(int) $a_user_id."'";
00551 $res = $ilDB->query($query);
00552
00553 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00554 {
00555 return $row->client_ip;
00556 }
00557 return "";
00558 }
00559
00560
00564 function _lookupName($a_user_id)
00565 {
00566 global $ilDB;
00567
00568 $q = "SELECT firstname, lastname, title FROM usr_data".
00569 " WHERE usr_id =".$ilDB->quote($a_user_id);
00570 $user_set = $ilDB->query($q);
00571 $user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC);
00572 return array("user_id" => $a_user_id,
00573 "firstname" => $user_rec["firstname"],
00574 "lastname" => $user_rec["lastname"],
00575 "title" => $user_rec["title"]);
00576 }
00577
00581 function _lookupLogin($a_user_id)
00582 {
00583 global $ilDB;
00584
00585 $q = "SELECT login FROM usr_data".
00586 " WHERE usr_id =".$ilDB->quote($a_user_id);
00587 $user_set = $ilDB->query($q);
00588 $user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC);
00589 return $user_rec["login"];
00590 }
00591
00595 function _lookupId($a_user_str)
00596 {
00597 global $ilDB;
00598
00599 $q = "SELECT usr_id FROM usr_data".
00600 " WHERE login =".$ilDB->quote($a_user_str);
00601 $user_set = $ilDB->query($q);
00602 $user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC);
00603 return $user_rec["usr_id"];
00604 }
00605
00609 function _lookupLastLogin($a_user_id)
00610 {
00611 global $ilDB;
00612
00613 $q = "SELECT last_login FROM usr_data".
00614 " WHERE usr_id =".$ilDB->quote($a_user_id);
00615 $user_set = $ilDB->query($q);
00616 $user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC);
00617 return $user_rec["last_login"];
00618 }
00619
00620
00626 function refreshLogin()
00627 {
00628 $q = "UPDATE usr_data SET ".
00629 "last_login = now() ".
00630 "WHERE usr_id = '".$this->id."'";
00631
00632 $this->ilias->db->query($q);
00633 }
00634
00641 function replacePassword($new_md5)
00642 {
00643 $this->passwd_type = IL_PASSWD_MD5;
00644 $this->passwd = $new_md5;
00645
00646 $q = "UPDATE usr_data SET ".
00647 "passwd='".$this->passwd."' ".
00648 "WHERE usr_id='".$this->id."'";
00649
00650 $this->ilias->db->query($q);
00651
00652 return true;
00653 }
00654
00663 function updatePassword($a_old, $a_new1, $a_new2)
00664 {
00665 if (func_num_args() != 3)
00666 {
00667 return false;
00668 }
00669
00670 if (!isset($a_old) or !isset($a_new1) or !isset($a_new2))
00671 {
00672 return false;
00673 }
00674
00675 if ($a_new1 != $a_new2)
00676 {
00677 return false;
00678 }
00679
00680
00681 if ($a_new1 == "" || $a_old == "")
00682 {
00683 return false;
00684 }
00685
00686
00687 switch ($this->passwd_type)
00688 {
00689 case IL_PASSWD_PLAIN:
00690 if ($a_old != $this->passwd)
00691 {
00692 return false;
00693 }
00694 break;
00695
00696 case IL_PASSWD_MD5:
00697 if (md5($a_old) != $this->passwd)
00698 {
00699 return false;
00700 }
00701 break;
00702
00703 case IL_PASSWD_CRYPT:
00704 if (_makeIlias2Password($a_old) != $this->passwd)
00705 {
00706 return false;
00707 }
00708 break;
00709 }
00710
00711
00712 $this->passwd = md5($a_new1);
00713 $this->passwd_type = IL_PASSWD_MD5;
00714
00715 $q = "UPDATE usr_data SET ".
00716 "passwd='".$this->passwd."' ".
00717 "WHERE usr_id='".$this->id."'";
00718 $this->ilias->db->query($q);
00719
00720 return true;
00721 }
00722
00730 function resetPassword($a_new1, $a_new2)
00731 {
00732 if (func_num_args() != 2)
00733 {
00734 return false;
00735 }
00736
00737 if (!isset($a_new1) or !isset($a_new2))
00738 {
00739 return false;
00740 }
00741
00742 if ($a_new1 != $a_new2)
00743 {
00744 return false;
00745 }
00746
00747
00748 $this->passwd = md5($a_new1);
00749 $this->passwd_type = IL_PASSWD_MD5;
00750
00751 $q = "UPDATE usr_data SET ".
00752 "passwd='".$this->passwd."' ".
00753 "WHERE usr_id='".$this->id."'";
00754 $this->ilias->db->query($q);
00755
00756 return true;
00757 }
00758
00762 function _makeIlias2Password($a_passwd)
00763 {
00764 return (crypt($a_passwd,substr($a_passwd,0,2)));
00765 }
00766
00770 function _lookupHasIlias2Password($a_user_login)
00771 {
00772 global $ilias, $ilDB;
00773
00774 $q = "SELECT i2passwd FROM usr_data ".
00775 "WHERE login = ".$ilDB->quote($a_user_login)."";
00776 $user_set = $ilias->db->query($q);
00777
00778 if ($user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC))
00779 {
00780 if ($user_rec["i2passwd"] != "")
00781 {
00782 return true;
00783 }
00784 }
00785
00786 return false;
00787 }
00788
00789 function _switchToIlias3Password($a_user, $a_pw)
00790 {
00791 global $ilias, $ilDB;
00792
00793 $q = "SELECT i2passwd FROM usr_data ".
00794 "WHERE login = ".$ilDB->quote($a_user)."";
00795 $user_set = $ilias->db->query($q);
00796
00797 if ($user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC))
00798 {
00799 if ($user_rec["i2passwd"] == ilObjUser::_makeIlias2Password($a_pw))
00800 {
00801 $q = "UPDATE usr_data SET passwd=".$ilDB->quote(md5($a_pw)).", i2passwd=''".
00802 "WHERE login = ".$ilDB->quote($a_user);
00803 $ilias->db->query($q);
00804 return true;
00805 }
00806 }
00807
00808 return false;
00809 }
00810
00817 function updateLogin($a_login)
00818 {
00819 if (func_num_args() != 1)
00820 {
00821 return false;
00822 }
00823
00824 if (!isset($a_login))
00825 {
00826 return false;
00827 }
00828
00829
00830 $this->login = $a_login;
00831
00832 $q = "UPDATE usr_data SET ".
00833 "login='".$this->login."' ".
00834 "WHERE usr_id='".$this->id."'";
00835 $this->ilias->db->query($q);
00836
00837 return true;
00838 }
00839
00846 function writePref($a_keyword, $a_value)
00847 {
00848 ilObjUser::_writePref($this->id, $a_keyword, $a_value);
00849 $this->setPref($a_keyword, $a_value);
00850 }
00851
00852
00853 function _writePref($a_usr_id, $a_keyword, $a_value)
00854 {
00855 global $ilDB;
00856
00857
00858 $q = "DELETE FROM usr_pref ".
00859 "WHERE usr_id='".$a_usr_id."' ".
00860 "AND keyword='".$a_keyword."'";
00861 $ilDB->query($q);
00862
00863
00864 if ($a_value != "")
00865 {
00866 $q = "INSERT INTO usr_pref ".
00867 "(usr_id, keyword, value) ".
00868 "VALUES ".
00869 "('".$a_usr_id."', '".$a_keyword."', '".$a_value."')";
00870
00871 $ilDB->query($q);
00872 }
00873 }
00874
00879 function writePrefs()
00880 {
00881
00882 $q = "DELETE FROM usr_pref ".
00883 "WHERE usr_id='".$this->id."'";
00884 $this->ilias->db->query($q);
00885
00886 foreach ($this->prefs as $keyword => $value)
00887 {
00888
00889 $q = "INSERT INTO usr_pref ".
00890 "(usr_id, keyword, value) ".
00891 "VALUES ".
00892 "('".$this->id."', '".$keyword."', '".$value."')";
00893 $this->ilias->db->query($q);
00894 }
00895 }
00896
00903 function setPref($a_keyword, $a_value)
00904 {
00905 if ($a_keyword != "")
00906 {
00907 $this->prefs[$a_keyword] = $a_value;
00908 }
00909 }
00910
00916 function getPref($a_keyword)
00917 {
00918 return $this->prefs[$a_keyword];
00919 }
00920
00921 function _lookupPref($a_usr_id,$a_keyword)
00922 {
00923 global $ilDB;
00924
00925 $query = "SELECT * FROM usr_pref WHERE usr_id='".$a_usr_id."' ".
00926 "AND keyword = '".$a_keyword."'";
00927 $res = $ilDB->query($query);
00928
00929 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00930 {
00931 return $row->value;
00932 }
00933 return false;
00934 }
00935
00941 function readPrefs()
00942 {
00943 if (is_array($this->prefs))
00944 {
00945 $this->oldPrefs = $this->prefs;
00946 }
00947
00948 $this->prefs = array();
00949
00950 $q = "SELECT * FROM usr_pref WHERE usr_id='".$this->id."'";
00951
00952 $r = $this->ilias->db->query($q);
00953
00954 while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
00955 {
00956 $this->prefs[$row["keyword"]] = $row["value"];
00957 }
00958
00959 return $r->numRows();
00960 }
00961
00962
00963
00964
00965
00966
00967
00968
00969
00975 function delete()
00976 {
00977 global $rbacadmin;
00978
00979
00980 include_once ("classes/class.ilMailbox.php");
00981 $mailbox = new ilMailbox($this->getId());
00982 $mailbox->delete();
00983 $mailbox->updateMailsOfDeletedUser();
00984
00985
00986 $this->ilias->db->query("DELETE FROM usr_data WHERE usr_id='".$this->getId()."'");
00987
00988
00989 $this->ilias->db->query("DELETE FROM usr_pref WHERE usr_id='".$this->getId()."'");
00990
00991
00992 $this->ilias->db->query("DELETE FROM usr_session WHERE user_id='".$this->getId()."'");
00993
00994
00995 $rbacadmin->removeUser($this->getId());
00996
00997
00998
00999 $q = "DELETE FROM bookmark_tree WHERE tree='".$this->getId()."'";
01000 $this->ilias->db->query($q);
01001
01002 $q = "DELETE FROM bookmark_data WHERE user_id='".$this->getId()."'";
01003 $this->ilias->db->query($q);
01004
01005
01006 include_once './classes/class.ilObjForum.php';
01007 ilObjForum::_deleteUser($this->getId());
01008
01009
01010 include_once './classes/class.ilLinkCheckNotify.php';
01011 ilLinkCheckNotify::_deleteUser($this->getId());
01012
01013
01014 include_once './course/classes/class.ilObjCourse.php';
01015 ilObjCourse::_deleteUser($this->getId());
01016
01017
01018 include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
01019 ilObjUserTracking::_deleteUser($this->getId());
01020
01021 include_once 'course/classes/Event/class.ilEventParticipants.php';
01022 ilEventParticipants::_deleteByUser($this->getId());
01023
01024
01025 $q = "DELETE FROM grp_registration WHERE user_id='".$this->getId()."'";
01026 $this->ilias->db->query($q);
01027
01028
01029 $this->deleteUserDefinedFieldEntries();
01030
01031
01032 parent::delete();
01033 return true;
01034 }
01035
01045 function setFullname($a_title = "",$a_firstname = "",$a_lastname = "")
01046 {
01047 $this->fullname = "";
01048
01049 if ($a_title)
01050 {
01051 $fullname = $a_title." ";
01052 }
01053 elseif ($this->utitle)
01054 {
01055 $this->fullname = $this->utitle." ";
01056 }
01057
01058 if ($a_firstname)
01059 {
01060 $fullname .= $a_firstname." ";
01061 }
01062 elseif ($this->firstname)
01063 {
01064 $this->fullname .= $this->firstname." ";
01065 }
01066
01067 if ($a_lastname)
01068 {
01069 return $fullname.$a_lastname;
01070 }
01071
01072 $this->fullname .= $this->lastname;
01073 }
01074
01089 function getFullname($a_max_strlen = 0)
01090 {
01091 if (!$a_max_strlen)
01092 {
01093 return ilUtil::stripSlashes($this->fullname);
01094 }
01095
01096 if (strlen($this->fullname) <= $a_max_strlen)
01097 {
01098 return ilUtil::stripSlashes($this->fullname);
01099 }
01100
01101 if ((strlen($this->utitle) + strlen($this->lastname) + 4) <= $a_max_strlen)
01102 {
01103 return ilUtil::stripSlashes($this->utitle." ".substr($this->firstname,0,1).". ".$this->lastname);
01104 }
01105
01106 if ((strlen($this->firstname) + strlen($this->lastname) + 1) <= $a_max_strlen)
01107 {
01108 return ilUtil::stripSlashes($this->firstname." ".$this->lastname);
01109 }
01110
01111 if ((strlen($this->lastname) + 3) <= $a_max_strlen)
01112 {
01113 return ilUtil::stripSlashes(substr($this->firstname,0,1).". ".$this->lastname);
01114 }
01115
01116 return ilUtil::stripSlashes(substr($this->lastname,0,$a_max_strlen));
01117 }
01118
01119
01125 function getLastVisitedLessons()
01126 {
01127
01128 $q = "SELECT * FROM lo_access ".
01129 "WHERE usr_id='".$this->id."' ".
01130 "ORDER BY timestamp DESC";
01131 $rst = $this->ilias->db->query($q);
01132
01133
01134 $result = array();
01135 while($record = $rst->fetchRow(DB_FETCHMODE_OBJECT))
01136 {
01137 $result[] = array(
01138 "timestamp" => $record->timestamp,
01139 "usr_id" => $record->usr_id,
01140 "lm_id" => $record->lm_id,
01141 "obj_id" => $record->obj_id,
01142 "lm_title" => $record->lm_title);
01143 }
01144 return $result;
01145 }
01146
01147
01153 function getLessons()
01154 {
01155
01156 $q = "SELECT * FROM lo_access ".
01157 "WHERE usr_id='".$this->id."' ";
01158 $rst = $this->ilias->db->query($q);
01159
01160
01161 $result = array();
01162 while($record = $rst->fetchRow(DB_FETCHMODE_OBJECT))
01163 {
01164 $result[] = array(
01165 "timestamp" => $record->timestamp,
01166 "usr_id" => $record->usr_id,
01167 "lm_id" => $record->lm_id,
01168 "obj_id" => $record->obj_id,
01169 "lm_title" => $record->lm_title);
01170 }
01171 return $result;
01172 }
01173
01174
01181 function getCourses()
01182 {
01183 global $lng;
01184
01185
01186 $courses = array();
01187
01188 $sql = "SELECT * FROM courses
01189 WHERE user_fk='".$this->id."'
01190 AND read=1";
01191 $courses[] = array(
01192 "id" => 1,
01193 "title" => "Course 1",
01194 "desc" => "description of course one",
01195 "content" => "This is Course One",
01196 "datetime" => date("Y-m-d")
01197 );
01198 return $courses;
01199 }
01200
01207 function getLiterature()
01208 {
01209
01210 $literature = array();
01211
01212 $sql = "SELECT * FROM literature";
01213
01214 $literature[] = array(
01215 "id" => 1,
01216 "url" => "http://www.gutenberg.de",
01217 "desc" => "project gutenberg",
01218 );
01219
01220 return $literature;
01221 }
01222
01226 function hasAcceptedUserAgreement()
01227 {
01228 if ($this->accept_date != "0000-00-00 00:00:00" || $this->login == "root")
01229 {
01230 return true;
01231 }
01232 return false;
01233 }
01234
01240 function setLogin($a_str)
01241 {
01242 $this->login = $a_str;
01243 }
01244
01249 function getLogin()
01250 {
01251 return $this->login;
01252 }
01253
01259 function setPasswd($a_str, $a_type = IL_PASSWD_PLAIN)
01260 {
01261 $this->passwd = $a_str;
01262 $this->passwd_type = $a_type;
01263 }
01264
01272 function getPasswd()
01273 {
01274 return $this->passwd;
01275 }
01282 function getPasswdType()
01283 {
01284 return $this->passwd_type;
01285 }
01286
01292 function setGender($a_str)
01293 {
01294 $this->gender = substr($a_str,-1);
01295 }
01296
01301 function getGender()
01302 {
01303 return $this->gender;
01304 }
01305
01313 function setUTitle($a_str)
01314 {
01315 $this->utitle = $a_str;
01316 }
01317
01324 function getUTitle()
01325 {
01326 return $this->utitle;
01327 }
01328
01334 function setFirstname($a_str)
01335 {
01336 $this->firstname = $a_str;
01337 }
01338
01343 function getFirstname()
01344 {
01345 return $this->firstname;
01346 }
01347
01353 function setLastname($a_str)
01354 {
01355 $this->lastname = $a_str;
01356 }
01357
01362 function getLastname()
01363 {
01364 return $this->lastname;
01365 }
01366
01372 function setInstitution($a_str)
01373 {
01374 $this->institution = $a_str;
01375 }
01376
01381 function getInstitution()
01382 {
01383 return $this->institution;
01384 }
01385
01391 function setDepartment($a_str)
01392 {
01393 $this->department = $a_str;
01394 }
01395
01400 function getDepartment()
01401 {
01402 return $this->department;
01403 }
01404
01410 function setStreet($a_str)
01411 {
01412 $this->street = $a_str;
01413 }
01414
01419 function getStreet()
01420 {
01421 return $this->street;
01422 }
01423
01429 function setCity($a_str)
01430 {
01431 $this->city = $a_str;
01432 }
01433
01438 function getCity()
01439 {
01440 return $this->city;
01441 }
01442
01448 function setZipcode($a_str)
01449 {
01450 $this->zipcode = $a_str;
01451 }
01452
01457 function getZipcode()
01458 {
01459 return $this->zipcode;
01460 }
01461
01467 function setCountry($a_str)
01468 {
01469 $this->country = $a_str;
01470 }
01471
01476 function getCountry()
01477 {
01478 return $this->country;
01479 }
01480
01486 function setPhoneOffice($a_str)
01487 {
01488 $this->phone_office = $a_str;
01489 }
01490
01495 function getPhoneOffice()
01496 {
01497 return $this->phone_office;
01498 }
01499
01505 function setPhoneHome($a_str)
01506 {
01507 $this->phone_home = $a_str;
01508 }
01509
01514 function getPhoneHome()
01515 {
01516 return $this->phone_home;
01517 }
01518
01524 function setPhoneMobile($a_str)
01525 {
01526 $this->phone_mobile = $a_str;
01527 }
01528
01533 function getPhoneMobile()
01534 {
01535 return $this->phone_mobile;
01536 }
01537
01543 function setFax($a_str)
01544 {
01545 $this->fax = $a_str;
01546 }
01547
01552 function getFax()
01553 {
01554 return $this->fax;
01555 }
01556
01562 function setClientIP($a_str)
01563 {
01564 $this->client_ip = $a_str;
01565 }
01566
01571 function getClientIP()
01572 {
01573 return $this->client_ip;
01574 }
01575
01581 function setMatriculation($a_str)
01582 {
01583 $this->matriculation = $a_str;
01584 }
01585
01590 function getMatriculation()
01591 {
01592 return $this->matriculation;
01593 }
01594
01600 function setEmail($a_str)
01601 {
01602 $this->email = $a_str;
01603 }
01604
01609 function getEmail()
01610 {
01611 return $this->email;
01612 }
01613
01619 function setHobby($a_str)
01620 {
01621 $this->hobby = $a_str;
01622 }
01623
01628 function getHobby()
01629 {
01630 return $this->hobby;
01631 }
01632
01638 function setLanguage($a_str)
01639 {
01640 $this->setPref("language",$a_str);
01641 unset($_SESSION['lang']);
01642 }
01643
01649 function getLanguage()
01650 {
01651 return $this->prefs["language"];
01652 }
01653
01654 function _lookupLanguage($a_usr_id)
01655 {
01656 global $ilDB;
01657
01658 $q = "SELECT value FROM usr_pref WHERE usr_id='".$a_usr_id."' AND keyword = 'language'";
01659 $r = $ilDB->query($q);
01660
01661 while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
01662 {
01663 return $row['value'];
01664 }
01665 return 'en';
01666 }
01667
01668
01669 function _checkPassword($a_usr_id, $a_pw)
01670 {
01671 global $ilDB;
01672
01673 $q = "SELECT passwd FROM usr_data ".
01674 " WHERE usr_id=".$ilDB->quote($a_usr_id);
01675 $usr_set = $ilDB->query($q);
01676
01677 if($usr_rec = $usr_set->fetchRow(DB_FETCHMODE_ASSOC))
01678 {
01679 if ($usr_rec["passwd"] == md5($a_pw))
01680 {
01681 return true;
01682 }
01683 }
01684 return false;
01685 }
01686
01687 function _writeExternalAccount($a_usr_id, $a_ext_id)
01688 {
01689 global $ilDB;
01690
01691 $q = "UPDATE usr_data ".
01692 " SET ext_account = ".$ilDB->quote($a_ext_id).
01693 " WHERE usr_id=".$ilDB->quote($a_usr_id);
01694 $usr_set = $ilDB->query($q);
01695 }
01696
01697 function _writeAuthMode($a_usr_id, $a_auth_mode)
01698 {
01699 global $ilDB;
01700
01701 $q = "UPDATE usr_data ".
01702 " SET auth_mode = ".$ilDB->quote($a_auth_mode).
01703 " WHERE usr_id=".$ilDB->quote($a_usr_id);
01704 $usr_set = $ilDB->query($q);
01705 }
01706
01711 function getCurrentLanguage()
01712 {
01713 return $_SESSION['lang'];
01714 }
01715
01721 function setLastLogin($a_str)
01722 {
01723 $this->last_login = $a_str;
01724 }
01725
01731 function getLastLogin()
01732 {
01733 return $this->last_login;
01734 }
01735
01741 function setLastUpdate($a_str)
01742 {
01743 $this->last_update = $a_str;
01744 }
01745 function getLastUpdate()
01746 {
01747 return $this->last_update;
01748 }
01749
01755 function setComment($a_str)
01756 {
01757 $this->referral_comment = $a_str;
01758 }
01759
01764 function getComment()
01765 {
01766 return $this->referral_comment;
01767 }
01768
01775 function setApproveDate($a_str)
01776 {
01777 $this->approve_date = $a_str;
01778 }
01779
01785 function getApproveDate()
01786 {
01787 return $this->approve_date;
01788 }
01789
01796 function setActive($a_active, $a_owner = 6)
01797 {
01798 if (empty($a_owner))
01799 {
01800 $a_owner = 0;
01801 }
01802
01803 if ($a_active)
01804 {
01805 $this->active = 1;
01806 $this->setApproveDate(date('Y-m-d H:i:s'));
01807 $this->setOwner($a_owner);
01808 }
01809 else
01810 {
01811 $this->active = 0;
01812 $this->setApproveDate('0000-00-00 00:00:00');
01813 $this->setOwner(0);
01814 }
01815 }
01816
01821 function getActive()
01822 {
01823 return $this->active;
01824 }
01825
01831 function syncActive()
01832 {
01833 $storedActive = 0;
01834 if ($this->getStoredActive($this->id))
01835 {
01836 $storedActive = 1;
01837 }
01838
01839 $currentActive = 0;
01840 if ($this->active)
01841 {
01842 $currentActive = 1;
01843 }
01844
01845 if ((!empty($storedActive) && empty($currentActive)) ||
01846 (empty($storedActive) && !empty($currentActive)))
01847 {
01848 $this->setActive($currentActive, $this->getUserIdByLogin($this->ilias->auth->getUsername()));
01849 }
01850 }
01851
01858 function getStoredActive($a_id)
01859 {
01860 global $ilias;
01861
01862 $query = "SELECT active FROM usr_data ".
01863 "WHERE usr_id = '".$a_id."'";
01864
01865 $row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
01866
01867 return $row->active ? true : false;
01868 }
01869
01875 function setSkin($a_str)
01876 {
01877
01878 $this->skin = $a_str;
01879 }
01880
01881 function setTimeLimitOwner($a_owner)
01882 {
01883 $this->time_limit_owner = $a_owner;
01884 }
01885 function getTimeLimitOwner()
01886 {
01887 return $this->time_limit_owner ? $this->time_limit_owner : 7;
01888 }
01889 function setTimeLimitFrom($a_from)
01890 {
01891 $this->time_limit_from = $a_from;
01892 }
01893 function getTimeLimitFrom()
01894 {
01895 return $this->time_limit_from ? $this->time_limit_from : time();
01896 }
01897 function setTimeLimitUntil($a_until)
01898 {
01899 $this->time_limit_until = $a_until;
01900 }
01901 function getTimeLimitUntil()
01902 {
01903 return $this->time_limit_until ? $this->time_limit_until : time();
01904 }
01905 function setTimeLimitUnlimited($a_unlimited)
01906 {
01907 $this->time_limit_unlimited = $a_unlimited;
01908 }
01909 function getTimeLimitUnlimited()
01910 {
01911 return $this->time_limit_unlimited;
01912 }
01913 function setTimeLimitMessage($a_time_limit_message)
01914 {
01915 return $this->time_limit_message = $a_time_limit_message;
01916 }
01917 function getTimeLimitMessage()
01918 {
01919 return $this->time_limit_message;
01920 }
01921
01922
01923 function checkTimeLimit()
01924 {
01925 if($this->getTimeLimitUnlimited())
01926 {
01927 return true;
01928 }
01929 if($this->getTimeLimitFrom() < time() and $this->getTimeLimitUntil() > time())
01930 {
01931 return true;
01932 }
01933 return false;
01934 }
01935 function setProfileIncomplete($a_prof_inc)
01936 {
01937 $this->profile_incomplete = (boolean) $a_prof_inc;
01938 }
01939 function getProfileIncomplete()
01940 {
01941 return $this->profile_incomplete;
01942 }
01943
01944 function &getAppliedUsers()
01945 {
01946 $this->applied_users = array();
01947 $this->__readAppliedUsers($this->getId());
01948
01949 return $this->applied_users ? $this->applied_users : array();
01950 }
01951
01952 function isChild($a_usr_id)
01953 {
01954 if($a_usr_id == $this->getId())
01955 {
01956 return true;
01957 }
01958
01959 $this->applied_users = array();
01960 $this->__readAppliedUsers($this->getId());
01961
01962 return in_array($a_usr_id,$this->applied_users);
01963 }
01964
01965 function __readAppliedUsers($a_parent_id)
01966 {
01967 $query = "SELECT usr_id FROM usr_data ".
01968 "WHERE time_limit_owner = '".$a_parent_id."'";
01969
01970 $res = $this->ilias->db->query($query);
01971 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
01972 {
01973 $this->applied_users[] = $row->usr_id;
01974
01975
01976 $this->__readAppliedUsers($row->usr_id);
01977 }
01978 return true;
01979 }
01980
01981
01982
01983
01984
01985 function checkUserId()
01986 {
01987 $r = $this->ilias->db->query("SELECT usr_id FROM usr_data WHERE login='".$this->ilias->auth->getUsername()."'");
01988
01989 if ($r->numRows() > 0)
01990 {
01991 $data = $r->fetchRow();
01992 $this->id = $data[0];
01993
01994 return $this->id;
01995 }
01996
01997 return false;
01998 }
01999
02000
02001
02002
02003
02004
02005 function isCurrentUserActive()
02006 {
02007 $r = $this->ilias->db->query("SELECT active FROM usr_data WHERE login='".$this->ilias->auth->getUsername()."'");
02008
02009 if ($r->numRows() > 0)
02010 {
02011 $data = $r->fetchRow();
02012 if (!empty($data[0]))
02013 {
02014 return true;
02015 }
02016 }
02017
02018 return false;
02019 }
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029 function getUserIdByLogin($a_login)
02030 {
02031 global $ilias, $ilDB;
02032
02033 $query = "SELECT usr_id FROM usr_data ".
02034 "WHERE login = ".$ilDB->quote($a_login);
02035
02036 $row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
02037
02038 return $row->usr_id ? $row->usr_id : 0;
02039 }
02040
02049 function _getUserIdsByEmail($a_email)
02050 {
02051 global $ilias, $ilDB;
02052
02053 $query = "SELECT login FROM usr_data ".
02054 "WHERE email = ".$ilDB->quote($a_email)." and active=1";
02055
02056 $res = $ilias->db->query($query);
02057 $ids = array ();
02058 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
02059 {
02060 $ids[] = $row->login;
02061 }
02062
02063 return $ids;
02064 }
02065
02066
02067
02076 function getUserIdByEmail($a_email)
02077 {
02078 $query = "SELECT usr_id FROM usr_data ".
02079 "WHERE email = '".$a_email."'";
02080
02081 $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
02082 return $row->usr_id ? $row->usr_id : 0;
02083 }
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093 function getLoginByUserId($a_userid)
02094 {
02095 global $ilias;
02096
02097 $query = "SELECT login FROM usr_data ".
02098 "WHERE usr_id = '".$a_userid."'";
02099
02100 $row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
02101
02102 return $row->login ? $row->login : false;
02103 }
02104
02112 function searchUsers($a_search_str, $active = 1)
02113 {
02114
02115 global $ilias;
02116
02117
02118
02119 if (strtolower(substr($a_search_str, 0, 5)) == "role:")
02120 {
02121 $query = "SELECT DISTINCT usr_data.usr_id,usr_data.login,usr_data.firstname,usr_data.lastname,usr_data.email ".
02122 "FROM object_data,rbac_ua,usr_data ".
02123 "WHERE object_data.title LIKE '%".substr($a_search_str,5)."%' and object_data.type = 'role' ".
02124 "and rbac_ua.rol_id = object_data.obj_id ".
02125 "and usr_data.usr_id = rbac_ua.usr_id ".
02126 "AND rbac_ua.usr_id != '".ANONYMOUS_USER_ID."'";
02127 }
02128 else
02129 {
02130 $query = "SELECT usr_id,login,firstname,lastname,email,active FROM usr_data ".
02131 "WHERE (login LIKE '%".$a_search_str."%' ".
02132 "OR firstname LIKE '%".$a_search_str."%' ".
02133 "OR lastname LIKE '%".$a_search_str."%' ".
02134 "OR email LIKE '%".$a_search_str."%') ".
02135 "AND usr_id != '".ANONYMOUS_USER_ID."'";
02136 }
02137
02138 if (is_numeric($active) && $active > -1)
02139 $query .= "AND active = '$active'";
02140
02141 $res = $ilias->db->query($query);
02142 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
02143 {
02144 $ids[] = array(
02145 "usr_id" => $row->usr_id,
02146 "login" => $row->login,
02147 "firstname" => $row->firstname,
02148 "lastname" => $row->lastname,
02149 "email" => $row->email,
02150 "active" => $row->active);
02151 }
02152
02153 return $ids ? $ids : array();
02154 }
02155
02163 function _search(&$a_search_obj, $active=1)
02164 {
02165 global $ilBench;
02166
02167
02168
02169
02170
02171 $where_condition = $a_search_obj->getWhereCondition("like",array("login","firstname","lastname","title",
02172 "email","institution","street","city",
02173 "zipcode","country","phone_home","fax"));
02174 $in = $a_search_obj->getInStatement("usr_data.usr_id");
02175
02176 $query = "SELECT DISTINCT(usr_data.usr_id) FROM usr_data ".
02177 "LEFT JOIN usr_pref USING (usr_id) ".
02178 $where_condition." ".
02179 $in." ".
02180 "AND usr_data.usr_id != '".ANONYMOUS_USER_ID."' ";
02181 # "AND usr_pref.keyword = 'public_profile' ";
02182 # "AND usr_pref.value = 'y'";
02183
02184 if (is_numeric($active) && $active > -1)
02185 $query .= "AND active = '$active'";
02186
02187 $ilBench->start("Search", "ilObjUser_search");
02188 $res = $a_search_obj->ilias->db->query($query);
02189 $ilBench->stop("Search", "ilObjUser_search");
02190
02191 $counter = 0;
02192
02193 while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
02194 {
02195 $result_data[$counter++]["id"] = $row->usr_id;
02196
02197
02198
02199 #$result_data[$counter]["link"] = "profile.php?user=".$row->usr_id;
02200 #$result_data[$counter++]["target"] = "";
02201 }
02202 return $result_data ? $result_data : array();
02203 }
02204
02214 function _getLinkToObject($a_id)
02215 {
02216 return array("profile.php?user=".$a_id,"");
02217 }
02218
02219
02220
02221
02222
02223
02224 function getGroupMemberships($a_user_id = "")
02225 {
02226 global $rbacreview, $tree;
02227
02228 if (strlen($a_user_id) > 0)
02229 {
02230 $user_id = $a_user_id;
02231 }
02232 else
02233 {
02234 $user_id = $this->getId();
02235 }
02236
02237 $grp_memberships = array();
02238
02239
02240 $roles = $rbacreview->assignedRoles($user_id);
02241
02242 foreach ($roles as $role)
02243 {
02244 $ass_rolefolders = $rbacreview->getFoldersAssignedToRole($role);
02245
02246 foreach ($ass_rolefolders as $role_folder)
02247 {
02248 $node = $tree->getParentNodeData($role_folder);
02249
02250 if ($node["type"] == "grp")
02251 {
02252 $group =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
02253
02254 if ($group->isMember($user_id) == true && !in_array($group->getId(), $grp_memberships) )
02255 {
02256 array_push($grp_memberships, $group->getId());
02257 }
02258 }
02259
02260 unset($group);
02261 }
02262 }
02263
02264 return $grp_memberships;
02265 }
02266
02267
02276 function updateActiveRoles($a_user_id)
02277 {
02278 global $rbacreview, $ilDB;
02279
02280 if (!count($user_online = ilUtil::getUsersOnline($a_user_id)) == 1)
02281 {
02282 return false;
02283 }
02284
02285 $role_arr = $rbacreview->assignedRoles($a_user_id);
02286
02287 if ($_SESSION["AccountId"] == $a_user_id)
02288 {
02289 $_SESSION["RoleId"] = $role_arr;
02290 }
02291 else
02292 {
02293 $roles = "RoleId|".serialize($role_arr);
02294 $modified_data = preg_replace("/RoleId.*?;\}/",$roles,$user_online[$a_user_id]["data"]);
02295
02296 $q = "UPDATE usr_session SET data='".ilUtil::prepareDBString($modified_data)."' WHERE user_id = '".$a_user_id."'";
02297 $ilDB->query($q);
02298 }
02299
02300 return true;
02301 }
02302
02311 function _getAllUserLogins(&$ilias)
02312 {
02313 $query = "SELECT login FROM usr_data ";
02314
02315 $res = $ilias->db->query($query);
02316 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
02317 {
02318 $logins[] = $row->login;
02319 }
02320 return $logins ? $logins : array();
02321 }
02322
02331 function _getAllUserData($a_fields = NULL, $active =-1)
02332 {
02333 global $ilDB;
02334
02335 $result_arr = array();
02336
02337 if ($a_fields !== NULL and is_array($a_fields))
02338 {
02339 if (count($a_fields) == 0)
02340 {
02341 $select = "*";
02342 }
02343 else
02344 {
02345 if (($usr_id_field = array_search("usr_id",$a_fields)) !== false)
02346 unset($a_fields[$usr_id_field]);
02347
02348 $select = implode(",",$a_fields).",usr_data.usr_id";
02349
02350 if(in_array('online_time',$a_fields))
02351 {
02352 $select .= ",ut_online.online_time ";
02353 }
02354 }
02355
02356 $q = "SELECT ".$select." FROM usr_data ";
02357
02358
02359
02360 if(in_array('online_time',$a_fields))
02361 {
02362 $q .= "LEFT JOIN ut_online ON usr_data.usr_id = ut_online.usr_id ";
02363 }
02364
02365
02366 if (is_numeric($active) && $active > -1)
02367 $q .= "WHERE active='$active'";
02368
02369 $r = $ilDB->query($q);
02370
02371 while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
02372 {
02373 $result_arr[] = $row;
02374 }
02375 }
02376
02377 return $result_arr;
02378 }
02379
02383 function _getNumberOfUsersForStyle($a_skin, $a_style)
02384 {
02385 global $ilDB;
02386
02387 $q = "SELECT count(*) as cnt FROM usr_pref AS up1, usr_pref AS up2 ".
02388 " WHERE up1.keyword= ".$ilDB->quote("style")." AND up1.value= ".$ilDB->quote($a_style).
02389 " AND up2.keyword= ".$ilDB->quote("skin")." AND up2.value= ".$ilDB->quote($a_skin).
02390 " AND up1.usr_id = up2.usr_id ";
02391
02392 $cnt_set = $ilDB->query($q);
02393
02394 $cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);
02395
02396 return $cnt_rec["cnt"];
02397 }
02398
02402 function _getAllUserAssignedStyles()
02403 {
02404 global $ilDB;
02405
02406 $q = "SELECT DISTINCT up1.value as style, up2.value as skin FROM usr_pref AS up1, usr_pref AS up2 ".
02407 " WHERE up1.keyword= ".$ilDB->quote("style").
02408 " AND up2.keyword= ".$ilDB->quote("skin").
02409 " AND up1.usr_id = up2.usr_id ";
02410
02411
02412 $sty_set = $ilDB->query($q);
02413
02414 $styles = array();
02415 while($sty_rec = $sty_set->fetchRow(DB_FETCHMODE_ASSOC))
02416 {
02417 $styles[] = $sty_rec["skin"].":".$sty_rec["style"];
02418 }
02419
02420 return $styles;
02421 }
02422
02426 function _moveUsersToStyle($a_from_skin, $a_from_style, $a_to_skin, $a_to_style)
02427 {
02428 global $ilDB;
02429
02430 $q = "SELECT up1.usr_id as usr_id FROM usr_pref AS up1, usr_pref AS up2 ".
02431 " WHERE up1.keyword= ".$ilDB->quote("style")." AND up1.value= ".$ilDB->quote($a_from_style).
02432 " AND up2.keyword= ".$ilDB->quote("skin")." AND up2.value= ".$ilDB->quote($a_from_skin).
02433 " AND up1.usr_id = up2.usr_id ";
02434
02435 $usr_set = $ilDB->query($q);
02436
02437 while ($usr_rec = $usr_set->fetchRow(DB_FETCHMODE_ASSOC))
02438 {
02439 ilObjUser::_writePref($usr_rec["usr_id"], "skin", $a_to_skin);
02440 ilObjUser::_writePref($usr_rec["usr_id"], "style", $a_to_style);
02441 }
02442 }
02443
02451 function addDesktopItem($a_item_id, $a_type, $a_par = "")
02452 {
02453 $q = "SELECT * FROM desktop_item WHERE ".
02454 "item_id = '$a_item_id' AND type = '$a_type' AND user_id = '".
02455 $this->getId()."'";
02456 $item_set = $this->ilias->db->query($q);
02457
02458
02459 if (!$d = $item_set->fetchRow())
02460 {
02461 $q = "INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ".
02462 " ('$a_item_id','$a_type','".$this->getId()."' , '$a_par')";
02463 $this->ilias->db->query($q);
02464 }
02465 }
02466
02475 function setDesktopItemParameters($a_item_id, $a_type, $a_par)
02476 {
02477 $q = "UPDATE desktop_item SET parameters = '$a_par' ".
02478 " WHERE item_id = '$a_item_id' AND type = '$a_type' ".
02479 " AND user_id = '".$this->getId()."' ";
02480 $this->ilias->db->query($q);
02481 }
02482
02490 function dropDesktopItem($a_item_id, $a_type)
02491 {
02492 $q = "DELETE FROM desktop_item WHERE ".
02493 " item_id = '$a_item_id' AND".
02494 " type = '$a_type' AND".
02495 " user_id = '".$this->getId()."'";
02496 $this->ilias->db->query($q);
02497 }
02498
02506 function isDesktopItem($a_item_id, $a_type)
02507 {
02508 $q = "SELECT * FROM desktop_item WHERE ".
02509 "item_id = '$a_item_id' AND type = '$a_type' AND user_id = '".
02510 $this->getId()."'";
02511 $item_set = $this->ilias->db->query($q);
02512
02513 if ($d = $item_set->fetchRow())
02514 {
02515 return true;
02516 }
02517 else
02518 {
02519 return false;
02520 }
02521 }
02522
02529 function getDesktopItems($a_types = "")
02530 {
02531 global $ilUser, $rbacsystem, $tree;
02532
02533
02534 if ($a_types == "")
02535 {
02536 $q = "SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ".
02537 " FROM desktop_item AS it, object_reference AS oref ".
02538 ", object_data AS obj".
02539 " WHERE ".
02540 "it.item_id = oref.ref_id AND ".
02541 "oref.obj_id = obj.obj_id AND ".
02542 "it.user_id = '".$this->getId()."'";
02543
02544 $item_set = $this->ilias->db->query($q);
02545 $items = array();
02546 while ($item_rec = $item_set->fetchRow(DB_FETCHMODE_ASSOC))
02547 {
02548 if ($tree->isInTree($item_rec["ref_id"]))
02549 {
02550 $parent_ref = $tree->getParentId($item_rec["ref_id"]);
02551 $par_left = $tree->getLeftValue($parent_ref);
02552 $par_left = sprintf("%010d", $par_left);
02553 $items[$par_left.$item_rec["title"].$item_rec["ref_id"]] =
02554 array("ref_id" => $item_rec["ref_id"],
02555 "obj_id" => $item_rec["obj_id"],
02556 "type" => $item_rec["type"],
02557 "title" => $item_rec["title"],
02558 "description" => $item_rec["description"],
02559 "parent_ref" => $parent_ref);
02560 }
02561 }
02562 ksort($items);
02563 }
02564 else
02565 {
02566 if (!is_array($a_types))
02567 {
02568 $a_types = array($a_types);
02569 }
02570 $items = array();
02571 $foundsurveys = array();
02572 foreach($a_types as $a_type)
02573 {
02574 $q = "SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item AS it, object_reference AS oref ".
02575 ", object_data AS obj WHERE ".
02576 "it.item_id = oref.ref_id AND ".
02577 "oref.obj_id = obj.obj_id AND ".
02578 "it.type = '$a_type' AND ".
02579 "it.user_id = '".$this->getId()."' ".
02580 "ORDER BY title";
02581
02582 $item_set = $this->ilias->db->query($q);
02583 while ($item_rec = $item_set->fetchRow(DB_FETCHMODE_ASSOC))
02584 {
02585 $items[$item_rec["title"].$a_type.$item_rec["ref_id"]] =
02586 array("ref_id" => $item_rec["ref_id"],
02587 "obj_id" => $item_rec["obj_id"], "type" => $a_type,
02588 "title" => $item_rec["title"], "description" => $item_rec["description"]);
02589 }
02590
02591 }
02592 ksort($items);
02593 }
02594 return $items;
02595 }
02596
02604 function addObjectToClipboard($a_item_id, $a_type, $a_title)
02605 {
02606 $q = "SELECT * FROM personal_clipboard WHERE ".
02607 "item_id = '$a_item_id' AND type = '$a_type' AND user_id = '".
02608 $this->getId()."'";
02609 $item_set = $this->ilias->db->query($q);
02610
02611
02612 if (!$d = $item_set->fetchRow())
02613 {
02614 $q = "INSERT INTO personal_clipboard (item_id, type, user_id, title) VALUES ".
02615 " ('$a_item_id','$a_type','".$this->getId()."', '".$a_title."')";
02616 $this->ilias->db->query($q);
02617 }
02618 }
02619
02623 function getClipboardObjects($a_type = "")
02624 {
02625 $type_str = ($a_type != "")
02626 ? " AND type = '$a_type' "
02627 : "";
02628 $q = "SELECT * FROM personal_clipboard WHERE ".
02629 "user_id = '".$this->getId()."' ".
02630 $type_str;
02631 $objs = $this->ilias->db->query($q);
02632 $objects = array();
02633 while ($obj = $objs->fetchRow(DB_FETCHMODE_ASSOC))
02634 {
02635 if ($obj["type"] == "mob")
02636 {
02637 $obj["title"] = ilObject::_lookupTitle($obj["item_id"]);
02638 }
02639 $objects[] = array ("id" => $obj["item_id"],
02640 "type" => $obj["type"], "title" => $obj["title"]);
02641 }
02642 return $objects;
02643 }
02644
02653 function _getUsersForClipboadObject($a_type, $a_id)
02654 {
02655 global $ilDB;
02656
02657 $q = "SELECT DISTINCT user_id FROM personal_clipboard WHERE ".
02658 "item_id = '$a_id' AND ".
02659 "type = '$a_type'";
02660 $user_set = $ilDB->query($q);
02661 $users = array();
02662 while ($user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC))
02663 {
02664 $users[] = $user_rec["user_id"];
02665 }
02666
02667 return $users;
02668 }
02669
02677 function removeObjectFromClipboard($a_item_id, $a_type)
02678 {
02679 $q = "DELETE FROM personal_clipboard WHERE ".
02680 "item_id = '$a_item_id' AND type = '$a_type' ".
02681 " AND user_id = '".$this->getId()."'";
02682 $this->ilias->db->query($q);
02683 }
02684
02685 function _getImportedUserId($i2_id)
02686 {
02687 $query = "SELECT obj_id FROM object_data WHERE import_id = '".$i2_id."'";
02688
02689 $res = $this->ilias->db->query($query);
02690 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
02691 {
02692 $id = $row->obj_id;
02693 }
02694 return $id ? $id : 0;
02695 }
02696
02697
02698
02699
02700
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02719 function setAuthMode($a_str)
02720 {
02721 $this->auth_mode = $a_str;
02722 }
02723
02728 function getAuthMode($a_auth_key = false)
02729 {
02730 if (!$a_auth_key)
02731 {
02732 return $this->auth_mode;
02733 }
02734
02735 include_once('classes/class.ilAuthUtils.php');
02736 return ilAuthUtils::_getAuthMode($this->auth_mode);
02737 }
02738
02746 function setExternalAccount($a_str)
02747 {
02748 $this->ext_account = $a_str;
02749 }
02750
02758 function getExternalAccount()
02759 {
02760 return $this->ext_account;
02761 }
02762
02768 function _checkExternalAuthAccount($a_auth, $a_account)
02769 {
02770 global $ilDB;
02771
02772 $r = $ilDB->query("SELECT * FROM usr_data WHERE ".
02773 " ext_account = ".$ilDB->quote($a_account)." AND ".
02774 " auth_mode = ".$ilDB->quote($a_auth));
02775 if ($usr = $r->fetchRow(DB_FETCHMODE_ASSOC))
02776 {
02777 return $usr["login"];
02778 }
02779 else
02780 {
02781 return false;
02782 }
02783 }
02784
02788 function _getNumberOfUsersPerAuthMode()
02789 {
02790 global $ilDB;
02791
02792 $r = $ilDB->query("SELECT count(*) AS cnt, auth_mode FROM usr_data ".
02793 "GROUP BY auth_mode");
02794 $cnt_arr = array();
02795 while($cnt = $r->fetchRow(DB_FETCHMODE_ASSOC))
02796 {
02797 $cnt_arr[$cnt["auth_mode"]] = $cnt["cnt"];
02798 }
02799
02800 return $cnt_arr;
02801 }
02802
02808 function _getLocalAccountsForEmail($a_email)
02809 {
02810 global $ilDB, $ilSetting;
02811
02812
02813 $or_str = "";
02814 if ($ilSetting->get("auth_mode") == 1)
02815 {
02816 $or_str = " OR auth_mode = ".$ilDB->quote("default");
02817 }
02818
02819 $usr_set = $ilDB->query("SELECT * FROM usr_data WHERE ".
02820 " email = ".$ilDB->quote($a_email)." AND ".
02821 " (auth_mode = ".$ilDB->quote("local").$or_str.")");
02822
02823 $users = array();
02824
02825 while ($usr_rec = $usr_set->fetchRow(DB_FETCHMODE_ASSOC))
02826 {
02827 $users[$usr_rec["usr_id"]] = $usr_rec["login"];
02828 }
02829
02830 return $users;
02831 }
02832
02833
02841 function _uploadPersonalPicture($tmp_file, $obj_id)
02842 {
02843 $webspace_dir = ilUtil::getWebspaceDir();
02844 $image_dir = $webspace_dir."/usr_images";
02845 $store_file = "usr_".$obj_id."."."jpg";
02846 $target_file = $image_dir."/$store_file";
02847
02848 chmod($tmp_file, 0770);
02849
02850
02851
02852 $show_file = "$image_dir/usr_".$obj_id.".jpg";
02853 $thumb_file = "$image_dir/usr_".$obj_id."_small.jpg";
02854 $xthumb_file = "$image_dir/usr_".$obj_id."_xsmall.jpg";
02855 $xxthumb_file = "$image_dir/usr_".$obj_id."_xxsmall.jpg";
02856
02857 system(ilUtil::getConvertCmd()." $tmp_file" . "[0] -geometry 200x200 -quality 100 JPEG:$show_file");
02858 system(ilUtil::getConvertCmd()." $tmp_file" . "[0] -geometry 100x100 -quality 100 JPEG:$thumb_file");
02859 system(ilUtil::getConvertCmd()." $tmp_file" . "[0] -geometry 75x75 -quality 100 JPEG:$xthumb_file");
02860 system(ilUtil::getConvertCmd()." $tmp_file" . "[0] -geometry 30x30 -quality 100 JPEG:$xxthumb_file");
02861
02862
02863 ilObjUser::_writePref($obj_id, "profile_image", $store_file);
02864
02865 return TRUE;
02866 }
02867
02873 function getPersonalPicturePath($a_size = "small", $a_force_pic = false)
02874 {
02875 return ilObjUser::_getPersonalPicturePath($this->getId(),$a_size,$a_force_pic);
02876 }
02877
02884 function _getPersonalPicturePath($a_usr_id,$a_size = "small", $a_force_pic = false)
02885 {
02886 global $ilDB;
02887
02888 $query = "SELECT * FROM usr_pref WHERE ".
02889 "keyword = 'public_upload' ".
02890 "AND value = 'y' ".
02891 "AND usr_id = '".$a_usr_id."'";
02892
02893 $res = $ilDB->query($query);
02894 $upload = $res->numRows() ? true : false;
02895
02896 $query = "SELECT * FROM usr_pref WHERE ".
02897 "keyword = 'public_profile' ".
02898 "AND value = 'y' ".
02899 "AND usr_id = '".$a_usr_id."'";
02900
02901 $res = $ilDB->query($query);
02902 $profile = $res->numRows() ? true : false;
02903
02904 if(defined('ILIAS_MODULE'))
02905 {
02906 $webspace_dir = ('.'.$webspace_dir);
02907 }
02908 $webspace_dir .= ('./'.ilUtil::getWebspaceDir());
02909
02910 $image_dir = $webspace_dir."/usr_images";
02911 $thumb_file = $image_dir."/usr_".$a_usr_id."_".$a_size.".jpg";
02912
02913 if((($upload && $profile) || $a_force_pic)
02914 && @is_file($thumb_file))
02915 {
02916 $file = $thumb_file."?t=".rand(1, 99999);
02917 }
02918 else
02919 {
02920 $file = ilUtil::getImagePath("no_photo_".$a_size.".jpg");
02921 }
02922
02923 return $file;
02924 }
02925
02926 function setUserDefinedData($a_data)
02927 {
02928 if(!is_array($a_data))
02929 {
02930 return false;
02931 }
02932 foreach($a_data as $field => $data)
02933 {
02934 $new_data[$field] = ilUtil::stripSlashes($data);
02935 }
02936 $this->user_defined_data = $new_data;
02937
02938 return true;
02939 }
02940
02941 function getUserDefinedData()
02942 {
02943 return $this->user_defined_data ? $this->user_defined_data : array();
02944 }
02945
02946 function updateUserDefinedFields()
02947 {
02948 $fields = '';
02949
02950 foreach($this->user_defined_data as $field => $value)
02951 {
02952 if($field != 'usr_id')
02953 {
02954 $fields .= ("`".$field."` = '".ilUtil::prepareDBString($value)."', ");
02955 }
02956 }
02957
02958 $query = "REPLACE INTO usr_defined_data ".
02959 "SET ".$fields." ".
02960 "usr_id = '".$this->getId()."'";
02961
02962 $this->db->query($query);
02963 return true;
02964 }
02965
02966 function readUserDefinedFields()
02967 {
02968 $query = "SELECT * FROM usr_defined_data ".
02969 "WHERE usr_id = '".$this->getId()."'";
02970
02971 $res = $this->db->query($query);
02972 while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
02973 {
02974 $this->user_defined_data = $row;
02975 }
02976 return true;
02977 }
02978
02979 function addUserDefinedFieldEntry()
02980 {
02981 $query = "INSERT INTO usr_defined_data ".
02982 "SET usr_id = '".$this->getId()."'";
02983 $this->db->query($query);
02984
02985 return true;
02986 }
02987
02988 function deleteUserDefinedFieldEntries()
02989 {
02990 $query = "DELETE FROM usr_defined_data ".
02991 "WHERE usr_id = '".$this->getId()."'";
02992 $this->db->query($query);
02993
02994 return true;
02995 }
02996
03002 function getProfileAsString(&$a_language,$a_with_access_limits = true)
03003 {
03004 include_once 'classes/class.ilObjRole.php';
03005
03006 global $lng,$rbacreview;
03007
03008 $language =& $a_language;
03009 $language->loadLanguageModule('registration');
03010 $language->loadLanguageModule('crs');
03011
03012 $body = '';
03013 $body .= ($language->txt("login").": ".$this->getLogin()."\n");
03014
03015 if(strlen($this->getUTitle()))
03016 {
03017 $body .= ($language->txt("title").": ".$this->getUTitle()."\n");
03018 }
03019 if(strlen($this->getGender()))
03020 {
03021 $gender = ($this->getGender() == 'm') ?
03022 $language->txt('gender_m') :
03023 $language->txt('gender_f');
03024 $body .= ($language->txt("gender").": ".$gender."\n");
03025 }
03026 if(strlen($this->getFirstname()))
03027 {
03028 $body .= ($language->txt("firstname").": ".$this->getFirstname()."\n");
03029 }
03030 if(strlen($this->getLastname()))
03031 {
03032 $body .= ($language->txt("lastname").": ".$this->getLastname()."\n");
03033 }
03034 if(strlen($this->getInstitution()))
03035 {
03036 $body .= ($language->txt("institution").": ".$this->getInstitution()."\n");
03037 }
03038 if(strlen($this->getDepartment()))
03039 {
03040 $body .= ($language->txt("department").": ".$this->getDepartment()."\n");
03041 }
03042 if(strlen($this->getStreet()))
03043 {
03044 $body .= ($language->txt("street").": ".$this->getStreet()."\n");
03045 }
03046 if(strlen($this->getCity()))
03047 {
03048 $body .= ($language->txt("city").": ".$this->getCity()."\n");
03049 }
03050 if(strlen($this->getZipcode()))
03051 {
03052 $body .= ($language->txt("zipcode").": ".$this->getZipcode()."\n");
03053 }
03054 if(strlen($this->getCountry()))
03055 {
03056 $body .= ($language->txt("country").": ".$this->getCountry()."\n");
03057 }
03058 if(strlen($this->getPhoneOffice()))
03059 {
03060 $body .= ($language->txt("phone_office").": ".$this->getPhoneOffice()."\n");
03061 }
03062 if(strlen($this->getPhoneHome()))
03063 {
03064 $body .= ($language->txt("phone_home").": ".$this->getPhoneHome()."\n");
03065 }
03066 if(strlen($this->getPhoneMobile()))
03067 {
03068 $body .= ($language->txt("phone_mobile").": ".$this->getPhoneMobile()."\n");
03069 }
03070 if(strlen($this->getFax()))
03071 {
03072 $body .= ($language->txt("fax").": ".$this->getFax()."\n");
03073 }
03074 if(strlen($this->getEmail()))
03075 {
03076 $body .= ($language->txt("email").": ".$this->getEmail()."\n");
03077 }
03078 if(strlen($this->getHobby()))
03079 {
03080 $body .= ($language->txt("hobby").": ".$this->getHobby()."\n");
03081 }
03082 if(strlen($this->getComment()))
03083 {
03084 $body .= ($language->txt("referral_comment").": ".$this->getComment()."\n");
03085 }
03086 if(strlen($this->getMatriculation()))
03087 {
03088 $body .= ($language->txt("matriculation").": ".$this->getMatriculation()."\n");
03089 }
03090 if(strlen($this->getCreateDate()))
03091 {
03092 $body .= ($language->txt("create_date").": ".$this->getCreateDate()."\n");
03093 }
03094
03095 foreach($rbacreview->getGlobalRoles() as $role)
03096 {
03097 if($rbacreview->isAssigned($this->getId(),$role))
03098 {
03099 $gr[] = ilObjRole::_lookupTitle($role);
03100 }
03101 }
03102 if(count($gr))
03103 {
03104 $body .= ($language->txt('reg_role_info').': '.implode(',',$gr)."\n");
03105 }
03106
03107
03108 if($a_with_access_limits)
03109 {
03110 if($this->getTimeLimitUnlimited())
03111 {
03112 $body .= ($language->txt('time_limit').": ".$language->txt('crs_unlimited')."\n");
03113 }
03114 else
03115 {
03116 $body .= ($language->txt('time_limit').": ".$language->txt('crs_from')." ".
03117 strftime('%c',$this->getTimeLimitFrom())." ".
03118 $language->txt('crs_to')." ".
03119 strftime('%c',$this->getTimeLimitUntil())."\n");
03120 }
03121 }
03122 return $body;
03123 }
03124 }
03125 ?>