seeddms-code/utils/xmldump.php

845 lines
31 KiB
PHP
Raw Normal View History

2012-01-12 16:46:56 +00:00
<?php
2017-03-06 09:50:51 +00:00
if(isset($_SERVER['SEEDDMS_HOME'])) {
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php");
2017-03-06 09:56:16 +00:00
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassAcl.php");
2017-03-06 09:50:51 +00:00
} else {
require_once("../inc/inc.ClassSettings.php");
2017-03-06 09:56:16 +00:00
require_once("../inc/inc.ClassAcl.php");
2017-03-06 09:50:51 +00:00
}
2012-01-12 16:46:56 +00:00
function usage() { /* {{{ */
echo "Usage:\n";
echo " seeddms-xmldump [-h] [-v] [--config <file>]\n";
2012-01-12 16:46:56 +00:00
echo "\n";
echo "Description:\n";
echo " This program creates an xml dump of the whole or parts of the dms.\n";
echo "\n";
echo "Options:\n";
echo " -h, --help: print usage information and exit.\n";
echo " -v, --version: print version and exit.\n";
echo " --config: set alternative config file.\n";
2012-12-13 21:35:07 +00:00
echo " --folder: set start folder.\n";
echo " --skip-root: do not export the root folder itself.\n";
echo " --sections <sections>: comma seperated list of sections to export.\n";
2015-07-30 09:24:56 +00:00
echo " --maxsize: maximum size of files to be included in output\n";
echo " (defaults to 100000)\n";
echo " --contentdir: directory where all document versions are stored\n";
echo " which are larger than maxsize.\n";
2012-01-12 16:46:56 +00:00
} /* }}} */
function wrapWithCData($text) { /* {{{ */
if(preg_match("/[<>&]/", $text))
return("<![CDATA[".$text."]]>");
else
return $text;
} /* }}} */
$version = "0.0.1";
$shortoptions = "hv";
$longoptions = array('help', 'version', 'skip-root', 'config:', 'folder:', 'maxsize:', 'contentdir:', 'sections:');
2012-01-12 16:46:56 +00:00
if(false === ($options = getopt($shortoptions, $longoptions))) {
usage();
exit(0);
}
/* Print help and exit */
if(isset($options['h']) || isset($options['help'])) {
usage();
exit(0);
}
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."\n";
exit(0);
}
/* Set alternative config file */
if(isset($options['config'])) {
$settings = new Settings($options['config']);
} else {
$settings = new Settings();
}
2013-06-06 12:42:31 +00:00
/* Set maximum size of files included in xml file */
2013-05-28 19:46:46 +00:00
if(isset($options['maxsize'])) {
2015-07-30 09:24:56 +00:00
$maxsize = intval($options['maxsize']);
2013-05-28 19:46:46 +00:00
} else {
$maxsize = 100000;
}
2015-07-30 09:24:56 +00:00
/* Set directory for file largen than maxsize */
if(isset($options['contentdir'])) {
if(file_exists($options['contentdir'])) {
$contentdir = $options['contentdir'];
if(substr($contentdir, -1, 1) != DIRECTORY_SEPARATOR)
$contentdir .= DIRECTORY_SEPARATOR;
} else {
echo "Directory ".$options['contentdir']." does not exists\n";
exit(1);
}
} else {
$contentdir = '';
}
$sections = array();
if(isset($options['sections'])) {
$sections = explode(',', $options['sections']);
}
2013-06-06 12:42:31 +00:00
if(isset($settings->_extraPath))
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
require_once("SeedDMS/Core.php");
2012-12-13 21:35:07 +00:00
if(isset($options['folder'])) {
$folderid = intval($options['folder']);
} else {
$folderid = $settings->_rootFolderID;
}
2015-07-30 09:24:56 +00:00
$skiproot = false;
if(isset($options['skip-root'])) {
$skiproot = true;
}
$statistic = array(
'documents'=>0,
'folders'=>0,
2016-09-15 19:40:19 +00:00
'roles'=>0,
'users'=>0,
'groups'=>0,
'attributedefinitions'=>0,
'keywordcategories'=>0,
'documentcategories'=>0,
2015-08-06 20:21:28 +00:00
'transmittals'=>0,
2016-09-07 14:50:10 +00:00
'workflows'=>0,
'workflowactions'=>0,
'workflowstates'=>0,
);
function dumplog($version, $type, $logs, $indent) { /* {{{ */
global $dms, $contentdir, $maxsize;
$document = $version->getDocument();
switch($type) {
case 'approval':
$type2 = 'approve';
break;
default:
2015-08-09 05:25:26 +00:00
$type2 = $type;
}
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(!empty($a['file'])) {
$filename = $dms->contentDir . $document->getDir().'r'.(int) $a[$type2.'LogID'];
if(file_exists($filename)) {
2016-09-15 12:00:42 +00:00
echo $indent." <data length=\"".filesize($filename)."\"";
if(filesize($filename) < $maxsize) {
echo ">\n";
echo chunk_split(base64_encode(file_get_contents($filename)), 76, "\n");
2016-09-15 12:00:42 +00:00
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";
} /* }}} */
2016-09-15 12:00:42 +00:00
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";
}
}
} /* }}} */
2015-07-30 09:24:56 +00:00
function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
global $sections, $statistic, $index, $dms, $maxsize, $contentdir;
2015-07-30 09:24:56 +00:00
if(!$sections || in_array('folders', $sections)) {
2015-07-30 09:24:56 +00:00
if(!$skipcurrent) {
echo $indent."<folder id=\"".$folder->getId()."\"";
if($parent)
echo " parent=\"".$parent->getID()."\"";
echo ">\n";
echo $indent." <attr name=\"name\">".wrapWithCData($folder->getName())."</attr>\n";
2015-08-04 05:40:17 +00:00
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $folder->getDate())."</attr>\n";
2015-07-30 09:24:56 +00:00
echo $indent." <attr name=\"defaultaccess\">".$folder->getDefaultAccess()."</attr>\n";
echo $indent." <attr name=\"inheritaccess\">".$folder->inheritsAccess()."</attr>\n";
echo $indent." <attr name=\"sequence\">".$folder->getSequence()."</attr>\n";
2012-01-12 16:46:56 +00:00
echo $indent." <attr name=\"comment\">".wrapWithCData($folder->getComment())."</attr>\n";
2015-07-30 09:24:56 +00:00
echo $indent." <attr name=\"owner\">".$folder->getOwner()->getId()."</attr>\n";
if($attributes = $folder->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();
2016-09-13 15:09:00 +00:00
echo $indent." <attr type=\"user\" attrdef=\"".$attrdef->getID()."\">".wrapWithCData($attribute->getValue())."</attr>\n";
2015-07-30 09:24:56 +00:00
}
2012-12-13 21:35:07 +00:00
}
2016-09-15 12:00:42 +00:00
$notifications = $folder->getNotifyList();
dumpNotifications($notifications, $indent);
/* 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()) {
2015-07-30 09:24:56 +00:00
$accesslist = $folder->getAccessList();
2016-09-15 12:00:42 +00:00
if($accesslist['users'] || $accesslist['groups']) {
echo $indent." <acls>\n";
2015-07-30 09:24:56 +00:00
foreach($accesslist['users'] as $acl) {
echo $indent." <acl type=\"user\"";
$user = $acl->getUser();
echo " user=\"".$user->getID()."\"";
echo " mode=\"".$acl->getMode()."\"";
echo "/>\n";
}
foreach($accesslist['groups'] as $acl) {
echo $indent." <acl type=\"group\"";
$group = $acl->getGroup();
echo $indent." group=\"".$group->getID()."\"";
echo $indent." mode=\"".$acl->getMode()."\"";
echo "/>\n";
}
echo $indent." </acls>\n";
2016-09-15 12:00:42 +00:00
}
2012-12-13 21:35:07 +00:00
}
2015-07-30 09:24:56 +00:00
echo $indent."</folder>\n";
$statistic['folders']++;
2015-07-30 09:24:56 +00:00
$parentfolder = $folder;
} else {
$parentfolder = null;
2012-12-13 21:35:07 +00:00
}
2012-01-12 16:46:56 +00:00
$subfolders = $folder->getSubFolders();
if($subfolders) {
foreach($subfolders as $subfolder) {
2015-07-30 09:24:56 +00:00
tree($subfolder, $parentfolder, $indent);
2012-01-12 16:46:56 +00:00
}
}
}
if(!$sections || in_array('documents', $sections)) {
2012-01-12 16:46:56 +00:00
$documents = $folder->getDocuments();
if($documents) {
foreach($documents as $document) {
$owner = $document->getOwner();
2016-09-13 15:09:00 +00:00
/* parent folder is only set if it is no skipped */
echo $indent."<document id=\"".$document->getId()."\"".(!$skipcurrent ? " folder=\"".$folder->getID()."\"" : "");
2012-12-13 21:35:07 +00:00
if($document->isLocked())
echo " locked=\"true\"";
echo ">\n";
echo $indent." <attr name=\"name\">".wrapWithCData($document->getName())."</attr>\n";
2015-08-04 05:40:17 +00:00
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $document->getDate())."</attr>\n";
2012-01-12 16:46:56 +00:00
if($document->getExpires())
2015-08-04 05:40:17 +00:00
echo $indent." <attr name=\"expires\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $document->getExpires())."</attr>\n";
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"owner\">".$owner->getId()."</attr>\n";
2012-01-12 16:46:56 +00:00
if($document->getKeywords())
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"keywords\">".wrapWithCData($document->getKeywords())."</attr>\n";
echo $indent." <attr name=\"defaultaccess\">".$document->getDefaultAccess()."</attr>\n";
echo $indent." <attr name=\"inheritaccess\">".$document->inheritsAccess()."</attr>\n";
echo $indent." <attr name=\"sequence\">".$document->getSequence()."</attr>\n";
2012-01-12 16:46:56 +00:00
if($document->isLocked()) {
$user = $document->getLockingUser();
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"lockedby\">".$user->getId()."</attr>\n";
2012-01-12 16:46:56 +00:00
}
2015-07-30 09:24:56 +00:00
echo $indent." <attr name=\"comment\">".wrapWithCData($document->getComment())."</attr>\n";
2012-12-13 21:35:07 +00:00
if($attributes = $document->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();
2017-03-03 13:59:13 +00:00
echo $indent." <attr type=\"user\" attrdef=\"".$attrdef->getID()."\">".wrapWithCData($attribute->getValue())."</attr>\n";
2012-12-13 21:35:07 +00:00
}
}
2012-01-12 16:46:56 +00:00
2016-09-15 12:00:42 +00:00
/* 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.
*/
2012-01-12 16:46:56 +00:00
if(!$document->inheritsAccess()) {
2015-07-30 09:24:56 +00:00
$accesslist = $document->getAccessList();
2016-09-15 12:00:42 +00:00
if($accesslist['users'] || $accesslist['groups']) {
echo $indent." <acls>\n";
2015-07-30 09:24:56 +00:00
foreach($accesslist['users'] as $acl) {
echo $indent." <acl type=\"user\"";
$user = $acl->getUser();
echo " user=\"".$user->getID()."\"";
echo " mode=\"".$acl->getMode()."\"";
echo "/>\n";
2012-01-12 16:46:56 +00:00
}
2015-07-30 09:24:56 +00:00
foreach($accesslist['groups'] as $acl) {
echo $indent." <acl type=\"group\"";
$group = $acl->getGroup();
echo $indent." group=\"".$group->getID()."\"";
echo $indent." mode=\"".$acl->getMode()."\"";
echo "/>\n";
}
echo $indent." </acls>\n";
2016-09-15 12:00:42 +00:00
}
2012-01-12 16:46:56 +00:00
}
$cats = $document->getCategories();
if($cats) {
2012-12-13 21:35:07 +00:00
echo $indent." <categories>\n";
2012-01-12 16:46:56 +00:00
foreach($cats as $cat) {
2015-07-30 09:24:56 +00:00
echo $indent." <category id=\"".$cat->getId()."\"/>\n";
2012-01-12 16:46:56 +00:00
}
2012-12-13 21:35:07 +00:00
echo $indent." </categories>\n";
2012-01-12 16:46:56 +00:00
}
$versions = $document->getContent();
if($versions) {
2012-12-13 21:35:07 +00:00
echo $indent." <versions>\n";
2012-01-12 16:46:56 +00:00
foreach($versions as $version) {
$owner = $version->getUser();
2015-07-30 09:24:56 +00:00
echo $indent." <version version=\"".$version->getVersion()."\">\n";
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"mimetype\">".$version->getMimeType()."</attr>\n";
2015-08-04 05:40:17 +00:00
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $version->getDate())."</attr>\n";
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"filetype\">".$version->getFileType()."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($version->getComment())."</attr>\n";
echo $indent." <attr name=\"owner\">".$owner->getId()."</attr>\n";
echo $indent." <attr name=\"orgfilename\">".wrapWithCData($version->getOriginalFileName())."</attr>\n";
2017-07-27 19:16:38 +00:00
echo $indent." <attr name=\"revisiondate\" format=\"Y-m-d\">".$version->getRevisionDate()."</attr>\n";
2012-12-13 21:35:07 +00:00
if($attributes = $version->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();
2017-03-03 13:59:13 +00:00
echo $indent." <attr type=\"user\" attrdef=\"".$attrdef->getID()."\">".wrapWithCData($attribute->getValue())."</attr>\n";
2012-12-13 21:35:07 +00:00
}
}
2015-07-31 13:31:16 +00:00
if($statuslog = $version->getStatusLog()) {
echo $indent." <status id=\"".$statuslog[0]['statusID']."\">\n";
foreach($statuslog as $entry) {
echo $indent." <statuslog>\n";
echo $indent." <attr name=\"status\">".$entry['status']."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($entry['comment'])."</attr>\n";
2015-08-04 05:40:17 +00:00
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".$entry['date']."</attr>\n";
2015-07-31 13:31:16 +00:00
echo $indent." <attr name=\"user\">".$entry['userID']."</attr>\n";
echo $indent." </statuslog>\n";
}
echo $indent." </status>\n";
}
$approvalStatus = $version->getApprovalStatus(300);
2012-01-12 16:46:56 +00:00
if($approvalStatus) {
dumplog($version, 'approval', $approvalStatus, $indent);
2012-01-12 16:46:56 +00:00
}
$reviewStatus = $version->getReviewStatus(300);
2012-01-12 16:46:56 +00:00
if($reviewStatus) {
dumplog($version, 'review', $reviewStatus, $indent);
2012-01-12 16:46:56 +00:00
}
$receiptStatus = $version->getReceiptStatus(300);
2015-08-06 04:24:37 +00:00
if($receiptStatus) {
dumplog($version, 'receipt', $receiptStatus, $indent);
2015-08-06 04:24:37 +00:00
}
$revisionStatus = $version->getRevisionStatus(300);
2015-08-06 04:24:37 +00:00
if($revisionStatus) {
dumplog($version, 'revision', $revisionStatus, $indent);
2015-08-06 04:24:37 +00:00
}
2016-09-13 15:09:00 +00:00
$workflow = $version->getWorkflow();
if($workflow) {
$workflowstate = $version->getWorkflowState();
echo $indent." <workflow id=\"".$workflow->getID()."\" state=\"".$workflowstate->getID()."\"></workflow>\n";
}
$wkflogs = $version->getWorkflowLog();
if($wkflogs) {
echo $indent." <workflowlogs>\n";
foreach($wkflogs as $wklog) {
echo $indent." <workflowlog>\n";
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".$wklog->getDate()."</attr>\n";
2016-09-16 09:20:55 +00:00
echo $indent." <attr name=\"workflow\">".$wklog->getWorkflow()->getID()."</attr>\n";
2016-09-13 15:09:00 +00:00
echo $indent." <attr name=\"transition\">".$wklog->getTransition()->getID()."</attr>\n";
$loguser = $wklog->getUser();
echo $indent." <attr name=\"user\">".$loguser->getID()."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($wklog->getComment())."</attr>\n";
echo $indent." </workflowlog>\n";
}
echo $indent." </workflowlogs>\n";
}
2012-01-12 16:46:56 +00:00
if(file_exists($dms->contentDir . $version->getPath())) {
2015-07-30 09:24:56 +00:00
echo $indent." <data length=\"".filesize($dms->contentDir . $version->getPath())."\"";
if(filesize($dms->contentDir . $version->getPath()) < $maxsize) {
echo ">\n";
2012-01-12 16:46:56 +00:00
echo chunk_split(base64_encode(file_get_contents($dms->contentDir . $version->getPath())), 76, "\n");
2015-07-30 09:24:56 +00:00
echo $indent." </data>\n";
} else {
echo " fileref=\"".$document->getID()."-".$version->getVersion().$version->getFileType()."\" />\n";
if($contentdir) {
copy($dms->contentDir . $version->getPath(), $contentdir.$document->getID()."-".$version->getVersion().$version->getFileType());
} else {
echo "Warning: version content (size=".filesize($dms->contentDir . $version->getPath()).") will be missing from output\n";
2015-07-30 09:24:56 +00:00
}
2012-01-12 16:46:56 +00:00
}
2012-12-13 21:35:07 +00:00
} else {
echo $indent." <!-- ".$dms->contentDir . $version->getPath()." not found -->\n";
2016-09-16 15:23:29 +00:00
echo $indent." <data length=\"0\"></data>\n";
2012-01-12 16:46:56 +00:00
}
2012-12-13 21:35:07 +00:00
echo $indent." </version>\n";
2012-01-12 16:46:56 +00:00
}
2012-12-13 21:35:07 +00:00
echo $indent." </versions>\n";
2012-01-12 16:46:56 +00:00
}
$files = $document->getDocumentFiles();
if($files) {
2012-12-13 21:35:07 +00:00
echo $indent." <files>\n";
2012-01-12 16:46:56 +00:00
foreach($files as $file) {
$owner = $file->getUser();
2012-12-13 21:35:07 +00:00
echo $indent." <file id=\"".$file->getId()."\">\n";
echo $indent." <attr name=\"name\">".wrapWithCData($file->getName())."</attr>\n";
echo $indent." <attr name=\"mimetype\">".$file->getMimeType()."</attr>\n";
2015-08-04 05:40:17 +00:00
echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $file->getDate())."</attr>\n";
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"filetype\">".wrapWithCData($file->getFileType())."</attr>\n";
echo $indent." <attr name=\"version\">".$file->getVersion()."</attr>\n";
2017-03-09 09:22:38 +00:00
echo $indent." <attr name=\"public\">".($file->isPublic() ? 1 : 0)."</attr>\n";
2012-12-13 21:35:07 +00:00
echo $indent." <attr name=\"owner\">".$owner->getId()."</attr>\n";
echo $indent." <attr name=\"comment\">".wrapWithCData($file->getComment())."</attr>\n";
echo $indent." <attr name=\"orgfilename\">".wrapWithCData($file->getOriginalFileName())."</attr>\n";
2015-07-30 09:24:56 +00:00
if(file_exists($dms->contentDir . $file->getPath())) {
echo $indent." <data length=\"".filesize($dms->contentDir . $file->getPath())."\"";
if(filesize($dms->contentDir . $file->getPath()) < $maxsize) {
echo ">\n";
echo chunk_split(base64_encode(file_get_contents($dms->contentDir . $file->getPath())), 76, "\n");
echo $indent." </data>\n";
} else {
echo " fileref=\"".$document->getID()."-A-".$file->getID().$file->getFileType()."\" />\n";
if($contentdir) {
2016-09-15 12:00:42 +00:00
copy($dms->contentDir . $file->getPath(), $contentdir.$document->getID()."-A-".$file->getID().$file->getFileType());
} else {
echo "Warning: file content (size=".filesize($dms->contentDir . $file->getPath()).") will be missing from output\n";
2015-07-30 09:24:56 +00:00
}
}
} else {
echo $indent." <!-- ".$dms->contentDir . $version->getID()." not found -->\n";
2013-05-28 19:46:46 +00:00
}
2012-12-13 21:35:07 +00:00
echo $indent." </file>\n";
2012-01-12 16:46:56 +00:00
}
2012-12-13 21:35:07 +00:00
echo $indent." </files>\n";
2012-01-12 16:46:56 +00:00
}
$links = $document->getDocumentLinks();
if($links) {
2012-12-13 21:35:07 +00:00
echo $indent." <links>\n";
2012-01-12 16:46:56 +00:00
foreach($links as $link) {
$owner = $link->getUser();
$target = $link->getTarget();
2012-12-13 21:35:07 +00:00
echo $indent." <link id=\"".$link->getId()."\">\n";
echo $indent." <attr name=\"target\">".$target->getId()."</attr>\n";
echo $indent." <attr name=\"owner\">".$owner->getId()."</attr>\n";
echo $indent." <attr name=\"public\">".$link->isPublic()."</attr>\n";
echo $indent." </link>\n";
2012-01-12 16:46:56 +00:00
}
2012-12-13 21:35:07 +00:00
echo $indent." </links>\n";
2012-01-12 16:46:56 +00:00
}
$notifications = $document->getNotifyList();
2016-09-15 12:00:42 +00:00
dumpNotifications($notifications, $indent);
2012-01-12 16:46:56 +00:00
2012-12-13 21:35:07 +00:00
echo $indent."</document>\n";
$statistic['documents']++;
2012-01-12 16:46:56 +00:00
}
}
}
2012-12-13 21:35:07 +00:00
} /* }}} */
2012-01-12 16:46:56 +00:00
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
2012-01-12 16:46:56 +00:00
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
2015-07-30 09:24:56 +00:00
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
2013-06-06 12:42:31 +00:00
echo "Database update needed.";
exit;
}
2012-01-12 16:46:56 +00:00
$dms->setRootFolderID($settings->_rootFolderID);
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";
2016-09-15 19:40:19 +00:00
/* Dump roles {{{ */
if(!$sections || in_array('roles', $sections)) {
2016-09-22 06:48:09 +00:00
/**
* Show tree of acos
*
*/
function aco_tree($aro=null, $aco=null, $indent='') { /* {{{ */
$tchildren = $aco->getChildren();
$html = '';
if($tchildren) {
foreach($tchildren as $child) {
if($child->getPermission($aro)) {
$html .= $indent."<aco id=\"".$child->getID()."\" alias=\"".$child->getAlias()."\">\n";
$html .= $indent." <attr name=\"permission\">".((int) $child->getPermission($aro))."</attr>\n";
//$html .= $indent." <attr name=\"alias\">".$child->getAlias()."</attr>\n";
//$html .= $indent." <attr name=\"aro\">".($aro ? $aro->getID() : 0)."</attr>\n";
if($thtml = aco_tree($aro, $child, $indent.' ')) {
$html .= $thtml;
}
$html .= $indent."</aco>\n";
} else {
if($thtml = aco_tree($aro, $child, $indent.' ')) {
$html .= $indent."<aco id=\"".$child->getID()."\" alias=\"".$child->getAlias()."\">\n";
//$html .= $indent." <attr name=\"alias\">".$child->getAlias()."</attr>\n";
$html .= $thtml;
$html .= $indent."</aco>\n";
}
}
}
}
return $html;
} /* }}} */
2016-09-15 19:40:19 +00:00
$roles = $dms->getAllRoles();
if($roles) {
echo "<roles>\n";
foreach ($roles as $role) {
echo " <role id=\"".$role->getId()."\">\n";
echo " <attr name=\"name\">".wrapWithCData($role->getName())."</attr>\n";
echo " <attr name=\"role\">".$role->getRole()."</attr>\n";
echo " <attr name=\"noaccess\">".implode(',', $role->getNoAccess())."</attr>\n";
2016-09-22 06:48:09 +00:00
$aro = SeedDMS_Aro::getInstance($role, $dms);
if($acos = SeedDMS_Aco::getRoot($dms)) {
foreach($acos as $aco) {
echo " <aco id=\"".$aco->getID()."\" alias=\"".$aco->getAlias()."\">\n";
if($aco->getPermission($aro)) {
echo " <attr name=\"permission\">".((int) $aco->getPermission($aro))."</attr>\n";
// echo " <attr name=\"alias\">".$aco->getAlias()."</attr>\n";
// echo " <attr name=\"aro\">".($aro ? $aro->getID() : 0)."</attr>\n";
} else {
// echo " <attr name=\"alias\">".$aco->getAlias()."</attr>\n";
}
if($html = aco_tree($aro, $aco, ' '))
echo $html;
echo " </aco>\n";
}
}
2016-09-15 19:40:19 +00:00
echo " </role>\n";
$statistic['roles']++;
}
echo "</roles>\n";
}
}
/* }}} */
/* Dump users {{{ */
if(!$sections || in_array('users', $sections)) {
2012-01-12 16:46:56 +00:00
$users = $dms->getAllUsers();
if($users) {
echo "<users>\n";
foreach ($users as $user) {
echo " <user id=\"".$user->getId()."\">\n";
echo " <attr name=\"login\">".wrapWithCData($user->getLogin())."</attr>\n";
echo " <attr name=\"pwd\">".wrapWithCData($user->getPwd())."</attr>\n";
echo " <attr name=\"email\">".wrapWithCData($user->getEmail())."</attr>\n";
echo " <attr name=\"fullname\">".wrapWithCData($user->getFullName())."</attr>\n";
echo " <attr name=\"comment\">".wrapWithCData($user->getComment())."</attr>\n";
echo " <attr name=\"language\">".$user->getLanguage()."</attr>\n";
echo " <attr name=\"theme\">".$user->getTheme()."</attr>\n";
2016-09-15 19:40:19 +00:00
echo " <attr name=\"role\">".$user->getRole()->getID()."</attr>\n";
2012-01-12 16:46:56 +00:00
echo " <attr name=\"hidden\">".$user->isHidden()."</attr>\n";
2012-12-13 21:35:07 +00:00
echo " <attr name=\"disabled\">".$user->isDisabled()."</attr>\n";
echo " <attr name=\"pwdexpiration\">".$user->getPwdExpiration()."</attr>\n";
2015-08-05 16:20:24 +00:00
echo " <attr name=\"homefolder\">".$user->getHomeFolder()."</attr>\n";
2017-02-21 07:16:22 +00:00
echo " <attr name=\"secret\">".$user->getSecret()."</attr>\n";
2012-01-12 16:46:56 +00:00
if($image = $user->getImage()) {
echo " <image id=\"".$image['id']."\">\n";
2012-12-13 21:35:07 +00:00
echo " <attr name=\"mimetype\">".$image['mimeType']."</attr>\n";
2016-09-13 15:09:00 +00:00
/* image data is already base64 coded */
echo " <data>".$image['image']."</data>\n";
2012-01-12 16:46:56 +00:00
echo " </image>\n";
}
2015-07-30 09:24:56 +00:00
if($mreviewers = $user->getMandatoryReviewers()) {
echo " <mandatory_reviewers>\n";
foreach($mreviewers as $mreviewer) {
if((int) $mreviewer['reviewerUserID'])
echo " <user id=\"".$mreviewer['reviewerUserID']."\"></user>\n";
elseif((int) $mreviewer['reviewerGroupID'])
echo " <group id=\"".$mreviewer['reviewerGroupID']."\"></group>\n";
}
echo " </mandatory_reviewers>\n";
}
if($mapprovers = $user->getMandatoryApprovers()) {
echo " <mandatory_approvers>\n";
foreach($mapprovers as $mapprover) {
if((int) $mapprover['approverUserID'])
echo " <user id=\"".$mapprover['approverUserID']."\"></user>\n";
elseif((int) $mapprover['approverGroupID'])
echo " <group id=\"".$mapprover['approverGroupID']."\"></group>\n";
}
echo " </mandatory_approvers>\n";
}
2015-08-06 15:55:42 +00:00
if($substitutes = $user->getSubstitutes()) {
echo " <substitutes>\n";
foreach($substitutes as $substitute) {
2015-08-06 16:26:47 +00:00
echo " <substitute user=\"".$substitute->getID()."\" />\n";
2015-08-06 15:55:42 +00:00
}
echo " </substitutes>\n";
}
2016-09-07 14:50:10 +00:00
if($mworkflows = $user->getMandatoryWorkflows()) {
echo " <mandatory_workflows>\n";
foreach($mworkflows as $mworkflow) {
echo " <workflow id=\"".$mworkflow->getID()."\"></workflow>\n";
}
echo " </mandatory_workflows>\n";
}
2012-01-12 16:46:56 +00:00
echo " </user>\n";
$statistic['users']++;
2012-01-12 16:46:56 +00:00
}
echo "</users>\n";
}
}
/* }}} */
2012-01-12 16:46:56 +00:00
/* Dump groups {{{ */
if(!$sections || in_array('groups', $sections)) {
2012-01-12 16:46:56 +00:00
$groups = $dms->getAllGroups();
if($groups) {
echo "<groups>\n";
foreach ($groups as $group) {
echo " <group id=\"".$group->getId()."\">\n";
2014-03-21 17:13:14 +00:00
echo " <attr name=\"name\">".wrapWithCData($group->getName())."</attr>\n";
echo " <attr name=\"comment\">".wrapWithCData($group->getComment())."</attr>\n";
2012-01-12 16:46:56 +00:00
$users = $group->getUsers();
if($users) {
echo " <users>\n";
foreach ($users as $user) {
2015-07-30 09:24:56 +00:00
echo " <user user=\"".$user->getId()."\"/>\n";
2012-01-12 16:46:56 +00:00
}
echo " </users>\n";
}
echo " </group>\n";
$statistic['groups']++;
2012-01-12 16:46:56 +00:00
}
echo "</groups>\n";
}
}
/* }}} */
2012-01-12 16:46:56 +00:00
/* Dump keywordcategories {{{ */
if(!$sections || in_array('keywordcategories', $sections)) {
2012-01-12 16:46:56 +00:00
$categories = $dms->getAllKeywordCategories();
if($categories) {
echo "<keywordcategories>\n";
foreach($categories as $category) {
$owner = $category->getOwner();
echo " <keywordcategory id=\"".$category->getId()."\">\n";
echo " <attr name=\"name\">".wrapWithCData($category->getName())."</attr>\n";
echo " <attr name=\"owner\">".$owner->getId()."</attr>\n";
if($keywords = $category->getKeywordLists()) {
echo " <keywords>\n";
foreach($keywords as $keyword) {
echo " <keyword id=\"".$keyword['id']."\">\n";
echo " <attr name=\"name\">".wrapWithCData($keyword['keywords'])."</attr>\n";
echo " </keyword>\n";
}
echo " </keywords>\n";
}
echo " </keywordcategory>\n";
$statistic['keywordcategories']++;
2012-01-12 16:46:56 +00:00
}
echo "</keywordcategories>\n";
}
}
/* }}} */
2012-01-12 16:46:56 +00:00
/* Dump documentcategories {{{ */
if(!$sections || in_array('documentcategories', $sections)) {
2012-01-12 16:46:56 +00:00
$categories = $dms->getDocumentCategories();
if($categories) {
echo "<documentcategories>\n";
foreach($categories as $category) {
echo " <documentcategory id=\"".$category->getId()."\">\n";
echo " <attr name=\"name\">".wrapWithCData($category->getName())."</attr>\n";
echo " </documentcategory>\n";
$statistic['documentcategories']++;
2012-01-12 16:46:56 +00:00
}
echo "</documentcategories>\n";
}
}
/* }}} */
2012-01-12 16:46:56 +00:00
/* Dump attributedefinition {{{ */
if(!$sections || in_array('attributedefinition', $sections)) {
2012-12-13 21:35:07 +00:00
$attrdefs = $dms->getAllAttributeDefinitions();
if($attrdefs) {
echo "<attrіbutedefinitions>\n";
foreach ($attrdefs as $attrdef) {
echo " <attributedefinition id=\"".$attrdef->getID()."\" objtype=\"";
switch($attrdef->getObjType()) {
case SeedDMS_Core_AttributeDefinition::objtype_all:
2012-12-13 21:35:07 +00:00
echo "all";
break;
case SeedDMS_Core_AttributeDefinition::objtype_folder:
2012-12-13 21:35:07 +00:00
echo "folder";
break;
case SeedDMS_Core_AttributeDefinition::objtype_document:
2012-12-13 21:35:07 +00:00
echo "document";
break;
case SeedDMS_Core_AttributeDefinition::objtype_documentcontent:
2012-12-13 21:35:07 +00:00
echo "documentcontent";
break;
}
echo "\">\n";
echo " <attr name=\"name\">".$attrdef->getName()."</attr>\n";
2013-05-28 19:46:46 +00:00
echo " <attr name=\"multiple\">".$attrdef->getMultipleValues()."</attr>\n";
2017-03-03 13:36:59 +00:00
echo " <attr name=\"valueset\">".wrapWithCData($attrdef->getValueSet())."</attr>\n";
2012-12-13 21:35:07 +00:00
echo " <attr name=\"type\">".$attrdef->getType()."</attr>\n";
echo " <attr name=\"minvalues\">".$attrdef->getMinValues()."</attr>\n";
echo " <attr name=\"maxvalues\">".$attrdef->getMaxValues()."</attr>\n";
2015-07-30 09:24:56 +00:00
echo " <attr name=\"regex\">".wrapWithCData($attrdef->getRegex())."</attr>\n";
2012-12-13 21:35:07 +00:00
echo " </attributedefinition>\n";
$statistic['attributedefinitions']++;
2012-12-13 21:35:07 +00:00
}
echo "</attrіbutedefinitions>\n";
}
}
/* }}} */
2012-12-13 21:35:07 +00:00
2016-09-07 14:50:10 +00:00
/* Dump workflows {{{ */
if(!$sections || in_array('workflows', $sections)) {
$workflowstates = $dms->getAllWorkflowStates();
if($workflowstates) {
echo "<workflowstates>\n";
foreach ($workflowstates as $workflowstate) {
echo " <workflowstate id=\"".$workflowstate->getID()."\">\n";
echo " <attr name=\"name\">".$workflowstate->getName()."</attr>\n";
echo " <attr name=\"documentstate\">".$workflowstate->getDocumentStatus()."</attr>\n";
echo " </workflowstate>\n";
$statistic['workflowstates']++;
}
echo "</workflowstates>\n";
}
$workflowactions = $dms->getAllWorkflowActions();
if($workflowactions) {
echo "<workflowactions>\n";
foreach ($workflowactions as $workflowaction) {
echo " <workflowaction id=\"".$workflowaction->getID()."\">\n";
echo " <attr name=\"name\">".$workflowaction->getName()."</attr>\n";
echo " </workflowaction>\n";
$statistic['workflowactions']++;
}
echo "</workflowactions>\n";
}
$workflows = $dms->getAllWorkflows();
if($workflows) {
echo "<workflows>\n";
foreach ($workflows as $workflow) {
echo " <workflow id=\"".$workflow->getID()."\">\n";
echo " <attr name=\"name\">".$workflow->getName()."</attr>\n";
echo " <attr name=\"initstate\">".$workflow->getInitState()->getID()."</attr>\n";
2016-09-15 19:40:19 +00:00
echo " <attr name=\"layoutdata\">".wrapWithCData($workflow->getLayoutData())."</attr>\n";
2016-09-07 14:50:10 +00:00
if($transitions = $workflow->getTransitions()) {
echo " <transitions>\n";
foreach($transitions as $transition) {
echo " <transition id=\"".$transition->getID()."\">\n";
echo " <attr name=\"startstate\">".$transition->getState()->getID()."</attr>\n";
echo " <attr name=\"nextstate\">".$transition->getNextState()->getID()."</attr>\n";
echo " <attr name=\"action\">".$transition->getAction()->getID()."</attr>\n";
echo " <attr name=\"maxtime\">".$transition->getMaxTime()."</attr>\n";
if($transusers = $transition->getUsers()) {
echo " <users>\n";
foreach($transusers as $transuser) {
echo " <user id=\"".$transuser->getUser()->getID()."\"></user>\n";
}
echo " </users>\n";
}
if($transgroups = $transition->getGroups()) {
echo " <groups>\n";
foreach($transgroups as $transgroup) {
echo " <group id=\"".$transgroup->getGroup()->getID()."\" numofusers=\"".$transgroup->getNumOfUsers()."\"></group>\n";
}
echo " </groups>\n";
}
echo " </transition>\n";
}
echo " </transitions>\n";
}
echo " </workflow>\n";
$statistic['workflows']++;
}
echo "</workflows>\n";
}
}
/* }}} */
/* Dump folders and documents {{{ */
2012-12-13 21:35:07 +00:00
$folder = $dms->getFolder($folderid);
if($folder) {
2015-07-30 09:24:56 +00:00
tree($folder, null, '', $skiproot);
2012-12-13 21:35:07 +00:00
}
/* }}} */
2012-01-12 16:46:56 +00:00
/* Dump transmittals {{{ */
2016-09-22 06:48:09 +00:00
if(!$sections || in_array('transmittals', $sections)) {
2015-08-05 20:46:15 +00:00
$transmittals = $dms->getAllTransmittals();
if($transmittals) {
echo "<transmittals>\n";
foreach($transmittals as $transmittal) {
echo " <transmittal id=\"".$transmittal->getID()."\">\n";
echo " <attr name=\"name\">".$transmittal->getName()."</attr>\n";
echo " <attr name=\"owner\">".$transmittal->getUser()->getID()."</attr>\n";
echo " <attr name=\"comment\">".$transmittal->getComment()."</attr>\n";
if($items = $transmittal->getItems()) {
echo " <items>\n";
foreach($items as $item) {
echo " <item id=\"".$item->getID()."\">\n";
$content = $item->getContent();
echo " <attr name=\"document\">".$content->getDocument()->getID()."</attr>\n";
echo " <attr name=\"version\">".$content->getVersion()."</attr>\n";
echo " <attr name=\"date\" format=\"Y-m-d H:i:s\">".$item->getDate()."</attr>\n";
echo " </item>\n";
}
echo " </items>\n";
}
echo " </transmittal>\n";
2015-08-06 20:21:28 +00:00
$statistic['transmittals']++;
2015-08-05 20:46:15 +00:00
}
echo "</transmittals>\n";
}
2016-09-22 06:48:09 +00:00
}
/* }}} */
2015-08-05 20:46:15 +00:00
/* Dump statistics {{{ */
2015-08-06 16:20:43 +00:00
echo "<statistics>\n";
echo " <command><![CDATA[".implode(" ", $argv)."]]></command>\n";
foreach($statistic as $type=>$count)
2015-08-06 16:20:43 +00:00
echo " <".$type.">".$count."</".$type.">\n";
echo "</statistics>\n";
/* }}} */
2012-01-12 16:46:56 +00:00
echo "</dms>\n";
?>