Merge branch 'develop' into seeddms-5.1.x

This commit is contained in:
Uwe Steinmann 2016-05-30 19:30:57 +02:00
commit 86d775ff84
5 changed files with 43 additions and 52 deletions

View File

@ -863,8 +863,10 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
$values = explode($attrvalue[0], substr($attrvalue, 1));
else
$values = $attrvalue;
} else {
} elseif($attrvalue) {
$values = array($attrvalue);
} else {
$values = array();
}
$this->_validation_error = 0;

View File

@ -82,17 +82,25 @@ else
foreach($attributes as $attrdefid=>$attribute) {
$attrdef = $dms->getAttributeDefinition($attrdefid);
if($attribute) {
if($attrdef->getRegex()) {
if(!preg_match($attrdef->getRegex(), $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() && $attrdef->getMaxValues() < count($attribute)) {
if(!$attrdef->validate($attribute)) {
switch($attrdef->getValidationError()) {
case 5:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_malformed_email", array("attrname"=>$attrdef->getName(), "value"=>$attribute)));
break;
case 4:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_malformed_url", array("attrname"=>$attrdef->getName(), "value"=>$attribute)));
break;
case 3:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_no_regex_match", array("attrname"=>$attrdef->getName(), "value"=>$attribute, "regex"=>$attrdef->getRegex())));
break;
case 2:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
break;
case 1:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
break;
default:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("error_occured"));
}
}
} elseif($attrdef->getMinValues() > 0) {

View File

@ -65,17 +65,25 @@ if($attributes) {
foreach($attributes as $attrdefid=>$attribute) {
$attrdef = $dms->getAttributeDefinition($attrdefid);
if($attribute) {
if($attrdef->getRegex()) {
if(!preg_match($attrdef->getRegex(), $attribute)) {
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() && $attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
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(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) {

View File

@ -280,31 +280,19 @@ if($attributes) {
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"));
}
}
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() && $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"));
}
} elseif($attrdef->getMinValues() > 0) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
} elseif(isset($oldattributes[$attrdefid])) {
if(!$document->removeAttribute($dms->getAttributeDefinition($attrdefid)))
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
}
foreach($oldattributes as $attrdefid=>$oldattribute) {
if(!isset($attributes[$attrdefid])) {
if(!$document->removeAttribute($dms->getAttributeDefinition($attrdefid)))

View File

@ -249,21 +249,6 @@ if ($_FILES['userfile']['error'] == 0) {
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" => $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() && $attrdef->getMaxValues() < count($attribute)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_max_values", array("attrname"=>$attrdef->getName())));
}
}
*/
} elseif($attrdef->getMinValues() > 0) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName())));
}