ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAccountRegistrationGUI Class Reference

Class ilAccountRegistrationGUI. More...

+ Collaboration diagram for ilAccountRegistrationGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 displayForm ()
 
 saveForm ()
 
 login ()
 

Protected Member Functions

 __initForm ()
 
 __distributeMails ($password)
 
 doProfileAutoComplete ()
 

Protected Attributes

 $registration_settings
 
 $code_enabled
 
 $code_was_used
 
 $userObj
 
 $termsOfServiceEvaluation
 
 $recommended_content_manager
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountRegistrationGUI::__construct ( )

Definition at line 38 of file class.ilAccountRegistrationGUI.php.

References $DIC, $ilCtrl, $lng, and $tpl.

39  {
40  global $DIC;
41 
42  $ilCtrl = $DIC->ctrl();
43  $tpl = $DIC['tpl'];
44  $lng = $DIC->language();
45 
46  $this->tpl = &$tpl;
47 
48  $this->ctrl = &$ilCtrl;
49  $this->ctrl->saveParameter($this, 'lang');
50 
51  $this->lng = &$lng;
52  $this->lng->loadLanguageModule('registration');
53 
54  $this->registration_settings = new ilRegistrationSettings();
55 
56  $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
57  $this->registration_settings->getAllowCodes());
58 
59  $this->termsOfServiceEvaluation = $DIC['tos.document.evaluator'];
60  $this->recommended_content_manager = new ilRecommendedContentManager();
61  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $ilCtrl
Definition: ilias.php:18
$lng
Class ilObjAuthSettingsGUI.
$DIC
Definition: xapitoken.php:46
Recommended content manager (business logic)

Member Function Documentation

◆ __distributeMails()

ilAccountRegistrationGUI::__distributeMails (   $password)
protected

Definition at line 627 of file class.ilAccountRegistrationGUI.php.

References $code_was_used, $password, ilLoggerFactory\getLogger(), IL_REG_ACTIVATION, IL_REG_APPROVE, ilRegistrationMimeMailNotification\TYPE_NOTIFICATION_ACTIVATION, ilRegistrationMailNotification\TYPE_NOTIFICATION_APPROVERS, and ilRegistrationMailNotification\TYPE_NOTIFICATION_CONFIRMATION.

Referenced by saveForm().

628  {
629 
630  // Always send mail to approvers
631  if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) {
632  $mail = new ilRegistrationMailNotification();
634  $mail->setRecipients($this->registration_settings->getApproveRecipients());
635  $mail->setAdditionalInformation(array('usr' => $this->userObj));
636  $mail->send();
637  } else {
638  $mail = new ilRegistrationMailNotification();
640  $mail->setRecipients($this->registration_settings->getApproveRecipients());
641  $mail->setAdditionalInformation(array('usr' => $this->userObj));
642  $mail->send();
643  }
644 
645  // Send mail to new user
646  // Registration with confirmation link ist enabled
647  if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used) {
648 
651  $mail->setRecipients(array($this->userObj));
652  $mail->setAdditionalInformation(
653  array(
654  'usr' => $this->userObj,
655  'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
656  )
657  );
658  $mail->send();
659  } else {
660  $accountMail = new ilAccountRegistrationMail(
661  $this->registration_settings,
662  $this->lng,
664  );
665  $accountMail->withDirectRegistrationMode()->send($this->userObj, $password, $this->code_was_used);
666  }
667  }
Class for mime mail registration notifications.
Class ilAccountRegistrationMail.
const IL_REG_ACTIVATION
$password
Definition: cron.php:14
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __initForm()

ilAccountRegistrationGUI::__initForm ( )
protected

Definition at line 102 of file class.ilAccountRegistrationGUI.php.

References $DIC, $ilUser, ilUserDefinedFields\_getInstance(), ilRegistrationCode\CODE_LENGTH, ilCustomUserFieldsHelper\getInstance(), IL_REG_ACTIVATION, iljQueryUtil\initjQuery(), ilTermsOfServiceHelper\isEnabled(), ilUserProfile\MODE_REGISTRATION, and ilFormPropertyGUI\setRequired().

Referenced by displayForm(), and saveForm().

