summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSimon Rettberg2021-01-22 11:58:48 +0100
committerSimon Rettberg2021-01-22 11:58:48 +0100
commitb991e9cf9d4d5547402dfb2204e52f9638200c24 (patch)
tree0b8bfc0142a6bffa570864e5da876779cca8142a /modules
parentUpdate bwidm info links (diff)
downloadbwlp-webadmin-b991e9cf9d4d5547402dfb2204e52f9638200c24.tar.gz
bwlp-webadmin-b991e9cf9d4d5547402dfb2204e52f9638200c24.tar.xz
bwlp-webadmin-b991e9cf9d4d5547402dfb2204e52f9638200c24.zip
[images] Add very simple image management page
Diffstat (limited to 'modules')
-rw-r--r--modules/images.inc.php51
1 files changed, 51 insertions, 0 deletions
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 @@
+<?php
+
+class Page_Images extends Page
+{
+
+ protected function doPreprocess()
+ {
+ User::load();
+ if (!User::isShibbolethAuth()) {
+ Message::addError('Not {{0}}', CONFIG_IDM);
+ Util::redirect('?do=Main');
+ }
+ if (!User::isAdmin()) {
+ Message::addError('Not admin!');
+ Util::redirect('?do=Main');
+ }
+ if (Request::post('action') === 'delete') {
+ $image = Request::post('image');
+ $row = Database::queryFirst('SELECT filepath FROM imageversion WHERE imageversionid = :version',
+ ['version' => $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]);
+ }
+
+}