Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2020-12-14 18:18:40 +01:00
commit f7bedcdbd8
3 changed files with 10 additions and 3 deletions

View File

@ -1136,15 +1136,21 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
* definition.
* If the validation fails the validation error will be set which
* can be requested by SeedDMS_Core_Attribute::getValidationError()
* Set $new to true if the value to be checked isn't saved to the database
* already. It will just be passed to the callback onAttributeValidate where
* it could be used to, e.g. check if a value is unique once it is saved to
* the database.
*
* @param string|array $attrvalue attribute value
* @param boolean $new set to true if the value is new value and not taken from
* an existing attribute
* @return boolean true if validation succeds, otherwise false
*/
function validate($attrvalue) { /* {{{ */
function validate($attrvalue, $new=false) { /* {{{ */
/* Check if 'onAttributeValidate' callback is set */
if(isset($this->_dms->callbacks['onAttributeValidate'])) {
foreach($this->_dms->callbacks['onAttributeValidate'] as $callback) {
$ret = call_user_func($callback[0], $callback[1], $this, $attrvalue);
$ret = call_user_func($callback[0], $callback[1], $this, $attrvalue, $new);
if(is_bool($ret))
return $ret;
}

View File

@ -1856,6 +1856,7 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp()
<notes>
- SeedDMS_Folder_DMS::getAccessList() and getDefaultAccess() do not return fals anymore if the parent does not exists. They just stop inheritance.
- pass attribute value to callback 'onAttributeValidate'
- new paramter 'new' of methode SeedDMЅ_Core_AttributeDefinition::validate()
</notes>
</release>
<release>

View File

@ -120,7 +120,7 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) {
if(!$attrdef->validate($attribute)) {
if(!$attrdef->validate($attribute, true)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false;
}