103  {
104  global $DIC;
105 
106  $ilUser = $DIC->user();
107 
108  $ilUser->setLanguage($this->lng->getLangKey());
109  $ilUser->setId(ANONYMOUS_USER_ID);
110 
111  // needed for multi-text-fields (interests)
113 
114  $this->form = new ilPropertyFormGUI();
115  $this->form->setFormAction($this->ctrl->getFormAction($this));
116 
117 
118  // code handling
119 
120  if ($this->code_enabled) {
121  $field = new ilFormSectionHeaderGUI();
122  $field->setTitle($this->lng->txt('registration_codes_type_reg'));
123  $this->form->addItem($field);
124  $code = new ilTextInputGUI($this->lng->txt("registration_code"), "usr_registration_code");
125  $code->setSize(40);
126  $code->setMaxLength(ilRegistrationCode::CODE_LENGTH);
127  if ((bool) $this->registration_settings->registrationCodeRequired()) {
128  $code->setRequired(true);
129  $code->setInfo($this->lng->txt("registration_code_required_info"));
130  } else {
131  $code->setInfo($this->lng->txt("registration_code_optional_info"));
132  }
133  $this->form->addItem($code);
134  }
135 
136 
137  // user defined fields
138  $user_defined_data = $ilUser->getUserDefinedData();
139 
140  $user_defined_fields = ilUserDefinedFields::_getInstance();
141  $custom_fields = array();
142 
143  foreach ($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition) {
144  $fprop = ilCustomUserFieldsHelper::getInstance()->getFormPropertyForDefinition(
145  $definition,
146  true,
147  $user_defined_data['f_' . $field_id]
148  );
149  if ($fprop instanceof ilFormPropertyGUI) {
150  $custom_fields['udf_' . $definition['field_id']] = $fprop;
151  }
152  }
153 
154  // standard fields
155  $up = new ilUserProfile();
156  $up->setMode(ilUserProfile::MODE_REGISTRATION);
157  $up->skipGroup("preferences");
158 
159  $up->setAjaxCallback(
160  $this->ctrl->getLinkTarget($this, 'doProfileAutoComplete', '', true)
161  );
162 
163  $this->lng->loadLanguageModule("user");
164 
165  // add fields to form
166  $up->addStandardFieldsToForm($this->form, null, $custom_fields);
167  unset($custom_fields);
168 
169 
170  // set language selection to current display language
171  $flang = $this->form->getItemByPostVar("usr_language");
172  if ($flang) {
173  $flang->setValue($this->lng->getLangKey());
174  }
175 
176  // add information to role selection (if not hidden)
177  if ($this->code_enabled) {
178  $role = $this->form->getItemByPostVar("usr_roles");
179  if ($role && $role->getType() == "select") {
180  $role->setInfo($this->lng->txt("registration_code_role_info"));
181  }
182  }
183 
184  // #11407
185  $domains = array();
186  foreach ($this->registration_settings->getAllowedDomains() as $item) {
187  if (trim($item)) {
188  $domains[] = $item;
189  }
190  }
191  if (sizeof($domains)) {
192  $mail_obj = $this->form->getItemByPostVar('usr_email');
193  $mail_obj->setInfo(sprintf(
194  $this->lng->txt("reg_email_domains"),
195  implode(", ", $domains)
196  ) . "<br />" .
197  ($this->code_enabled ? $this->lng->txt("reg_email_domains_code") : ""));
198  }
199 
200  // #14272
201  if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) {
202  $mail_obj = $this->form->getItemByPostVar('usr_email');
203  if ($mail_obj) { // #16087
204  $mail_obj->setRequired(true);
205  }
206  }
207 
208  if (\ilTermsOfServiceHelper::isEnabled() && $this->termsOfServiceEvaluation->hasDocument()) {
209  $document = $this->termsOfServiceEvaluation->document();
210 
211  $field = new ilFormSectionHeaderGUI();
212  $field->setTitle($this->lng->txt('usr_agreement'));
213  $this->form->addItem($field);
214 
215  $field = new ilCustomInputGUI();
216  $field->setHTML('<div id="agreement">' . $document->content() . '</div>');
217  $this->form->addItem($field);
218 
219  $field = new ilCheckboxInputGUI($this->lng->txt('accept_usr_agreement'), 'accept_terms_of_service');
220  $field->setRequired(true);
221  $field->setValue(1);
222  $this->form->addItem($field);
223  }
224 
225 
226  if (ilCaptchaUtil::isActiveForRegistration()) {
227  $captcha = new ilCaptchaInputGUI($this->lng->txt("captcha_code"), 'captcha_code');
228  $captcha->setRequired(true);
229  $this->form->addItem($captcha);
230  }
231 
232  $this->form->addCommandButton("saveForm", $this->lng->txt("register"));
233  }
static _getInstance()
Get instance.
This class represents a property form user interface.
This class represents a captcha input in a property form.
This class represents a section header in a property form.
Class ilUserProfile.
This class represents a checkbox property in a property form.
const IL_REG_ACTIVATION
$ilUser
Definition: imgupload.php:18
This class represents a custom property in a property form.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
This class represents a property in a property form.
$DIC
Definition: xapitoken.php:46
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayForm()

