//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; return;
} }
$canManageUsers = perms_check(
perms_get_user(MSZ_PERMS_USER, user_session_current('user_id', 0)),
MSZ_PERM_USER_MANAGE_USERS
);
$getRole = db_prepare(' $getRole = db_prepare('
SELECT SELECT
`role_id`, `role_name`, `role_colour`, `role_description`, `role_created`, `role_id`, `role_name`, `role_colour`, `role_description`, `role_created`,
@ -82,7 +87,8 @@ $roles = db_query('
ORDER BY `role_id` ORDER BY `role_id`
')->fetchAll(PDO::FETCH_ASSOC); ')->fetchAll(PDO::FETCH_ASSOC);
$getUsers = db_prepare(" $getUsers = db_prepare(sprintf(
'
SELECT SELECT
u.`user_id`, u.`username`, u.`user_country`, r.`role_id`, 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_title`, r.`role_title`, r.`role_name`) as `user_title`,
@ -93,9 +99,14 @@ $getUsers = db_prepare("
LEFT JOIN `msz_user_roles` as ur LEFT JOIN `msz_user_roles` as ur
ON ur.`user_id` = u.`user_id` ON ur.`user_id` = u.`user_id`
WHERE ur.`role_id` = :role_id WHERE ur.`role_id` = :role_id
ORDER BY u.`{$orderFields[$orderBy]['column']}` {$orderDir} %1$s
ORDER BY u.`%2$s` %3$s
LIMIT :offset, :take LIMIT :offset, :take
"); ',
$canManageUsers ? '' : 'AND u.`user_deleted` IS NULL',
$orderFields[$orderBy]['column'],
$orderDir
));
$getUsers->bindValue('role_id', $role['role_id']); $getUsers->bindValue('role_id', $role['role_id']);
$getUsers->bindValue('offset', $usersOffset); $getUsers->bindValue('offset', $usersOffset);
$getUsers->bindValue('take', $usersTake); $getUsers->bindValue('take', $usersTake);
@ -112,4 +123,5 @@ echo tpl_render('user.listing', [
'order_default' => $defaultOrder, 'order_default' => $defaultOrder,
'users_offset' => $usersOffset, 'users_offset' => $usersOffset,
'users_take' => $usersTake, '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') }} {{ container_title(edit_change is defined ? 'Editing #' ~ edit_change.change_id : 'Adding a new change') }}
<label class="form__label" style="width:100%"> <div style="display: flex; margin: 2px 5px;">
<div class="form__label__text">Log</div> {{ input_select('change[action]', changelog_actions, edit_change.action_id|default(0), 'action_name', 'action_id') }}
<div class="form__label__input"> {{ input_text('change[log]', '', edit_change is defined ? edit_change.change_log : '', 'text', '', true, {'maxlength':255,'style':'flex-grow:1'}) }}
{{ input_text('change[log]', '', edit_change is defined ? edit_change.change_log : '', 'text', '', true, {'maxlength':255}) }}
</div> </div>
</label>
<label class="form__label" style="width:100%"> <label class="form__label">
<div class="form__label__text">Text</div> <div class="form__label__text">Text</div>
<div class="form__label__input"> <div class="form__label__input">
<textarea class="input__textarea" name="change[text]" maxlength="65535">{{ edit_change is defined ? edit_change.change_text : '' }}</textarea> <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"> <label class="form__label">
<div class="form__label__text">Action</div> <div class="form__label__text">Action</div>
<div class="form__label__input"> <div class="form__label__input">
{{ input_select('change[action]', changelog_actions, edit_change.action_id|default(0), 'action_name', 'action_id') }}
</div> </div>
</label> </label>
@ -57,7 +55,7 @@
{{ container_title('Tags') }} {{ container_title('Tags') }}
{% if edit_change_assigned_tags|length > 0 %} {% if edit_change_assigned_tags|length > 0 %}
<form method="post" action="" style="display:inline-block"> <form method="post" action="">
<label class="form__label"> <label class="form__label">
<div class="form__label__text">Assigned Tags</div> <div class="form__label__text">Assigned Tags</div>
<div class="form__label__input"> <div class="form__label__input">
@ -70,7 +68,7 @@
{% endif %} {% endif %}
{% if edit_change_available_tags|length > 0 %} {% 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"> <label class="form__label">
<div class="form__label__text">Available Tags</div> <div class="form__label__text">Available Tags</div>
<div class="form__label__input"> <div class="form__label__input">

View file

@ -40,7 +40,12 @@
<div class="userlist"> <div class="userlist">
{% for user in users %} {% for user in users %}
<div class="userlist__item"> <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> </div>
{% endfor %} {% endfor %}
</div> </div>

View file

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