misuzu/public-legacy/manage/users/roles.php

28 lines
756 B
PHP

<?php
namespace Misuzu;
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
die('Script must be called through the Misuzu route dispatcher.');
if(!$msz->authInfo->getPerms('user')->check(Perm::U_ROLES_MANAGE))
Template::throwError(403);
$roles = $msz->usersCtx->roles;
$pagination = new Pagination($roles->countRoles(), 10);
if(!$pagination->hasValidOffset())
Template::throwError(404);
$rolesAll = [];
$roleInfos = $roles->getRoles(pagination: $pagination);
foreach($roleInfos as $roleInfo)
$rolesAll[] = [
'info' => $roleInfo,
'members' => $roles->countRoleUsers($roleInfo),
];
Template::render('manage.users.roles', [
'manage_roles' => $rolesAll,
'manage_roles_pagination' => $pagination,
]);