mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 21:21:27 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
46f5b630d6
|
@ -88,13 +88,13 @@ if(isset($options['basefolder'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if modification time shall be taken over */
|
/* check if modification time shall be taken over */
|
||||||
$filemtime = false;
|
$setfiledate = false;
|
||||||
if(isset($options['filemtime'])) {
|
if(isset($options['filemtime'])) {
|
||||||
$filemtime = true;
|
$setfiledate = true;
|
||||||
}
|
}
|
||||||
$foldermtime = false;
|
$setfolderdate = false;
|
||||||
if(isset($options['foldermtime'])) {
|
if(isset($options['setfolderdate'])) {
|
||||||
$foldermtime = true;
|
$setfolderdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($settings->_extraPath))
|
if(isset($settings->_extraPath))
|
||||||
|
@ -119,16 +119,94 @@ if(isset($options['d'])) {
|
||||||
|
|
||||||
include($myincpath."/inc/inc.Settings.php");
|
include($myincpath."/inc/inc.Settings.php");
|
||||||
include($myincpath."/inc/inc.Utils.php");
|
include($myincpath."/inc/inc.Utils.php");
|
||||||
include($myincpath."/inc/inc.Init.php");
|
|
||||||
include($myincpath."/inc/inc.Language.php");
|
include($myincpath."/inc/inc.Language.php");
|
||||||
|
include($myincpath."/inc/inc.Init.php");
|
||||||
include($myincpath."/inc/inc.Extension.php");
|
include($myincpath."/inc/inc.Extension.php");
|
||||||
include($myincpath."/inc/inc.DBInit.php");
|
include($myincpath."/inc/inc.DBInit.php");
|
||||||
include($myincpath."/inc/inc.ClassNotificationService.php");
|
|
||||||
include($myincpath."/inc/inc.ClassEmailNotify.php");
|
|
||||||
include($myincpath."/inc/inc.ClassController.php");
|
|
||||||
|
|
||||||
echo $settings->_contentDir.$settings->_contentOffsetDir.PHP_EOL;
|
echo $settings->_contentDir.$settings->_contentOffsetDir.PHP_EOL;
|
||||||
|
|
||||||
|
function getBaseData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
|
$objdata[$colname] = $coldata;
|
||||||
|
return $objdata;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function getAttributeData($attrdef, $coldata, $objdata) { /* {{{ */
|
||||||
|
$objdata['attributes'][$attrdef->getID()] = $coldata;
|
||||||
|
return $objdata;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function getCategoryData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
|
global $catids;
|
||||||
|
$kk = explode(',', $coldata);
|
||||||
|
$objdata['category'][] = array();
|
||||||
|
foreach($kk as $k) {
|
||||||
|
if(isset($catids[$k]))
|
||||||
|
$objdata['category'][] = $catids[$k];
|
||||||
|
}
|
||||||
|
return $objdata;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function getUserData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
|
global $userids;
|
||||||
|
if(isset($userids[$coldata]))
|
||||||
|
$objdata['owner'] = $userids[$coldata];
|
||||||
|
return $objdata;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
$metadata = array();
|
||||||
|
if(!isset($metadatafile)) {
|
||||||
|
$csvdelim = ';';
|
||||||
|
$csvencl = '"';
|
||||||
|
if($fp = fopen($metadatafile, 'r')) {
|
||||||
|
$colmap = array();
|
||||||
|
if($header = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
|
||||||
|
foreach($header as $i=>$colname) {
|
||||||
|
$colname = trim($colname);
|
||||||
|
if(in_array($colname, array('category'))) {
|
||||||
|
$colmap[$i] = array("getCategoryData", $colname);
|
||||||
|
} elseif(in_array($colname, array('owner'))) {
|
||||||
|
$colmap[$i] = array("getUserData", $colname);
|
||||||
|
} elseif(in_array($colname, array('filename', 'category', 'name', 'comment'))) {
|
||||||
|
$colmap[$i] = array("getBaseData", $colname);
|
||||||
|
} elseif(substr($colname, 0, 5) == 'attr:') {
|
||||||
|
$kk = explode(':', $colname, 2);
|
||||||
|
if(($attrdef = $dms->getAttributeDefinitionByName($kk[1])) || ($attrdef = $dms->getAttributeDefinition((int) $kk[1]))) {
|
||||||
|
$colmap[$i] = array("getAttributeData", $attrdef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// echo "<pre>";print_r($colmap);echo "</pre>";
|
||||||
|
if(count($colmap) > 1) {
|
||||||
|
$nameprefix = dirname($dirname).'/';
|
||||||
|
$allcats = $dms->getDocumentCategories();
|
||||||
|
$catids = array();
|
||||||
|
foreach($allcats as $cat)
|
||||||
|
$catids[$cat->getName()] = $cat;
|
||||||
|
$allusers = $dms->getAllUsers();
|
||||||
|
$userids = array();
|
||||||
|
foreach($allusers as $muser)
|
||||||
|
$userids[$muser->getLogin()] = $muser;
|
||||||
|
while(!feof($fp)) {
|
||||||
|
if($data = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
|
||||||
|
$mi = $nameprefix.$data[$colmap['filename']];
|
||||||
|
// $metadata[$mi] = array('category'=>array());
|
||||||
|
$md = array();
|
||||||
|
$md['attributes'] = array();
|
||||||
|
foreach($data as $i=>$coldata) {
|
||||||
|
if(isset($colmap[$i])) {
|
||||||
|
$md = call_user_func($colmap[$i][0], $colmap[$i][1], $coldata, $md);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($md['filename']))
|
||||||
|
$metadata[$nameprefix.$md['filename']] = $md;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a global user object */
|
/* Create a global user object */
|
||||||
if(!($user = $dms->getUserByLogin($userlogin))) {
|
if(!($user = $dms->getUserByLogin($userlogin))) {
|
||||||
echo "User with login '".$userlogin."' does not exists.";
|
echo "User with login '".$userlogin."' does not exists.";
|
||||||
|
@ -146,21 +224,22 @@ if ($folder->getAccessMode($user) < M_READWRITE) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function import_folder($dirname, $folder, $filemtime, $foldermtime) {
|
$dms->setForceLink(true);
|
||||||
global $user, $excludefiles, $fsencoding;
|
|
||||||
|
function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadata) { /* {{{ */
|
||||||
|
global $user, $doccount, $foldercount;
|
||||||
|
|
||||||
$d = dir($dirname);
|
$d = dir($dirname);
|
||||||
$sequence = 1;
|
$sequence = 1;
|
||||||
while(false !== ($entry = $d->read())) {
|
while(false !== ($entry = $d->read())) {
|
||||||
$path = $dirname.'/'.$entry;
|
$path = $dirname.'/'.$entry;
|
||||||
if(!in_array($entry, $excludefiles)) {
|
if($entry != '.' && $entry != '..' && $entry != '.svn') {
|
||||||
$name = iconv($fsencoding, 'utf-8', basename($path));
|
|
||||||
if(is_file($path)) {
|
if(is_file($path)) {
|
||||||
|
$name = utf8_basename($path);
|
||||||
$filetmp = $path;
|
$filetmp = $path;
|
||||||
|
|
||||||
$reviewers = array();
|
$reviewers = array();
|
||||||
$approvers = array();
|
$approvers = array();
|
||||||
$comment = '';
|
|
||||||
$version_comment = '';
|
$version_comment = '';
|
||||||
$reqversion = 1;
|
$reqversion = 1;
|
||||||
$expires = false;
|
$expires = false;
|
||||||
|
@ -173,43 +252,56 @@ function import_folder($dirname, $folder, $filemtime, $foldermtime) {
|
||||||
if (is_bool($lastDotIndex) && !$lastDotIndex) $filetype = ".";
|
if (is_bool($lastDotIndex) && !$lastDotIndex) $filetype = ".";
|
||||||
else $filetype = substr($name, $lastDotIndex);
|
else $filetype = substr($name, $lastDotIndex);
|
||||||
|
|
||||||
echo $mimetype." - ".$filetype." - ".$path.PHP_EOL;
|
$docname = !empty($metadata[$path]['name']) ? $metadata[$path]['name'] : $name;
|
||||||
$res = $folder->addDocument($name, $comment, $expires, $user, $keywords,
|
$comment = !empty($metadata[$path]['comment']) ? $metadata[$path]['comment'] : '';
|
||||||
$categories, $filetmp, $name,
|
$owner = !empty($metadata[$path]['owner']) ? $metadata[$path]['owner'] : $user;
|
||||||
$filetype, $mimetype, $sequence, $reviewers,
|
|
||||||
$approvers, $reqversion, $version_comment);
|
|
||||||
|
|
||||||
if (is_bool($res) && !$res) {
|
echo $mimetype." - ".$filetype." - ".$path."<br />\n";
|
||||||
echo "Could not add document to folder".PHP_EOL;
|
if($res = $folder->addDocument($docname, $comment, $expires, $owner, $keywords,
|
||||||
exit(1);
|
!empty($metadata[$path]['category']) ? $metadata[$path]['category'] : array(), $filetmp, $name,
|
||||||
|
$filetype, $mimetype, $sequence, $reviewers,
|
||||||
|
$approvers, $reqversion, $version_comment,
|
||||||
|
!empty($metadata[$path]['attributes']) ? $metadata[$path]['attributes'] : array())) {
|
||||||
|
$doccount++;
|
||||||
|
if($setfiledate) {
|
||||||
|
$newdoc = $res[0];
|
||||||
|
$newdoc->setDate(filemtime($path));
|
||||||
|
$lc = $newdoc->getLatestContent();
|
||||||
|
$lc->setDate(filemtime($path));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Error importing ".$path."<br />";
|
||||||
|
echo "<pre>".print_r($res, true)."</pre>";
|
||||||
|
// return false;
|
||||||
}
|
}
|
||||||
if($filemtime) {
|
set_time_limit(30);
|
||||||
$newdoc = $res[0];
|
|
||||||
$newdoc->setDate(filemtime($path));
|
|
||||||
$lc = $newdoc->getLatestContent();
|
|
||||||
$lc->setDate(filemtime($path));
|
|
||||||
}
|
|
||||||
set_time_limit(1200);
|
|
||||||
} elseif(is_dir($path)) {
|
} elseif(is_dir($path)) {
|
||||||
$newfolder = $folder->addSubFolder($name, '', $user, $sequence);
|
$name = utf8_basename($path);
|
||||||
if($foldermtime) {
|
if($newfolder = $folder->addSubFolder($name, '', $user, $sequence)) {
|
||||||
$newfolder->setDate(filemtime($path));
|
$foldercount++;
|
||||||
|
if($setfolderdate) {
|
||||||
|
$newfolder->setDate(filemtime($path));
|
||||||
|
}
|
||||||
|
if(!import_folder($path, $newfolder, $setfiledate, $setfolderdate, $metadata))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// return false;
|
||||||
}
|
}
|
||||||
import_folder($path, $newfolder, $filemtime, $foldermtime);
|
|
||||||
}
|
}
|
||||||
$sequence++;
|
$sequence++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
if($createbasefolder) {
|
if($createbasefolder) {
|
||||||
if($newfolder = $folder->addSubFolder(basename($dirname), '', $user, 1)) {
|
if($newfolder = $folder->addSubFolder(basename($dirname), '', $user, 1)) {
|
||||||
if($foldermtime) {
|
if($setfolderdate) {
|
||||||
$newfolder->setDate(filemtime($dirname));
|
$newfolder->setDate(filemtime($dirname));
|
||||||
}
|
}
|
||||||
import_folder($dirname, $newfolder, $filemtime, $foldermtime);
|
import_folder($dirname, $newfolder, $setfiledate, $setfolderdate, $metadata);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
import_folder($dirname, $folder, $filemtime, $foldermtime);
|
import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3297,7 +3297,7 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
|
||||||
if(!$skipcont)
|
if(!$skipcont)
|
||||||
$content .= $this->documentListRowStart($document);
|
$content .= $this->documentListRowStart($document);
|
||||||
|
|
||||||
$previewer->createPreview($latestContent);
|
if($previewer) $previewer->createPreview($latestContent);
|
||||||
$version = $latestContent->getVersion();
|
$version = $latestContent->getVersion();
|
||||||
|
|
||||||
if($ec = $this->callHook('documentListRowExtraContent', $document, $latestContent))
|
if($ec = $this->callHook('documentListRowExtraContent', $document, $latestContent))
|
||||||
|
@ -3311,7 +3311,7 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
|
||||||
else {
|
else {
|
||||||
if($accessop->check_controller_access('Download', array('action'=>'version')))
|
if($accessop->check_controller_access('Download', array('action'=>'version')))
|
||||||
$content .= "<a draggable=\"false\" href=\"".$this->params['settings']->_httpRoot."op/op.Download.php?documentid=".$docID."&version=".$version."\">";
|
$content .= "<a draggable=\"false\" href=\"".$this->params['settings']->_httpRoot."op/op.Download.php?documentid=".$docID."&version=".$version."\">";
|
||||||
if($previewer->hasPreview($latestContent)) {
|
if($previewer && $previewer->hasPreview($latestContent)) {
|
||||||
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->params['settings']->_httpRoot."op/op.Preview.php?documentid=".$document->getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->params['settings']->_httpRoot."op/op.Preview.php?documentid=".$document->getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
||||||
} else {
|
} else {
|
||||||
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" ".($previewwidth ? "width=\"".$previewwidth."\"" : "")."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" ".($previewwidth ? "width=\"".$previewwidth."\"" : "")."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
||||||
|
|
|
@ -54,9 +54,12 @@ $('.folderselect').click(function(ev) {
|
||||||
$rii = new DirectoryIterator($path);
|
$rii = new DirectoryIterator($path);
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
foreach ($rii as $file)
|
foreach ($rii as $file) {
|
||||||
if (!$file->isDir())
|
if (!$file->isDir())
|
||||||
$files[] = [substr($file->getPath(), strlen($path)+1), $file->getFilename()];
|
$files[] = [substr($file->getPath(), strlen($path)+1), $file->getFilename()];
|
||||||
|
if(count($files) > 20)
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
@ -68,11 +71,14 @@ $('.folderselect').click(function(ev) {
|
||||||
$rii = new DirectoryIterator($path);
|
$rii = new DirectoryIterator($path);
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
foreach ($rii as $file)
|
foreach ($rii as $file) {
|
||||||
if ($file->isDir()) {
|
if ($file->isDir()) {
|
||||||
if(($t = substr($file->getPath(), strlen($path)+1)) && ($file->getFilename() == '.'))
|
if(($t = substr($file->getPath(), strlen($path)+1)) && ($file->getFilename() == '.'))
|
||||||
$files[] = $t;
|
$files[] = $t;
|
||||||
}
|
}
|
||||||
|
if(count($files) > 20)
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3289,7 +3289,7 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
|
||||||
if(!$skipcont)
|
if(!$skipcont)
|
||||||
$content .= $this->documentListRowStart($document);
|
$content .= $this->documentListRowStart($document);
|
||||||
|
|
||||||
$previewer->createPreview($latestContent);
|
if($previewer) $previewer->createPreview($latestContent);
|
||||||
$version = $latestContent->getVersion();
|
$version = $latestContent->getVersion();
|
||||||
|
|
||||||
if($ec = $this->callHook('documentListRowExtraContent', $document, $latestContent))
|
if($ec = $this->callHook('documentListRowExtraContent', $document, $latestContent))
|
||||||
|
@ -3303,7 +3303,7 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
|
||||||
else {
|
else {
|
||||||
if($accessop->check_controller_access('Download', array('action'=>'version')))
|
if($accessop->check_controller_access('Download', array('action'=>'version')))
|
||||||
$content .= "<a draggable=\"false\" href=\"".$this->params['settings']->_httpRoot."op/op.Download.php?documentid=".$docID."&version=".$version."\">";
|
$content .= "<a draggable=\"false\" href=\"".$this->params['settings']->_httpRoot."op/op.Download.php?documentid=".$docID."&version=".$version."\">";
|
||||||
if($previewer->hasPreview($latestContent)) {
|
if($previewer && $previewer->hasPreview($latestContent)) {
|
||||||
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->params['settings']->_httpRoot."op/op.Preview.php?documentid=".$document->getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->params['settings']->_httpRoot."op/op.Preview.php?documentid=".$document->getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
||||||
} else {
|
} else {
|
||||||
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" ".($previewwidth ? "width=\"".$previewwidth."\"" : "")."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"".$previewwidth."\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" ".($previewwidth ? "width=\"".$previewwidth."\"" : "")."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user