本文整理汇总了PHP中UserRole::findByRoleId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRole::findByRoleId方法的具体用法?PHP UserRole::findByRoleId怎么用?PHP UserRole::findByRoleId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRole
的用法示例。
在下文中一共展示了UserRole::findByRoleId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executePermissions
public function executePermissions()
{
if (!$this->isAllowed(PERMISSION_ROLE_PERMISSION_MANAGE)) {
return $this->raise403(t("You don't have permission"));
}
$id = $this->get('id');
if (!$id || !($role = \Roles::retrieveById($id))) {
return $this->raise404(t('Role not found!'));
}
//get role's members id
/** @var \UserRole[] $userRoles */
$userRoles = (array) \UserRole::findByRoleId($id);
$staffs = \Users::findBySection(\Users::SECTION_STAFF);
$members = [];
$others = [];
$t = [];
foreach ($userRoles as $ur) {
$t[$ur->getUserId()] = true;
}
foreach ($staffs as $staff) {
if (isset($t[$staff->getId()])) {
$members[$staff->getId()] = $staff;
} else {
if ($staff->isActive()) {
$others[$staff->getId()] = $staff;
}
}
}
unset($members[1]);
unset($others[1]);
$assigned = \Permissions::findByRoleId($role->getId(), true);
$permissions = \Permissions::getPermissionsList();
foreach ($permissions as $group => &$pg) {
foreach ($pg['permissions'] as $permission => &$detail) {
if (isset($assigned[$permission])) {
$detail['assigned'] = true;
} else {
$detail['assigned'] = false;
}
}
}
$this->setView('Role/detail');
$this->view()->assign(array('permissions' => $permissions, 'role' => $role, 'members' => $members, 'otherGuys' => $others));
return $this->renderComponent();
}