mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
6e2133747d
|
@ -1139,18 +1139,21 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
|||
* 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.
|
||||
* the database. $object is set to a folder, document or documentcontent
|
||||
* if the attribute belongs to such an object. This will be null, if a
|
||||
* new object is created.
|
||||
*
|
||||
* @param string|array $attrvalue attribute value
|
||||
* @param object $object set if the current attribute is saved for this object
|
||||
* @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, $new=false) { /* {{{ */
|
||||
function validate($attrvalue, $object=null, $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, $new);
|
||||
$ret = call_user_func($callback[0], $callback[1], $this, $attrvalue, $object, $new);
|
||||
if(is_bool($ret))
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -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, true)) {
|
||||
if(!$attrdef->validate($attribute, $document, true)) {
|
||||
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class SeedDMS_Controller_EditFolder extends SeedDMS_Controller_Common {
|
|||
$attrdef = $dms->getAttributeDefinition($attrdefid);
|
||||
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
|
||||
if($attribute) {
|
||||
if(!$attrdef->validate($attribute)) {
|
||||
if(!$attrdef->validate($attribute, $folder, true)) {
|
||||
$this->errormsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ if($attributes) {
|
|||
foreach($attributes as $attrdefid=>$attribute) {
|
||||
$attrdef = $dms->getAttributeDefinition($attrdefid);
|
||||
if($attribute) {
|
||||
if(!$attrdef->validate($attribute)) {
|
||||
if(!$attrdef->validate($attribute, $version, true)) {
|
||||
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user