From fa01bf8961cba7a59872a550a8f371b6b1b746c7 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 11 Mar 2023 17:53:53 +0100 Subject: [PATCH] ManageAssets: trade filename for user uploaded field --- controllers/ManageAssets.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/controllers/ManageAssets.php b/controllers/ManageAssets.php index 463ede5..4598c8e 100644 --- a/controllers/ManageAssets.php +++ b/controllers/ManageAssets.php @@ -38,13 +38,17 @@ class ManageAssets extends HTMLController 'data' => 'filename', ], ], - 'title' => [ - 'header' => 'Title', + 'id_user_uploaded' => [ + 'header' => 'User uploaded', 'is_sortable' => true, 'parse' => [ - 'type' => 'value', - 'link' => BASEURL . '/editasset/?id={ID_ASSET}', - 'data' => 'title', + 'type' => 'function', + 'data' => function($row) { + if (!empty($row['first_name'])) + return $row['first_name'] . ' ' . $row['surname']; + else + return 'n/a'; + }, ], ], 'dimensions' => [ @@ -69,12 +73,15 @@ class ManageAssets extends HTMLController 'items_per_page' => 30, 'base_url' => BASEURL . '/manageassets/', 'get_data' => function($offset = 0, $limit = 30, $order = '', $direction = 'down') { - if (!in_array($order, ['id_asset', 'title', 'subdir', 'filename'])) + if (!in_array($order, ['id_asset', 'id_user_uploaded', 'title', 'subdir', 'filename'])) $order = 'id_asset'; $data = Registry::get('db')->queryAssocs(' - SELECT id_asset, title, subdir, filename, image_width, image_height - FROM assets + SELECT a.id_asset, a.subdir, a.filename, + a.image_width, a.image_height, + 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}', [