Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2023-01-03 16:38:57 +01:00
commit 2f868c4f44
35 changed files with 1032 additions and 68 deletions

View File

@ -271,7 +271,7 @@
- rest api returns version attributes as 'version_attributes' (was - rest api returns version attributes as 'version_attributes' (was
'version-attributes'), each attribute also contains the name 'version-attributes'), each attribute also contains the name
- new hook in rest api to add more routes in extensions - new hook in rest api to add more routes in extensions
- uploaded serveral documents at once by fast upload will assign random - uploaded several documents at once by fast upload will assign random
sequence number to allow manually sorting the documents afterwards sequence number to allow manually sorting the documents afterwards
- fix counting of login failures if both ldap and db authentication is done - fix counting of login failures if both ldap and db authentication is done

View File

@ -451,6 +451,7 @@ class SeedDMS_Core_DMS {
$this->classnames['folder'] = 'SeedDMS_Core_Folder'; $this->classnames['folder'] = 'SeedDMS_Core_Folder';
$this->classnames['document'] = 'SeedDMS_Core_Document'; $this->classnames['document'] = 'SeedDMS_Core_Document';
$this->classnames['documentcontent'] = 'SeedDMS_Core_DocumentContent'; $this->classnames['documentcontent'] = 'SeedDMS_Core_DocumentContent';
$this->classnames['documentfile'] = 'SeedDMS_Core_DocumentFile';
$this->classnames['user'] = 'SeedDMS_Core_User'; $this->classnames['user'] = 'SeedDMS_Core_User';
$this->classnames['role'] = 'SeedDMS_Core_Role'; $this->classnames['role'] = 'SeedDMS_Core_Role';
$this->classnames['group'] = 'SeedDMS_Core_Group'; $this->classnames['group'] = 'SeedDMS_Core_Group';

View File

@ -2714,7 +2714,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if ((is_bool($resArr) && !$resArr) || count($resArr)==0) return false; if ((is_bool($resArr) && !$resArr) || count($resArr)==0) return false;
$resArr = $resArr[0]; $resArr = $resArr[0];
$file = new SeedDMS_Core_DocumentFile($resArr["id"], $this, $resArr["userID"], $resArr["comment"], $resArr["date"], $resArr["dir"], $resArr["fileType"], $resArr["mimeType"], $resArr["orgFileName"], $resArr["name"],$resArr["version"],$resArr["public"]); $classname = $this->_dms->getClassname('documentfile');
$file = new $classname($resArr["id"], $this, $resArr["userID"], $resArr["comment"], $resArr["date"], $resArr["dir"], $resArr["fileType"], $resArr["mimeType"], $resArr["orgFileName"], $resArr["name"],$resArr["version"],$resArr["public"]);
$user = $this->_dms->getLoggedInUser(); $user = $this->_dms->getLoggedInUser();
if($file->getAccessMode($user) >= M_READ) if($file->getAccessMode($user) >= M_READ)
return $file; return $file;
@ -2755,8 +2756,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_documentFiles = array($hash=>array()); $this->_documentFiles = array($hash=>array());
$user = $this->_dms->getLoggedInUser(); $user = $this->_dms->getLoggedInUser();
$classname = $this->_dms->getClassname('documentfile');
foreach ($resArr as $row) { foreach ($resArr as $row) {
$file = new SeedDMS_Core_DocumentFile($row["id"], $this, $row["userID"], $row["comment"], $row["date"], $row["dir"], $row["fileType"], $row["mimeType"], $row["orgFileName"], $row["name"], $row["version"], $row["public"]); $file = new $classname($row["id"], $this, $row["userID"], $row["comment"], $row["date"], $row["dir"], $row["fileType"], $row["mimeType"], $row["orgFileName"], $row["name"], $row["version"], $row["public"]);
if($file->getAccessMode($user) >= M_READ) if($file->getAccessMode($user) >= M_READ)
array_push($this->_documentFiles[$hash], $file); array_push($this->_documentFiles[$hash], $file);
} }

View File

@ -313,6 +313,7 @@ class SeedDMS_Core_DatabaseAccess {
switch($this->_driver) { switch($this->_driver) {
case 'mysql': case 'mysql':
$this->_conn->exec('SET NAMES utf8'); $this->_conn->exec('SET NAMES utf8');
$this->_conn->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
/* Turn this on if you want strict checking of default values, etc. */ /* Turn this on if you want strict checking of default values, etc. */
/* $this->_conn->exec("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'"); */ /* $this->_conn->exec("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'"); */
/* The following is the default on Ubuntu 16.04 */ /* The following is the default on Ubuntu 16.04 */
@ -459,9 +460,15 @@ class SeedDMS_Core_DatabaseAccess {
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
} }
$this->_intransaction++; $this->_intransaction++;
if($this->_logfp) {
fwrite($this->_logfp, microtime()." START ".$htis->_intransaction."\n");
}
} /* }}} */ } /* }}} */
function rollbackTransaction() { /* {{{ */ function rollbackTransaction() { /* {{{ */
if($this->_logfp) {
fwrite($this->_logfp, microtime()." ROLLBACK ".$htis->_intransaction."\n");
}
if($this->_intransaction == 1) { if($this->_intransaction == 1) {
$this->_conn->rollBack(); $this->_conn->rollBack();
} }
@ -469,6 +476,9 @@ class SeedDMS_Core_DatabaseAccess {
} /* }}} */ } /* }}} */
function commitTransaction() { /* {{{ */ function commitTransaction() { /* {{{ */
if($this->_logfp) {
fwrite($this->_logfp, microtime()." COMMIT ".$htis->_intransaction."\n");
}
if($this->_intransaction == 1) { if($this->_intransaction == 1) {
$this->_conn->commit(); $this->_conn->commit();
} }

View File

@ -2049,6 +2049,8 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp()
<notes> <notes>
- SeedDMS_Core_Folder::addDocument() does rollback transaction propperly when setting document categories fail - SeedDMS_Core_Folder::addDocument() does rollback transaction propperly when setting document categories fail
- add $skiproot and $sep parameter to SeedDMS_Core_Folder::getFolderPathPlain() - add $skiproot and $sep parameter to SeedDMS_Core_Folder::getFolderPathPlain()
- turn off auto commit for mysql
- add class name for 'documentfile'
</notes> </notes>
</release> </release>
<release> <release>

View File

@ -182,7 +182,15 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
if(file_exists($path)) { if(file_exists($path)) {
$mimetype = $version->getMimeType(); $mimetype = $version->getMimeType();
$this->mimetype = $mimetype; $this->mimetype = $mimetype;
if(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) { if(is_callable($convcmd)) {
$result = $convcmd($document);
if($result['content']) {
self::setContent($result['content']);
} elseif($result['content'] === false) {
$this->errormsg = $result['errormsg'];
}
$this->cmd = $result['cmd'];
} elseif(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) {
if($service = $convcmd->getService($mimetype, 'text/plain')) { if($service = $convcmd->getService($mimetype, 'text/plain')) {
$content = $convcmd->convert($path, $mimetype, 'text/plain'); $content = $convcmd->convert($path, $mimetype, 'text/plain');
if($content) { if($content) {

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2021-05-10</date> <date>2023-01-03</date>
<time>08:55:43</time> <time>08:55:43</time>
<version> <version>
<release>1.1.17</release> <release>1.1.18</release>
<api>1.1.17</api> <api>1.1.18</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -23,7 +23,7 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
- close pipes in execWithTimeout(), also return exit code of command - IndexedDocument() accepts a callable for conversion to text
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -368,5 +368,21 @@ Index users with at least read access on the document
- add indexing of folders - add indexing of folders
</notes> </notes>
</release> </release>
<release>
<date>2021-05-10</date>
<time>08:55:43</time>
<version>
<release>1.1.17</release>
<api>1.1.17</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- close pipes in execWithTimeout(), also return exit code of command
</notes>
</release>
</changelog> </changelog>
</package> </package>

View File

@ -31,4 +31,9 @@ require_once('Preview/Previewer.php');
*/ */
require_once('Preview/PdfPreviewer.php'); require_once('Preview/PdfPreviewer.php');
/**
* @uses Preview/PdfPreviewer.php
*/
require_once('Preview/TxtPreviewer.php');
?> ?>

View File

@ -27,18 +27,6 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */ function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */
parent::__construct($previewDir, $timeout, $xsendfile); parent::__construct($previewDir, $timeout, $xsendfile);
$this->converters = array( $this->converters = array(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/vnd.oasis.opendocument.text' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'text/rtf' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/msword' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/vnd.ms-excel' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'text/plain' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/postscript' => "ps2pdf '%f' - > '%o'",
'image/jpeg' => "convert '%f' pdf:- > '%o'",
'image/png' => "convert '%f' pdf:- > '%o'",
'image/gif' => "convert '%f' pdf:- > '%o'",
'video/mp4' => "convert '%f[1-20]' pdf:- > '%o'",
); );
} /* }}} */ } /* }}} */
@ -128,9 +116,11 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
} elseif(isset($this->converters['*'])) { } elseif(isset($this->converters['*'])) {
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters['*']); $cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters['*']);
} }
if($cmd) { if($cmd) {
try { try {
self::execWithTimeout($cmd, $this->timeout); self::execWithTimeout($cmd, $this->timeout);
$new = true;
} catch(Exception $e) { } catch(Exception $e) {
$this->lastpreviewfile = ''; $this->lastpreviewfile = '';
return false; return false;
@ -139,6 +129,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
} }
return true; return true;
} }
$new = false;
return true; return true;
} /* }}} */ } /* }}} */

View File

@ -68,7 +68,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
case $dms->getClassname('documentcontent'): case $dms->getClassname('documentcontent'):
$target = $dir.'p'.$object->getVersion().'-'.$width; $target = $dir.'p'.$object->getVersion().'-'.$width;
break; break;
case "SeedDMS_Core_DocumentFile": case $dms->getClassname('documentfile'):
$target = $dir.'f'.$object->getID().'-'.$width; $target = $dir.'f'.$object->getID().'-'.$width;
break; break;
default: default:

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2021-10-16</date> <date>2023-01-02</date>
<time>09:49:39</time> <time>09:49:39</time>
<version> <version>
<release>1.4.0</release> <release>1.5.0</release>
<api>1.4.0</api> <api>1.5.0</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -23,8 +23,7 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
- use new conversion service if available - add previewer which creates txt
- createRawPreview() checks early if a converter exists
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -38,6 +37,9 @@
<file name="PdfPreviewer.php" role="php"> <file name="PdfPreviewer.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@package_version@" to="version" type="package-info" />
</file> </file>
<file name="TxtPreviewer.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
</dir> <!-- /Lucene --> </dir> <!-- /Lucene -->
<dir name="tests"> <dir name="tests">
</dir> <!-- /tests --> </dir> <!-- /tests -->
@ -49,7 +51,7 @@
<dependencies> <dependencies>
<required> <required>
<php> <php>
<min>4.3.0</min> <min>7.4.0</min>
</php> </php>
<pearinstaller> <pearinstaller>
<min>1.5.4</min> <min>1.5.4</min>
@ -488,5 +490,22 @@ update package description
preview image was actually created preview image was actually created
</notes> </notes>
</release> </release>
<release>
<date>2021-10-16</date>
<time>09:49:39</time>
<version>
<release>1.4.0</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- use new conversion service if available
- createRawPreview() checks early if a converter exists
</notes>
<release>
</changelog> </changelog>
</package> </package>

View File

@ -183,7 +183,15 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
if(file_exists($path)) { if(file_exists($path)) {
$mimetype = $version->getMimeType(); $mimetype = $version->getMimeType();
$this->mimetype = $mimetype; $this->mimetype = $mimetype;
if(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) { if(is_callable($convcmd)) {
$result = $convcmd($document);
if($result['content']) {
self::setContent($result['content']);
} elseif($result['content'] === false) {
$this->errormsg = $result['errormsg'];
}
$this->cmd = $result['cmd'];
} elseif(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) {
if($service = $convcmd->getService($mimetype, 'text/plain')) { if($service = $convcmd->getService($mimetype, 'text/plain')) {
$content = $convcmd->convert($path, $mimetype, 'text/plain'); $content = $convcmd->convert($path, $mimetype, 'text/plain');
if($content) { if($content) {

View File

@ -11,7 +11,7 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2022-12-09</date> <date>2023-01-03</date>
<time>08:57:44</time> <time>08:57:44</time>
<version> <version>
<release>1.0.18</release> <release>1.0.18</release>
@ -25,6 +25,7 @@
<notes> <notes>
- add optional parameter $order to SeedDMS_SQLiteFTS_Indexer::find() - add optional parameter $order to SeedDMS_SQLiteFTS_Indexer::find()
- add optional parameters $query and $col to SeedDMS_SQLiteFTS_Indexer::terms() - add optional parameters $query and $col to SeedDMS_SQLiteFTS_Indexer::terms()
- IndexedDocument() accepts a callable for conversion to text
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">

View File

@ -12,8 +12,6 @@
* @version Release: @package_version@ * @version Release: @package_version@
*/ */
require_once("inc.ClassNotificationService.php");
require_once("inc.ClassEmailNotify.php");
require_once("inc.ClassSession.php"); require_once("inc.ClassSession.php");
require_once("inc.ClassAccessOperation.php"); require_once("inc.ClassAccessOperation.php");
@ -109,8 +107,6 @@ if($settings->_useHomeAsRootFolder && !$user->isAdmin() && $user->getHomeFolder(
$role = $user->getRole(); $role = $user->getRole();
$dms->noReadForStatus = $role->getNoAccess(); $dms->noReadForStatus = $role->getNoAccess();
require_once('inc/inc.Notification.php');
/* Include additional language file for view /* Include additional language file for view
* This file must set $LANG[xx][] * This file must set $LANG[xx][]
*/ */

View File

@ -0,0 +1,73 @@
<?php
/* Middleware for authentication based on session */
class SeedDMS_Auth_Middleware_Session { /* {{{ */
private $container;
public function __construct($container) {
$this->container = $container;
}
/**
* Example middleware invokable class
*
* @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
* @param \Psr\Http\Message\ResponseInterface $response PSR7 response
* @param callable $next Next middleware
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function __invoke($request, $response, $next) {
// $this->container has the DI
$dms = $this->container->dms;
$settings = $this->container->config;
$logger = $this->container->logger;
$userobj = null;
if($this->container->has('userobj'))
$userobj = $this->container->userobj;
if($userobj) {
$response = $next($request, $response);
return $response;
}
$logger->log("Invoke middleware for method ".$request->getMethod()." on '".$request->getUri()->getPath()."'", PEAR_LOG_INFO);
require_once("inc/inc.ClassSession.php");
$session = new SeedDMS_Session($dms->getDb());
if (isset($_COOKIE["mydms_session"])) {
$dms_session = $_COOKIE["mydms_session"];
$logger->log("Session key: ".$dms_session, PEAR_LOG_DEBUG);
if(!$resArr = $session->load($dms_session)) {
/* Delete Cookie */
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot);
$logger->log("Session for id '".$dms_session."' has gone", PEAR_LOG_ERR);
return $response->withStatus(403);
}
/* Load user data */
$userobj = $dms->getUser($resArr["userID"]);
if (!is_object($userobj)) {
/* Delete Cookie */
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot);
if($settings->_enableGuestLogin) {
if(!($userobj = $dms->getUser($settings->_guestID)))
return $response->withStatus(403);
} else
return $response->withStatus(403);
}
if($userobj->isAdmin()) {
if($resArr["su"]) {
if(!($userobj = $dms->getUser($resArr["su"])))
return $response->withStatus(403);
}
}
$dms->setUser($userobj);
} else {
return $response->withStatus(403);
}
$this->container['userobj'] = $userobj;
$response = $next($request, $response);
return $response;
}
} /* }}} */

View File

@ -72,18 +72,25 @@ class SeedDMS_ConversionMgr {
* @param string $file name of file to convert * @param string $file name of file to convert
* @param string $from mimetype of input file * @param string $from mimetype of input file
* @param string $to mimetype of output file * @param string $to mimetype of output file
* @param string $target name of target file. If none is given the
* content of the converted document will be returned.
* @param array $params additional parameter needed for the conversion,
* e.g. the width of an image
* *
* @return boolean true on success, other false * @return boolean true on success, other false
*/ */
public function convert($file, $from, $to, $target=null, $params=array()) { public function convert($file, $from, $to, $target=null, $params=array()) { /* {{{ */
if(isset($this->services[$from][$to])) { if(isset($this->services[$from][$to])) {
$services = $this->services[$from][$to]; $services = $this->services[$from][$to];
for(end($services); key($services)!==null; prev($services)) { for(end($services); key($services)!==null; prev($services)) {
$service = current($services); $service = current($services);
$text = $service->convert($file, $target, $params); $text = $service->convert($file, $target, $params);
if($text !== false) if($text === false)
return false;
if($text)
return $text; return $text;
} }
} }
} return true;
} /* }}} */
} }

View File

@ -91,11 +91,11 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
} }
} /* }}} */ } /* }}} */
public function __construct($from, $to, $cmd) { public function __construct($from, $to, $cmd, $timeout=5) {
$this->from = $from; $this->from = $from;
$this->to = $to; $this->to = $to;
$this->cmd = $cmd; $this->cmd = $cmd;
$this->timeout = 5; $this->timeout = ((int) $timeout) ? (int) $timeout : 5;
} }
public function getInfo() { public function getInfo() {

View File

@ -54,6 +54,7 @@ class SeedDMS_FulltextService {
$this->services = array(); $this->services = array();
$this->converters = array(); $this->converters = array();
$this->conversionmgr = null; $this->conversionmgr = null;
$this->previewer = null;
$this->logger = null; $this->logger = null;
$this->maxsize = 0; $this->maxsize = 0;
$this->index = null; $this->index = null;
@ -93,6 +94,73 @@ class SeedDMS_FulltextService {
$this->cmdtimeout = $timeout; $this->cmdtimeout = $timeout;
} }
public function setPreviewer($previewer) {
$this->previewer = $previewer;
}
/**
* Returns callback function to convert a document into plain text
*
* This variant just uses the conversion manager and does not
* cache the converted document
*/
public function getConversionCallback() { /* {{{ */
$conversionmgr = $this->conversionmgr;
return function($object) use ($conversionmgr) {
$result = ['content'=>false, 'cmd'=>'', 'errormsg'=>''];
if(!$conversionmgr)
return $result;
if($object->isType('document')) {
$dms = $object->getDMS();
$version = $object->getLatestContent();
$mimetype = $version->getMimeType();
$path = $dms->contentDir . $version->getPath();
if(file_exists($path)) {
if($service = $conversionmgr->getService($mimetype, 'text/plain')) {
$content = $conversionmgr->convert($path, $mimetype, 'text/plain');
if($content) {
$result['content'] = $content;
} elseif($content === false) {
$result['errormsg'] = 'Conversion failed';
}
$result['cmd'] = get_class($service);
} else {
$result['cmd'] = 'No service to convert '.$mimetype.' to text/plain';
}
}
}
return $result;
};
} /* }}} */
/**
* Returns callback function to convert a document into plain text
*
* This variant just uses the text previewer which
* caches the converted document
*/
public function getConversionWithPreviewCallback() { /* {{{ */
$previewer = $this->previewer;
return function($object) use ($previewer) {
$result = ['content'=>false, 'cmd'=>'', 'errormsg'=>''];
if($object->isType('document')) {
$dms = $object->getDMS();
$version = $object->getLatestContent();
if($previewer->createPreview($version)) {
if($previewer->hasPreview($version)) {
$filename = $previewer->getFileName($version).'.txt';
$result['content'] = file_get_contents($filename);
$result['cmd'] = 'previewer '.$previewer->getFileSize($version);
}
} else {
$result['cmd'] = 'previewer';
$result['errormsg'] = 'Creating preview failed';
}
}
return $result;
};
} /* }}} */
/** /**
* Return an indexable document from the given document or folder * Return an indexable document from the given document or folder
* *
@ -108,7 +176,8 @@ class SeedDMS_FulltextService {
$nocontent = $object->getLatestContent()->getFileSize() > $this->maxsize && $this->maxsize && !$forceupdate; $nocontent = $object->getLatestContent()->getFileSize() > $this->maxsize && $this->maxsize && !$forceupdate;
else else
$nocontent = true; $nocontent = true;
return new $this->services[0]['IndexedDocument']($object->getDMS(), $object, $this->conversionmgr ? $this->conversionmgr : $this->converters, $nocontent, $this->cmdtimeout); $convcallback = $this->getConversionWithPreviewCallback();
return new $this->services[0]['IndexedDocument']($object->getDMS(), $object, $convcallback /*$this->conversionmgr ? $this->conversionmgr : $this->converters*/, $nocontent, $this->cmdtimeout);
} }
/** /**

View File

@ -5,19 +5,19 @@ $conversionmgr = new SeedDMS_ConversionMgr();
if(!empty($settings->_converters['preview'])) { if(!empty($settings->_converters['preview'])) {
foreach($settings->_converters['preview'] as $mimetype=>$cmd) { foreach($settings->_converters['preview'] as $mimetype=>$cmd) {
$conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'image/png', $cmd))->setLogger($logger); $conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'image/png', $cmd), $settings->_cmdTimeout)->setLogger($logger);
} }
} }
if(!empty($settings->_converters['pdf'])) { if(!empty($settings->_converters['pdf'])) {
foreach($settings->_converters['pdf'] as $mimetype=>$cmd) { foreach($settings->_converters['pdf'] as $mimetype=>$cmd) {
$conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'application/pdf', $cmd))->setLogger($logger); $conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'application/pdf', $cmd, $settings->_cmdTimeout))->setLogger($logger);
} }
} }
if(!empty($settings->_converters['fulltext'])) { if(!empty($settings->_converters['fulltext'])) {
foreach($settings->_converters['fulltext'] as $mimetype=>$cmd) { foreach($settings->_converters['fulltext'] as $mimetype=>$cmd) {
$conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'text/plain', $cmd))->setLogger($logger); $conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'text/plain', $cmd, $settings->_cmdTimeout))->setLogger($logger);
} }
} }

View File

@ -70,3 +70,7 @@ require_once('inc/inc.Tasks.php');
require_once("inc.ConversionInit.php"); require_once("inc.ConversionInit.php");
require_once('inc.FulltextInit.php'); require_once('inc.FulltextInit.php');
require_once('inc.AuthenticationInit.php'); require_once('inc.AuthenticationInit.php');
require_once("inc.ClassNotificationService.php");
require_once("inc.ClassEmailNotify.php");
require_once('inc.Notification.php');

View File

@ -46,5 +46,10 @@ if($settings->_enableFullSearch) {
$fulltextservice->setConversionMgr($conversionmgr); $fulltextservice->setConversionMgr($conversionmgr);
$fulltextservice->setMaxSize($settings->_maxSizeForFullText); $fulltextservice->setMaxSize($settings->_maxSizeForFullText);
$fulltextservice->setCmdTimeout($settings->_cmdTimeout); $fulltextservice->setCmdTimeout($settings->_cmdTimeout);
require_once("SeedDMS/Preview.php");
$txtpreviewer = new SeedDMS_Preview_TxtPreviewer($settings->_cacheDir, $settings->_cmdTimeout, $settings->_enableXsendfile);
if($conversionmgr)
$txtpreviewer->setConversionMgr($conversionmgr);
$fulltextservice->setPreviewer($txtpreviewer);
} }

View File

@ -53,11 +53,19 @@ if(true) {
}; };
}; };
$app = new \Slim\App($c); $app = new \Slim\App($c);
$container = $app->getContainer();
$container['dms'] = $dms;
$container['config'] = $settings;
$container['conversionmgr'] = $conversionmgr;
$container['logger'] = $logger;
$container['fulltextservice'] = $fulltextservice;
$container['notifier'] = $notifier;
$container['authenticator'] = $authenticator;
if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) { foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
if (method_exists($hookObj, 'addRoute')) { if (method_exists($hookObj, 'addRoute')) {
$hookObj->addRoute(array('dms'=>$dms, 'app'=>$app, 'settings'=>$settings)); $hookObj->addRoute(array('dms'=>$dms, 'app'=>$app, 'settings'=>$settings, 'conversionmgr'=>$conversionmgr, 'authenticator'=>$authenticator, 'fulltextservice'=>$fulltextservice, 'logger'=>$logger));
// } else { // } else {
// include("inc/inc.Authentication.php"); // include("inc/inc.Authentication.php");
// if (method_exists($hookObj, 'addRouteAfterAuthentication')) { // if (method_exists($hookObj, 'addRouteAfterAuthentication')) {

View File

@ -1079,9 +1079,9 @@ switch($command) {
$ires = $index->addDocument($idoc); $ires = $index->addDocument($idoc);
header('Content-Type: application/json'); header('Content-Type: application/json');
if(false === $ires) { if(false === $ires) {
echo json_encode(array('success'=>false, 'message'=>getMLText('error_document_indexed'), 'data'=>$prefix.$object->getID(), 'mimetype'=>$idoc->getMimeType(), 'cmd'=>$idoc->getCmd())); echo json_encode(array('success'=>false, 'message'=>getMLText('error_document_indexed', ['name'=>$object->getName()]), 'data'=>$prefix.$object->getID(), 'mimetype'=>$idoc->getMimeType(), 'cmd'=>$idoc->getCmd()));
} else { } else {
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_indexed'), 'data'=>$prefix.$object->getID(), 'cmd'=>$idoc->getCmd())); echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_indexed', ['name'=>$object->getName()]), 'data'=>$prefix.$object->getID(), 'cmd'=>$idoc->getCmd()));
} }
} else { } else {
header('Content-Type: application/json'); header('Content-Type: application/json');

View File

@ -100,7 +100,7 @@ if($view) {
$view->setParam('offset', $offset); $view->setParam('offset', $offset);
$view->setParam('limit', $limit); $view->setParam('limit', $limit);
$view->setParam('onepage', $settings->_onePageMode); // do most navigation by reloading areas of pages with ajax $view->setParam('onepage', $settings->_onePageMode); // do most navigation by reloading areas of pages with ajax
$view->setParam('currenttab', 'folderinfo'); $view->setParam('currenttab', isset($_GET['currenttab']) ? $_GET['currenttab'] : "folderinfo");
$view($_GET); $view($_GET);
exit; exit;
} }

View File

@ -2619,17 +2619,17 @@ class RestapiAuth { /* {{{ */
// $this->container has the DI // $this->container has the DI
$dms = $this->container->dms; $dms = $this->container->dms;
$settings = $this->container->config; $settings = $this->container->config;
$logger = $this->container->logger; $logger = $this->container->logger;
$userobj = null; $userobj = null;
if($this->container->has('userobj')) if($this->container->has('userobj'))
$userobj = $this->container->userobj; $userobj = $this->container->userobj;
if($userobj) { if($userobj) {
$response = $next($request, $response); $response = $next($request, $response);
return $response; return $response;
} }
$logger->log("Invoke middleware for method ".$request->getMethod()." on '".$request->getUri()->getPath()."'", PEAR_LOG_INFO); $logger->log("Invoke middleware for method ".$request->getMethod()." on '".$request->getUri()->getPath()."'", PEAR_LOG_INFO);
$logger->log("Access with method ".$request->getMethod()." on '".$request->getUri()->getPath()."'".(isset($this->container->environment['HTTP_ORIGIN']) ? " with origin ".$this->container->environment['HTTP_ORIGIN'] : ''), PEAR_LOG_INFO); $logger->log("Access with method ".$request->getMethod()." on '".$request->getUri()->getPath()."'".(isset($this->container->environment['HTTP_ORIGIN']) ? " with origin ".$this->container->environment['HTTP_ORIGIN'] : ''), PEAR_LOG_INFO);
if($settings->_apiOrigin && isset($this->container->environment['HTTP_ORIGIN'])) { if($settings->_apiOrigin && isset($this->container->environment['HTTP_ORIGIN'])) {
$logger->log("Checking origin", PEAR_LOG_DEBUG); $logger->log("Checking origin", PEAR_LOG_DEBUG);

179
utils/delete.php Normal file
View File

@ -0,0 +1,179 @@
<?php
if(isset($_SERVER['SEEDDMS_HOME'])) {
ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path'));
$myincpath = $_SERVER['SEEDDMS_HOME'];
} else {
ini_set('include_path', dirname(realpath($argv[0])). PATH_SEPARATOR .ini_get('include_path'));
$myincpath = dirname(realpath($argv[0]));
}
function usage() { /* {{{ */
echo "Usage:".PHP_EOL;
echo " seeddms-delete [--config <file>] [-h] [-v] -f <folder id> -e <folder id> -d <document id>".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program deletes a folder or document.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config: set alternative config file.".PHP_EOL;
echo " -f <folder id>: id of folder to be deleted".PHP_EOL;
echo " -e <folder id>: id of folder to be emptied".PHP_EOL;
echo " -d <document id>: id of document to be deleted".PHP_EOL;
echo " -u <user>: login name of user".PHP_EOL;
echo PHP_EOL;
echo "If the user is not given the user with id 1 will be used.".PHP_EOL;
echo "The options -d, -e and -f can be passed multiple times or the option value".PHP_EOL;
echo "can be a comma separated list of ids.".PHP_EOL;
} /* }}} */
$version = "0.0.1";
$shortoptions = "e:f:d:u:hv";
$longoptions = array('help', 'version', 'config:');
if(false === ($options = getopt($shortoptions, $longoptions))) {
usage();
exit(0);
}
/* Print help and exit */
if(isset($options['h']) || isset($options['help'])) {
usage();
exit(0);
}
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version.PHP_EOL;
exit(0);
}
/* Set alternative config file */
if(isset($options['config'])) {
define('SEEDDMS_CONFIG_FILE', $options['config']);
} elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) {
define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']);
}
/* Set folders to be deleted */
$folderids = array();
if(isset($options['f'])) {
if(is_string($options['f']))
$folderids = explode(',', $options['f']);
else
$folderids = $options['f'];
}
/* Set folders to be emptied */
$emptyids = array();
if(isset($options['e'])) {
if(is_string($options['e']))
$emptyids = explode(',', $options['e']);
else
$emptyids = $options['e'];
}
/* Set documents to be deleted */
$documentids = array();
if(isset($options['d'])) {
if(is_string($options['d']))
$documentids = explode(',', $options['d']);
else
$documentids = $options['d'];
}
if(!$documentids && !$folderids && !$emptyids) {
echo "Neither folder ids nor document ids were given".PHP_EOL;
usage();
exit(1);
}
$username = '';
if(isset($options['u'])) {
$username = $options['u'];
}
include($myincpath."/inc/inc.Settings.php");
include($myincpath."/inc/inc.Init.php");
include($myincpath."/inc/inc.Extension.php");
include($myincpath."/inc/inc.DBInit.php");
include($myincpath."/inc/inc.ClassNotificationService.php");
include($myincpath."/inc/inc.Notification.php");
include($myincpath."/inc/inc.ClassController.php");
/* Create a global user object {{{ */
if($username) {
if(!($user = $dms->getUserByLogin($username))) {
echo "No such user '".$username."'.";
exit;
}
} else
$user = $dms->getUser(1);
$dms->setUser($user);
/* }}} */
foreach($folderids as $folderid) {
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
echo "Could not find folder with id ".$folderid.PHP_EOL;
} else {
if ($folder->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights on folder with id ".$folderid.PHP_EOL;
} else {
$controller = Controller::factory('RemoveFolder', array('dms'=>$dms, 'user'=>$user));
$controller->setParam('folder', $folder);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$document = $controller->run()) {
echo "Could not remove folder with id ".$folderid.PHP_EOL;
} else {
echo "Folder with id ".$folderid." removed.".PHP_EOL;
}
}
}
}
foreach($emptyids as $folderid) {
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
echo "Could not find folder with id ".$folderid.PHP_EOL;
}
if ($folder->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights on folder with id ".$folderid.PHP_EOL;
}
$controller = Controller::factory('EmptyFolder', array('dms'=>$dms, 'user'=>$user));
$controller->setParam('folder', $folder);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$document = $controller->run()) {
echo "Could not empty folder with id ".$folderid.PHP_EOL;
} else {
echo "Folder with id ".$folderid." emptied.".PHP_EOL;
}
}
foreach($documentids as $documentid) {
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
echo "Could not find specified document with id ".$documentid.PHP_EOL;
}
if ($document->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights on document with id ".$documentid.PHP_EOL;
}
$controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user));
$controller->setParam('document', $document);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$document = $controller->run()) {
echo "Could not remove document with id ".$documentid.PHP_EOL;
} else {
echo "Document with id ".$documentid." removed.".PHP_EOL;
}
}

