From 3e54a5b830c9ef9dcd77407b5064de00bd4621fd Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 12 Aug 2016 17:23:07 +0200 Subject: [dozmod] Improve layout, texts etc. --- .../dozmod/inc/pagemailtemplates.inc.php | 72 ++++++++-------- modules-available/dozmod/page.inc.php | 2 + modules-available/dozmod/style.css | 51 ++++++++---- modules-available/dozmod/templates/mailconfig.html | 2 - .../dozmod/templates/runtimeconfig.html | 93 +++++++++++---------- modules-available/dozmod/templates/templates.html | 95 +++++++++++----------- 6 files changed, 167 insertions(+), 148 deletions(-) diff --git a/modules-available/dozmod/inc/pagemailtemplates.inc.php b/modules-available/dozmod/inc/pagemailtemplates.inc.php index fedb13c8..73ce0ade 100644 --- a/modules-available/dozmod/inc/pagemailtemplates.inc.php +++ b/modules-available/dozmod/inc/pagemailtemplates.inc.php @@ -14,12 +14,16 @@ class Page_mail_templates extends Page Util::redirect('?do=Main'); } - $action = Request::get('action', 'show', 'string'); - + $action = Request::post('action', 'show', 'string'); if ($action === 'show') { $this->fetchTemplates(); } elseif ($action === 'save') { $this->handleSave(); + } elseif ($action === 'reset') { + $this->handleReset(); + } else { + Message::addError('main.invalid-action', $action); + Util::redirect('?do=dozmod§ion=templates'); } } @@ -54,32 +58,41 @@ class Page_mail_templates extends Page } protected function doRender() { - //echo '
';
-		//var_dump($this->templates);
-		//echo '
'; - //die(); $this->enrichHtml(); Render::addTemplate('templates', ['templates' => $this->templates]); } private function handleSave() { - $data = []; - $data['templates'] = Request::post('templates'); - $data = $this->cleanTemplateArray($data); - if ($data!= NULL) { - $data = json_encode($data, JSON_PRETTY_PRINT); - //echo '
';
-			//print_r($data);
-			//echo '
'; - //die(); + $data = Request::post('templates'); + if (is_array($data)) { + $this->fetchTemplates(); + foreach ($this->templates as &$template) { + if (isset($data[$template['name']])) { + $template['template'] = $data[$template['name']]['template']; + } + } + unset($template); + $data = json_encode(array('templates' => $this->templates)); Database::exec("UPDATE sat.configuration SET value = :value WHERE parameter = 'templates'", array('value' => $data)); Message::addSuccess('templates-saved'); - Util::redirect('?do=dozmod§ion=templates&action=show'); } else { - die('error while encoding'); + Message::addError('nothing-submitted'); } + Util::redirect('?do=dozmod§ion=templates'); + } + private function handleReset() + { + $result = Download::asStringPost('http://127.0.0.1:9080/do/reset-mail-templates', array(), 10, $code); + if ($code == 999) { + Message::addError('timeout'); + } elseif ($code != 200) { + Message::addError('dozmod-error', $code); + } else { + Message::addSuccess('all-templates-reset', $result); + } + Util::redirect('?do=dozmod§ion=templates'); } private function fetchTemplates() { @@ -87,33 +100,12 @@ class Page_mail_templates extends Page if ($templates != null) { $templates = @json_decode($templates['value'], true); if (is_array($templates)) { + $names = array_map(function ($e) { return $e['name']; }, $templates['templates']); + array_multisort($names, SORT_ASC, $templates['templates']); $this->templates = $templates['templates']; } } } - private function cleanTemplateArray($in) { - $out = []; - foreach ($in['templates'] as $t) { - $tcopy = $t; - $tcopy['mandatory_variables'] = $this->toArray($t['mandatory_variables']); - $tcopy['optional_variables'] = $this->toArray($t['optional_variables']); - $tcopy['description'] = $t['description']; - $tcopy['name'] = $t['name']; - - $out['templates'][] = $tcopy; - } - return $out; - } - - private function toArray($value) { - if (empty($value)) { - return []; - } else if(is_array($value)) { - return $value; - } else { - return array($value); - } - } } diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index 31d4cce2..7e8db7c4 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -234,6 +234,8 @@ class Page_DozMod extends Page 'value' => $data )); Message::addSuccess('mail-config-saved'); + } else { + Message::addError('main.invalid-action', $do); } Util::redirect('?do=DozMod§ion=mailconfig'); } diff --git a/modules-available/dozmod/style.css b/modules-available/dozmod/style.css index c6975d3e..8cc5548d 100644 --- a/modules-available/dozmod/style.css +++ b/modules-available/dozmod/style.css @@ -1,9 +1,3 @@ - - -input[type=checkbox] { - border: 2px solid green !important; -} - /* this is based on https://github.com/flatlogic/awesome-bootstrap-checkbox */ .checkbox { @@ -47,6 +41,7 @@ input[type=checkbox] { .checkbox input[type="radio"] { opacity: 0; z-index: 1; + top: -6px; } @@ -58,18 +53,44 @@ input[type=checkbox] { } .checkbox input[type="checkbox"]:checked + label::after, .checkbox input[type="radio"]:checked + label::after { - font-family: "FontAwesome"; - content: "\f00c"; + font-family: "Glyphicons Halflings"; + content: "\E013"; +} + +.witherror { + border: 1px solid red; +} + +/* +.table-input-group tr:first-child { + background: #EEEEEE url("./style/bg.png"); + border-style: solid none solid solid; + border-radius: 4px 0px 0px 4px; + border-color: #CCCCCC #555555 #CCCCCC #CCCCCC; + border-width: 1px 0px 1px 1px; + color: #555555; } +*/ +.table-input-group { + border-collapse: separate; +} -input[type="checkbox"].styled:checked + label:after { - font-family: 'FontAwesome'; - content: "\f00c"; +.table-input-group tr.input-group { + display: table-row; + width: auto; + border-collapse: separate; } -input[type="checkbox"] .styled:checked + label::before { - color: #fff; + +.table-input-group tr.input-group td.input-group-addon { + text-align: left; + border-collapse: separate; } -input[type="checkbox"] .styled:checked + label::after { - color: #fff; + +.table-input-group tr.input-group input.form-control { + width: auto; +} + +.table-input-group tr.input-group td:last-child input { + border-radius: 0px 4px 4px 0px; } diff --git a/modules-available/dozmod/templates/mailconfig.html b/modules-available/dozmod/templates/mailconfig.html index 56850637..69622796 100644 --- a/modules-available/dozmod/templates/mailconfig.html +++ b/modules-available/dozmod/templates/mailconfig.html @@ -6,8 +6,6 @@

{{lang_mailDescription}}

-

[BETA] Diese Funktionalität ist neu. Wir bitten um Nachsicht, falls es Situationen gibt, in denen zu viele - oder zu wenige Nachrichten verschickt werden.

diff --git a/modules-available/dozmod/templates/runtimeconfig.html b/modules-available/dozmod/templates/runtimeconfig.html index eced5784..011fcac4 100644 --- a/modules-available/dozmod/templates/runtimeconfig.html +++ b/modules-available/dozmod/templates/runtimeconfig.html @@ -5,90 +5,97 @@ {{lang_runtimeConfig}}
-

{{lang_descriptionRuntimeConfig}}

+

{{lang_defaultPermissions}}

+

{{lang_descriptionPermissionConfig}}

-

{{lang_defaultLecturePermissions}}

+ {{lang_defaultLecturePermissions}} - - + + -
- - -
- -
+
+ +
-
-

{{lang_defaultImagePermissions}}

+
+ {{lang_defaultImagePermissions}}
- -
- -
-
- +
- +
- -
-
-

{{lang_runtimeConfigLimits}}

-
- - -
-
- - -
-
- - -
+
+

{{lang_runtimeConfigLimits}}

+

{{lang_descriptionRuntimeLimits}}

+ + + + + + + + + + + + + +
{{lang_maxImageValidity}} + +
{{lang_maxLectureVisibility}} + +
{{lang_maxTransfers}} + +

- +
diff --git a/modules-available/dozmod/templates/templates.html b/modules-available/dozmod/templates/templates.html index e8e3f592..3b2a003f 100644 --- a/modules-available/dozmod/templates/templates.html +++ b/modules-available/dozmod/templates/templates.html @@ -1,15 +1,18 @@ -

Templates

+

{{lang_mailTemplates}}

-
+

{{lang_templatePageDescription}}

+ + +
{{#templates}} -
-
+
+