summaryrefslogtreecommitdiffstats
path: root/modules/images.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/images.inc.php')
-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]);
+ }
+
+}