304
utils/expireddocs.php Normal file
View File

@ -0,0 +1,304 @@
<?php
if(isset($_SERVER['SEEDDMS_HOME'])) {
ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path'));
$myincpath = $_SERVER['SEEDDMS_HOME'];
} else {
ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path'));
$myincpath = dirname($argv[0]);
}
function usage() { /* {{{ */
echo "Usage:".PHP_EOL;
echo " seeddms-expireddocs [--config <file>] [-u <user>] [-h] [-v] [-t] [-q] [-o] [-f <email>] [-u <user>] [-w] [-b <base>] [-c] -d <days> -D <days>".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " Check for files which will expire in the next days and inform the".PHP_EOL;
echo " the owner and all users watching the document.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config=<file>: set alternative config file.".PHP_EOL;
echo " -u <user>: login name of user".PHP_EOL;
echo " -w: send mail also to all users watching the document".PHP_EOL;
echo " -c: list also categories for each document".PHP_EOL;
echo " -f <email>: set From field in notification mail".PHP_EOL;
echo " -b <base>: set base for links in html email. The final link will be".PHP_EOL;
echo " <base><httpRoot>out/out.ViewDocument.php. The default is".PHP_EOL;
echo " http://localhost".PHP_EOL;
echo " -d <days>: check till n days in the future (default 14). Days always".PHP_EOL.
" start at 00:00:00 and end at 23:59:59. A value of '1' means today.".PHP_EOL;
" '-d 2' will search for documents expiring today or tomorrow.".PHP_EOL;
echo " -D <days>: start checking in n days in the future (default 0). This value".PHP_EOL.
" must be less then -d. A value of 0 means to start checking today.".PHP_EOL.
" Any positive number will start checking in n days.".PHP_EOL.
" A negative number will look backwards in time.".PHP_EOL.
" '-d 10 -D 5' will search for documents expiring in 5 to 10 days.".PHP_EOL.
" '-d 10 -D -5' will search for documents which have expired in the last 5 days".PHP_EOL.
" or will expire in the next 10 days.".PHP_EOL;
echo " -o: list obsolete documents (default: do not list)".PHP_EOL;
echo " -t: run in test mode (will not send any mails)".PHP_EOL;
echo " -q: be quite (just output error messages)".PHP_EOL;
} /* }}} */
$version = "0.0.2";
$tableformat = "%-60s %-14s";
$tableformathtml = "<tr><td>%s</td><td>%s</td></tr>";
$baseurl = "http://localhost/";
$mailfrom = "uwe@steinman.cx";
$shortoptions = "u:d:D:f:b:wtqhvo";
$longoptions = array('help', 'version', 'config:');
if(false === ($options = getopt($shortoptions, $longoptions))) {
usage();
exit(0);
}
/* Print help and exit */
if(isset($options['h']) || isset($options['help'])) {
usage();
exit(0);
}
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version.PHP_EOL;
exit(0);
}
/* Set alternative config file */
if(isset($options['config'])) {
define('SEEDDMS_CONFIG_FILE', $options['config']);
} elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) {
define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']);
}
include($myincpath."/inc/inc.Settings.php");
include($myincpath."/inc/inc.Utils.php");
include($myincpath."/inc/inc.Init.php");
include($myincpath."/inc/inc.Language.php");
include($myincpath."/inc/inc.Extension.php");
include($myincpath."/inc/inc.DBInit.php");
$LANG['de_DE']['daylyDigestMail'] = 'Tägliche Benachrichtigungsmail';
$LANG['en_GB']['daylyDigestMail'] = 'Dayly digest mail';
$LANG['de_DE']['docsExpiringInNDays'] = 'Dokumente, die in den nächsten [days] Tagen ablaufen';
$LANG['en_GB']['docsExpiringInNDays'] = 'Documents expiring in the next [days] days';
$LANG['de_DE']['docsExpiringBetween'] = 'Dokumente, die zwischen dem [start] und [end] ablaufen';
$LANG['en_GB']['docsExpiringBetween'] = 'Documents which expire between [start] and [end]';
require_once('Mail.php');
require_once('Mail/mime.php');
$usernames = array();
if(isset($options['u'])) {
$usernames = explode(',', $options['u']);
}
$informwatcher = false;
if(isset($options['w'])) {
$informwatcher = true;
}
$showcats = false;
if(isset($options['c'])) {
$showcats = true;
$tableformathtml = "<tr><td>%s</td><td>%s</td><td>%s</td></tr>";
}
$days = 14;
if(isset($options['d'])) {
$days = (int) $options['d'];
}
$enddays = 0;
if(isset($options['D'])) {
$enddays = (int) $options['D'];
}
if($enddays >= $days) {
echo "Value of -D must be less then value of -d".PHP_EOL;
exit(1);
}
if(isset($options['f'])) {
$mailfrom = trim($options['f']);
}
if(isset($options['b'])) {
$baseurl = trim($options['b']);
}
$showobsolete = false;
if(isset($options['o'])) {
$showobsolete = true;
}
$dryrun = false;
if(isset($options['t'])) {
$dryrun = true;
echo "Running in test mode will not send any mail.".PHP_EOL;
}
$quite = false;
if(isset($options['q'])) {
$quite = true;
}
$startts = strtotime("midnight", time());
if(!$quite)
echo "Checking for documents expiring between ".getLongReadableDate($startts+$enddays*86400)." and ".getLongReadableDate($startts+$days*86400-1).PHP_EOL;
$users = array();
if(!$usernames) {
$users = $dms->getAllUsers();
} else {
/* Create a global user object */
foreach($usernames as $username) {
if(!$user = $dms->getUserByLogin($username)) {
echo "No such user with name '".$username."'".PHP_EOL;
exit(1);
}
$users[] = $user;
}
}
if (!$db->createTemporaryTable("ttstatid") || !$db->createTemporaryTable("ttcontentid")) {
echo getMLText("internal_error_exit").PHP_EOL;
exit;
}
foreach($users as $user) {
$groups = $user->getGroups();
$groupids = array();
foreach($groups as $group)
$groupids[] = $group->getID();
$sendmail = false; /* Set to true if there is something to report */
$body = "";
$bodyhtml = "<html>".PHP_EOL."<head>".PHP_EOL."<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />".PHP_EOL."<title>SeedDMS: ".getMLText('daylyDigestMail', array(), "", $user->getLanguage())."</title>".PHP_EOL."<base href=\"".$baseurl.$settings->_httpRoot."\" />".PHP_EOL."</head>".PHP_EOL."<body>".PHP_EOL."";
/*
$queryStr = "SELECT `tblDocuments`.* FROM `tblDocuments`".
"WHERE `tblDocuments`.`owner` = '".$user->getID()."' ".
"AND `tblDocuments`.`expires` < '".($startts + $days*86400)."' ".
"AND `tblDocuments`.`expires` > '".($startts)."'";
*/
$queryStr = "SELECT DISTINCT a.*, `tblDocumentStatusLog`.* FROM `tblDocuments` a ".
"LEFT JOIN `ttcontentid` ON `ttcontentid`.`document` = `a`.`id` ".
"LEFT JOIN `tblDocumentContent` ON `a`.`id` = `tblDocumentContent`.`document` AND `tblDocumentContent`.`version` = `ttcontentid`.`maxVersion` ".
"LEFT JOIN `tblNotify` b ON a.`id`=b.`target` ".
"LEFT JOIN `tblDocumentStatus` ON `tblDocumentStatus`.`documentID` = `tblDocumentContent`.`document` AND `tblDocumentContent`.`version` = `tblDocumentStatus`.`version` ".
"LEFT JOIN `ttstatid` ON `ttstatid`.`statusID` = `tblDocumentStatus`.`statusID` ".
"LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusLogID` = `ttstatid`.`maxLogID` ".
"WHERE (a.`owner` = '".$user->getID()."' ".
($informwatcher ? " OR ((b.`userID` = '".$user->getID()."' ".
($groupids ? "or b.`groupID` in (".implode(',', $groupids).")" : "").") ".
"AND b.`targetType` = 2) " : "").
") AND a.`expires` < '".($startts + $days*86400)."' ".
"AND a.`expires` > '".($startts + $enddays*86400)."' ";
if(!$showobsolete)
$queryStr .= "AND `tblDocumentStatusLog`.`status` != -2";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr) {
echo getMLText("internal_error_exit").PHP_EOL;
exit;
}
$body .= "==== ";
$body .= getMLText('docsExpiringBetween', array('start'=>getReadableDate($startts + ($enddays)*86400), 'end'=>getReadableDate($startts + ($days)*86400)), "", $user->getLanguage()).PHP_EOL;
$body .= "==== ";
$body .= $user->getFullname();
$body .= PHP_EOL.PHP_EOL;
$bodyhtml .= "<h2>";
$bodyhtml .= getMLText('docsExpiringBetween', array('start'=>getReadableDate($startts + ($enddays)*86400), 'end'=>getReadableDate($startts + ($days)*86400)), "", $user->getLanguage()).PHP_EOL;
$bodyhtml .= "</h2>".PHP_EOL;
$bodyhtml .= "<h3>";
$bodyhtml .= $user->getFullname();
$bodyhtml .= "</h3>".PHP_EOL;
if (count($resArr)>0) {
$sendmail = true;
$body .= sprintf($tableformat.PHP_EOL, getMLText("name", array(), "", $user->getLanguage()), getMLText("expires", array(), "", $user->getLanguage()));
$body .= "---------------------------------------------------------------------------------".PHP_EOL;
$bodyhtml .= "<table>".PHP_EOL;
if($showcats)
$bodyhtml .= sprintf($tableformathtml.PHP_EOL, getMLText("name", array(), "", $user->getLanguage()), getMLText("categories", array(), "", $user->getLanguage()), getMLText("expires", array(), "", $user->getLanguage()));
else
$bodyhtml .= sprintf($tableformathtml.PHP_EOL, getMLText("name", array(), "", $user->getLanguage()), getMLText("expires", array(), "", $user->getLanguage()));
foreach ($resArr as $res) {
if($doc = $dms->getDocument((int) $res['id'])) {
$catnames = array();
if($cats = $doc->getCategories()) {
foreach($cats as $cat)
$catnames[] = $cat->getName();
}
}
$body .= sprintf($tableformat.PHP_EOL, $res["name"], (!$res["expires"] ? "-":getReadableDate($res["expires"])));
if($showcats)
$body .= getMLText("categories", array(), "", $user->getLanguage()).": ".implode(', ', $catnames).PHP_EOL;
if($showcats)
$bodyhtml .= sprintf($tableformathtml.PHP_EOL, '<a href="out/out.ViewDocument.php?documentid='.$res["id"].'">'.htmlspecialchars($res["name"]).'</a>', implode(', ', $catnames), (!$res["expires"] ? "-":getReadableDate($res["expires"])));
else
$bodyhtml .= sprintf($tableformathtml.PHP_EOL, '<a href="out/out.ViewDocument.php?documentid='.$res["id"].'">'.htmlspecialchars($res["name"]).'</a>', (!$res["expires"] ? "-":getReadableDate($res["expires"])));
}
$bodyhtml .= "</table>".PHP_EOL;
} else {
$body .= getMLText("no_docs_to_look_at", array(), "", $user->getLanguage()).PHP_EOL.PHP_EOL;
$bodyhtml .= "<p>".getMLText("no_docs_to_look_at", array(), "", $user->getLanguage())."</p>".PHP_EOL.PHP_EOL;
}
if($sendmail) {
if($user->getEmail()) {
if(!$quite) {
echo "Send mail to ".$user->getLogin()." <".$user->getEmail().">".PHP_EOL;
echo $body;
echo "----------------------------".PHP_EOL.PHP_EOL.PHP_EOL;
echo $bodyhtml;
}
if(!$dryrun) {
$mime = new Mail_mime(array('eol' => PHP_EOL));
$mime->setTXTBody($body);
$mime->setHTMLBody($bodyhtml);
$body = $mime->get(array(
'text_encoding'=>'8bit',
'html_encoding'=>'8bit',
'head_charset'=>'utf-8',
'text_charset'=>'utf-8',
'html_charset'=>'utf-8'
));
$hdrs = $mime->headers(array('From' => $mailfrom, 'Subject' => 'SeedDMS: '.getMLText('daylyDigestMail', array(), "", $user->getLanguage()), 'Content-Type' => 'text/plain; charset=UTF-8'));
$mail_params = array();
if($settings->_smtpServer) {
$mail_params['host'] = $settings->_smtpServer;
if($settings->smtpPort) {
$mail_params['port'] = $settings->_smtpPort;
}
if($settings->smtpUser) {
$mail_params['auth'] = true;
$mail_params['username'] = $settings->_smtpUser;
$mail_params['password'] = $settings->_smtpPassword;
}
$mail = Mail::factory('smtp', $mail_params);
} else {
$mail = Mail::factory('mail');
}
$mail->send($user->getEmail(), $hdrs, $body);
}
} else {
if(!$quite) {
echo "User ".$user->getLogin()." has no email".PHP_EOL;
}
}
} else {
if(!$quite) {
echo "No notification for user ".$user->getLogin()." needed".PHP_EOL;
}
}
}

