check for propper number of attribute values

This commit is contained in:
Uwe Steinmann 2014-11-17 07:03:57 +01:00
parent f4bb51933f
commit 834a8118e6
5 changed files with 49 additions and 1 deletions

View File

@ -75,6 +75,14 @@ foreach($attributes as $attrdefid=>$attribute) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_no_regex_match"));
}
}
if(is_array($attribute)) {
if($attrdef->getMinValues() > count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}
if($attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
}
}
}
@ -90,6 +98,14 @@ foreach($attributes_version as $attrdefid=>$attribute) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_no_regex_match"));
}
}
if(is_array($attribute)) {
if($attrdef->getMinValues() > count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}
if($attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
}
}
}

View File

@ -69,6 +69,14 @@ foreach($attributes as $attrdefid=>$attribute) {
UI::exitError(getMLText("folder_title", array("foldername" => $document->getName())),getMLText("attr_no_regex_match"));
}
}
if(is_array($attribute)) {
if($attrdef->getMinValues() > count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}
if($attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
}
}
}

View File

@ -252,6 +252,14 @@ if($attributes) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_no_regex_match"));
}
}
if(is_array($attribute)) {
if($attrdef->getMinValues() > count($attribute)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}
if($attrdef->getMaxValues() < count($attribute)) {
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"));

View File

@ -160,7 +160,15 @@ if($attributes) {
if($attribute) {
if($attrdef->getRegex()) {
if(!preg_match($attrdef->getRegex(), $attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $document->getName())),getMLText("attr_no_regex_match"));
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_no_regex_match"));
}
}
if(is_array($attribute)) {
if($attrdef->getMinValues() > count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}
if($attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
}
if(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) {

View File

@ -183,6 +183,14 @@ if ($_FILES['userfile']['error'] == 0) {
UI::exitError(getMLText("document_title", array("documentname" => $folder->getName())),getMLText("attr_no_regex_match"));
}
}
if(is_array($attribute)) {
if($attrdef->getMinValues() > count($attribute)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}
if($attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
}
}
}
} else {