ilAccountRegistrationGUI::displayForm ( )

Definition at line 89 of file class.ilAccountRegistrationGUI.php.

References $tpl, and __initForm().

Referenced by executeCommand(), and saveForm().

90  {
91 
92  $tpl = ilStartUpGUI::initStartUpTemplate(array('tpl.usr_registration.html', 'Services/Registration'), true);
93  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('registration'));
94 
95  if (!$this->form) {
96  $this->__initForm();
97  }
98  $tpl->setVariable('FORM', $this->form->getHTML());
99  return $tpl;
100  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doProfileAutoComplete()

ilAccountRegistrationGUI::doProfileAutoComplete ( )
protected

Definition at line 721 of file class.ilAccountRegistrationGUI.php.

References $result, ilJsonUtil\encode(), exit, and ilPublicUserProfileGUI\getAutocompleteResult().

722  {
723  $field_id = (string) $_REQUEST["f"];
724  $term = (string) $_REQUEST["term"];
725 
727  if (sizeof($result)) {
729  }
730 
731  exit();
732  }
exit
Definition: login.php:29
$result
static getAutocompleteResult($a_field_id, $a_term)
static encode($mixed, $suppress_native=false)
+ Here is the call graph for this function:

◆ executeCommand()

ilAccountRegistrationGUI::executeCommand ( )

Definition at line 63 of file class.ilAccountRegistrationGUI.php.

References $DIC, $ilErr, $tpl, displayForm(), IL_REG_DISABLED, and ilStartUpGUI\printToGlobalTemplate().

64  {
65  global $DIC;
66 
67  if ($this->registration_settings->getRegistrationType() == IL_REG_DISABLED) {
68  $ilErr = $DIC['ilErr'];
69  $ilErr->raiseError($this->lng->txt('reg_disabled'), $ilErr->FATAL);
70  }
71 
72  $cmd = $this->ctrl->getCmd();
73  switch ($cmd) {
74  case 'saveForm':
75  $tpl = $this->$cmd();
76  break;
77  default:
78  $tpl = $this->displayForm();
79  }
80 
81  $gtpl = $this->tpl;
82  $gtpl->setPermanentLink('usr', null, 'registration');
84  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
static printToGlobalTemplate($tpl)
$ilErr
Definition: raiseError.php:18
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ login()

ilAccountRegistrationGUI::login ( )

Definition at line 669 of file class.ilAccountRegistrationGUI.php.

References $code_was_used, $DIC, Vendor\Package\$f, $tpl, IL_REG_ACTIVATION, IL_REG_APPROVE, IL_REG_CODES, IL_REG_DIRECT, and ilInitialisation\initUserAccount().

Referenced by saveForm().

670  {
671  global $DIC;
672  $f = $DIC->ui()->factory();
673  $renderer = $DIC->ui()->renderer();
674 
675  $tpl = ilStartUpGUI::initStartUpTemplate(array('tpl.usr_registered.html', 'Services/Registration'), false);
676  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('registration'));
677 
678  $tpl->setVariable("TXT_WELCOME", $this->lng->txt("welcome") . ", " . $this->userObj->getTitle() . "!");
679  if (
680  (
681  $this->registration_settings->getRegistrationType() == IL_REG_DIRECT ||
682  $this->registration_settings->getRegistrationType() == IL_REG_CODES ||
684  ) &&
685  !$this->registration_settings->passwordGenerationEnabled()
686  ) {
687  $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('txt_registered'));
688 
689  $login_link = $renderer->render($f->link()->standard($this->lng->txt('login_to_ilias'), './login.php?cmd=force_login&lang=' . $this->userObj->getLanguage()));
690  $tpl->setVariable('LOGIN_LINK', $login_link);
691  } elseif ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE) {
692  $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('txt_submitted'));
693  } elseif ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) {
694  $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('reg_confirmation_link_successful'));
695  } else {
696  $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('txt_registered_passw_gen'));
697  }
698  return $tpl;
699  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
const IL_REG_ACTIVATION
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveForm()

