]\n";
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";
} /* }}} */
function wrapWithCData($text) { /* {{{ */
if(preg_match("/[<>&]/", $text))
return("");
else
return $text;
} /* }}} */
$version = "0.0.1";
$shortoptions = "hv";
$longoptions = array('help', 'version', 'config:');
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();
}
function tree($folder, $indent='') {
global $index, $dms;
echo $indent."getId()."\">\n";
echo $indent." ".wrapWithCData($folder->getName())."\n";
echo $indent." ".date('c', $folder->getDate())."\n";
echo $indent." ".$folder->getDefaultAccess()."\n";
echo $indent." ".$folder->inheritsAccess()."\n";
echo $indent." ".$folder->getSequence()."\n";
if($folder->getComment())
echo $indent." ".wrapWithCData($folder->getComment())."\n";
echo $indent." ".$folder->getOwner()->getId()."\n";
$subfolders = $folder->getSubFolders();
if($subfolders) {
echo $indent." \n";
foreach($subfolders as $subfolder) {
tree($subfolder, $indent.' ');
}
echo $indent." \n";
}
$documents = $folder->getDocuments();
if($documents) {
echo $indent." \n";
foreach($documents as $document) {
$owner = $document->getOwner();
echo $indent." getId()."\">\n";
echo $indent." ".wrapWithCData($document->getName())."\n";
echo $indent." ".date('c', $document->getDate())."\n";
if($document->getExpires())
echo $indent." ".date('c', $document->getExpires())."\n";
echo $indent." ".$owner->getId()."\n";
if($document->getKeywords())
echo $indent." ".wrapWithCData($document->getKeywords())."\n";
echo $indent." ".$document->getDefaultAccess()."\n";
echo $indent." ".$document->inheritsAccess()."\n";
echo $indent." ".$document->getSequence()."\n";
if($document->isLocked()) {
$user = $document->getLockingUser();
echo $indent." ".$user->getId()."\n";
}
if($document->getComment())
echo $indent." ".wrapWithCData($document->getComment())."\n";
/* Check if acl is not inherited */
if(!$document->inheritsAccess()) {
$acls = $document->getAccessList();
if($acls['groups'] || $acls['users']) {
echo $indent." \n";
if($acls['users']) {
foreach($acls['users'] as $acluser) {
$user = $acluser->getUser();
echo $indent." \n";
echo $indent." ".$user->getId()."\n";
echo $indent." ".$acluser->getMode()."\n";
echo $indent." \n";
}
}
if($acls['groups']) {
foreach($acls['groups'] as $aclgroup) {
$group = $aclgroup->getGroup();
echo $indent." \n";
echo $indent." ".$group->getId()."\n";
echo $indent." ".$acluser->getMode()."\n";
echo $indent." \n";
}
}
echo $indent." \n";
}
}
$cats = $document->getCategories();
if($cats) {
echo $indent." \n";
foreach($cats as $cat) {
echo $indent." ".$cat->getId()."\n";
}
echo $indent." \n";
}
$versions = $document->getContent();
if($versions) {
echo $indent." \n";
foreach($versions as $version) {
$approvalStatus = $version->getApprovalStatus();
$reviewStatus = $version->getReviewStatus();
$owner = $version->getUser();
echo $indent." getVersion()."\">\n";
echo $indent." ".$version->getMimeType()."\n";
echo $indent." ".date('c', $version->getDate())."\n";
echo $indent." ".$version->getFileType()."\n";
echo $indent." ".wrapWithCData($version->getComment())."\n";
echo $indent." ".$owner->getId()."\n";
echo $indent." ".wrapWithCData($version->getOriginalFileName())."\n";
if($approvalStatus) {
echo $indent." \n";
foreach($approvalStatus as $a) {
echo $indent." \n";
echo $indent." ".$a['type']."\n";
echo $indent." ".$a['required']."\n";
echo $indent." ".$a['status']."\n";
echo $indent." ".wrapWithCData($a['comment'])."\n";
echo $indent." ".$a['userID']."\n";
echo $indent." ".$a['date']."\n";
echo $indent." \n";
}
echo $indent." \n";
}
if($reviewStatus) {
echo $indent." \n";
foreach($reviewStatus as $a) {
echo $indent." \n";
echo $indent." ".$a['type']."\n";
echo $indent." ".$a['required']."\n";
echo $indent." ".$a['status']."\n";
echo $indent." ".wrapWithCData($a['comment'])."\n";
echo $indent." ".$a['userID']."\n";
echo $indent." ".$a['date']."\n";
echo $indent." \n";
}
echo $indent." \n";
}
if(file_exists($dms->contentDir . $version->getPath())) {
echo $indent." contentDir . $version->getPath())."\">\n";
if(filesize($dms->contentDir . $version->getPath()) < 1000000) {
echo chunk_split(base64_encode(file_get_contents($dms->contentDir . $version->getPath())), 76, "\n");
}
echo $indent." \n";
}
echo $indent." \n";
}
echo $indent." \n";
}
$files = $document->getDocumentFiles();
if($files) {
echo $indent." \n";
foreach($files as $file) {
$owner = $file->getUser();
echo $indent." getId()."\">\n";
echo $indent." ".wrapWithCData($file->getName())."\n";
echo $indent." ".$file->getMimeType()."\n";
echo $indent." ".date('c', $file->getDate())."\n";
echo $indent." ".wrapWithCData($file->getFileType())."\n";
echo $indent." ".$owner->getId()."\n";
echo $indent." ".wrapWithCData($file->getComment())."\n";
echo $indent." ".wrapWithCData($file->getOriginalFileName())."\n";
echo $indent." \n";
}
echo $indent." \n";
}
$links = $document->getDocumentLinks();
if($links) {
echo $indent." \n";
foreach($links as $link) {
$owner = $link->getUser();
$target = $link->getTarget();
echo $indent." getId()."\">\n";
echo $indent." ".$target->getId()."\n";
echo $indent." ".$owner->getId()."\n";
echo $indent." ".$link->isPublic()."\n";
echo $indent." \n";
}
echo $indent." \n";
}
$notifications = $document->getNotifyList();
if($notifications) {
if($notifications['groups'] || $notifications['users']) {
echo $indent." \n";
if($notifications['users']) {
foreach($notifications['users'] as $user) {
echo $indent." \n";
echo $indent." ".$user->getId()."\n";
echo $indent." \n";
}
}
if($notifications['groups']) {
foreach($notifications['groups'] as $group) {
echo $indent." \n";
echo $indent." ".$group->getId()."\n";
echo $indent." \n";
}
}
echo $indent." \n";
}
}
echo $indent." \n";
}
echo $indent." \n";
}
echo $indent."\n";
}
$db = new LetoDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
$dms = new LetoDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
$dms->setRootFolderID($settings->_rootFolderID);
echo "\n";
echo "\n";
$users = $dms->getAllUsers();
if($users) {
echo "\n";
foreach ($users as $user) {
echo " getId()."\">\n";
echo " ".wrapWithCData($user->getLogin())."\n";
echo " ".wrapWithCData($user->getPwd())."\n";
echo " ".wrapWithCData($user->getEmail())."\n";
echo " ".wrapWithCData($user->getFullName())."\n";
echo " ".wrapWithCData($user->getComment())."\n";
echo " ".$user->getLanguage()."\n";
echo " ".$user->getTheme()."\n";
echo " ".$user->getRole()."\n";
echo " ".$user->isHidden()."\n";
if($image = $user->getImage()) {
echo " \n";
echo " ".$image['mimetype']."\n";
echo " ".base64_encode($image['image'])."\n";
echo " \n";
}
echo " \n";
}
echo "\n";
}
$groups = $dms->getAllGroups();
if($groups) {
echo "\n";
foreach ($groups as $group) {
echo " getId()."\">\n";
echo " ".wrapWithCData($user->getFullName())."\n";
echo " ".wrapWithCData($user->getComment())."\n";
$users = $group->getUsers();
if($users) {
echo " \n";
foreach ($users as $user) {
echo " ".$user->getId()."\n";
}
echo " \n";
}
echo " \n";
}
echo "\n";
}
$categories = $dms->getAllKeywordCategories();
if($categories) {
echo "\n";
foreach($categories as $category) {
$owner = $category->getOwner();
echo " getId()."\">\n";
echo " ".wrapWithCData($category->getName())."\n";
echo " ".$owner->getId()."\n";
if($keywords = $category->getKeywordLists()) {
echo " \n";
foreach($keywords as $keyword) {
echo " \n";
echo " ".wrapWithCData($keyword['keywords'])."\n";
echo " \n";
}
echo " \n";
}
echo " \n";
}
echo "\n";
}
$categories = $dms->getDocumentCategories();
if($categories) {
echo "\n";
foreach($categories as $category) {
echo " getId()."\">\n";
echo " ".wrapWithCData($category->getName())."\n";
echo " \n";
}
echo "\n";
}
$folder = $dms->getFolder($settings->_rootFolderID);
tree($folder);
echo "\n";
?>