ILIAS  release_7 Revision v7.30-3-g800a261c036
ilAccountRegistrationGUI Class Reference

Class ilAccountRegistrationGUI. More...

+ Collaboration diagram for ilAccountRegistrationGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 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 40 of file class.ilAccountRegistrationGUI.php.

41 {
42 global $DIC;
43
44 $ilCtrl = $DIC->ctrl();
45 $tpl = $DIC['tpl'];
46 $lng = $DIC->language();
47
48 $this->tpl =&$tpl;
49
50 $this->ctrl =&$ilCtrl;
51 $this->ctrl->saveParameter($this, 'lang');
52
53 $this->lng =&$lng;
54 $this->lng->loadLanguageModule('registration');
55
56 $this->registration_settings = new ilRegistrationSettings();
57
58 $this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
59 $this->registration_settings->getAllowCodes());
60
61 $this->termsOfServiceEvaluation = $DIC['tos.document.evaluator'];
62 $this->recommended_content_manager = new ilRecommendedContentManager();
63 }
Recommended content manager (business logic)
Class ilObjAuthSettingsGUI.
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$lng

References $DIC, $lng, and $tpl.

Member Function Documentation

◆ __distributeMails()

ilAccountRegistrationGUI::__distributeMails (   $password)
protected

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

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

References $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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __initForm()

ilAccountRegistrationGUI::__initForm ( )
protected

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

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

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

Referenced by saveForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doProfileAutoComplete()

ilAccountRegistrationGUI::doProfileAutoComplete ( )
protected

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

723 {
724 $field_id = (string) $_REQUEST["f"];
725 $term = (string) $_REQUEST["term"];
726
728 if (sizeof($result)) {
730 }
731
732 exit();
733 }
$result
static encode($mixed, $suppress_native=false)
static getAutocompleteResult($a_field_id, $a_term)
exit
Definition: login.php:29

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

+ Here is the call graph for this function:

◆ executeCommand()

ilAccountRegistrationGUI::executeCommand ( )

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

66 {
67 global $DIC;
68
69 if ($this->registration_settings->getRegistrationType() == IL_REG_DISABLED) {
70 $ilErr = $DIC['ilErr'];
71 $ilErr->raiseError($this->lng->txt('reg_disabled'), $ilErr->FATAL);
72 }
73
74 $cmd = $this->ctrl->getCmd();
75 switch ($cmd) {
76 case 'saveForm':
77 $tpl = $this->$cmd();
78 break;
79 default:
80 $tpl = $this->displayForm();
81 }
82
83 $gtpl = $DIC['tpl'];
84 $gtpl->setPermanentLink('usr', null, 'registration');
86 }
static printToGlobalTemplate($tpl)
$ilErr
Definition: raiseError.php:18

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

+ Here is the call graph for this function:

◆ login()

ilAccountRegistrationGUI::login ( )

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

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

References $DIC, Vendor\Package\$f, $tpl, IL_REG_ACTIVATION, IL_REG_APPROVE, IL_REG_CODES, and IL_REG_DIRECT.

Referenced by saveForm().

+ Here is the caller graph for this function:

◆ saveForm()

ilAccountRegistrationGUI::saveForm ( )

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

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

References $DIC, $email, $ilSetting, $login, $password, __distributeMails(), __initForm(), ilObjUser\_doesLoginnameExistInHistory(), ilObjUser\_loginExists(), ilObjRole\_lookupAllowRegister(), ilRegistrationCode\getCodeRole(), ilSystemSupportContacts\getMailsToAddress(), ilTermsOfServiceHelper\isEnabled(), ilUtil\isLogin(), ilUtil\isPasswordValidForUserContext(), ilRegistrationCode\isValidRegistrationCode(), login(), ilUtil\prepareFormOutput(), ilUtil\sendFailure(), and ilUtil\sendInfo().

+ 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.

◆ $recommended_content_manager

ilAccountRegistrationGUI::$recommended_content_manager
protected

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

◆ $registration_settings

ilAccountRegistrationGUI::$registration_settings
protected

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

◆ $termsOfServiceEvaluation

ilAccountRegistrationGUI::$termsOfServiceEvaluation
protected

Definition at line 33 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: