new parameter 'new' of SeedDMS_Core_AttributeDefinition::validate()

This commit is contained in:
Uwe Steinmann 2020-12-14 18:16:35 +01:00
parent c4cdf7b92e
commit 55e0204054
2 changed files with 9 additions and 2 deletions

View File

@ -1131,15 +1131,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

@ -26,6 +26,7 @@
<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>
<contents>
<dir baseinstalldir="SeedDMS" name="/">