/** * @return bool */ public function getStatus() { return ilTermsOfServiceHelper::isEnabled(); }
/** * @param bool|null $status * @return void|bool */ public function hasToAcceptTermsOfServiceInSession($status = null) { if (null === $status) { return ilSession::get('has_to_accept_agr_in_session'); } require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php'; if (ilTermsOfServiceHelper::isEnabled()) { ilSession::set('has_to_accept_agr_in_session', (int) $status); } }
/** * Show terms of service link * @global ilLanguage $lng * @param string $page_editor_html */ protected function showTermsOfServiceLink($page_editor_html) { /** * @var $lng ilLanguage */ global $lng; try { require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php'; if (ilTermsOfServiceHelper::isEnabled() && ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng)) { $utpl = new ilTemplate('tpl.login_terms_of_service_link.html', true, true, 'Services/Init'); $utpl->setVariable('TXT_TERMS_OF_SERVICE', $lng->txt('usr_agreement')); $utpl->setVariable('LINK_TERMS_OF_SERVICE', $this->ctrl->getLinkTarget($this, 'showTermsOfService')); return $this->substituteLoginPageElements($GLOBALS['tpl'], $page_editor_html, $utpl->get(), '[list-user-agreement]', 'USER_AGREEMENT'); } } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) { } return $this->substituteLoginPageElements($GLOBALS['tpl'], $page_editor_html, '', '[list-user-agreement]', 'USER_AGREEMENT'); }
public function saveForm() { 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'; if (!ilRegistrationCode::isUnusedCode($code)) { $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'); $agr_obj->setAlert($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; } } 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 && ilObjUser::_doesLoginnameExistInHistory($login)) { $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; }