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

37 lines
1 KiB
PHP

<?php
namespace Misuzu;
use Misuzu\Users\Roles;
if(!$msz->authInfo->getPerms('user')->check(Perm::U_USERS_MANAGE))
Template::throwError(403);
$pagination = new Pagination($msz->usersCtx->users->countUsers(), 30);
if(!$pagination->hasValidOffset())
Template::throwError(404);
$userList = [];
$userInfos = $msz->usersCtx->users->getUsers(pagination: $pagination, orderBy: 'id');
$roleInfos = [];
foreach($userInfos as $userInfo) {
$displayRoleId = $userInfo->displayRoleId ?? Roles::DEFAULT_ROLE;
if(array_key_exists($displayRoleId, $roleInfos))
$roleInfo = $roleInfos[$displayRoleId];
else
$roleInfos[$displayRoleId] = $roleInfo = $msz->usersCtx->roles->getRole($displayRoleId);
$colour = $userInfo->hasColour ? $userInfo->colour : $roleInfo->colour;
$userList[] = [
'info' => $userInfo,
'role' => $roleInfo,
'colour' => $colour,
];
}
Template::render('manage.users.users', [
'manage_users' => $userList,
'manage_users_pagination' => $pagination,
]);