mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
validate attribute values
This commit is contained in:
parent
c340006089
commit
be990463bd
|
@ -260,6 +260,28 @@ if($attributes) {
|
|||
foreach($attributes as $attrdefid=>$attribute) {
|
||||
$attrdef = $dms->getAttributeDefinition($attrdefid);
|
||||
if($attribute) {
|
||||
if(!$attrdef->validate($attribute)) {
|
||||
switch($attrdef->getValidationError()) {
|
||||
case 5:
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_malformed_email", array("attrname"=>$attrdef->getName(), "value"=>$attribute)));
|
||||
break;
|
||||
case 4:
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_malformed_url", array("attrname"=>$attrdef->getName(), "value"=>$attribute)));
|
||||
break;
|
||||
case 3:
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_no_regex_match", array("attrname"=>$attrdef->getName(), "value"=>$attribute, "regex"=>$attrdef->getRegex())));
|
||||
break;
|
||||
case 2:
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
|
||||
break;
|
||||
case 1:
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
|
||||
break;
|
||||
default:
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
}
|
||||
}
|
||||
/*
|
||||
if($attrdef->getRegex()) {
|
||||
if(!preg_match($attrdef->getRegex(), $attribute)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_no_regex_match"));
|
||||
|
@ -273,6 +295,7 @@ if($attributes) {
|
|||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
|
||||
}
|
||||
}
|
||||
*/
|
||||
if(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) {
|
||||
if(!$document->setAttributeValue($dms->getAttributeDefinition($attrdefid), $attribute))
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user