本文整理汇总了PHP中ilObjRole::_lookupAllowRegister方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjRole::_lookupAllowRegister方法的具体用法?PHP ilObjRole::_lookupAllowRegister怎么用?PHP ilObjRole::_lookupAllowRegister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjRole
的用法示例。
在下文中一共展示了ilObjRole::_lookupAllowRegister方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveForm
public function saveForm()
{
global $lng, $ilSetting;
$this->__initForm();
$form_valid = $this->form->checkInput();
require_once 'Services/User/classes/class.ilObjUser.php';
// custom validation
// 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;
}
}
}
if (!$this->form->getInput("usr_agreement")) {
$agr_obj = $this->form->getItemByPostVar('usr_agreement');
$agr_obj->setAlert($lng->txt("force_accept_usr_agreement"));
$form_valid = false;
}
$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 {
// get role from valid code
$valid_role = (int) ilRegistrationCode::getCodeRole($code);
}
}
}
// 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"));
//.........这里部分代码省略.........
示例2: editRoles
function editRoles()
{
include_once './Services/AccessControl/classes/class.ilObjRole.php';
global $ilAccess, $ilErr, $rbacreview;
if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
$ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
}
$this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.edit_roles.html', 'Services/Registration');
$this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_SELECTABLE_ROLES", $this->lng->txt('reg_selectable_roles'));
$this->tpl->setVariable("ARR_DOWNRIGHT", ilUtil::getImagePath('arrow_downright.png'));
$this->tpl->setVariable("ACTIONS", $this->lng->txt('actions'));
$this->tpl->setVariable("UPDATE", $this->lng->txt('save'));
$this->tpl->setVariable("CANCEL", $this->lng->txt('cancel'));
$counter = 0;
foreach ($rbacreview->getGlobalRoles() as $role) {
if ($role == SYSTEM_ROLE_ID or $role == ANONYMOUS_ROLE_ID) {
continue;
}
$this->tpl->setCurrentBlock("roles");
$this->tpl->setVariable("CSSROW", ilUtil::switchColor(++$counter, 'tblrow1', 'tblrow2'));
$this->tpl->setVariable("CHECK_ROLE", ilUtil::formCheckbox(ilObjRole::_lookupAllowRegister($role), "roles[{$role}]", 1));
$this->tpl->setVariable("ROLE", ilObjRole::_lookupTitle($role));
$this->tpl->parseCurrentBlock();
}
}