ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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  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();
473  $up->setMode(ilUserProfile::MODE_REGISTRATION);
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
581  $code_data = ilRegistrationCode::getCodeData($code);
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 ||
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  $show_online = $ilSetting->get("show_users_online");
693  if ($show_online == "")
694  {
695  $show_online = "y";
696  }
697  $this->userObj->setPref("show_users_online", $show_online);
698  $this->userObj->writePrefs();
699 
700 
701  $rbacadmin->assignUser((int)$a_role, $this->userObj->getId());
702 
703  // local roles from code
704  if($this->code_was_used && is_array($code_local_roles))
705  {
706  foreach(array_unique($code_local_roles) as $local_role_obj_id)
707  {
708  // is given role (still) valid?
709  if(ilObject::_lookupType($local_role_obj_id) == "role")
710  {
711  $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
712 
713  // patch to remove for 45 due to mantis 21953
714  $role_obj = $GLOBALS['rbacreview']->getObjectOfRole($local_role_obj_id);
715  switch(ilObject::_lookupType($role_obj))
716  {
717  case 'crs':
718  case 'grp':
719  $role_refs = ilObject::_getAllReferences($role_obj);
720  $role_ref = end($role_refs);
721  ilObjUser::_addDesktopItem($this->userObj->getId(),$role_ref,ilObject::_lookupType($role_obj));
722  break;
723  }
724  }
725  }
726  }
727 
728  return $password;
729  }
730 
731  protected function __distributeMails($password, $a_language = null)
732  {
733  global $ilSetting;
734 
735  include_once './Services/Language/classes/class.ilLanguage.php';
736  include_once './Services/User/classes/class.ilObjUser.php';
737  include_once "Services/Mail/classes/class.ilFormatMail.php";
738  include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
739 
740  // Always send mail to approvers
741  if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
742  {
743  $mail = new ilRegistrationMailNotification();
745  $mail->setRecipients($this->registration_settings->getApproveRecipients());
746  $mail->setAdditionalInformation(array('usr' => $this->userObj));
747  $mail->send();
748  }
749  else
750  {
751  $mail = new ilRegistrationMailNotification();
753  $mail->setRecipients($this->registration_settings->getApproveRecipients());
754  $mail->setAdditionalInformation(array('usr' => $this->userObj));
755  $mail->send();
756 
757  }
758  // Send mail to new user
759 
760  // Registration with confirmation link ist enabled
761  if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used)
762  {
763  include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
764 
767  $mail->setRecipients(array($this->userObj));
768  $mail->setAdditionalInformation(
769  array(
770  'usr' => $this->userObj,
771  'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
772  )
773  );
774  $mail->send();
775  }
776  else
777  {
778  // try individual account mail in user administration
779  include_once("Services/Mail/classes/class.ilAccountMail.php");
780  include_once './Services/User/classes/class.ilObjUserFolder.php';
781 
782  $amail = ilObjUserFolder::_lookupNewAccountMail($a_language);
783  if (trim($amail["body"]) == "" || trim($amail["subject"]) == "")
784  {
785  $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
786  }
787  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
788  {
789  $acc_mail = new ilAccountMail();
790  $acc_mail->setUser($this->userObj);
791  if ($this->registration_settings->passwordGenerationEnabled())
792  {
793  $acc_mail->setUserPassword($password);
794  }
795 
796  if($amail["att_file"])
797  {
798  include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
800  $fs->create();
801  $path = $fs->getAbsolutePath()."/";
802 
803  $acc_mail->addAttachment($path."/".$amail["lang"], $amail["att_file"]);
804  }
805 
806  $acc_mail->send();
807  }
808  else // do default mail
809  {
810  include_once "Services/Mail/classes/class.ilMimeMail.php";
811 
812  $mmail = new ilMimeMail();
813  $mmail->autoCheck(false);
814  $mmail->From($ilSetting->get("admin_email"));
815  $mmail->To($this->userObj->getEmail());
816 
817  // mail subject
818  $subject = $this->lng->txt("reg_mail_subject");
819 
820  // mail body
821  $body = $this->lng->txt("reg_mail_body_salutation")." ".$this->userObj->getFullname().",\n\n".
822  $this->lng->txt("reg_mail_body_text1")."\n\n".
823  $this->lng->txt("reg_mail_body_text2")."\n".
824  ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
825  $body .= $this->lng->txt("login").": ".$this->userObj->getLogin()."\n";
826 
827  if ($this->registration_settings->passwordGenerationEnabled())
828  {
829  $body.= $this->lng->txt("passwd").": ".$password."\n";
830  }
831  $body.= "\n";
832 
833  // Info about necessary approvement
834  if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
835  {
836  $body .= ($this->lng->txt('reg_mail_body_pwd_generation')."\n\n");
837  }
838 
839  $body .= ($this->lng->txt("reg_mail_body_text3")."\n\r");
840  $body .= $this->userObj->getProfileAsString($this->lng);
841  $mmail->Subject($subject);
842  $mmail->Body($body);
843  $mmail->Send();
844  }
845  }
846  }
847 
851  public function login($password)
852  {
856  global $lng;
857 
858  ilStartUpGUI::initStartUpTemplate(array('tpl.usr_registered.html', 'Services/Registration'), false);
859  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('registration'));
860 
861  $this->tpl->setVariable("TXT_WELCOME", $lng->txt("welcome") . ", " . $this->userObj->getTitle() . "!");
862  if(
863  (
864  $this->registration_settings->getRegistrationType() == IL_REG_DIRECT ||
865  $this->registration_settings->getRegistrationType() == IL_REG_CODES ||
867  ) &&
868  !$this->registration_settings->passwordGenerationEnabled()
869  )
870  {
871  $this->tpl->setCurrentBlock('activation');
872  $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_registered'));
873  $this->tpl->setVariable('FORMACTION', 'login.php?cmd=post&target=' . ilUtil::stripSlashes($_GET['target']));
874  if(ilSession::get('forceShoppingCartRedirect'))
875  {
876  $this->tpl->setVariable('FORMACTION', './login.php?forceShoppingCartRedirect=1');
877  }
878  $this->tpl->setVariable('TARGET', 'target="_parent"');
879  $this->tpl->setVariable('TXT_LOGIN', $lng->txt('login_to_ilias'));
880  $this->tpl->setVariable('USERNAME', $this->userObj->getLogin());
881  $this->tpl->setVariable('PASSWORD', $password);
882  $this->tpl->parseCurrentBlock();
883  }
884  else if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE)
885  {
886  $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_submitted'));
887 
888  if(IS_PAYMENT_ENABLED == true)
889  {
890  if(ilSession::get('forceShoppingCartRedirect'))
891  {
892  $this->tpl->setCurrentBlock('activation');
893  include_once 'Services/Payment/classes/class.ilShopLinkBuilder.php';
894  $shop_link = new ilShopLinkBuilder();
895  $this->tpl->setVariable('FORMACTION', $shop_link->buildLink('ilshopshoppingcartgui', '_forceShoppingCartRedirect_user=' . $this->userObj->getId()));
896  $this->tpl->setVariable('TARGET', 'target=\'_parent\'');
897 
898  $this->lng->loadLanguageModule('payment');
899  $this->tpl->setVariable('TXT_LOGIN', $lng->txt('pay_goto_shopping_cart'));
900  $this->tpl->parseCurrentBlock();
901  $this->lng->loadLanguageModule('registration');
902  }
903  }
904  }
905  else if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
906  {
907  $login_url = './login.php?cmd=force_login&lang=' . $this->userObj->getLanguage();
908  $this->tpl->setVariable('TXT_REGISTERED', sprintf($lng->txt('reg_confirmation_link_successful'), $login_url));
909  $this->tpl->setVariable('REDIRECT_URL', $login_url);
910  }
911  else
912  {
913  $this->tpl->setVariable('TXT_REGISTERED', $lng->txt('txt_registered_passw_gen'));
914  }
915  }
916 
917  protected function doProfileAutoComplete()
918  {
919  $field_id = (string)$_REQUEST["f"];
920  $term = (string)$_REQUEST["term"];
921 
922  include_once "Services/User/classes/class.ilPublicUserProfileGUI.php";
924  if(sizeof($result))
925  {
926  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
928  }
929 
930  exit();
931  }
932 }
const UDF_TYPE_SELECT
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
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.
$cmd
Definition: sahs_server.php:35
static getAutocompleteResult($a_field_id, $a_term)
static get($a_var)
Get a value.
Class ilUserProfile.
This class represents a checkbox property in a property form.
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
_lookupAllowRegister($a_role_id)
check whether role is allowed in user registration or not
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.
$GLOBALS['ct_recipient']
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
setSize($a_size)
Set Size.
const UDF_TYPE_TEXT
const IL_REG_ACTIVATION
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
const UDF_TYPE_WYSIWYG
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
global $ilUser
Definition: imgupload.php:15
isLogin($a_login)
Class ilShopLinkBuilder.
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
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.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
setRequired($a_required)
Set Required.
static _doesLoginnameExistInHistory($a_login)
Checks wether the passed loginname already exists in history.