summaryrefslogtreecommitdiffstats
path: root/modules-available/dozmod/inc/pagemailtemplates.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-06-02 16:20:55 +0200
committerSimon Rettberg2017-06-02 16:20:55 +0200
commit437c66fe1482f73c6585c3aa86fe728c9a1ea627 (patch)
tree0b871f6a88ee35e7fe5798175ec8b87499f16144 /modules-available/dozmod/inc/pagemailtemplates.inc.php
parent[main] Make lang_yes and lang_no global (diff)
downloadslx-admin-437c66fe1482f73c6585c3aa86fe728c9a1ea627.tar.gz
slx-admin-437c66fe1482f73c6585c3aa86fe728c9a1ea627.tar.xz
slx-admin-437c66fe1482f73c6585c3aa86fe728c9a1ea627.zip
[dozmod] Show if templates are modified or have their defaults updated
Diffstat (limited to 'modules-available/dozmod/inc/pagemailtemplates.inc.php')
-rw-r--r--modules-available/dozmod/inc/pagemailtemplates.inc.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/modules-available/dozmod/inc/pagemailtemplates.inc.php b/modules-available/dozmod/inc/pagemailtemplates.inc.php
index ef52ec12..8136e1dc 100644
--- a/modules-available/dozmod/inc/pagemailtemplates.inc.php
+++ b/modules-available/dozmod/inc/pagemailtemplates.inc.php
@@ -22,7 +22,7 @@ class Page_mail_templates extends Page
private function enrichHtml() {
/* for each template */
- foreach ($this->templates as $k => $t) {
+ foreach ($this->templates as &$t) {
$lis = "";
$optManVars = "";
$optVars = "";
@@ -36,16 +36,22 @@ class Page_mail_templates extends Page
}
/* also options for hidden inputs */
- $this->templates[$k]['html_availableVariables'] = $lis;
- $this->templates[$k]['html_mandatoryVariables'] = $optManVars;
- $this->templates[$k]['html_optionalVariables'] = $optVars;
+ $t['html_availableVariables'] = $lis;
+ $t['html_mandatoryVariables'] = $optManVars;
+ $t['html_optionalVariables'] = $optVars;
/* also for javascript */
- $this->templates[$k]['list_mandatoryVariables'] =
- implode(',', $this->templates[$k]['mandatory_variables']);
+ $t['list_mandatoryVariables'] =
+ implode(',', $t['mandatory_variables']);
- $this->templates[$k]['list_optionalVariables'] =
- implode(',', $this->templates[$k]['optional_variables']);
+ $t['list_optionalVariables'] =
+ implode(',', $t['optional_variables']);
+
+ settype($t['original'], 'bool');
+ settype($t['edit_version'], 'int');
+ settype($t['version'], 'int');
+ $t['modified'] = !$t['original'];
+ $t['conflict'] = !$t['original'] && $t['edit_version'] < $t['version'];
}
}
@@ -55,12 +61,22 @@ class Page_mail_templates extends Page
Render::addTemplate('templates', ['templates' => $this->templates]);
}
- private function handleSave() {
+ private function forcmp($string)
+ {
+ return trim(str_replace("\r\n", "\n", $string));
+ }
+
+ private function handleSave()
+ {
$data = Request::post('templates');
if (is_array($data)) {
$this->fetchTemplates();
foreach ($this->templates as &$template) {
if (isset($data[$template['name']])) {
+ if ($this->forcmp($template['template']) !== $this->forcmp($data[$template['name']]['template'])) {
+ $template['edit_version'] = $template['version'];
+ }
+ $template['original'] = $this->forcmp($template['original_template']) === $this->forcmp($data[$template['name']]['template']);
$template['template'] = $data[$template['name']]['template'];
}
}