add check for wrong file type, fix repairing of checksum and filesize

This commit is contained in:
Uwe Steinmann 2020-02-13 12:20:16 +01:00
parent 9b24827598
commit 450bdc0b7f
2 changed files with 91 additions and 19 deletions

View File

@ -66,6 +66,12 @@ if(isset($_GET['setchecksum']) && $_GET['setchecksum'] == 1) {
$setchecksum = 0;
}
if(isset($_GET['setfiletype']) && $_GET['setfiletype'] == 1) {
$setfiletype = 1;
} else {
$setfiletype = 0;
}
$folder = $dms->getFolder($settings->_rootFolderID);
$unlinkedversions = $dms->getUnlinkedDocumentContent();
if(!isset($_GET['action']) || $_GET['action'] == 'listUnlinkedFolders')
@ -84,6 +90,10 @@ if(!isset($_GET['action']) || $_GET['action'] == 'listMissingChecksum')
$nochecksumversions = $dms->getNoChecksumDocumentContent();
else
$nochecksumversions = null;
if(!isset($_GET['action']) || $_GET['action'] == 'listWrongFiletype')
$wrongfiletypeversions = $dms->getWrongFiletypeDocumentContent();
else
$wrongfiletypeversions = null;
if(!isset($_GET['action']) || $_GET['action'] == 'listDuplicateContent')
$duplicateversions = $dms->getDuplicateDocumentContent();
else
@ -215,6 +225,7 @@ if($view) {
$view->setParam('unlinkeddocuments', $unlinkeddocuments);
$view->setParam('nofilesizeversions', $nofilesizeversions);
$view->setParam('nochecksumversions', $nochecksumversions);
$view->setParam('wrongfiletypeversions', $wrongfiletypeversions);
$view->setParam('duplicateversions', $duplicateversions);
$view->setParam('docsinrevision', $docsinrevision);
$view->setParam('docsinreception', $docsinreception);
@ -222,6 +233,7 @@ if($view) {
$view->setParam('unlink', $unlink);
$view->setParam('setfilesize', $setfilesize);
$view->setParam('setchecksum', $setchecksum);
$view->setParam('setfiletype', $setfiletype);
$view->setParam('repair', $repair);
$view->setParam('showtree', showtree());
$view->setParam('rootfolder', $rootfolder);

View File

@ -152,7 +152,7 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
$this->contentHeading(getMLText("unlinked_documents"));
if($unlinkeddocuments) {
print "<table class=\"table-condensed\">";
print "<table class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("id")."</th>\n";
@ -186,7 +186,7 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
}
if($unlinkedcontent) {
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";
@ -215,11 +215,11 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
$user = $this->params['user'];
$folder = $this->params['folder'];
$nofilesizeversions = $this->params['nofilesizeversions'];
$setfilesize = $this->params['setfilesize'];
$repair = $this->params['repair'];
$this->contentHeading(getMLText("missing_filesize"));
if($nofilesizeversions) {
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";
@ -229,18 +229,25 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
print "</tr>\n</thead>\n<tbody>\n";
foreach($nofilesizeversions as $version) {
$doc = $version->getDocument();
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
echo "<td>";
if($setfilesize) {
if($version->setFileSize())
echo getMLText('repaired');
$class = $msg = '';
if($repair) {
if($version->setFileSize()) {
$msg = getMLText('repaired');
$class = ' class="success"';
} else {
$msg = getMLText('not_repaired');
$class = ' class="error"';
}
}
print "<tr".$class."><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
echo "<td>";
echo $msg;
echo "</td>";
print "</tr>\n";
}
print "</tbody></table>\n";
if($setfilesize == 0) {
echo '<p><a href="out.ObjectCheck.php?setfilesize=1">'.getMLText('do_object_setfilesize').'</a></p>';
if($repair == 0) {
echo '<div class="repair"><a class="btn btn-primary" data-action="listMissingFileSize">'.getMLText('do_object_setfilesize').'</a></div>';
}
}
@ -251,11 +258,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
$user = $this->params['user'];
$folder = $this->params['folder'];
$nochecksumversions = $this->params['nochecksumversions'];
$repair = $this->params['repair'];
$this->contentHeading(getMLText("missing_checksum"));
if($nochecksumversions) {
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";
@ -265,18 +273,69 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
print "</tr>\n</thead>\n<tbody>\n";
foreach($nochecksumversions as $version) {
$doc = $version->getDocument();
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
echo "<td>";
if($setchecksum) {
if($version->setChecksum())
echo getMLText('repaired');
$class = $msg = '';
if($repair) {
if($version->setChecksum()) {
$msg = getMLText('repaired');
$class = ' class="success"';
} else {
$msg = getMLText('not_repaired');
$class = ' class="error"';
}
}
print "<tr".$class."><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
echo "<td>";
echo $msg;
echo "</td>";
print "</tr>\n";
}
print "</tbody></table>\n";
if($setchecksum == 0) {
echo '<p><a href="out.ObjectCheck.php?setchecksum=1">'.getMLText('do_object_setchecksum').'</a></p>';
if($repair == 0) {
echo '<div class="repair"><a class="btn btn-primary" data-action="listMissingChecksum">'.getMLText('do_object_setchecksum').'</a></div>';
}
}
} /* }}} */
function listWrongFiletype() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$wrongfiletypeversions = $this->params['wrongfiletypeversions'];
$repair = $this->params['repair'];
$this->contentHeading(getMLText("wrong_filetype"));
if($wrongfiletypeversions) {
print "<table class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th>".getMLText("document")."</th>\n";
print "<th>".getMLText("version")."</th>\n";
print "<th>".getMLText("original_filename")."</th>\n";
print "<th>".getMLText("mimetype")."</th>\n";
print "<th>".getMLText("filetype")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
foreach($wrongfiletypeversions as $version) {
$doc = $version->getDocument();
$class = $msg = '';
if($repair) {
if($version->setFiletype()) {
$msg = getMLText('repaired');
$class = ' class="success"';
} else {
$msg = getMLText('not_repaired');
$class = ' class="error"';
}
}
print "<tr".$class."><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td><td>".$version->getFileType()."</td>";
echo "<td>";
echo $msg;
echo "</td>";
print "</tr>\n";
}
print "</tbody></table>\n";
if($repair == 0) {
echo '<div class="repair"><a class="btn btn-primary" data-action="listWrongFiletype">'.getMLText('do_object_setfiletype').'</a></div>';
}
}
} /* }}} */
@ -504,6 +563,7 @@ $(document).ready( function() {
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="listMissingChecksum"><span class="badge '.($nochecksumversions ? 'badge-info ' : '').'badge-right">'.count($nochecksumversions).'</span>'.getMLText("missing_checksum").'</a></li>';
echo '<li class=""><a data-href="#wrong_filetype" data-action="listWrongFiletype"><span class="badge '.($wrongfiletypeversions ? 'badge-info ' : '').'badge-right">'.count($wrongfiletypeversions).'</span>'.getMLText("wrong_filetype").'</a></li>';
echo '</ul>';
$this->contentHeading(getMLText("object_check_warning"));
echo '<ul class="nav nav-list bs-docs-sidenav _affix">';