ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
18 require_once './Services/Registration/classes/class.ilRegistrationSettings.php';
19 require_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);
117  $code->setMaxLength(ilRegistrationCode::CODE_LENGTH);
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();
178  $up->setMode(ilUserProfile::MODE_REGISTRATION);
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  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
238  if(ilTermsOfServiceHelper::isEnabled() && $document->exists())
239  {
240  $field = new ilFormSectionHeaderGUI();
241  $field->setTitle($lng->txt('usr_agreement'));
242  $this->form->addItem($field);
243 
244  $field = new ilCustomInputGUI();
245  $field->setHTML('<div id="agreement">' . $document->getContent() . '</div>');
246  $this->form->addItem($field);
247 
248  $field = new ilCheckboxInputGUI($lng->txt('accept_usr_agreement'), 'accept_terms_of_service');
249  $field->setRequired(true);
250  $field->setValue(1);
251  $this->form->addItem($field);
252  }
253 
254  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
255  if(ilCaptchaUtil::isActiveForRegistration())
256  {
257  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
258  $captcha = new ilCaptchaInputGUI($lng->txt("captcha_code"), 'captcha_code');
259  $captcha->setRequired(true);
260  $this->form->addItem($captcha);
261  }
262 
263  $this->form->addCommandButton("saveForm", $lng->txt("register"));
264  }
265 
266  public function saveForm()
267  {
268  global $lng, $ilSetting, $rbacreview;
269 
270  $this->__initForm();
271  $form_valid = $this->form->checkInput();
272 
273  require_once 'Services/User/classes/class.ilObjUser.php';
274 
275 
276  // custom validation
277  $valid_code = $valid_role = false;
278 
279  // code
280  if($this->code_enabled)
281  {
282  $code = $this->form->getInput('usr_registration_code');
283  // could be optional
284  if(
285  $this->registration_settings->registrationCodeRequired() ||
286  strlen($code)
287  )
288  {
289  // code validation
290  include_once './Services/Registration/classes/class.ilRegistrationCode.php';
292  {
293  $code_obj = $this->form->getItemByPostVar('usr_registration_code');
294  $code_obj->setAlert($lng->txt('registration_code_not_valid'));
295  $form_valid = false;
296  }
297  else
298  {
299  $valid_code = true;
300 
301  // get role from code, check if (still) valid
302  $role_id = (int)ilRegistrationCode::getCodeRole($code);
303  if($role_id && $rbacreview->isGlobalRole($role_id))
304  {
305  $valid_role = $role_id;
306  }
307  }
308  }
309  }
310 
311  // valid codes override email domain check
312  if(!$valid_code)
313  {
314  // validate email against restricted domains
315  $email = $this->form->getInput("usr_email");
316  if($email)
317  {
318  // #10366
319  $domains = array();
320  foreach($this->registration_settings->getAllowedDomains() as $item)
321  {
322  if(trim($item))
323  {
324  $domains[] = $item;
325  }
326  }
327  if(sizeof($domains))
328  {
329  $mail_valid = false;
330  foreach($domains as $domain)
331  {
332  $domain = str_replace("*", "~~~", $domain);
333  $domain = preg_quote($domain);
334  $domain = str_replace("~~~", ".+", $domain);
335  if(preg_match("/^".$domain."$/", $email, $hit))
336  {
337  $mail_valid = true;
338  break;
339  }
340  }
341  if(!$mail_valid)
342  {
343  $mail_obj = $this->form->getItemByPostVar('usr_email');
344  $mail_obj->setAlert(sprintf($lng->txt("reg_email_domains"),
345  implode(", ", $domains)));
346  $form_valid = false;
347  }
348  }
349  }
350  }
351 
352  $error_lng_var = '';
353  if(
354  !$this->registration_settings->passwordGenerationEnabled() &&
355  !ilUtil::isPasswordValidForUserContext($this->form->getInput('usr_password'), $this->form->getInput('username'), $error_lng_var)
356  )
357  {
358  $passwd_obj = $this->form->getItemByPostVar('usr_password');
359  $passwd_obj->setAlert($lng->txt($error_lng_var));
360  $form_valid = false;
361  }
362 
363  if(ilTermsOfServiceHelper::isEnabled() && !$this->form->getInput('accept_terms_of_service'))
364  {
365  $agr_obj = $this->form->getItemByPostVar('accept_terms_of_service');
366  if($agr_obj)
367  {
368  $agr_obj->setAlert($lng->txt('force_accept_usr_agreement'));
369  }
370  else
371  {
372  ilUtil::sendFailure($lng->txt('force_accept_usr_agreement'));
373  }
374  $form_valid = false;
375  }
376 
377  // no need if role is attached to code
378  if(!$valid_role)
379  {
380  // manual selection
381  if ($this->registration_settings->roleSelectionEnabled())
382  {
383  include_once "./Services/AccessControl/classes/class.ilObjRole.php";
384  $selected_role = $this->form->getInput("usr_roles");
385  if ($selected_role && ilObjRole::_lookupAllowRegister($selected_role))
386  {
387  $valid_role = (int)$selected_role;
388  }
389  }
390  // assign by email
391  else
392  {
393  include_once 'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
394  $registration_role_assignments = new ilRegistrationRoleAssignments();
395  $valid_role = (int)$registration_role_assignments->getRoleByEmail($this->form->getInput("usr_email"));
396  }
397  }
398 
399  // no valid role could be determined
400  if (!$valid_role)
401  {
402  ilUtil::sendInfo($lng->txt("registration_no_valid_role"));
403  $form_valid = false;
404  }
405 
406  // validate username
407  $login_obj = $this->form->getItemByPostVar('username');
408  $login = $this->form->getInput("username");
409  if (!ilUtil::isLogin($login))
410  {
411  $login_obj->setAlert($lng->txt("login_invalid"));
412  $form_valid = false;
413  }
414  else if (ilObjUser::_loginExists($login))
415  {
416  $login_obj->setAlert($lng->txt("login_exists"));
417  $form_valid = false;
418  }
419  else if ((int)$ilSetting->get('allow_change_loginname') &&
420  (int)$ilSetting->get('reuse_of_loginnames') == 0 &&
422  {
423  $login_obj->setAlert($lng->txt('login_exists'));
424  $form_valid = false;
425  }
426 
427  if(!$form_valid)
428  {
429  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
430  }
431  else
432  {
433  $password = $this->__createUser($valid_role);
434  $this->__distributeMails($password, $this->form->getInput("usr_language"));
435  $this->login($password);
436  return true;
437  }
438 
439  $this->form->setValuesByPost();
440  $this->displayForm();
441  return false;
442  }
443 
444  protected function __createUser($a_role)
445  {
451  global $ilSetting, $rbacadmin, $lng;
452 
453 
454  // something went wrong with the form validation
455  if(!$a_role)
456  {
457  global $ilias;
458  $ilias->raiseError("Invalid role selection in registration".
459  ", IP: ".$_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL);
460  }
461 
462 
463  $this->userObj = new ilObjUser();
464 
465  include_once("./Services/User/classes/class.ilUserProfile.php");
466  $up = new ilUserProfile();
467  $up->setMode(ilUserProfile::MODE_REGISTRATION);
468 
469  $map = array();
470  $up->skipGroup("preferences");
471  $up->skipGroup("settings");
472  $up->skipField("password");
473  $up->skipField("birthday");
474  $up->skipField("upload");
475  foreach ($up->getStandardFields() as $k => $v)
476  {
477  if($v["method"])
478  {
479  $method = "set".substr($v["method"], 3);
480  if(method_exists($this->userObj, $method))
481  {
482  if ($k != "username")
483  {
484  $k = "usr_".$k;
485  }
486  $field_obj = $this->form->getItemByPostVar($k);
487  if($field_obj)
488  {
489 
490  $this->userObj->$method($this->form->getInput($k));
491  }
492  }
493  }
494  }
495 
496  $this->userObj->setFullName();
497 
498  $birthday_obj = $this->form->getItemByPostVar("usr_birthday");
499  if($birthday_obj)
500  {
501  $birthday = $this->form->getInput("usr_birthday");
502  $this->userObj->setBirthday($birthday);
503  }
504 
505  $this->userObj->setTitle($this->userObj->getFullname());
506  $this->userObj->setDescription($this->userObj->getEmail());
507 
508  if ($this->registration_settings->passwordGenerationEnabled())
509  {
510  $password = ilUtil::generatePasswords(1);
511  $password = $password[0];
512  }
513  else
514  {
515  $password = $this->form->getInput("usr_password");
516  }
517  $this->userObj->setPasswd($password);
518 
519 
520  // Set user defined data
521  include_once './Services/User/classes/class.ilUserDefinedFields.php';
522  $user_defined_fields =& ilUserDefinedFields::_getInstance();
523  $defs = $user_defined_fields->getRegistrationDefinitions();
524  $udf = array();
525  foreach ($_POST as $k => $v)
526  {
527  if (substr($k, 0, 4) == "udf_")
528  {
529  $f = substr($k, 4);
530  $udf[$f] = $v;
531  }
532  }
533  $this->userObj->setUserDefinedData($udf);
534 
535  $this->userObj->setTimeLimitOwner(7);
536 
537 
538  $access_limit = null;
539 
540  $this->code_was_used = false;
541  if($this->code_enabled)
542  {
543  $code_local_roles = $code_has_access_limit = null;
544 
545  // #10853 - could be optional
546  $code = $this->form->getInput('usr_registration_code');
547  if($code)
548  {
549  include_once './Services/Registration/classes/class.ilRegistrationCode.php';
550 
551  // set code to used
553  $this->code_was_used = true;
554 
555  // handle code attached local role(s) and access limitation
557  if($code_data["role_local"])
558  {
559  // need user id before we can assign role(s)
560  $code_local_roles = explode(";", $code_data["role_local"]);
561  }
562  if($code_data["alimit"])
563  {
564  // see below
565  $code_has_access_limit = true;
566 
567  switch($code_data["alimit"])
568  {
569  case "absolute":
570  $abs = date_parse($code_data["alimitdt"]);
571  $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']);
572  break;
573 
574  case "relative":
575  $rel = unserialize($code_data["alimitdt"]);
576  $access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 +
577  $rel["y"] * 31536000 + time();
578  break;
579  }
580  }
581  }
582  }
583 
584  // code access limitation will override any other access limitation setting
585  if (!($this->code_was_used && $code_has_access_limit) &&
586  $this->registration_settings->getAccessLimitation())
587  {
588  include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
589  $access_limitations_obj = new ilRegistrationRoleAccessLimitations();
590  switch($access_limitations_obj->getMode($a_role))
591  {
592  case 'absolute':
593  $access_limit = $access_limitations_obj->getAbsolute($a_role);
594  break;
595 
596  case 'relative':
597  $rel_d = (int) $access_limitations_obj->getRelative($a_role,'d');
598  $rel_m = (int) $access_limitations_obj->getRelative($a_role,'m');
599  $rel_y = (int) $access_limitations_obj->getRelative($a_role,'y');
600  $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
601  break;
602  }
603  }
604 
605  if($access_limit)
606  {
607  $this->userObj->setTimeLimitUnlimited(0);
608  $this->userObj->setTimeLimitUntil($access_limit);
609  }
610  else
611  {
612  $this->userObj->setTimeLimitUnlimited(1);
613  $this->userObj->setTimeLimitUntil(time());
614  }
615 
616  $this->userObj->setTimeLimitFrom(time());
617 
618  include_once './Services/User/classes/class.ilUserCreationContext.php';
620 
621  $this->userObj->create();
622 
623 
624  if($this->registration_settings->getRegistrationType() == IL_REG_DIRECT ||
625  $this->registration_settings->getRegistrationType() == IL_REG_CODES ||
627  {
628  $this->userObj->setActive(1,0);
629  }
630  else if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
631  {
632  $this->userObj->setActive(0,0);
633  }
634  else
635  {
636  $this->userObj->setActive(0,0);
637  }
638 
639  $this->userObj->updateOwner();
640 
641  // set a timestamp for last_password_change
642  // this ts is needed by ilSecuritySettings
643  $this->userObj->setLastPasswordChangeTS( time() );
644 
645  $this->userObj->setIsSelfRegistered(true);
646 
647  //insert user data in table user_data
648  $this->userObj->saveAsNew();
649 
650  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
652 
653  // setup user preferences
654  $this->userObj->setLanguage($this->form->getInput('usr_language'));
655  $hits_per_page = $ilSetting->get("hits_per_page");
656  if ($hits_per_page < 10)
657  {
658  $hits_per_page = 10;
659  }
660  $this->userObj->setPref("hits_per_page", $hits_per_page);
661  if(strlen($_GET['target']) > 0)
662  {
663  $this->userObj->setPref('reg_target', ilUtil::stripSlashes($_GET['target']));
664  }
665  /*$show_online = $ilSetting->get("show_users_online");
666  if ($show_online == "")
667  {
668  $show_online = "y";
669  }
670  $this->userObj->setPref("show_users_online", $show_online);*/
671  $this->userObj->setPref('bs_allow_to_contact_me', $ilSetting->get('bs_allow_to_contact_me', 'n'));
672  $this->userObj->setPref('chat_osc_accept_msg', $ilSetting->get('chat_osc_accept_msg', 'n'));
673  $this->userObj->writePrefs();
674 
675 
676  $rbacadmin->assignUser((int)$a_role, $this->userObj->getId());
677 
678  // local roles from code
679  if($this->code_was_used && is_array($code_local_roles))
680  {
681  foreach(array_unique($code_local_roles) as $local_role_obj_id)
682  {
683  // is given role (still) valid?
684  if(ilObject::_lookupType($local_role_obj_id) == "role")
685  {
686  $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
687 
688  // patch to remove for 45 due to mantis 21953
689  $role_obj = $GLOBALS['rbacreview']->getObjectOfRole($local_role_obj_id);
690  switch(ilObject::_lookupType($role_obj))
691  {
692  case 'crs':
693  case 'grp':
694  $role_refs = ilObject::_getAllReferences($role_obj);
695  $role_ref = end($role_refs);
696  ilObjUser::_addDesktopItem($this->userObj->getId(),$role_ref,ilObject::_lookupType($role_obj));
697  break;
698  }
699  }
700  }
701  }
702 
703  return $password;
704  }
705 
706  protected function __distributeMails($password, $a_language = null)
707  {
708  global $ilSetting;
709 
710  include_once './Services/Language/classes/class.ilLanguage.php';
711  include_once './Services/User/classes/class.ilObjUser.php';
712  include_once "Services/Mail/classes/class.ilFormatMail.php";
713  include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
714 
715  // Always send mail to approvers
716  if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
717  {
718  $mail = new ilRegistrationMailNotification();
720  $mail->setRecipients($this->registration_settings->getApproveRecipients());
721  $mail->setAdditionalInformation(array('usr' => $this->userObj));
722  $mail->send();
723  }
724  else
725  {
726  $mail = new ilRegistrationMailNotification();
728  $mail->setRecipients($this->registration_settings->getApproveRecipients());
729  $mail->setAdditionalInformation(array('usr' => $this->userObj));
730  $mail->send();
731 
732  }
733  // Send mail to new user
734 
735  // Registration with confirmation link ist enabled
736  if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used)
737  {
738  include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
739 
742  $mail->setRecipients(array($this->userObj));
743  $mail->setAdditionalInformation(
744  array(
745  'usr' => $this->userObj,
746  'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
747  )
748  );
749  $mail->send();
750  }
751  else
752  {
753  // try individual account mail in user administration
754  include_once("Services/Mail/classes/class.ilAccountMail.php");
755  include_once './Services/User/classes/class.ilObjUserFolder.php';
756 
757  $amail = ilObjUserFolder::_lookupNewAccountMail($a_language);
758  if (trim($amail["body"]) == "" || trim($amail["subject"]) == "")
759  {
760  $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
761  }
762  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
763  {
764  $acc_mail = new ilAccountMail();
765  $acc_mail->setUser($this->userObj);
766  if ($this->registration_settings->passwordGenerationEnabled())
767  {
768  $acc_mail->setUserPassword($password);
769  }
770 
771  if($amail["att_file"])
772  {
773  include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
775  $fs->create();
776  $path = $fs->getAbsolutePath()."/";
777 
778  $acc_mail->addAttachment($path."/".$amail["lang"], $amail["att_file"]);
779  }
780 
781  $acc_mail->send();
782  }
783  else // do default mail
784  {
785  include_once "Services/Mail/classes/class.ilMimeMail.php";
786 
787  $mmail = new ilMimeMail();
788  $mmail->autoCheck(false);
789  $mmail->From($ilSetting->get("admin_email"));
790  $mmail->To($this->userObj->getEmail());
791 
792  // mail subject
793  $subject = $this->lng->txt("reg_mail_subject");
794 
795  // mail body
796  $body = $this->lng->txt("reg_mail_body_salutation")." ".$this->userObj->getFullname().",\n\n".
797  $this->lng->txt("reg_mail_body_text1")."\n\n".
798  $this->lng->txt("reg_mail_body_text2")."\n".
799  ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
800  $body .= $this->lng->txt("login").": ".$this->userObj->getLogin()."\n";
801 
802  if ($this->registration_settings->passwordGenerationEnabled())
803  {
804  $body.= $this->lng->txt("passwd").": ".$password."\n";
805  }
806  $body.= "\n";
807 
808  // Info about necessary approvement
809  if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
810  {
811  $body .= ($this->lng->txt('reg_mail_body_pwd_generation')."\n\n");
812  }
813 
814  $body .= ($this->lng->txt("reg_mail_body_text3")."\n\r");
815  $body .= $this->userObj->getProfileAsString($this->lng);
816  $mmail->Subject($subject);
817  $mmail->Body($body);
818  $mmail->Send();
819  }
820  }
821  }
822 
826  public function login($password)
827  {
831  global $lng;
832 
833  ilStartUpGUI::initStartUpTemplate(array('tpl.usr_registered.html', 'Services/Registration'), false);
834  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('registration'));
835 
836  $this->tpl->setVariable("TXT_WELCOME", $lng->txt("welcome") . ", " . $this->userObj->getTitle() . "!");
837  if(
838  (
839  $this->registration_settings->getRegistrationType() == IL_REG_DIRECT ||
840  $this->registration_settings->getRegistrationType() == IL_REG_CODES ||
842  ) &&
843  !$this->registration_settings->passwordGenerationEnabled()
844  )
845  {
846  // store authenticated user in session
847  ilSession::set('registered_user', $this->userObj->getId());
848 
849  $this->tpl->setCurrentBlock('activation');
850  $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_registered'));
851 
852  $action = $GLOBALS['DIC']->ctrl()->getFormAction($this, 'login').'&target='. ilUtil::stripSlashes($_GET['target']);
853  $this->tpl->setVariable('FORMACTION', $action);
854 
855  $this->tpl->setVariable('TXT_LOGIN', $lng->txt('login_to_ilias'));
856  $this->tpl->parseCurrentBlock();
857  }
858  else if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE)
859  {
860  $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_submitted'));
861  }
862  else if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
863  {
864  $login_url = './login.php?cmd=force_login&lang=' . $this->userObj->getLanguage();
865  $this->tpl->setVariable('TXT_REGISTERED', sprintf($lng->txt('reg_confirmation_link_successful'), $login_url));
866  $this->tpl->setVariable('REDIRECT_URL', $login_url);
867  }
868  else
869  {
870  $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_registered_passw_gen'));
871  }
872  }
873 
879  protected function showLogin()
880  {
884  $auth_session = $GLOBALS['DIC']['ilAuthSession'];
885  $auth_session->setAuthenticated(
886  true,
887  ilSession::get('registered_user')
888  );
889  ilInitialisation::initUserAccount();
890  return ilInitialisation::redirectToStartingPage();
891  }
892 
893  protected function doProfileAutoComplete()
894  {
895  $field_id = (string)$_REQUEST["f"];
896  $term = (string)$_REQUEST["term"];
897 
898  include_once "Services/User/classes/class.ilPublicUserProfileGUI.php";
900  if(sizeof($result))
901  {
902  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
904  }
905 
906  exit();
907  }
908 }
const UDF_TYPE_SELECT
global $ilErr
Definition: raiseError.php:16
$path
Definition: aliased.php:25
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
Class for mime mail registration notifications.
static _getInstance()
Get instance.
This class represents a selection list property in a property form.
$result
This class represents a property form user interface.
Class ilAccountRegistrationGUI.
This class represents a captcha input in a property form.
$_GET["client_id"]
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static getInstance()
Get instance.
This class represents a section header in a property form.
$code
Definition: example_050.php:99
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
static getAutocompleteResult($a_field_id, $a_term)
static get($a_var)
Get a value.
Class ilUserProfile.
static set($a_var, $a_val)
Set a value.
This class represents a checkbox property in a property form.
Add rich text string
The name of the decorator.
static generatePasswords($a_number)
Generate a number of passwords.
__distributeMails($password, $a_language=null)
static _getAllReferences($a_id)
get all reference ids of object
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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 encode($mixed, $suppress_native=false)
if(!is_array($argv)) $options
this class encapsulates the PHP mail() function.
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
static _lookupNewAccountMail($a_lang)
const UDF_TYPE_TEXT
const IL_REG_ACTIVATION
This class represents a text property in a property form.
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
const UDF_TYPE_WYSIWYG
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilObjAuthSettingsGUI.
This class represents a custom property in a property form.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user&#39;s personal desktop
static isLogin($a_login)
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
Class ilAccountMail.
static initjQuery($a_tpl=null)
Init jQuery.
const USER_FOLDER_ID
Class ilObjUserFolder.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static _lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
$_POST["username"]
setRequired($a_required)
Set Required.
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.