//Merging management and public user listing.

This commit is contained in:
flash 2018-12-05 20:57:56 +01:00
parent 9bd1d3e910
commit 0a417b75af
4 changed files with 41 additions and 26 deletions

View file

@ -56,6 +56,11 @@ if (empty($orderDir)) {
return;
}
$canManageUsers = perms_check(
perms_get_user(MSZ_PERMS_USER, user_session_current('user_id', 0)),
MSZ_PERM_USER_MANAGE_USERS
);
$getRole = db_prepare('
SELECT
`role_id`, `role_name`, `role_colour`, `role_description`, `role_created`,
@ -82,20 +87,26 @@ $roles = db_query('
ORDER BY `role_id`
')->fetchAll(PDO::FETCH_ASSOC);
$getUsers = db_prepare("
SELECT
u.`user_id`, u.`username`, u.`user_country`, r.`role_id`,
COALESCE(u.`user_title`, r.`role_title`, r.`role_name`) as `user_title`,
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
FROM `msz_users` as u
LEFT JOIN `msz_roles` as r
ON r.`role_id` = u.`display_role`
LEFT JOIN `msz_user_roles` as ur
ON ur.`user_id` = u.`user_id`
WHERE ur.`role_id` = :role_id
ORDER BY u.`{$orderFields[$orderBy]['column']}` {$orderDir}
LIMIT :offset, :take
");
$getUsers = db_prepare(sprintf(
'
SELECT
u.`user_id`, u.`username`, u.`user_country`, r.`role_id`,
COALESCE(u.`user_title`, r.`role_title`, r.`role_name`) as `user_title`,
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
FROM `msz_users` as u
LEFT JOIN `msz_roles` as r
ON r.`role_id` = u.`display_role`
LEFT JOIN `msz_user_roles` as ur
ON ur.`user_id` = u.`user_id`
WHERE ur.`role_id` = :role_id
%1$s
ORDER BY u.`%2$s` %3$s
LIMIT :offset, :take
',
$canManageUsers ? '' : 'AND u.`user_deleted` IS NULL',
$orderFields[$orderBy]['column'],
$orderDir
));
$getUsers->bindValue('role_id', $role['role_id']);
$getUsers->bindValue('offset', $usersOffset);
$getUsers->bindValue('take', $usersTake);
@ -112,4 +123,5 @@ echo tpl_render('user.listing', [
'order_default' => $defaultOrder,
'users_offset' => $usersOffset,
'users_take' => $usersTake,
'can_manage_users' => $canManageUsers,
]);

View file

@ -13,14 +13,12 @@
{{ container_title(edit_change is defined ? 'Editing #' ~ edit_change.change_id : 'Adding a new change') }}
<label class="form__label" style="width:100%">
<div class="form__label__text">Log</div>
<div class="form__label__input">
{{ input_text('change[log]', '', edit_change is defined ? edit_change.change_log : '', 'text', '', true, {'maxlength':255}) }}
</div>
</label>
<div style="display: flex; margin: 2px 5px;">
{{ input_select('change[action]', changelog_actions, edit_change.action_id|default(0), 'action_name', 'action_id') }}
{{ input_text('change[log]', '', edit_change is defined ? edit_change.change_log : '', 'text', '', true, {'maxlength':255,'style':'flex-grow:1'}) }}
</div>
<label class="form__label" style="width:100%">
<label class="form__label">
<div class="form__label__text">Text</div>
<div class="form__label__input">
<textarea class="input__textarea" name="change[text]" maxlength="65535">{{ edit_change is defined ? edit_change.change_text : '' }}</textarea>
@ -30,7 +28,7 @@
<label class="form__label">
<div class="form__label__text">Action</div>
<div class="form__label__input">
{{ input_select('change[action]', changelog_actions, edit_change.action_id|default(0), 'action_name', 'action_id') }}
</div>
</label>
@ -57,7 +55,7 @@
{{ container_title('Tags') }}
{% if edit_change_assigned_tags|length > 0 %}
<form method="post" action="" style="display:inline-block">
<form method="post" action="">
<label class="form__label">
<div class="form__label__text">Assigned Tags</div>
<div class="form__label__input">
@ -70,7 +68,7 @@
{% endif %}
{% if edit_change_available_tags|length > 0 %}
<form class="container" method="post" action="" style="display:inline-block">
<form method="post" action="">
<label class="form__label">
<div class="form__label__text">Available Tags</div>
<div class="form__label__input">

View file

@ -40,7 +40,12 @@
<div class="userlist">
{% for user in users %}
<div class="userlist__item">
{{ user_card(user) }}
{{ user_card(user, null, null, not can_manage_users ? [] : [
{
'href': '/manage/users.php?v=view&u=%d'|format(user.user_id),
'text': 'Manage',
}
]) }}
</div>
{% endfor %}
</div>

View file

@ -29,7 +29,7 @@
</div>
</div>
</div>
{% if actions is iterable %}
{% if actions is iterable and actions|length > 0 %}
<div class="usercard__actions">
{% for action in actions %}
<a class="usercard__action"