ilAccountRegistrationGUI::saveForm ( )

Definition at line 235 of file class.ilAccountRegistrationGUI.php.

References $_GET, $_POST, $_SERVER, $code_was_used, $DIC, $email, Vendor\Package\$f, $GLOBALS, $ilSetting, $login, $password, __distributeMails(), __initForm(), ilObjUser\_doesLoginnameExistInHistory(), ilObject\_getAllReferences(), ilUserDefinedFields\_getInstance(), ilObjUser\_loginExists(), ilObjRole\_lookupAllowRegister(), ilObject\_lookupType(), ilUserCreationContext\CONTEXT_REGISTRATION, displayForm(), ilUtil\generatePasswords(), ilRegistrationCode\getCodeData(), ilRegistrationCode\getCodeRole(), ilUserCreationContext\getInstance(), ilSystemSupportContacts\getMailsToAddress(), IL_REG_ACTIVATION, IL_REG_CODES, IL_REG_DIRECT, ilTermsOfServiceHelper\isEnabled(), ilUtil\isLogin(), ilUtil\isPasswordValidForUserContext(), ilRegistrationCode\isValidRegistrationCode(), login(), ilUserProfile\MODE_REGISTRATION, ilUtil\prepareFormOutput(), ilUtil\sendFailure(), ilUtil\sendInfo(), ilUtil\stripSlashes(), and ilRegistrationCode\useCode().

