do some logging

This commit is contained in:
Uwe Steinmann 2024-08-21 16:44:19 +02:00
parent 83f0cfff8d
commit 65299463f4

View File

@ -140,7 +140,7 @@ if(isset($_GET['setfolderdate']) && $_GET["setfolderdate"]) {
}
function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadata) { /* {{{ */
global $user, $doccount, $foldercount;
global $user, $doccount, $foldercount, $logger;
$d = dir($dirname);
$sequence = 1;
@ -169,7 +169,9 @@ function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadat
$comment = !empty($metadata[$path]['comment']) ? $metadata[$path]['comment'] : '';
$owner = !empty($metadata[$path]['owner']) ? $metadata[$path]['owner'] : $user;
echo $mimetype." - ".$filetype." - ".$path."<br />\n";
// echo $mimetype." - ".$filetype." - ".$path."<br />\n";
if($logger)
$logger->log('ImportFS: importing \''.$path.'\' '.(!empty($metadata[$path]['attributes']) ? 'with' : 'without').' metadata', PEAR_LOG_INFO);
if($res = $folder->addDocument($docname, $comment, $expires, $owner, $keywords,
!empty($metadata[$path]['category']) ? $metadata[$path]['category'] : array(), $filetmp, $name,
$filetype, $mimetype, $sequence, $reviewers,
@ -182,10 +184,11 @@ function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadat
$lc = $newdoc->getLatestContent();
$lc->setDate(filemtime($path));
}
if($logger)
$logger->log('ImportFS: imported \''.$path.'\' as document '.$res[0]->getId(), PEAR_LOG_INFO);
} else {
echo "Error importing ".$path."<br />";
echo "<pre>".print_r($res, true)."</pre>";
// return false;
if($logger)
$logger->log('ImportFS: importing \''.$path.'\' failed.', PEAR_LOG_ERR);
}
set_time_limit(30);
} elseif(is_dir($path)) {
@ -195,10 +198,13 @@ function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadat
if($setfolderdate) {
$newfolder->setDate(filemtime($path));
}
if($logger)
$logger->log('ImportFS: creating folder \''.$path.'\' as folder '.$newfolder->getId(), PEAR_LOG_INFO);
if(!import_folder($path, $newfolder, $setfiledate, $setfolderdate, $metadata))
return false;
} else {
// return false;
if($logger)
$logger->log('ImportFS: creating folder \''.$path.'\' failed.', PEAR_LOG_ERR);
}
}
$sequence++;
@ -208,19 +214,27 @@ function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadat
} /* }}} */
$foldercount = $doccount = 0;
if($_GET['createfolder']) {
if(!empty($_GET['createfolder'])) {
if($newfolder = $folder->addSubFolder($_GET["dropfolderfileform1"], '', $user, 1)) {
if($setfolderdate) {
$newfolder->setDate(filemtime($dirname));
}
if($logger)
$logger->log('ImportFS: creating folder \''.$_GET["dropfolderfileform1"].'\' as folder '.$newfolder->getId(), PEAR_LOG_INFO);
} else {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_importfs')));
if($logger)
$logger->log('ImportFS: creating folder \''.$_GET["dropfolderfileform1"].'\' failed.', PEAR_LOG_ERR);
}
} else {
$newfolder = $folder;
}
if($newfolder) {
if($logger) {
$logger->log('ImportFS: importing into folder '.$newfolder->getId(), PEAR_LOG_INFO);
if($metadata)
$logger->log('ImportFS: using metadata for '.count($metadata).' files from file \''.$metadatafile.'\'', PEAR_LOG_INFO);
}
if(!import_folder($dirname, $newfolder, $setfiledate, $setfolderdate, $metadata))
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_importfs')));
else {
@ -231,6 +245,8 @@ if($newfolder) {
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_importfs', array('docs'=>$doccount, 'folders'=>$foldercount))));
}
} else {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_importfs')));
}
header("Location:../out/out.ViewFolder.php?folderid=".$newfolder->getID());