reorganize page like MyDocuments page

This commit is contained in:
Uwe Steinmann 2017-01-24 14:20:43 +01:00
parent 27247438f5
commit b814b07e2a
2 changed files with 249 additions and 64 deletions

View File

@ -35,6 +35,11 @@ if (!$accessop->check_view_access($view, $_GET)) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
$listtype = 'listRepair';
if (isset($_GET["list"])) {
$listtype = $_GET['list'];
}
if(isset($_GET['repair']) && $_GET['repair'] == 1) {
$repair = 1;
} else {
@ -68,8 +73,60 @@ $nochecksumversions = $dms->getNoChecksumDocumentContent();
$duplicateversions = $dms->getDuplicateDocumentContent();
$rootfolder = $dms->getFolder($settings->_rootFolderID);
function repair_tree($dms, $user, $folder, $path=':') { /* {{{ */
$objects = array();
/* Don't do folderlist check for root folder */
if($path != ':') {
/* If the path contains a folder id twice, the a cyclic relation
* exists.
*/
$tmparr = explode(':', $path);
array_shift($tmparr);
if(count($tmparr) != count(array_unique($tmparr))) {
$objects[] = array('object'=>$folder, 'msg'=>'Folder path contains cyclic relation');
}
$folderList = $folder->getFolderList();
/* Check the folder */
if($folderList != $path) {
$objects[] = array('object'=>$folder, 'msg'=>"Folderlist is '".$folderList."', should be '".$path);
}
}
$subfolders = $folder->getSubFolders();
foreach($subfolders as $subfolder) {
$objects = array_merge($objects, repair_tree($dms, $user, $subfolder, $path.$folder->getId().':'));
}
$path .= $folder->getId().':';
$documents = $folder->getDocuments();
foreach($documents as $document) {
/* Check the folder list of the document */
$folderList = $document->getFolderList();
if($folderList != $path) {
$objects[] = array('object'=>$document, 'msg'=>"Folderlist is '".$folderList."', should be '".$path);
}
/* Check if the content is available */
$versions = $document->getContent();
if($versions) {
foreach($versions as $version) {
$filepath = $dms->contentDir . $version->getPath();
if(!file_exists($filepath)) {
$objects[] = array('object'=>$version, 'msg'=>'Document content is missing');
}
}
} else {
$objects[] = array('object'=>$version, 'msg'=>'Document has no content at all');
}
}
return $objects;
} /* }}} */
$repairobjects = repair_tree($dms, $user, $folder);
if($view) {
$view->setParam('folder', $folder);
$view->setParam('listtype', $listtype);
$view->setParam('unlinkedcontent', $unlinkedversions);
$view->setParam('unlinkedfolders', $unlinkedfolders);
$view->setParam('unlinkeddocuments', $unlinkeddocuments);
@ -81,6 +138,7 @@ if($view) {
$view->setParam('setchecksum', $setchecksum);
$view->setParam('repair', $repair);
$view->setParam('rootfolder', $rootfolder);
$view->setParam('repairobjects', $repairobjects);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;

View File

@ -31,6 +31,57 @@ require_once("class.Bootstrap.php");
*/
class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
function _tree($dms, $user, $folder, $path=':') { /* {{{ */
$objects = array();
/* Don't do folderlist check for root folder */
if($path != ':') {
/* If the path contains a folder id twice, the a cyclic relation
* exists.
*/
$tmparr = explode(':', $path);
array_shift($tmparr);
if(count($tmparr) != count(array_unique($tmparr))) {
$objects[] = array('object'=>$folder, 'msg'=>'Folder path contains cyclic relation');
}
$folderList = $folder->getFolderList();
/* Check the folder */
if($folderList != $path) {
$objects[] = array('object'=>$folder, 'msg'=>"Folderlist is '".$folderList."', should be '".$path);
}
}
$subfolders = $folder->getSubFolders();
foreach($subfolders as $subfolder) {
$objects = array_merge($objects, $this->_tree($dms, $user, $subfolder, $path.$folder->getId().':'));
}
$path .= $folder->getId().':';
$documents = $folder->getDocuments();
foreach($documents as $document) {
/* Check the folder list of the document */
$folderList = $document->getFolderList();
if($folderList != $path) {
$objects[] = array('object'=>$document, 'msg'=>"Folderlist is '".$folderList."', should be '".$path);
}
/* Check if the content is available */
$versions = $document->getContent();
if($versions) {
foreach($versions as $version) {
$filepath = $dms->contentDir . $version->getPath();
if(!file_exists($filepath)) {
$objects[] = array('object'=>$version, 'msg'=>'Document content is missing');
}
}
} else {
$objects[] = array('object'=>$version, 'msg'=>'Document has no content at all');
}
}
return $objects;
} /* }}} */
function tree($dms, $folder, $repair, $path=':', $indent='') { /* {{{ */
global $user;
@ -185,65 +236,44 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
}
} /* }}} */
function js() { /* {{{ */
$user = $this->params['user'];
$folder = $this->params['folder'];
header('Content-Type: application/javascript; charset=UTF-8');
$this->printDeleteFolderButtonJs();
$this->printDeleteDocumentButtonJs();
} /* }}} */
function show() { /* {{{ */
function listRepair() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$unlinkedversions = $this->params['unlinkedcontent'];
$unlinkedfolders = $this->params['unlinkedfolders'];
$unlinkeddocuments = $this->params['unlinkeddocuments'];
$nofilesizeversions = $this->params['nofilesizeversions'];
$nochecksumversions = $this->params['nochecksumversions'];
$duplicateversions = $this->params['duplicateversions'];
$repair = $this->params['repair'];
$unlink = $this->params['unlink'];
$setfilesize = $this->params['setfilesize'];
$setchecksum = $this->params['setchecksum'];
$rootfolder = $this->params['rootfolder'];
$this->enableClipboard = $this->params['enableclipboard'];
$objects = $this->params['repairobjects'];
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("objectcheck"));
if($repair) {
echo "<div class=\"alert\">".getMLText('repairing_objects')."</div>";
}
$this->contentContainerStart();
print "<table class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("error")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
$this->needsrepair = false;
$this->tree($dms, $folder, $repair);
print "</tbody></table>\n";
if($objects) {
if($repair) {
echo "<div class=\"alert\">".getMLText('repairing_objects')."</div>";
}
print "<table class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("error")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
$this->needsrepair = false;
print "</tbody></table>\n";
if($this->needsrepair && $repair == 0) {
echo '<p><a href="out.ObjectCheck.php?repair=1">'.getMLText('do_object_repair').'</a></p>';
if($this->needsrepair && $repair == 0) {
echo '<p><a href="out.ObjectCheck.php?repair=1">'.getMLText('do_object_repair').'</a></p>';
}
}
$this->contentContainerEnd();
} /* }}} */
function listUnlinkedFolders() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$unlinkedfolders = $this->params['unlinkedfolders'];
$this->contentHeading(getMLText("unlinked_folders"));
if($unlinkedfolders) {
$this->contentHeading(getMLText("unlinked_folders"));
$this->contentContainerStart();
print "<table class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th>".getMLText("name")."</th>\n";
@ -262,12 +292,17 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
echo "</tr>";
}
print "</tbody></table>\n";
$this->contentContainerEnd();
}
} /* }}} */
function listUnlinkedDocuments() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$unlinkeddocuments = $this->params['unlinkeddocuments'];
$this->contentHeading(getMLText("unlinked_documents"));
if($unlinkeddocuments) {
$this->contentHeading(getMLText("unlinked_documents"));
$this->contentContainerStart();
print "<table class=\"table-condensed\">";
print "<thead>\n<tr>\n";
print "<th>".getMLText("name")."</th>\n";
@ -286,16 +321,22 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
echo "</tr>";
}
print "</tbody></table>\n";
$this->contentContainerEnd();
}
} /* }}} */
function listUnlinkedContent() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$unlinkedcontent = $this->params['unlinkedcontent'];
$unlink = $this->params['unlink'];
$this->contentHeading(getMLText("unlinked_content"));
$this->contentContainerStart();
if($unlink) {
echo "<p>".getMLText('unlinking_objects')."</p>";
}
if($unlinkedversions) {
if($unlinkedcontent) {
print "<table class=\"table-condensed\">";
print "<thead>\n<tr>\n";
print "<th>".getMLText("document")."</th>\n";
@ -304,7 +345,7 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
print "<th>".getMLText("mimetype")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
foreach($unlinkedversions as $version) {
foreach($unlinkedcontent as $version) {
$doc = $version->getDocument();
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
if($unlink) {
@ -318,11 +359,15 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
}
}
$this->contentContainerEnd();
} /* }}} */
function listMissingFileSize() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$nofilesizeversions = $this->params['nofilesizeversions'];
$this->contentHeading(getMLText("missing_filesize"));
$this->contentContainerStart();
if($nofilesizeversions) {
print "<table class=\"table-condensed\">";
print "<thead>\n<tr>\n";
@ -347,10 +392,15 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
}
}
$this->contentContainerEnd();
} /* }}} */
function listMissingChecksum() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$nochecksumversions = $this->params['nochecksumversions'];
$this->contentHeading(getMLText("missing_checksum"));
$this->contentContainerStart();
if($nochecksumversions) {
print "<table class=\"table-condensed\">";
@ -375,14 +425,18 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
echo '<p><a href="out.ObjectCheck.php?setchecksum=1">'.getMLText('do_object_setchecksum').'</a></p>';
}
}
} /* }}} */
$this->contentContainerEnd();
function listDuplicateContent() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$duplicateversions = $this->params['duplicateversions'];
$this->contentHeading(getMLText("duplicate_content"));
$this->contentContainerStart();
if($duplicateversions) {
print "<table class=\"table-condensed\">";
print "<table class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th>".getMLText("document")."</th>\n";
print "<th>".getMLText("version")."</th>\n";
@ -403,8 +457,81 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
}
print "</tbody></table>\n";
}
} /* }}} */
function js() { /* {{{ */
$user = $this->params['user'];
$folder = $this->params['folder'];
header('Content-Type: application/javascript; charset=UTF-8');
$this->printDeleteFolderButtonJs();
$this->printDeleteDocumentButtonJs();
?>
$(document).ready( function() {
$('body').on('click', 'ul.bs-docs-sidenav li a', function(ev){
ev.preventDefault();
$('#kkkk.ajax').data('action', $(this).data('action'));
$('#kkkk.ajax').trigger('update', {orderby: $(this).data('orderby')});
});
$('body').on('click', 'table th a', function(ev){
ev.preventDefault();
$('#kkkk.ajax').data('action', $(this).data('action'));
$('#kkkk.ajax').trigger('update', {orderby: $(this).data('orderby'), orderdir: $(this).data('orderdir')});
});
});
<?php
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$listtype = $this->params['listtype'];
$unlinkedcontent = $this->params['unlinkedcontent'];
$unlinkedfolders = $this->params['unlinkedfolders'];
$unlinkeddocuments = $this->params['unlinkeddocuments'];
$nofilesizeversions = $this->params['nofilesizeversions'];
$nochecksumversions = $this->params['nochecksumversions'];
$duplicateversions = $this->params['duplicateversions'];
$repair = $this->params['repair'];
$unlink = $this->params['unlink'];
$setfilesize = $this->params['setfilesize'];
$setchecksum = $this->params['setchecksum'];
$rootfolder = $this->params['rootfolder'];
$repairobjects = $this->params['repairobjects'];
$this->enableClipboard = $this->params['enableclipboard'];
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
echo '<div class="row-fluid">';
echo '<div class="span3">';
$this->contentHeading(getMLText("object_check_critical"));
echo '<ul class="nav nav-list bs-docs-sidenav _affix">';
echo '<li class=""><a data-href="#all_documents" data-action="listRepair"><span class="badge '.($repairobjects ? 'badge-info ' : '').'badge-right">'.count($repairobjects).'</span>'.getMLText("objectcheck").'</a></li>';
echo '<li class=""><a data-href="#unlinked_folders" data-action="listUnlinkedFolders"><span class="badge '.($unlinkedfolders ? 'badge-info ' : '').'badge-right">'.count($unlinkedfolders).'</span>'.getMLText("unlinked_folders").'</a></li>';
echo '<li class=""><a data-href="#unlinked_documents" data-action="listUnlinkedDocuments"><span class="badge '.($unlinkeddocuments ? 'badge-info ' : '').'badge-right">'.count($unlinkeddocuments).'</span>'.getMLText("unlinked_documents").'</a></li>';
echo '<li class=""><a data-href="#unlinked_content" data-action="listUnlinkedContent"><span class="badge '.($unlinkedcontent ? 'badge-info ' : '').'badge-right">'.count($unlinkedcontent).'</span>'.getMLText("unlinked_content").'</a></li>';
echo '<li class=""><a data-href="#missing_filesize" data-action="listMissingFileSize"><span class="badge '.($nofilesizeversions ? 'badge-info ' : '').'badge-right">'.count($nofilesizeversions).'</span>'.getMLText("missing_filesize").'</a></li>';
echo '<li class=""><a data-href="#missing_checksum" data-action="listMissingFileSize"><span class="badge '.($nochecksumversions ? 'badge-info ' : '').'badge-right">'.count($nochecksumversions).'</span>'.getMLText("missing_checksum").'</a></li>';
echo '</ul>';
$this->contentHeading(getMLText("object_check_warning"));
echo '<ul class="nav nav-list bs-docs-sidenav _affix">';
echo '<li class=""><a data-href="#duplicate_content" data-action="listDuplicateContent"><span class="badge '.($duplicateversions ? 'badge-info ' : '').'badge-right">'.count($duplicateversions).'</span>'.getMLText("duplicate_content").'</a></li>';
echo '</ul>';
echo '</div>';
echo '<div class="span9">';
echo '<div id="kkkk" class="ajax" data-view="ObjectCheck" data-action="'.($listtype ? $listtype : 'listRepair').'"></div>';
echo '</div>';
echo '</div>';
$this->contentContainerEnd();
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */