From 259e4bcb0eeb6235f1e7acf35a3a82ee6c4e729f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Thu, 4 Aug 2016 17:34:29 +0200 Subject: [PATCH] Fixes #4945 Some more date fixes for templates --- include/simpleplugin/class_attribute.inc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/simpleplugin/class_attribute.inc b/include/simpleplugin/class_attribute.inc index 0f43741f9..202114e4f 100644 --- a/include/simpleplugin/class_attribute.inc +++ b/include/simpleplugin/class_attribute.inc @@ -1438,7 +1438,7 @@ class DateAttribute extends Attribute { if ($value === "" && !$this->isRequired()) { return $value; - } elseif (is_object($this->plugin) && $this->plugin->is_template && (preg_match('/%/', $value))) { + } elseif (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $value)) { return $value; } else { return $this->ldapToDate($value); @@ -1453,7 +1453,11 @@ class DateAttribute extends Attribute try { return $this->getDateValue()->format('d.m.Y'); } catch (Exception $e) { - return ""; + if (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $this->value)) { + return $this->value; + } else { + return ''; + } } } } @@ -1491,8 +1495,8 @@ class DateAttribute extends Attribute try { $this->setValue($this->getDateValue()); } catch (Exception $e) { - if (is_object($this->plugin) && $this->plugin->is_template) { - return $value; + if (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $this->value)) { + return $this->value; } else { throw $e; } @@ -1513,7 +1517,7 @@ class DateAttribute extends Attribute try { $this->getDateValue(); } catch (Exception $e) { - if (is_object($this->plugin) && $this->plugin->is_template) { + if (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $this->value)) { return; } else { return sprintf(_('Error, incorrect date: %s'), $e->getMessage()); -- GitLab