ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAccountRegistrationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
18require_once './Services/Registration/classes/class.ilRegistrationSettings.php';
19require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
20
25{
26 protected $registration_settings; // [object]
27 protected $code_enabled; // [bool]
28 protected $code_was_used; // [bool]
29
30 public function __construct()
31 {
32 global $ilCtrl,$tpl,$lng;
33
34 $this->tpl =& $tpl;
35
36 $this->ctrl =& $ilCtrl;
37 $this->ctrl->saveParameter($this,'lang');
38
39 $this->lng =& $lng;
40 $this->lng->loadLanguageModule('registration');
41
42 $this->registration_settings = new ilRegistrationSettings();
43
44 $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
45 $this->registration_settings->getAllowCodes());
46 }
47
48 public function executeCommand()
49 {
50 global $ilErr, $tpl;
51
52 if($this->registration_settings->getRegistrationType() == IL_REG_DISABLED)
53 {
54 $ilErr->raiseError($this->lng->txt('reg_disabled'),$ilErr->FATAL);
55 }
56
57 $next_class = $this->ctrl->getNextClass($this);
58 $cmd = $this->ctrl->getCmd();
59
60 switch($next_class)
61 {
62 default:
63 if($cmd)
64 {
65 $this->$cmd();
66 }
67 else
68 {
69 $this->displayForm();
70 }
71 break;
72 }
73 $tpl->show();
74 return true;
75 }
76
80 public function displayForm()
81 {
85 global $lng;
86
87 ilStartUpGUI::initStartUpTemplate(array('tpl.usr_registration.html', 'Services/Registration'), true);
88 $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('registration'));
89
90 if(!$this->form)
91 {
92 $this->__initForm();
93 }
94 $this->tpl->setVariable('FORM', $this->form->getHTML());
95 }
96
97 protected function __initForm()
98 {
99 global $lng, $ilUser;
100
101 // needed for multi-text-fields (interests)
102 include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
104
105 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
106 $this->form = new ilPropertyFormGUI();
107 $this->form->setFormAction($this->ctrl->getFormAction($this));
108
109
110 // code handling
111
112 if($this->code_enabled)
113 {
114 include_once 'Services/Registration/classes/class.ilRegistrationCode.php';
115 $code = new ilTextInputGUI($lng->txt("registration_code"), "usr_registration_code");
116 $code->setSize(40);
118 if((bool)$this->registration_settings->registrationCodeRequired())
119 {
120 $code->setRequired(true);
121 $code->setInfo($lng->txt("registration_code_required_info"));
122 }
123 else
124 {
125 $code->setInfo($lng->txt("registration_code_optional_info"));
126 }
127 $this->form->addItem($code);
128 }
129
130
131 // user defined fields
132
133 $user_defined_data = $ilUser->getUserDefinedData();
134
135 include_once './Services/User/classes/class.ilUserDefinedFields.php';
136 $user_defined_fields =& ilUserDefinedFields::_getInstance();
137 $custom_fields = array();
138 foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
139 {
140 if($definition['field_type'] == UDF_TYPE_TEXT)
141 {
142 $custom_fields["udf_".$definition['field_id']] =
143 new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
144 $custom_fields["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
145 $custom_fields["udf_".$definition['field_id']]->setMaxLength(255);
146 $custom_fields["udf_".$definition['field_id']]->setSize(40);
147 }
148 else if($definition['field_type'] == UDF_TYPE_WYSIWYG)
149 {
150 $custom_fields["udf_".$definition['field_id']] =
151 new ilTextAreaInputGUI($definition['field_name'], "udf_".$definition['field_id']);
152 $custom_fields["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
153 $custom_fields["udf_".$definition['field_id']]->setUseRte(true);
154 }
155 else
156 {
157 $custom_fields["udf_".$definition['field_id']] =
158 new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
159 $custom_fields["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
160 $custom_fields["udf_".$definition['field_id']]->setOptions(
161 $user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
162 }
163 if($definition['required'])
164 {
165 $custom_fields["udf_".$definition['field_id']]->setRequired(true);
166 }
167
168 if($definition['field_type'] == UDF_TYPE_SELECT && !$user_defined_data["f_".$field_id])
169 {
170 $options = array(""=>$lng->txt("please_select")) + $custom_fields["udf_".$definition['field_id']]->getOptions();
171 $custom_fields["udf_".$definition['field_id']]->setOptions($options);
172 }
173 }
174
175 // standard fields
176 include_once("./Services/User/classes/class.ilUserProfile.php");
177 $up = new ilUserProfile();
179 $up->skipGroup("preferences");
180
181 $up->setAjaxCallback(
182 $this->ctrl->getLinkTarget($this, 'doProfileAutoComplete', '', true)
183 );
184
185 $lng->loadLanguageModule("user");
186
187 // add fields to form
188 $up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
189 unset($custom_fields);
190
191
192 // set language selection to current display language
193 $flang = $this->form->getItemByPostVar("usr_language");
194 if($flang)
195 {
196 $flang->setValue($lng->getLangKey());
197 }
198
199 // add information to role selection (if not hidden)
200 if($this->code_enabled)
201 {
202 $role = $this->form->getItemByPostVar("usr_roles");
203 if($role && $role->getType() == "select")
204 {
205 $role->setInfo($lng->txt("registration_code_role_info"));
206 }
207 }
208
209 // #11407
210 $domains = array();
211 foreach($this->registration_settings->getAllowedDomains() as $item)
212 {
213 if(trim($item))
214 {
215 $domains[] = $item;
216 }
217 }
218 if(sizeof($domains))
219 {
220 $mail_obj = $this->form->getItemByPostVar('usr_email');
221 $mail_obj->setInfo(sprintf($lng->txt("reg_email_domains"),
222 implode(", ", $domains))."<br />".
223 ($this->code_enabled ? $lng->txt("reg_email_domains_code") : ""));
224 }
225
226 // #14272
227 if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
228 {
229 $mail_obj = $this->form->getItemByPostVar('usr_email');
230 if($mail_obj) // #16087
231 {
232 $mail_obj->setRequired(true);
233 }
234 }
235
236 if(ilTermsOfServiceHelper::isEnabled())
237 {
238 try
239 {
240 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
242 $field = new ilFormSectionHeaderGUI();
243 $field->setTitle($lng->txt('usr_agreement'));
244 $this->form->addItem($field);
245
246 $field = new ilCustomInputGUI();
247 $field->setHTML('<div id="agreement">' . $document->getContent() . '</div>');
248 $this->form->addItem($field);
249
250 $field = new ilCheckboxInputGUI($lng->txt('accept_usr_agreement'), 'accept_terms_of_service');
251 $field->setRequired(true);
252 $field->setValue(1);
253 $this->form->addItem($field);
254 }
256 {
257 }
258 }
259
260 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
261 if(ilCaptchaUtil::isActiveForRegistration())
262 {
263 require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
264 $captcha = new ilCaptchaInputGUI($lng->txt("captcha_code"), 'captcha_code');
265 $captcha->setRequired(true);
266 $this->form->addItem($captcha);
267 }
268
269 $this->form->addCommandButton("saveForm", $lng->txt("register"));
270 }
271
272 public function saveForm()
273 {
274 global $lng, $ilSetting, $rbacreview;
275
276 $this->__initForm();
277 $form_valid = $this->form->checkInput();
278
279 require_once 'Services/User/classes/class.ilObjUser.php';
280
281
282 // custom validation
283 $valid_code = $valid_role = false;
284
285 // code
286 if($this->code_enabled)
287 {
288 $code = $this->form->getInput('usr_registration_code');
289 // could be optional
290 if(
291 $this->registration_settings->registrationCodeRequired() ||
292 strlen($code)
293 )
294 {
295 // code validation
296 include_once './Services/Registration/classes/class.ilRegistrationCode.php';
298 {
299 $code_obj = $this->form->getItemByPostVar('usr_registration_code');
300 $code_obj->setAlert($lng->txt('registration_code_not_valid'));
301 $form_valid = false;
302 }
303 else
304 {
305 $valid_code = true;
306
307 // get role from code, check if (still) valid
308 $role_id = (int)ilRegistrationCode::getCodeRole($code);
309 if($role_id && $rbacreview->isGlobalRole($role_id))
310 {
311 $valid_role = $role_id;
312 }
313 }
314 }
315 }
316
317 // valid codes override email domain check
318 if(!$valid_code)
319 {
320 // validate email against restricted domains
321 $email = $this->form->getInput("usr_email");
322 if($email)
323 {
324 // #10366
325 $domains = array();
326 foreach($this->registration_settings->getAllowedDomains() as $item)
327 {
328 if(trim($item))
329 {
330 $domains[] = $item;
331 }
332 }
333 if(sizeof($domains))
334 {
335 $mail_valid = false;
336 foreach($domains as $domain)
337 {
338 $domain = str_replace("*", "~~~", $domain);
339 $domain = preg_quote($domain);
340 $domain = str_replace("~~~", ".+", $domain);
341 if(preg_match("/^".$domain."$/", $email, $hit))
342 {
343 $mail_valid = true;
344 break;
345 }
346 }
347 if(!$mail_valid)
348 {
349 $mail_obj = $this->form->getItemByPostVar('usr_email');
350 $mail_obj->setAlert(sprintf($lng->txt("reg_email_domains"),
351 implode(", ", $domains)));
352 $form_valid = false;
353 }
354 }
355 }
356 }
357
358 $error_lng_var = '';
359 if(
360 !$this->registration_settings->passwordGenerationEnabled() &&
361 !ilUtil::isPasswordValidForUserContext($this->form->getInput('usr_password'), $this->form->getInput('username'), $error_lng_var)
362 )
363 {
364 $passwd_obj = $this->form->getItemByPostVar('usr_password');
365 $passwd_obj->setAlert($lng->txt($error_lng_var));
366 $form_valid = false;
367 }
368
369 if(ilTermsOfServiceHelper::isEnabled() && !$this->form->getInput('accept_terms_of_service'))
370 {
371 $agr_obj = $this->form->getItemByPostVar('accept_terms_of_service');
372 if($agr_obj)
373 {
374 $agr_obj->setAlert($lng->txt('force_accept_usr_agreement'));
375 }
376 else
377 {
378 ilUtil::sendFailure($lng->txt('force_accept_usr_agreement'));
379 }
380 $form_valid = false;
381 }
382
383 // no need if role is attached to code
384 if(!$valid_role)
385 {
386 // manual selection
387 if ($this->registration_settings->roleSelectionEnabled())
388 {
389 include_once "./Services/AccessControl/classes/class.ilObjRole.php";
390 $selected_role = $this->form->getInput("usr_roles");
391 if ($selected_role && ilObjRole::_lookupAllowRegister($selected_role))
392 {
393 $valid_role = (int)$selected_role;
394 }
395 }
396 // assign by email
397 else
398 {
399 include_once 'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
400 $registration_role_assignments = new ilRegistrationRoleAssignments();
401 $valid_role = (int)$registration_role_assignments->getRoleByEmail($this->form->getInput("usr_email"));
402 }
403 }
404
405 // no valid role could be determined
406 if (!$valid_role)
407 {
408 ilUtil::sendInfo($lng->txt("registration_no_valid_role"));
409 $form_valid = false;
410 }
411
412 // validate username
413 $login_obj = $this->form->getItemByPostVar('username');
414 $login = $this->form->getInput("username");
415 if (!ilUtil::isLogin($login))
416 {
417 $login_obj->setAlert($lng->txt("login_invalid"));
418 $form_valid = false;
419 }
420 else if (ilObjUser::_loginExists($login))
421 {
422 $login_obj->setAlert($lng->txt("login_exists"));
423 $form_valid = false;
424 }
425 else if ((int)$ilSetting->get('allow_change_loginname') &&
426 (int)$ilSetting->get('reuse_of_loginnames') == 0 &&
428 {
429 $login_obj->setAlert($lng->txt('login_exists'));
430 $form_valid = false;
431 }
432
433 if(!$form_valid)
434 {
435 ilUtil::sendFailure($lng->txt('form_input_not_valid'));
436 }
437 else
438 {
439 $password = $this->__createUser($valid_role);
440 $this->__distributeMails($password, $this->form->getInput("usr_language"));
441 $this->login($password);
442 return true;
443 }
444
445 $this->form->setValuesByPost();
446 $this->displayForm();
447 return false;
448 }
449
450 protected function __createUser($a_role)
451 {
457 global $ilSetting, $rbacadmin, $lng;
458
459
460 // something went wrong with the form validation
461 if(!$a_role)
462 {
463 global $ilias;
464 $ilias->raiseError("Invalid role selection in registration".
465 ", IP: ".$_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL);
466 }
467
468
469 $this->userObj = new ilObjUser();
470
471 include_once("./Services/User/classes/class.ilUserProfile.php");
472 $up = new ilUserProfile();
474
475 $map = array();
476 $up->skipGroup("preferences");
477 $up->skipGroup("settings");
478 $up->skipGroup("instant_messengers");
479 $up->skipField("password");
480 $up->skipField("birthday");
481 $up->skipField("upload");
482 foreach ($up->getStandardFields() as $k => $v)
483 {
484 if($v["method"])
485 {
486 $method = "set".substr($v["method"], 3);
487 if(method_exists($this->userObj, $method))
488 {
489 if ($k != "username")
490 {
491 $k = "usr_".$k;
492 }
493 $field_obj = $this->form->getItemByPostVar($k);
494 if($field_obj)
495 {
496
497 $this->userObj->$method($this->form->getInput($k));
498 }
499 }
500 }
501 }
502
503 $this->userObj->setFullName();
504
505 $birthday_obj = $this->form->getItemByPostVar("usr_birthday");
506 if ($birthday_obj)
507 {
508 $birthday = $this->form->getInput("usr_birthday");
509 $birthday = $birthday["date"];
510
511 // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui
512 if(!is_array($birthday))
513 {
514 $this->userObj->setBirthday($birthday);
515 }
516 }
517
518 // messenger
519 $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
520 foreach($map as $client)
521 {
522 $field = "usr_im_".$client;
523 $field_obj = $this->form->getItemByPostVar($field);
524 if($field_obj)
525 {
526 $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
527 }
528 }
529
530 $this->userObj->setTitle($this->userObj->getFullname());
531 $this->userObj->setDescription($this->userObj->getEmail());
532
533 if ($this->registration_settings->passwordGenerationEnabled())
534 {
535 $password = ilUtil::generatePasswords(1);
536 $password = $password[0];
537 }
538 else
539 {
540 $password = $this->form->getInput("usr_password");
541 }
542 $this->userObj->setPasswd($password);
543
544
545 // Set user defined data
546 include_once './Services/User/classes/class.ilUserDefinedFields.php';
547 $user_defined_fields =& ilUserDefinedFields::_getInstance();
548 $defs = $user_defined_fields->getRegistrationDefinitions();
549 $udf = array();
550 foreach ($_POST as $k => $v)
551 {
552 if (substr($k, 0, 4) == "udf_")
553 {
554 $f = substr($k, 4);
555 $udf[$f] = $v;
556 }
557 }
558 $this->userObj->setUserDefinedData($udf);
559
560 $this->userObj->setTimeLimitOwner(7);
561
562
563 $access_limit = null;
564
565 $this->code_was_used = false;
566 if($this->code_enabled)
567 {
568 $code_local_roles = $code_has_access_limit = null;
569
570 // #10853 - could be optional
571 $code = $this->form->getInput('usr_registration_code');
572 if($code)
573 {
574 include_once './Services/Registration/classes/class.ilRegistrationCode.php';
575
576 // set code to used
578 $this->code_was_used = true;
579
580 // handle code attached local role(s) and access limitation
582 if($code_data["role_local"])
583 {
584 // need user id before we can assign role(s)
585 $code_local_roles = explode(";", $code_data["role_local"]);
586 }
587 if($code_data["alimit"])
588 {
589 // see below
590 $code_has_access_limit = true;
591
592 switch($code_data["alimit"])
593 {
594 case "absolute":
595 $abs = date_parse($code_data["alimitdt"]);
596 $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']);
597 break;
598
599 case "relative":
600 $rel = unserialize($code_data["alimitdt"]);
601 $access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 +
602 $rel["y"] * 31536000 + time();
603 break;
604 }
605 }
606 }
607 }
608
609 // code access limitation will override any other access limitation setting
610 if (!($this->code_was_used && $code_has_access_limit) &&
611 $this->registration_settings->getAccessLimitation())
612 {
613 include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
614 $access_limitations_obj = new ilRegistrationRoleAccessLimitations();
615 switch($access_limitations_obj->getMode($a_role))
616 {
617 case 'absolute':
618 $access_limit = $access_limitations_obj->getAbsolute($a_role);
619 break;
620
621 case 'relative':
622 $rel_d = (int) $access_limitations_obj->getRelative($a_role,'d');
623 $rel_m = (int) $access_limitations_obj->getRelative($a_role,'m');
624 $rel_y = (int) $access_limitations_obj->getRelative($a_role,'y');
625 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
626 break;
627 }
628 }
629
630 if($access_limit)
631 {
632 $this->userObj->setTimeLimitUnlimited(0);
633 $this->userObj->setTimeLimitUntil($access_limit);
634 }
635 else
636 {
637 $this->userObj->setTimeLimitUnlimited(1);
638 $this->userObj->setTimeLimitUntil(time());
639 }
640
641 $this->userObj->setTimeLimitFrom(time());
642
643 include_once './Services/User/classes/class.ilUserCreationContext.php';
645
646 $this->userObj->create();
647
648
649 if($this->registration_settings->getRegistrationType() == IL_REG_DIRECT ||
650 $this->registration_settings->getRegistrationType() == IL_REG_CODES ||
651 $this->code_was_used)
652 {
653 $this->userObj->setActive(1,0);
654 }
655 else if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
656 {
657 $this->userObj->setActive(0,0);
658 }
659 else
660 {
661 $this->userObj->setActive(0,0);
662 }
663
664 $this->userObj->updateOwner();
665
666 // set a timestamp for last_password_change
667 // this ts is needed by ilSecuritySettings
668 $this->userObj->setLastPasswordChangeTS( time() );
669
670 $this->userObj->setIsSelfRegistered(true);
671
672 //insert user data in table user_data
673 $this->userObj->saveAsNew();
674
675 try
676 {
677 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
679 }
681 {
682 }
683
684 // setup user preferences
685 $this->userObj->setLanguage($this->form->getInput('usr_language'));
686 $hits_per_page = $ilSetting->get("hits_per_page");
687 if ($hits_per_page < 10)
688 {
689 $hits_per_page = 10;
690 }
691 $this->userObj->setPref("hits_per_page", $hits_per_page);
692 if(strlen($_GET['target']) > 0)
693 {
694 $this->userObj->setPref('reg_target', ilUtil::stripSlashes($_GET['target']));
695 }
696 /*$show_online = $ilSetting->get("show_users_online");
697 if ($show_online == "")
698 {
699 $show_online = "y";
700 }
701 $this->userObj->setPref("show_users_online", $show_online);*/
702 $this->userObj->setPref('bs_allow_to_contact_me', 'y');
703 $this->userObj->writePrefs();
704
705
706 $rbacadmin->assignUser((int)$a_role, $this->userObj->getId());
707
708 // local roles from code
709 if($this->code_was_used && is_array($code_local_roles))
710 {
711 foreach(array_unique($code_local_roles) as $local_role_obj_id)
712 {
713 // is given role (still) valid?
714 if(ilObject::_lookupType($local_role_obj_id) == "role")
715 {
716 $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
717
718 // patch to remove for 45 due to mantis 21953
719 $role_obj = $GLOBALS['rbacreview']->getObjectOfRole($local_role_obj_id);
720 switch(ilObject::_lookupType($role_obj))
721 {
722 case 'crs':
723 case 'grp':
724 $role_refs = ilObject::_getAllReferences($role_obj);
725 $role_ref = end($role_refs);
726 ilObjUser::_addDesktopItem($this->userObj->getId(),$role_ref,ilObject::_lookupType($role_obj));
727 break;
728 }
729 }
730 }
731 }
732
733 return $password;
734 }
735
736 protected function __distributeMails($password, $a_language = null)
737 {
738 global $ilSetting;
739
740 include_once './Services/Language/classes/class.ilLanguage.php';
741 include_once './Services/User/classes/class.ilObjUser.php';
742 include_once "Services/Mail/classes/class.ilFormatMail.php";
743 include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
744
745 // Always send mail to approvers
746 if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
747 {
748 $mail = new ilRegistrationMailNotification();
750 $mail->setRecipients($this->registration_settings->getApproveRecipients());
751 $mail->setAdditionalInformation(array('usr' => $this->userObj));
752 $mail->send();
753 }
754 else
755 {
756 $mail = new ilRegistrationMailNotification();
758 $mail->setRecipients($this->registration_settings->getApproveRecipients());
759 $mail->setAdditionalInformation(array('usr' => $this->userObj));
760 $mail->send();
761
762 }
763 // Send mail to new user
764
765 // Registration with confirmation link ist enabled
766 if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used)
767 {
768 include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
769
772 $mail->setRecipients(array($this->userObj));
773 $mail->setAdditionalInformation(
774 array(
775 'usr' => $this->userObj,
776 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
777 )
778 );
779 $mail->send();
780 }
781 else
782 {
783 // try individual account mail in user administration
784 include_once("Services/Mail/classes/class.ilAccountMail.php");
785 include_once './Services/User/classes/class.ilObjUserFolder.php';
786
787 $amail = ilObjUserFolder::_lookupNewAccountMail($a_language);
788 if (trim($amail["body"]) == "" || trim($amail["subject"]) == "")
789 {
790 $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
791 }
792 if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
793 {
794 $acc_mail = new ilAccountMail();
795 $acc_mail->setUser($this->userObj);
796 if ($this->registration_settings->passwordGenerationEnabled())
797 {
798 $acc_mail->setUserPassword($password);
799 }
800
801 if($amail["att_file"])
802 {
803 include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
805 $fs->create();
806 $path = $fs->getAbsolutePath()."/";
807
808 $acc_mail->addAttachment($path."/".$amail["lang"], $amail["att_file"]);
809 }
810
811 $acc_mail->send();
812 }
813 else // do default mail
814 {
815 include_once "Services/Mail/classes/class.ilMimeMail.php";
816
817 $mmail = new ilMimeMail();
818 $mmail->autoCheck(false);
819 $mmail->From($ilSetting->get("admin_email"));
820 $mmail->To($this->userObj->getEmail());
821
822 // mail subject
823 $subject = $this->lng->txt("reg_mail_subject");
824
825 // mail body
826 $body = $this->lng->txt("reg_mail_body_salutation")." ".$this->userObj->getFullname().",\n\n".
827 $this->lng->txt("reg_mail_body_text1")."\n\n".
828 $this->lng->txt("reg_mail_body_text2")."\n".
829 ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
830 $body .= $this->lng->txt("login").": ".$this->userObj->getLogin()."\n";
831
832 if ($this->registration_settings->passwordGenerationEnabled())
833 {
834 $body.= $this->lng->txt("passwd").": ".$password."\n";
835 }
836 $body.= "\n";
837
838 // Info about necessary approvement
839 if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
840 {
841 $body .= ($this->lng->txt('reg_mail_body_pwd_generation')."\n\n");
842 }
843
844 $body .= ($this->lng->txt("reg_mail_body_text3")."\n\r");
845 $body .= $this->userObj->getProfileAsString($this->lng);
846 $mmail->Subject($subject);
847 $mmail->Body($body);
848 $mmail->Send();
849 }
850 }
851 }
852
856 public function login($password)
857 {
861 global $lng;
862
863 ilStartUpGUI::initStartUpTemplate(array('tpl.usr_registered.html', 'Services/Registration'), false);
864 $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('registration'));
865
866 $this->tpl->setVariable("TXT_WELCOME", $lng->txt("welcome") . ", " . $this->userObj->getTitle() . "!");
867 if(
868 (
869 $this->registration_settings->getRegistrationType() == IL_REG_DIRECT ||
870 $this->registration_settings->getRegistrationType() == IL_REG_CODES ||
871 $this->code_was_used
872 ) &&
873 !$this->registration_settings->passwordGenerationEnabled()
874 )
875 {
876 $this->tpl->setCurrentBlock('activation');
877 $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_registered'));
878 $this->tpl->setVariable('FORMACTION', 'login.php?cmd=post&target=' . ilUtil::stripSlashes($_GET['target']));
879 if(ilSession::get('forceShoppingCartRedirect'))
880 {
881 $this->tpl->setVariable('FORMACTION', './login.php?forceShoppingCartRedirect=1');
882 }
883 $this->tpl->setVariable('TARGET', 'target="_parent"');
884 $this->tpl->setVariable('TXT_LOGIN', $lng->txt('login_to_ilias'));
885 $this->tpl->setVariable('USERNAME', $this->userObj->getLogin());
886 $this->tpl->setVariable('PASSWORD', $password);
887 $this->tpl->parseCurrentBlock();
888 }
889 else if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE)
890 {
891 $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_submitted'));
892
893 if(IS_PAYMENT_ENABLED == true)
894 {
895 if(ilSession::get('forceShoppingCartRedirect'))
896 {
897 $this->tpl->setCurrentBlock('activation');
898 include_once 'Services/Payment/classes/class.ilShopLinkBuilder.php';
899 $shop_link = new ilShopLinkBuilder();
900 $this->tpl->setVariable('FORMACTION', $shop_link->buildLink('ilshopshoppingcartgui', '_forceShoppingCartRedirect_user=' . $this->userObj->getId()));
901 $this->tpl->setVariable('TARGET', 'target=\'_parent\'');
902
903 $this->lng->loadLanguageModule('payment');
904 $this->tpl->setVariable('TXT_LOGIN', $lng->txt('pay_goto_shopping_cart'));
905 $this->tpl->parseCurrentBlock();
906 $this->lng->loadLanguageModule('registration');
907 }
908 }
909 }
910 else if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
911 {
912 $login_url = './login.php?cmd=force_login&lang=' . $this->userObj->getLanguage();
913 $this->tpl->setVariable('TXT_REGISTERED', sprintf($lng->txt('reg_confirmation_link_successful'), $login_url));
914 $this->tpl->setVariable('REDIRECT_URL', $login_url);
915 }
916 else
917 {
918 $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_registered_passw_gen'));
919 }
920 }
921
922 protected function doProfileAutoComplete()
923 {
924 $field_id = (string)$_REQUEST["f"];
925 $term = (string)$_REQUEST["term"];
926
927 include_once "Services/User/classes/class.ilPublicUserProfileGUI.php";
929 if(sizeof($result))
930 {
931 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
933 }
934
935 exit();
936 }
937}
$result
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
const USER_FOLDER_ID
Class ilObjUserFolder.
const IL_REG_ACTIVATION
const UDF_TYPE_SELECT
const UDF_TYPE_WYSIWYG
const UDF_TYPE_TEXT
Class ilAccountMail.
Class ilAccountRegistrationGUI.
__distributeMails($password, $a_language=null)
This class represents a captcha input in a property form.
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a section header in a property form.
static encode($mixed, $suppress_native=false)
this class encapsulates the PHP mail() function.
_lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
static getAutocompleteResult($a_field_id, $a_term)
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
Class for mime mail registration notifications.
Class ilObjAuthSettingsGUI.
This class represents a selection list property in a property form.
static get($a_var)
Get a value.
Class ilShopLinkBuilder.
static trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getInstance()
Get instance.
static _getInstance()
Get instance.
Class ilUserProfile.
isLogin($a_login)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static generatePasswords($a_number)
Generate a number of passwords.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static initjQuery($a_tpl=null)
Init jQuery.
$_POST['username']
Definition: cron.php:12
$code
Definition: example_050.php:99
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $ilUser
Definition: imgupload.php:15