本文整理汇总了PHP中RoleModel::setUserRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::setUserRoles方法的具体用法?PHP RoleModel::setUserRoles怎么用?PHP RoleModel::setUserRoles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::setUserRoles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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->setHighlightRoute('dashboard/user');
Gdn_Theme::section('Moderation');
// 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();
list($Offset, $Limit) = offsetLimit($Page, 30);
// Determine our data filters.
$Filter = $this->_getFilter();
if ($Filter) {
$Filter['Keywords'] = $Keywords;
} else {
$Filter = array('Keywords' => (string) $Keywords);
}
$Filter['Optimize'] = Gdn::userModel()->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);
// Figure out our number of results and users.
$showUserCount = $this->UserData->count();
if (!Gdn::userModel()->pastUserThreshold()) {
// Pfft, query that sucker however you want.
$this->setData('RecordCount', $UserModel->searchCount($Filter));
} else {
// We have a user search, so at least set enough data for the Next pager.
if ($showUserCount) {
$this->setData('_CurrentRecords', $showUserCount);
} else {
// No search was done. Just give the total users overall. First, zero-out our pager.
$this->setData('_CurrentRecords', 0);
if (!Gdn::userModel()->pastUserMegaThreshold()) {
// Restoring this semi-optimized counter is our compromise to let non-mega sites know their exact total users.
$this->setData('UserCount', $UserModel->getCount());
} else {
// Dang, yo. Get a table status guess instead of really counting.
$this->setData('UserEstimate', Gdn::userModel()->countEstimate());
}
}
}
// Add roles to the user data.
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();
}
示例2: postController_render_before
/**
*
* @param PostController $sender Sending controller instance.
* @param array $args Event arguments.
*/
public function postController_render_before($sender, $args)
{
$data = $sender->data('Comments');
if (is_object($data)) {
RoleModel::setUserRoles($data->result(), 'InsertUserID');
}
}