lots of bug fixes

This commit is contained in:
Uwe Steinmann 2016-09-15 14:00:42 +02:00
parent 4ccdcac7df
commit e55047fb58

View File

@ -140,11 +140,11 @@ function dumplog($version, $type, $logs, $indent) { /* {{{ */
if(!empty($a['file'])) { if(!empty($a['file'])) {
$filename = $dms->contentDir . $document->getDir().'r'.(int) $a[$type2.'LogID']; $filename = $dms->contentDir . $document->getDir().'r'.(int) $a[$type2.'LogID'];
if(file_exists($filename)) { if(file_exists($filename)) {
echo $indent." <data length=\"".filesize($filename)."\""; echo $indent." <data length=\"".filesize($filename)."\"";
if(filesize($filename) < $maxsize) { if(filesize($filename) < $maxsize) {
echo ">\n"; echo ">\n";
echo chunk_split(base64_encode(file_get_contents($filename)), 76, "\n"); echo chunk_split(base64_encode(file_get_contents($filename)), 76, "\n");
echo $indent." </data>\n"; echo $indent." </data>\n";
} else { } else {
echo " fileref=\"".$filename."\" />\n"; echo " fileref=\"".$filename."\" />\n";
if($contentdir) { if($contentdir) {
@ -163,6 +163,25 @@ function dumplog($version, $type, $logs, $indent) { /* {{{ */
echo $indent." </".$type."s>\n"; echo $indent." </".$type."s>\n";
} /* }}} */ } /* }}} */
function dumpNotifications($notifications, $indent) { /* {{{ */
if($notifications) {
if($notifications['groups'] || $notifications['users']) {
echo $indent." <notifications>\n";
if($notifications['users']) {
foreach($notifications['users'] as $user) {
echo $indent." <user id=\"".$user->getID()."\" />\n";
}
}
if($notifications['groups']) {
foreach($notifications['groups'] as $group) {
echo $indent." <group id=\"".$group->getID()."\" />\n";
}
}
echo $indent." </notifications>\n";
}
}
} /* }}} */
function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
global $sections, $statistic, $index, $dms, $maxsize, $contentdir; global $sections, $statistic, $index, $dms, $maxsize, $contentdir;
@ -185,11 +204,19 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
echo $indent." <attr type=\"user\" attrdef=\"".$attrdef->getID()."\">".wrapWithCData($attribute->getValue())."</attr>\n"; echo $indent." <attr type=\"user\" attrdef=\"".$attrdef->getID()."\">".wrapWithCData($attribute->getValue())."</attr>\n";
} }
} }
if($folder->inheritsAccess()) { $notifications = $folder->getNotifyList();
echo $indent." <acls type=\"inherited\" />\n"; dumpNotifications($notifications, $indent);
} else {
echo $indent." <acls>\n"; /* getAccessList() returns also inherited access. So first check
* if inheritsAccess is set and don't output any acls in that case.
* There could be acls of the folder, which will be visible once the
* inheritsAccess is turned off. Those entries will be lost in the
* xml output.
*/
if(!$folder->inheritsAccess()) {
$accesslist = $folder->getAccessList(); $accesslist = $folder->getAccessList();
if($accesslist['users'] || $accesslist['groups']) {
echo $indent." <acls>\n";
foreach($accesslist['users'] as $acl) { foreach($accesslist['users'] as $acl) {
echo $indent." <acl type=\"user\""; echo $indent." <acl type=\"user\"";
$user = $acl->getUser(); $user = $acl->getUser();
@ -205,6 +232,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
echo "/>\n"; echo "/>\n";
} }
echo $indent." </acls>\n"; echo $indent." </acls>\n";
}
} }
echo $indent."</folder>\n"; echo $indent."</folder>\n";
$statistic['folders']++; $statistic['folders']++;
@ -252,10 +280,16 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
} }
} }
/* Check if acl is not inherited */ /* getAccessList() returns also inherited access. So first check
* if inheritsAccess is set and don't output any acls in that case.
* There could be acls of the folder, which will be visible once the
* inheritsAccess is turned off. Those entries will be lost in the
* xml output.
*/
if(!$document->inheritsAccess()) { if(!$document->inheritsAccess()) {
echo $indent." <acls>\n";
$accesslist = $document->getAccessList(); $accesslist = $document->getAccessList();
if($accesslist['users'] || $accesslist['groups']) {
echo $indent." <acls>\n";
foreach($accesslist['users'] as $acl) { foreach($accesslist['users'] as $acl) {
echo $indent." <acl type=\"user\""; echo $indent." <acl type=\"user\"";
$user = $acl->getUser(); $user = $acl->getUser();
@ -271,6 +305,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
echo "/>\n"; echo "/>\n";
} }
echo $indent." </acls>\n"; echo $indent." </acls>\n";
}
} }
$cats = $document->getCategories(); $cats = $document->getCategories();
@ -383,7 +418,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
} else { } else {
echo " fileref=\"".$document->getID()."-A-".$file->getID().$file->getFileType()."\" />\n"; echo " fileref=\"".$document->getID()."-A-".$file->getID().$file->getFileType()."\" />\n";
if($contentdir) { if($contentdir) {
copy($dms->contentDir . $version->getPath(), $contentdir.$document->getID()."-A-".$file->getID().$file->getFileType()); copy($dms->contentDir . $file->getPath(), $contentdir.$document->getID()."-A-".$file->getID().$file->getFileType());
} else { } else {
echo "Warning: file content (size=".filesize($dms->contentDir . $file->getPath()).") will be missing from output\n"; echo "Warning: file content (size=".filesize($dms->contentDir . $file->getPath()).") will be missing from output\n";
} }
@ -410,22 +445,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
echo $indent." </links>\n"; echo $indent." </links>\n";
} }
$notifications = $document->getNotifyList(); $notifications = $document->getNotifyList();
if($notifications) { dumpNotifications($notifications, $indent);
if($notifications['groups'] || $notifications['users']) {
echo $indent." <notifications>\n";
if($notifications['users']) {
foreach($notifications['users'] as $user) {
echo $indent." <user id=\"".$user->getID()."\" />\n";
}
}
if($notifications['groups']) {
foreach($notifications['groups'] as $group) {
echo $indent." <group id=\"".$group->getID()."\" />\n";
}
}
echo $indent." </notifications>\n";
}
}
echo $indent."</document>\n"; echo $indent."</document>\n";
$statistic['documents']++; $statistic['documents']++;