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
00034 require_once "include/inc.header.php";
00035 require_once "classes/class.ilUserAgreement.php";
00036
00037
00038 if (!$ilias->getSetting("enable_registration"))
00039 {
00040 #if (empty($_SESSION["AccountId"]) and $_SESSION["AccountId"] !== false)
00041 #{
00042 $ilErr->raiseError($lng->txt('permission_denied'),$ilErr->FATAL);
00043 #}
00044 }
00045
00046 switch ($_GET["cmd"])
00047 {
00048 case "save":
00049 saveForm();
00050 break;
00051
00052 case "login":
00053 loginPage();
00054 break;
00055
00056 default:
00057 displayForm();
00058 break;
00059 }
00060
00061 function loginPage()
00062 {
00063 global $tpl,$ilias,$lng;
00064
00065 $tpl->addBlockFile("CONTENT", "content", "tpl.usr_registered.html");
00066 $tpl->setVariable("FORMACTION","login.php");
00067 $tpl->setVariable("TARGET","target=\"_parent\"");
00068 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("registration"));
00069 $tpl->setVariable("TXT_WELCOME", $lng->txt("welcome").", ".urldecode(ilUtil::stripSlashes($_GET["name"]))."!");
00070 if ($ilias->getSetting("auto_registration"))
00071 {
00072 $tpl->setVariable("TXT_REGISTERED", $lng->txt("txt_registered"));
00073 }
00074 else
00075 {
00076 $tpl->setVariable("TXT_REGISTERED", $lng->txt("txt_submitted"));
00077 }
00078 $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
00079 $tpl->setVariable("USERNAME", base64_decode($_GET["user"]));
00080 $tpl->setVariable("PASSWORD", base64_decode($_GET["pass"]));
00081
00082 $ilias->auth->logout();
00083 session_destroy();
00084
00085 $tpl->show();
00086 }
00087
00088 function saveForm()
00089 {
00090 global $tpl, $ilias, $lng, $rbacadmin, $ilDB, $ilErr;
00091
00092
00093 $settings = $ilias->getAllSettings();
00094
00095
00096
00097
00098
00099
00100 if (! ($_POST["status"]=="accepted") )
00101 {
00102 $ilias->raiseError($lng->txt("force_accept_usr_agreement"),$ilias->error_obj->MESSAGE);
00103 }
00104
00105
00106 foreach ($settings as $key => $val)
00107 {
00108 if (substr($key,0,8) == "require_")
00109 {
00110 if ($settings["passwd_auto_generate"] == 1 and ($key == "require_passwd" or $key == "require_passwd2"))
00111 {
00112 continue;
00113 }
00114
00115 $require_keys[] = substr($key,8);
00116 }
00117 }
00118
00119 foreach ($require_keys as $key => $val)
00120 {
00121 if (isset($settings["require_" . $val]) && $settings["require_" . $val])
00122 {
00123 if (empty($_POST["Fobject"][$val]))
00124 {
00125 $ilias->raiseError($lng->txt("fill_out_all_required_fields") . ": " . $lng->txt($val),$ilias->error_obj->MESSAGE);
00126 }
00127 }
00128 }
00129
00130
00131 if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
00132 {
00133 $ilias->raiseError($lng->txt("login_invalid"),$ilias->error_obj->MESSAGE);
00134 }
00135
00136
00137 if (loginExists($_POST["Fobject"]["login"]))
00138 {
00139 $ilias->raiseError($lng->txt("login_exists"),$ilias->error_obj->MESSAGE);
00140 }
00141
00142 if ($settings["passwd_auto_generate"] != 1)
00143 {
00144
00145 if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
00146 {
00147 $ilias->raiseError($lng->txt("passwd_not_match"),$ilias->error_obj->MESSAGE);
00148 }
00149
00150
00151 if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
00152 {
00153 $ilias->raiseError($lng->txt("passwd_invalid"),$ilias->error_obj->MESSAGE);
00154 }
00155 }
00156 else
00157 {
00158 $passwd = ilUtil::generatePasswords(1);
00159 $_POST["Fobject"]["passwd"] = $passwd[0];
00160 }
00161
00162
00163 require_once "classes/class.ilObjUser.php";
00164 $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
00165
00166
00167 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
00168 {
00169 $ilias->raiseError($lng->txt("email_not_valid"),$ilias->error_obj->MESSAGE);
00170 }
00171
00172
00173 include_once("classes/class.ilObjRole.php");
00174 if (!ilObjRole::_lookupAllowRegister($_POST["Fobject"]["default_role"]))
00175 {
00176 $ilias->raiseError("Invalid role selection in registration: ".
00177 ilObject::_lookupTitle($_POST["Fobject"]["default_role"])." [".$_POST["Fobject"]["default_role"]."]".
00178 ", IP: ".$_SERVER["REMOTE_ADDR"],$ilias->error_obj->FATAL);
00179 }
00180
00181
00182 $auth_mode = ilObjRole::_getAuthMode($_POST["Fobject"]["default_role"]);
00183 $_POST["Fobject"]['auth_mode'] = $auth_mode;
00184
00185
00186
00187
00188
00189 if ($auth_mode == "radius")
00190 {
00191 $_POST['username'] = $_POST["Fobject"]["login"];
00192 $_POST['password'] = $_POST["Fobject"]["passwd"];
00193 include_once('classes/class.ilRADIUSAuthentication.php');
00194 $radius_servers = ilRADIUSAuthentication::_getServers($ilDB);
00195 $settings = $ilias->getAllSettings();
00196
00197 foreach ($radius_servers as $radius_server)
00198 {
00199 $rad_params['servers'][] = array($radius_server,$settings["radius_port"],$settings["radius_shared_secret"]);
00200 }
00201 $auth = new Auth("RADIUS", $rad_params,"",false);
00202 $auth->start();
00203 $err = $ilErr->getLastError();
00204 if (!$auth->getAuth())
00205 {
00206 $add = (!is_object($err))
00207 ? ""
00208 : "<br>".$err->getMessage();
00209 $ilias->raiseError($lng->txt("could_not_verify_account").
00210 $add, $ilErr->MESSAGE);
00211 }
00212 }
00213
00214
00215
00216
00217
00218
00219 $userObj = new ilObjUser();
00220 $userObj->assignData($_POST["Fobject"]);
00221 $userObj->setTitle($userObj->getFullname());
00222 $userObj->setDescription($userObj->getEmail());
00223
00224
00225 $userObj->setTimeLimitOwner(7);
00226 $userObj->setTimeLimitUnlimited(1);
00227 $userObj->setTimeLimitFrom(time());
00228 $userObj->setTimeLimitUntil(time());
00229
00230 $userObj->create();
00231
00232 if (isset($settings["auto_registration"]) && ($settings["auto_registration"] == 1))
00233 {
00234 $userObj->setActive(1, 6);
00235 }
00236 else
00237 {
00238 $userObj->setActive(0, 0);
00239 }
00240
00241 $userObj->updateOwner();
00242
00243
00244 $userObj->saveAsNew();
00245
00246
00247 $userObj->writeAccepted();
00248
00249
00250 $userObj->setLanguage($_POST["Fobject"]["language"]);
00251 $userObj->setPref("hits_per_page", $ilias->getSetting("hits_per_page"));
00252 $userObj->setPref("show_users_online", $ilias->getSetting("show_users_online"));
00253 $userObj->writePrefs();
00254
00255
00256 $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 if (!$ilias->getSetting("auto_registration"))
00274 {
00275 $approve_recipient = $ilias->getSetting("approve_recipient");
00276 if (empty($approve_recipient))
00277 {
00278 $approve_recipient = $userObj->getLoginByUserId(6);
00279 }
00280
00281 include_once "classes/class.ilFormatMail.php";
00282
00283 $umail = new ilFormatMail($userObj->getId());
00284
00285
00286 $subject = $lng->txt("client_id") . " " . $ilias->client_id . ": " . $lng->txt("usr_new");
00287
00288
00289 $body = $lng->txt("login").": ".$userObj->getLogin()."\n\r".
00290 $lng->txt("title").": ".$userObj->getTitle()."\n\r".
00291 $lng->txt("gender").": ".$userObj->getGender()."\n\r".
00292 $lng->txt("firstname").": ".$userObj->getFirstname()."\n\r".
00293 $lng->txt("lastname").": ".$userObj->getLastname()."\n\r".
00294 $lng->txt("institution").": ".$userObj->getInstitution()."\n\r".
00295 $lng->txt("department").": ".$userObj->getDepartment()."\n\r".
00296 $lng->txt("street").": ".$userObj->getStreet()."\n\r".
00297 $lng->txt("city").": ".$userObj->getCity()."\n\r".
00298 $lng->txt("zipcode").": ".$userObj->getZipcode()."\n\r".
00299 $lng->txt("country").": ".$userObj->getCountry()."\n\r".
00300 $lng->txt("phone_office").": ".$userObj->getPhoneOffice()."\n\r".
00301 $lng->txt("phone_home").": ".$userObj->getPhoneHome()."\n\r".
00302 $lng->txt("phone_mobile").": ".$userObj->getPhoneMobile()."\n\r".
00303 $lng->txt("fax").": ".$userObj->getFax()."\n\r".
00304 $lng->txt("email").": ".$userObj->getEmail()."\n\r".
00305 $lng->txt("hobby").": ".$userObj->getHobby()."\n\r".
00306 $lng->txt("referral_comment").": ".$userObj->getComment()."\n\r".
00307 $lng->txt("matriculation").": ".$userObj->getMatriculation()."\n\r".
00308 $lng->txt("create_date").": ".$userObj->getCreateDate()."\n\r".
00309 $lng->txt("default_role").": ".$_POST["Fobject"]["default_role"]."\n\r";
00310
00311 $error_message = $umail->sendMail($approve_recipient,"","",$subject,$body,array(),array("normal"));
00312 }
00313
00314 if ($settings["passwd_auto_generate"] == 1)
00315 {
00316 include_once "classes/class.ilMimeMail.php";
00317
00318 $mmail = new ilMimeMail();
00319 $mmail->autoCheck(false);
00320 $mmail->From($settings["admin_email"]);
00321 $mmail->To($userObj->getEmail());
00322
00323
00324 $subject = $lng->txt("reg_mail_subject");
00325
00326
00327 $body = $lng->txt("reg_mail_body_salutation")." ".$userObj->getFullname().",\n\r".
00328 $lng->txt("reg_mail_body_welcome")."\n\r".
00329 $lng->txt("reg_mail_body_text1")."\n\r".
00330 $lng->txt("reg_mail_body_text2")."\n\r".
00331 ILIAS_HTTP_PATH."login.php?client_id=".$ilias->client_id."\n\r".
00332 $lng->txt("login").": ".$userObj->getLogin()."\n\r".
00333 $lng->txt("passwd").": ".$_POST["Fobject"]["passwd"]."\n\r\n\r".
00334 $lng->txt("reg_mail_body_text3")."\n\r".
00335 $lng->txt("title").": ".$userObj->getTitle()."\n\r".
00336 $lng->txt("gender").": ".$userObj->getGender()."\n\r".
00337 $lng->txt("firstname").": ".$userObj->getFirstname()."\n\r".
00338 $lng->txt("lastname").": ".$userObj->getLastname()."\n\r".
00339 $lng->txt("institution").": ".$userObj->getInstitution()."\n\r".
00340 $lng->txt("department").": ".$userObj->getDepartment()."\n\r".
00341 $lng->txt("street").": ".$userObj->getStreet()."\n\r".
00342 $lng->txt("city").": ".$userObj->getCity()."\n\r".
00343 $lng->txt("zipcode").": ".$userObj->getZipcode()."\n\r".
00344 $lng->txt("country").": ".$userObj->getCountry()."\n\r".
00345 $lng->txt("phone_office").": ".$userObj->getPhoneOffice()."\n\r".
00346 $lng->txt("phone_home").": ".$userObj->getPhoneHome()."\n\r".
00347 $lng->txt("phone_mobile").": ".$userObj->getPhoneMobile()."\n\r".
00348 $lng->txt("fax").": ".$userObj->getFax()."\n\r".
00349 $lng->txt("email").": ".$userObj->getEmail()."\n\r".
00350 $lng->txt("hobby").": ".$userObj->getHobby()."\n\r".
00351 $lng->txt("referral_comment").": ".$userObj->getComment()."\n\r".
00352 $lng->txt("create_date").": ".$userObj->getCreateDate()."\n\r".
00353 $lng->txt("default_role").": ".$_POST["Fobject"]["default_role"]."\n\r";
00354
00355 $mmail->Subject($subject);
00356 $mmail->Body($body);
00357 $mmail->Send();
00358 }
00359
00360 ilUtil::redirect("register.php?lang=".$_GET["lang"]."&cmd=login&user=".base64_encode($_POST["Fobject"]["login"])."&pass=".base64_encode($_POST["Fobject"]["passwd"])."&name=".urlencode(ilUtil::stripSlashes($userObj->getFullname())));
00361 }
00362
00363
00364 function displayForm()
00365 {
00366 global $tpl,$ilias,$lng,$ObjDefinition;
00367
00368
00369 $settings = $ilias->getAllSettings();
00370
00371
00372 $tpl->addBlockFile("CONTENT", "content", "tpl.usr_registration.html");
00373 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00374
00375
00376
00377
00378
00379 include_once("classes/class.ilObjRole.php");
00380 $reg_roles = ilObjRole::_lookupRegisterAllowed();
00381
00382 $rol = array();
00383 foreach ($reg_roles as $role)
00384 {
00385 $rol[$role["id"]] = $role["title"];
00386 }
00387
00388 $role = ilUtil::formSelect($_SESSION["error_post_vars"]["Fobject"]["default_role"],"Fobject[default_role]",$rol,false,true);
00389
00390 $data = array();
00391 $data["fields"] = array();
00392 $data["fields"]["login"] = "";
00393
00394 if ($settings["passwd_auto_generate"] != 1)
00395 {
00396 $data["fields"]["passwd"] = "";
00397 $data["fields"]["passwd2"] = "";
00398 }
00399
00400 $data["fields"]["title"] = "";
00401 $data["fields"]["gender"] = "";
00402 $data["fields"]["firstname"] = "";
00403 $data["fields"]["lastname"] = "";
00404 $data["fields"]["institution"] = "";
00405 $data["fields"]["department"] = "";
00406 $data["fields"]["street"] = "";
00407 $data["fields"]["city"] = "";
00408 $data["fields"]["zipcode"] = "";
00409 $data["fields"]["country"] = "";
00410 $data["fields"]["phone_office"] = "";
00411 $data["fields"]["phone_home"] = "";
00412 $data["fields"]["phone_mobile"] = "";
00413 $data["fields"]["fax"] = "";
00414 $data["fields"]["email"] = "";
00415 $data["fields"]["hobby"] = "";
00416 $data["fields"]["referral_comment"] = "";
00417 $data["fields"]["matriculation"] = "";
00418 $data["fields"]["default_role"] = $role;
00419
00420
00421 foreach ($data["fields"] as $key => $val)
00422 {
00423 $str = $lng->txt($key);
00424 if ($key == "title")
00425 {
00426 $str = $lng->txt("person_title");
00427 }
00428
00429 if (!in_array($key, array("default_role", "login", "passwd", "passwd2",
00430 "firstname", "lastname", "gender")))
00431 {
00432 if ($settings["usr_settings_hide_".$key] != 1)
00433 {
00434 $tpl->setCurrentBlock($key."_section");
00435
00436 }
00437 else
00438 {
00439 continue;
00440 }
00441 }
00442
00443
00444 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00445 {
00446 $str = $str . '<span class="asterisk">*</span>';
00447 }
00448
00449 $tpl->setVariable("TXT_".strtoupper($key), $str);
00450
00451
00452 if ($key == "default_role")
00453 {
00454 $tpl->setVariable(strtoupper($key), $val);
00455 }
00456 else
00457 {
00458 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00459 {
00460 $val = $_SESSION["error_post_vars"]["Fobject"][$key];
00461 }
00462 $tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
00463
00464 }
00465
00466 if (!in_array($key, array("default_role", "login", "passwd", "passwd2",
00467 "firstname", "lastname", "gender")))
00468 {
00469 $tpl->parseCurrentBlock();
00470
00471 }
00472 }
00473
00474
00475 if ($settings["passwd_auto_generate"] != 1)
00476 {
00477
00478 $str = $lng->txt("retype_password");
00479 if (isset($settings["require_passwd2"]) && $settings["require_passwd2"])
00480 {
00481 $str = $str . '<span class="asterisk">*</span>';
00482 }
00483
00484 $tpl->setVariable("TXT_PASSWD2", $str);
00485 }
00486 else
00487 {
00488 $tpl->setVariable("TXT_PASSWD_SELECT", $lng->txt("passwd"));
00489 $tpl->setVariable("TXT_PASSWD_VIA_MAIL", $lng->txt("reg_passwd_via_mail"));
00490 }
00491
00492 $tpl->setVariable("FORMACTION", "register.php?cmd=save&lang=".$_GET["lang"]);
00493 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00494 $tpl->setVariable("TXT_REQUIRED_FIELDS", $lng->txt("required_field"));
00495 $tpl->setVariable("TXT_LOGIN_DATA", $lng->txt("login_data"));
00496 $tpl->setVariable("TXT_PERSONAL_DATA", $lng->txt("personal_data"));
00497 $tpl->setVariable("TXT_CONTACT_DATA", $lng->txt("contact_data"));
00498 $tpl->setVariable("TXT_SETTINGS", $lng->txt("settings"));
00499 $tpl->setVariable("TXT_OTHER", $lng->txt("user_profile_other"));
00500 $tpl->setVariable("TXT_LANGUAGE",$lng->txt("language"));
00501 $tpl->setVariable("TXT_GENDER_F",$lng->txt("gender_f"));
00502 $tpl->setVariable("TXT_GENDER_M",$lng->txt("gender_m"));
00503 $tpl->setVariable("TXT_OK",$lng->txt("ok"));
00504 $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
00505
00506
00507 $languages = $lng->getInstalledLanguages();
00508
00509 $count = (int) round(count($languages) / 2);
00510 $num = 1;
00511
00512 foreach ($languages as $lang_key)
00513 {
00514
00515
00516
00517
00518
00519
00520
00521 $tpl->setCurrentBlock("languages");
00522 $tpl->setVariable("LINK_LANG", "./register.php?lang=".$lang_key);
00523 $tpl->setVariable("LANG_NAME",
00524 ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
00525 $tpl->setVariable("LANG_ICON", $lang_key);
00526 $tpl->setVariable("BORDER", 0);
00527 $tpl->setVariable("VSPACE", 0);
00528 $tpl->parseCurrentBlock();
00529
00530 $num++;
00531 }
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $lng->lang_key;
00542
00543 foreach ($languages as $lang_key)
00544 {
00545 $tpl->setCurrentBlock("language_selection");
00546 $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00547 $tpl->setVariable("LANGSHORT", $lang_key);
00548
00549 if ($selected_lang == $lang_key)
00550 {
00551 $tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00552 }
00553
00554 $tpl->parseCurrentBlock();
00555 }
00556
00557
00558 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00559 {
00560
00561 $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00562
00563 if (!empty($gender))
00564 {
00565 $tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00566 }
00567 }
00568
00569 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("registration"));
00570 $tpl->setVariable("TXT_PAGETITLE", "ILIAS3 - ".$lng->txt("registration"));
00571 $tpl->setVariable("TXT_REGISTER_INFO", $lng->txt("register_info"));
00572 $tpl->setVariable("AGREEMENT", ilUserAgreement::_getText());
00573 $tpl->setVariable("ACCEPT_CHECKBOX", ilUtil::formCheckbox(0, "status", "accepted"));
00574 $tpl->setVariable("ACCEPT_AGREEMENT", $lng->txt("accept_usr_agreement") . '<span class="asterisk">*</span>');
00575
00576 $tpl->show();
00577
00578 }
00579
00580 ?>
00581