本文整理汇总了PHP中RoleModel::SetUserRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::SetUserRoles方法的具体用法?PHP RoleModel::SetUserRoles怎么用?PHP RoleModel::SetUserRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::SetUserRoles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetMembersListEnh
public function GetMembersListEnh($Limit = 5, $Offset = 0, $SortOrder, $UserField)
{
$RoleAction = $RoleActionID = "";
$RemoveRoleArray = C('Plugins.MembersListEnh.RoleID');
if (isset($RemoveRoleArray)) {
$RoleAction = $RemoveRoleArray[0];
$RoleActionID = $RemoveRoleArray[1];
}
$MembersListEnhModel = new Gdn_Model('User');
$SQL = $MembersListEnhModel->SQL->Select('*')->From('User u')->LeftJoin('UserRole ur', 'u.UserID = ur.UserID');
if (C('EnabledPlugins.KarmaBank') == TRUE) {
$SQL->LeftJoin('KarmaBankBalance kb', 'u.UserID = kb.UserID');
}
if ($UserField != "Balance") {
$SQL->OrderBy("u.{$UserField}", $SortOrder);
}
if (C('EnabledPlugins.KarmaBank') == TRUE && $UserField == "Balance") {
$SQL->OrderBy("kb.Balance", $SortOrder);
}
$SQL->Where('Deleted', false);
if ($RoleAction == "Exclude") {
$SQL->Where('ur.RoleID<>', $RoleActionID);
}
if ($RoleAction == "Include") {
$SQL->Where('ur.RoleID', $RoleActionID);
}
// Only show user once if in more than one role.
$SQL->GroupBy('ur.UserID');
$Sender->UserData = $SQL->Limit($Limit, $Offset)->Get();
RoleModel::SetUserRoles($Sender->UserData->Result());
return $Sender->UserData;
}
示例2: Index
public function Index($Keywords = '', $Page = '') {
$this->Permission(
array(
'Garden.Users.Add',
'Garden.Users.Edit',
'Garden.Users.Delete'
),
'',
FALSE
);
$this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('user.js');
$this->Title(T('Users'));
$this->AddSideMenu('dashboard/user');
$this->Form->Method = 'get';
// Input Validation.
list($Offset, $Limit) = OffsetLimit($Page, PagerModule::$DefaultPageSize);
if (!$Keywords) {
$Keywords = $this->Form->GetFormValue('Keywords');
if ($Keywords)
$Offset = 0;
}
// Put the Keyword back in the form
if ($Keywords)
$this->Form->SetFormValue('Keywords', $Keywords);
$UserModel = new UserModel();
//$Like = trim($Keywords) == '' ? FALSE : array('u.Name' => $Keywords, 'u.Email' => $Keywords);
list($Offset, $Limit) = OffsetLimit($Page, 30);
$Filter = $this->_GetFilter();
if ($Filter)
$Filter['Keywords'] = $Keywords;
else
$Filter = $Keywords;
$this->SetData('RecordCount', $UserModel->SearchCount($Filter));
$this->UserData = $UserModel->Search($Filter, 'u.Name', 'asc', $Limit, $Offset);
RoleModel::SetUserRoles($this->UserData->Result());
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'users';
}
$this->Render();
}
示例3: PostController_Render_Before
public function PostController_Render_Before($Sender)
{
$Data = $Sender->Data('Comments');
if (is_object($Data)) {
RoleModel::SetUserRoles($Data->Result(), 'InsertUserID');
}
}
示例4: index
/**
* User management list.
*
* @since 2.0.0
* @access public
* @param mixed $Keywords Term or array of terms to filter list of users.
* @param int $Page Page number.
* @param string $Order Sort order for list.
*/
public function index($Keywords = '', $Page = '', $Order = '')
{
$this->permission(array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'), '', false);
// Page setup
$this->addJsFile('jquery.gardenmorepager.js');
$this->addJsFile('user.js');
$this->title(t('Users'));
$this->addSideMenu('dashboard/user');
// Form setup
$this->Form->Method = 'get';
// Input Validation.
list($Offset, $Limit) = offsetLimit($Page, PagerModule::$DefaultPageSize);
if (!$Keywords) {
$Keywords = $this->Form->getFormValue('Keywords');
if ($Keywords) {
$Offset = 0;
}
}
if (!is_string($Keywords)) {
$Keywords = '';
}
// Put the Keyword back in the form
if ($Keywords) {
$this->Form->setFormValue('Keywords', $Keywords);
}
$UserModel = new UserModel();
//$Like = trim($Keywords) == '' ? FALSE : array('u.Name' => $Keywords, 'u.Email' => $Keywords);
list($Offset, $Limit) = offsetLimit($Page, 30);
$Filter = $this->_GetFilter();
if ($Filter) {
$Filter['Keywords'] = $Keywords;
} else {
$Filter = array('Keywords' => (string) $Keywords);
}
$Filter['Optimize'] = $this->PastUserThreshold();
// Sorting
if (in_array($Order, array('DateInserted', 'DateFirstVisit', 'DateLastActive'))) {
$Order = 'u.' . $Order;
$OrderDir = 'desc';
} else {
$Order = 'u.Name';
$OrderDir = 'asc';
}
// Get user list
$this->UserData = $UserModel->Search($Filter, $Order, $OrderDir, $Limit, $Offset);
$this->setData('Users', $this->UserData);
if ($this->PastUserThreshold()) {
$this->setData('_CurrentRecords', $this->UserData->count());
} else {
$this->setData('RecordCount', $UserModel->SearchCount($Filter));
}
RoleModel::SetUserRoles($this->UserData->result());
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL && $this->_DeliveryMethod == DELIVERY_METHOD_XHTML) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
$this->View = 'users';
}
$this->render();
}