add option -u to set the user doing the upload (Bug #214)

This commit is contained in:
Uwe Steinmann 2015-05-15 07:16:46 +02:00
parent eb7f3613ca
commit ce572f82cb

View File

@ -20,6 +20,7 @@ function usage() { /* {{{ */
echo " -s <number>: set sequence for file (used for ordering files within a folder\n";
echo " -n <name>: set name of file\n";
echo " -V <version>: set version of file (defaults to 1).\n";
echo " -u <user>: login name of user\n";
echo " -f <filename>: upload this file\n";
echo " -s <sequence>: set sequence of file\n";
echo " -t <mimetype> set mimetype of file manually. Do not do that unless you know\n";
@ -27,7 +28,7 @@ function usage() { /* {{{ */
} /* }}} */
$version = "0.0.1";
$shortoptions = "F:c:C:k:K:s:V:f:n:t:hv";
$shortoptions = "F:c:C:k:K:s:V:u:f:n:t:hv";
$longoptions = array('help', 'version', 'config:');
if(false === ($options = getopt($shortoptions, $longoptions))) {
usage();
@ -104,6 +105,11 @@ if(isset($options['n'])) {
$name = $options['n'];
}
$username = '';
if(isset($options['u'])) {
$username = $options['u'];
}
$filename = '';
if(isset($options['f'])) {
$filename = $options['f'];
@ -141,7 +147,10 @@ $dms->setEnableConverting($settings->_enableConverting);
$dms->setViewOnlineFileTypes($settings->_viewOnlineFileTypes);
/* Create a global user object */
$user = $dms->getUser(1);
if($username)
$user = $dms->getUserByLogin();
else
$user = $dms->getUser(1);
if(is_readable($filename)) {
if(filesize($filename)) {