本文整理汇总了PHP中RoleModel::getDefaultRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::getDefaultRoles方法的具体用法?PHP RoleModel::getDefaultRoles怎么用?PHP RoleModel::getDefaultRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::getDefaultRoles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$SQL->update('Role')->set('Type', RoleModel::TYPE_MEMBER)->where('RoleID', $types[RoleModel::TYPE_MEMBER])->put();
// RemoveFromConfig('Garden.Registration.DefaultRoles');
}
if ($v = c('Garden.Registration.ConfirmEmailRole')) {
$SQL->update('Role')->set('Type', RoleModel::TYPE_UNCONFIRMED)->where('RoleID', $types[RoleModel::TYPE_UNCONFIRMED])->put();
// RemoveFromConfig('Garden.Registration.ConfirmEmailRole');
}
$guestRoleIDs = Gdn::sql()->getWhere('UserRole', array('UserID' => 0))->resultArray();
if (!empty($guestRoleIDs)) {
$SQL->update('Role')->set('Type', RoleModel::TYPE_GUEST)->where('RoleID', $types[RoleModel::TYPE_GUEST])->put();
$SQL->delete('UserRole', array('UserID' => 0));
}
}
if (!$UserRoleExists) {
// Assign the admin user to admin role.
$adminRoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_ADMINISTRATOR);
foreach ($adminRoleIDs as $id) {
$SQL->replace('UserRole', array(), array('UserID' => 1, 'RoleID' => $id));
}
}
// User Meta Table
$Construct->table('UserMeta')->column('UserID', 'int', false, 'primary')->column('Name', 'varchar(100)', false, array('primary', 'index'))->column('Value', 'text', true)->set($Explicit, $Drop);
// User Points Table
$Construct->table('UserPoints')->column('SlotType', array('d', 'w', 'm', 'y', 'a'), false, 'primary')->column('TimeSlot', 'datetime', false, 'primary')->column('Source', 'varchar(10)', 'Total', 'primary')->column('CategoryID', 'int', 0, 'primary')->column('UserID', 'int', false, 'primary')->column('Points', 'int', 0)->set($Explicit, $Drop);
// Create the authentication table.
$Construct->table('UserAuthentication')->column('ForeignUserKey', 'varchar(100)', false, 'primary')->column('ProviderKey', 'varchar(64)', false, 'primary')->column('UserID', 'int', false, 'key')->set($Explicit, $Drop);
$Construct->table('UserAuthenticationProvider')->column('AuthenticationKey', 'varchar(64)', false, 'primary')->column('AuthenticationSchemeAlias', 'varchar(32)', false)->column('Name', 'varchar(50)', true)->column('URL', 'varchar(255)', true)->column('AssociationSecret', 'text', true)->column('AssociationHashMethod', 'varchar(20)', true)->column('AuthenticateUrl', 'varchar(255)', true)->column('RegisterUrl', 'varchar(255)', true)->column('SignInUrl', 'varchar(255)', true)->column('SignOutUrl', 'varchar(255)', true)->column('PasswordUrl', 'varchar(255)', true)->column('ProfileUrl', 'varchar(255)', true)->column('Attributes', 'text', true)->column('Active', 'tinyint', '1')->column('IsDefault', 'tinyint', 0)->set($Explicit, $Drop);
$Construct->table('UserAuthenticationNonce')->column('Nonce', 'varchar(100)', false, 'primary')->column('Token', 'varchar(128)', false)->column('Timestamp', 'timestamp', false)->set($Explicit, $Drop);
$Construct->table('UserAuthenticationToken')->column('Token', 'varchar(128)', false, 'primary')->column('ProviderKey', 'varchar(64)', false, 'primary')->column('ForeignUserKey', 'varchar(100)', true)->column('TokenSecret', 'varchar(64)', false)->column('TokenType', array('request', 'access'), false)->column('Authorized', 'tinyint(1)', false)->column('Timestamp', 'timestamp', false)->column('Lifetime', 'int', false)->set($Explicit, $Drop);
// Fix the sync roles config spelling mistake.
if (c('Garden.SSO.SynchRoles')) {
示例2: newUserRoleIDs
/**
*
*
* @return array
* @throws Gdn_UserException
*/
public function newUserRoleIDs()
{
// Registration method
$RegistrationMethod = c('Garden.Registration.Method', 'Basic');
$DefaultRoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
switch ($RegistrationMethod) {
case 'Approval':
$RoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_APPLICANT);
break;
case 'Invitation':
throw new Gdn_UserException(t('This forum is currently set to invitation only mode.'));
case 'Basic':
case 'Captcha':
default:
$RoleID = $DefaultRoleID;
break;
}
if (empty($RoleID)) {
trace("You don't have any default roles defined.", TRACE_WARNING);
}
return $RoleID;
}
示例3: save
/**
*
*
* @throws Exception
* @throws Gdn_UserException
*/
public function save()
{
$this->permission('Garden.Users.Edit');
if (!Gdn::request()->isAuthenticatedPostBack()) {
throw new Exception('Requires POST', 405);
}
$Form = new Gdn_Form();
if ($SSOString = $Form->getFormValue('SSOString')) {
$Parts = explode(' ', $SSOString);
$String = $Parts[0];
$Data = json_decode(base64_decode($String), true);
$User = arrayTranslate($Data, array('name' => 'Name', 'email' => 'Email', 'photourl' => 'Photo', 'client_id' => 'ClientID', 'uniqueid' => 'UniqueID'));
} else {
$User = $Form->formValues();
}
if (!isset($User['UserID']) && isset($User['UniqueID'])) {
// Try and find the user based on SSO.
$Auth = Gdn::userModel()->getAuthentication($User['UniqueID'], $User['ClientID']);
if ($Auth) {
$User['UserID'] = $Auth['UserID'];
}
}
if (!isset($User['UserID'])) {
// Add some default values to make saving easier.
if (!isset($User['RoleID'])) {
$DefaultRoles = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
$User['RoleID'] = $DefaultRoles;
} elseif (is_numeric($User['RoleID'])) {
// UserModel->save() demands an array for RoleID.
$User['RoleID'] = array($User['RoleID']);
}
if (!isset($User['Password'])) {
$User['Password'] = md5(microtime());
$User['HashMethod'] = 'Random';
}
}
$UserID = Gdn::userModel()->save($User, array('SaveRoles' => isset($User['RoleID']), 'NoConfirmEmail' => true));
if ($UserID) {
if (!isset($User['UserID'])) {
$User['UserID'] = $UserID;
}
if (isset($User['ClientID']) && isset($User['UniqueID'])) {
Gdn::userModel()->saveAuthentication(array('UserID' => $User['UserID'], 'Provider' => $User['ClientID'], 'UniqueID' => $User['UniqueID']));
}
$this->setData('User', $User);
} else {
throw new Gdn_UserException(Gdn::userModel()->Validation->resultsText());
}
$this->render('Blank', 'Utility');
}
示例4: cachePermissions
/**
*
*
* @param null $UserID
* @param null $RoleID
* @return array|null
*/
public function cachePermissions($UserID = null, $RoleID = null)
{
if (!$UserID) {
$RoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_GUEST);
}
// Select all of the permission columns.
$PermissionColumns = $this->PermissionColumns();
foreach ($PermissionColumns as $ColumnName => $Value) {
$this->SQL->select('p.`' . $ColumnName . '`', 'MAX');
}
$this->SQL->from('Permission p');
if (!is_null($RoleID)) {
$this->SQL->where('p.RoleID', $RoleID);
} elseif (!is_null($UserID)) {
$this->SQL->join('UserRole ur', 'p.RoleID = ur.RoleID')->where('ur.UserID', $UserID);
}
$this->SQL->select(array('p.JunctionTable', 'p.JunctionColumn', 'p.JunctionID'))->groupBy(array('p.JunctionTable', 'p.JunctionColumn', 'p.JunctionID'));
$Result = $this->SQL->get()->resultArray();
return $Result;
}