ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAccountRegistrationGUI Class Reference

Class ilAccountRegistrationGUI. More...

+ Collaboration diagram for ilAccountRegistrationGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 saveForm ()
 

Protected Member Functions

 __initForm ()
 
 __distributeMails ($password, $a_language=null)
 
 doProfileAutoComplete ()
 

Protected Attributes

 $registration_settings
 
 $code_enabled
 
 $code_was_used
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountRegistrationGUI::__construct ( )

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

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 }
global $tpl
Definition: ilias.php:8
Class ilObjAuthSettingsGUI.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

References $ilCtrl, $lng, and $tpl.

Member Function Documentation

◆ __distributeMails()

ilAccountRegistrationGUI::__distributeMails (   $password,
  $a_language = null 
)
protected

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

737 {
738 global $ilSetting;
739
740 include_once './Services/Language/classes/class.ilLanguage.php';
741 include_once './Services/User/classes/class.ilObjUser.php';
742 include_once "Services/Mail/classes/class.ilFormatMail.php";
743 include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
744
745 // Always send mail to approvers
746 if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
747 {
748 $mail = new ilRegistrationMailNotification();
750 $mail->setRecipients($this->registration_settings->getApproveRecipients());
751 $mail->setAdditionalInformation(array('usr' => $this->userObj));
752 $mail->send();
753 }
754 else
755 {
756 $mail = new ilRegistrationMailNotification();
758 $mail->setRecipients($this->registration_settings->getApproveRecipients());
759 $mail->setAdditionalInformation(array('usr' => $this->userObj));
760 $mail->send();
761
762 }
763 // Send mail to new user
764
765 // Registration with confirmation link ist enabled
766 if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used)
767 {
768 include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
769
772 $mail->setRecipients(array($this->userObj));
773 $mail->setAdditionalInformation(
774 array(
775 'usr' => $this->userObj,
776 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
777 )
778 );
779 $mail->send();
780 }
781 else
782 {
783 // try individual account mail in user administration
784 include_once("Services/Mail/classes/class.ilAccountMail.php");
785 include_once './Services/User/classes/class.ilObjUserFolder.php';
786
787 $amail = ilObjUserFolder::_lookupNewAccountMail($a_language);
788 if (trim($amail["body"]) == "" || trim($amail["subject"]) == "")
789 {
790 $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
791 }
792 if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
793 {
794 $acc_mail = new ilAccountMail();
795 $acc_mail->setUser($this->userObj);
796 if ($this->registration_settings->passwordGenerationEnabled())
797 {
798 $acc_mail->setUserPassword($password);
799 }
800
801 if($amail["att_file"])
802 {
803 include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
805 $fs->create();
806 $path = $fs->getAbsolutePath()."/";
807
808 $acc_mail->addAttachment($path."/".$amail["lang"], $amail["att_file"]);
809 }
810
811 $acc_mail->send();
812 }
813 else // do default mail
814 {
815 include_once "Services/Mail/classes/class.ilMimeMail.php";
816
817 $mmail = new ilMimeMail();
818 $mmail->autoCheck(false);
819 $mmail->From($ilSetting->get("admin_email"));
820 $mmail->To($this->userObj->getEmail());
821
822 // mail subject
823 $subject = $this->lng->txt("reg_mail_subject");
824
825 // mail body
826 $body = $this->lng->txt("reg_mail_body_salutation")." ".$this->userObj->getFullname().",\n\n".
827 $this->lng->txt("reg_mail_body_text1")."\n\n".
828 $this->lng->txt("reg_mail_body_text2")."\n".
829 ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
830 $body .= $this->lng->txt("login").": ".$this->userObj->getLogin()."\n";
831
832 if ($this->registration_settings->passwordGenerationEnabled())
833 {
834 $body.= $this->lng->txt("passwd").": ".$password."\n";
835 }
836 $body.= "\n";
837
838 // Info about necessary approvement
839 if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
840 {
841 $body .= ($this->lng->txt('reg_mail_body_pwd_generation')."\n\n");
842 }
843
844 $body .= ($this->lng->txt("reg_mail_body_text3")."\n\r");
845 $body .= $this->userObj->getProfileAsString($this->lng);
846 $mmail->Subject($subject);
847 $mmail->Body($body);
848 $mmail->Send();
849 }
850 }
851 }
const USER_FOLDER_ID
Class ilObjUserFolder.
const IL_REG_ACTIVATION
Class ilAccountMail.
this class encapsulates the PHP mail() function.
Class for mime mail registration notifications.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilSetting
Definition: privfeed.php:40
$path
Definition: index.php:22

References $GLOBALS, $ilSetting, $path, ilObjUserFolder\_lookupNewAccountMail(), IL_REG_ACTIVATION, IL_REG_APPROVE, ilRegistrationMimeMailNotification\TYPE_NOTIFICATION_ACTIVATION, ilRegistrationMailNotification\TYPE_NOTIFICATION_APPROVERS, ilRegistrationMailNotification\TYPE_NOTIFICATION_CONFIRMATION, and USER_FOLDER_ID.

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 97 of file class.ilAccountRegistrationGUI.php.

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);
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();
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 }
const UDF_TYPE_SELECT
const UDF_TYPE_WYSIWYG
const UDF_TYPE_TEXT
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 section header in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static _getInstance()
Get instance.
Class ilUserProfile.
static initjQuery($a_tpl=null)
Init jQuery.
$code
Definition: example_050.php:99
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15

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

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 922 of file class.ilAccountRegistrationGUI.php.

923 {
924 $field_id = (string)$_REQUEST["f"];
925 $term = (string)$_REQUEST["term"];
926
927 include_once "Services/User/classes/class.ilPublicUserProfileGUI.php";
929 if(sizeof($result))
930 {
931 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
933 }
934
935 exit();
936 }
$result
static encode($mixed, $suppress_native=false)
static getAutocompleteResult($a_field_id, $a_term)
exit
Definition: login.php:54
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

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

+ Here is the call graph for this function:

◆ executeCommand()

ilAccountRegistrationGUI::executeCommand ( )

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

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 }
$cmd
Definition: sahs_server.php:35

References $cmd, $ilErr, $tpl, and IL_REG_DISABLED.

◆ saveForm()

ilAccountRegistrationGUI::saveForm ( )

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

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 }
__distributeMails($password, $a_language=null)
_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.
isLogin($a_login)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $code, $ilSetting, $lng, __distributeMails(), __initForm(), ilObjUser\_doesLoginnameExistInHistory(), ilObjUser\_loginExists(), ilObjRole\_lookupAllowRegister(), ilRegistrationCode\getCodeRole(), ilUtil\isLogin(), ilUtil\isPasswordValidForUserContext(), ilRegistrationCode\isValidRegistrationCode(), 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.

◆ $registration_settings

ilAccountRegistrationGUI::$registration_settings
protected

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


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