diff --git a/include/simpleplugin/attributes/class_DateAttribute.inc b/include/simpleplugin/attributes/class_DateAttribute.inc index 63ca51d5d81881467bea697e57f22443a3924852..8796696f63fdf7c3732d88fc7df475f015db2a72 100644 --- a/include/simpleplugin/attributes/class_DateAttribute.inc +++ b/include/simpleplugin/attributes/class_DateAttribute.inc @@ -136,16 +136,27 @@ class DateAttribute extends Attribute try { $dateValue = $this->getDateValue(); if (($this->minDate !== NULL) && ($dateValue < $this->minDate)) { - return sprintf(_('Invalid date in %s, should be newer than: %s'), $this->getLabel(), $this->minDate->format('Y-m-d')); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('%s is older than %s'), $dateValue->format('Y-m-d'), $this->minDate->format('Y-m-d'))) + ); } if (($this->maxDate !== NULL) && ($dateValue > $this->maxDate)) { - return sprintf(_('Invalid date in %s, should be older than: %s'), $this->getLabel(), $this->maxDate->format('Y-m-d')); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('%s is newer than %s'), $dateValue->format('Y-m-d'), $this->maxDate->format('Y-m-d'))) + ); } } catch (Exception $e) { if ($this->isTemplate() && preg_match('/%/', $this->value)) { return ''; } else { - return sprintf(_('Error, incorrect date: %s'), $e->getMessage()); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('Incorrect date: %s'), $e->getMessage())), + 0, + $e + ); } } return ''; diff --git a/include/simpleplugin/attributes/class_SelectAttribute.inc b/include/simpleplugin/attributes/class_SelectAttribute.inc index 3accc9082fec440986b7f2f98eddd0f7b4353af8..4551557cd0ab3886a8cd5557b7883e1c6bd222a9 100644 --- a/include/simpleplugin/attributes/class_SelectAttribute.inc +++ b/include/simpleplugin/attributes/class_SelectAttribute.inc @@ -158,7 +158,10 @@ class SelectAttribute extends Attribute return $error; } else { if (!$this->disabled && !in_array($this->value, $this->choices)) { - return sprintf(_('The value "%s" for field "%s" is not in the list of possible choices'), $this->value, $this->getLabel()); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('"%s" is not in the list of possible choices'), $this->value)) + ); } } } diff --git a/include/simpleplugin/attributes/class_SetAttribute.inc b/include/simpleplugin/attributes/class_SetAttribute.inc index d79d3665436f40e7e168aa18ff914ff56468cb91..d351832525e0260d0da6d77232895c738641028f 100644 --- a/include/simpleplugin/attributes/class_SetAttribute.inc +++ b/include/simpleplugin/attributes/class_SetAttribute.inc @@ -147,7 +147,10 @@ class SetAttribute extends Attribute return $error; } else { if (!is_array($this->value)) { - return sprintf(_('The value for multivaluated field "%s" is not an array'), $this->getLabel()); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(_('Value is not an array')) + ); } foreach ($this->value as $value) { $this->attribute->setValue($value); diff --git a/include/simpleplugin/attributes/class_StringAttribute.inc b/include/simpleplugin/attributes/class_StringAttribute.inc index 857710e300af8fe58a7576f96854e83f3b1da432..74a73ee93939e489fdad6c4e7de4d4f0a6020954 100644 --- a/include/simpleplugin/attributes/class_StringAttribute.inc +++ b/include/simpleplugin/attributes/class_StringAttribute.inc @@ -133,7 +133,10 @@ class StringAttribute extends Attribute function validate () { if (($this->pattern !== '') && !preg_match($this->pattern, $this->value)) { - return msgPool::invalid($this->getLabel(), $this->value, $this->example); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf('"%s"', $this->getValue())) + ); } } diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc index 747f7beccfc9f8a2b363a0e3536cc8a1cc759977..ebf5815a6b0a13a26de1ac02dd4dd4b4723b383c 100644 --- a/include/simpleplugin/class_Attribute.inc +++ b/include/simpleplugin/class_Attribute.inc @@ -586,7 +586,10 @@ class Attribute continue; } - return msgPool::duplicated($this->getLabel(), $attrs['dn']); + return new SimplePluginCheckError( + $this, + htmlescape(msgPool::duplicated($this->getLabel(), $attrs['dn'])) + ); } } } diff --git a/include/simpleplugin/class_helpersAttribute.inc b/include/simpleplugin/class_helpersAttribute.inc index 28829a54cfc133638f86f70c87221235e8389ccf..523e7ed55718babf9c2a370d5535e192d43e2ef3 100644 --- a/include/simpleplugin/class_helpersAttribute.inc +++ b/include/simpleplugin/class_helpersAttribute.inc @@ -30,7 +30,10 @@ class TestValidateAttribute extends StringAttribute { $func = $this->testFunc; if (!tests::$func($this->value)) { - return msgPool::invalid($this->getLabel(), $this->value, $this->example); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf('"%s"', $this->value)) + ); } } } diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc index 1fe769aa5f68adf6830e26545c4fc35ec510d0bc..5ab4a8815f5e1fbd9093d025cb95bcc195b83492 100644 --- a/plugins/admin/departments/class_department.inc +++ b/plugins/admin/departments/class_department.inc @@ -167,7 +167,10 @@ class department extends simplePlugin $namingAttr = static::$namingAttr; if (($namingAttr == 'ou') && tests::is_department_name_reserved($this->$namingAttr)) { - $message[] = msgPool::reserved(_('Name')); + $message[] = new SimplePluginCheckError( + $this, + htmlescape(msgPool::reserved(_('Name'))) + ); } return $message; diff --git a/plugins/admin/groups/class_ogroup.inc b/plugins/admin/groups/class_ogroup.inc index 80afd7bdc6a5922a60d49da1437c9cc63d3503cf..094598b3b9ba68901bcc21e1a644a675c4d048e6 100644 --- a/plugins/admin/groups/class_ogroup.inc +++ b/plugins/admin/groups/class_ogroup.inc @@ -248,7 +248,10 @@ class ogroup extends simplePlugin $message = parent::check(); $this->reload(); if (preg_match('/W/', $this->gosaGroupObjects) && preg_match('/T/', $this->gosaGroupObjects)) { - $message[] = _('Putting both workstations and terminals in the same group is not allowed'); + $message[] = new SimplePluginCheckError( + $this, + htmlescape(_('Putting both workstations and terminals in the same group is not allowed')) + ); } return $message; diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc index c05a5aa03392c59e23a6d9465fcb075c8dd9a263..bbb942bce477113d0f5c7773b7993f6d5d5d18cd 100644 --- a/plugins/config/class_configInLdap.inc +++ b/plugins/config/class_configInLdap.inc @@ -536,10 +536,16 @@ class configInLdap extends simplePlugin { $messages = parent::check(); if (($this->fdPasswordDefaultHash == 'sasl') && ($this->fdSaslRealm == '') && ($this->fdSaslExop == '')) { - $messages[] = _('You need to fill saslRealm or saslExop in the configuration screen in order to use SASL'); + $messages[] = new SimplePluginCheckError( + $this, + htmlescape(_('You need to fill saslRealm or saslExop in the configuration screen in order to use SASL')) + ); } if ($this->attributesAccess['fdLanguage']->hasChanged() && ($this->fdLanguage != '') && !Language::isAvailable($this->fdLanguage)) { - $messages[] = sprintf(_('It seems the selected language "%s" is not installed on the system. Please install it or select an other one.'), $this->fdLanguage); + $messages[] = new SimplePluginCheckError( + $this, + htmlescape(sprintf(_('It seems the selected language "%s" is not installed on the system. Please install it or select an other one.'), $this->fdLanguage)) + ); } return $messages; } diff --git a/plugins/personal/generic/class_UserPasswordAttribute.inc b/plugins/personal/generic/class_UserPasswordAttribute.inc index bdcb7a957c03fd0dbc68bddc071891238ca3e000..2373a5638402e1101e89e6a01edfbd5e1b47c016 100644 --- a/plugins/personal/generic/class_UserPasswordAttribute.inc +++ b/plugins/personal/generic/class_UserPasswordAttribute.inc @@ -237,7 +237,13 @@ class UserPasswordAttribute extends CompositeAttribute return $error; } if (($this->attributes[1]->getValue() != '') || ($this->attributes[2]->getValue() != '')) { - return user::reportPasswordProblems($this->plugin->dn, $this->attributes[1]->getValue(), $this->attributes[2]->getValue()); + $error = user::reportPasswordProblems($this->plugin->dn, $this->attributes[1]->getValue(), $this->attributes[2]->getValue()); + if ($error !== FALSE) { + return new SimplePluginCheckError( + $this, + htmlescape($error) + ); + } } }