+ * getHookObjects();
+ * foreach($hookObjs as $hookObj) {
+ * if (method_exists($hookObj, $hook)) {
+ * $ret = $hookObj->$hook($this, ...);
+ * ...
+ * }
+ * }
+ * ?>
+ *
+ *
+ * @params string $classname name of class (current class if left empty)
+ * @return array list of hook objects registered for the class
+ */
+ function getHookObjects($classname='') { /* {{{ */
+ if($classname)
+ $tmp = explode('_', $classname);
+ else
+ $tmp = explode('_', get_class($this));
+ if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) {
+ return $GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])];
+ }
+ return array();
+ } /* }}} */
+
+ /**
+ * Check if a hook is registered
+ *
+ * @param $hook string name of hook
+ * @return mixed false if one of the hooks fails,
+ * true if all hooks succedded,
+ * null if no hook was called
+ */
+ function hasHook($hook) { /* {{{ */
+ $tmp = explode('_', get_class($this));
+ if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) {
+ foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) {
+ if (method_exists($hookObj, $hook)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } /* }}} */
+
}
?>
diff --git a/inc/inc.DBInit.php b/inc/inc.DBInit.php
index 583e6482a..1519dd4e0 100644
--- a/inc/inc.DBInit.php
+++ b/inc/inc.DBInit.php
@@ -18,14 +18,33 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-if(!empty($settings->_coreDir))
- require_once($settings->_coreDir.'/Core.php');
-else
- require_once('SeedDMS/Core.php');
+if(isset($GLOBALS['SEEDDMS_HOOKS']['initDB'])) {
+ foreach($GLOBALS['SEEDDMS_HOOKS']['initDB'] as $hookObj) {
+ if (method_exists($hookObj, 'pretInitDB')) {
+ $hookObj->preInitDB(array('settings'=>$settings));
+ }
+ }
+}
$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 . "\"");
+if(isset($GLOBALS['SEEDDMS_HOOKS']['initDB'])) {
+ foreach($GLOBALS['SEEDDMS_HOOKS']['initDB'] as $hookObj) {
+ if (method_exists($hookObj, 'postInitDB')) {
+ $hookObj->postInitDB(array('db'=>$db, 'settings'=>$settings));
+ }
+ }
+}
+
+if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
+ foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
+ if (method_exists($hookObj, 'pretInitDMS')) {
+ $hookObj->preInitDMS(array('db'=>$db, 'settings'=>$settings));
+ }
+ }
+}
+
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
@@ -37,4 +56,13 @@ $dms->setRootFolderID($settings->_rootFolderID);
$dms->setMaxDirID($settings->_maxDirID);
$dms->setEnableConverting($settings->_enableConverting);
$dms->setViewOnlineFileTypes($settings->_viewOnlineFileTypes);
+
+if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
+ foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
+ if (method_exists($hookObj, 'postInitDMS')) {
+ $hookObj->postInitDMS(array('dms'=>$dms, 'settings'=>$settings));
+ }
+ }
+}
+
?>
diff --git a/inc/inc.Extension.php b/inc/inc.Extension.php
new file mode 100644
index 000000000..b3f6eaf26
--- /dev/null
+++ b/inc/inc.Extension.php
@@ -0,0 +1,50 @@
+
+ * @copyright Copyright (C) 2013 Uwe Steinmann
+ * @version Release: @package_version@
+ */
+
+require "inc.ClassExtensionMgr.php";
+require_once "inc.ClassExtBase.php";
+
+$extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir);
+$extconffile = $extMgr->getExtensionsConfFile();
+if(!file_exists($extconffile)) {
+ $extMgr->createExtensionConf();
+}
+$EXT_CONF = array();
+include($extconffile);
+
+foreach($EXT_CONF as $extname=>$extconf) {
+ if(!isset($extconf['disable']) || $extconf['disable'] == false) {
+ $classfile = $settings->_rootDir."/ext/".$extname."/".$extconf['class']['file'];
+ if(file_exists($classfile)) {
+ include($classfile);
+ $obj = new $extconf['class']['name'];
+ 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($__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;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/inc/inc.Init.php b/inc/inc.Init.php
new file mode 100644
index 000000000..2336a7344
--- /dev/null
+++ b/inc/inc.Init.php
@@ -0,0 +1,25 @@
+_coreDir))
+ require_once($settings->_coreDir.'/Core.php');
+else
+ require_once('SeedDMS/Core.php');
+
diff --git a/inc/inc.Language.php b/inc/inc.Language.php
index 4b7fe9fce..d1f51ab14 100644
--- a/inc/inc.Language.php
+++ b/inc/inc.Language.php
@@ -67,6 +67,11 @@ function getLanguages()
function getMLText($key, $replace = array(), $defaulttext = "", $lang="") { /* {{{ */
GLOBAL $settings, $LANG, $session, $MISSING_LANG;
+ $trantext = '';
+ if(0 && $settings->_otrance) {
+ $trantext = '';
+ }
+
if(!$lang) {
if($session)
$lang = $session->getLanguage();
@@ -87,17 +92,12 @@ function getMLText($key, $replace = array(), $defaulttext = "", $lang="") { /* {
} else
$tmpText = $LANG[$lang][$key];
-/*
- if (!isset($text[$key])) {
- if (!$defaulttext)
- return "Error getting Text: " . $key . " (" . $settings->_language . ")";
- else
- $tmpText = $defaulttext;
- } else
- $tmpText = $text[$key];
-*/
+ if(0 && $settings->_otrance) {
+ $_GLOBALS['used_langs'][$key] = $tmpText;
+ }
+
if (count($replace) == 0)
- return $tmpText;
+ return $tmpText.$trantext;
$keys = array_keys($replace);
foreach ($keys as $key)
diff --git a/inc/inc.Settings.php b/inc/inc.Settings.php
index a766e0811..b855a068d 100644
--- a/inc/inc.Settings.php
+++ b/inc/inc.Settings.php
@@ -47,7 +47,10 @@ if (file_exists("../inc/inc.Settings.old.php")) {
}
require_once('inc.ClassSettings.php');
-$settings = new Settings();
+if(defined("SEEDDMS_CONFIG_FILE"))
+ $settings = new Settings(SEEDDMS_CONFIG_FILE);
+else
+ $settings = new Settings();
if(!defined("SEEDDMS_INSTALL") && file_exists(dirname($settings->_configFilePath)."/ENABLE_INSTALL_TOOL")) {
die("SeedDMS won't run unless your remove the file ENABLE_INSTALL_TOOL from your configuration directory.");
}
@@ -112,4 +115,9 @@ if($settings->_enableFullSearch) {
}
}
+/* Add root Dir. Needed because the view classes are included
+ * relative to it.
+ */
+ini_set('include_path', $settings->_rootDir. PATH_SEPARATOR .ini_get('include_path'));
+
?>
diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php
index 8342681f7..d273fc0e4 100644
--- a/inc/inc.Utils.php
+++ b/inc/inc.Utils.php
@@ -79,6 +79,39 @@ function getReadableDurationArray($secs) {
return $units;
}
+/**
+ * Compare two version
+ *
+ * This functions compares two version in the format x.x.x
+ *
+ * @param string $ver1
+ * @param string $ver2
+ * @return int -1 if $ver1 < $ver2, 0 if $ver1 == $ver2, 1 if $ver1 > $ver2
+ */
+function cmpVersion($ver1, $ver2) {
+ $tmp1 = explode('.', $ver1);
+ $tmp2 = explode('.', $ver2);
+ if(intval($tmp1[0]) < intval($tmp2[0])) {
+ return -1;
+ } elseif(intval($tmp1[0]) > intval($tmp2[0])) {
+ return 1;
+ } else {
+ if(intval($tmp1[1]) < intval($tmp2[1])) {
+ return -1;
+ } elseif(intval($tmp1[1]) > intval($tmp2[1])) {
+ return 1;
+ } else {
+ if(intval($tmp1[2]) < intval($tmp2[2])) {
+ return -1;
+ } elseif(intval($tmp1[2]) > intval($tmp2[2])) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ }
+}
+
//
// The original string sanitizer, kept for reference.
//function sanitizeString($string) {
@@ -306,15 +339,26 @@ function dskspace($dir) { /* {{{ */
return $space;
} /* }}} */
-function add_log_line($msg="") { /* {{{ */
+/**
+ * Log a message
+ *
+ * This function is still here for convienice and because it is
+ * used at so many places.
+ *
+ * @param string $msg
+ * @param int $priority can be one of PEAR_LOG_EMERG, PEAR_LOG_ALERT,
+ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
+ * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
+ */
+function add_log_line($msg="", $priority=null) { /* {{{ */
global $logger, $user;
if(!$logger) return;
if($user)
- $logger->log($user->getLogin()." (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg);
+ $logger->log($user->getLogin()." (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg, $priority);
else
- $logger->log("-- (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg);
+ $logger->log("-- (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg, $priority);
} /* }}} */
function _add_log_line($msg="") { /* {{{ */
@@ -444,6 +488,22 @@ function checkQuota($user) { /* {{{ */
return ($quota - $user->getUsedDiskSpace());
} /* }}} */
+function encryptData($key, $value){
+ $text = $value;
+ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
+ $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
+ $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
+ return $crypttext;
+}
+
+function decryptData($key, $value){
+ $crypttext = $value;
+ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
+ $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
+ $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypttext, MCRYPT_MODE_ECB, $iv);
+ return trim($decrypttext);
+}
+
/**
* Return file extension for a give mimetype
*
diff --git a/inc/inc.Version.php b/inc/inc.Version.php
index 88401cc22..5e8ead552 100644
--- a/inc/inc.Version.php
+++ b/inc/inc.Version.php
@@ -20,7 +20,7 @@
class SeedDMS_Version {
- public $_number = "4.3.23";
+ public $_number = "5.0.0";
private $_string = "SeedDMS";
function SeedDMS_Version() {
diff --git a/install/create_tables-innodb.sql b/install/create_tables-innodb.sql
index cd065b66f..26e923ef3 100644
--- a/install/create_tables-innodb.sql
+++ b/install/create_tables-innodb.sql
@@ -65,6 +65,7 @@ CREATE TABLE `tblUsers` (
`loginfailures` tinyint(4) NOT NULL default '0',
`disabled` smallint(1) NOT NULL default '0',
`quota` bigint,
+ `homefolder` int(11) default NULL,
PRIMARY KEY (`id`),
UNIQUE (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -136,6 +137,8 @@ CREATE TABLE `tblFolders` (
CONSTRAINT `tblFolders_owner` FOREIGN KEY (`owner`) REFERENCES `tblUsers` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ALTER TABLE tblUsers ADD CONSTRAINT `tblUsers_homefolder` FOREIGN KEY (`homefolder`) REFERENCES `tblFolders` (`id`);
+
-- --------------------------------------------------------
--
@@ -708,8 +711,8 @@ CREATE TABLE `tblVersion` (
-- Initial content for database
--
-INSERT INTO tblUsers VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, '0000-00-00 00:00:00', 0, 0, 0);
-INSERT INTO tblUsers VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, '0000-00-00 00:00:00', 0, 0, 0);
+INSERT INTO tblUsers VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, '0000-00-00 00:00:00', 0, 0, 0, NULL);
+INSERT INTO tblUsers VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, '0000-00-00 00:00:00', 0, 0, 0, NULL);
INSERT INTO tblFolders VALUES (1, 'DMS', 0, '', 'DMS root', UNIX_TIMESTAMP(), 1, 0, 2, 0);
-INSERT INTO tblVersion VALUES (NOW(), 4, 3, 0);
+INSERT INTO tblVersion VALUES (NOW(), 5, 0, 0);
INSERT INTO tblCategory VALUES (0, '');
diff --git a/install/create_tables-sqlite3.sql b/install/create_tables-sqlite3.sql
index 13378361e..444ca5c34 100644
--- a/install/create_tables-sqlite3.sql
+++ b/install/create_tables-sqlite3.sql
@@ -62,6 +62,7 @@ CREATE TABLE `tblUsers` (
`loginfailures` INTEGER NOT NULL default '0',
`disabled` INTEGER NOT NULL default '0',
`quota` INTEGER,
+ `homefolder` INTEGER default NULL REFERENCES `tblFolders` (`id`),
UNIQUE (`login`)
);
@@ -615,8 +616,8 @@ CREATE TABLE `tblVersion` (
-- Initial content for database
--
-INSERT INTO tblUsers VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, '', 0, 0, 0);
-INSERT INTO tblUsers VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, '', 0, 0, 0);
+INSERT INTO tblUsers VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, '', 0, 0, 0, 0);
+INSERT INTO tblUsers VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, '', 0, 0, 0, 0);
INSERT INTO tblFolders VALUES (1, 'DMS', 0, '', 'DMS root', strftime('%s','now'), 1, 0, 2, 0);
-INSERT INTO tblVersion VALUES (DATETIME(), 4, 3, 0);
+INSERT INTO tblVersion VALUES (DATETIME(), 5, 0, 0);
INSERT INTO tblCategory VALUES (0, '');
diff --git a/install/install.php b/install/install.php
index e9762cd03..db2258bc0 100644
--- a/install/install.php
+++ b/install/install.php
@@ -119,7 +119,7 @@ function fileExistsInIncludePath($file) { /* {{{ */
* Load default settings + set
*/
define("SEEDDMS_INSTALL", "on");
-define("SEEDDMS_VERSION", "4.3.23");
+define("SEEDDMS_VERSION", "5.0.0");
require_once('../inc/inc.ClassSettings.php');
diff --git a/install/settings.xml.template_install b/install/settings.xml.template_install
index d4c789800..55988c660 100644
--- a/install/settings.xml.template_install
+++ b/install/settings.xml.template_install
@@ -34,7 +34,7 @@
-->