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

This commit is contained in:
Uwe Steinmann 2021-11-04 17:07:36 +01:00
commit 4e5fefa4ba
4 changed files with 90 additions and 73 deletions

View File

@ -532,13 +532,13 @@ class SeedDMS_Core_DatabaseAccess {
"GROUP BY `tblDocumentReviewLog`.`reviewID` "; //.
// "ORDER BY `maxLogID`";
}
if (!$this->_ttreviewid) {
if (!$this->_ttreviewid) {
if (!$this->getResult($queryStr))
return false;
$this->_ttreviewid=true;
}
else {
if (is_bool($override) && $override) {
if (is_bool($override) && $override) {
if (!$this->getResult("DROP TABLE IF EXISTS `ttreviewid`"))
return false;
if (!$this->getResult($queryStr))

View File

@ -51,6 +51,12 @@ class SeedDMS_Extension_Mgr {
*/
protected $cachedir;
/**
* @var array $configcache cached result of checkExtensionByName()
* @access protected
*/
protected $configcache;
/**
* @var string[] $errmsg list of error message from last operation
* @access protected
@ -104,6 +110,7 @@ class SeedDMS_Extension_Mgr {
* is given
*/
public function __construct($extdir = '', $cachedir = '', $reposurl = '', $proxyurl='', $proxyuser='', $proxypass='') { /* {{{ */
$this->configcache = [];
$this->cachedir = $cachedir;
$this->extdir = $extdir;
$this->reposurl = $reposurl;
@ -325,48 +332,66 @@ class SeedDMS_Extension_Mgr {
return $ret;
} /* }}} */
public function checkExtensionByDir($dir, $options = array()) { /* {{{ */
$this->errmsgs = array();
if(!file_exists($dir)) {
if(!file_exists($this->extdir.'/'.$dir))
return false;
else
$dir = $this->extdir.'/'.$dir;
}
if(!file_exists($dir."/conf.php")) {
$this->errmsgs[] = "Missing extension configuration";
return false;
}
include($dir."/conf.php");
if(!isset($EXT_CONF)) {
$this->errmsgs[] = "Missing \$EXT_CONF in configuration";
return false;
}
$extname = key($EXT_CONF);
if(!$extname || !preg_match('/[a-zA-Z_]*/', $extname)) {
$this->errmsgs[] = "Extension has invalid or no name";
return false;
}
$extconf = $EXT_CONF[$extname];
if(!empty($extconf['language']['file']) && !file_exists($dir."/".$extconf['language']['file'])) {
$this->errmsgs[] = "Missing language file";
}
if(!empty($extconf['class']['file']) && !file_exists($dir."/".$extconf['class']['file'])) {
$this->errmsgs[] = "Missing class file";
}
if(!empty($extconf['icon']) && !file_exists($dir."/".$extconf['icon'])) {
$this->errmsgs[] = "Missing icon file";
}
if($this->errmsgs)
return false;
return self::checkExtensionByName($extname, $extconf, $options);
}
/**
* Check content of extension directory or configuration of extension
*
* @param string|array $dir full path to extension directory or extension name
* or an array containing the configuration.
* @param boolean $noconstraints set to true if constraints to local seeddms
* installation shall not be checked.
* @param array $options array with options elements 'noconstraints' and 'nofiles'.
* Set 'noconstraints' to true if
* constraints to local seeddms installation shall not be checked. Set 'nofiles'
* to true to turn off checking of files
* @return boolean true if check was successful, otherwise false
*/
public function checkExtension($dir, $options=array()) { /* {{{ */
$this->errmsgs = array();
if(is_string($dir)) {
if(!file_exists($dir)) {
if(!file_exists($this->extdir.'/'.$dir))
return false;
else
$dir = $this->extdir.'/'.$dir;
}
if(!file_exists($dir."/conf.php")) {
$this->errmsgs[] = "Missing extension configuration";
return false;
}
include($dir."/conf.php");
if(!isset($EXT_CONF)) {
$this->errmsgs[] = "Missing \$EXT_CONF in configuration";
return false;
}
$extname = key($EXT_CONF);
if(!$extname || !preg_match('/[a-zA-Z_]*/', $extname)) {
$this->errmsgs[] = "Extension has invalid or no name";
return false;
}
$extconf = $EXT_CONF[$extname];
} elseif(is_array($dir)) {
$extconf = $dir;
/* If just the configuration is passed, then there is no way to check
* for existence of files.
*/
$options['nofiles'] = true;
public function checkExtensionByName($extname, $extconf, $options=array()) { /* {{{ */
if(isset($this->configcache[$extname])) {
return $this->configcache[$extname];
}
$this->errmsgs = array();
if(!isset($extconf['constraints']['depends']['seeddms'])) {
$this->errmsgs[] = "Missing dependency on SeedDMS";
}
@ -382,17 +407,6 @@ class SeedDMS_Extension_Mgr {
if(!isset($extconf['author'])) {
$this->errmsgs[] = "Missing author";
}
if(!isset($options['nofiles']) || $options['nofiles'] == false) {
if(!empty($extconf['language']['file']) && !file_exists($dir."/".$extconf['language']['file'])) {
$this->errmsgs[] = "Missing language file";
}
if(!empty($extconf['class']['file']) && !file_exists($dir."/".$extconf['class']['file'])) {
$this->errmsgs[] = "Missing class file";
}
if(!empty($extconf['icon']) && !file_exists($dir."/".$extconf['icon'])) {
$this->errmsgs[] = "Missing icon file";
}
}
if(!isset($options['noconstraints']) || $options['noconstraints'] == false) {
if(isset($extconf['constraints']['depends'])) {
@ -446,9 +460,11 @@ class SeedDMS_Extension_Mgr {
}
if($this->errmsgs)
return false;
$this->configcache[$extname] = false;
else
$this->configcache[$extname] = true;
return true;
return $this->configcache[$extname];
} /* }}} */
static protected function rrmdir($dir) { /* {{{ */
@ -498,7 +514,7 @@ class SeedDMS_Extension_Mgr {
// exec($cmd);
/* Check if extension is complete and fullfills the constraints */
if(!self::checkExtension($newdir)) {
if(!self::checkExtensionByDir($newdir)) {
self::rrmdir($newdir);
return false;
}

View File

@ -56,7 +56,7 @@ class UI extends UI_Default {
$decorators = array();
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
if(!$settings->extensionIsDisabled($extname)) {
if($extMgr->checkExtension($extconf)) {
if($extMgr->checkExtensionByName($extname, $extconf)) {
if(isset($extconf['decorators'][$class])) {
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
if(file_exists($filename)) {
@ -73,7 +73,7 @@ class UI extends UI_Default {
$httpbasedir = '';
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
if(!$settings->extensionIsDisabled($extname)) {
if($extMgr->checkExtension($extconf)) {
if($extMgr->checkExtensionByName($extname, $extconf)) {
/* Setting the 'views' element in the configuration can be used to
* replace an existing view in views/bootstrap/, e.g. class.ViewFolder.php
* without providing an out/out.ViewFolder.php. In that case $httpbasedir

View File

@ -26,9 +26,10 @@ $version = new SeedDMS_Version;
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
if(!$settings->extensionIsDisabled($extname)) {
$disabled = true;
if($extMgr->checkExtension($extconf)) {
if($extMgr->checkExtensionByName($extname, $extconf)) {
$disabled = false;
} else {
$settings->disableExtension($extname);
// echo $extMgr->getErrorMsg();
}
/* check for requirements */
@ -42,30 +43,30 @@ foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
}
*/
if(!$disabled) {
if(isset($extconf['class']) && isset($extconf['class']['file']) && isset($extconf['class']['name'])) {
$classfile = $settings->_rootDir."/ext/".$extname."/".$extconf['class']['file'];
if(file_exists($classfile)) {
include($classfile);
$obj = new $extconf['class']['name']($settings, null, $logger);
if(method_exists($obj, 'init'))
$obj->init();
if(isset($extconf['class']) && isset($extconf['class']['file']) && isset($extconf['class']['name'])) {
$classfile = $settings->_rootDir."/ext/".$extname."/".$extconf['class']['file'];
if(file_exists($classfile)) {
include($classfile);
$obj = new $extconf['class']['name']($settings, null, $logger);
if(method_exists($obj, 'init'))
$obj->init();
}
}
}
if(isset($extconf['language']['file'])) {
$langfile = $settings->_rootDir."/ext/".$extname."/".$extconf['language']['file'];
if(file_exists($langfile)) {
unset($__lang);
include($langfile);
if(isset($__lang) && $__lang) {
foreach($__lang as $lang=>&$data) {
if(isset($GLOBALS['LANG'][$lang]))
$GLOBALS['LANG'][$lang] = array_merge($GLOBALS['LANG'][$lang], $data);
else
$GLOBALS['LANG'][$lang] = $data;
if(isset($extconf['language']['file'])) {
$langfile = $settings->_rootDir."/ext/".$extname."/".$extconf['language']['file'];
if(file_exists($langfile)) {
unset($__lang);
include($langfile);
if(isset($__lang) && $__lang) {
foreach($__lang as $lang=>&$data) {
if(isset($GLOBALS['LANG'][$lang]))
$GLOBALS['LANG'][$lang] = array_merge($GLOBALS['LANG'][$lang], $data);
else
$GLOBALS['LANG'][$lang] = $data;
}
}
}
}
}
}
}
}