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

This commit is contained in:
Uwe Steinmann 2020-06-05 18:10:23 +02:00
commit 50fb928988
10 changed files with 62 additions and 49 deletions

View File

@ -158,7 +158,9 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 5.1.18 Changes in version 5.1.18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- various minor improvements of indexer.php script
- minor fix for better behaviour of folder tree ('plus' signs appears if folder
has children)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 5.1.17 Changes in version 5.1.17
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -245,7 +245,7 @@ class SeedDMS_Core_Attribute { /* {{{ */
*/ */
function validate() { /* {{{ */ function validate() { /* {{{ */
/** @var SeedDMS_Core_AttributeDefinition $attrdef */ /** @var SeedDMS_Core_AttributeDefinition $attrdef */
$attrdef = $this->_attrdef(); /** @todo check this out, this method is not existing */ $attrdef = $this->_attrdef;
$result = $attrdef->validate($this->_value); $result = $attrdef->validate($this->_value);
$this->_validation_error = $attrdef->getValidationError(); $this->_validation_error = $attrdef->getValidationError();
return $result; return $result;
@ -1128,11 +1128,6 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
if(!$success) if(!$success)
$this->_validation_error = 3; $this->_validation_error = 3;
break; break;
case self::type_boolean: /** @todo: Same case in LINE 966 */
foreach($values as $value) {
$success &= preg_match('/^[01]$/', $value);
}
break;
case self::type_email: case self::type_email:
foreach($values as $value) { foreach($values as $value) {
$success &= preg_match('/^[a-z0-9._-]+@+[a-z0-9._-]+\.+[a-z]{2,4}$/i', $value); $success &= preg_match('/^[a-z0-9._-]+@+[a-z0-9._-]+\.+[a-z]{2,4}$/i', $value);

View File

@ -1580,7 +1580,7 @@ class SeedDMS_Core_DMS {
$orderdir = 'ASC'; $orderdir = 'ASC';
/** @noinspection PhpUndefinedConstantInspection */ /** @noinspection PhpUndefinedConstantInspection */
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ". $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
"AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.", ".S_IN_REVISION.") "; /** @todo S_IN_REVISION is not defined */ "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.") ";
if ($orderby=='e') $queryStr .= "ORDER BY `expires`"; if ($orderby=='e') $queryStr .= "ORDER BY `expires`";
else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`"; else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`";
else if ($orderby=='s') $queryStr .= "ORDER BY `status`"; else if ($orderby=='s') $queryStr .= "ORDER BY `status`";

View File

@ -1821,7 +1821,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if ((int)$version<1) { if ((int)$version<1) {
$queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id; $queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res) if (is_bool($resArr) && !$resArr)
return false; return false;
$version = $resArr[0]['m']+1; $version = $resArr[0]['m']+1;
@ -1892,7 +1892,6 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
// a document be rejected. // a document be rejected.
$pendingReview=false; $pendingReview=false;
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$reviewRes = array(); /** @todo unused variable */
foreach (array("i", "g") as $i){ foreach (array("i", "g") as $i){
if (isset($reviewers[$i])) { if (isset($reviewers[$i])) {
foreach ($reviewers[$i] as $reviewerID) { foreach ($reviewers[$i] as $reviewerID) {
@ -1911,7 +1910,6 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
// and make a recommendation on its release as an approved version. // and make a recommendation on its release as an approved version.
$pendingApproval=false; $pendingApproval=false;
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$approveRes = array(); /** @todo unused variable */
foreach (array("i", "g") as $i){ foreach (array("i", "g") as $i){
if (isset($approvers[$i])) { if (isset($approvers[$i])) {
foreach ($approvers[$i] as $approverID) { foreach ($approvers[$i] as $approverID) {
@ -1953,7 +1951,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
} }
/** @noinspection PhpMethodParametersCountMismatchInspection */ /** @noinspection PhpMethodParametersCountMismatchInspection */
$docResultSet->setStatus($status,$comment,$user); /** @todo parameter count wrong */ $docResultSet->setStatus($status);
$db->commitTransaction(); $db->commitTransaction();
return $docResultSet; return $docResultSet;
@ -1991,7 +1989,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if ((int) $version<1) { if ((int) $version<1) {
$queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id; $queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res) /** @todo undefined variable */ if (is_bool($resArr) && !$resArr)
return false; return false;
$version = $resArr[0]['m']; $version = $resArr[0]['m'];
@ -2057,7 +2055,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if (!isset($this->_content)) { if (!isset($this->_content)) {
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version`"; $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version`";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res) /** @todo undefined variable */ if (is_bool($resArr) && !$resArr)
return false; return false;
$this->_content = array(); $this->_content = array();
@ -2103,7 +2101,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." AND `version` = " . (int) $version; $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." AND `version` = " . (int) $version;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res) /** @todo undefined variable */ if (is_bool($resArr) && !$resArr)
return false; return false;
if (count($resArr) != 1) if (count($resArr) != 1)
return false; return false;
@ -2161,7 +2159,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC"; $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res) /** @todo: $res not defined */ if (is_bool($resArr) && !$resArr)
return false; return false;
$classname = $this->_dms->getClassname('documentcontent'); $classname = $this->_dms->getClassname('documentcontent');

View File

@ -555,7 +555,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if (isset($this->_subFolders)) { if (isset($this->_subFolders)) {
/** @noinspection PhpUndefinedFieldInspection */ /** @noinspection PhpUndefinedFieldInspection */
return count($this->subFolders); /** @todo not $this->_subFolders? */ return count($this->_subFolders);
} }
$queryStr = "SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this->_id; $queryStr = "SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
@ -757,7 +757,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if (isset($this->_documents)) { if (isset($this->_documents)) {
/** @noinspection PhpUndefinedFieldInspection */ /** @noinspection PhpUndefinedFieldInspection */
return count($this->documents); /** @todo not $this->_documents? */ return count($this->_documents);
} }
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id; $queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);

View File

@ -1784,6 +1784,22 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp()
- add parameters $orderdir, $orderby, $update to SeedDMS_Core::getExpiredDocuments() - add parameters $orderdir, $orderby, $update to SeedDMS_Core::getExpiredDocuments()
</notes> </notes>
</release> </release>
<release>
<date>2020-06-05</date>
<time>09:43:12</time>
<version>
<release>5.1.18</release>
<api>5.1.18</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- fixed remaining todos
</notes>
</release>
<release> <release>
<date>2017-02-28</date> <date>2017-02-28</date>
<time>06:34:50</time> <time>06:34:50</time>

View File

@ -78,7 +78,7 @@ $db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostn
//$db->_conn->debug = 1; //$db->_conn->debug = 1;
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir); $dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
if(!$dms->checkVersion()) { if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
echo "Database update needed."; echo "Database update needed.";
exit; exit;
} }

View File

@ -4,20 +4,19 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
} else { } else {
require_once("../inc/inc.ClassSettings.php"); require_once("../inc/inc.ClassSettings.php");
} }
require("Log.php");
function usage() { /* {{{ */ function usage() { /* {{{ */
echo "Usage:\n"; echo "Usage:".PHP_EOL;
echo " seeddms-indexer [-h] [-v] [--config <file>]\n"; echo " seeddms-indexer [-h] [-v] [--config <file>]".PHP_EOL;
echo "\n"; echo "".PHP_EOL;
echo "Description:\n"; echo "Description:".PHP_EOL;
echo " This program recreates the full text index of SeedDMS.\n"; echo " This program recreates the full text index of SeedDMS.".PHP_EOL;
echo "\n"; echo "".PHP_EOL;
echo "Options:\n"; echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.\n"; echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.\n"; echo " -v, --version: print version and exit.".PHP_EOL;
echo " -c: recreate index.\n"; echo " -c: recreate index.".PHP_EOL;
echo " --config: set alternative config file.\n"; echo " --config: set alternative config file.".PHP_EOL;
} /* }}} */ } /* }}} */
$version = "0.0.2"; $version = "0.0.2";
@ -36,7 +35,7 @@ if(isset($options['h']) || isset($options['help'])) {
/* Print version and exit */ /* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) { if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."\n"; echo $version."".PHP_EOL;
exit(0); exit(0);
} }
@ -60,6 +59,7 @@ if(isset($settings->_extraPath))
require_once("inc/inc.Init.php"); require_once("inc/inc.Init.php");
require_once("inc/inc.Extension.php"); require_once("inc/inc.Extension.php");
require_once("inc/inc.DBInit.php"); require_once("inc/inc.DBInit.php");
require "vendor/autoload.php";
if($settings->_fullSearchEngine == 'sqlitefts') { if($settings->_fullSearchEngine == 'sqlitefts') {
$indexconf = array( $indexconf = array(
@ -80,8 +80,8 @@ if($settings->_fullSearchEngine == 'sqlitefts') {
} }
function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
global $settings; global $settings, $themes;
echo $indent."D ".$folder->getName()."\n"; echo $themes->black($indent."D ".$folder->getName()).PHP_EOL;
$subfolders = $folder->getSubFolders(); $subfolders = $folder->getSubFolders();
foreach($subfolders as $subfolder) { foreach($subfolders as $subfolder) {
tree($dms, $index, $indexconf, $subfolder, $indent.' '); tree($dms, $index, $indexconf, $subfolder, $indent.' ');
@ -101,9 +101,9 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
} }
} }
$index->addDocument($idoc); $index->addDocument($idoc);
echo " (Document added)\n"; echo $themes->green(" (Document added)").PHP_EOL;
} catch(Exception $e) { } catch(Exception $e) {
echo " (Timeout)\n"; echo $themes->error(" (Timeout)").PHP_EOL;
} }
} else { } else {
try { try {
@ -113,7 +113,7 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
} }
$content = $document->getLatestContent(); $content = $document->getLatestContent();
if($created > $content->getDate()) { if($created > $content->getDate()) {
echo " (Document unchanged)\n"; echo $themes->italic(" (Document unchanged)").PHP_EOL;
} else { } else {
$index->delete($hit->id); $index->delete($hit->id);
try { try {
@ -126,21 +126,23 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
} }
} }
$index->addDocument($idoc); $index->addDocument($idoc);
echo " (Document updated)\n"; echo $themes->green(" (Document updated)").PHP_EOL;
} catch(Exception $e) { } catch(Exception $e) {
echo " (Timeout)\n"; echo $themes->error(" (Timeout)").PHP_EOL;
} }
} }
} }
} }
} /* }}} */ } /* }}} */
$themes = new \AlecRabbit\ConsoleColour\Themes();
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase); $db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\""); $db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir); $dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
if(!$dms->checkVersion()) { if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
echo "Database update needed.\n"; echo "Database update needed.".PHP_EOL;
exit(1); exit(1);
} }
@ -151,7 +153,7 @@ if($recreate)
else else
$index = $indexconf['Indexer']::open($settings->_luceneDir); $index = $indexconf['Indexer']::open($settings->_luceneDir);
if(!$index) { if(!$index) {
echo "Could not create index.\n"; echo "Could not create index.".PHP_EOL;
exit(1); exit(1);
} }

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ -z "${SEEDDMS_HOME}" ]; then if [ -z "${SEEDDMS_HOME}" ]; then
echo 'Please set $SEEDDMS_HOME before running this script' parentdir=$(dirname "$0")
exit 1 export SEEDDMS_HOME=$(dirname "$parentdir")
fi fi
exec php -f "${SEEDDMS_HOME}/utils/indexer.php" -- "${@}" exec php -f "${SEEDDMS_HOME}/utils/indexer.php" -- "${@}"

View File

@ -1872,7 +1872,7 @@ $(document).ready(function() {
* @param boolean $partialtree set to true if the given folder is the start folder * @param boolean $partialtree set to true if the given folder is the start folder
*/ */
function printNewTreeNavigationJs($folderid=0, $accessmode=M_READ, $showdocs=0, $formid='form1', $expandtree=0, $orderby='', $partialtree=false) { /* {{{ */ function printNewTreeNavigationJs($folderid=0, $accessmode=M_READ, $showdocs=0, $formid='form1', $expandtree=0, $orderby='', $partialtree=false) { /* {{{ */
function jqtree($obj, $path, $folder, $user, $accessmode, $showdocs=1, $expandtree=0, $orderby='', $level=0) { function jqtree($obj, $path, $folder, $user, $accessmode, $showdocs=1, $expandtree=0, $orderby='', $level=0) { /* {{{ */
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc'); $orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
if($path/* || $expandtree>=$level*/) { if($path/* || $expandtree>=$level*/) {
if($path) if($path)
@ -1885,7 +1885,7 @@ $(document).ready(function() {
$subfolders = array($pathfolder); $subfolders = array($pathfolder);
} }
foreach($subfolders as $subfolder) { foreach($subfolders as $subfolder) {
$node = array('label'=>$subfolder->getName(), 'id'=>$subfolder->getID(), 'load_on_demand'=>(0 && ($subfolder->hasSubFolders() || ($subfolder->hasDocuments() && $showdocs))) ? true : false, 'is_folder'=>true); $node = array('label'=>$subfolder->getName(), 'id'=>$subfolder->getID(), 'load_on_demand'=>(1 && ($subfolder->hasSubFolders() || ($subfolder->hasDocuments() && $showdocs))) ? true : false, 'is_folder'=>true);
if(/*$expandtree>=$level ||*/ $pathfolder->getID() == $subfolder->getID()) { if(/*$expandtree>=$level ||*/ $pathfolder->getID() == $subfolder->getID()) {
$node['children'] = jqtree($obj, $path, $subfolder, $user, $accessmode, $showdocs, $expandtree, $orderby, $level+1); $node['children'] = jqtree($obj, $path, $subfolder, $user, $accessmode, $showdocs, $expandtree, $orderby, $level+1);
if($showdocs) { if($showdocs) {
@ -1913,7 +1913,7 @@ $(document).ready(function() {
return $children; return $children;
} }
return array(); return array();
} } /* }}} */
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc'); $orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
if($folderid) { if($folderid) {
@ -1957,7 +1957,7 @@ var data = <?php echo json_encode($tree); ?>;
$(function() { $(function() {
const $tree = $('#jqtree<?php echo $formid ?>'); const $tree = $('#jqtree<?php echo $formid ?>');
$tree.tree({ $tree.tree({
// saveState: true, // saveState: false,
selectable: true, selectable: true,
data: data, data: data,
saveState: 'jqtree<?php echo $formid; ?>', saveState: 'jqtree<?php echo $formid; ?>',
@ -1980,7 +1980,7 @@ $(function() {
} }
}); });
// Unfold node for currently selected folder // Unfold node for currently selected folder
$('#jqtree<?php echo $formid ?>').tree('selectNode', $('#jqtree<?php echo $formid ?>').tree('getNodeById', <?php echo $folderid ?>), false); $('#jqtree<?php echo $formid ?>').tree('selectNode', $('#jqtree<?php echo $formid ?>').tree('getNodeById', <?php echo $folderid ?>), false, true);
$('#jqtree<?php echo $formid ?>').on( $('#jqtree<?php echo $formid ?>').on(
'tree.click', 'tree.click',
function(event) { function(event) {