本文整理汇总了PHP中RoleModel::getByPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::getByPermission方法的具体用法?PHP RoleModel::getByPermission怎么用?PHP RoleModel::getByPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::getByPermission方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registration
/**
* Configuration of registration settings.
*
* Events: BeforeRegistrationUpdate
*
* @since 2.0.0
* @access public
* @param string $RedirectUrl Where to send user after registration.
*/
public function registration($RedirectUrl = '')
{
$this->permission('Garden.Settings.Manage');
$this->addSideMenu('dashboard/settings/registration');
$this->addJsFile('registration.js');
$this->title(t('Registration'));
// Create a model to save configuration settings
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$registrationOptions = array('Garden.Registration.Method' => 'Captcha', 'Garden.Registration.InviteExpiration', 'Garden.Registration.ConfirmEmail');
if ($manageCaptcha = c('Garden.Registration.ManageCaptcha', true)) {
$registrationOptions[] = 'Garden.Registration.CaptchaPrivateKey';
$registrationOptions[] = 'Garden.Registration.CaptchaPublicKey';
}
$this->setData('_ManageCaptcha', $manageCaptcha);
$ConfigurationModel->setField($registrationOptions);
// Set the model on the forms.
$this->Form->setModel($ConfigurationModel);
// Load roles with sign-in permission
$RoleModel = new RoleModel();
$this->RoleData = $RoleModel->getByPermission('Garden.SignIn.Allow');
$this->setData('_Roles', array_column($this->RoleData->resultArray(), 'Name', 'RoleID'));
// Get currently selected InvitationOptions
$this->ExistingRoleInvitations = Gdn::config('Garden.Registration.InviteRoles');
if (is_array($this->ExistingRoleInvitations) === false) {
$this->ExistingRoleInvitations = array();
}
// Get the currently selected Expiration Length
$this->InviteExpiration = Gdn::config('Garden.Registration.InviteExpiration', '');
// Registration methods.
$this->RegistrationMethods = array('Captcha' => "New users fill out a simple form and are granted access immediately.", 'Approval' => "New users are reviewed and approved by an administrator (that's you!).", 'Invitation' => "Existing members send invitations to new members.", 'Connect' => "New users are only registered through SSO plugins.");
// Options for how many invitations a role can send out per month.
$this->InvitationOptions = array('0' => t('None'), '1' => '1', '2' => '2', '5' => '5', '-1' => t('Unlimited'));
// Options for when invitations should expire.
$this->InviteExpirationOptions = array('1 week' => t('1 week after being sent'), '2 weeks' => t('2 weeks after being sent'), '1 month' => t('1 month after being sent'), 'FALSE' => t('never'));
if ($this->Form->authenticatedPostBack() === false) {
$this->Form->setData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->applyRule('Garden.Registration.Method', 'Required');
// Define the Garden.Registration.RoleInvitations setting based on the postback values
$InvitationRoleIDs = $this->Form->getValue('InvitationRoleID');
$InvitationCounts = $this->Form->getValue('InvitationCount');
$this->ExistingRoleInvitations = arrayCombine($InvitationRoleIDs, $InvitationCounts);
$ConfigurationModel->forceSetting('Garden.Registration.InviteRoles', $this->ExistingRoleInvitations);
// Event hook
$this->EventArguments['ConfigurationModel'] =& $ConfigurationModel;
$this->fireEvent('BeforeRegistrationUpdate');
// Save!
if ($this->Form->save() !== false) {
$this->informMessage(t("Your settings have been saved."));
if ($RedirectUrl != '') {
$this->RedirectUrl = $RedirectUrl;
}
}
}
$this->render();
}