2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* ManageUsers.php
|
|
|
|
* Contains the controller with the list of users.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class ManageUsers extends HTMLController
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
// Ensure it's just admins at this point.
|
|
|
|
if (!Registry::get('user')->isAdmin())
|
|
|
|
throw new NotAllowedException();
|
|
|
|
|
2023-03-11 19:34:52 +01:00
|
|
|
Session::resetSessionToken();
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
$options = [
|
|
|
|
'form' => [
|
|
|
|
'action' => BASEURL . '/edituser/',
|
|
|
|
'method' => 'get',
|
2023-03-11 14:24:17 +01:00
|
|
|
'class' => 'col-md-6 text-end',
|
2016-09-01 23:13:23 +02:00
|
|
|
'buttons' => [
|
|
|
|
'add' => [
|
|
|
|
'type' => 'submit',
|
|
|
|
'caption' => 'Add new user',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'columns' => [
|
|
|
|
'id_user' => [
|
|
|
|
'value' => 'id_user',
|
|
|
|
'header' => 'ID',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'surname' => [
|
|
|
|
'header' => 'Last name',
|
|
|
|
'is_sortable' => true,
|
|
|
|
'parse' => [
|
|
|
|
'link' => BASEURL . '/edituser/?id={ID_USER}',
|
|
|
|
'data' => 'surname',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'first_name' => [
|
|
|
|
'header' => 'First name',
|
|
|
|
'is_sortable' => true,
|
|
|
|
'parse' => [
|
|
|
|
'link' => BASEURL . '/edituser/?id={ID_USER}',
|
|
|
|
'data' => 'first_name',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'slug' => [
|
|
|
|
'header' => 'Slug',
|
|
|
|
'is_sortable' => true,
|
|
|
|
'parse' => [
|
|
|
|
'link' => BASEURL . '/edituser/?id={ID_USER}',
|
|
|
|
'data' => 'slug',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'emailaddress' => [
|
|
|
|
'value' => 'emailaddress',
|
|
|
|
'header' => 'Email address',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'last_action_time' => [
|
|
|
|
'parse' => [
|
|
|
|
'type' => 'timestamp',
|
|
|
|
'data' => [
|
|
|
|
'timestamp' => 'last_action_time',
|
|
|
|
'pattern' => 'long',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'header' => 'Last activity',
|
|
|
|
'is_sortable' => true,
|
|
|
|
],
|
|
|
|
'ip_address' => [
|
|
|
|
'is_sortable' => true,
|
|
|
|
'value' => 'ip_address',
|
|
|
|
'header' => 'IP address',
|
|
|
|
],
|
|
|
|
'is_admin' => [
|
|
|
|
'is_sortable' => true,
|
|
|
|
'header' => 'Admin?',
|
|
|
|
'parse' => [
|
|
|
|
'type' => 'function',
|
|
|
|
'data' => function($row) {
|
|
|
|
return $row['is_admin'] ? 'yes' : 'no';
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
2024-12-19 15:00:00 +01:00
|
|
|
'default_sort_order' => 'id_user',
|
|
|
|
'default_sort_direction' => 'down',
|
|
|
|
'start' => $_GET['start'] ?? 0,
|
|
|
|
'sort_order' => $_GET['order'] ?? '',
|
|
|
|
'sort_direction' => $_GET['dir'] ?? '',
|
2016-09-01 23:13:23 +02:00
|
|
|
'title' => 'Manage users',
|
|
|
|
'no_items_label' => 'No users meet the requirements of the current filter.',
|
2017-11-05 16:27:12 +01:00
|
|
|
'items_per_page' => 30,
|
2023-03-11 14:24:17 +01:00
|
|
|
'index_class' => 'col-md-6',
|
2016-09-01 23:13:23 +02:00
|
|
|
'base_url' => BASEURL . '/manageusers/',
|
2024-12-19 15:00:00 +01:00
|
|
|
'get_data' => function($offset, $limit, $order, $direction) {
|
|
|
|
assert(in_array($order, ['id_user', 'surname', 'first_name', 'slug', 'emailaddress', 'last_action_time', 'ip_address', 'is_admin']));
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2024-12-19 15:00:00 +01:00
|
|
|
return Registry::get('db')->queryAssocs('
|
2016-09-01 23:13:23 +02:00
|
|
|
SELECT *
|
|
|
|
FROM users
|
|
|
|
ORDER BY {raw:order}
|
|
|
|
LIMIT {int:offset}, {int:limit}',
|
|
|
|
[
|
|
|
|
'order' => $order . ($direction == 'up' ? ' ASC' : ' DESC'),
|
|
|
|
'offset' => $offset,
|
|
|
|
'limit' => $limit,
|
|
|
|
]);
|
|
|
|
},
|
2024-12-19 15:00:00 +01:00
|
|
|
'get_count' => 'Member::getCount',
|
2016-09-01 23:13:23 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
$table = new GenericTable($options);
|
|
|
|
parent::__construct('User management - Page ' . $table->getCurrentPage() .' - ' . SITE_TITLE);
|
|
|
|
$this->page->adopt(new TabularData($table));
|
|
|
|
}
|
|
|
|
}
|