summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/download.inc.php12
-rw-r--r--inc/message.inc.php2
-rw-r--r--lang/de/messages.json1
-rw-r--r--lang/de/templates/dozmod/images-delete.json12
-rw-r--r--lang/de/templates/dozmod/mailconfig.json1
-rw-r--r--lang/de/templates/dozmod/userlist.json1
-rw-r--r--lang/en/messages.json1
-rw-r--r--lang/en/templates/dozmod/images-delete.json12
-rw-r--r--lang/en/templates/dozmod/mailconfig.json1
-rw-r--r--lang/en/templates/dozmod/userlist.json1
-rw-r--r--lang/pt/templates/dozmod/images-delete.json3
-rw-r--r--modules/dozmod.inc.php70
-rw-r--r--style/default.css6
-rw-r--r--templates/dozmod/images-delete.html57
-rw-r--r--templates/dozmod/mailconfig.html3
-rw-r--r--templates/dozmod/userlist.html1
16 files changed, 174 insertions, 10 deletions
diff --git a/inc/download.inc.php b/inc/download.inc.php
index 5347e2ee..51601545 100644
--- a/inc/download.inc.php
+++ b/inc/download.inc.php
@@ -69,11 +69,13 @@ class Download
public static function asStringPost($url, $params, $timeout, &$code)
{
$string = '';
- foreach ($params as $k => $v) {
- if (!empty($string)) {
- $string .= '&';
+ if (is_array($params)) {
+ foreach ($params as $k => $v) {
+ if (!empty($string)) {
+ $string .= '&';
+ }
+ $string .= $k . '=' . urlencode($v);
}
- $string .= $k . '=' . urlencode($v);
}
$ch = self::initCurl($url, $timeout, $head);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -115,7 +117,7 @@ class Download
return false;
}
if (preg_match_all('#\bHTTP/\d+\.\d+ (\d+) #', $head, $out, PREG_SET_ORDER)) {
- $code = (int) $out[count($out)-1][1];
+ $code = (int) $out[count($out) - 1][1];
} else {
$code = '999 ' . curl_error($ch);
}
diff --git a/inc/message.inc.php b/inc/message.inc.php
index 2fccb0a0..472811ff 100644
--- a/inc/message.inc.php
+++ b/inc/message.inc.php
@@ -120,7 +120,7 @@ class Message
foreach (array_merge(self::$list, self::$alreadyDisplayed) as $item) {
$str = 'message[]=' . urlencode($item['type'] . '|' .$item['id']);
if (!empty($item['params'])) {
- $str .= '|' . implode('|', $item['params']);
+ $str .= '|' . urlencode(implode('|', $item['params']));
}
$parts[] = $str;
}
diff --git a/lang/de/messages.json b/lang/de/messages.json
index eddc564a..13b38c59 100644
--- a/lang/de/messages.json
+++ b/lang/de/messages.json
@@ -7,6 +7,7 @@
"config-invalid": "Konfiguration mit ID {{0}} existiert nicht",
"db-update-done": "Datenbank wurde aktualisiert",
"debug-mode": "Der Debug-Modus ist aktiv!",
+ "delete-images": "L\u00f6schung: {{0}}",
"deleted-tag": "Tag wurde entfernt",
"empty-archive": "Das Archiv enth\u00e4lt keine Dateien oder Verzeichnisse",
"empty-field": "Ein Feld wurde nicht ausgef\u00fcllt",
diff --git a/lang/de/templates/dozmod/images-delete.json b/lang/de/templates/dozmod/images-delete.json
new file mode 100644
index 00000000..8c54e4d1
--- /dev/null
+++ b/lang/de/templates/dozmod/images-delete.json
@@ -0,0 +1,12 @@
+{
+ "lang_delButton": "Gew\u00e4hlte Images endg\u00fcltig l\u00f6schen",
+ "lang_delete": "L\u00f6schen",
+ "lang_description": "Diese Liste zeigt Images, die entweder abgelaufen sind, oder deren Datei besch\u00e4digt, verschoben oder gel\u00f6scht wurde. Diese Images sind zur Zeit im Lehrpool nicht verf\u00fcgbar, ihre endg\u00fcltige L\u00f6schung muss aber manuell best\u00e4tigt werden, um gr\u00f6\u00dfere Katastrophen durch Softwarefehler, verstellte Systemuhren etc. zu vermeiden.",
+ "lang_hasNewer": "Neuere Version existiert",
+ "lang_heading": "Zu l\u00f6schende Image-Versionen",
+ "lang_image": "VM",
+ "lang_owner": "Besitzer",
+ "lang_size": "Gr\u00f6\u00dfe",
+ "lang_subHeading": "Images, die abgelaufen oder besch\u00e4digt sind",
+ "lang_version": "Version vom"
+} \ No newline at end of file
diff --git a/lang/de/templates/dozmod/mailconfig.json b/lang/de/templates/dozmod/mailconfig.json
index dde03c55..4509c3c7 100644
--- a/lang/de/templates/dozmod/mailconfig.json
+++ b/lang/de/templates/dozmod/mailconfig.json
@@ -3,6 +3,7 @@
"lang_host": "Host",
"lang_mailConfig": "SMTP-Konfiguration zum Versenden von Mails",
"lang_mailConfigHeadline": "EMail-Konfiguration",
+ "lang_mailDescription": "F\u00fcllen Sie die folgenden Felder aus, wenn sie m\u00f6chten, dass Dozenten Benachrichtigungen per Mail bekommen, falls eine von ihnen genutzte oder erstellte VM oder Veranstaltung abl\u00e4uft. Um diese Funktion zu deaktivieren, lassen Sie eines der mit (*) gekennzeichneten Felder leer. Wenn das hier angegebene E-Mail-Konto nur zum Versenden von Mails genutzt wird, sollten Sie einen Auto-Responder einrichten f\u00fcr den Fall, dass ein Dozent auf eine der automatisch generierten Mails antwortet (bzw. eine explizit angegebene Reply-To Adresse ignoriert).",
"lang_password": "Passwort",
"lang_port": "Port",
"lang_replyTo": "Reply-To Adresse (z.B. Helpdesk)",
diff --git a/lang/de/templates/dozmod/userlist.json b/lang/de/templates/dozmod/userlist.json
index 5c9a0f5f..e9e33cc2 100644
--- a/lang/de/templates/dozmod/userlist.json
+++ b/lang/de/templates/dozmod/userlist.json
@@ -7,5 +7,6 @@
"lang_superUser": "Ist SuperUser (darf alle Veranstaltungen und VMs bearbeiten\/l\u00f6schen)",
"lang_user": "Benutzername",
"lang_userList": "Benutzerliste",
+ "lang_userListDescription": "Hier k\u00f6nnen Sie individuelle Nutzer zu \"Super-Usern\" machen. Diese haben im Dozentenmodul auf alle Veranstaltungen und VMs Vollzugriff, unabh\u00e4ngig von den gesetzten Berechtigungen. Au\u00dferdem k\u00f6nnen Sie hier Benutzer vom Zugriff mittels des Dozentenmoduls ausschlie\u00dfen.",
"lang_userListHeader": "Dem Satelliten bekannte Benutzer"
} \ No newline at end of file
diff --git a/lang/en/messages.json b/lang/en/messages.json
index a18d2287..bd8ffb18 100644
--- a/lang/en/messages.json
+++ b/lang/en/messages.json
@@ -7,6 +7,7 @@
"config-invalid": "Configuration with id {{0}} does not exist",
"db-update-done": "Database successfully updated",
"debug-mode": "The debug mode is active!",
+ "delete-images": "Delete: {{0}}",
"deleted-tag": "Tag was successfully removed",
"empty-archive": "The archive contains no files or directories",
"empty-field": "A field was not filled",
diff --git a/lang/en/templates/dozmod/images-delete.json b/lang/en/templates/dozmod/images-delete.json
new file mode 100644
index 00000000..fcc8c7e7
--- /dev/null
+++ b/lang/en/templates/dozmod/images-delete.json
@@ -0,0 +1,12 @@
+{
+ "lang_delButton": "Permanently delete selected images",
+ "lang_delete": "Delete",
+ "lang_description": "This list shows images that reached their expire date, or where the image file in the file system is damaged or missing. You need to manually confirm the deletion of these files for safety reasons (software bugs, wrong system time, etc.).",
+ "lang_hasNewer": "Newer version exists",
+ "lang_heading": "Images marked for deletion",
+ "lang_image": "VM",
+ "lang_owner": "Owner",
+ "lang_size": "Size",
+ "lang_subHeading": "Expired or damaged images",
+ "lang_version": "Version timestamp"
+} \ No newline at end of file
diff --git a/lang/en/templates/dozmod/mailconfig.json b/lang/en/templates/dozmod/mailconfig.json
index 7628615e..0c0dcd7f 100644
--- a/lang/en/templates/dozmod/mailconfig.json
+++ b/lang/en/templates/dozmod/mailconfig.json
@@ -3,6 +3,7 @@
"lang_host": "Host",
"lang_mailConfig": "SMTP configuration for sending mails",
"lang_mailConfigHeadline": "email configuration",
+ "lang_mailDescription": "Fill in the following fields if you want to notify tutors\/professors\/lecturers about expiring VMs and lectures. If you leave one of the required fields blank, the feature will be disabled.",
"lang_password": "Password",
"lang_port": "Port",
"lang_replyTo": "Reply-To address",
diff --git a/lang/en/templates/dozmod/userlist.json b/lang/en/templates/dozmod/userlist.json
index d6eca1c1..615f1b14 100644
--- a/lang/en/templates/dozmod/userlist.json
+++ b/lang/en/templates/dozmod/userlist.json
@@ -7,5 +7,6 @@
"lang_superUser": "Is super user (can edit\/delete all lectures and VMs)",
"lang_user": "User name",
"lang_userList": "User list",
+ "lang_userListDescription": "Here you can promote \"super users\", which will have all permissions in the \"Dozenzenmodul\". You can also ban users from accessing this server via the \"Dozentenmodul\".",
"lang_userListHeader": "Users known to this satellite"
} \ No newline at end of file
diff --git a/lang/pt/templates/dozmod/images-delete.json b/lang/pt/templates/dozmod/images-delete.json
new file mode 100644
index 00000000..c44dc44f
--- /dev/null
+++ b/lang/pt/templates/dozmod/images-delete.json
@@ -0,0 +1,3 @@
+[
+
+] \ No newline at end of file
diff --git a/modules/dozmod.inc.php b/modules/dozmod.inc.php
index cec1c114..35edb22c 100644
--- a/modules/dozmod.inc.php
+++ b/modules/dozmod.inc.php
@@ -17,10 +17,18 @@ class Page_DozMod extends Page
if ($action === 'mail') {
$this->mailHandler();
}
+ if ($action === 'delimages') {
+ $result = $this->handleDeleteImages();
+ if (!empty($result)) {
+ Message::addInfo('delete-images', $result);
+ }
+ Util::redirect('?do=DozMod');
+ }
}
protected function doRender()
{
+ $this->listDeletePendingImages();
// Mail config
$conf = Database::queryFirst('SELECT value FROM sat.configuration WHERE parameter = :param', array('param' => 'mailconfig'));
if ($conf != null) {
@@ -35,6 +43,38 @@ class Page_DozMod extends Page
$this->listOrganizations();
}
+ private function listDeletePendingImages()
+ {
+ $res = Database::simpleQuery("SELECT b.displayname,"
+ . " own.firstname, own.lastname, own.email,"
+ . " v.imageversionid, v.createtime, v.filesize, v.deletestate,"
+ . " lat.expiretime AS latexptime, lat.deletestate AS latdelstate"
+ . " FROM sat.imageversion v"
+ . " INNER JOIN sat.imagebase b ON (b.imagebaseid = v.imagebaseid)"
+ . " INNER JOIN sat.user own ON (b.ownerid = own.userid)"
+ . " LEFT JOIN sat.imageversion lat ON (b.latestversionid = lat.imageversionid)"
+ . " WHERE v.deletestate <> 'KEEP'"
+ . " ORDER BY b.displayname ASC, v.createtime ASC");
+ $NOW = time();
+ $rows = array();
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if ($row['latexptime'] > $NOW && $row['latdelstate'] === 'KEEP') {
+ $row['hasNewerClass'] = 'glyphicon-ok green';
+ } else {
+ $row['hasNewerClass'] = 'glyphicon-remove red';
+ }
+ if ($row['deletestate'] === 'DO_DELETE') {
+ $row['name_extra_class'] = 'slx-strike';
+ }
+ $row['version'] = date('d.m.Y H:i:s', $row['createtime']);
+ $row['filesize'] = Util::readableFileSize($row['filesize']);
+ $rows[] = $row;
+ }
+ if (empty($rows))
+ return;
+ Render::addTemplate('dozmod/images-delete', array('images' => $rows));
+ }
+
private function cleanMailArray()
{
$keys = array('host', 'port', 'ssl', 'senderAddress', 'replyTo', 'username', 'password', 'serverName');
@@ -61,7 +101,31 @@ class Page_DozMod extends Page
$this->setUserOption($action);
} elseif ($action === 'setorglogin') {
$this->setOrgOption($action);
+ } elseif ($action === 'delimages') {
+ die($this->handleDeleteImages());
+ }
+ }
+
+ private function handleDeleteImages()
+ {
+ $images = Request::post('images', false);
+ if (is_array($images)) {
+ foreach ($images as $image => $val) {
+ if (strtolower($val) !== 'on')
+ continue;
+ Database::exec("UPDATE sat.imageversion SET deletestate = 'DO_DELETE'"
+ . " WHERE deletestate = 'SHOULD_DELETE' AND imageversionid = :imageversionid", array(
+ 'imageversionid' => $image
+ ));
+ }
+ if (!empty($images)) {
+ $ret = Download::asStringPost('http://127.0.0.1:9080/do/delete-images', false, 2, $code);
+ if ($code == 999) {
+ $ret .= "\nConnection to DMSD failed.";
+ }
+ }
}
+ return false;
}
private function handleTestMail()
@@ -96,8 +160,8 @@ class Page_DozMod extends Page
'value' => $data
));
Message::addSuccess('mail-config-saved');
- Util::redirect('?do=DozMod');
}
+ Util::redirect('?do=DozMod');
}
private function listUsers()
@@ -150,7 +214,7 @@ class Page_DozMod extends Page
} else {
die('Unknown');
}
- $user = (string)Request::post('userid', '?');
+ $user = (string) Request::post('userid', '?');
$ret = Database::exec("UPDATE sat.user SET $field = :onoff WHERE userid = :userid", array(
'userid' => $user,
'onoff' => $val
@@ -174,7 +238,7 @@ class Page_DozMod extends Page
die('Unknown');
}
$ret = Database::exec("UPDATE sat.organization SET $field = :onoff WHERE organizationid = :organizationid", array(
- 'organizationid' => (string)Request::post('organizationid', ''),
+ 'organizationid' => (string) Request::post('organizationid', ''),
'onoff' => $val
));
if ($ret === false)
diff --git a/style/default.css b/style/default.css
index 901da5e9..7e12f122 100644
--- a/style/default.css
+++ b/style/default.css
@@ -178,4 +178,8 @@ body {
.slx-pointer {
cursor: pointer;
-} \ No newline at end of file
+}
+
+.slx-strike {
+ text-decoration: line-through;
+}
diff --git a/templates/dozmod/images-delete.html b/templates/dozmod/images-delete.html
new file mode 100644
index 00000000..c4cbfd34
--- /dev/null
+++ b/templates/dozmod/images-delete.html
@@ -0,0 +1,57 @@
+<h2>{{lang_heading}}</h2>
+
+<div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_subHeading}}
+ </div>
+ <div class="panel-body">
+ <p>{{lang_description}}</p>
+ <div class="table-responsive">
+ <form id="delform" method="post" action="?do=DozMod" onsubmit="return slxPostdel()">
+ <input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="action" value="delimages">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>{{lang_image}}</th>
+ <th>{{lang_version}}</th>
+ <th>{{lang_owner}}</th>
+ <th><span class="glyphicon glyphicon-upload" title="{{lang_hasNewer}}"></th>
+ <th>{{lang_size}}</th>
+ <th><span class="glyphicon glyphicon-trash" title="{{lang_delete}}"></span></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#images}}
+ <tr>
+ <td class="text-left slx-nowrap {{name_extra_class}}">{{displayname}}<br><span class="small">{{imageversionid}}</span></td>
+ <td class="text-left slx-nowrap">{{version}}</td>
+ <td class="text-left slx-nowrap"><a href="mailto:{{email}}">{{lastname}}, {{firstname}}</a></td>
+ <td class="text-left slx-nowrap"><span class="glyphicon {{hasNewerClass}}"></span></td>
+ <td class="text-right slx-nowrap">{{filesize}}</td>
+ <td><input name="images[{{imageversionid}}]" type="checkbox" checked="checked"></td>
+ </tr>
+ {{/images}}
+ </tbody>
+ </table>
+ <button id="delbtn" class="btn btn-danger" type="submit" name="button" value="save">{{lang_delButton}}</button>
+ </form>
+ <pre style="display:none" id="deloutput"></pre>
+ </div>
+ </div>
+</div>
+
+<script type="text/javascript"><!--
+
+function slxPostdel() {
+ var f = $('#delform');
+ $('#delbtn').prop('disabled', true);
+ $.post('?do=DozMod', f.serialize()).done(function (data) {
+ $('#deloutput').text(data).css('display', '');
+ }).fail(function () {
+ $('#deloutput').text('ERROR').css('display', '');
+ });
+ return false;
+}
+
+--> </script> \ No newline at end of file
diff --git a/templates/dozmod/mailconfig.html b/templates/dozmod/mailconfig.html
index 58d45a0f..5f38b50b 100644
--- a/templates/dozmod/mailconfig.html
+++ b/templates/dozmod/mailconfig.html
@@ -5,6 +5,9 @@
{{lang_mailConfig}}
</div>
<div class="panel-body">
+ <p>{{lang_mailDescription}}</p>
+ <p>[BETA] Diese Funktionalität ist neu. Wir bitten um Nachsicht, falls es Situationen gibt, in denen zu viele
+ oder zu wenige Nachrichten verschickt werden.</p>
<form action="?do=DozMod" method="post" id="mailconf">
<div class="input-group">
<label class="input-group-addon slx-ga2" for="host-id">{{lang_host}} *</label>
diff --git a/templates/dozmod/userlist.html b/templates/dozmod/userlist.html
index 7fe52acc..a76eae5e 100644
--- a/templates/dozmod/userlist.html
+++ b/templates/dozmod/userlist.html
@@ -5,6 +5,7 @@
{{lang_userListHeader}}
</div>
<div class="panel-body">
+ <p>{{lang_userListDescription}}</p>
<div class="table-responsive">
<table class="table table-stripped table-condensed">
<thead>