当前位置: 首页>>代码示例>>PHP>>正文


PHP RoleModel::define方法代码示例

本文整理汇总了PHP中RoleModel::define方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::define方法的具体用法?PHP RoleModel::define怎么用?PHP RoleModel::define使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RoleModel的用法示例。


在下文中一共展示了RoleModel::define方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

$Database = Gdn::database();
$SQL = $Database->sql();
$Construct = $Database->structure();
$Px = $Database->DatabasePrefix;
// Role Table
$Construct->table('Role');
$RoleTableExists = $Construct->tableExists();
$RoleTypeExists = $Construct->columnExists('Type');
$Construct->primaryKey('RoleID')->column('Name', 'varchar(100)')->column('Description', 'varchar(500)', true)->column('Type', array(RoleModel::TYPE_GUEST, RoleModel::TYPE_UNCONFIRMED, RoleModel::TYPE_APPLICANT, RoleModel::TYPE_MEMBER, RoleModel::TYPE_MODERATOR, RoleModel::TYPE_ADMINISTRATOR), true)->column('Sort', 'int', true)->column('Deletable', 'tinyint(1)', '1')->column('CanSession', 'tinyint(1)', '1')->column('PersonalInfo', 'tinyint(1)', '0')->set($Explicit, $Drop);
$RoleModel = new RoleModel();
if (!$RoleTableExists || $Drop) {
    // Define default roles.
    $RoleModel->Database = $Database;
    $RoleModel->SQL = $SQL;
    $Sort = 1;
    $RoleModel->define(array('Name' => 'Guest', 'Type' => RoleModel::TYPE_GUEST, 'RoleID' => 2, 'Sort' => $Sort++, 'Deletable' => '0', 'CanSession' => '0', 'Description' => t('Guest Role Description', 'Guests can only view content. Anyone browsing the site who is not signed in is considered to be a "Guest".')));
    $RoleModel->define(array('Name' => 'Unconfirmed', 'Type' => RoleModel::TYPE_UNCONFIRMED, 'RoleID' => 3, 'Sort' => $Sort++, 'Deletable' => '0', 'CanSession' => '1', 'Description' => t('Unconfirmed Role Description', 'Users must confirm their emails before becoming full members. They get assigned to this role.')));
    $RoleModel->define(array('Name' => 'Applicant', 'Type' => RoleModel::TYPE_APPLICANT, 'RoleID' => 4, 'Sort' => $Sort++, 'Deletable' => '0', 'CanSession' => '1', 'Description' => t('Applicant Role Description', 'Users who have applied for membership, but have not yet been accepted. They have the same permissions as guests.')));
    $RoleModel->define(array('Name' => 'Member', 'Type' => RoleModel::TYPE_MEMBER, 'RoleID' => 8, 'Sort' => $Sort++, 'Deletable' => '1', 'CanSession' => '1', 'Description' => t('Member Role Description', 'Members can participate in discussions.')));
    $RoleModel->define(array('Name' => 'Moderator', 'Type' => RoleModel::TYPE_MODERATOR, 'RoleID' => 32, 'Sort' => $Sort++, 'Deletable' => '1', 'CanSession' => '1', 'Description' => t('Moderator Role Description', 'Moderators have permission to edit most content.')));
    $RoleModel->define(array('Name' => 'Administrator', 'Type' => RoleModel::TYPE_ADMINISTRATOR, 'RoleID' => 16, 'Sort' => $Sort++, 'Deletable' => '1', 'CanSession' => '1', 'Description' => t('Administrator Role Description', 'Administrators have permission to do anything.')));
}
// User Table
$Construct->table('User');
$PhotoIDExists = $Construct->columnExists('PhotoID');
$PhotoExists = $Construct->columnExists('Photo');
$UserExists = $Construct->tableExists();
$ConfirmedExists = $Construct->columnExists('Confirmed');
$Construct->primaryKey('UserID')->column('Name', 'varchar(50)', false, 'key')->column('Password', 'varbinary(100)')->column('HashMethod', 'varchar(10)', true)->column('Photo', 'varchar(255)', null)->column('Title', 'varchar(100)', null)->column('Location', 'varchar(100)', null)->column('About', 'text', true)->column('Email', 'varchar(100)', false, 'index')->column('ShowEmail', 'tinyint(1)', '0')->column('Gender', array('u', 'm', 'f'), 'u')->column('CountVisits', 'int', '0')->column('CountInvitations', 'int', '0')->column('CountNotifications', 'int', null)->column('InviteUserID', 'int', true)->column('DiscoveryText', 'text', true)->column('Preferences', 'text', true)->column('Permissions', 'text', true)->column('Attributes', 'text', true)->column('DateSetInvitations', 'datetime', true)->column('DateOfBirth', 'datetime', true)->column('DateFirstVisit', 'datetime', true)->column('DateLastActive', 'datetime', true, 'index')->column('LastIPAddress', 'varchar(15)', true)->column('AllIPAddresses', 'varchar(100)', true)->column('DateInserted', 'datetime', false, 'index')->column('InsertIPAddress', 'varchar(15)', true)->column('DateUpdated', 'datetime', true)->column('UpdateIPAddress', 'varchar(15)', true)->column('HourOffset', 'int', '0')->column('Score', 'float', null)->column('Admin', 'tinyint(1)', '0')->column('Confirmed', 'tinyint(1)', '1')->column('Verified', 'tinyint(1)', '0')->column('Banned', 'tinyint(1)', '0')->column('Deleted', 'tinyint(1)', '0')->column('Points', 'int', 0)->set($Explicit, $Drop);
// Modify all users with ConfirmEmail role to be unconfirmed
if ($UserExists && !$ConfirmedExists) {
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:31,代码来源:structure.php


注:本文中的RoleModel::define方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。