本文整理匯總了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();
}