mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
fix setting attributes, return quota and disk usage in PROPFIND
This commit is contained in:
parent
2661fae059
commit
4832e14b30
|
@ -59,6 +59,22 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
|||
*/
|
||||
var $user = "";
|
||||
|
||||
/**
|
||||
* Disk space occupied by user
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $diskspace;
|
||||
|
||||
/**
|
||||
* Max disk space occupied by user
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $quota;
|
||||
|
||||
/**
|
||||
* Set to true if original file shall be used instead of document name
|
||||
* This can lead to duplicate file names in a directory because the original
|
||||
|
@ -191,6 +207,8 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
|||
$this->logger->log('check_auth: type='.$type.', user='.$user.' authenticated', PEAR_LOG_INFO);
|
||||
|
||||
$this->user = $controller->getUser();
|
||||
$this->diskspace = $this->user->getUsedDiskSpace();
|
||||
$this->quota = $this->user->getQuota();
|
||||
if(!$this->user) {
|
||||
if($this->logger) {
|
||||
$this->logger->log($controller->getErrorMsg(), PEAR_LOG_NOTICE);
|
||||
|
@ -402,6 +420,9 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
|||
$info["props"][] = $this->mkprop("displayname", $obj->getName());
|
||||
$info["props"][] = $this->mkprop("resourcetype", "collection");
|
||||
$info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
|
||||
$info["props"][] = $this->mkprop("quota-used-bytes", $this->diskspace);
|
||||
if($this->quota)
|
||||
$info["props"][] = $this->mkprop("quota-available-bytes", $this->quota-$this->diskspace);
|
||||
} else {
|
||||
// modification time
|
||||
$info["props"][] = $this->mkprop("getlastmodified",$obj->getLatestContent()->getDate());
|
||||
|
@ -464,13 +485,68 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
|||
if($attributes) {
|
||||
foreach($attributes as $attribute) {
|
||||
$attrdef = $attribute->getAttributeDefinition();
|
||||
$valueset = $attrdef->getValueSetAsArray();
|
||||
if($valueset && $attrdef->getMultipleValues()) {
|
||||
// $fname = 'attr_'.$attrdef->getId();//str_replace(array(' ', '|'), array('', ''), $attrdef->getName());
|
||||
$attrregex = '/[^a-zA-ZÄäÜüÖöß0-9_-]/';
|
||||
$fname = 'attr_'.preg_replace($attrregex, '', $attrdef->getName());
|
||||
$isvalueset = $attrdef->getValueSet();
|
||||
$ismulti = $attrdef->getMultipleValues();
|
||||
$fvalue = null;
|
||||
if($ismulti) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_int:
|
||||
$fvalue = $attribute->getValueAsArray();
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$fvalue = array_map(fn($value): int => strtotime($value), $attribute->getValueAsArray());
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_document:
|
||||
$fvalue = array_map(fn($value): string => $value->getName(), $attribute->getValueAsArray());
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_folder:
|
||||
$fvalue = array_map(fn($value): string => $value->getName(), $attribute->getValueAsArray());
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_user:
|
||||
$fvalue = array_map(fn($value): string => $value->getFullName(), $attribute->getValueAsArray());
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_group:
|
||||
$fvalue = array_map(fn($value): string => $value->getName(), $attribute->getValueAsArray());
|
||||
break;
|
||||
default:
|
||||
$fvalue = $attribute->getValue();
|
||||
}
|
||||
$valuesetstr = $attrdef->getValueSet();
|
||||
$delimiter = substr($valuesetstr, 0, 1);
|
||||
$info["props"][] = $this->mkprop("SeedDMS:", 'attr_'.str_replace(array(' ', '|'), array('', ''), $attrdef->getName()), $delimiter.implode($delimiter, $attribute->getValueAsArray()));
|
||||
} else
|
||||
$info["props"][] = $this->mkprop("SeedDMS:", 'attr_'.str_replace(array(' ','|'), array('', '',''), $attrdef->getName()), $attribute->getValue());
|
||||
$fvalue = $delimiter.implode($delimiter, $fvalue);
|
||||
} else {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_int:
|
||||
$fvalue = (int) $attribute->getValue();
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$fvalue = strtotime($attribute->getValue());
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_document:
|
||||
$fvalue = $attribute->getValue()->getName();
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_folder:
|
||||
$fvalue = $attribute->getValue()->getName();
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_user:
|
||||
$fvalue = $attribute->getValue()->getFullName();
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_group:
|
||||
$fvalue = $attribute->getValue()->getName();
|
||||
break;
|
||||
default:
|
||||
$fvalue = $attribute->getValue();
|
||||
}
|
||||
}
|
||||
if($fvalue) {
|
||||
// if($this->logger) {
|
||||
// $this->logger->log('Adding property '.$fname." = ".$fvalue, PEAR_LOG_INFO);
|
||||
// }
|
||||
$info["props"][] = $this->mkprop("SeedDMS:", $fname, $fvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user