$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); 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 { $repair = 0; } if(isset($_GET['unlink']) && $_GET['unlink'] == 1) { $unlink = 1; } else { $unlink = 0; } if(isset($_GET['setfilesize']) && $_GET['setfilesize'] == 1) { $setfilesize = 1; } else { $setfilesize = 0; } if(isset($_GET['setchecksum']) && $_GET['setchecksum'] == 1) { $setchecksum = 1; } else { $setchecksum = 0; } $folder = $dms->getFolder($settings->_rootFolderID); $unlinkedversions = $dms->getUnlinkedDocumentContent(); $unlinkedfolders = $dms->checkFolders(); $unlinkeddocuments = $dms->checkDocuments(); $nofilesizeversions = $dms->getNoFileSizeDocumentContent(); $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); $view->setParam('nofilesizeversions', $nofilesizeversions); $view->setParam('nochecksumversions', $nochecksumversions); $view->setParam('duplicateversions', $duplicateversions); $view->setParam('unlink', $unlink); $view->setParam('setfilesize', $setfilesize); $view->setParam('setchecksum', $setchecksum); $view->setParam('repair', $repair); $view->setParam('rootfolder', $rootfolder); $view->setParam('repairobjects', $repairobjects); $view->setParam('accessobject', $accessop); $view($_GET); exit; } ?>