From 3d86ea325a17f558fe60ba12edf090745ffdd655 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Tue, 26 Jul 2016 14:47:53 +0200 Subject: dozmod runtimeconfig. --- .../dozmod/lang/de/template-tags.json | 15 +++ modules-available/dozmod/page.inc.php | 80 ++++++++++++-- modules-available/dozmod/style.css | 75 +++++++++++++ .../dozmod/templates/runtimeconfig.html | 118 +++++++++++++++++++++ 4 files changed, 282 insertions(+), 6 deletions(-) create mode 100644 modules-available/dozmod/style.css create mode 100644 modules-available/dozmod/templates/runtimeconfig.html diff --git a/modules-available/dozmod/lang/de/template-tags.json b/modules-available/dozmod/lang/de/template-tags.json index b70d6784..79d918f2 100644 --- a/modules-available/dozmod/lang/de/template-tags.json +++ b/modules-available/dozmod/lang/de/template-tags.json @@ -1,8 +1,15 @@ { "lang_asteriskRequired": "Felder mit (*) sind erforderlich", "lang_canLogin": "Nutzer dieser Einrichtung k\u00f6nnen sich am Satelliten anmelden", + "lang_defaultImagePermissionAdmin": "Administration", + "lang_defaultImagePermissionDownload": "Download", + "lang_defaultImagePermissionEdit": "Bearbeiten", + "lang_defaultImagePermissionLink": "Verkn\u00fcpfen", + "lang_defaultImagePermissions": "Standard-Berechtigungen f\u00fcr Images", + "lang_defaultLecturePermissions": "Standard-Berechtigungen f\u00fcr Vorlesungen", "lang_delButton": "Gew\u00e4hlte Images endg\u00fcltig 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_descriptionRuntimeConfig": "Blah blah blah", "lang_email": "EMail", "lang_emailNotifications": "EMail-Benachrichtigungen aktiviert", "lang_hasNewer": "Neuere Version existiert", @@ -10,9 +17,14 @@ "lang_host": "Host", "lang_image": "VM", "lang_lastLogin": "Letzte Anmeldung", + "lang_lecturePermissionAdmin": "Administration", + "lang_lecturePermissionEdit": "Bearbeiten", "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_maxImageValidity": "Maximale G\u00fcltigkeit", + "lang_maxLectureVisibility": "Maximale Sichtbarkeit", + "lang_maxTransfers": "Maximale Anzahl an Uploads", "lang_organization": "Einrichtung", "lang_organizationList": "Liste der Einrichtungen", "lang_organizationListHeader": "Nutzungsrechte f\u00fcr den Satelliten festlegen", @@ -20,6 +32,9 @@ "lang_password": "Passwort", "lang_port": "Port", "lang_replyTo": "Reply-To Adresse (z.B. Helpdesk)", + "lang_runtimeConfig": "Laufzeit-Konfiguration", + "lang_runtimeConfigHeadline": "Laufzeit-Konfiguration", + "lang_runtimeConfigLimits": "Beschr\u00e4nkungen", "lang_senderAddress": "Absenderadresse", "lang_senderName": "Absender Anzeigename", "lang_size": "Gr\u00f6\u00dfe", diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index 60c6c24a..669538e5 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -17,6 +17,9 @@ class Page_DozMod extends Page if ($action === 'mail') { $this->mailHandler(); } + if ($action === 'runtime') { + $this->runtimeHandler(); + } if ($action === 'delimages') { $result = $this->handleDeleteImages(); if (!empty($result)) { @@ -30,14 +33,42 @@ class Page_DozMod extends Page { $this->listDeletePendingImages(); // Mail config - $conf = Database::queryFirst('SELECT value FROM sat.configuration WHERE parameter = :param', array('param' => 'mailconfig')); - if ($conf != null) { - $conf = @json_decode($conf['value'], true); - if (is_array($conf)) { - $conf['set_' . $conf['ssl']] = 'selected="selected"'; + $mailConf = Database::queryFirst('SELECT value FROM sat.configuration WHERE parameter = :param', array('param' => 'mailconfig')); + if ($mailConf != null) { + $mailConf = @json_decode($mailConf['value'], true); + if (is_array($mailConf)) { + $mailConf['set_' . $mailConf['ssl']] = 'selected="selected"'; } } - Render::addTemplate('mailconfig', $conf); + Render::addTemplate('mailconfig', $mailConf); + // Runtime config + $runtimeConf = Database::queryFirst('SELECT value FROM sat.configuration WHERE parameter = :param', array('param' => 'runtimelimits')); + if ($runtimeConf != null) { + $runtimeConf = json_decode($runtimeConf['value'], true); + + /* convert some value to corresponding "selected" texts */ + if ($runtimeConf['defaultLecturePermissions']['edit']) { + $runtimeConf['defaultLecturePermissions']['edit'] = 'checked="checked"'; + } + if ($runtimeConf['defaultLecturePermissions']['admin']) { + $runtimeConf['defaultLecturePermissions']['admin'] = 'checked="checked"'; + } + if ($runtimeConf['defaultImagePermissions']['edit']) { + $runtimeConf['defaultImagePermissions']['edit'] = 'checked="checked"'; + } + if ($runtimeConf['defaultImagePermissions']['admin']) { + $runtimeConf['defaultImagePermissions']['admin'] = 'checked="checked"'; + } + if ($runtimeConf['defaultImagePermissions']['link']) { + $runtimeConf['defaultImagePermissions']['link'] = 'checked="checked"'; + } + if ($runtimeConf['defaultImagePermissions']['download']) { + $runtimeConf['defaultImagePermissions']['download'] = 'checked="checked"'; + } + + } + Render::addTemplate('runtimeconfig', $runtimeConf); + // User list for making people admin $this->listUsers(); $this->listOrganizations(); @@ -171,6 +202,43 @@ class Page_DozMod extends Page Util::redirect('?do=DozMod'); } + private function runtimeHandler() + { + // Check action + $do = Request::post('button'); + if ($do === 'save') { + $data = []; + $data['defaultLecturePermissions'] = Request::post('defaultLecturePermissions', NULL, "array"); + $data['defaultImagePermissions'] = Request::post('defaultImagePermissions', NULL, "array"); + + foreach(['maxImageValidityDays', 'maxLectureValidityDays', 'maxTransfers'] as $field) { + $value = Request::post($field); + $data[$field] = $value; + } + + /* ensure types */ + settype($data['defaultLecturePermissions']['edit'], 'boolean'); + settype($data['defaultLecturePermissions']['admin'], 'boolean'); + settype($data['defaultImagePermissions']['edit'], 'boolean'); + settype($data['defaultImagePermissions']['admin'], 'boolean'); + settype($data['defaultImagePermissions']['link'], 'boolean'); + settype($data['defaultImagePermissions']['download'], 'boolean'); + settype($data['maxImageValidityDays'], 'int'); + settype($data['maxLectureValidityDays'], 'int'); + settype($data['maxTransfers'], 'int'); + + $data = json_encode($data); + Database::exec('INSERT INTO sat.configuration (parameter, value)' + . ' VALUES (:param, :value)' + . ' ON DUPLICATE KEY UPDATE value = VALUES(value)', array( + 'param' => 'runtimelimits', + 'value' => $data + )); + Message::addSuccess('runtimelimits-config-saved'); + } + Util::redirect('?do=DozMod'); + } + private function listUsers() { $res = Database::simpleQuery('SELECT userid, firstname, lastname, email, lastlogin, user.canlogin, issuperuser, emailnotifications,' diff --git a/modules-available/dozmod/style.css b/modules-available/dozmod/style.css new file mode 100644 index 00000000..c6975d3e --- /dev/null +++ b/modules-available/dozmod/style.css @@ -0,0 +1,75 @@ + + +input[type=checkbox] { + border: 2px solid green !important; +} + +/* this is based on https://github.com/flatlogic/awesome-bootstrap-checkbox */ + +.checkbox { + padding-left: 20px; +} +.checkbox label { + display: inline-block; + vertical-align: middle; + position: relative; + padding-left: 5px; +} +.checkbox label::before { + content: ""; + display: inline-block; + position: absolute; + width: 17px; + height: 17px; + left: 0; + margin-left: -20px; + border: 1px solid #cccccc; + border-radius: 3px; + background-color: #fff; + -webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out; + -o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out; + transition: border 0.15s ease-in-out, color 0.15s ease-in-out; +} +.checkbox label::after { + display: inline-block; + position: absolute; + width: 16px; + height: 16px; + left: 0; + top: 0; + margin-left: -20px; + padding-left: 3px; + padding-top: 1px; + font-size: 11px; + color: #555555; +} +.checkbox input[type="checkbox"], +.checkbox input[type="radio"] { + opacity: 0; + z-index: 1; +} + + +.checkbox input[type="checkbox"]:focus + label::before, +.checkbox input[type="radio"]:focus + label::before { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} +.checkbox input[type="checkbox"]:checked + label::after, +.checkbox input[type="radio"]:checked + label::after { + font-family: "FontAwesome"; + content: "\f00c"; +} + + +input[type="checkbox"].styled:checked + label:after { + font-family: 'FontAwesome'; + content: "\f00c"; +} +input[type="checkbox"] .styled:checked + label::before { + color: #fff; +} +input[type="checkbox"] .styled:checked + label::after { + color: #fff; +} diff --git a/modules-available/dozmod/templates/runtimeconfig.html b/modules-available/dozmod/templates/runtimeconfig.html new file mode 100644 index 00000000..06de8d8f --- /dev/null +++ b/modules-available/dozmod/templates/runtimeconfig.html @@ -0,0 +1,118 @@ +

{{lang_runtimeConfigHeadline}}

+ +
+
+ {{lang_runtimeConfig}} +
+
+

{{lang_descriptionRuntimeConfig}}

+
+ + + + +
+

{{lang_defaultLecturePermissions}}

+ + + + +
+ + +
+
+ + +
+ +
+ +
+

{{lang_defaultImagePermissions}}

+ + + + + +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ + +
+
+

{{lang_runtimeConfigLimits}}

+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ + + +
+
+
+ + -- cgit v1.2.3-55-g7522