215
utils/importfs.php Normal file
View File

@ -0,0 +1,215 @@
<?php
if(isset($_SERVER['SEEDDMS_HOME'])) {
ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path'));
$myincpath = $_SERVER['SEEDDMS_HOME'];
} else {
ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path'));
$myincpath = dirname($argv[0]);
}
function usage() { /* {{{ */
echo "Usage:".PHP_EOL;
echo " seeddms-importfs [--config <file>] [-h] [-v] -F <folder id> -d <dirname>".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program uploads a directory recursively into a folder of SeedDMS.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config: set alternative config file.".PHP_EOL;
echo " --user: use this user for accessing seeddms.".PHP_EOL;
echo " --exclude: exlude files/directories by name (defaults to .svn, .gitignore).".PHP_EOL;
echo " This must be just the file or directory without the path.".PHP_EOL;
echo " --filemtime: take over modification time from file.".PHP_EOL;
echo " --foldermtime: take over modification time from folder.".PHP_EOL;
echo " --basefolder: creates the base folder".PHP_EOL;
echo " -F <folder id>: id of folder the file is uploaded to".PHP_EOL;
echo " -d <dirname>: upload this directory".PHP_EOL;
echo " -e <encoding>: encoding used by filesystem (defaults to iso-8859-1)".PHP_EOL;
} /* }}} */
$version = "0.0.1";
$shortoptions = "d:F:e:hv";
$longoptions = array('help', 'version', 'user:', 'basefolder', 'filemtime', 'foldermtime', 'exclude:', 'config:');
if(false === ($options = getopt($shortoptions, $longoptions))) {
usage();
exit(0);
}
/* Print help and exit */
if(!$options || isset($options['h']) || isset($options['help'])) {
usage();
exit(0);
}
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version.PHP_EOL;
exit(0);
}
/* Set encoding of names in filesystem */
$fsencoding = 'iso-8859-1';
if(isset($options['e'])) {
$fsencoding = $options['e'];
}
/* Set alternative config file */
if(isset($options['config'])) {
define('SEEDDMS_CONFIG_FILE', $options['config']);
} elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) {
define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']);
}
$excludefiles = array('.', '..');
if(isset($options['exclude'])) {
if(is_array($options['exclude']))
$excludefiles = array_merge($excludefiles, $options['exclude']);
else
$excludefiles[] = $options['exclude'];
} else {
$excludefiles[] = '.svn';
$excludefiles[] = '.gitignore';
}
if(isset($options['user'])) {
$userlogin = $options['user'];
} else {
echo "Missing user".PHP_EOL;
usage();
exit(1);
}
/* check if base folder shall be created */
$createbasefolder = false;
if(isset($options['basefolder'])) {
$createbasefolder = true;
}
/* check if modification time shall be taken over */
$filemtime = false;
if(isset($options['filemtime'])) {
$filemtime = true;
}
$foldermtime = false;
if(isset($options['foldermtime'])) {
$foldermtime = true;
}
if(isset($settings->_extraPath))
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
if(isset($options['F'])) {
$folderid = (int) $options['F'];
} else {
echo "Missing folder ID".PHP_EOL;
usage();
exit(1);
}
$dirname = '';
if(isset($options['d'])) {
$dirname = $options['d'];
} else {
echo "Missing import directory".PHP_EOL;
usage();
exit(1);
}
include($myincpath."/inc/inc.Settings.php");
include($myincpath."/inc/inc.Utils.php");
include($myincpath."/inc/inc.Init.php");
include($myincpath."/inc/inc.Language.php");
include($myincpath."/inc/inc.Extension.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;
/* Create a global user object */
if(!($user = $dms->getUserByLogin($userlogin))) {
echo "User with login '".$userlogin."' does not exists.";
exit;
}
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
echo "Could not find specified folder".PHP_EOL;
exit(1);
}
if ($folder->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights".PHP_EOL;
exit(1);
}
function import_folder($dirname, $folder, $filemtime, $foldermtime) {
global $user, $excludefiles, $fsencoding;
$d = dir($dirname);
$sequence = 1;
while(false !== ($entry = $d->read())) {
$path = $dirname.'/'.$entry;
if(!in_array($entry, $excludefiles)) {
$name = iconv($fsencoding, 'utf-8', basename($path));
if(is_file($path)) {
$filetmp = $path;
$reviewers = array();
$approvers = array();
$comment = '';
$version_comment = '';
$reqversion = 1;
$expires = false;
$keywords = '';
$categories = array();
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $path);
$lastDotIndex = strrpos($name, ".");
if (is_bool($lastDotIndex) && !$lastDotIndex) $filetype = ".";
else $filetype = substr($name, $lastDotIndex);
echo $mimetype." - ".$filetype." - ".$path.PHP_EOL;
$res = $folder->addDocument($name, $comment, $expires, $user, $keywords,
$categories, $filetmp, $name,
$filetype, $mimetype, $sequence, $reviewers,
$approvers, $reqversion, $version_comment);
if (is_bool($res) && !$res) {
echo "Could not add document to folder".PHP_EOL;
exit(1);
}
if($filemtime) {
$newdoc = $res[0];
$newdoc->setDate(filemtime($path));
$lc = $newdoc->getLatestContent();
$lc->setDate(filemtime($path));
}
set_time_limit(1200);
} elseif(is_dir($path)) {
$newfolder = $folder->addSubFolder($name, '', $user, $sequence);
if($foldermtime) {
$newfolder->setDate(filemtime($path));
}
import_folder($path, $newfolder, $filemtime, $foldermtime);
}
$sequence++;
}
}
}
if($createbasefolder) {
if($newfolder = $folder->addSubFolder(basename($dirname), '', $user, 1)) {
if($foldermtime) {
$newfolder->setDate(filemtime($dirname));
}
import_folder($dirname, $newfolder, $filemtime, $foldermtime);
}
} else {
import_folder($dirname, $folder, $filemtime, $foldermtime);
}

