ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

ilAccountRegistrationGUI::__construct ( )

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

References $ilCtrl, $lng, and $tpl.

{
global $ilCtrl,$tpl,$lng;
$this->tpl =& $tpl;
$this->ctrl =& $ilCtrl;
$this->ctrl->saveParameter($this,'lang');
$this->lng =& $lng;
$this->lng->loadLanguageModule('registration');
$this->registration_settings = new ilRegistrationSettings();
$this->code_enabled = ($this->registration_settings->registrationCodeRequired() ||
$this->registration_settings->getAllowCodes());
}

Member Function Documentation

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

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

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

{
global $ilSetting;
include_once './Services/Language/classes/class.ilLanguage.php';
include_once './Services/User/classes/class.ilObjUser.php';
include_once "Services/Mail/classes/class.ilFormatMail.php";
include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
// Always send mail to approvers
if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
{
$mail->setRecipients($this->registration_settings->getApproveRecipients());
$mail->setAdditionalInformation(array('usr' => $this->userObj));
$mail->send();
}
else
{
$mail->setRecipients($this->registration_settings->getApproveRecipients());
$mail->setAdditionalInformation(array('usr' => $this->userObj));
$mail->send();
}
// Send mail to new user
// Registration with confirmation link ist enabled
if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used)
{
include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
$mail->setRecipients(array($this->userObj));
$mail->setAdditionalInformation(
array(
'usr' => $this->userObj,
'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()
)
);
$mail->send();
}
else
{
// try individual account mail in user administration
include_once("Services/Mail/classes/class.ilAccountMail.php");
include_once './Services/User/classes/class.ilObjUserFolder.php';
if (trim($amail["body"]) == "" || trim($amail["subject"]) == "")
{
$amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
}
if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
{
$acc_mail = new ilAccountMail();
$acc_mail->setUser($this->userObj);
if ($this->registration_settings->passwordGenerationEnabled())
{
$acc_mail->setUserPassword($password);
}
if($amail["att_file"])
{
include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
$fs->create();
$path = $fs->getAbsolutePath()."/";
$acc_mail->addAttachment($path."/".$amail["lang"], $amail["att_file"]);
}
$acc_mail->send();
}
else // do default mail
{
include_once "Services/Mail/classes/class.ilMimeMail.php";
$mmail = new ilMimeMail();
$mmail->autoCheck(false);
$mmail->From($ilSetting->get("admin_email"));
$mmail->To($this->userObj->getEmail());
// mail subject
$subject = $this->lng->txt("reg_mail_subject");
// mail body
$body = $this->lng->txt("reg_mail_body_salutation")." ".$this->userObj->getFullname().",\n\n".
$this->lng->txt("reg_mail_body_text1")."\n\n".
$this->lng->txt("reg_mail_body_text2")."\n".
ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
$body .= $this->lng->txt("login").": ".$this->userObj->getLogin()."\n";
if ($this->registration_settings->passwordGenerationEnabled())
{
$body.= $this->lng->txt("passwd").": ".$password."\n";
}
$body.= "\n";
// Info about necessary approvement
if($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used)
{
$body .= ($this->lng->txt('reg_mail_body_pwd_generation')."\n\n");
}
$body .= ($this->lng->txt("reg_mail_body_text3")."\n\r");
$body .= $this->userObj->getProfileAsString($this->lng);
$mmail->Subject($subject);
$mmail->Body($body);
$mmail->Send();
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAccountRegistrationGUI::__initForm ( )
protected

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

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

Referenced by saveForm().

{
global $lng, $ilUser;
// needed for multi-text-fields (interests)
include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
$this->form = new ilPropertyFormGUI();
$this->form->setFormAction($this->ctrl->getFormAction($this));
// code handling
if($this->code_enabled)
{
include_once 'Services/Registration/classes/class.ilRegistrationCode.php';
$code = new ilTextInputGUI($lng->txt("registration_code"), "usr_registration_code");
$code->setSize(40);
$code->setMaxLength(ilRegistrationCode::CODE_LENGTH);
if((bool)$this->registration_settings->registrationCodeRequired())
{
$code->setRequired(true);
$code->setInfo($lng->txt("registration_code_required_info"));
}
else
{
$code->setInfo($lng->txt("registration_code_optional_info"));
}
$this->form->addItem($code);
}
// user defined fields
$user_defined_data = $ilUser->getUserDefinedData();
include_once './Services/User/classes/class.ilUserDefinedFields.php';
$user_defined_fields =& ilUserDefinedFields::_getInstance();
$custom_fields = array();
foreach($user_defined_fields->getRegistrationDefinitions() as $field_id => $definition)
{
if($definition['field_type'] == UDF_TYPE_TEXT)
{
$custom_fields["udf_".$definition['field_id']] =
new ilTextInputGUI($definition['field_name'], "udf_".$definition['field_id']);
$custom_fields["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
$custom_fields["udf_".$definition['field_id']]->setMaxLength(255);
$custom_fields["udf_".$definition['field_id']]->setSize(40);
}
else if($definition['field_type'] == UDF_TYPE_WYSIWYG)
{
$custom_fields["udf_".$definition['field_id']] =
new ilTextAreaInputGUI($definition['field_name'], "udf_".$definition['field_id']);
$custom_fields["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
$custom_fields["udf_".$definition['field_id']]->setUseRte(true);
}
else
{
$custom_fields["udf_".$definition['field_id']] =
new ilSelectInputGUI($definition['field_name'], "udf_".$definition['field_id']);
$custom_fields["udf_".$definition['field_id']]->setValue($user_defined_data["f_".$field_id]);
$custom_fields["udf_".$definition['field_id']]->setOptions(
$user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
}
if($definition['required'])
{
$custom_fields["udf_".$definition['field_id']]->setRequired(true);
}
if($definition['field_type'] == UDF_TYPE_SELECT && !$user_defined_data["f_".$field_id])
{
$options = array(""=>$lng->txt("please_select")) + $custom_fields["udf_".$definition['field_id']]->getOptions();
$custom_fields["udf_".$definition['field_id']]->setOptions($options);
}
}
// standard fields
include_once("./Services/User/classes/class.ilUserProfile.php");
$up = new ilUserProfile();
$up->skipGroup("preferences");
$up->setAjaxCallback(
$this->ctrl->getLinkTarget($this, 'doProfileAutoComplete', '', true)
);
$lng->loadLanguageModule("user");
// add fields to form
$up->addStandardFieldsToForm($this->form, NULL, $custom_fields);
unset($custom_fields);
// set language selection to current display language
$flang = $this->form->getItemByPostVar("usr_language");
if($flang)
{
$flang->setValue($lng->getLangKey());
}
// add information to role selection (if not hidden)
if($this->code_enabled)
{
$role = $this->form->getItemByPostVar("usr_roles");
if($role && $role->getType() == "select")
{
$role->setInfo($lng->txt("registration_code_role_info"));
}
}
// #11407
$domains = array();
foreach($this->registration_settings->getAllowedDomains() as $item)
{
if(trim($item))
{
$domains[] = $item;
}
}
if(sizeof($domains))
{
$mail_obj = $this->form->getItemByPostVar('usr_email');
$mail_obj->setInfo(sprintf($lng->txt("reg_email_domains"),
implode(", ", $domains))."<br />".
($this->code_enabled ? $lng->txt("reg_email_domains_code") : ""));
}
// #14272
if($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION)
{
$mail_obj = $this->form->getItemByPostVar('usr_email');
if($mail_obj) // #16087
{
$mail_obj->setRequired(true);
}
}
if(ilTermsOfServiceHelper::isEnabled())
{
try
{
require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
$field = new ilFormSectionHeaderGUI();
$field->setTitle($lng->txt('usr_agreement'));
$this->form->addItem($field);
$field = new ilCustomInputGUI();
$field->setHTML('<div id="agreement">' . $document->getContent() . '</div>');
$this->form->addItem($field);
$field = new ilCheckboxInputGUI($lng->txt('accept_usr_agreement'), 'accept_terms_of_service');
$field->setRequired(true);
$field->setValue(1);
$this->form->addItem($field);
}
{
}
}
require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
if(ilCaptchaUtil::isActiveForRegistration())
{
require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
$captcha = new ilCaptchaInputGUI($lng->txt("captcha_code"), 'captcha_code');
$captcha->setRequired(true);
$this->form->addItem($captcha);
}
$this->form->addCommandButton("saveForm", $lng->txt("register"));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAccountRegistrationGUI::doProfileAutoComplete ( )
protected

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

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

{
$field_id = (string)$_REQUEST["f"];
$term = (string)$_REQUEST["term"];
include_once "Services/User/classes/class.ilPublicUserProfileGUI.php";
if(sizeof($result))
{
include_once 'Services/JSON/classes/class.ilJsonUtil.php';
}
exit();
}

+ Here is the call graph for this function:

ilAccountRegistrationGUI::executeCommand ( )

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

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

{
global $ilErr, $tpl;
if($this->registration_settings->getRegistrationType() == IL_REG_DISABLED)
{
$ilErr->raiseError($this->lng->txt('reg_disabled'),$ilErr->FATAL);
}
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->ctrl->getCmd();
switch($next_class)
{
default:
if($cmd)
{
$this->$cmd();
}
else
{
$this->displayForm();
}
break;
}
$tpl->show();
return true;
}
ilAccountRegistrationGUI::saveForm ( )

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

References $ilSetting, $lng, __distributeMails(), __initForm(), ilObjUser\_doesLoginnameExistInHistory(), ilObjUser\_loginExists(), ilObjRole\_lookupAllowRegister(), ilRegistrationCode\getCodeRole(), ilUtil\isLogin(), ilUtil\isPasswordValidForUserContext(), ilRegistrationCode\isUnusedCode(), ilUtil\sendFailure(), and ilUtil\sendInfo().

{
global $lng, $ilSetting, $rbacreview;
$this->__initForm();
$form_valid = $this->form->checkInput();
require_once 'Services/User/classes/class.ilObjUser.php';
// custom validation
$valid_code = $valid_role = false;
// code
if($this->code_enabled)
{
$code = $this->form->getInput('usr_registration_code');
// could be optional
if($code)
{
// code validation
include_once './Services/Registration/classes/class.ilRegistrationCode.php';
{
$code_obj = $this->form->getItemByPostVar('usr_registration_code');
$code_obj->setAlert($lng->txt('registration_code_not_valid'));
$form_valid = false;
}
else
{
$valid_code = true;
// get role from code, check if (still) valid
$role_id = (int)ilRegistrationCode::getCodeRole($code);
if($role_id && $rbacreview->isGlobalRole($role_id))
{
$valid_role = $role_id;
}
}
}
}
// valid codes override email domain check
if(!$valid_code)
{
// validate email against restricted domains
$email = $this->form->getInput("usr_email");
if($email)
{
// #10366
$domains = array();
foreach($this->registration_settings->getAllowedDomains() as $item)
{
if(trim($item))
{
$domains[] = $item;
}
}
if(sizeof($domains))
{
$mail_valid = false;
foreach($domains as $domain)
{
$domain = str_replace("*", "~~~", $domain);
$domain = preg_quote($domain);
$domain = str_replace("~~~", ".+", $domain);
if(preg_match("/^".$domain."$/", $email, $hit))
{
$mail_valid = true;
break;
}
}
if(!$mail_valid)
{
$mail_obj = $this->form->getItemByPostVar('usr_email');
$mail_obj->setAlert(sprintf($lng->txt("reg_email_domains"),
implode(", ", $domains)));
$form_valid = false;
}
}
}
}
$error_lng_var = '';
if(
!$this->registration_settings->passwordGenerationEnabled() &&
!ilUtil::isPasswordValidForUserContext($this->form->getInput('usr_password'), $this->form->getInput('username'), $error_lng_var)
)
{
$passwd_obj = $this->form->getItemByPostVar('usr_password');
$passwd_obj->setAlert($lng->txt($error_lng_var));
$form_valid = false;
}
if(ilTermsOfServiceHelper::isEnabled() && !$this->form->getInput('accept_terms_of_service'))
{
$agr_obj = $this->form->getItemByPostVar('accept_terms_of_service');
if($agr_obj)
{
$agr_obj->setAlert($lng->txt('force_accept_usr_agreement'));
}
else
{
ilUtil::sendFailure($lng->txt('force_accept_usr_agreement'));
}
$form_valid = false;
}
// no need if role is attached to code
if(!$valid_role)
{
// manual selection
if ($this->registration_settings->roleSelectionEnabled())
{
include_once "./Services/AccessControl/classes/class.ilObjRole.php";
$selected_role = $this->form->getInput("usr_roles");
if ($selected_role && ilObjRole::_lookupAllowRegister($selected_role))
{
$valid_role = (int)$selected_role;
}
}
// assign by email
else
{
include_once 'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
$registration_role_assignments = new ilRegistrationRoleAssignments();
$valid_role = (int)$registration_role_assignments->getRoleByEmail($this->form->getInput("usr_email"));
}
}
// no valid role could be determined
if (!$valid_role)
{
ilUtil::sendInfo($lng->txt("registration_no_valid_role"));
$form_valid = false;
}
// validate username
$login_obj = $this->form->getItemByPostVar('username');
$login = $this->form->getInput("username");
if (!ilUtil::isLogin($login))
{
$login_obj->setAlert($lng->txt("login_invalid"));
$form_valid = false;
}
else if (ilObjUser::_loginExists($login))
{
$login_obj->setAlert($lng->txt("login_exists"));
$form_valid = false;
}
else if ((int)$ilSetting->get('allow_change_loginname') &&
(int)$ilSetting->get('reuse_of_loginnames') == 0 &&
{
$login_obj->setAlert($lng->txt('login_exists'));
$form_valid = false;
}
if(!$form_valid)
{
ilUtil::sendFailure($lng->txt('form_input_not_valid'));
}
else
{
$password = $this->__createUser($valid_role);
$this->__distributeMails($password, $this->form->getInput("usr_language"));
$this->login($password);
return true;
}
$this->form->setValuesByPost();
$this->displayForm();
return false;
}

+ Here is the call graph for this function:

Field Documentation

ilAccountRegistrationGUI::$code_enabled
protected

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

ilAccountRegistrationGUI::$code_was_used
protected

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

Referenced by __distributeMails().

ilAccountRegistrationGUI::$registration_settings
protected

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


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