export files saved added with approval/review

This commit is contained in:
Uwe Steinmann 2015-08-09 06:47:00 +02:00
parent ce756a5939
commit 63f075f969

View File

@ -107,6 +107,56 @@ $statistic = array(
'documentcategories'=>0, 'documentcategories'=>0,
); );
function dumplog($type, $logs, $indent) { /* {{{ */
switch($type) {
case 'approval':
$type2 = 'approve';
break;
default:
$type2 = 'review';
}
echo $indent." <".$type."s>\n";
$curid = 0;
foreach($logs as $a) {
if($a[$type2.'ID'] != $curid) {
if($curid != 0) {
echo $indent." </".$type.">\n";
}
echo $indent." <".$type." id=\"".$a[$type2.'ID']."\">\n";
echo $indent." <attr name=\"type\">".$a['type']."</attr>\n";
echo $indent." <attr name=\"required\">".$a['required']."</attr>\n";
}
echo $indent." <".$type."log id=\"".$a[$type2.'LogID']."\">\n";
echo $indent." <attr name=\"user\">".$a['userID']."</attr>\n";
echo $indent." <attr name=\"status\">".$a['status']."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($a['comment'])."</attr>\n";
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".$a['date']."</attr>\n";
if($a['file']) {
$filename = $dms->contentDir . $document->getDir().'r'.(int) $a[$type2.'LogID'];
if(file_exists($filename)) {
echo $indent." <data length=\"".filesize($filename)."\"";
if(filesize($filesize) < $maxsize) {
echo ">\n";
echo chunk_split(base64_encode(file_get_contents($filename)), 76, "\n");
echo $indent." </data>\n";
} else {
echo " fileref=\"".$filename."\" />\n";
if($contentdir) {
copy($filename, $contentdir.$document->getID()."-R-".$a[$type2.'LogID']);
} else {
echo "Warning: ".$type." log file (size=".filesize($filename).") will be missing from output\n";
}
}
}
}
echo $indent." </".$type."log>\n";
$curid = $a[$type2.'ID'];
}
if($curid != 0)
echo $indent." </".$type.">\n";
echo $indent." </".$type."s>\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;
@ -258,54 +308,10 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
echo $indent." </status>\n"; echo $indent." </status>\n";
} }
if($approvalStatus) { if($approvalStatus) {
echo $indent." <approvals>\n"; dumplog('approval', $approvalStatus, $indent);
$curapprovalid = 0;
foreach($approvalStatus as $a) {
if($a['approveID'] != $curapprovalid) {
if($curapprovalid != 0) {
echo $indent." </approval>\n";
}
echo $indent." <approval id=\"".$a['approveID']."\">\n";
echo $indent." <attr name=\"type\">".$a['type']."</attr>\n";
echo $indent." <attr name=\"required\">".$a['required']."</attr>\n";
}
echo $indent." <approvallog id=\"".$a['approveLogID']."\">\n";
echo $indent." <attr name=\"user\">".$a['userID']."</attr>\n";
echo $indent." <attr name=\"status\">".$a['status']."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($a['comment'])."</attr>\n";
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".$a['date']."</attr>\n";
echo $indent." </approvallog>\n";
// echo $indent." </approval>\n";
$curapprovalid = $a['approveID'];
}
if($curapprovalid != 0)
echo $indent." </approval>\n";
echo $indent." </approvals>\n";
} }
if($reviewStatus) { if($reviewStatus) {
echo $indent." <reviews>\n"; dumplog('review', $reviewStatus, $indent);
$curreviewid = 0;
foreach($reviewStatus as $a) {
if($a['reviewID'] != $curreviewid) {
if($curreviewid != 0) {
echo $indent." </review>\n";
}
echo $indent." <review id=\"".$a['reviewID']."\">\n";
echo $indent." <attr name=\"type\">".$a['type']."</attr>\n";
echo $indent." <attr name=\"required\">".$a['required']."</attr>\n";
}
echo $indent." <reviewlog id=\"".$a['reviewLogID']."\">\n";
echo $indent." <attr name=\"user\">".$a['userID']."</attr>\n";
echo $indent." <attr name=\"status\">".$a['status']."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($a['comment'])."</attr>\n";
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".$a['date']."</attr>\n";
echo $indent." </reviewlog>\n";
// echo $indent." </review>\n";
$curreviewid = $a['reviewID'];
}
if($curreviewid != 0)
echo $indent." </review>\n";
echo $indent." </reviews>\n";
} }
if(file_exists($dms->contentDir . $version->getPath())) { if(file_exists($dms->contentDir . $version->getPath())) {
echo $indent." <data length=\"".filesize($dms->contentDir . $version->getPath())."\""; echo $indent." <data length=\"".filesize($dms->contentDir . $version->getPath())."\"";
@ -415,6 +421,8 @@ $dms->setRootFolderID($settings->_rootFolderID);
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<dms dbversion=\"".implode('.', array_slice($dms->getDBVersion(), 1, 3))."\" date=\"".date('Y-m-d H:i:s')."\">\n"; echo "<dms dbversion=\"".implode('.', array_slice($dms->getDBVersion(), 1, 3))."\" date=\"".date('Y-m-d H:i:s')."\">\n";
/* Dump users {{{ */
if(!$sections || in_array('users', $sections)) { if(!$sections || in_array('users', $sections)) {
$users = $dms->getAllUsers(); $users = $dms->getAllUsers();
if($users) { if($users) {
@ -464,7 +472,9 @@ if($users) {
echo "</users>\n"; echo "</users>\n";
} }
} }
/* }}} */
/* Dump groups {{{ */
if(!$sections || in_array('groups', $sections)) { if(!$sections || in_array('groups', $sections)) {
$groups = $dms->getAllGroups(); $groups = $dms->getAllGroups();
if($groups) { if($groups) {
@ -487,7 +497,9 @@ if($groups) {
echo "</groups>\n"; echo "</groups>\n";
} }
} }
/* }}} */
/* Dump keywordcategories {{{ */
if(!$sections || in_array('keywordcategories', $sections)) { if(!$sections || in_array('keywordcategories', $sections)) {
$categories = $dms->getAllKeywordCategories(); $categories = $dms->getAllKeywordCategories();
if($categories) { if($categories) {
@ -512,7 +524,9 @@ if($categories) {
echo "</keywordcategories>\n"; echo "</keywordcategories>\n";
} }
} }
/* }}} */
/* Dump documentcategories {{{ */
if(!$sections || in_array('documentcategories', $sections)) { if(!$sections || in_array('documentcategories', $sections)) {
$categories = $dms->getDocumentCategories(); $categories = $dms->getDocumentCategories();
if($categories) { if($categories) {
@ -526,7 +540,9 @@ if($categories) {
echo "</documentcategories>\n"; echo "</documentcategories>\n";
} }
} }
/* }}} */
/* Dump attributedefinition {{{ */
if(!$sections || in_array('attributedefinition', $sections)) { if(!$sections || in_array('attributedefinition', $sections)) {
$attrdefs = $dms->getAllAttributeDefinitions(); $attrdefs = $dms->getAllAttributeDefinitions();
if($attrdefs) { if($attrdefs) {
@ -561,16 +577,22 @@ if($attrdefs) {
echo "</attrіbutedefinitions>\n"; echo "</attrіbutedefinitions>\n";
} }
} }
/* }}} */
/* Dump folders and documents {{{ */
$folder = $dms->getFolder($folderid); $folder = $dms->getFolder($folderid);
if($folder) { if($folder) {
tree($folder, null, '', $skiproot); tree($folder, null, '', $skiproot);
} }
/* }}} */
/* Dump statistics {{{ */
echo "<statistics>\n"; echo "<statistics>\n";
echo " <command><![CDATA[".implode(" ", $argv)."]]></command>\n"; echo " <command><![CDATA[".implode(" ", $argv)."]]></command>\n";
foreach($statistic as $type=>$count) foreach($statistic as $type=>$count)
echo " <".$type.">".$count."</".$type.">\n"; echo " <".$type.">".$count."</".$type.">\n";
echo "</statistics>\n"; echo "</statistics>\n";
/* }}} */
echo "</dms>\n"; echo "</dms>\n";
?> ?>