ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAccountRegistrationGUI Class Reference

Class ilAccountRegistrationGUI. More...

+ Collaboration diagram for ilAccountRegistrationGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 saveForm ()
 

Protected Member Functions

 __initForm ()
 
 __distributeMails ($password)
 
 doProfileAutoComplete ()
 

Protected Attributes

 $registration_settings
 
 $code_enabled
 
 $code_was_used
 
 $userObj
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountRegistrationGUI::__construct ( )

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

References $ilCtrl, $lng, and $tpl.

33  {
34  global $ilCtrl,$tpl,$lng;
35 
36  $this->tpl =&$tpl;
37 
38  $this->ctrl =&$ilCtrl;
39  $this->ctrl->saveParameter($this, 'lang');
40 
41  $this->lng =&$lng;
42  $this->lng->loadLanguageModule('registration');
43 
44  $this->registration_settings = new ilRegistrationSettings();
45 
46  $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
47  $this->registration_settings->getAllowCodes());
48  }
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17

Member Function Documentation

◆ __distributeMails()

ilAccountRegistrationGUI::__distributeMails (   $password)
protected

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

References $_GET, $action, $code_was_used, $GLOBALS, $ilSetting, $lng, $password, array, ilSession\get(), ilLoggerFactory\getLogger(), IL_REG_ACTIVATION, IL_REG_APPROVE, IL_REG_CODES, IL_REG_DIRECT, ilSession\set(), ilUtil\stripSlashes(), ilRegistrationMimeMailNotification\TYPE_NOTIFICATION_ACTIVATION, ilRegistrationMailNotification\TYPE_NOTIFICATION_APPROVERS, and ilRegistrationMailNotification\TYPE_NOTIFICATION_CONFIRMATION.

Referenced by saveForm().

625  {
626  global $ilSetting;
627 
628  include_once './Services/Language/classes/class.ilLanguage.php';
629  include_once './Services/User/classes/class.ilObjUser.php';
630  include_once "Services/Mail/classes/class.ilFormatMail.php";
631  include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
632 
633  // Always send mail to approvers
634  if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) {
635  $mail = new ilRegistrationMailNotification();
637  $mail->setRecipients($this->registration_settings->getApproveRecipients());
638  $mail->setAdditionalInformation(array('usr' => $this->userObj));
639  $mail->send();
640  } else {
641  $mail = new ilRegistrationMailNotification();
643  $mail->setRecipients($this->registration_settings->getApproveRecipients());
644  $mail->setAdditionalInformation(array('usr' => $this->userObj));
645  $mail->send();
646  }
647 
648  // Send mail to new user
649  // Registration with confirmation link ist enabled
650  if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used) {
651  include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
652 
655  $mail->setRecipients(array($this->userObj));
656  $mail->setAdditionalInformation(
657  array(
658  'usr' => $this->userObj,
659  'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
660  )
661  );
662  $mail->send();
663  } else {
664  $accountMail = new ilAccountRegistrationMail(
665  $this->registration_settings,
666  $this->lng,
668  );
669  $accountMail->withDirectRegistrationMode()->send($this->userObj, $password, $this->code_was_used);
670  }
671  }
Class for mime mail registration notifications.
$password
Definition: pwgen.php:17
Class ilAccountRegistrationMail.
const IL_REG_ACTIVATION
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
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 94 of file class.ilAccountRegistrationGUI.php.

References $code, $ilUser, $lng, $options, ilUserDefinedFields\_getInstance(), array, ilRegistrationCode\CODE_LENGTH, ilTermsOfServiceSignableDocumentFactory\getByLanguageObject(), IL_REG_ACTIVATION, iljQueryUtil\initjQuery(), ilTermsOfServiceHelper\isEnabled(), ilUserProfile\MODE_REGISTRATION, ilFormPropertyGUI\setRequired(), UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

Referenced by executeCommand(), and saveForm().

