1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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]);
}
}
|