forked from Public/pics
Management controllers: move table queries into models
This commit is contained in:
@@ -65,11 +65,10 @@ class ManageAlbums extends HTMLController
|
||||
'index_class' => 'col-md-6',
|
||||
'base_url' => BASEURL . '/managealbums/',
|
||||
'get_data' => function($offset, $limit, $order, $direction) {
|
||||
assert(in_array($order, ['id_tag', 'tag', 'slug', 'count']));
|
||||
return PhotoAlbum::getHierarchy($order, $direction);
|
||||
return Tag::getOffset($offset, $limit, $order, $direction, true);
|
||||
},
|
||||
'get_count' => function() {
|
||||
return 9999;
|
||||
return Tag::getCount(false, 'Album', true);
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -131,23 +131,7 @@ class ManageAssets extends HTMLController
|
||||
'items_per_page' => 30,
|
||||
'index_class' => 'col-md-6',
|
||||
'base_url' => BASEURL . '/manageassets/',
|
||||
'get_data' => function($offset, $limit, $order, $direction) {
|
||||
assert(in_array($order, ['id_asset', 'id_user_uploaded', 'title', 'subdir', 'filename']));
|
||||
|
||||
return Registry::get('db')->queryAssocs('
|
||||
SELECT a.id_asset, a.subdir, a.filename,
|
||||
a.image_width, a.image_height, a.mimetype,
|
||||
u.id_user, u.first_name, u.surname
|
||||
FROM assets AS a
|
||||
LEFT JOIN users AS u ON a.id_user_uploaded = u.id_user
|
||||
ORDER BY {raw:order}
|
||||
LIMIT {int:offset}, {int:limit}',
|
||||
[
|
||||
'order' => $order . ($direction == 'up' ? ' ASC' : ' DESC'),
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
},
|
||||
'get_data' => 'Asset::getOffset',
|
||||
'get_count' => 'Asset::getCount',
|
||||
];
|
||||
|
||||
|
||||
@@ -105,20 +105,7 @@ class ManageErrors extends HTMLController
|
||||
'index_class' => 'col-md-6',
|
||||
'base_url' => BASEURL . '/manageerrors/',
|
||||
'get_count' => 'ErrorLog::getCount',
|
||||
'get_data' => function($offset, $limit, $order, $direction) {
|
||||
assert(in_array($order, ['id_entry', 'file', 'line', 'time', 'ipaddress', 'id_user']));
|
||||
|
||||
return Registry::get('db')->queryAssocs('
|
||||
SELECT *
|
||||
FROM log_errors
|
||||
ORDER BY {raw:order}
|
||||
LIMIT {int:offset}, {int:limit}',
|
||||
[
|
||||
'order' => $order . ($direction === 'up' ? ' ASC' : ' DESC'),
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
},
|
||||
'get_data' => 'ErrorLog::getOffset',
|
||||
];
|
||||
|
||||
$error_log = new GenericTable($options);
|
||||
|
||||
@@ -81,28 +81,10 @@ class ManageTags extends HTMLController
|
||||
'index_class' => 'col-md-6',
|
||||
'base_url' => BASEURL . '/managetags/',
|
||||
'get_data' => function($offset, $limit, $order, $direction) {
|
||||
assert(in_array($order, ['id_tag', 'tag', 'slug', 'count']));
|
||||
|
||||
return Registry::get('db')->queryAssocs('
|
||||
SELECT t.*, u.id_user, u.first_name, u.surname
|
||||
FROM tags AS t
|
||||
LEFT JOIN users AS u ON t.id_user_owner = u.id_user
|
||||
WHERE kind != {string:album}
|
||||
ORDER BY {raw:order}
|
||||
LIMIT {int:offset}, {int:limit}',
|
||||
[
|
||||
'order' => $order . ($direction == 'up' ? ' ASC' : ' DESC'),
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
'album' => 'Album',
|
||||
]);
|
||||
return Tag::getOffset($offset, $limit, $order, $direction, false);
|
||||
},
|
||||
'get_count' => function() {
|
||||
return Registry::get('db')->queryValue('
|
||||
SELECT COUNT(*)
|
||||
FROM tags
|
||||
WHERE kind != {string:album}',
|
||||
['album' => 'Album']);
|
||||
return Tag::getCount(false, null, false);
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -100,20 +100,7 @@ class ManageUsers extends HTMLController
|
||||
'items_per_page' => 30,
|
||||
'index_class' => 'col-md-6',
|
||||
'base_url' => BASEURL . '/manageusers/',
|
||||
'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']));
|
||||
|
||||
return Registry::get('db')->queryAssocs('
|
||||
SELECT *
|
||||
FROM users
|
||||
ORDER BY {raw:order}
|
||||
LIMIT {int:offset}, {int:limit}',
|
||||
[
|
||||
'order' => $order . ($direction == 'up' ? ' ASC' : ' DESC'),
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
},
|
||||
'get_data' => 'Member::getOffset',
|
||||
'get_count' => 'Member::getCount',
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user