95  {
96  global $lng, $ilUser;
97 
98  // needed for multi-text-fields (interests)
99  include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
101 
102  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
103  $this->form = new ilPropertyFormGUI();
104  $this->form->setFormAction($this->ctrl->getFormAction($this));
105 
106 
107  // code handling
108 
109  if ($this->code_enabled) {
110  include_once 'Services/Registration/classes/class.ilRegistrationCode.php';
111  $code = new ilTextInputGUI($lng->txt("registration_code"), "usr_registration_code");
112  $code->setSize(40);
113  $code->setMaxLength(ilRegistrationCode::CODE_LENGTH);
114  if ((bool) $this->registration_settings->registrationCodeRequired()) {
115  $code->setRequired(true);
116  $code->setInfo($lng->txt("registration_code_required_info"));
117  } else {
118  $code->setInfo($lng->txt("registration_code_optional_info"));
119  }
120  $this->form->addItem($code);
121  }
122 
123 
124  // user defined fields
125 
126  $user_defined_data = $ilUser->getUserDefinedData();
127 
128  include_once './Services/User/classes/class.ilUserDefinedFields.php';
129  $user_defined_fields =&ilUserDefinedFields::_getInstance();
130  $custom_fields = array();
131  foreach ($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition) {
132  if ($definition['field_type'] == UDF_TYPE_TEXT) {
133  $custom_fields["udf_" . $definition['field_id']] =
134  new ilTextInputGUI($definition['field_name'], "udf_" . $definition['field_id']);
135  $custom_fields["udf_" . $definition['field_id']]->setValue($user_defined_data["f_" . $field_id]);
136  $custom_fields["udf_" . $definition['field_id']]->setMaxLength(255);
137  $custom_fields["udf_" . $definition['field_id']]->setSize(40);
138  } elseif ($definition['field_type'] == UDF_TYPE_WYSIWYG) {
139  $custom_fields["udf_" . $definition['field_id']] =
140  new ilTextAreaInputGUI($definition['field_name'], "udf_" . $definition['field_id']);
141  $custom_fields["udf_" . $definition['field_id']]->setValue($user_defined_data["f_" . $field_id]);
142  $custom_fields["udf_" . $definition['field_id']]->setUseRte(true);
143  } else {
144  $custom_fields["udf_" . $definition['field_id']] =
145  new ilSelectInputGUI($definition['field_name'], "udf_" . $definition['field_id']);
146  $custom_fields["udf_" . $definition['field_id']]->setValue($user_defined_data["f_" . $field_id]);
147  $custom_fields["udf_" . $definition['field_id']]->setOptions(
148  $user_defined_fields->fieldValuesToSelectArray($definition['field_values'])
149  );
150  }
151  if ($definition['required']) {
152  $custom_fields["udf_" . $definition['field_id']]->setRequired(true);
153  }
154 
155  if ($definition['field_type'] == UDF_TYPE_SELECT && !$user_defined_data["f_" . $field_id]) {
156  $options = $custom_fields["udf_" . $definition['field_id']]->getOptions();
157  $custom_fields["udf_" . $definition['field_id']]->setOptions($options);
158  }
159  }
160 
161  // standard fields
162  include_once("./Services/User/classes/class.ilUserProfile.php");
163  $up = new ilUserProfile();
164  $up->setMode(ilUserProfile::MODE_REGISTRATION);
165  $up->skipGroup("preferences");
166 
167  $up->setAjaxCallback(
168  $this->ctrl->getLinkTarget($this, 'doProfileAutoComplete', '', true)
169  );
170 
171  $lng->loadLanguageModule("user");
172 
173  // add fields to form
174  $up->addStandardFieldsToForm($this->form, null, $custom_fields);
175  unset($custom_fields);
176 
177 
178  // set language selection to current display language
179  $flang = $this->form->getItemByPostVar("usr_language");
180  if ($flang) {
181  $flang->setValue($lng->getLangKey());
182  }
183 
184  // add information to role selection (if not hidden)
185  if ($this->code_enabled) {
186  $role = $this->form->getItemByPostVar("usr_roles");
187  if ($role && $role->getType() == "select") {
188  $role->setInfo($lng->txt("registration_code_role_info"));
189  }
190  }
191 
192  // #11407
193  $domains = array();
194  foreach ($this->registration_settings->getAllowedDomains() as $item) {
195  if (trim($item)) {
196  $domains[] = $item;
197  }
198  }
199  if (sizeof($domains)) {
200  $mail_obj = $this->form->getItemByPostVar('usr_email');
201  $mail_obj->setInfo(sprintf(
202  $lng->txt("reg_email_domains"),
203  implode(", ", $domains)
204  ) . "<br />" .
205  ($this->code_enabled ? $lng->txt("reg_email_domains_code") : ""));
206  }
207 
208  // #14272
209  if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) {
210  $mail_obj = $this->form->getItemByPostVar('usr_email');
211  if ($mail_obj) { // #16087
212  $mail_obj->setRequired(true);
213  }
214  }
215 
216  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
218  if (ilTermsOfServiceHelper::isEnabled() && $document->exists()) {
219  $field = new ilFormSectionHeaderGUI();
220  $field->setTitle($lng->txt('usr_agreement'));
221  $this->form->addItem($field);
222 
223  $field = new ilCustomInputGUI();
224  $field->setHTML('<div id="agreement">' . $document->getContent() . '</div>');
225  $this->form->addItem($field);
226 
227  $field = new ilCheckboxInputGUI($lng->txt('accept_usr_agreement'), 'accept_terms_of_service');
228  $field->setRequired(true);
229  $field->setValue(1);
230  $this->form->addItem($field);
231  }
232 
233  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
234  if (ilCaptchaUtil::isActiveForRegistration()) {
235  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
236  $captcha = new ilCaptchaInputGUI($lng->txt("captcha_code"), 'captcha_code');
237  $captcha->setRequired(true);
238  $this->form->addItem($captcha);
239  }
240 
241  $this->form->addCommandButton("saveForm", $lng->txt("register"));
242  }
const UDF_TYPE_SELECT
static _getInstance()
Get instance.
This class represents a selection list property in a property form.
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.
$code
Definition: example_050.php:99
Class ilUserProfile.
This class represents a checkbox property in a property form.
const UDF_TYPE_TEXT
const IL_REG_ACTIVATION
This class represents a text property in a property form.
$ilUser
Definition: imgupload.php:18
const UDF_TYPE_WYSIWYG
Create styles array
The data for the language used.
This class represents a custom property in a property form.
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
setRequired($a_required)
Set Required.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doProfileAutoComplete()

