mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
52dfa8f401
|
@ -1859,6 +1859,9 @@ class SeedDMS_Core_DMS {
|
|||
$queryStr = '';
|
||||
}
|
||||
break; // }}}
|
||||
default:
|
||||
return false;
|
||||
break; // }}}
|
||||
}
|
||||
|
||||
if($queryStr) {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
</stability>
|
||||
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||
<notes>
|
||||
- SeedDMS_Core_DMS::getDocumentList() returns false, if an unknown list passed
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="SeedDMS" name="/">
|
||||
|
|
|
@ -8,36 +8,36 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
|
|||
}
|
||||
|
||||
function usage() { /* {{{ */
|
||||
echo "Usage:\n";
|
||||
echo " seeddms-adddoc [--config <file>] [-c <comment>] [-k <keywords>] [-s <number>] [-n <name>] [-V <version>] [-s <sequence>] [-t <mimetype>] [-a <attribute=value>] [-h] [-v] -F <folder id> -D <document id> -f <filename>\n";
|
||||
echo "\n";
|
||||
echo "Description:\n";
|
||||
echo " This program uploads a file into a folder or updates a document of SeedDMS.\n";
|
||||
echo "\n";
|
||||
echo "Options:\n";
|
||||
echo " -h, --help: print usage information and exit.\n";
|
||||
echo " -v, --version: print version and exit.\n";
|
||||
echo " --config: set alternative config file.\n";
|
||||
echo " -F <folder id>: id of folder the file is uploaded to\n";
|
||||
echo " -D <document id>: id of document the file is uploaded to.\n";
|
||||
echo " This will only be used if no folder id is given.\n";
|
||||
echo " -c <comment>: set comment for document. See [1].\n";
|
||||
echo " -C <comment>: set comment for version\n";
|
||||
echo " -k <keywords>: set keywords for file. See [1].\n";
|
||||
echo " -K <categories>: set categories for file. See [1].\n";
|
||||
echo " -s <number>: set sequence for file (used for ordering files within a folder. See [1].\n";
|
||||
echo " -n <name>: set name of file\n";
|
||||
echo " -V <version>: set version of file (defaults to 1). See [2].\n";
|
||||
echo " -u <user>: login name of user\n";
|
||||
echo " -f <filename>: upload this file\n";
|
||||
echo " -s <sequence>: set sequence of file. See [1]\n";
|
||||
echo " -t <mimetype> set mimetype of file manually. Do not do that unless you know\n";
|
||||
echo " what you do. If not set, the mimetype will be determined automatically.\n";
|
||||
echo " -a <attribute=value>: Set a document attribute; can occur multiple times. See [1].\n";
|
||||
echo " -A <attribute=value>: Set a version attribute; can occur multiple times.\n";
|
||||
echo "\n";
|
||||
echo "[1] This option applies only if a new document is uploaded. It has no effect\n"." if a new document version is uploaded.\n";
|
||||
echo "[2] If a new document version is uploaded it defaults to the next version number.\n";
|
||||
echo "Usage:".PHP_EOL;
|
||||
echo " seeddms-adddoc [--config <file>] [-c <comment>] [-k <keywords>] [-s <number>] [-n <name>] [-V <version>] [-s <sequence>] [-t <mimetype>] [-a <attribute=value>] [-h] [-v] -F <folder id> -D <document id> -f <filename>".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "Description:".PHP_EOL;
|
||||
echo " This program uploads a file into a folder or updates a document 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 " -F <folder id>: id of folder the file is uploaded to".PHP_EOL;
|
||||
echo " -D <document id>: id of document the file is uploaded to.".PHP_EOL;
|
||||
echo " This will only be used if no folder id is given.".PHP_EOL;
|
||||
echo " -c <comment>: set comment for document. See [1].".PHP_EOL;
|
||||
echo " -C <comment>: set comment for version".PHP_EOL;
|
||||
echo " -k <keywords>: set keywords for file. See [1].".PHP_EOL;
|
||||
echo " -K <categories>: set categories for file. See [1].".PHP_EOL;
|
||||
echo " -s <number>: set sequence for file (used for ordering files within a folder. See [1].".PHP_EOL;
|
||||
echo " -n <name>: set name of file".PHP_EOL;
|
||||
echo " -V <version>: set version of file (defaults to 1). See [2].".PHP_EOL;
|
||||
echo " -u <user>: login name of user".PHP_EOL;
|
||||
echo " -f <filename>: upload this file".PHP_EOL;
|
||||
echo " -s <sequence>: set sequence of file. See [1]".PHP_EOL;
|
||||
echo " -t <mimetype> set mimetype of file manually. Do not do that unless you know".PHP_EOL;
|
||||
echo " what you do. If not set, the mimetype will be determined automatically.".PHP_EOL;
|
||||
echo " -a <attribute=value>: Set a document attribute; can occur multiple times. See [1].".PHP_EOL;
|
||||
echo " -A <attribute=value>: Set a version attribute; can occur multiple times.".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "[1] This option applies only if a new document is uploaded. It has no effect".PHP_EOL." if a new document version is uploaded.".PHP_EOL;
|
||||
echo "[2] If a new document version is uploaded it defaults to the next version number.".PHP_EOL;
|
||||
} /* }}} */
|
||||
|
||||
$version = "0.0.1";
|
||||
|
@ -56,13 +56,15 @@ if(isset($options['h']) || isset($options['help'])) {
|
|||
|
||||
/* Print version and exit */
|
||||
if(isset($options['v']) || isset($options['verѕion'])) {
|
||||
echo $version."\n";
|
||||
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 parent folder or document */
|
||||
|
@ -73,7 +75,7 @@ if(isset($options['F'])) {
|
|||
if(isset($options['D'])) {
|
||||
$documentid = (int) $options['D'];
|
||||
} else {
|
||||
echo "Missing folder/document ID\n";
|
||||
echo "Missing folder/document ID".PHP_EOL;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ if(isset($options['K'])) {
|
|||
if($cat) {
|
||||
$categories[] = $cat;
|
||||
} else {
|
||||
echo "Category '".$categoryname."' not found\n";
|
||||
echo "Category '".$categoryname."' not found".PHP_EOL;
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
|
@ -168,12 +170,12 @@ if (isset($options['a'])) {
|
|||
$attrKey = strstr($thisAttribute, '=', true);
|
||||
$attrVal = substr(strstr($thisAttribute, '='), 1);
|
||||
if (empty($attrKey) || empty($attrVal)) {
|
||||
echo "Document attribute $thisAttribute not understood\n";
|
||||
echo "Document attribute $thisAttribute not understood".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
$attrdef = $dms->getAttributeDefinitionByName($attrKey);
|
||||
if (!$attrdef) {
|
||||
echo "Document attribute $attrKey unknown\n";
|
||||
echo "Document attribute $attrKey unknown".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
$document_attributes[$attrdef->getID()] = $attrVal;
|
||||
|
@ -194,12 +196,12 @@ if (isset($options['A'])) {
|
|||
$attrKey = strstr($thisAttribute, '=', true);
|
||||
$attrVal = substr(strstr($thisAttribute, '='), 1);
|
||||
if (empty($attrKey) || empty($attrVal)) {
|
||||
echo "Version attribute $thisAttribute not understood\n";
|
||||
echo "Version attribute $thisAttribute not understood".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
$attrdef = $dms->getAttributeDefinitionByName($attrKey);
|
||||
if (!$attrdef) {
|
||||
echo "Version attribute $attrKey unknown\n";
|
||||
echo "Version attribute $attrKey unknown".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
$version_attributes[$attrdef->getID()] = $attrVal;
|
||||
|
@ -251,11 +253,11 @@ if(is_readable($filename)) {
|
|||
}
|
||||
$filetype = "." . pathinfo($filename, PATHINFO_EXTENSION);
|
||||
} else {
|
||||
echo "File '".$filename."' has zero size\n";
|
||||
echo "File '".$filename."' has zero size".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
echo "File '".$filename."' is not readable\n";
|
||||
echo "File '".$filename."' is not readable".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -266,30 +268,30 @@ if($folderid) {
|
|||
$folder = $dms->getFolder($folderid);
|
||||
|
||||
if (!is_object($folder)) {
|
||||
echo "Could not find specified folder\n";
|
||||
echo "Could not find specified folder".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($folder->getAccessMode($user) < M_READWRITE) {
|
||||
echo "Not sufficient access rights\n";
|
||||
echo "Not sufficient access rights".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
} elseif($documentid) {
|
||||
$document = $dms->getDocument($documentid);
|
||||
|
||||
if (!is_object($document)) {
|
||||
echo "Could not find specified document\n";
|
||||
echo "Could not find specified document".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($document->getAccessMode($user) < M_READWRITE) {
|
||||
echo "Not sufficient access rights\n";
|
||||
echo "Not sufficient access rights".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_numeric($sequence)) {
|
||||
echo "Sequence must be numeric\n";
|
||||
echo "Sequence must be numeric".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -344,7 +346,7 @@ if($folder) {
|
|||
$controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs);
|
||||
|
||||
if(!$document = $controller->run()) {
|
||||
echo "Could not add document to folder\n";
|
||||
echo "Could not add document to folder".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
} elseif($document) {
|
||||
|
@ -364,8 +366,7 @@ if($folder) {
|
|||
$controller->setParam('workflow', null);
|
||||
|
||||
if(!$content = $controller->run()) {
|
||||
echo "Could not add version to document\n";
|
||||
echo "Could not add version to document".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,25 +1,32 @@
|
|||
<?php
|
||||
include("../inc/inc.ClassSettings.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:\n";
|
||||
echo " seeddms-createfolder [--config <file>] [-c <comment>] [-n <name>] [-s <sequence>] [-h] [-v] -F <parent id>\n";
|
||||
echo "\n";
|
||||
echo "Description:\n";
|
||||
echo " This program creates a new folder in SeedDMS.\n";
|
||||
echo "\n";
|
||||
echo "Options:\n";
|
||||
echo " -h, --help: print usage information and exit.\n";
|
||||
echo " -v, --version: print version and exit.\n";
|
||||
echo " --config: set alternative config file.\n";
|
||||
echo " -F <parent id>: id of parent folder\n";
|
||||
echo " -c <comment>: set comment for file\n";
|
||||
echo " -n <name>: set name of the folder\n";
|
||||
echo " -s <sequence>: set sequence of folder\n";
|
||||
echo "Usage:".PHP_EOL;
|
||||
echo " seeddms-createfolder [--config <file>] [-c <comment>] [-n <name>] [-s <sequence>] [-h] [-v] -F <parent id>".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "Description:".PHP_EOL;
|
||||
echo " This program creates a new folder in 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 " -u <user>: login name of user".PHP_EOL;
|
||||
echo " -F <parent id>: id of parent folder".PHP_EOL;
|
||||
echo " -c <comment>: set comment for file".PHP_EOL;
|
||||
echo " -n <name>: set name of the folder".PHP_EOL;
|
||||
echo " -s <sequence>: set sequence of folder".PHP_EOL;
|
||||
} /* }}} */
|
||||
|
||||
$version = "0.0.1";
|
||||
$shortoptions = "F:c:s:n:hv";
|
||||
$shortoptions = "F:u:c:s:n:hv";
|
||||
$longoptions = array('help', 'version', 'config:');
|
||||
if(false === ($options = getopt($shortoptions, $longoptions))) {
|
||||
usage();
|
||||
|
@ -34,30 +41,30 @@ if(isset($options['h']) || isset($options['help'])) {
|
|||
|
||||
/* Print version and exit */
|
||||
if(isset($options['v']) || isset($options['verѕion'])) {
|
||||
echo $version."\n";
|
||||
echo $version.PHP_EOL;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Set alternative config file */
|
||||
if(isset($options['config'])) {
|
||||
$settings = new Settings($options['config']);
|
||||
} else {
|
||||
$settings = new Settings();
|
||||
define('SEEDDMS_CONFIG_FILE', $options['config']);
|
||||
} elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) {
|
||||
define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']);
|
||||
}
|
||||
|
||||
if(isset($settings->_extraPath))
|
||||
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
|
||||
|
||||
require_once("SeedDMS/Core.php");
|
||||
|
||||
if(isset($options['F'])) {
|
||||
$folderid = (int) $options['F'];
|
||||
} else {
|
||||
echo "Missing parent folder ID\n";
|
||||
echo "Missing parent folder ID".PHP_EOL;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$username = '';
|
||||
if(isset($options['u'])) {
|
||||
$username = $options['u'];
|
||||
}
|
||||
|
||||
$comment = '';
|
||||
if(isset($options['c'])) {
|
||||
$comment = $options['c'];
|
||||
|
@ -73,46 +80,102 @@ if(isset($options['n'])) {
|
|||
$name = $options['n'];
|
||||
}
|
||||
|
||||
$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->_conn->debug = 1;
|
||||
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.ClassEmailNotify.php");
|
||||
include($myincpath."/inc/inc.ClassController.php");
|
||||
|
||||
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
|
||||
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
|
||||
echo "Database update needed.";
|
||||
exit;
|
||||
/* 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);
|
||||
/* }}} */
|
||||
|
||||
/* Create a global notifier object {{{ */
|
||||
$notifier = new SeedDMS_NotificationService();
|
||||
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) {
|
||||
if(method_exists($notificationObj, 'preAddService')) {
|
||||
$notificationObj->preAddService($dms, $notifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dms->setRootFolderID($settings->_rootFolderID);
|
||||
$dms->setMaxDirID($settings->_maxDirID);
|
||||
$dms->setEnableConverting($settings->_enableConverting);
|
||||
$dms->setViewOnlineFileTypes($settings->_viewOnlineFileTypes);
|
||||
if($settings->_enableEmail) {
|
||||
$notifier->addService(new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword));
|
||||
}
|
||||
|
||||
/* Create a global user object */
|
||||
$user = $dms->getUser(1);
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) {
|
||||
if(method_exists($notificationObj, 'postAddService')) {
|
||||
$notificationObj->postAddService($dms, $notifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
$folder = $dms->getFolder($folderid);
|
||||
|
||||
if (!is_object($folder)) {
|
||||
echo "Could not find specified folder\n";
|
||||
echo "Could not find specified folder".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($folder->getAccessMode($user) < M_READWRITE) {
|
||||
echo "Not sufficient access rights\n";
|
||||
echo "Not sufficient access rights".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!is_numeric($sequence)) {
|
||||
echo "Sequence must be numeric\n";
|
||||
echo "Sequence must be numeric".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$res = $folder->addSubFolder($name, $comment, $user, $sequence);
|
||||
$controller = Controller::factory('AddSubFolder', array('dms'=>$dms, 'user'=>$user));
|
||||
$controller->setParam('folder', $folder);
|
||||
$controller->setParam('name', $name);
|
||||
$controller->setParam('comment', $comment);
|
||||
$controller->setParam('sequence', $sequence);
|
||||
$controller->setParam('attributes', array());
|
||||
$controller->setParam('notificationgroups', array());
|
||||
$controller->setParam('notificationusers', array());
|
||||
if(!$subFolder = $controller->run()) {
|
||||
echo "Could not add subfolder to folder".PHP_EOL;
|
||||
} else {
|
||||
// Send notification to subscribers.
|
||||
if($notifier) {
|
||||
$fnl = $folder->getNotifyList();
|
||||
$snl = $subFolder->getNotifyList();
|
||||
$nl = array(
|
||||
'users'=>array_unique(array_merge($snl['users'], $fnl['users']), SORT_REGULAR),
|
||||
'groups'=>array_unique(array_merge($snl['groups'], $fnl['groups']), SORT_REGULAR)
|
||||
);
|
||||
|
||||
if (is_bool($res) && !$res) {
|
||||
echo "Could not add folder\n";
|
||||
exit(1);
|
||||
$subject = "new_subfolder_email_subject";
|
||||
$message = "new_subfolder_email_body";
|
||||
$params = array();
|
||||
$params['name'] = $subFolder->getName();
|
||||
$params['folder_name'] = $folder->getName();
|
||||
$params['folder_path'] = $folder->getFolderPathPlain();
|
||||
$params['username'] = $user->getFullName();
|
||||
$params['comment'] = $comment;
|
||||
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$subFolder->getID();
|
||||
$params['sitename'] = $settings->_siteName;
|
||||
$params['http_root'] = $settings->_httpRoot;
|
||||
$notifier->toList($user, $nl["users"], $subject, $message, $params);
|
||||
foreach ($nl["groups"] as $grp) {
|
||||
$notifier->toGroup($user, $grp, $subject, $message, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
<?php
|
||||
if(isset($_SERVER['SEEDDMS_HOME'])) {
|
||||
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php");
|
||||
ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path'));
|
||||
$myincpath = $_SERVER['SEEDDMS_HOME'];
|
||||
} else {
|
||||
require_once("../inc/inc.ClassSettings.php");
|
||||
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-indexer [-h] [-v] [-c] [--config <file>]".PHP_EOL;
|
||||
echo "".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "Description:".PHP_EOL;
|
||||
echo " This program recreates the full text index of SeedDMS.".PHP_EOL;
|
||||
echo "".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;
|
||||
|
@ -35,15 +37,15 @@ if(isset($options['h']) || isset($options['help'])) {
|
|||
|
||||
/* Print version and exit */
|
||||
if(isset($options['v']) || isset($options['verѕion'])) {
|
||||
echo $version."".PHP_EOL;
|
||||
echo $version.PHP_EOL;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Set alternative config file */
|
||||
if(isset($options['config'])) {
|
||||
$settings = new Settings($options['config']);
|
||||
} else {
|
||||
$settings = new Settings();
|
||||
define('SEEDDMS_CONFIG_FILE', $options['config']);
|
||||
} elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) {
|
||||
define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']);
|
||||
}
|
||||
|
||||
/* recreate index */
|
||||
|
@ -52,14 +54,10 @@ if(isset($options['c'])) {
|
|||
$recreate = true;
|
||||
}
|
||||
|
||||
if(isset($settings->_extraPath))
|
||||
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
|
||||
//ini_set('include_path', $settings->_rootDir. PATH_SEPARATOR .ini_get('include_path'));
|
||||
|
||||
require_once("inc/inc.Init.php");
|
||||
require_once("inc/inc.Extension.php");
|
||||
require_once("inc/inc.DBInit.php");
|
||||
require "vendor/autoload.php";
|
||||
include($myincpath."/inc/inc.Settings.php");
|
||||
include($myincpath."/inc/inc.Init.php");
|
||||
include($myincpath."/inc/inc.Extension.php");
|
||||
include($myincpath."/inc/inc.DBInit.php");
|
||||
|
||||
if($settings->_fullSearchEngine == 'sqlitefts') {
|
||||
$indexconf = array(
|
||||
|
@ -88,7 +86,7 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
|||
}
|
||||
$documents = $folder->getDocuments();
|
||||
foreach($documents as $document) {
|
||||
echo $indent." ".$document->getId().":".$document->getName()." ";
|
||||
echo $themes->black($indent." ".$document->getId().":".$document->getName()." ");
|
||||
$lucenesearch = new $indexconf['Search']($index);
|
||||
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
|
||||
try {
|
||||
|
@ -137,23 +135,12 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
|||
|
||||
$themes = new \AlecRabbit\ConsoleColour\Themes();
|
||||
|
||||
$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 . "\"");
|
||||
|
||||
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
|
||||
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
|
||||
echo "Database update needed.".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$dms->setRootFolderID($settings->_rootFolderID);
|
||||
|
||||
if($recreate)
|
||||
$index = $indexconf['Indexer']::create($settings->_luceneDir);
|
||||
else
|
||||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||
if(!$index) {
|
||||
echo "Could not create index.".PHP_EOL;
|
||||
echo $themes->error("Could not create index.").PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -164,4 +151,3 @@ tree($dms, $index, $indexconf, $folder);
|
|||
|
||||
$index->commit();
|
||||
$index->optimize();
|
||||
?>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${SEEDDMS_HOME}" ]; then
|
||||
echo 'Please set $SEEDDMS_HOME before running this script'
|
||||
exit 1
|
||||
parentdir=$(dirname "$0")
|
||||
export SEEDDMS_HOME=$(dirname "$parentdir")
|
||||
fi
|
||||
|
||||
exec php -f "${SEEDDMS_HOME}/utils/createfolder.php" -- "${@}"
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
<?php
|
||||
if(isset($_SERVER['SEEDDMS_HOME'])) {
|
||||
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php");
|
||||
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassAcl.php");
|
||||
ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path'));
|
||||
$myincpath = $_SERVER['SEEDDMS_HOME'];
|
||||
} else {
|
||||
require_once("../inc/inc.ClassSettings.php");
|
||||
require_once("../inc/inc.ClassAcl.php");
|
||||
ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path'));
|
||||
$myincpath = dirname($argv[0]);
|
||||
}
|
||||
|
||||
function usage() { /* {{{ */
|
||||
echo "Usage:\n";
|
||||
echo " seeddms-xmldump [-h] [-v] [--config <file>]\n";
|
||||
echo "\n";
|
||||
echo "Description:\n";
|
||||
echo " This program creates an xml dump of the whole or parts of the dms.\n";
|
||||
echo "\n";
|
||||
echo "Options:\n";
|
||||
echo " -h, --help: print usage information and exit.\n";
|
||||
echo " -v, --version: print version and exit.\n";
|
||||
echo " --config: set alternative config file.\n";
|
||||
echo " --folder: set start folder.\n";
|
||||
echo " --skip-root: do not export the root folder itself.\n";
|
||||
echo " --sections <sections>: comma seperated list of sections to export.\n";
|
||||
echo " --maxsize: maximum size of files to be included in output\n";
|
||||
echo " (defaults to 100000)\n";
|
||||
echo " --contentdir: directory where all document versions are stored\n";
|
||||
echo " which are larger than maxsize.\n";
|
||||
echo "Usage:".PHP_EOL;
|
||||
echo " seeddms-xmldump [-h] [-v] [--config <file>]".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "Description:".PHP_EOL;
|
||||
echo " This program creates an xml dump of the whole or parts of the dms.".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 " --folder: set start folder.".PHP_EOL;
|
||||
echo " --skip-root: do not export the root folder itself.".PHP_EOL;
|
||||
echo " --sections <sections>: comma seperated list of sections to export.".PHP_EOL;
|
||||
echo " --maxsize: maximum size of files to be included in output".PHP_EOL;
|
||||
echo " (defaults to 100000)".PHP_EOL;
|
||||
echo " --contentdir: directory where all document versions are stored".PHP_EOL;
|
||||
echo " which are larger than maxsize.".PHP_EOL;
|
||||
} /* }}} */
|
||||
|
||||
function wrapWithCData($text) { /* {{{ */
|
||||
|
@ -50,15 +50,15 @@ if(isset($options['h']) || isset($options['help'])) {
|
|||
|
||||
/* Print version and exit */
|
||||
if(isset($options['v']) || isset($options['verѕion'])) {
|
||||
echo $version."\n";
|
||||
echo $version.PHP_EOL;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Set alternative config file */
|
||||
if(isset($options['config'])) {
|
||||
$settings = new Settings($options['config']);
|
||||
} else {
|
||||
$settings = new Settings();
|
||||
define('SEEDDMS_CONFIG_FILE', $options['config']);
|
||||
} elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) {
|
||||
define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']);
|
||||
}
|
||||
|
||||
/* Set maximum size of files included in xml file */
|
||||
|
@ -75,7 +75,7 @@ if(isset($options['contentdir'])) {
|
|||
if(substr($contentdir, -1, 1) != DIRECTORY_SEPARATOR)
|
||||
$contentdir .= DIRECTORY_SEPARATOR;
|
||||
} else {
|
||||
echo "Directory ".$options['contentdir']." does not exists\n";
|
||||
echo "Directory ".$options['contentdir']." does not exists".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
|
@ -87,11 +87,6 @@ if(isset($options['sections'])) {
|
|||
$sections = explode(',', $options['sections']);
|
||||
}
|
||||
|
||||
if(isset($settings->_extraPath))
|
||||
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
|
||||
|
||||
require_once("SeedDMS/Core.php");
|
||||
|
||||
if(isset($options['folder'])) {
|
||||
$folderid = intval($options['folder']);
|
||||
} else {
|
||||
|
@ -475,16 +470,12 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
$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 . "\"");
|
||||
|
||||
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
|
||||
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
|
||||
echo "Database update needed.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$dms->setRootFolderID($settings->_rootFolderID);
|
||||
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.ClassSettings.php");
|
||||
include($myincpath."/inc/inc.Acl.php");
|
||||
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
||||
echo "<dms dbversion=\"".implode('.', array_slice($dms->getDBVersion(), 1, 3))."\" date=\"".date('Y-m-d H:i:s')."\">\n";
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
<?php
|
||||
if(isset($_SERVER['SEEDDMS_HOME'])) {
|
||||
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php");
|
||||
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassAcl.php");
|
||||
ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path'));
|
||||
$myincpath = $_SERVER['SEEDDMS_HOME'];
|
||||
} else {
|
||||
require_once("../inc/inc.ClassSettings.php");
|
||||
require_once("../inc/inc.ClassAcl.php");
|
||||
ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path'));
|
||||
$myincpath = dirname($argv[0]);
|
||||
}
|
||||
require("Log.php");
|
||||
|
||||
function usage() { /* {{{ */
|
||||
echo "Usage:\n";
|
||||
echo " seeddms-xmlimport [-h] [-v] [--config <file>]\n";
|
||||
echo "\n";
|
||||
echo "Description:\n";
|
||||
echo " This program imports an xml dump into the dms.\n";
|
||||
echo "\n";
|
||||
echo "Options:\n";
|
||||
echo " -h, --help: print usage information and exit.\n";
|
||||
echo " -v, --version: print version and exit.\n";
|
||||
echo " --config <config file>: set alternative config file.\n";
|
||||
echo " --folder <folder id>: set import folder.\n";
|
||||
echo " --file <file>: file containing the dump.\n";
|
||||
echo " --sections <sections>: comma seperated list of sections to read from dump.\n";
|
||||
echo " can be: users, groups, documents, folders, keywordcategories, or\n";
|
||||
echo " documentcategories, transmittals\n";
|
||||
echo " --contentdir <dir>: directory where all document versions are stored\n";
|
||||
echo " which are not included in the xml file.\n";
|
||||
echo " --default-user <user id>: use this user if user could not be found.\n";
|
||||
echo " --export-mapping <file>: write object mapping into file\n";
|
||||
echo " --debug: turn debug output on\n";
|
||||
echo "Usage:".PHP_EOL;
|
||||
echo " seeddms-xmlimport [-h] [-v] [--config <file>]".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "Description:".PHP_EOL;
|
||||
echo " This program imports an xml dump into the dms.".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 <config file>: set alternative config file.".PHP_EOL;
|
||||
echo " --folder <folder id>: set import folder.".PHP_EOL;
|
||||
echo " --file <file>: file containing the dump.".PHP_EOL;
|
||||
echo " --sections <sections>: comma seperated list of sections to read from dump.".PHP_EOL;
|
||||
echo " can be: users, groups, documents, folders, keywordcategories, or".PHP_EOL;
|
||||
echo " documentcategories, transmittals".PHP_EOL;
|
||||
echo " --contentdir <dir>: directory where all document versions are stored".PHP_EOL;
|
||||
echo " which are not included in the xml file.".PHP_EOL;
|
||||
echo " --default-user <user id>: use this user if user could not be found.".PHP_EOL;
|
||||
echo " --export-mapping <file>: write object mapping into file".PHP_EOL;
|
||||
echo " --debug: turn debug output on".PHP_EOL;
|
||||
} /* }}} */
|
||||
|
||||
function dateToTimestamp($date, $format='Y-m-d H:i:s') { /* {{{ */
|
||||
|
@ -580,7 +579,7 @@ function insert_document($document) { /* {{{ */
|
|||
copy($contentdir.$initversion['fileref'], $filename);
|
||||
} else {
|
||||
if(!isset($initversion['data']))
|
||||
echo $document['attributes']['name']."\n";
|
||||
echo $document['attributes']['name'].PHP_EOL;
|
||||
$filecontents = base64_decode($initversion['data']);
|
||||
if(strlen($filecontents) != $initversion['data_length']) {
|
||||
$logger->warning("File length (".strlen($filecontents).") doesn't match expected length (".$initversion['data_length'].").");
|
||||
|
@ -1873,16 +1872,10 @@ if(isset($options['h']) || isset($options['help'])) {
|
|||
|
||||
/* Print version and exit */
|
||||
if(isset($options['v']) || isset($options['verѕion'])) {
|
||||
echo $version."\n";
|
||||
echo $version."".PHP_EOL;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$logfile = "xmlimport.log";
|
||||
$logconf = array();
|
||||
$logconf['timeformat'] = '%Y-%m-%d %H:%M:%S';
|
||||
$logconf['lineFormat'] = '%{timestamp} %{priority} xmlimport: %{ident} %{message}';
|
||||
$logger = Log::factory('file', $logfile, '', $logconf);
|
||||
|
||||
/* Check for debug mode */
|
||||
$debug = false;
|
||||
if(isset($options['debug'])) {
|
||||
|
@ -1891,11 +1884,24 @@ if(isset($options['debug'])) {
|
|||
|
||||
/* Set alternative config file */
|
||||
if(isset($options['config'])) {
|
||||
$settings = new Settings($options['config']);
|
||||
} else {
|
||||
$settings = new Settings();
|
||||
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.Init.php");
|
||||
include($myincpath."/inc/inc.Extension.php");
|
||||
include($myincpath."/inc/inc.DBInit.php");
|
||||
include($myincpath."/inc/inc.ClassSettings.php");
|
||||
include($myincpath."/inc/inc.Acl.php");
|
||||
|
||||
$logfile = "xmlimport.log";
|
||||
$logconf = array();
|
||||
$logconf['timeformat'] = '%Y-%m-%d %H:%M:%S';
|
||||
$logconf['lineFormat'] = '%{timestamp} %{priority} xmlimport: %{ident} %{message}';
|
||||
$logger = Log::factory('file', $logfile, '', $logconf);
|
||||
|
||||
if(isset($options['folder'])) {
|
||||
$folderid = intval($options['folder']);
|
||||
} else {
|
||||
|
@ -2023,4 +2029,3 @@ if($exportmapping) {
|
|||
$logger->err("Could not open mapping file '".$exportmapping."'");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user