From b991e9cf9d4d5547402dfb2204e52f9638200c24 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 22 Jan 2021 11:58:48 +0100 Subject: [images] Add very simple image management page --- modules/images.inc.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++ templates/image-list.html | 51 +++++++++++++++++++++++++++++++++++++++++++++++ templates/main-menu.html | 1 + 3 files changed, 103 insertions(+) create mode 100644 modules/images.inc.php create mode 100644 templates/image-list.html diff --git a/modules/images.inc.php b/modules/images.inc.php new file mode 100644 index 0000000..f962c07 --- /dev/null +++ b/modules/images.inc.php @@ -0,0 +1,51 @@ + $image]); + if ($row === false) { + Message::addError('Image {{0}} nicht gefunden', $image); + } else { + // PHP process doesn't have write permissions to VM store, plus we don't have the absolute path + // for now this has to do, until someone comes along and adds an RPC method in the java app. + Message::addInfo('Vergessen Sie nicht, {{0}} vom Storage zu löschen', $row['filepath']); + Database::exec("DELETE FROM imageversion WHERE imageversionid = :version", + ['version' => $image]); + } + Util::redirect('?do=images'); + } + } + + protected function doRender() + { + $res = Database::simpleQuery('SELECT b.displayname, b.description, + v.imageversionid, v.createtime, v.expiretime, v.filesize, v.filepath + FROM imagebase b + INNER JOIN imageversion v USING (imagebaseid) + ORDER BY b.imagebaseid ASC, v.createtime ASC'); + $rows = []; + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $row['createtime_s'] = date('d.m.Y', $row['createtime']); + $row['expiretime_s'] = date('d.m.Y', $row['expiretime']); + $row['filesize_s'] = Util::readableFileSize($row['filesize']); + $rows[] = $row; + } + Render::addTemplate('image-list', ['list' => $rows]); + } + +} diff --git a/templates/image-list.html b/templates/image-list.html new file mode 100644 index 0000000..3c4561e --- /dev/null +++ b/templates/image-list.html @@ -0,0 +1,51 @@ +