From 957482bc9b23949923f7ac4a3dbb8b8b54892603 Mon Sep 17 00:00:00 2001 From: Sebastian Bartus-Kunz Date: Fri, 10 Jun 2016 15:06:41 +0200 Subject: [PATCH 01/64] Added change password request. --- restapi/index.php | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/restapi/index.php b/restapi/index.php index a2b17da90..f98ebe8ef 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -929,6 +929,53 @@ function createAccount() { /* {{{ */ return; } /* }}} */ +/** + * Updates the password of an existing Account, the password must be PUT as a md5 string + * + * @param $id The user name or numerical identifier + */ +function changeAccountPassword($id) { /* {{{ */ + global $app, $dms, $userobj; + + checkIfAdmin(); + + if ($app->request()->put('password') == null) + { + $app->response()->header('Content-Type', 'application/json'); + echo json_encode(array('success'=>false, 'message'=>'You must PUT a new password', 'data'=>'')); + return; + } + + $newPassword = $app->request()->put('password'); + + if(is_numeric($id)) + $account = $dms->getUser($id); + else { + $account = $dms->getUserByLogin($id); + } + + /** + * User not found + */ + if (!$account) { + $app->response()->status(404); + return; + } + + $operation = $account->setPwd($newPassword); + + if (!$operation){ + $app->response()->header('Content-Type', 'application/json'); + echo json_encode(array('success'=>false, 'message'=>'', 'data'=>'Could not change password.')); + return; + } + + $app->response()->header('Content-Type', 'application/json'); + echo json_encode(array('success'=>true, 'message'=>'', 'data'=>'')); + + return; +} /* }}} */ + function getAccountById($id) { /* {{{ */ global $app, $dms, $userobj; checkIfAdmin(); @@ -1351,6 +1398,7 @@ $app->get('/account/locked', 'getLockedDocuments'); $app->post('/accounts', 'createAccount'); $app->get('/accounts/:id', 'getAccountById'); $app->put('/accounts/:id/disable', 'setDisabledAccount'); +$app->get('/accounts/:id/password', 'changeAccountPassword'); $app->post('/groups', 'createGroup'); $app->get('/groups/:id', 'getGroup'); $app->put('/groups/:id/addUser', 'addUserToGroup'); From f3490fc6ced1af8d2c96b76c806d47c77553e4f1 Mon Sep 17 00:00:00 2001 From: Sebastian Bartus-Kunz Date: Fri, 10 Jun 2016 15:08:33 +0200 Subject: [PATCH 02/64] Small fix. --- restapi/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restapi/index.php b/restapi/index.php index f98ebe8ef..99b9460b2 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -1398,7 +1398,7 @@ $app->get('/account/locked', 'getLockedDocuments'); $app->post('/accounts', 'createAccount'); $app->get('/accounts/:id', 'getAccountById'); $app->put('/accounts/:id/disable', 'setDisabledAccount'); -$app->get('/accounts/:id/password', 'changeAccountPassword'); +$app->put('/accounts/:id/password', 'changeAccountPassword'); $app->post('/groups', 'createGroup'); $app->get('/groups/:id', 'getGroup'); $app->put('/groups/:id/addUser', 'addUserToGroup'); From 45d0c2618f4c183182d877fde444c9f4cedcbba4 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 5 Sep 2017 09:27:55 +0200 Subject: [PATCH 03/64] start new version 4.3.37 --- CHANGELOG | 4 ++++ Makefile | 2 +- SeedDMS_Core/Core/inc.ClassDMS.php | 2 +- SeedDMS_Core/package.xml | 23 +++++++++++++++++++---- inc/inc.Version.php | 2 +- install/install.php | 2 +- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 65ba943fa..4ab10c2ed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +-------------------------------------------------------------------------------- + Changes in version 4.3.37 +-------------------------------------------------------------------------------- + -------------------------------------------------------------------------------- Changes in version 4.3.36 -------------------------------------------------------------------------------- diff --git a/Makefile b/Makefile index 6e54b8d05..573f30a44 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=4.3.36 +VERSION=4.3.37 SRC=CHANGELOG inc conf utils index.php languages views op out doc styles LICENSE webdav install restapi pdfviewer # webapp diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index ea2e2a1e8..24e0e233e 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -307,7 +307,7 @@ class SeedDMS_Core_DMS { $this->callbacks = array(); $this->version = '@package_version@'; if($this->version[0] == '@') - $this->version = '4.3.36'; + $this->version = '4.3.37'; } /* }}} */ /** diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index c6a22e772..9236411f0 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -12,11 +12,11 @@ uwe@steinmann.cx yes - 2017-03-22 + 2017-09-05 - 4.3.36 - 4.3.36 + 4.3.37 + 4.3.37 stable @@ -24,7 +24,6 @@ GPL License -- fix sql statement for creating temp. tables (sqlite) @@ -1157,5 +1156,21 @@ SeedDMS_Core_DMS::getDuplicateDocumentContent() returns complete document do not sort some temporary tables anymore, because it causes an error in mysql if sql_mode=only_full_group_by is set + + 2017-03-22 + + + 4.3.36 + 4.3.36 + + + stable + stable + + GPL License + +- fix sql statement for creating temp. tables (sqlite) + + diff --git a/inc/inc.Version.php b/inc/inc.Version.php index d0a7b4d5d..5b821627e 100644 --- a/inc/inc.Version.php +++ b/inc/inc.Version.php @@ -20,7 +20,7 @@ class SeedDMS_Version { - public $_number = "4.3.36"; + public $_number = "4.3.37"; private $_string = "SeedDMS"; function __construct() { diff --git a/install/install.php b/install/install.php index 3aac8f012..78fce9940 100644 --- a/install/install.php +++ b/install/install.php @@ -118,7 +118,7 @@ function fileExistsInIncludePath($file) { /* {{{ */ * Load default settings + set */ define("SEEDDMS_INSTALL", "on"); -define("SEEDDMS_VERSION", "4.3.36"); +define("SEEDDMS_VERSION", "4.3.37"); require_once('../inc/inc.ClassSettings.php'); From ef6f263fc1d1f8ef2e23cebfbc2640595a643a1b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 11 Sep 2017 08:16:25 +0200 Subject: [PATCH 04/64] create indexer only if action is not set or 'show' (Closes #340) --- out/out.Indexer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/out/out.Indexer.php b/out/out.Indexer.php index cc41c252b..904ac6584 100644 --- a/out/out.Indexer.php +++ b/out/out.Indexer.php @@ -37,6 +37,7 @@ if(!$settings->_enableFullSearch) { UI::exitError(getMLText("admin_tools"),getMLText("fulltextsearch_disabled")); } +if(!isset($_GET['action']) || $_GET['action'] == 'show') if(isset($_GET['create']) && $_GET['create'] == 1) { if(isset($_GET['confirm']) && $_GET['confirm'] == 1) { $index = $indexconf['Indexer']::create($settings->_luceneDir); From b5fad8ddecbd884e0342b1c239dc15f58a860c53 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 11 Sep 2017 08:18:33 +0200 Subject: [PATCH 05/64] add entry for 5.1.4 --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 9d86f8008..df6aa06e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ -------------------------------------------------------------------------------- Changes in version 5.1.4 -------------------------------------------------------------------------------- +- fix javascript error when indexing document, because the indexer was also + created when the js-code was requested (Closes #340) -------------------------------------------------------------------------------- Changes in version 5.1.3 From bb3071bdae0372b03b3659535f28764a71837129 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 11 Sep 2017 08:21:28 +0200 Subject: [PATCH 06/64] use cmd timeout when indexing document (Closes 344) --- op/op.Ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op/op.Ajax.php b/op/op.Ajax.php index d25efbb3f..6fd1843ab 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -754,7 +754,7 @@ switch($command) { $index = $indexconf['Indexer']::open($settings->_luceneDir); if($index) { $indexconf['Indexer']::init($settings->_stopWordsFile); - $idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false); + $idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout); if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) { foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) { if (method_exists($hookObj, 'preIndexDocument')) { From 5f564e2b966f0c66347584be2c5ee0b1386d5a6d Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 11 Sep 2017 08:22:21 +0200 Subject: [PATCH 07/64] add entry for 5.0.14 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index b4a314aca..f6f900093 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ -------------------------------------------------------------------------------- Changes in version 5.0.14 -------------------------------------------------------------------------------- +- use cmd timeout when indexing documents (Closes #344) -------------------------------------------------------------------------------- Changes in version 5.0.13 From b4bcb94b6c6f9bfaf07cac157fb0b74cd81e6fb5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 11 Sep 2017 08:30:35 +0200 Subject: [PATCH 08/64] intialize $index even if action != show --- out/out.Indexer.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/out/out.Indexer.php b/out/out.Indexer.php index 904ac6584..85137fa2c 100644 --- a/out/out.Indexer.php +++ b/out/out.Indexer.php @@ -37,24 +37,27 @@ if(!$settings->_enableFullSearch) { UI::exitError(getMLText("admin_tools"),getMLText("fulltextsearch_disabled")); } -if(!isset($_GET['action']) || $_GET['action'] == 'show') -if(isset($_GET['create']) && $_GET['create'] == 1) { - if(isset($_GET['confirm']) && $_GET['confirm'] == 1) { - $index = $indexconf['Indexer']::create($settings->_luceneDir); +if(!isset($_GET['action']) || $_GET['action'] == 'show') { + if(isset($_GET['create']) && $_GET['create'] == 1) { + if(isset($_GET['confirm']) && $_GET['confirm'] == 1) { + $index = $indexconf['Indexer']::create($settings->_luceneDir); + if(!$index) { + UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); + } + $indexconf['Indexer']::init($settings->_stopWordsFile); + } else { + header('Location: out.CreateIndex.php'); + exit; + } + } else { + $index = $indexconf['Indexer']::open($settings->_luceneDir); if(!$index) { UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); } $indexconf['Indexer']::init($settings->_stopWordsFile); - } else { - header('Location: out.CreateIndex.php'); - exit; } } else { - $index = $indexconf['Indexer']::open($settings->_luceneDir); - if(!$index) { - UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); - } - $indexconf['Indexer']::init($settings->_stopWordsFile); + $index = null; } if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) { From 626c65b0e4385b6abb86fb656de1259805209d4d Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 07:14:09 +0200 Subject: [PATCH 09/64] createPreview() returns falls if converter programm fails --- SeedDMS_Preview/Preview/Previewer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/SeedDMS_Preview/Preview/Previewer.php b/SeedDMS_Preview/Preview/Previewer.php index 970fcdb95..c32271c29 100644 --- a/SeedDMS_Preview/Preview/Previewer.php +++ b/SeedDMS_Preview/Preview/Previewer.php @@ -140,6 +140,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base { try { self::execWithTimeout($cmd, $this->timeout); } catch(Exception $e) { + return false; } } return true; From 8c776c82698fe0ca07e42efd0ef638e137a43eb2 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 07:14:39 +0200 Subject: [PATCH 10/64] new version 1.2.3 --- SeedDMS_Preview/package.xml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/SeedDMS_Preview/package.xml b/SeedDMS_Preview/package.xml index 71eb627ba..6c0211aef 100644 --- a/SeedDMS_Preview/package.xml +++ b/SeedDMS_Preview/package.xml @@ -11,10 +11,10 @@ uwe@steinmann.cx yes - 2017-03-02 - + 2017-09-18 + - 1.2.2 + 1.2.3 1.2.0 @@ -23,8 +23,7 @@ GPL License -commands can be set for mimetypes 'xxxx/*' and '*' -pass mimetype as parameter '%m' to converter +createPreview() returns false if running the converter command fails @@ -271,5 +270,22 @@ add new previewer which converts document to pdf instead of png setConverters() overrides exiting converters + + 2017-03-02 + + + 1.2.2 + 1.2.0 + + + stable + stable + + GPL License + +commands can be set for mimetypes 'xxxx/*' and '*' +pass mimetype as parameter '%m' to converter + + From 82ca6f830253a6b6986b67a1915a01d4b2eff2e0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 10:22:39 +0200 Subject: [PATCH 11/64] createPreview() returns false if command cannot be executed --- SeedDMS_Preview/Preview/PdfPreviewer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/SeedDMS_Preview/Preview/PdfPreviewer.php b/SeedDMS_Preview/Preview/PdfPreviewer.php index f3c618b9f..49b303359 100644 --- a/SeedDMS_Preview/Preview/PdfPreviewer.php +++ b/SeedDMS_Preview/Preview/PdfPreviewer.php @@ -101,6 +101,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base { try { self::execWithTimeout($cmd, $this->timeout); } catch(Exception $e) { + return false; } } return true; From a1ca5991d891e049f01ee8523288a25531c7b413 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 10:23:26 +0200 Subject: [PATCH 12/64] remove some empty lines --- SeedDMS_Preview/Preview/Base.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SeedDMS_Preview/Preview/Base.php b/SeedDMS_Preview/Preview/Base.php index b68186c69..25a36cdee 100644 --- a/SeedDMS_Preview/Preview/Base.php +++ b/SeedDMS_Preview/Preview/Base.php @@ -64,13 +64,13 @@ class SeedDMS_Preview_Base { 2 => array("pipe", "w") ); $pipes = array(); - + $timeout += time(); $process = proc_open($cmd, $descriptorspec, $pipes); if (!is_resource($process)) { throw new Exception("proc_open failed on: " . $cmd); } - + $output = ''; $timeleft = $timeout - time(); $read = array($pipes[1]); @@ -78,13 +78,13 @@ class SeedDMS_Preview_Base { $exeptions = NULL; do { stream_select($read, $write, $exeptions, $timeleft, 200000); - + if (!empty($read)) { $output .= fread($pipes[1], 8192); } $timeleft = $timeout - time(); } while (!feof($pipes[1]) && $timeleft > 0); - + if ($timeleft <= 0) { proc_terminate($process); throw new Exception("command timeout on: " . $cmd); @@ -109,7 +109,7 @@ class SeedDMS_Preview_Base { /** * Check if converter for a given mimetype is set * - * @param string $mimetype + * @param string $mimetype * @return boolean true if converter exists, otherwise false */ function hasConverter($mimetype) { /* {{{ */ From f666996f201fd5b15eea802abdc4b31c7cb5372f Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 10:23:40 +0200 Subject: [PATCH 13/64] remove default icon if preview could not be created --- op/op.Preview.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/op/op.Preview.php b/op/op.Preview.php index 91c057be0..85effaf9f 100644 --- a/op/op.Preview.php +++ b/op/op.Preview.php @@ -71,8 +71,15 @@ if(!empty($_GET["width"])) $previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir, $_GET["width"]); else $previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir); -if(!$previewer->hasPreview($object)) - $previewer->createPreview($object); +if(!$previewer->hasPreview($object)) { + if(!$previewer->createPreview($object)) { + } +} +if(!$previewer->hasPreview($object)) { + header('Content-Type: image/svg+xml'); + readfile('../views/'.$theme.'/images/empty.svg'); + exit; +} header('Content-Type: image/png'); $previewer->getPreview($object); From 450d4cc27d7bf85f64b40dee2f5b05ed10197562 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 10:54:05 +0200 Subject: [PATCH 14/64] fix label in form --- views/bootstrap/class.PasswordForgotten.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.PasswordForgotten.php b/views/bootstrap/class.PasswordForgotten.php index dcf88d2b2..89363237a 100644 --- a/views/bootstrap/class.PasswordForgotten.php +++ b/views/bootstrap/class.PasswordForgotten.php @@ -82,7 +82,7 @@ document.form1.email.focus();

- +
From 649ed029868d957e4cc96fa8dbcb22dfb2e89e5c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 18 Sep 2017 10:54:13 +0200 Subject: [PATCH 15/64] add entry for 4.3.37 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 4ab10c2ed..d43439ad7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ -------------------------------------------------------------------------------- Changes in version 4.3.37 -------------------------------------------------------------------------------- +- fix label in password forgotten form (Closes #346) -------------------------------------------------------------------------------- Changes in version 4.3.36 From 3e2d6e3f745bafd98b2fca9274c990414bb9715f Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 20 Sep 2017 09:20:56 +0200 Subject: [PATCH 16/64] add preview width for dropfolder lists --- inc/inc.ClassSettings.php | 10 ++++++++++ op/op.Settings.php | 2 ++ out/out.DropFolderChooser.php | 3 ++- views/bootstrap/class.DropFolderChooser.php | 12 +++++++----- views/bootstrap/class.Settings.php | 8 ++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index 1c06d76db..e253030d7 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -217,8 +217,12 @@ class Settings { /* {{{ */ var $_cmdTimeout = 5; // Preview image width in lists var $_previewWidthList = 40; + // Preview image width in menu lists + var $_previewWidthMenuList = 40; // Preview image width on document details page var $_previewWidthDetail = 100; + // Preview image width in drop folder list + var $_previewWidthDropFolderList = 100; // show full preview on document details page var $_showFullPreview = false; // convert to pdf for preview on document details page @@ -404,8 +408,12 @@ class Settings { /* {{{ */ $this->_theme = strval($tab["theme"]); if(isset($tab["previewWidthList"])) $this->_previewWidthList = intval($tab["previewWidthList"]); + if(isset($tab["previewWidthMenuList"])) + $this->_previewWidthMenuList = intval($tab["previewWidthMenuList"]); if(isset($tab["previewWidthDetail"])) $this->_previewWidthDetail = intval($tab["previewWidthDetail"]); + if(isset($tab["previewWidthDropFolderList"])) + $this->_previewWidthDropFolderList = intval($tab["previewWidthDropFolderList"]); $this->_showFullPreview = Settings::boolVal($tab["showFullPreview"]); $this->_convertToPdf = Settings::boolVal($tab["convertToPdf"]); @@ -719,7 +727,9 @@ class Settings { /* {{{ */ $this->setXMLAttributValue($node, "availablelanguages", implode(',', $this->_availablelanguages)); $this->setXMLAttributValue($node, "theme", $this->_theme); $this->setXMLAttributValue($node, "previewWidthList", $this->_previewWidthList); + $this->setXMLAttributValue($node, "previewWidthMenuList", $this->_previewWidthMenuList); $this->setXMLAttributValue($node, "previewWidthDetail", $this->_previewWidthDetail); + $this->setXMLAttributValue($node, "previewWidthDropFolderList", $this->_previewWidthDropFolderList); $this->setXMLAttributValue($node, "showFullPreview", $this->_showFullPreview); $this->setXMLAttributValue($node, "convertToPdf", $this->_convertToPdf); diff --git a/op/op.Settings.php b/op/op.Settings.php index 7466686d3..3ca583bb3 100644 --- a/op/op.Settings.php +++ b/op/op.Settings.php @@ -65,6 +65,8 @@ if ($action == "saveSettings") $settings->_availablelanguages = $_POST["availablelanguages"]; $settings->_theme = $_POST["theme"]; $settings->_previewWidthList = $_POST["previewWidthList"]; + $settings->_previewWidthMenuList = $_POST["previewWidthMenuList"]; + $settings->_previewWidthDropFolderList = $_POST["previewWidthDropFolderList"]; $settings->_previewWidthDetail = $_POST["previewWidthDetail"]; $settings->_showFullPreview = getBoolValue("showFullPreview"); $settings->_convertToPdf = getBoolValue("convertToPdf"); diff --git a/out/out.DropFolderChooser.php b/out/out.DropFolderChooser.php index 5eaa38892..89ed922c1 100644 --- a/out/out.DropFolderChooser.php +++ b/out/out.DropFolderChooser.php @@ -49,7 +49,8 @@ if($view) { $view->setParam('dropfolderfile', isset($_GET["dropfolderfile"]) ? $_GET["dropfolderfile"] : ''); $view->setParam('form', $form); $view->setParam('cachedir', $settings->_cacheDir); - $view->setParam('previewWidthList', $settings->_previewWidthList); + $view->setParam('previewWidthMenuList', $settings->_previewWidthMenuList); + $view->setParam('previewWidthList', $settings->_previewWidthDropFolderList); $view->setParam('timeout', $settings->_cmdTimeout); $view->setParam('showfolders', $showfolders); $view($_GET); diff --git a/views/bootstrap/class.DropFolderChooser.php b/views/bootstrap/class.DropFolderChooser.php index 966da8cd3..2c9243064 100644 --- a/views/bootstrap/class.DropFolderChooser.php +++ b/views/bootstrap/class.DropFolderChooser.php @@ -56,10 +56,10 @@ $('.folderselect').click(function(ev) { $dropfolderdir = $this->params['dropfolderdir']; $showfolders = $this->params['showfolders']; $cachedir = $this->params['cachedir']; + $previewwidth = $this->params['previewWidthMenuList']; $timeout = $this->params['timeout']; $folderid = isset($_GET['folderid']) ? $_GET['folderid'] : 0; - $previewwidth = 40; $previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout); $c = 0; // count files @@ -78,10 +78,12 @@ $('.folderselect').click(function(ev) { if($showfolders == 0 && !is_dir($dir.'/'.$entry)) { $c++; $mimetype = finfo_file($finfo, $dir.'/'.$entry); - $previewer->createRawPreview($dir.'/'.$entry, 'dropfolder/', $mimetype); - $filecontent .= "
  • "; - if($previewer->hasRawPreview($dir.'/'.$entry, 'dropfolder/')) { - $filecontent .= "
    "; + $filecontent .= "
  • "; + if($previewwidth) { + $previewer->createRawPreview($dir.'/'.$entry, 'dropfolder/', $mimetype); + if($previewer->hasRawPreview($dir.'/'.$entry, 'dropfolder/')) { + $filecontent .= "
    "; + } } $filecontent .= "
    ".$entry."
    ".SeedDMS_Core_File::format_filesize(filesize($dir.'/'.$entry)).", ".date('Y-m-d H:i:s', filectime($dir.'/'.$entry))."
  • \n"; } elseif($showfolders && is_dir($dir.'/'.$entry)) { diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index 32d24628d..1fac139f5 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -187,6 +187,14 @@ if(!is_writeable($settings->_configFilePath)) { : showTextField("previewWidthList", $settings->_previewWidthList); ?> + "> + : + showTextField("previewWidthMenuList", $settings->_previewWidthMenuList); ?> + + "> + : + showTextField("previewWidthDropFolderList", $settings->_previewWidthDropFolderList); ?> + "> : showTextField("previewWidthDetail", $settings->_previewWidthDetail); ?> From 0967c109d0635c8586d93f1a33bd50644175acc4 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 20 Sep 2017 09:22:43 +0200 Subject: [PATCH 17/64] urlencode file name in printDropFolderChooserHtml() --- views/bootstrap/class.Bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 70d7205f9..0602ab109 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -1150,7 +1150,7 @@ $(document).ready(function() { print "\n"; ?>
    From d5f79f5f7c6bebd46be81406ed24c7b7d7521531 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 27 Sep 2017 18:36:59 +0200 Subject: [PATCH 20/64] various small improvements back ported from 6.0.x --- SeedDMS_Core/Core/inc.ClassDocument.php | 99 +++++++++++++++---------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index ceec06ed5..a2c9f73da 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -58,6 +58,41 @@ define("S_OBSOLETE", -2); */ define("S_EXPIRED", -3); +/** + * The different states a workflow log can be in. This is used in + * all tables tblDocumentXXXLog + */ +/* + * workflow is in a neutral status waiting for action of user + */ +define("S_LOG_WAITING", 0); + +/* + * workflow has been successful ended. The document content has been + * approved, reviewed, aknowledged or revised + */ +define("S_LOG_ACCEPTED", 1); + +/* + * workflow has been unsuccessful ended. The document content has been + * rejected + */ +define("S_LOG_REJECTED", -1); + +/* + * user has been removed from workflow. This can be for different reasons + * 1. the user has been actively removed from the workflow, 2. the user has + * been deleted. + */ +define("S_LOG_USER_REMOVED", -2); + +/* + * workflow is sleeping until reactivation. The workflow has been set up + * but not started. This is only valid for the revision workflow, which + * may run over and over again. + */ +define("S_LOG_SLEEPING", -3); + /** * Class to represent a document in the document management system * @@ -150,6 +185,16 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ */ protected $_sequence; + /** + * @var object temp. storage for latestcontent + */ + protected $_latestContent; + + /** + * @var array temp. storage for content + */ + protected $_content; + function __construct($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */ parent::__construct($id); $this->_name = $name; @@ -165,6 +210,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $this->_sequence = $sequence; $this->_categories = array(); $this->_notifyList = array(); + $this->_latestContent = null; + $this->_content = null; } /* }}} */ /** @@ -712,7 +759,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * * @param integer $mode access mode (defaults to M_ANY) * @param integer $op operation (defaults to O_EQ) - * @return array multi dimensional array + * @return array multi dimensional array or false in case of an error */ function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1265,8 +1312,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return false; } - unset($this->_content); - unset($this->_latestContent); + $this->_content = null; + $this->_latestContent = null; $content = $this->getLatestContent($contentID); $docResultSet = new SeedDMS_Core_AddContentResultSet($content); $docResultSet->setDMS($this->_dms); @@ -1438,8 +1485,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return false; } - unset($this->_content); - unset($this->_latestContent); + $this->_content = null; + $this->_latestContent = null; $db->commitTransaction(); return true; @@ -1501,7 +1548,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ } /* }}} */ function getLatestContent() { /* {{{ */ - if (!isset($this->_latestContent)) { + if (!$this->_latestContent) { $db = $this->_dms->getDB(); $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC LIMIT 1"; $resArr = $db->getResultArray($queryStr); @@ -2991,7 +3038,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ - function addIndReviewer($user, $requestUser, $listadmin=false) { /* {{{ */ + function addIndReviewer($user, $requestUser) { /* {{{ */ $db = $this->_document->_dms->getDB(); $userID = $user->getID(); @@ -3000,21 +3047,6 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ if($this->_document->getAccessMode($user) < M_READ) { return -2; } - /* - if (!isset($this->_readAccessList)) { - $this->_readAccessList = $this->_document->getReadAccessList($listadmin); - } - $approved = false; - foreach ($this->_readAccessList["users"] as $appUser) { - if ($userID == $appUser->getID()) { - $approved = true; - break; - } - } - if (!$approved) { - return -2; - } - */ // Check to see if the user has already been added to the review list. $reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version); @@ -3226,7 +3258,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ } } /* }}} */ - function addIndApprover($user, $requestUser, $listadmin=false) { /* {{{ */ + function addIndApprover($user, $requestUser) { /* {{{ */ $db = $this->_document->_dms->getDB(); $userID = $user->getID(); @@ -3235,19 +3267,6 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ if($this->_document->getAccessMode($user) < M_READ) { return -2; } - /* - $readAccessList = $this->_document->getReadAccessList($listadmin); - $approved = false; - foreach ($readAccessList["users"] as $appUser) { - if ($userID == $appUser->getID()) { - $approved = true; - break; - } - } - if (!$approved) { - return -2; - } - */ // Check to see if the user has already been added to the approvers list. $approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version); @@ -3473,7 +3492,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ } $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". - "VALUES ('". $indstatus["reviewID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; + "VALUES ('". $indstatus["reviewID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; $res = $db->getResult($queryStr); if (is_bool($res) && !$res) { return -1; @@ -3504,7 +3523,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ } $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". - "VALUES ('". $reviewStatus[0]["reviewID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; + "VALUES ('". $reviewStatus[0]["reviewID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; $res = $db->getResult($queryStr); if (is_bool($res) && !$res) { return -1; @@ -3536,7 +3555,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ } $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ". - "VALUES ('". $indstatus["approveID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; + "VALUES ('". $indstatus["approveID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; $res = $db->getResult($queryStr); if (is_bool($res) && !$res) { return -1; @@ -3567,7 +3586,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ } $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ". - "VALUES ('". $approvalStatus[0]["approveID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; + "VALUES ('". $approvalStatus[0]["approveID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; $res = $db->getResult($queryStr); if (is_bool($res) && !$res) { return -1; From 3912cbb5770bc8dc3e54de444e6772cb9926e2f6 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 27 Sep 2017 18:37:37 +0200 Subject: [PATCH 21/64] list all rejected documents --- views/bootstrap/class.MyDocuments.php | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/views/bootstrap/class.MyDocuments.php b/views/bootstrap/class.MyDocuments.php index 6f9e672e1..4f8e3511f 100644 --- a/views/bootstrap/class.MyDocuments.php +++ b/views/bootstrap/class.MyDocuments.php @@ -407,6 +407,84 @@ class SeedDMS_View_MyDocuments extends SeedDMS_Bootstrap_Style { else printMLText("no_docs_to_look_at"); $this->contentContainerEnd(); + + // Get list of documents owned by current user that are pending review or + // pending approval. + $queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser`, ". + "`tblDocumentContent`.`version`, `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ". + "`tblDocumentStatusLog`.`comment` AS `statusComment`, `tblDocumentStatusLog`.`date` as `statusDate`, ". + "`tblDocumentStatusLog`.`userID`, `oTbl`.`fullName` AS `ownerName`, `sTbl`.`fullName` AS `statusName` ". + "FROM `tblDocumentContent` ". + "LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` ". + "LEFT JOIN `tblDocumentStatus` ON `tblDocumentStatus`.`documentID` = `tblDocumentContent`.`document` ". + "LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusID` = `tblDocumentStatus`.`statusID` ". + "LEFT JOIN `ttstatid` ON `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` ". + "LEFT JOIN `ttcontentid` ON `ttcontentid`.`maxVersion` = `tblDocumentStatus`.`version` AND `ttcontentid`.`document` = `tblDocumentStatus`.`documentID` ". + "LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` ". + "LEFT JOIN `tblUsers` AS `oTbl` on `oTbl`.`id` = `tblDocuments`.`owner` ". + "LEFT JOIN `tblUsers` AS `sTbl` on `sTbl`.`id` = `tblDocumentStatusLog`.`userID` ". + "WHERE `ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` ". + "AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version` ". + "AND `tblDocuments`.`owner` = '".$user->getID()."' ". + "AND `tblDocumentStatusLog`.`status` IN (".S_REJECTED.") ". + "ORDER BY `statusDate` DESC"; + + $resArr = $db->getResultArray($queryStr); + if (is_bool($resArr) && !$resArr) { + $this->contentHeading(getMLText("warning")); + $this->contentContainer("Internal error. Unable to complete request. Exiting."); + $this->htmlEndPage(); + exit; + } + + $this->contentHeading(getMLText("documents_user_rejected")); + $this->contentContainerStart(); + if (count($resArr)>0) { + + print ""; + print "\n\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; + + foreach ($resArr as $res) { + $document = $dms->getDocument($res["documentID"]); + $document->verifyLastestContentExpriry(); + + // verify expiry + if ( $res["expires"] && time()>$res["expires"]+24*60*60 ){ + if ( $res["status"]==S_REJECTED ){ + $res["status"]=S_EXPIRED; + } + } + + print "\n"; + $latestContent = $document->getLatestContent(); + $previewer->createPreview($latestContent); + print ""; + print "\n"; + print ""; + print ""; + print ""; + print ""; + print "\n"; + } + print "
    ".getMLText("name")."".getMLText("status")."".getMLText("version")."".getMLText("last_update")."".getMLText("expires")."
    "; + if($previewer->hasPreview($latestContent)) { + print "getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } else { + print "getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } + print "" . htmlspecialchars($res["name"]) . "".getOverallStatusText($res["status"])."".$res["version"]."".$res["statusDate"]." ".htmlspecialchars($res["statusName"])."".(!$res["expires"] ? "-":getReadableDate($res["expires"]))."
    "; + + } + else printMLText("no_docs_to_look_at"); + + $this->contentContainerEnd(); } elseif($workflowmode == 'advanced') { // Get document list for the current user. $workflowStatus = $user->getWorkflowStatus(); From 031887de0a9977cb065c32483d02e9618ee601de Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 28 Sep 2017 07:21:08 +0200 Subject: [PATCH 22/64] add var noReadForStatus and method getLoggedInUser() --- SeedDMS_Core/Core/inc.ClassDMS.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index b982728b0..03b713229 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -147,6 +147,13 @@ class SeedDMS_Core_DMS { */ public $viewOnlineFileTypes; + /** + * @var array $noReadForStatus list of status without read right + * online. + * @access public + */ + public $noReadForStatus; + /** * @var string $version version of pear package * @access public @@ -354,6 +361,7 @@ class SeedDMS_Core_DMS { $this->forceRename = false; $this->enableConverting = false; $this->convertFileTypes = array(); + $this->noReadForStatus = array(); $this->classnames = array(); $this->classnames['folder'] = 'SeedDMS_Core_Folder'; $this->classnames['document'] = 'SeedDMS_Core_Document'; @@ -542,6 +550,19 @@ class SeedDMS_Core_DMS { $this->user = $user; } /* }}} */ + /** + * Get the logged in user + * + * If user authentication was done externally, this function can + * be used to tell the dms who is currently logged in. + * + * @return object $user + * + */ + function getLoggedInUser() { /* {{{ */ + return $this->user; + } /* }}} */ + /** * Return a document by its id * From f1f439af8c23590f9178e8bf105949b6ef6e3df2 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 28 Sep 2017 07:23:15 +0200 Subject: [PATCH 23/64] add support for access restrictions on document content --- SeedDMS_Core/Core/inc.ClassDocument.php | 208 ++++++++++++++++++++---- 1 file changed, 178 insertions(+), 30 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index a2c9f73da..d9c397f8c 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -1495,7 +1495,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Return all content elements of a document * - * This functions returns an array of content elements ordered by version + * This functions returns an array of content elements ordered by version. + * Version which are not accessible because of its status, will be filtered + * out. Access rights based on the document status are calculated for the + * currently logged in user. * * @return array list of objects of class SeedDMS_Core_DocumentContent */ @@ -1510,8 +1513,16 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $this->_content = array(); $classname = $this->_dms->getClassname('documentcontent'); - foreach ($resArr as $row) - array_push($this->_content, new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum'])); + $user = $this->_dms->getLoggedInUser(); + foreach ($resArr as $row) { + $content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']); + if($user) { + if($content->getAccessMode($user) >= M_READ) + array_push($this->_content, $content); + } else { + array_push($this->_content, $content); + } + } } return $this->_content; @@ -1520,8 +1531,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Return the content element of a document with a given version number * + * This function will check if the version is accessible and return false + * if not. Access rights based on the document status are calculated for the + * currently logged in user. + * * @param integer $version version number of content element - * @return object object of class SeedDMS_Core_DocumentContent + * @return object/boolean object of class {@link SeedDMS_Core_DocumentContent} + * or false */ function getContentByVersion($version) { /* {{{ */ if (!is_numeric($version)) return false; @@ -1544,10 +1560,19 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $resArr = $resArr[0]; $classname = $this->_dms->getClassname('documentcontent'); - return new $classname($resArr["id"], $this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"], $resArr['fileSize'], $resArr['checksum']); + if($content = new $classname($resArr["id"], $this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"], $resArr['fileSize'], $resArr['checksum'])) { + $user = $this->_dms->getLoggedInUser(); + /* A user with write access on the document may always see the version */ + if($user && $content->getAccessMode($user) == M_NONE) + return false; + else + return $content; + } else { + return false; + } } /* }}} */ - function getLatestContent() { /* {{{ */ + function __getLatestContent() { /* {{{ */ if (!$this->_latestContent) { $db = $this->_dms->getDB(); $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC LIMIT 1"; @@ -1564,6 +1589,49 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->_latestContent; } /* }}} */ + /** + * Get the latest version of document + * + * This function returns the latest accessible version of a document. + * If content access has been restricted by setting + * {@link SeedDMS_Core_DMS::noReadForStatus} the function will go + * backwards in history until an accessible version is found. If none + * is found null will be returned. + * Access rights based on the document status are calculated for the + * currently logged in user. + * + * @return object object of class {@link SeedDMS_Core_DocumentContent} + */ + function getLatestContent() { /* {{{ */ + if (!$this->_latestContent) { + $db = $this->_dms->getDB(); + $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC"; + $resArr = $db->getResultArray($queryStr); + if (is_bool($resArr) && !$res) + return false; + + $classname = $this->_dms->getClassname('documentcontent'); + $user = $this->_dms->getLoggedInUser(); + foreach ($resArr as $row) { + if (!$this->_latestContent) { + $content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']); + if($user) { + /* If the user may even write the document, then also allow to see all content. + * This is needed because the user could upload a new version + */ + if($content->getAccessMode($user) >= M_READ) { + $this->_latestContent = $content; + } + } else { + $this->_latestContent = $content; + } + } + } + } + + return $this->_latestContent; + } /* }}} */ + /** * Remove version of document * @@ -2750,36 +2818,117 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ /** * Returns the access mode similar to a document - * There is no real access mode for document content, so this is more - * like a virtual access mode, derived from the status or workflow - * of the document content. The idea is to return an access mode - * M_NONE if the user is still in a workflow or under review/approval. - * In such a case only those user involved in the workflow/review/approval - * process should be allowed to see the document. This method could - * be called by any function that returns the content e.g. getLatestContent() - * It may as well be used by SeedDMS_Core_Document::getAccessMode() to - * prevent access on the whole document if there is just one version. - * The return value is planed to be either M_NONE or M_READ. * - * @param object $user - * @return integer mode + * There is no real access mode for document content, so this is more + * like a virtual access mode, derived from the status of the document + * content. The function checks if {@link SeedDMS_Core_DMS::noReadForStatus} + * contains the status of the version and returns M_NONE if it exists and + * the user is not involved in a workflow or review/approval/revision. + * This method is called by all functions that returns the content e.g. + * {@link SeedDMS_Core_Document::getLatestContent()} + * It is also used by {@link SeedDMS_Core_Document::getAccessMode()} to + * prevent access on the whole document if there is no accessible version. + * + * FIXME: This function only works propperly if $u is the currently logged in + * user, because noReadForStatus will be set for this user. + * FIXED: instead of using $dms->noReadForStatus it is take from the user's role + * + * @param object $u user + * @return integer either M_NONE or M_READ */ function getAccessMode($u) { /* {{{ */ - if(!$this->_workflow) - $this->getWorkflow(); + $dms = $this->_document->_dms; - if($this->_workflow) { - if (!$this->_workflowState) - $this->getWorkflowState(); - $transitions = $this->_workflow->getNextTransitions($this->_workflowState); - foreach($transitions as $transition) { - if($this->triggerWorkflowTransitionIsAllowed($u, $transition)) - return M_READ; - } + if(!$u) return M_NONE; + + /* If read access isn't further restricted by status, than grant read access */ + if(!$dms->noReadForStatus) + return M_READ; + $noReadForStatus = $dms->noReadForStatus; + + if(!$noReadForStatus) + return M_READ; + + /* If the current status is not in list of status without read access, then grant read access */ + if(!in_array($this->getStatus()['status'], $noReadForStatus)) + return M_READ; + + /* Administrators have unrestricted access */ + if ($u->isAdmin()) return M_READ; + + /* The owner of the document has unrestricted access */ + $owner = $this->_document->getOwner(); + if ($u->getID() == $owner->getID()) return M_READ; + + /* Read/Write access on the document will also grant access on the version */ + if($this->_document->getAccessMode($u) >= M_READWRITE) return M_READ; + + /* At this point the current status is in the list of status without read access. + * The only way to still gain read access is, if the user is involved in the + * process, e.g. is a reviewer, approver or an active person in the workflow. + */ + $s = $this->getStatus(); + switch($s['status']) { + case S_DRAFT_REV: + $status = $this->getReviewStatus(); + foreach ($status as $r) { + if($r['status'] != -2) // Check if reviewer was removed + switch ($r["type"]) { + case 0: // Reviewer is an individual. + if($u->getId() == $r["required"]) + return M_READ; + break; + case 1: // Reviewer is a group. + $required = $dms->getGroup($r["required"]); + if (is_object($required) && $required->isMember($u)) + return M_READ; + break; + } + } + break; + case S_DRAFT_APP: + $status = $this->getApprovalStatus(); + foreach ($status as $r) { + if($r['status'] != -2) // Check if approver was removed + switch ($r["type"]) { + case 0: // Reviewer is an individual. + if($u->getId() == $r["required"]) + return M_READ; + break; + case 1: // Reviewer is a group. + $required = $dms->getGroup($r["required"]); + if (is_object($required) && $required->isMember($u)) + return M_READ; + break; + } + } + break; + case S_RELEASED: + break; + case S_IN_WORKFLOW: + if(!$this->_workflow) + $this->getWorkflow(); + + if($this->_workflow) { + if (!$this->_workflowState) + $this->getWorkflowState(); + $transitions = $this->_workflow->getNextTransitions($this->_workflowState); + foreach($transitions as $transition) { + if($this->triggerWorkflowTransitionIsAllowed($u, $transition)) + return M_READ; + } + } + break; + case S_REJECTED: + break; + case S_OBSOLETE: + break; + case S_EXPIRED: + break; } - return M_READ; + return M_NONE; } /* }}} */ /** @@ -3932,7 +4081,6 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ $this->_workflow->setDMS($this->_document->_dms); if($transition) { - echo "Trigger transition"; if(false === $this->triggerWorkflowTransition($user, $transition, $comment)) { $db->rollbackTransaction(); return false; From dde468ca9e6d1a9d030125ff83fdde0353d27a38 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 28 Sep 2017 20:48:29 +0200 Subject: [PATCH 24/64] make strict check for selected options in a select menu without strict checking an option with value=0 will be treated as if no option was selected. --- views/bootstrap/class.Settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index 1fac139f5..7eba8eff8 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -777,7 +777,7 @@ if(!is_writeable($settings->_configFilePath)) { echo "