add new attribute types 'document', 'folder', 'user', 'group'

This commit is contained in:
Uwe Steinmann 2020-08-28 11:45:37 +02:00
parent 619f90b4df
commit 9117f8f64a
3 changed files with 51 additions and 21 deletions

View File

@ -130,7 +130,8 @@ class SeedDMS_Core_Attribute { /* {{{ */
* the value set and later turned into a multi value attribute.
*/
$sep = substr($this->_value, 0, 1);
$vsep = $this->_attrdef->getValueSetSeparator();
if(!($vsep = $this->_attrdef->getValueSetSeparator()))
$vsep = $sep;
if($sep == $vsep)
return(explode($sep, substr($this->_value, 1)));
else
@ -156,38 +157,54 @@ class SeedDMS_Core_Attribute { /* {{{ */
$db = $this->_dms->getDB();
if($this->_attrdef->getMultipleValues()) {
$valuesetstr = $this->_attrdef->getValueSet();
/* Multiple values without a value set is not allowed */
if(!$valuesetstr = $this->_attrdef->getValueSet())
/* No need to have valueset anymore. If none is given, the values are
* expected to be separated by ','
if(!$valuesetstr)
return false;
*/
$valueset = $this->_attrdef->getValueSetAsArray();
if(is_array($values)) {
if($values) {
$error = false;
foreach($values as $v) {
if(!in_array($v, $valueset)) { $error = true; break; }
if($valueset) {
$error = false;
foreach($values as $v) {
if(!in_array($v, $valueset)) { $error = true; break; }
}
if($error)
return false;
$valuesetstr = $this->_attrdef->getValueSet();
$value = $valuesetstr[0].implode($valuesetstr[0], $values);
} else {
$value = ','.implode(',', $values);
}
if($error)
return false;
$valuesetstr = $this->_attrdef->getValueSet();
$value = $valuesetstr[0].implode($valuesetstr[0], $values);
} else {
$value = '';
}
} else {
if($values) {
if($valuesetstr[0] != $values[0])
$values = explode($valuesetstr[0], $values);
else
$values = explode($valuesetstr[0], substr($values, 1));
$error = false;
foreach($values as $v) {
if(!in_array($v, $valueset)) { $error = true; break; }
if($valuesetstr) {
if($valuesetstr[0] != $values[0])
$values = explode($valuesetstr[0], $values);
else
$values = explode($valuesetstr[0], substr($values, 1));
} else {
$values = explode(',', substr($values, 1));
}
if($valueset) {
$error = false;
foreach($values as $v) {
if(!in_array($v, $valueset)) { $error = true; break; }
}
if($error)
return false;
$value = $valuesetstr[0].implode($valuesetstr[0], $values);
} else {
$value = ','.implode(',', $values);
}
if($error)
return false;
$value = $valuesetstr[0].implode($valuesetstr[0], $values);
} else {
$value = $values;
}
@ -395,6 +412,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
const type_email = '6';
const type_date = '7';
/*
* Addtional data types of an attribute representing objects in seeddms
*/
const type_folder = '101';
const type_document = '102';
//const type_documentcontent = '103';
const type_user = '104';
const type_group = '105';
/*
* The object type for which a attribute may be used
*/

View File

@ -238,7 +238,10 @@ class SeedDMS_Core_Object { /* {{{ */
break;
}
if($attrdef->getMultipleValues() && is_array($value)) {
$sep = substr($attrdef->getValueSet(), 0, 1);
if(in_array($attrdef->getType(), array(SeedDMS_Core_AttributeDefinition::type_user, SeedDMS_Core_AttributeDefinition::type_group)))
$sep = ',';
else
$sep = substr($attrdef->getValueSet(), 0, 1);
$value = $sep.implode($sep, $value);
}
if(!isset($this->_attributes[$attrdef->getId()])) {

View File

@ -28,6 +28,7 @@
- clear the save content list and latest content in SeedDMS_Core_Document after
a version has been deleted.
- new method SeedDMS_Core_Document::isLatestVersion()
- add new attribute types 'document', 'folder', 'user', 'group'
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">