ilAccountRegistrationGUI::doProfileAutoComplete ( )
protected

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

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

737  {
738  $field_id = (string) $_REQUEST["f"];
739  $term = (string) $_REQUEST["term"];
740 
741  include_once "Services/User/classes/class.ilPublicUserProfileGUI.php";
743  if (sizeof($result)) {
744  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
746  }
747 
748  exit();
749  }
Add rich text string
$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 50 of file class.ilAccountRegistrationGUI.php.

References $ilErr, $lng, $tpl, __initForm(), array, and IL_REG_DISABLED.

51  {
52  global $ilErr, $tpl;
53 
54  if ($this->registration_settings->getRegistrationType() == IL_REG_DISABLED) {
55  $ilErr->raiseError($this->lng->txt('reg_disabled'), $ilErr->FATAL);
56  }
57 
58  $next_class = $this->ctrl->getNextClass($this);
59  $cmd = $this->ctrl->getCmd();
60 
61  switch ($next_class) {
62  default:
63  if ($cmd) {
64  $this->$cmd();
65  } else {
66  $this->displayForm();
67  }
68  break;
69  }
70  $tpl->setPermanentLink('usr', null, 'registration');
71  $tpl->show();
72  return true;
73  }
global $ilErr
Definition: raiseError.php:16
$tpl
Definition: ilias.php:10
+ Here is the call graph for this function:

◆ saveForm()

ilAccountRegistrationGUI::saveForm ( )

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

References $_GET, $_POST, $_SERVER, $code, $code_was_used, $domain, $email, $GLOBALS, $ilSetting, $lng, $password, __distributeMails(), __initForm(), ilObjUser\_addDesktopItem(), ilObjUser\_doesLoginnameExistInHistory(), ilObject\_getAllReferences(), ilUserDefinedFields\_getInstance(), ilObjUser\_loginExists(), ilObjRole\_lookupAllowRegister(), ilObject\_lookupType(), array, ilUserCreationContext\CONTEXT_REGISTRATION, ilUtil\generatePasswords(), ilTermsOfServiceSignableDocumentFactory\getByLanguageObject(), ilRegistrationCode\getCodeData(), ilRegistrationCode\getCodeRole(), ilUserCreationContext\getInstance(), IL_REG_ACTIVATION, IL_REG_CODES, IL_REG_DIRECT, ilTermsOfServiceHelper\isEnabled(), ilUtil\isLogin(), ilUtil\isPasswordValidForUserContext(), ilRegistrationCode\isValidRegistrationCode(), ilUserProfile\MODE_REGISTRATION, ilUtil\sendFailure(), ilUtil\sendInfo(), ilUtil\stripSlashes(), time, ilTermsOfServiceHelper\trackAcceptance(), and ilRegistrationCode\useCode().

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

◆ $code_was_used

ilAccountRegistrationGUI::$code_was_used
protected

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

Referenced by __distributeMails(), and saveForm().

◆ $registration_settings

ilAccountRegistrationGUI::$registration_settings
protected

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

◆ $userObj

ilAccountRegistrationGUI::$userObj
protected

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


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