9
utils/seeddms-delete Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -z "${SEEDDMS_HOME}" ]; then
parentdir=$(dirname "$0")
export SEEDDMS_HOME=$(dirname "$parentdir")
fi
exec php -f "${SEEDDMS_HOME}/utils/delete.php" -- "${@}"

8
utils/seeddms-expireddocs Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
if [ -z "${SEEDDMS_HOME}" ]; then
parentdir=$(dirname "$0")
export SEEDDMS_HOME=$(dirname "$parentdir")
fi
php -f ${SEEDDMS_HOME}/utils/expireddocs.php -- "${@}"

7
utils/seeddms-importfs Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
if [ -z "${SEEDDMS_HOME}" ]; then
parentdir=$(dirname "$0")
export SEEDDMS_HOME=$(dirname "$parentdir")
fi
php -f ${SEEDDMS_HOME}/utils/importfs.php -- "$@"

View File

@ -35,8 +35,8 @@ class SeedDMS_View_ChangePassword extends SeedDMS_Theme_Style {
header('Content-Type: application/javascript; charset=UTF-8'); header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('js_form_error', 'js_form_errors')); parent::jsTranslations(array('js_form_error', 'js_form_errors'));
?> ?>
document.form1.newpassword.focus();
$(document).ready(function() { $(document).ready(function() {
$('#newpassword').focus();
$("#form1").validate({ $("#form1").validate({
rules: { rules: {
newpasswordrepeat: { newpasswordrepeat: {
@ -78,7 +78,16 @@ $(document).ready(function() {
$this->contentContainerStart(); $this->contentContainerStart();
$this->formField( $this->formField(
getMLText("password"), getMLText("password"),
'<input class="pwd form-control" type="password" rel="strengthbar" name="newpassword" id="newpassword" required="required">' array(
'element'=>'input',
'type'=>'password',
'id'=>'newpassword',
'name'=>'newpassword',
'autocomplete'=>'off',
'required'=>true,
'class'=>'pwd',
'attributes'=>[['rel', 'strengthbar']]
)
); );
if($passwordstrength > 0) { if($passwordstrength > 0) {
$this->formField( $this->formField(

View File

@ -306,11 +306,11 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Theme_Style {
$this->columnStart(8); $this->columnStart(8);
?> ?>
<ul class="nav nav-pills" id="extensionstab" role="tablist"> <ul class="nav nav-pills" id="extensionstab" role="tablist">
<li class="nav-item <?php if(!$currenttab || $currenttab == 'installed') echo 'active'; ?>"><a class="nav-link <?php if(!$currenttab || $currenttab == 'installed') echo 'active'; ?>" data-target="#installed" data-toggle="tab" role="button"><?= getMLText('extension_mgr_installed'); ?></a></li> <?php $this->showPaneHeader('installed', getMLText('extension_mgr_installed'), (!$currenttab || $currenttab == 'installed')); ?>
<li class="nav-item <?php if($currenttab == 'repository') echo 'active'; ?>"><a class="nav-link <?php if($currenttab == 'repository') echo 'active'; ?>" data-target="#repository" data-toggle="tab" role="button"><?= getMLText('extension_mgr_repository'); ?></a></li> <?php $this->showPaneHeader('repository', getMLText('extension_mgr_repository'), ($currenttab == 'repository')); ?>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane <?php if(!$currenttab || $currenttab == 'installed') echo 'active'; ?>" id="installed" role="tabpanel"> <?php $this->showStartPaneContent('installed', (!$currenttab || $currenttab == 'installed')); ?>
<input id="extensionfilter" class="form-control" type="text" placeholder="<?= getMLText('type_to_filter'); ?>"> <input id="extensionfilter" class="form-control" type="text" placeholder="<?= getMLText('type_to_filter'); ?>">
<div class="ajax" data-view="ExtensionMgr" data-action="installedList" data-afterload="()=>{filterList();}"></div> <div class="ajax" data-view="ExtensionMgr" data-action="installedList" data-afterload="()=>{filterList();}"></div>
<?php <?php
@ -321,9 +321,9 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Theme_Style {
<input type="hidden" name="action" value="refresh" /> <input type="hidden" name="action" value="refresh" />
<p><?php $this->formSubmit("<i class=\"fa fa-refresh\"></i> " . getMLText('refresh'));?></p> <p><?php $this->formSubmit("<i class=\"fa fa-refresh\"></i> " . getMLText('refresh'));?></p>
</form> </form>
</div> <?php $this->showEndPaneContent('installed', $currenttab); ?>
<div class="tab-pane <?php if($currenttab == 'repository') echo 'active'; ?>" id="repository" role="tabpanel"> <?php $this->showStartPaneContent('repository', ($currenttab == 'repository')); ?>
<?php <?php
if($extmgr->getRepositoryUrl()) { if($extmgr->getRepositoryUrl()) {
echo "<table class=\"table\">\n"; echo "<table class=\"table\">\n";
@ -377,10 +377,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Theme_Style {
<?php $this->formSubmit("<i class=\"fa fa-refresh\"></i> " . getMLText('force_update'));?> <?php $this->formSubmit("<i class=\"fa fa-refresh\"></i> " . getMLText('force_update'));?>
</form> </form>
</div> </div>
<?php <?php $this->showEndPaneContent('repository', $currenttab); ?>
}
?>
</div>
</div> </div>
<?php <?php
$this->columnEnd(); $this->columnEnd();

View File

@ -165,6 +165,7 @@ function check_queue() {
else else
$('#status_'+data.data).html('<?= getMLText('index_done').' ('.getMLText('index_no_content').')' ?>'); $('#status_'+data.data).html('<?= getMLText('index_done').' ('.getMLText('index_no_content').')' ?>');
} else { } else {
$('#update_messages').append('<div><p><strong>Docid: ' + data.data + ' (' + data.mimetype + ')</strong></p>' + '<p>Cmd: ' + data.cmd + '</p>' + data.message+'</div>');
$('#status_'+data.data).html('<?= getMLText('index_error') ?>'); $('#status_'+data.data).html('<?= getMLText('index_error') ?>');
noty({ noty({
text: '<p><strong>Docid: ' + data.data + ' (' + data.mimetype + ')</strong></p>' + '<p>Cmd: ' + data.cmd + '</p>' + data.message, text: '<p><strong>Docid: ' + data.data + ' (' + data.mimetype + ')</strong></p>' + '<p>Cmd: ' + data.cmd + '</p>' + data.message,
@ -218,6 +219,8 @@ $(document).ready( function() {
$this->globalNavigation(); $this->globalNavigation();
$this->contentStart(); $this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools"); $this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->rowStart();
$this->columnStart(6);
$this->contentHeading(getMLText("update_fulltext_index")); $this->contentHeading(getMLText("update_fulltext_index"));
if($fulltextservice) { if($fulltextservice) {
$index = $fulltextservice->Indexer(); $index = $fulltextservice->Indexer();
@ -230,7 +233,6 @@ div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
.progress {margin-bottom: 2px;} .progress {margin-bottom: 2px;}
.bar-legend {text-align: right; font-size: 85%; margin-bottom: 15px;} .bar-legend {text-align: right; font-size: 85%; margin-bottom: 15px;}
</style> </style>
<div style="max-width: 900px;">
<div> <div>
<div class="progress"> <div class="progress">
<div class="progress-bar bar total-bar" role="progressbar" style="width: 100%;"></div> <div class="progress-bar bar total-bar" role="progressbar" style="width: 100%;"></div>
@ -247,7 +249,13 @@ div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
$folderprocess = new SeedDMS_View_Indexer_Process_Folder($fulltextservice, $forceupdate); $folderprocess = new SeedDMS_View_Indexer_Process_Folder($fulltextservice, $forceupdate);
call_user_func(array($folderprocess, 'process'), $folder, -1); call_user_func(array($folderprocess, 'process'), $folder, -1);
$tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process')); $tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process'));
echo "</div>"; $this->columnEnd();
$this->columnStart(6);
$this->contentHeading(getMLText("update_fulltext_messages"));
echo '<div id="update_messages">';
echo '</div>';
$this->columnEnd();
$this->rowEnd();
$index->commit(); $index->commit();
$index->optimize(); $index->optimize();

View File

@ -137,6 +137,9 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Theme_Style {
header('Content-Type: application/javascript; charset=UTF-8'); header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder')); parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder'));
?> ?>
$(document).ready(function() {
$('#searchfield').focus();
});
seeddms_folder = <?= $folder->getID() ?>; seeddms_folder = <?= $folder->getID() ?>;
function folderSelectedmaintree(id, name) { function folderSelectedmaintree(id, name) {
<?php if(!$onepage) { ?> <?php if(!$onepage) { ?>