diff --git a/include/simpleplugin/class_attribute.inc b/include/simpleplugin/class_attribute.inc index 0f43741f95971fe61aaf2d006c862a1d6bfc3e17..202114e4f33b7938ae68c673a6ae4957c8ee784e 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());