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") or AUTH_CURRENT != AUTH_LOCAL)
00039 {
00040 if (empty($_SESSION["AccountId"]) and $_SESSION["AccountId"] !== false)
00041 {
00042 $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->WARNING);
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"));
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;
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
00183
00184
00185
00186
00187 $userObj = new ilObjUser();
00188 $userObj->assignData($_POST["Fobject"]);
00189 $userObj->setTitle($userObj->getFullname());
00190 $userObj->setDescription($userObj->getEmail());
00191
00192
00193 $userObj->setTimeLimitOwner(7);
00194 $userObj->setTimeLimitUnlimited(1);
00195 $userObj->setTimeLimitFrom(time());
00196 $userObj->setTimeLimitUntil(time());
00197
00198 $userObj->create();
00199
00200 if (isset($settings["auto_registration"]) && ($settings["auto_registration"] == 1))
00201 {
00202 $userObj->setActive(1, 6);
00203 }
00204 else
00205 {
00206 $userObj->setActive(0, 0);
00207 }
00208
00209 $userObj->updateOwner();
00210
00211
00212 $userObj->saveAsNew();
00213
00214
00215 $userObj->writeAccepted();
00216
00217
00218 $userObj->setLanguage($_POST["Fobject"]["language"]);
00219 $userObj->writePrefs();
00220
00221
00222 $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 if (!$ilias->getSetting("auto_registration"))
00240 {
00241 $approve_recipient = $ilias->getSetting("approve_recipient");
00242 if (empty($approve_recipient))
00243 {
00244 $approve_recipient = $userObj->getLoginByUserId(6);
00245 }
00246
00247 include_once "classes/class.ilFormatMail.php";
00248
00249 $umail = new ilFormatMail($userObj->getId());
00250
00251
00252 $subject = $lng->txt("client_id") . " " . $ilias->client_id . ": " . $lng->txt("usr_new");
00253
00254
00255 $body = $lng->txt("login").": ".$userObj->getLogin()."\n\r".
00256 $lng->txt("passwd").": ".$_POST["Fobject"]["passwd"]."\n\r".
00257 $lng->txt("title").": ".$userObj->getTitle()."\n\r".
00258 $lng->txt("gender").": ".$userObj->getGender()."\n\r".
00259 $lng->txt("firstname").": ".$userObj->getFirstname()."\n\r".
00260 $lng->txt("lastname").": ".$userObj->getLastname()."\n\r".
00261 $lng->txt("institution").": ".$userObj->getInstitution()."\n\r".
00262 $lng->txt("department").": ".$userObj->getDepartment()."\n\r".
00263 $lng->txt("street").": ".$userObj->getStreet()."\n\r".
00264 $lng->txt("city").": ".$userObj->getCity()."\n\r".
00265 $lng->txt("zipcode").": ".$userObj->getZipcode()."\n\r".
00266 $lng->txt("country").": ".$userObj->getCountry()."\n\r".
00267 $lng->txt("phone_office").": ".$userObj->getPhoneOffice()."\n\r".
00268 $lng->txt("phone_home").": ".$userObj->getPhoneHome()."\n\r".
00269 $lng->txt("phone_mobile").": ".$userObj->getPhoneMobile()."\n\r".
00270 $lng->txt("fax").": ".$userObj->getFax()."\n\r".
00271 $lng->txt("email").": ".$userObj->getEmail()."\n\r".
00272 $lng->txt("hobby").": ".$userObj->getHobby()."\n\r".
00273 $lng->txt("referral_comment").": ".$userObj->getComment()."\n\r".
00274 $lng->txt("matriculation").": ".$userObj->getMatriculation()."\n\r".
00275 $lng->txt("create_date").": ".$userObj->getCreateDate()."\n\r".
00276 $lng->txt("default_role").": ".$_POST["Fobject"]["default_role"]."\n\r";
00277
00278 $error_message = $umail->sendMail($approve_recipient,"","",$subject,$body,array(),array("normal"));
00279 }
00280
00281 if ($settings["passwd_auto_generate"] == 1)
00282 {
00283 include_once "classes/class.ilMimeMail.php";
00284
00285 $mmail = new ilMimeMail();
00286 $mmail->autoCheck(false);
00287 $mmail->From($settings["admin_email"]);
00288 $mmail->To($userObj->getEmail());
00289
00290
00291 $subject = $lng->txt("reg_mail_subject");
00292
00293
00294 $body = $lng->txt("reg_mail_body_salutation")." ".$userObj->getFullname().",\n\r".
00295 $lng->txt("reg_mail_body_welcome")."\n\r".
00296 $lng->txt("reg_mail_body_text1")."\n\r".
00297 $lng->txt("reg_mail_body_text2")."\n\r".
00298 ILIAS_HTTP_PATH."login.php?client_id=".$ilias->client_id."\n\r".
00299 $lng->txt("login").": ".$userObj->getLogin()."\n\r".
00300 $lng->txt("passwd").": ".$_POST["Fobject"]["passwd"]."\n\r\n\r".
00301 $lng->txt("reg_mail_body_text3")."\n\r".
00302 $lng->txt("title").": ".$userObj->getTitle()."\n\r".
00303 $lng->txt("gender").": ".$userObj->getGender()."\n\r".
00304 $lng->txt("firstname").": ".$userObj->getFirstname()."\n\r".
00305 $lng->txt("lastname").": ".$userObj->getLastname()."\n\r".
00306 $lng->txt("institution").": ".$userObj->getInstitution()."\n\r".
00307 $lng->txt("department").": ".$userObj->getDepartment()."\n\r".
00308 $lng->txt("street").": ".$userObj->getStreet()."\n\r".
00309 $lng->txt("city").": ".$userObj->getCity()."\n\r".
00310 $lng->txt("zipcode").": ".$userObj->getZipcode()."\n\r".
00311 $lng->txt("country").": ".$userObj->getCountry()."\n\r".
00312 $lng->txt("phone_office").": ".$userObj->getPhoneOffice()."\n\r".
00313 $lng->txt("phone_home").": ".$userObj->getPhoneHome()."\n\r".
00314 $lng->txt("phone_mobile").": ".$userObj->getPhoneMobile()."\n\r".
00315 $lng->txt("fax").": ".$userObj->getFax()."\n\r".
00316 $lng->txt("email").": ".$userObj->getEmail()."\n\r".
00317 $lng->txt("hobby").": ".$userObj->getHobby()."\n\r".
00318 $lng->txt("referral_comment").": ".$userObj->getComment()."\n\r".
00319 $lng->txt("create_date").": ".$userObj->getCreateDate()."\n\r".
00320 $lng->txt("default_role").": ".$_POST["Fobject"]["default_role"]."\n\r";
00321
00322 $mmail->Subject($subject);
00323 $mmail->Body($body);
00324 $mmail->Send();
00325 }
00326
00327 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())));
00328 }
00329
00330
00331 function displayForm()
00332 {
00333 global $tpl,$ilias,$lng,$ObjDefinition;
00334
00335
00336 $settings = $ilias->getAllSettings();
00337
00338
00339 $tpl->addBlockFile("CONTENT", "content", "tpl.usr_registration.html");
00340 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00341
00342
00343
00344
00345
00346 include_once("classes/class.ilObjRole.php");
00347 $reg_roles = ilObjRole::_lookupRegisterAllowed();
00348
00349 $rol = array();
00350 foreach ($reg_roles as $role)
00351 {
00352 $rol[$role["id"]] = $role["title"];
00353 }
00354
00355 $role = ilUtil::formSelect($_SESSION["error_post_vars"]["Fobject"]["default_role"],"Fobject[default_role]",$rol,false,true);
00356
00357 $data = array();
00358 $data["fields"] = array();
00359 $data["fields"]["login"] = "";
00360
00361 if ($settings["passwd_auto_generate"] != 1)
00362 {
00363 $data["fields"]["passwd"] = "";
00364 $data["fields"]["passwd2"] = "";
00365 }
00366
00367 $data["fields"]["title"] = "";
00368 $data["fields"]["gender"] = "";
00369 $data["fields"]["firstname"] = "";
00370 $data["fields"]["lastname"] = "";
00371 $data["fields"]["institution"] = "";
00372 $data["fields"]["department"] = "";
00373 $data["fields"]["street"] = "";
00374 $data["fields"]["city"] = "";
00375 $data["fields"]["zipcode"] = "";
00376 $data["fields"]["country"] = "";
00377 $data["fields"]["phone_office"] = "";
00378 $data["fields"]["phone_home"] = "";
00379 $data["fields"]["phone_mobile"] = "";
00380 $data["fields"]["fax"] = "";
00381 $data["fields"]["email"] = "";
00382 $data["fields"]["hobby"] = "";
00383 $data["fields"]["referral_comment"] = "";
00384 $data["fields"]["matriculation"] = "";
00385 $data["fields"]["default_role"] = $role;
00386
00387
00388 foreach ($data["fields"] as $key => $val)
00389 {
00390 $str = $lng->txt($key);
00391 if ($key == "title")
00392 {
00393 $str = $lng->txt("person_title");
00394 }
00395
00396
00397 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00398 {
00399 $str = $str . '<span class="asterisk">*</span>';
00400 }
00401
00402 $tpl->setVariable("TXT_".strtoupper($key), $str);
00403
00404 if ($key == "default_role")
00405 {
00406 $tpl->setVariable(strtoupper($key), $val);
00407 }
00408 else
00409 {
00410 $tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
00411 }
00412 }
00413
00414
00415 if ($settings["passwd_auto_generate"] != 1)
00416 {
00417
00418 $str = $lng->txt("retype_password");
00419 if (isset($settings["require_passwd2"]) && $settings["require_passwd2"])
00420 {
00421 $str = $str . '<span class="asterisk">*</span>';
00422 }
00423
00424 $tpl->setVariable("TXT_PASSWD2", $str);
00425 }
00426 else
00427 {
00428 $tpl->setVariable("TXT_PASSWD_SELECT", $lng->txt("passwd"));
00429 $tpl->setVariable("TXT_PASSWD_VIA_MAIL", $lng->txt("reg_passwd_via_mail"));
00430 }
00431
00432 $tpl->setVariable("FORMACTION", "register.php?cmd=save&lang=".$_GET["lang"]);
00433 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00434 $tpl->setVariable("TXT_REQUIRED_FIELDS", $lng->txt("required_field"));
00435 $tpl->setVariable("TXT_LOGIN_DATA", $lng->txt("login_data"));
00436 $tpl->setVariable("TXT_PERSONAL_DATA", $lng->txt("personal_data"));
00437 $tpl->setVariable("TXT_CONTACT_DATA", $lng->txt("contact_data"));
00438 $tpl->setVariable("TXT_SETTINGS", $lng->txt("settings"));
00439 $tpl->setVariable("TXT_OTHER", $lng->txt("user_profile_other"));
00440 $tpl->setVariable("TXT_LANGUAGE",$lng->txt("language"));
00441 $tpl->setVariable("TXT_GENDER_F",$lng->txt("gender_f"));
00442 $tpl->setVariable("TXT_GENDER_M",$lng->txt("gender_m"));
00443
00444
00445 $languages = $lng->getInstalledLanguages();
00446
00447 $count = (int) round(count($languages) / 2);
00448 $num = 1;
00449
00450 foreach ($languages as $lang_key)
00451 {
00452
00453
00454
00455
00456
00457
00458
00459 $tpl->setCurrentBlock("languages");
00460 $tpl->setVariable("LINK_LANG", "./register.php?lang=".$lang_key);
00461 $tpl->setVariable("LANG_NAME", $lng->txt("lang_".$lang_key));
00462 $tpl->setVariable("LANG_ICON", $lang_key);
00463 $tpl->setVariable("BORDER", 0);
00464 $tpl->setVariable("VSPACE", 0);
00465 $tpl->parseCurrentBlock();
00466
00467 $num++;
00468 }
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $lng->lang_key;
00479
00480 foreach ($languages as $lang_key)
00481 {
00482 $tpl->setCurrentBlock("language_selection");
00483 $tpl->setVariable("LANG", $lng->txt("lang_".$lang_key));
00484 $tpl->setVariable("LANGSHORT", $lang_key);
00485
00486 if ($selected_lang == $lang_key)
00487 {
00488 $tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00489 }
00490
00491 $tpl->parseCurrentBlock();
00492 }
00493
00494
00495 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00496 {
00497 foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00498 {
00499 if ($key != "default_role" and $key != "language")
00500 {
00501 $tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
00502 }
00503 }
00504
00505
00506 $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00507
00508 if (!empty($gender))
00509 {
00510 $tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00511 }
00512 }
00513
00514 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("registration"));
00515 $tpl->setVariable("TXT_PAGETITLE", "ILIAS3 - ".$lng->txt("registration"));
00516 $tpl->setVariable("TXT_REGISTER_INFO", $lng->txt("register_info"));
00517 $tpl->setVariable("AGREEMENT", ilUserAgreement::_getText());
00518 $tpl->setVariable("ACCEPT_CHECKBOX", ilUtil::formCheckbox(0, "status", "accepted"));
00519 $tpl->setVariable("ACCEPT_AGREEMENT", $lng->txt("accept_usr_agreement") . '<span class="asterisk">*</span>');
00520
00521 $tpl->show();
00522
00523 }
00524
00525 ?>
00526