236  {
237  global $DIC;
238 
239  $ilSetting = $DIC->settings();
240  $rbacreview = $DIC->rbac()->review();
241 
242  $this->__initForm();
243  $form_valid = $this->form->checkInput();
244 
245  // custom validation
246  $valid_code = $valid_role = false;
247 
248  // code
249  if ($this->code_enabled) {
250  $code = $this->form->getInput('usr_registration_code');
251  // could be optional
252  if (
253  $this->registration_settings->registrationCodeRequired() ||
254  strlen($code)
255  ) {
256  // code validation
258  $code_obj = $this->form->getItemByPostVar('usr_registration_code');
259  $code_obj->setAlert($this->lng->txt('registration_code_not_valid'));
260  $form_valid = false;
261  } else {
262  $valid_code = true;
263 
264  // get role from code, check if (still) valid
265  $role_id = (int) ilRegistrationCode::getCodeRole($code);
266  if ($role_id && $rbacreview->isGlobalRole($role_id)) {
267  $valid_role = $role_id;
268  }
269  }
270  }
271  }
272 
273  // valid codes override email domain check
274  if (!$valid_code) {
275  // validate email against restricted domains
276  $email = $this->form->getInput("usr_email");
277  if ($email) {
278  // #10366
279  $domains = array();
280  foreach ($this->registration_settings->getAllowedDomains() as $item) {
281  if (trim($item)) {
282  $domains[] = $item;
283  }
284  }
285  if (sizeof($domains)) {
286  $mail_valid = false;
287  foreach ($domains as $domain) {
288  $domain = str_replace("*", "~~~", $domain);
289  $domain = preg_quote($domain);
290  $domain = str_replace("~~~", ".+", $domain);
291  if (preg_match("/^" . $domain . "$/", $email, $hit)) {
292  $mail_valid = true;
293  break;
294  }
295  }
296  if (!$mail_valid) {
297  $mail_obj = $this->form->getItemByPostVar('usr_email');
298  $mail_obj->setAlert(sprintf(
299  $this->lng->txt("reg_email_domains"),
300  implode(", ", $domains)
301  ));
302  $form_valid = false;
303  }
304  }
305  }
306  }
307 
308  $error_lng_var = '';
309  if (
310  !$this->registration_settings->passwordGenerationEnabled() &&
311  !ilUtil::isPasswordValidForUserContext($this->form->getInput('usr_password'), $this->form->getInput('username'), $error_lng_var)
312  ) {
313  $passwd_obj = $this->form->getItemByPostVar('usr_password');
314  $passwd_obj->setAlert($this->lng->txt($error_lng_var));
315  $form_valid = false;
316  }
317 
318  $showGlobalTermsOfServieFailure = false;
319  if (\ilTermsOfServiceHelper::isEnabled() && !$this->form->getInput('accept_terms_of_service')) {
320  $agr_obj = $this->form->getItemByPostVar('accept_terms_of_service');
321  if ($agr_obj) {
322  $agr_obj->setAlert($this->lng->txt('force_accept_usr_agreement'));
323  $form_valid = false;
324  } else {
325  $showGlobalTermsOfServieFailure = true;
326  }
327  }
328 
329  // no need if role is attached to code
330  if (!$valid_role) {
331  // manual selection
332  if ($this->registration_settings->roleSelectionEnabled()) {
333  $selected_role = $this->form->getInput("usr_roles");
334  if ($selected_role && ilObjRole::_lookupAllowRegister($selected_role)) {
335  $valid_role = (int) $selected_role;
336  }
337  }
338  // assign by email
339  else {
340  $registration_role_assignments = new ilRegistrationRoleAssignments();
341  $valid_role = (int) $registration_role_assignments->getRoleByEmail($this->form->getInput("usr_email"));
342  }
343  }
344 
345  // no valid role could be determined
346  if (!$valid_role) {
347  ilUtil::sendInfo($this->lng->txt("registration_no_valid_role"));
348  $form_valid = false;
349  }
350 
351  // validate username
352  $login_obj = $this->form->getItemByPostVar('username');
353  $login = $this->form->getInput("username");
354  $captcha = $this->form->getItemByPostVar("captcha_code");
355  if (!ilUtil::isLogin($login)) {
356  $login_obj->setAlert($this->lng->txt("login_invalid"));
357  $form_valid = false;
358  }
359 
360  if ($form_valid) {
362  if (empty($captcha) || empty($captcha->getAlert())) {
363  $login_obj->setAlert($this->lng->txt("login_exists"));
364  }
365  $form_valid = false;
366  } elseif ((int) $ilSetting->get('allow_change_loginname') &&
367  (int) $ilSetting->get('reuse_of_loginnames') == 0 &&
369  if (empty($captcha) || empty($captcha->getAlert())) {
370  $login_obj->setAlert($this->lng->txt("login_exists"));
371  }
372  $form_valid = false;
373  }
374  }
375 
376  if (!$form_valid) {
377  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
378  } elseif ($showGlobalTermsOfServieFailure) {
379  $this->lng->loadLanguageModule('tos');
380  \ilUtil::sendFailure(sprintf(
381  $this->lng->txt('tos_account_reg_not_possible'),
383  ));
384  } else {
385  $password = $this->__createUser($valid_role);
387  return $this->login();
388  }
389  $this->form->setValuesByPost();
390  return $this->displayForm();
391  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$login
Definition: cron.php:13
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
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 getMailsToAddress()
Get mailto: emails.
static isValidRegistrationCode($a_code)
Check if given code is a valid registration code.
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:285
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$password
Definition: cron.php:14
static isLogin($a_login)
global $ilSetting
Definition: privfeed.php:17
$DIC
Definition: xapitoken.php:46
static _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.
+ Here is the call graph for this function:

Field Documentation

◆ $code_enabled

ilAccountRegistrationGUI::$code_enabled
protected

Definition at line 25 of file class.ilAccountRegistrationGUI.php.

◆ $code_was_used

ilAccountRegistrationGUI::$code_was_used
protected

Definition at line 26 of file class.ilAccountRegistrationGUI.php.

Referenced by __distributeMails(), login(), and saveForm().

◆ $recommended_content_manager

ilAccountRegistrationGUI::$recommended_content_manager
protected

Definition at line 36 of file class.ilAccountRegistrationGUI.php.

◆ $registration_settings

ilAccountRegistrationGUI::$registration_settings
protected

Definition at line 24 of file class.ilAccountRegistrationGUI.php.

◆ $termsOfServiceEvaluation

ilAccountRegistrationGUI::$termsOfServiceEvaluation
protected

Definition at line 31 of file class.ilAccountRegistrationGUI.php.

◆ $userObj

ilAccountRegistrationGUI::$userObj
protected

Definition at line 28 of file class.ilAccountRegistrationGUI.php.


The documentation for this class was generated from the following file: