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

This commit is contained in:
Uwe Steinmann 2019-09-06 14:51:21 +02:00
commit 670597ea5f
45 changed files with 1321 additions and 449 deletions

View File

@ -6,6 +6,10 @@ RewriteRule ^favicon.ico$ styles/bootstrap/favicon.ico [L]
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=CWD:%2]
# Do not allow access on the other directories in www
RewriteRule "^utils/.*$" "" [F]
RewriteRule "^doc/.*$" "" [F]
# Anything below the following dirs will never be rewritten
RewriteRule "^pdfviewer/.*$" "-" [L]
RewriteRule "^views/bootstrap/images.*$" "-" [L]

View File

@ -26,6 +26,11 @@ else
*/
require_once('Core/inc.ClassDMS.php');
/**
* @uses SeedDMS_Decorator
*/
require_once('Core/inc.ClassDecorator.php');
/**
* @uses SeedDMS_Object
*/

View File

@ -87,6 +87,13 @@ class SeedDMS_Core_DMS {
*/
protected $classnames;
/**
* @var array $decorators list of decorators for objects being instanciate
* by the dms
* @access protected
*/
protected $decorators;
/**
* @var SeedDMS_Core_User $user reference to currently logged in user. This must be
* an instance of {@link SeedDMS_Core_User}. This variable is currently not
@ -456,16 +463,16 @@ class SeedDMS_Core_DMS {
} /* }}} */
/**
* Return class name of instantiated objects
* Return class name of classes instanciated by SeedDMS_Core
*
* This method returns the class name of those objects being instantiated
* by the dms. Each class has an internal place holder, which must be
* passed to function.
*
* @param string $objectname placeholder (can be one of 'folder', 'document',
* 'documentcontent', 'user', 'group'
* 'documentcontent', 'user', 'group')
*
* @return string/boolean name of class or false if placeholder is invalid
* @return string/boolean name of class or false if object name is invalid
*/
function getClassname($objectname) { /* {{{ */
if(isset($this->classnames[$objectname]))
@ -497,6 +504,44 @@ class SeedDMS_Core_DMS {
return $oldclass;
} /* }}} */
/**
* Return list of decorators
*
* This method returns the list of decorator class names of those objects
* being instantiated
* by the dms. Each class has an internal place holder, which must be
* passed to function.
*
* @param string $objectname placeholder (can be one of 'folder', 'document',
* 'documentcontent', 'user', 'group')
*
* @return array/boolean list of class names or false if object name is invalid
*/
function getDecorators($objectname) { /* {{{ */
if(isset($this->decorators[$objectname]))
return $this->decorators[$objectname];
else
return false;
} /* }}} */
/**
* Add a decorator
*
* This method adds a single decorator class name to the list of decorators
* of those objects being instantiated
* by the dms. Each class has an internal place holder, which must be
* passed to function.
*
* @param string $objectname placeholder (can be one of 'folder', 'document',
* 'documentcontent', 'user', 'group')
*
* @return boolean true if decorator could be added, otherwise false
*/
function addDecorator($objectname, $decorator) { /* {{{ */
$this->decorators[$objectname][] = $decorator;
return true;
} /* }}} */
/**
* Return database where meta data is stored
*

View File

@ -0,0 +1,42 @@
<?php
/**
* Implementation of the decorator pattern
*
* @category DMS
* @package SeedDMS_Core
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Class which implements a simple decorator pattern
*
* @category DMS
* @package SeedDMS_Core
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_Core_Decorator {
protected $o;
public function __construct($object) {
$this->o = $object;
}
public function __call($method, $args)
{
if (!method_exists($this->o, $method)) {
throw new Exception("Undefined method $method attempt.");
}
/* In case the called method returns the object itself, then return this object */
$result = call_user_func_array(array($this->o, $method), $args);
return $result === $this->o ? $this : $result;
}
}

View File

@ -249,6 +249,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_content = null;
} /* }}} */
/**
* Check if this object is of type 'document'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'document';
} /* }}} */
/**
* Return an array of database fields which used for searching
* a term entered in the database search form
@ -318,9 +327,27 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/** @var SeedDMS_Core_Document $document */
$document = new $classname($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $lock, $resArr["keywords"], $resArr["sequence"]);
$document->setDMS($dms);
$document = $document->applyDecorators();
return $document;
} /* }}} */
/**
* Apply decorators
*
* @return object final object after all decorators has been applied
*/
function applyDecorators() { /* {{{ */
if($decorators = $this->_dms->getDecorators('document')) {
$s = $this;
foreach($decorators as $decorator) {
$s = new $decorator($s);
}
return $s;
} else {
return $this;
}
} /* }}} */
/**
* Return the directory of the document in the file system relativ
* to the contentDir
@ -468,7 +495,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db = $this->_dms->getDB();
if(!$this->_categories)
self::getCategories();
$this->getCategories();
$catids = array();
foreach($this->_categories as $cat)
@ -570,7 +597,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* @return SeedDMS_Core_Folder parent folder
*/
function getParent() { /* {{{ */
return self::getFolder();
return $this->getFolder();
} /* }}} */
function getFolder() { /* {{{ */
@ -699,7 +726,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_defaultAccess = $mode;
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -733,7 +760,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_inheritAccess = ($inheritAccess ? "1" : "0");
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -1182,7 +1209,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
unset($this->_accessList);
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -3229,7 +3256,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$this->_orgFileName = $orgFileName;
$this->_fileType = $fileType;
$this->_mimeType = $mimeType;
$this->_dms = $document->_dms;
$this->_dms = $document->getDMS();
if(!$fileSize) {
$this->_fileSize = SeedDMS_Core_File::fileSize($this->_dms->contentDir . $this->getPath());
} else {
@ -3275,6 +3302,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return null;
} /* }}} */
/**
* Check if this object is of type 'documentcontent'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'documentcontent';
} /* }}} */
function getVersion() { return $this->_version; }
function getComment() { return $this->_comment; }
function getDate() { return $this->_date; }
@ -6343,11 +6379,11 @@ class SeedDMS_Core_DocumentLink { /* {{{ */
* @return int either M_NONE or M_READ
*/
function getAccessMode($u, $source, $target) { /* {{{ */
$dms = $this->_document->_dms;
$dms = $this->_document->getDMS();
/* Check if 'onCheckAccessDocumentLink' callback is set */
if(isset($this->_dms->callbacks['onCheckAccessDocumentLink'])) {
foreach($this->_dms->callbacks['onCheckAccessDocumentLink'] as $callback) {
if(isset($dms->callbacks['onCheckAccessDocumentLink'])) {
foreach($dms->callbacks['onCheckAccessDocumentLink'] as $callback) {
if(($ret = call_user_func($callback[0], $callback[1], $this, $u, $source, $target)) > 0) {
return $ret;
}

View File

@ -129,6 +129,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$this->_notifyList = array();
} /* }}} */
/**
* Check if this object is of type 'folder'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'folder';
} /* }}} */
/**
* Return an array of database fields which used for searching
* a term entered in the database search form
@ -191,9 +200,27 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
/** @var SeedDMS_Core_Folder $folder */
$folder = new $classname($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["date"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]);
$folder->setDMS($dms);
$folder = $folder->applyDecorators();
return $folder;
} /* }}} */
/**
* Apply decorators
*
* @return object final object after all decorators has been applied
*/
function applyDecorators() { /* {{{ */
if($decorators = $this->_dms->getDecorators('folder')) {
$s = $this;
foreach($decorators as $decorator) {
$s = new $decorator($s);
}
return $s;
} else {
return $this;
}
} /* }}} */
/**
* Get the name of the folder.
*
@ -448,7 +475,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$this->_defaultAccess = $mode;
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -481,7 +508,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$this->_inheritAccess = $inheritAccess;
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -1229,7 +1256,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
unset($this->_accessList);
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */

View File

@ -47,6 +47,15 @@ class SeedDMS_Core_Object { /* {{{ */
$this->_dms = null;
} /* }}} */
/**
* Check if this object is of a given type.
*
* This method must be implemened in the child class
*
* @param string $type type of object
*/
public function isType($type) {return false;}
/**
* Set dms this object belongs to.
*
@ -57,23 +66,27 @@ class SeedDMS_Core_Object { /* {{{ */
*
* @param SeedDMS_Core_DMS $dms reference to dms
*/
function setDMS($dms) { /* {{{ */
public function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
public function getDMS() { /* {{{ */
return $this->_dms;
} /* }}} */
/**
* Return the internal id of the document
*
* @return integer id of document
*/
function getID() { return $this->_id; }
public function getID() { return $this->_id; }
/**
* Returns all attributes set for the object
*
* @return array|bool
*/
function getAttributes() { /* {{{ */
public function getAttributes() { /* {{{ */
if (!$this->_attributes) {
$db = $this->_dms->getDB();
@ -113,7 +126,7 @@ class SeedDMS_Core_Object { /* {{{ */
* @return array|string value of attritbute or false. The value is an array
* if the attribute is defined as multi value
*/
function getAttribute($attrdef) { /* {{{ */
public function getAttribute($attrdef) { /* {{{ */
if (!$this->_attributes) {
$this->getAttributes();
}
@ -133,7 +146,7 @@ class SeedDMS_Core_Object { /* {{{ */
* @return array|string value of attritbute or false. The value is an array
* if the attribute is defined as multi value
*/
function getAttributeValue($attrdef) { /* {{{ */
public function getAttributeValue($attrdef) { /* {{{ */
if (!$this->_attributes) {
$this->getAttributes();
}
@ -171,7 +184,7 @@ class SeedDMS_Core_Object { /* {{{ */
* @return array|bool
* even if the attribute is not defined as multi value
*/
function getAttributeValueAsArray($attrdef) { /* {{{ */
public function getAttributeValueAsArray($attrdef) { /* {{{ */
if (!$this->_attributes) {
$this->getAttributes();
}
@ -194,7 +207,7 @@ class SeedDMS_Core_Object { /* {{{ */
* @return string value of attritbute or false. The value is always a string
* even if the attribute is defined as multi value
*/
function getAttributeValueAsString($attrdef) { /* {{{ */
public function getAttributeValueAsString($attrdef) { /* {{{ */
if (!$this->_attributes) {
$this->getAttributes();
}
@ -214,7 +227,7 @@ class SeedDMS_Core_Object { /* {{{ */
* must be an array
* @return boolean true if operation was successful, otherwise false
*/
function setAttributeValue($attrdef, $value) { /* {{{ */
public function setAttributeValue($attrdef, $value) { /* {{{ */
$db = $this->_dms->getDB();
if (!$this->_attributes) {
$this->getAttributes();
@ -265,7 +278,7 @@ class SeedDMS_Core_Object { /* {{{ */
* @param SeedDMS_Core_AttributeDefinition $attrdef
* @return boolean true if operation was successful, otherwise false
*/
function removeAttribute($attrdef) { /* {{{ */
public function removeAttribute($attrdef) { /* {{{ */
$db = $this->_dms->getDB();
if (!$this->_attributes) {
$this->getAttributes();

View File

@ -25,50 +25,50 @@
* @version Release: @package_version@
*/
class SeedDMS_Core_File {
/**
* @param $old
* @param $new
* @return bool
*/
static function renameFile($old, $new) { /* {{{ */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameFile($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
/**
* @param $file
* @return bool
*/
static function removeFile($file) { /* {{{ */
/**
* @param $file
* @return bool
*/
static function removeFile($file) { /* {{{ */
return @unlink($file);
} /* }}} */
/**
* @param $source
* @param $target
* @return bool
*/
static function copyFile($source, $target) { /* {{{ */
/**
* @param $source
* @param $target
* @return bool
*/
static function copyFile($source, $target) { /* {{{ */
return @copy($source, $target);
} /* }}} */
/**
* @param $source
* @param $target
* @return bool
*/
static function moveFile($source, $target) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!@copyFile($source, $target))
/**
* @param $source
* @param $target
* @return bool
*/
static function moveFile($source, $target) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!@copyFile($source, $target))
return false;
/** @noinspection PhpUndefinedFunctionInspection */
return @removeFile($source);
/** @noinspection PhpUndefinedFunctionInspection */
return @removeFile($source);
} /* }}} */
/**
* @param $file
* @return bool|int
*/
static function fileSize($file) { /* {{{ */
/**
* @param $file
* @return bool|int
*/
static function fileSize($file) { /* {{{ */
if(!$a = fopen($file, 'r'))
return false;
fseek($a, 0, SEEK_END);
@ -77,22 +77,22 @@ class SeedDMS_Core_File {
return $filesize;
} /* }}} */
/**
* @param $size
* @param array $sizes
* @return string
*/
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
/**
* @param $size
* @param array $sizes
* @return string
*/
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
if ($size == 0) return('0 Bytes');
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
} /* }}} */
/**
* @param $str
* @return bool|int
*/
static function parse_filesize($str) { /* {{{ */
/**
* @param $str
* @return bool|int
*/
static function parse_filesize($str) { /* {{{ */
preg_replace('/\s\s+/', ' ', $str);
if(strtoupper(substr($str, -1)) == 'B') {
$value = (int) substr($str, 0, -2);
@ -115,32 +115,32 @@ class SeedDMS_Core_File {
return $value;
break;
}
/** @noinspection PhpUnreachableStatementInspection */
return false;
/** @noinspection PhpUnreachableStatementInspection */
return false;
} /* }}} */
/**
* @param $file
* @return string
*/
static function checksum($file) { /* {{{ */
/**
* @param $file
* @return string
*/
static function checksum($file) { /* {{{ */
return md5_file($file);
} /* }}} */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameDir($old, $new) { /* {{{ */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameDir($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
/**
* @param $path
* @return bool
*/
static function makeDir($path) { /* {{{ */
/**
* @param $path
* @return bool
*/
static function makeDir($path) { /* {{{ */
if( !is_dir( $path ) ){
$res=@mkdir( $path , 0777, true);
@ -195,11 +195,11 @@ class SeedDMS_Core_File {
*/
} /* }}} */
/**
* @param $path
* @return bool
*/
static function removeDir($path) { /* {{{ */
/**
* @param $path
* @return bool
*/
static function removeDir($path) { /* {{{ */
$handle = @opendir($path);
while ($entry = @readdir($handle) )
{
@ -220,12 +220,12 @@ class SeedDMS_Core_File {
return @rmdir($path);
} /* }}} */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function copyDir($sourcePath, $targetPath) { /* {{{ */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function copyDir($sourcePath, $targetPath) { /* {{{ */
if (mkdir($targetPath, 0777)) {
$handle = @opendir($sourcePath);
while ($entry = @readdir($handle) ) {
@ -247,26 +247,26 @@ class SeedDMS_Core_File {
return true;
} /* }}} */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function moveDir($sourcePath, $targetPath) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!copyDir($sourcePath, $targetPath))
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function moveDir($sourcePath, $targetPath) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!copyDir($sourcePath, $targetPath))
return false;
/** @noinspection PhpUndefinedFunctionInspection */
return removeDir($sourcePath);
/** @noinspection PhpUndefinedFunctionInspection */
return removeDir($sourcePath);
} /* }}} */
// code by Kioob (php.net manual)
/**
* @param $source
* @param bool $level
* @return bool|string
*/
static function gzcompressfile($source, $level=false) { /* {{{ */
/**
* @param $source
* @param bool $level
* @return bool|string
*/
static function gzcompressfile($source, $level=false) { /* {{{ */
$dest=$source.'.gz';
$mode='wb'.$level;
$error=false;

View File

@ -80,7 +80,11 @@ a revision can also be started if some revisors have already reviewed the docume
<file name="inc.ClassWorkflow.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
<<<<<<< HEAD
<file name="inc.ClassTransmittal.php" role="php">
=======
<file name="inc.ClassDecorator.php" role="php">
>>>>>>> seeddms-5.1.x
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
</dir> <!-- /DTD -->
@ -1695,6 +1699,23 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp()
- add new method SeedDMS_Core_Folder::empty()
</notes>
</release>
<release>
<date>2019-09-06</date>
<time>07:31:17</time>
<version>
<release>5.1.13</release>
<api>5.1.13</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- add decorators
- add new methods SeedDMS_Core_Document::isType(), SeedDMS_Core_Folder::isType(), SeedDMS_Core_DocumentContent::isType(). Use them instead of checking the class name.
</notes>
</release>
<release>
<date>2017-02-28</date>
<time>06:34:50</time>

View File

@ -23,6 +23,7 @@
class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
public function run() {
global $theme;
$dms = $this->params['dms'];
$type = $this->params['type'];
$settings = $this->params['settings'];
@ -57,7 +58,9 @@ class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
$previewer->setConverters($settings->_converters['preview']);
$previewer->setXsendfile($settings->_enableXsendfile);
if(!$previewer->hasPreview($content)) {
add_log_line("");
if(!$previewer->createPreview($content)) {
add_log_line("", PEAR_LOG_ERR);
}
}
if(!$previewer->hasPreview($content)) {

View File

@ -1,5 +1,33 @@
Conversion to pdf
=================
Conversion to text for fulltext search
=======================================
text/plain
text/csv
cat '%s'
application/pdf
pdftotext -nopgbrk %s - | sed -e 's/ [a-zA-Z0-9.]\{1\} / /g' -e 's/[0-9.]//g'
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx2txt '%s' -
application/msword
catdoc %s
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsx2csv %s
application/vnd.ms-excel
xls2csv %s
text/html
html2text %s
Many office formats
unoconv -d document -f txt --stdout '%s'
Conversion to pdf for pdf preview
==================================
text/plain
text/csv
@ -22,8 +50,16 @@ application/vnd.ms-excel
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
unoconv -d spreadsheet -f pdf --stdout -v '%f' > '%o'
Preview
========
Conversion to png for preview images
=====================================
If you have problems running convert on PDF documents then read this page
https://askubuntu.com/questions/1081895/trouble-with-batch-conversion-of-png-to-pdf-using-convert
It basically instructs you to comment out the line
<policy domain="coder" rights="none" pattern="PDF" />
in /etc/ImageMagick-6/policy.xml
image/jpg
image/jpeg
@ -46,5 +82,5 @@ application/rtf
application/vnd.ms-powerpoint
text/csv
application/vnd.wordperfect
/usr/bin/unoconv -d document -e PageRange=1 -f pdf --stdout -v '%f' | gs -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dPDFFitPage -r72x72 -sOutputFile=- -dFirstPage=1 -dLastPage=1 -q - | convert -resize %wx png:- '%o'
unoconv -d document -e PageRange=1 -f pdf --stdout -v '%f' | gs -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dPDFFitPage -r72x72 -sOutputFile=- -dFirstPage=1 -dLastPage=1 -q - | convert -resize %wx png:- '%o'

View File

@ -105,6 +105,17 @@ IndexIgnore *
</ifModule>
```
Securing the configuration file
---------------------------------
The configuration can be fully controlled by any administrator of SeedDMS. This
can be crucial for those configuration options where external commands are
being configured, e.g. for the full text engine or creating preview images.
As a hoster you may not want this configuration options being set by a SeedDMS
administrator. For now you need to make the configuration file `settings.xml`
unwritable for the web server.
UPDATING FROM A PREVIOUS VERSION OR SEEDDMS
=============================================

View File

@ -63,7 +63,7 @@ class SeedDMS_AccessOperation {
* even if is disallowed in the settings.
*/
function mayEditVersion($document, $vno=0) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($vno)
$version = $document->getContentByVersion($vno);
else
@ -87,7 +87,7 @@ class SeedDMS_AccessOperation {
* even if is disallowed in the settings.
*/
function mayRemoveVersion($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
$versions = $document->getContent();
if ((($this->settings->_enableVersionDeletion && ($document->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin() ) && (count($versions) > 1)) {
return true;
@ -107,7 +107,7 @@ class SeedDMS_AccessOperation {
* even if is disallowed in the settings.
*/
function mayOverrideStatus($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ((($this->settings->_enableVersionModification && ($document->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && ($status["status"]==S_DRAFT || $status["status"]==S_RELEASED || $status["status"]==S_REJECTED || $status["status"]==S_OBSOLETE || $status["status"]==S_NEEDS_CORRECTION)) {
@ -130,7 +130,7 @@ class SeedDMS_AccessOperation {
* explicitly allows it.
*/
function maySetReviewersApprovers($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
$reviewstatus = $latestContent->getReviewStatus();
@ -163,7 +163,7 @@ class SeedDMS_AccessOperation {
* settings.
*/
function maySetRecipients($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if (($this->settings->_enableVersionModification && ($document->getAccessMode($this->user) >= M_READWRITE)) || $this->user->isAdmin()) {
@ -184,7 +184,7 @@ class SeedDMS_AccessOperation {
* settings.
*/
function maySetRevisors($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ((($this->settings->_enableVersionModification && ($document->getAccessMode($this->user) >= M_READWRITE)) || $this->user->isAdmin()) && ($status["status"]==S_RELEASED || $status["status"]==S_IN_REVISION)) {
@ -205,7 +205,7 @@ class SeedDMS_AccessOperation {
* settings.
*/
function maySetWorkflow($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$workflow = $latestContent->getWorkflow();
if ((($this->settings->_enableVersionModification && ($document->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && (!$workflow || ($workflow->getInitState()->getID() == $latestContent->getWorkflowState()->getID()))) {
@ -223,7 +223,7 @@ class SeedDMS_AccessOperation {
* expiration date is only allowed if the document has not been obsoleted.
*/
function maySetExpires($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ((($document->getAccessMode($this->user) >= M_READWRITE) || $this->user->isAdmin()) && ($status["status"]!=S_OBSOLETE)) {
@ -244,7 +244,7 @@ class SeedDMS_AccessOperation {
* disallowed in the settings.
*/
function mayEditComment($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($document->isLocked()) {
$lockingUser = $document->getLockingUser();
if (($lockingUser->getID() != $this->user->getID()) && ($document->getAccessMode($this->user) != M_ALL)) {
@ -271,7 +271,7 @@ class SeedDMS_AccessOperation {
* disallowed in the settings.
*/
function mayEditAttributes($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
$workflow = $latestContent->getWorkflow();
@ -291,7 +291,7 @@ class SeedDMS_AccessOperation {
* account here.
*/
function mayReview($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ($document->getAccessMode($this->user) >= M_READ && $status["status"]==S_DRAFT_REV) {
@ -309,7 +309,7 @@ class SeedDMS_AccessOperation {
* review and if it is allowed in the settings
*/
function mayUpdateReview($document, $updateUser) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($this->settings->_enableUpdateRevApp && ($updateUser == $this->user) && $document->getAccessMode($this->user) >= M_READ && !$document->hasExpired()) {
return true;
}
@ -324,7 +324,7 @@ class SeedDMS_AccessOperation {
* approval and if it is allowed in the settings
*/
function mayUpdateApproval($document, $updateUser) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($this->settings->_enableUpdateRevApp && ($updateUser == $this->user) && $document->getAccessMode($this->user) >= M_READ && !$document->hasExpired()) {
return true;
}
@ -342,7 +342,7 @@ class SeedDMS_AccessOperation {
* account here.
*/
function mayApprove($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ($document->getAccessMode($this->user) >= M_READ && $status["status"]==S_DRAFT_APP) {
@ -361,7 +361,7 @@ class SeedDMS_AccessOperation {
* account here.
*/
function mayReceipt($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ($document->getAccessMode($this->user) >= M_READ && $status["status"]==S_RELEASED) {
@ -379,7 +379,7 @@ class SeedDMS_AccessOperation {
* review and if it is allowed in the settings
*/
function mayUpdateReceipt($document, $updateUser) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($this->settings->_enableUpdateReceipt && ($updateUser == $this->user) && $document->getAccessMode($this->user) >= M_READ && !$document->hasExpired()) {
return true;
}
@ -395,7 +395,7 @@ class SeedDMS_AccessOperation {
* account here.
*/
function mayRevise($document) { /* {{{ */
if($this->obj->isType('document')) {
if($document->isType('document')) {
if($latestContent = $document->getLatestContent()) {
$status = $latestContent->getStatus();
if ($document->getAccessMode($this->user) >= M_READ && $status["status"]!=S_OBSOLETE) {

View File

@ -54,6 +54,7 @@ class SeedDMS_Controller_Common {
* @return mixed return value of called method
*/
function __invoke($get=array()) {
$this->callHook('preRun', isset($get['action']) ? $get['action'] : 'run');
if(isset($get['action']) && $get['action']) {
if(method_exists($this, $get['action'])) {
return $this->{$get['action']}();
@ -63,6 +64,7 @@ class SeedDMS_Controller_Common {
}
} else
return $this->run();
$this->callHook('postRun', isset($get['action']) ? $get['action'] : 'run');
}
function setParams($params) {
@ -188,10 +190,17 @@ class SeedDMS_Controller_Common {
* null if no hook was called
*/
function callHook($hook) { /* {{{ */
$tmps = array();
$tmp = explode('_', get_class($this));
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])])) {
$tmps[] = $tmp[2];
$tmp = explode('_', get_parent_class($this));
$tmps[] = $tmp[2];
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
foreach($tmps as $tmp)
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) {
$this->lasthookresult = null;
foreach($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])] as $hookObj) {
foreach($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)] as $hookObj) {
if (method_exists($hookObj, $hook)) {
switch(func_num_args()) {
case 3:

View File

@ -295,10 +295,10 @@ class SeedDMS_Session {
/* id is only set if load() was called before */
if($this->id) {
$dms = $object->_dms;
if(get_class($object) == $dms->getClassname('document')) {
if($object->isType('document')) {
if(!in_array($object->getID(), $this->data['clipboard']['docs']))
array_push($this->data['clipboard']['docs'], $object->getID());
} elseif(get_class($object) == $dms->getClassname('folder')) {
} elseif($object->isType('folder')) {
if(!in_array($object->getID(), $this->data['clipboard']['folders']))
array_push($this->data['clipboard']['folders'], $object->getID());
}
@ -318,11 +318,11 @@ class SeedDMS_Session {
/* id is only set if load() was called before */
if($this->id) {
$dms = $object->_dms;
if(get_class($object) == $dms->getClassname('document')) {
if($object->isType('document')) {
$key = array_search($object->getID(), $this->data['clipboard']['docs']);
if($key !== false)
unset($this->data['clipboard']['docs'][$key]);
} elseif(get_class($object) == $dms->getClassname('folder')) {
} elseif($object->isType('folder')) {
$key = array_search($object->getID(), $this->data['clipboard']['folders']);
if($key !== false)
unset($this->data['clipboard']['folders'][$key]);

View File

@ -52,27 +52,49 @@ class UI extends UI_Default {
} else {
$classname = "SeedDMS_View_".$class;
}
/* Collect all decorators */
$decorators = array();
foreach($EXT_CONF as $extname=>$extconf) {
if(!isset($extconf['disable']) || $extconf['disable'] == false) {
if(isset($extconf['decorators'][$class])) {
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
if(file_exists($filename)) {
$classname = $extconf['decorators'][$class]['name'];
$decorators[$extname] = $extconf['decorators'][$class];
}
}
}
}
/* Do not check for class file anymore but include it relative
* to rootDir or an extension dir if it has set the include path
* to rootDir or an extension dir if it has been set the include path
*/
$filename = '';
$httpbasedir = '';
foreach($EXT_CONF as $extname=>$extconf) {
if(!isset($extconf['disable']) || $extconf['disable'] == false) {
/* 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
* will not be set because out/out.xxx.php is still used.
*/
if(isset($extconf['views'][$class])) {
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/".$extconf['views'][$class]['file'];
if(file_exists($filename)) {
// $httpbasedir = 'ext/'.$extname.'/';
$classname = $extconf['views'][$class]['name'];
break;
}
}
/* New views are added by creating a file out/out.xx.php and
* views/bootstrap/class.xx.php, without setting the 'views' element
* in the configuration
*/
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/class.".$class.".php";
if(file_exists($filename)) {
$httpbasedir = 'ext/'.$extname.'/';
break;
}
$filename = '';
if(isset($extconf['views'][$class])) {
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/".$extconf['views'][$class]['file'];
if(file_exists($filename)) {
$httpbasedir = 'ext/'.$extname.'/';
$classname = $extconf['views'][$class]['name'];
break;
}
}
}
}
if(!$filename)
@ -116,6 +138,11 @@ class UI extends UI_Default {
$view->setParam('showmissingtranslations', $settings->_showMissingTranslations);
$view->setParam('defaultsearchmethod', $settings->_defaultSearchMethod);
$view->setParam('cachedir', $settings->_cacheDir);
foreach($decorators as $extname=>$decorator) {
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$decorator['file'];
require($filename);
$view = new $decorator['name']($view);
}
return $view;
}
return null;

View File

@ -157,6 +157,7 @@ switch($command) {
}
break; /* }}} */
/* The subtree command is deprecated. It has been moved into view */
case 'subtree': /* {{{ */
if($user) {
if(empty($_GET['node']))

View File

@ -48,6 +48,43 @@ if(strpos($dirname, realpath($settings->_dropFolderDir.'/'.$user->getLogin().'/'
UI::exitError(getMLText("admin_tools"),getMLText("invalid_dropfolder_folder"));
}
$metadata = array();
if(!empty($_GET["dropfolderfileform2"])) {
$metadatafile = realpath($settings->_dropFolderDir.'/'.$user->getLogin()."/".$_GET["dropfolderfileform2"]);
$csvdelim = ';';
$csvencl = '"';
if($fp = fopen($metadatafile, 'r')) {
$colmap = array();
if($header = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
print_r($header);
foreach($header as $i=>$colname) {
if(in_array($colname, array('filename', 'category'))) {
$colmap[$colname] = $i;
}
}
}
if(count($colmap) > 1) {
$nameprefix = dirname($dirname).'/';
$allcats = $dms->getDocumentCategories();
$catids = array();
foreach($allcats as $cat)
$catids[$cat->getName()] = $cat;
while(!feof($fp)) {
if($data = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
$metadata[$nameprefix.$data[$colmap['filename']]] = array('category'=>array());
if($data[$colmap['category']]) {
$kk = explode(',', $data[$colmap['category']]);
foreach($kk as $k) {
if(isset($catids[$k]))
$metadata[$nameprefix.$data[$colmap['filename']]]['category'][] = $catids[$k];
}
}
}
}
}
}
}
$setfiledate = false;
if(isset($_GET['setfiledate']) && $_GET["setfiledate"]) {
$setfiledate = true;
@ -58,7 +95,7 @@ if(isset($_GET['setfolderdate']) && $_GET["setfolderdate"]) {
$setfolderdate = true;
}
function import_folder($dirname, $folder, $setfiledate, $setfolderdate) { /* {{{ */
function import_folder($dirname, $folder, $setfiledate, $setfolderdate, $metadata) { /* {{{ */
global $user, $doccount, $foldercount;
$d = dir($dirname);
@ -81,13 +118,13 @@ function import_folder($dirname, $folder, $setfiledate, $setfolderdate) { /* {{{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $path);
$lastDotIndex = strrpos($path, ".");
$lastDotIndex = strrpos($name, ".");
if (is_bool($lastDotIndex) && !$lastDotIndex) $filetype = ".";
else $filetype = substr($path, $lastDotIndex);
else $filetype = substr($name, $lastDotIndex);
// echo $mimetype." - ".$filetype." - ".$path."\n";
if($res = $folder->addDocument($name, $comment, $expires, $user, $keywords,
$categories, $filetmp, $name,
$metadata[$path]['category'], $filetmp, $name,
$filetype, $mimetype, $sequence, $reviewers,
$approvers, $reqversion, $version_comment)) {
$doccount++;
@ -108,7 +145,7 @@ function import_folder($dirname, $folder, $setfiledate, $setfolderdate) { /* {{{
if($setfolderdate) {
$newfolder->setDate(filemtime($path));
}
if(!import_folder($path, $newfolder, $setfiledate, $setfolderdate))
if(!import_folder($path, $newfolder, $setfiledate, $setfolderdate, $metadata))
return false;
} else {
return false;
@ -125,7 +162,7 @@ if($newfolder = $folder->addSubFolder($_GET["dropfolderfileform1"], '', $user, 1
if($setfolderdate) {
$newfolder->setDate(filemtime($dirname));
}
if(!import_folder($dirname, $newfolder, $setfiledate, $setfolderdate))
if(!import_folder($dirname, $newfolder, $setfiledate, $setfolderdate, $metadata))
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_importfs')));
else {
if(isset($_GET['remove']) && $_GET["remove"]) {

View File

@ -93,8 +93,8 @@ if ($folder->setParent($targetFolder)) {
$notifier->toGroup($user, $grp, $subject, $message, $params);
}
// if user is not owner send notification to owner
if ($user->getID() != $folder->getOwner()->getID())
$notifier->toIndividual($user, $folder->getOwner(), $subject, $message, $params);
//if ($user->getID() != $folder->getOwner()->getID())
// $notifier->toIndividual($user, $folder->getOwner(), $subject, $message, $params);
}
} else {

View File

@ -65,7 +65,8 @@ if (!isset($_POST["overrideStatus"]) || !is_numeric($_POST["overrideStatus"]) ||
$overallStatus = $content->getStatus();
// status change control
// status change control, setting a status to obsolete is alwasy allowed
if(intval($_POST["overrideStatus"]) != S_OBSOLETE)
if ($overallStatus["status"] == S_REJECTED || $overallStatus["status"] == S_EXPIRED || $overallStatus["status"] == S_DRAFT_REV || $overallStatus["status"] == S_DRAFT_APP || $overallStatus["status"] == S_IN_WORKFLOW) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("cannot_change_final_states"));
}

View File

@ -85,6 +85,7 @@ else
$previewer->setConverters($settings->_converters['preview']);
$previewer->setXsendfile($settings->_enableXsendfile);
if(!$previewer->hasPreview($object)) {
add_log_line("");
if(!$previewer->createPreview($object)) {
}
}

View File

@ -35,11 +35,11 @@ if(!checkFormKey('removearchive')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["arkname"]) || !file_exists($settings->_contentDir.$_POST["arkname"]) ) {
if (!isset($_POST["arkname"]) || !file_exists(addDirSep($settings->_backupDir).$_POST["arkname"]) ) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
}
if (!SeedDMS_Core_File::removeFile($settings->_contentDir.$_POST["arkname"])) {
if (!SeedDMS_Core_File::removeFile(addDirSep($settings->_backupDir).$_POST["arkname"])) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}

View File

@ -106,6 +106,7 @@ if ($notifier){
$params['username'] = $user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$notifier->toList($user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message, $params);

View File

@ -35,11 +35,11 @@ if(!checkFormKey('removedump')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["dumpname"]) || !file_exists($settings->_contentDir.$_POST["dumpname"]) ) {
if (!isset($_POST["dumpname"]) || !file_exists(addDirSep($settings->_backupDir).$_POST["dumpname"]) ) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
}
if (!SeedDMS_Core_File::removeFile($settings->_contentDir.$_POST["dumpname"])) {
if (!SeedDMS_Core_File::removeFile($settings->_backupDir.$_POST["dumpname"])) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}

View File

@ -104,7 +104,7 @@ else {
* be informed about the removal.
*/
$emailUserList = array();
$emailUserList[] = $version->_userID;
$emailUserList[] = $version->getUser()->getID();
$emailGroupList = array();
$status = $version->getReviewStatus();
foreach ($status as $st) {
@ -150,12 +150,12 @@ else {
$nl=$document->getNotifyList();
$userrecipients = array();
foreach ($emailUserList as $eID) {
$eU = $version->_document->_dms->getUser($eID);
$eU = $version->getDMS()->getUser($eID);
$userrecipients[] = $eU;
}
$grouprecipients = array();
foreach ($emailGroupList as $eID) {
$eU = $version->_document->_dms->getGroup($eID);
$eU = $version->getDMS()->getGroup($eID);
$grouprecipients[] = $eU;
}

View File

@ -30,5 +30,5 @@ include("../inc/inc.Authentication.php");
$session->setLanguage($_GET['lang']);
header("Location: ".$_GET['referer']);
header("Location: http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$_GET['referer']);
?>

View File

@ -28,13 +28,34 @@ require_once("inc/inc.DBInit.php");
require_once("inc/inc.ClassUI.php");
require_once("inc/inc.Authentication.php");
$form = preg_replace('/[^A-Za-z0-9_]+/', '', $_GET["form"]);
$mode = intval($_GET["mode"]);
$exclude = intval($_GET["exclude"]);
if(isset($_GET['action']) && $_GET['action'] == 'subtree') {
if (isset($_GET["node"]) || !is_numeric($_GET["node"]) || intval($_GET["node"])<1) {
$nodeid = $settings->_rootFolderID;
} else {
$nodeid = intval($_GET["node"]);
}
$node = $dms->getFolder($nodeid);
if (!is_object($node)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))), getMLText("invalid_folder_id"));
}
} else {
$form = preg_replace('/[^A-Za-z0-9_]+/', '', $_GET["form"]);
$mode = intval($_GET["mode"]);
$exclude = intval($_GET["exclude"]);
}
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'rootfolderid'=>$settings->_rootFolderID, 'form'=>$form, 'mode'=>$mode, 'exclude'=>$exclude));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'rootfolderid'=>$settings->_rootFolderID));
if($view) {
if(isset($_GET['action']) && $_GET['action'] == 'subtree') {
$view->setParam('node', $node);
$view->setParam('orderby', $settings->_sortFoldersDefault);
} else {
$view->setParam('form', $form);
$view->setParam('mode', $mode);
$view->setParam('exclude', $exclude);
}
$view($_GET);
exit;
}

View File

@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
/
if(!isset($settings))
require_once("../inc/inc.Settings.php");
require_once("inc/inc.LogInit.php");
@ -34,7 +34,7 @@ if (!$accessop->check_view_access($view, $_GET)) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (!isset($_GET["arkname"]) || !file_exists($settings->_contentDir.$_GET["arkname"]) ) {
if (!isset($_GET["arkname"]) || !file_exists(addDirSep($settings->_backupDir).$_GET["arkname"]) ) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
}

View File

@ -34,7 +34,7 @@ if (!$accessop->check_view_access($view, $_GET)) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (!isset($_GET["dumpname"]) || !file_exists($settings->_contentDir.$_GET["dumpname"]) ) {
if (!isset($_GET["dumpname"]) || !file_exists(addDirSep($settings->_backupDir).$_GET["dumpname"]) ) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
}

View File

@ -444,53 +444,64 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// -------------- Output results --------------------------------------------
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if($view) {
$view->setParam('accessobject', $accessop);
$view->setParam('query', $query);
$view->setParam('searchhits', $entries);
$view->setParam('totalpages', $totalPages);
$view->setParam('pagenumber', $pageNumber);
$view->setParam('limit', $limit);
$view->setParam('searchtime', $searchTime);
$view->setParam('urlparams', $_GET);
$view->setParam('cachedir', $settings->_cacheDir);
$view->setParam('totaldocs', $dcount /*resArr['totalDocs']*/);
$view->setParam('totalfolders', $fcount /*resArr['totalFolders']*/);
$view->setParam('fullsearch', (isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSearch) ? true : false);
$view->setParam('mode', isset($mode) ? $mode : '');
$view->setParam('orderby', isset($orderby) ? $orderby : '');
$view->setParam('defaultsearchmethod', $settings->_defaultSearchMethod);
$view->setParam('resultmode', isset($resultmode) ? $resultmode : '');
$view->setParam('searchin', isset($searchin) ? $searchin : array());
$view->setParam('startfolder', isset($startFolder) ? $startFolder : null);
$view->setParam('owner', $owner);
$view->setParam('startdate', isset($startdate) ? $startdate : array());
$view->setParam('stopdate', isset($stopdate) ? $stopdate : array());
$view->setParam('expstartdate', isset($expstartdate) ? $expstartdate : array());
$view->setParam('expstopdate', isset($expstopdate) ? $expstopdate : array());
$view->setParam('creationdate', isset($creationdate) ? $creationdate : '');
$view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: '');
$view->setParam('status', isset($status) ? $status : array());
$view->setParam('categories', isset($categories) ? $categories : '');
$view->setParam('attributes', isset($attributes) ? $attributes : '');
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
$view->setParam('attrdefs', $attrdefs);
$allCats = $dms->getDocumentCategories();
$view->setParam('allcategories', $allCats);
$allUsers = $dms->getAllUsers($settings->_sortUsersInList);
$view->setParam('allusers', $allUsers);
$view->setParam('workflowmode', $settings->_workflowMode);
$view->setParam('enablefullsearch', $settings->_enableFullSearch);
$view->setParam('previewWidthList', $settings->_previewWidthList);
$view->setParam('previewconverters', $settings->_converters['preview']);
$view->setParam('timeout', $settings->_cmdTimeout);
$view->setParam('xsendfile', $settings->_enableXsendfile);
$view->setParam('reception', $reception);
$view->setParam('showsinglesearchhit', $settings->_showSingleSearchHit);
$view($_GET);
exit;
if($settings->_showSingleSearchHit && count($entries) == 1) {
$entry = $entries[0];
if($entry->isType('document')) {
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
exit;
} elseif($entry->isType('folder')) {
header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID());
exit;
}
} else {
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if($view) {
$view->setParam('accessobject', $accessop);
$view->setParam('query', $query);
$view->setParam('searchhits', $entries);
$view->setParam('totalpages', $totalPages);
$view->setParam('pagenumber', $pageNumber);
$view->setParam('limit', $limit);
$view->setParam('searchtime', $searchTime);
$view->setParam('urlparams', $_GET);
$view->setParam('cachedir', $settings->_cacheDir);
$view->setParam('totaldocs', $dcount /*resArr['totalDocs']*/);
$view->setParam('totalfolders', $fcount /*resArr['totalFolders']*/);
$view->setParam('fullsearch', (isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSearch) ? true : false);
$view->setParam('mode', isset($mode) ? $mode : '');
$view->setParam('orderby', isset($orderby) ? $orderby : '');
$view->setParam('defaultsearchmethod', $settings->_defaultSearchMethod);
$view->setParam('resultmode', isset($resultmode) ? $resultmode : '');
$view->setParam('searchin', isset($searchin) ? $searchin : array());
$view->setParam('startfolder', isset($startFolder) ? $startFolder : null);
$view->setParam('owner', $owner);
$view->setParam('startdate', isset($startdate) ? $startdate : array());
$view->setParam('stopdate', isset($stopdate) ? $stopdate : array());
$view->setParam('expstartdate', isset($expstartdate) ? $expstartdate : array());
$view->setParam('expstopdate', isset($expstopdate) ? $expstopdate : array());
$view->setParam('creationdate', isset($creationdate) ? $creationdate : '');
$view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: '');
$view->setParam('status', isset($status) ? $status : array());
$view->setParam('categories', isset($categories) ? $categories : '');
$view->setParam('attributes', isset($attributes) ? $attributes : '');
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
$view->setParam('attrdefs', $attrdefs);
$allCats = $dms->getDocumentCategories();
$view->setParam('allcategories', $allCats);
$allUsers = $dms->getAllUsers($settings->_sortUsersInList);
$view->setParam('allusers', $allUsers);
$view->setParam('workflowmode', $settings->_workflowMode);
$view->setParam('enablefullsearch', $settings->_enableFullSearch);
$view->setParam('previewWidthList', $settings->_previewWidthList);
$view->setParam('previewconverters', $settings->_converters['preview']);
$view->setParam('timeout', $settings->_cmdTimeout);
$view->setParam('xsendfile', $settings->_enableXsendfile);
$view->setParam('reception', $reception);
$view->setParam('showsinglesearchhit', $settings->_showSingleSearchHit);
$view($_GET);
exit;
}
}
?>

View File

@ -46,6 +46,19 @@ if (!is_object($folder)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))), getMLText("invalid_folder_id"));
}
if(isset($_GET['action']) && $_GET['action'] == 'subtree') {
if (!isset($_GET["node"]) || !is_numeric($_GET["node"]) || intval($_GET["node"])<1) {
$nodeid = $settings->_rootFolderID;
} else {
$nodeid = intval($_GET["node"]);
}
$node = $dms->getFolder($nodeid);
if (!is_object($node)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))), getMLText("invalid_folder_id"));
}
}
if (isset($_GET["orderby"]) && strlen($_GET["orderby"])>0 ) {
$orderby=$_GET["orderby"];
} else $orderby=$settings->_sortFoldersDefault;
@ -63,6 +76,8 @@ if ($folder->getAccessMode($user) < M_READ) {
}
if($view) {
if(isset($_GET['action']) && $_GET['action'] == 'subtree')
$view->setParam('node', $node);
$view->setParam('folder', $folder);
$view->setParam('orderby', $orderby);
$view->setParam('enableFolderTree', $settings->_enableFolderTree);

View File

@ -405,7 +405,8 @@ $(document).ready( function() {
} else {
url += "&"+param1;
}
element.prepend('<div style="position: absolute; overflow: hidden; background: #f7f7f7; z-index: 1000; height: '+element.height()+'px; width: '+element.width()+'px; opacity: 0.7; display: table;"><div style="display: table-cell;text-align: center; vertical-align: middle; "><img src="../views/bootstrap/images/ajax-loader.gif"></div>');
if(!element.data('no-spinner'))
element.prepend('<div style="position: absolute; overflow: hidden; background: #f7f7f7; z-index: 1000; height: '+element.height()+'px; width: '+element.width()+'px; opacity: 0.7; display: table;"><div style="display: table-cell;text-align: center; vertical-align: middle; "><img src="../views/bootstrap/images/ajax-loader.gif"></div>');
$.get(url, function(data) {
element.html(data);
$(".chzn-select").select2({
@ -571,7 +572,7 @@ function onAddClipboard(ev) { /* {{{ */
processData: false,
cache: false,
data: formData,
success: function(data){
success: function(data, textStatus) {
status.setProgress(100);
if(data.success) {
noty({
@ -707,26 +708,25 @@ function onAddClipboard(ev) { /* {{{ */
}( window.SeedDMSUpload = window.SeedDMSUpload || {}, jQuery )); /* }}} */
$(document).ready(function() { /* {{{ */
var obj = $("#dragandrophandler");
obj.on('dragenter', function (e) {
$(document).on('dragenter', "#dragandrophandler", function (e) {
e.stopPropagation();
e.preventDefault();
$(this).css('border', '2px dashed #0B85A1');
});
obj.on('dragleave', function (e) {
$(document).on('dragleave', "#dragandrophandler", function (e) {
$(this).css('border', '0px solid white');
});
obj.on('dragover', function (e) {
$(document).on('dragover', "#dragandrophandler", function (e) {
e.stopPropagation();
e.preventDefault();
});
obj.on('drop', function (e) {
$(document).on('drop', "#dragandrophandler", function (e) {
$(this).css('border', '0px dotted #0B85A1');
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
//We need to send dropped files to Server
SeedDMSUpload.handleFileUpload(files,obj, obj);
SeedDMSUpload.handleFileUpload(files, $(this), $(this));
});
$(document).on('dragenter', '.droptarget', function (e) {
@ -1153,3 +1153,9 @@ $(document).ready(function() { /* {{{ */
timeOutId = setTimeout(checkTasks, 60000);
}
var updateDropFolder = function() {
$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder});
console.log(seeddms_folder);
timeOutId = setTimeout(updateDropFolder, 60000);
}

View File

@ -1,2 +1,15 @@
Order allow,deny
Deny from all
# line below if for Apache 2.4
<ifModule mod_authz_core.c>
Require all denied
</ifModule>
# line below if for Apache 2.2
<ifModule !mod_authz_core.c>
deny from all
Satisfy All
</ifModule>
# section for Apache 2.2 and 2.4
<ifModule mod_autoindex.c>
IndexIgnore *
</ifModule>

View File

@ -209,7 +209,7 @@ $(document).ready(function() {
'type'=>'text',
'id'=>'name',
'name'=>'name',
'required'=>true
'required'=>false
)
);
$this->formField(
@ -321,7 +321,7 @@ $(document).ready(function() {
);
$this->formField(
getMLText("local_file"),
$enablelargefileupload ? $this->getFineUploaderHtml() : $this->getFileChooserHtml('userfile[]', false).($enablemultiupload ? '<a class="" id="new-file"><?php printMLtext("add_multiple_files") ?></a>' : '')
$enablelargefileupload ? $this->getFineUploaderHtml() : $this->getFileChooserHtml('userfile[]', $enablemultiupload).($enablemultiupload ? '<a class="" id="new-file"><?php printMLtext("add_multiple_files") ?></a>' : '')
);
if($dropfolderdir) {
$this->formField(

View File

@ -1801,7 +1801,7 @@ $(document).ready(function() {
$node['load_on_demand'] = true;
$node['children'] = array();
} else {
$node['children'] = jqtree($this, $path, $folder, $this->params['user'], $accessmode, $showdocs, $expandtree, $orderby, 0);
$node['children'] = jqtree($this, $path, $folder, $this->params['user'], $accessmode, $showdocs, 0 /*$expandtree*/, $orderby, 0);
if($showdocs) {
$documents = $folder->getDocuments(isset($orderby[0]) ? $orderby[0] : '', $orderdir);
$documents = SeedDMS_Core_DMS::filterAccess($documents, $this->params['user'], $accessmode);

View File

@ -0,0 +1,60 @@
<?php
/**
* Implementation of the decorator pattern
*
* @category DMS
* @package SeedDMS_Core
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Class which implements a simple decorator pattern
*
* @category DMS
* @package SeedDMS_Core
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_Decorator {
protected $o;
public function __construct($object) {
$this->o = $object;
}
public function __call($method, $args)
{
if (!method_exists($this->o, $method)) {
throw new Exception("Undefined method $method attempt.");
}
/* In case the called method returns the object itself, then return this object */
$result = call_user_func_array(array($this->o, $method), $args);
return $result === $this->o ? $this : $result;
}
/**
* Must have its own invoke
*/
public function __invoke($get=array()) {
$this->callHook('preRun', isset($get['action']) ? $get['action'] : 'show');
if(isset($get['action']) && $get['action']) {
if(method_exists($this->o, $get['action'])) {
$this->o->{$get['action']}();
} else {
echo "Missing action '".htmlspecialchars($get['action'])."'";
}
} else
$this->show();
$this->callHook('postRun', isset($get['action']) ? $get['action'] : 'show');
}
}

View File

@ -31,6 +31,14 @@ require_once("class.Bootstrap.php");
*/
class SeedDMS_View_DocumentChooser extends SeedDMS_Bootstrap_Style {
public function subtree() { /* {{{ */
$user = $this->params['user'];
$node = $this->params['node'];
$orderby = $this->params['orderby'];
$this->printNewTreeNavigationSubtree($node->getID(), 1, $orderby);
} /* }}} */
function js() { /* {{{ */
$folder = $this->params['folder'];
$form = $this->params['form'];

View File

@ -40,12 +40,14 @@ class SeedDMS_View_DropFolderChooser extends SeedDMS_Bootstrap_Style {
header('Content-Type: application/javascript');
?>
$('.fileselect').click(function(ev) {
attr_filename = $(ev.currentTarget).attr('filename');
fileSelected(attr_filename);
attr_filename = $(ev.currentTarget).data('filename');
attr_form = $(ev.currentTarget).data('form');
fileSelected(attr_filename, attr_form);
});
$('.folderselect').click(function(ev) {
attr_foldername = $(ev.currentTarget).attr('foldername');
folderSelected(attr_foldername);
attr_foldername = $(ev.currentTarget).data('foldername');
attr_form = $(ev.currentTarget).data('form');
folderSelected(attr_foldername, attr_form);
});
<?php
} /* }}} */
@ -144,13 +146,13 @@ $('.folderselect').click(function(ev) {
$previewer->createRawPreview($dir.'/'.$entry, 'dropfolder/', $mimetype);
echo "<tr><td style=\"min-width: ".$previewwidth."px;\">";
if($previewer->hasRawPreview($dir.'/'.$entry, 'dropfolder/')) {
echo "<img style=\"cursor: pointer;\" class=\"fileselect mimeicon\" filename=\"".$entry."\" width=\"".$previewwidth."\" src=\"../op/op.DropFolderPreview.php?filename=".$entry."&width=".$previewwidth."\" title=\"".htmlspecialchars($mimetype)."\">";
echo "<img style=\"cursor: pointer;\" class=\"fileselect mimeicon\" data-filename=\"".$entry."\" data-form=\"".$form."\" width=\"".$previewwidth."\" src=\"../op/op.DropFolderPreview.php?filename=".$entry."&width=".$previewwidth."\" title=\"".htmlspecialchars($mimetype)."\">";
}
echo "</td><td><span style=\"cursor: pointer;\" class=\"fileselect\" filename=\"".$entry."\">".$entry."</span></td><td align=\"right\">".SeedDMS_Core_File::format_filesize(filesize($dir.'/'.$entry))."</td><td>".date('Y-m-d H:i:s', filectime($dir.'/'.$entry))."</td></tr>\n";
echo "</td><td><span style=\"cursor: pointer;\" class=\"fileselect\" data-filename=\"".$entry."\" data-form=\"".$form."\">".$entry."</span></td><td align=\"right\">".SeedDMS_Core_File::format_filesize(filesize($dir.'/'.$entry))."</td><td>".date('Y-m-d H:i:s', filectime($dir.'/'.$entry))."</td></tr>\n";
} elseif($showfolders && is_dir($dir.'/'.$entry)) {
echo "<tr>";
echo "<td></td>";
echo "<td><span style=\"cursor: pointer;\" class=\"folderselect\" foldername=\"".$entry."\" >".$entry."</span></td><td align=\"right\"></td><td></td>";
echo "<td><span style=\"cursor: pointer;\" class=\"folderselect\" data-foldername=\"".$entry."\" data-form=\"".$form."\">".$entry."</span></td><td align=\"right\"></td><td></td>";
echo "</tr>\n";
}
}

View File

@ -31,6 +31,14 @@ require_once("class.Bootstrap.php");
*/
class SeedDMS_View_FolderChooser extends SeedDMS_Bootstrap_Style {
public function subtree() { /* {{{ */
$user = $this->params['user'];
$node = $this->params['node'];
$orderby = $this->params['orderby'];
$this->printNewTreeNavigationSubtree($node->getID(), 0, $orderby);
} /* }}} */
function js() { /* {{{ */
$rootfolderid = $this->params['rootfolderid'];
$form = $this->params['form'];

View File

@ -79,7 +79,6 @@ $(document).ready(function() {
$this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder);
$this->contentHeading(getMLText("edit_existing_notify"));
$this->contentContainerStart();
$userNotifyIDs = array();
foreach ($notifyList["users"] as $userNotify) {

View File

@ -59,6 +59,10 @@ class SeedDMS_View_ImportFS extends SeedDMS_Bootstrap_Style {
getMLText("dropfolder_folder"),
$this->getDropFolderChooserHtml("form1", "", 1)
);
$this->formField(
getMLText("dropfolder_metadata"),
$this->getDropFolderChooserHtml("form2", "", 0)
);
$this->formField(
getMLText("removeFolderFromDropFolder"),
array(

View File

@ -549,9 +549,9 @@ $(document).ready( function() {
if($entries) {
/*
foreach ($entries as $entry) {
if(get_class($entry) == $dms->getClassname('document')) {
if($entry->isType('document')) {
$doccount++;
} elseif(get_class($entry) == $dms->getClassname('document')) {
} elseif($entry->isType('document')) {
$foldercount++;
}
}
@ -585,7 +585,7 @@ $(document).ready( function() {
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
$previewer->setConverters($previewconverters);
foreach ($entries as $entry) {
if(get_class($entry) == $dms->getClassname('document')) {
if($entry->isType('document')) {
$txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search');
if(is_string($txt))
echo $txt;
@ -636,7 +636,7 @@ $(document).ready( function() {
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-default">'.getMLText('attributes').'</span>', $attrstr, true);
print $this->documentListRow($document, $previewer, false, 0, $extracontent);
}
} elseif(get_class($entry) == $dms->getClassname('folder')) {
} elseif($entry->isType('folder')) {
$folder = $entry;
$owner = $folder->getOwner();
if (in_array(2, $searchin)) {

View File

@ -83,7 +83,15 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style {
}
} /* }}} */
function js() { /* {{{ */
public function subtree() { /* {{{ */
$user = $this->params['user'];
$node = $this->params['node'];
$orderby = $this->params['orderby'];
$this->printNewTreeNavigationSubtree($node->getID(), 0, $orderby);
} /* }}} */
public function js() { /* {{{ */
$user = $this->params['user'];
$folder = $this->params['folder'];
$orderby = $this->params['orderby'];
@ -96,8 +104,11 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style {
header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder'));
?>
seeddms_folder = <?= $folder->getID() ?>;
function folderSelected(id, name) {
window.location = '../out/out.ViewFolder.php?folderid=' + id;
// window.location = '../out/out.ViewFolder.php?folderid=' + id;
seeddms_folder = id;
$('div.ajax').trigger('update', {folderid: id, orderby: '<?= $orderby ?>'});
}
<?php if($maxItemsPerPage) { ?>
function loadMoreObjects(element, limit) {
@ -134,7 +145,17 @@ $(window).scroll(function() {
$('#loadmore').click(function(e) {
loadMoreObjects($(this), $(this).data('all'));
});
<?php } ?>
/*
$('body').on('click', '[id^=\"table-row-folder\"]', function(ev) {
attr_id = $(ev.currentTarget).attr('id').split('-')[3];
folderSelected(attr_id, '');
$([document.documentElement, document.body]).animate({
scrollTop: 200
}, 200);
});
*/
<?php
if($showtree == 1)
$this->printNewTreeNavigationJs($folder->getID(), M_READ, 0, '', ($expandFolderTree == 1) ? -1 : 3, $orderby);
@ -151,6 +172,222 @@ $('#loadmore').click(function(e) {
$this->printDeleteDocumentButtonJs();
} /* }}} */
function folderInfos() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$txt = $this->callHook('folderInfo', $folder);
if(is_string($txt))
echo $txt;
else {
$owner = $folder->getOwner();
$this->contentHeading(getMLText("folder_infos"));
$this->contentContainerStart();
echo "<table class=\"table-condensed\">\n";
if($user->isAdmin()) {
echo "<tr>";
echo "<td>".getMLText("id").":</td>\n";
echo "<td>".htmlspecialchars($folder->getID())."</td>\n";
echo "</tr>";
}
echo "<tr>";
echo "<td>".getMLText("owner").":</td>\n";
echo "<td><a href=\"mailto:".htmlspecialchars($owner->getEmail())."\">".htmlspecialchars($owner->getFullName())."</a></td>\n";
echo "</tr>";
echo "<tr>";
echo "<td>".getMLText("creation_date").":</td>";
echo "<td>".getLongReadableDate($folder->getDate())."</td>";
echo "</tr>";
if($folder->getComment()) {
echo "<tr>";
echo "<td>".getMLText("comment").":</td>\n";
echo "<td>".htmlspecialchars($folder->getComment())."</td>\n";
echo "</tr>";
}
if($user->isAdmin()) {
echo "<tr>";
echo "<td>".getMLText('default_access').":</td>";
echo "<td>".$this->getAccessModeText($folder->getDefaultAccess())."</td>";
echo "</tr>";
if($folder->inheritsAccess()) {
echo "<tr>";
echo "<td>".getMLText("access_mode").":</td>\n";
echo "<td>";
echo getMLText("inherited")."<br />";
$this->printAccessList($folder);
echo "</tr>";
} else {
echo "<tr>";
echo "<td>".getMLText('access_mode').":</td>";
echo "<td>";
$this->printAccessList($folder);
echo "</td>";
echo "</tr>";
}
}
$attributes = $folder->getAttributes();
if($attributes) {
foreach($attributes as $attribute) {
$arr = $this->callHook('showFolderAttribute', $folder, $attribute);
if(is_array($arr)) {
echo $txt;
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1].":</td>";
echo "</tr>";
} else {
$attrdef = $attribute->getAttributeDefinition();
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php echo htmlspecialchars(implode(', ', $attribute->getValueAsArray())); ?></td>
</tr>
<?php
}
}
}
echo "</table>\n";
$this->contentContainerEnd();
}
} /* }}} */
function folderList() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$folderid = $folder->getId();
$orderby = $this->params['orderby'];
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
$cachedir = $this->params['cachedir'];
$maxItemsPerPage = $this->params['maxItemsPerPage'];
$incItemsPerPage = $this->params['incItemsPerPage'];
$previewwidth = $this->params['previewWidthList'];
$previewconverters = $this->params['previewConverters'];
$timeout = $this->params['timeout'];
$xsendfile = $this->params['xsendfile'];
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
$previewer->setConverters($previewconverters);
$txt = $this->callHook('listHeader', $folder);
if(is_string($txt))
echo $txt;
else
$this->contentHeading(getMLText("folder_contents"));
$subFolders = $this->callHook('folderGetSubFolders', $folder, $orderby[0], $orderdir);
if($subFolders === null)
$subFolders = $folder->getSubFolders($orderby[0], $orderdir);
$subFolders = SeedDMS_Core_DMS::filterAccess($subFolders, $user, M_READ);
$documents = $this->callHook('folderGetDocuments', $folder, $orderby[0], $orderdir);
if($documents === null)
$documents = $folder->getDocuments($orderby[0], $orderdir);
$documents = SeedDMS_Core_DMS::filterAccess($documents, $user, M_READ);
$parent = null; //$folder->getParent();
$txt = $this->callHook('folderListPreContent', $folder, $subFolders, $documents);
if(is_string($txt))
echo $txt;
$i = 0;
if ((count($subFolders) > 0)||(count($documents) > 0)){
$txt = $this->callHook('folderListHeader', $folder, $orderby, $orderdir);
if(is_string($txt))
echo $txt;
else {
print "<table id=\"viewfolder-table\" class=\"table table-condensed table-hover\">";
print "<thead>\n<tr>\n";
print "<th>".($parent ? '<button class="btn btn-mini btn-default" id="table-row-folder-'.$parent->getID().'"><i class="icon-arrow-up"></i></button>' : '')."</th>\n";
print "<th>".getMLText("name");
print " <a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="n"||$orderby=="na"?"&orderby=nd":"&orderby=n")."\" title=\"".getMLText("sort_by_name")."\">".($orderby=="n"||$orderby=="na"?' <i class="icon-sort-by-alphabet selected"></i>':($orderby=="nd"?' <i class="icon-sort-by-alphabet-alt selected"></i>':' <i class="icon-sort-by-alphabet"></i>'))."</a>";
print " <a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="s"||$orderby=="sa"?"&orderby=sd":"&orderby=s")."\" title=\"".getMLText("sort_by_sequence")."\">".($orderby=="s"||$orderby=="sa"?' <i class="icon-sort-by-order selected"></i>':($orderby=="sd"?' <i class="icon-sort-by-order-alt selected"></i>':' <i class="icon-sort-by-order"></i>'))."</a>";
print " <a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="d"||$orderby=="da"?"&orderby=dd":"&orderby=d")."\" title=\"".getMLText("sort_by_date")."\">".($orderby=="d"||$orderby=="da"?' <i class="icon-sort-by-attributes selected"></i>':($orderby=="dd"?' <i class="icon-sort-by-attributes-alt selected"></i>':' <i class="icon-sort-by-attributes"></i>'))."</a>";
print "</th>\n";
// print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
// print "<th>".getMLText("version")."</th>\n";
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
}
foreach($subFolders as $subFolder) {
if(!$maxItemsPerPage || $i < $maxItemsPerPage) {
$txt = $this->callHook('folderListItem', $subFolder, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->folderListRow($subFolder);
}
}
$i++;
}
if($subFolders && $documents) {
if(!$maxItemsPerPage || $maxItemsPerPage > count($subFolders)) {
$txt = $this->callHook('folderListSeparator', $folder);
if(is_string($txt))
echo $txt;
}
}
foreach($documents as $document) {
if(!$maxItemsPerPage || $i < $maxItemsPerPage) {
$document->verifyLastestContentExpriry();
$txt = $this->callHook('documentListItem', $document, $previewer, false, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->documentListRow($document, $previewer);
}
}
$i++;
}
$txt = $this->callHook('folderListFooter', $folder);
if(is_string($txt))
echo $txt;
else
echo "</tbody>\n</table>\n";
if($maxItemsPerPage && $i > $maxItemsPerPage)
echo "<button id=\"loadmore\" style=\"width: 100%; margin-bottom: 20px;\" class=\"btn btn-default\" data-folder=\"".$folder->getId()."\"data-offset=\"".$maxItemsPerPage."\" data-limit=\"".$incItemsPerPage."\" data-all=\"".($i-$maxItemsPerPage)."\">".getMLText('x_more_objects', array('number'=>($i-$maxItemsPerPage)))."</button>";
}
else printMLText("empty_folder_list");
$txt = $this->callHook('folderListPostContent', $folder, $subFolders, $documents);
if(is_string($txt))
echo $txt;
} /* }}} */
function navigation() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$txt = $this->callHook('folderMenu', $folder);
if(is_string($txt))
echo $txt;
else {
$this->pageNavigation($this->getFolderPathHTML($folder), "view_folder", $folder);
}
echo $this->callHook('preContent');
} /* }}} */
function dropUpload() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$this->contentHeading(getMLText("dropupload"), true);
?>
<div id="dragandrophandler" class="well alert" data-droptarget="folder_<?php echo $folder->getID(); ?>" data-target="<?php echo $folder->getID(); ?>" data-uploadformtoken="<?php echo createFormKey(''); ?>"><?php printMLText('drop_files_here'); ?></div>
<?php
} /* }}} */
function entries() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
@ -246,25 +483,20 @@ $('#loadmore').click(function(e) {
$xsendfile = $this->params['xsendfile'];
$folderid = $folder->getId();
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
$previewer->setConverters($previewconverters);
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
echo $this->callHook('startPage');
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$txt = $this->callHook('folderMenu', $folder);
if(is_string($txt))
echo $txt;
else {
$this->pageNavigation($this->getFolderPathHTML($folder), "view_folder", $folder);
}
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
$previewer->setConverters($previewconverters);
echo $this->callHook('preContent');
// $this->navigation();
?>
<div class="ajax" data-view="ViewFolder" data-action="navigation" data-no-spinner="true" <?php echo ($folder ? "data-query=\"folderid=".$folder->getID()."\"" : "") ?>></div>
<?php
echo "<div class=\"row-fluid\">\n";
@ -305,184 +537,27 @@ $('#loadmore').click(function(e) {
echo "<div class=\"row-fluid\">";
echo "<div class=\"span8\">";
}
$txt = $this->callHook('folderInfo', $folder);
if(is_string($txt))
echo $txt;
else {
$owner = $folder->getOwner();
$this->contentHeading(getMLText("folder_infos"));
$this->contentContainerStart();
echo "<table class=\"table-condensed\">\n";
if($user->isAdmin()) {
echo "<tr>";
echo "<td>".getMLText("id").":</td>\n";
echo "<td>".htmlspecialchars($folder->getID())."</td>\n";
echo "</tr>";
}
echo "<tr>";
echo "<td>".getMLText("owner").":</td>\n";
echo "<td><a href=\"mailto:".htmlspecialchars($owner->getEmail())."\">".htmlspecialchars($owner->getFullName())."</a></td>\n";
echo "</tr>";
echo "<tr>";
echo "<td>".getMLText("creation_date").":</td>";
echo "<td>".getLongReadableDate($folder->getDate())."</td>";
echo "</tr>";
if($folder->getComment()) {
echo "<tr>";
echo "<td>".getMLText("comment").":</td>\n";
echo "<td>".htmlspecialchars($folder->getComment())."</td>\n";
echo "</tr>";
}
if($user->isAdmin()) {
echo "<tr>";
echo "<td>".getMLText('default_access').":</td>";
echo "<td>".$this->getAccessModeText($folder->getDefaultAccess())."</td>";
echo "</tr>";
if($folder->inheritsAccess()) {
echo "<tr>";
echo "<td>".getMLText("access_mode").":</td>\n";
echo "<td>";
echo getMLText("inherited")."<br />";
$this->printAccessList($folder);
echo "</tr>";
} else {
echo "<tr>";
echo "<td>".getMLText('access_mode').":</td>";
echo "<td>";
$this->printAccessList($folder);
echo "</td>";
echo "</tr>";
}
}
$attributes = $folder->getAttributes();
if($attributes) {
foreach($attributes as $attribute) {
$arr = $this->callHook('showFolderAttribute', $folder, $attribute);
if(is_array($arr)) {
echo $txt;
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1].":</td>";
echo "</tr>";
} else {
$attrdef = $attribute->getAttributeDefinition();
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php echo htmlspecialchars(implode(', ', $attribute->getValueAsArray())); ?></td>
</tr>
// $this->folderInfos();
?>
<div class="ajax" data-view="ViewFolder" data-action="folderInfos" data-no-spinner="true" <?php echo ($folder ? "data-query=\"folderid=".$folder->getID()."\"" : "") ?>></div>
<?php
}
}
}
echo "</table>\n";
$this->contentContainerEnd();
}
if ($enableDropUpload && $folder->getAccessMode($user) >= M_READWRITE) {
echo "</div>";
echo "<div class=\"span4\">";
$this->contentHeading(getMLText("dropupload"), true);
// $this->addFooterJS("SeedDMSUpload.setUrl('../op/op.Ajax.php');");
// $this->addFooterJS("SeedDMSUpload.setAbortBtnLabel('".getMLText("cancel")."');");
// $this->addFooterJS("SeedDMSUpload.setEditBtnLabel('".getMLText("edit_document_props")."');");
// $this->addFooterJS("SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");");
// $this->addFooterJS("SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');");
// $this->dropUpload();
?>
<div id="dragandrophandler" class="well alert" data-droptarget="folder_<?php echo $folder->getID(); ?>" data-target="<?php echo $folder->getID(); ?>" data-uploadformtoken="<?php echo createFormKey(''); ?>"><?php printMLText('drop_files_here'); ?></div>
<div class="ajax" data-view="ViewFolder" data-action="dropUpload" <?php echo ($folder ? "data-query=\"folderid=".$folder->getID()."\"" : "") ?>></div>
<?php
echo "</div>";
echo "</div>";
}
$txt = $this->callHook('listHeader', $folder);
if(is_string($txt))
echo $txt;
else
$this->contentHeading(getMLText("folder_contents"));
$subFolders = $this->callHook('folderGetSubFolders', $folder, $orderby[0], $orderdir);
if($subFolders === null)
$subFolders = $folder->getSubFolders($orderby[0], $orderdir);
$subFolders = SeedDMS_Core_DMS::filterAccess($subFolders, $user, M_READ);
$documents = $this->callHook('folderGetDocuments', $folder, $orderby[0], $orderdir);
if($documents === null)
$documents = $folder->getDocuments($orderby[0], $orderdir);
$documents = SeedDMS_Core_DMS::filterAccess($documents, $user, M_READ);
$txt = $this->callHook('folderListPreContent', $folder, $subFolders, $documents);
if(is_string($txt))
echo $txt;
$i = 0;
if ((count($subFolders) > 0)||(count($documents) > 0)){
$txt = $this->callHook('folderListHeader', $folder, $orderby, $orderdir);
if(is_string($txt))
echo $txt;
else {
print "<table id=\"viewfolder-table\" class=\"table table-condensed table-hover\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name");
print " <a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="n"||$orderby=="na"?"&orderby=nd":"&orderby=n")."\" title=\"".getMLText("sort_by_name")."\">".($orderby=="n"||$orderby=="na"?' <i class="icon-sort-by-alphabet selected"></i>':($orderby=="nd"?' <i class="icon-sort-by-alphabet-alt selected"></i>':' <i class="icon-sort-by-alphabet"></i>'))."</a>";
print " <a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="s"||$orderby=="sa"?"&orderby=sd":"&orderby=s")."\" title=\"".getMLText("sort_by_sequence")."\">".($orderby=="s"||$orderby=="sa"?' <i class="icon-sort-by-order selected"></i>':($orderby=="sd"?' <i class="icon-sort-by-order-alt selected"></i>':' <i class="icon-sort-by-order"></i>'))."</a>";
print " <a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="d"||$orderby=="da"?"&orderby=dd":"&orderby=d")."\" title=\"".getMLText("sort_by_date")."\">".($orderby=="d"||$orderby=="da"?' <i class="icon-sort-by-attributes selected"></i>':($orderby=="dd"?' <i class="icon-sort-by-attributes-alt selected"></i>':' <i class="icon-sort-by-attributes"></i>'))."</a>";
print "</th>\n";
// print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
// print "<th>".getMLText("version")."</th>\n";
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
}
foreach($subFolders as $subFolder) {
if(!$maxItemsPerPage || $i < $maxItemsPerPage) {
$txt = $this->callHook('folderListItem', $subFolder, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->folderListRow($subFolder);
}
}
$i++;
}
if($subFolders && $documents) {
if(!$maxItemsPerPage || $maxItemsPerPage > count($subFolders)) {
$txt = $this->callHook('folderListSeparator', $folder);
if(is_string($txt))
echo $txt;
}
}
foreach($documents as $document) {
if(!$maxItemsPerPage || $i < $maxItemsPerPage) {
$document->verifyLastestContentExpriry();
$txt = $this->callHook('documentListItem', $document, $previewer, false, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->documentListRow($document, $previewer);
}
}
$i++;
}
$txt = $this->callHook('folderListFooter', $folder);
if(is_string($txt))
echo $txt;
else
echo "</tbody>\n</table>\n";
if($maxItemsPerPage && $i > $maxItemsPerPage)
echo "<button id=\"loadmore\" style=\"width: 100%; margin-bottom: 20px;\" class=\"btn btn-default\" data-folder=\"".$folder->getId()."\"data-offset=\"".$maxItemsPerPage."\" data-limit=\"".$incItemsPerPage."\" data-all=\"".($i-$maxItemsPerPage)."\">".getMLText('x_more_objects', array('number'=>($i-$maxItemsPerPage)))."</button>";
}
else printMLText("empty_folder_list");
$txt = $this->callHook('folderListPostContent', $folder, $subFolders, $documents);
if(is_string($txt))
echo $txt;
// $this->folderList();
?>
<div class="ajax" data-view="ViewFolder" data-action="folderList" <?php echo ($folder ? "data-query=\"folderid=".$folder->getID()."&orderby=".$orderby."\"" : "") ?>></div>
<?php
echo "</div>\n"; // End of right column div
echo "</div>\n"; // End of div around left and right column

View File

@ -1,5 +1,7 @@
<?php
include("../inc/inc.Settings.php");
//include("../inc/inc.LogInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
@ -8,6 +10,7 @@ include("../inc/inc.ClassEmailNotify.php");
include("../inc/inc.ClassController.php");
include("Log.php");
// LogInit.php cannot be used, because of the different log file
if($settings->_logFileEnable) {
if ($settings->_logFileRotation=="h") $logname=date("YmdH", time());
else if ($settings->_logFileRotation=="d") $logname=date("Ymd", time());
@ -17,16 +20,38 @@ if($settings->_logFileEnable) {
@mkdir($settings->_contentDir.'log');
if(file_exists($settings->_contentDir.'log') && is_dir($settings->_contentDir.'log')) {
$log = Log::factory('file', $logname);
$log->setMask(Log::MAX(PEAR_LOG_INFO));
$log->setMask(Log::MAX(PEAR_LOG_DEBUG));
} else
$log = null;
} else {
$log = null;
}
$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);
}
}
}
if($settings->_enableEmail) {
$notifier->addService(new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword));
}
if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) {
if(method_exists($notificationObj, 'postAddService')) {
$notificationObj->postAddService($dms, $notifier);
}
}
}
include("webdav.php");
$server = new HTTP_WebDAV_Server_SeedDMS();
$server->ServeRequest($dms, $log);
$server->ServeRequest($dms, $log, $notifier);
//$files = array();
//$options = array('path'=>'/Test1/subdir', 'depth'=>1);
//echo $server->MKCOL(&$options);

View File

@ -31,6 +31,16 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
*/
var $logger = null;
/**
* A reference to a notifier
*
* This is set by ServeRequest
*
* @access private
* @var object
*/
var $notifier = null;
/**
* Currently logged in user
*
@ -53,7 +63,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
* @access public
* @param object $dms reference to DMS
*/
function ServeRequest($dms = null, $logger = null) /* {{{ */
function ServeRequest($dms = null, $logger = null, $notifier = null) /* {{{ */
{
// set root directory, defaults to webserver document root if not set
if ($dms) {
@ -65,6 +75,9 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
// set logger
$this->logger = $logger;
// set notifier
$this->notifier = $notifier;
// special treatment for litmus compliance test
// reply on its identifier header
// not needed for the test itself but eases debugging
@ -93,6 +106,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->logger) {
switch($methode) {
case 'MOVE':
case 'COPY':
$msg = $methode.': '.$options['path'].' -> '.$options['dest'];
break;
default:
@ -601,7 +615,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$document = $this->dms->getDocumentByName($name, $folder);
if($document) {
if($this->logger)
$this->logger->log('PUT: replacing document id='.$document->getID(), PEAR_LOG_INFO);
$this->logger->log('PUT: saving document id='.$document->getID(), PEAR_LOG_INFO);
if ($document->getAccessMode($this->user, 'updateDocument') < M_READWRITE) {
if($this->logger)
$this->logger->log('PUT: no access on document', PEAR_LOG_ERR);
@ -633,13 +647,63 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
} else {
if($this->logger)
$this->logger->log('PUT: adding new version', PEAR_LOG_INFO);
if(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) {
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
$indexconf = null;
}
$controller = Controller::factory('UpdateDocument');
$controller->setParam('dms', $this->dms);
$controller->setParam('user', $this->user);
$controller->setParam('documentsource', 'webdav');
$controller->setParam('folder', $document->getFolder());
$controller->setParam('document', $document);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('comment', '');
$controller->setParam('userfiletmp', $tmpFile);
$controller->setParam('userfilename', $name);
$controller->setParam('filetype', $fileType);
$controller->setParam('userfiletype', $mimetype);
$controller->setParam('reviewers', array());
$controller->setParam('approvers', array());
$controller->setParam('attributes', array());
$controller->setParam('workflow', null);
if(!$content = $controller->run()) {
// if(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) {
if($this->logger)
$this->logger->log('PUT: error adding new version', PEAR_LOG_ERR);
unlink($tmpFile);
return "409 Conflict";
}
}
if($this->notifier) {
if($this->logger)
$this->logger->log('PUT: Sending Notifications', PEAR_LOG_INFO);
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_updated_email_subject";
$message = "document_updated_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = $document->getComment();
$params['version_comment'] = $content->getComment();
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $notifyList["users"], $subject, $message, $params);
foreach ($notifyList["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
}
}
} else {
@ -651,6 +715,16 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
unlink($tmpFile);
return "403 Forbidden";
}
/* Check if name already exists in the folder */
/*
if(!$settings->_enableDuplicateDocNames) {
if($folder->hasDocumentByName($name)) {
return "403 Forbidden";
}
}
*/
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
@ -699,6 +773,33 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$this->logger->log('PUT: error adding object: '.$controller->getErrorMsg(), PEAR_LOG_ERR);
return "409 Conflict ".$controller->getErrorMsg();
}
if($this->notifier) {
if($this->logger)
$this->logger->log('PUT: Sending Notifications', PEAR_LOG_INFO);
$fnl = $folder->getNotifyList();
$dnl = $document->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR)
);
$subject = "new_document_email_subject";
$message = "new_document_email_body";
$params = array();
$params['name'] = $name;
$params['folder_name'] = $folder->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = '';
$params['version_comment'] = '';
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
}
unlink($tmpFile);
@ -713,7 +814,9 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
* @return bool true on success
*/
function MKCOL($options) /* {{{ */
{
{
global $settings;
$this->log_options('MKCOL', $options);
$path = $options["path"];
@ -774,6 +877,33 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
return "409 Conflict ".$controller->getErrorMsg();
}
if($this->notifier) {
if($this->logger)
$this->logger->log('MKCOL: Sending Notifications', PEAR_LOG_INFO);
$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)
);
$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'] = $this->user->getFullName();
$params['comment'] = '';
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$subFolder->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
return ("201 Created");
} /* }}} */
@ -820,6 +950,16 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$this->logger->log('DELETE: cannot delete, folder has children', PEAR_LOG_ERR);
return "409 Conflict";
}
$parent = $obj->getParent();
$fnl = $obj->getNotifyList();
$pnl = $parent->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($fnl['users'], $pnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($fnl['groups'], $pnl['groups']), SORT_REGULAR)
);
$foldername = $obj->getName();
$controller = Controller::factory('RemoveFolder');
$controller->setParam('dms', $this->dms);
$controller->setParam('user', $this->user);
@ -827,10 +967,39 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
if(!$controller->run()) {
// if(!$obj->remove()) {
return "409 Conflict ".$controller->getErrorMsg();
}
if($this->notifier) {
if($this->logger)
$this->logger->log('DELETE: Sending Notifications', PEAR_LOG_INFO);
$subject = "folder_deleted_email_subject";
$message = "folder_deleted_email_body";
$params = array();
$params['name'] = $foldername;
$params['folder_path'] = $parent->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$parent->getID();
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
} else {
/* Get the notify list before removing the document
* Also inform the users/groups of the parent folder
*/
$folder = $obj->getFolder();
$dnl = $obj->getNotifyList();
$fnl = $folder->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR)
);
$docname = $obj->getName();
$controller = Controller::factory('RemoveDocument');
$controller->setParam('dms', $this->dms);
$controller->setParam('user', $this->user);
@ -838,9 +1007,26 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
if(!$controller->run()) {
// if(!$obj->remove()) {
return "409 Conflict ".$controller->getErrorMsg();
}
if($this->notifier){
if($this->logger)
$this->logger->log('DELETE: Sending Notifications', PEAR_LOG_INFO);
$subject = "document_deleted_email_subject";
$message = "document_deleted_email_body";
$params = array();
$params['name'] = $docname;
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
}
return "204 No Content";
@ -855,6 +1041,8 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
*/
function MOVE($options) /* {{{ */
{
global $settings;
$this->log_options('MOVE', $options);
// no copying to different WebDAV Servers yet
@ -908,13 +1096,13 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$fspath = $this->dms->contentDir.'/'.$content->getPath();
/* save the content as a new version in the destination document */
if(!$objdest->addContent('', $this->user, $fspath, $content->getOriginalFileName(), $content->getFileType(), $content->getMimeType, array(), array(), 0)) {
if(!$objdest->addContent('', $this->user, $fspath, $content->getOriginalFileName(), $content->getFileType(), $content->getMimeType(), array(), array(), 0)) {
unlink($tmpFile);
return "409 Conflict";
}
/* change the name of the destination object */
$objdest->setName($objsource->getName());
// $objdest->setName($objsource->getName());
/* delete the source object */
$objsource->remove();
@ -922,11 +1110,84 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
return "204 No Content";
} elseif(get_class($objdest) == $this->dms->getClassname('folder')) {
/* Set the new Folder of the source object */
if(get_class($objsource) == $this->dms->getClassname('document'))
$objsource->setFolder($objdest);
elseif(get_class($objsource) == $this->dms->getClassname('folder'))
$objsource->setParent($objdest);
else
if(get_class($objsource) == $this->dms->getClassname('document')) {
/* Check if name already exists in the folder */
/*
if(!$settings->_enableDuplicateDocNames) {
if($objdest->hasDocumentByName($objsource->getName())) {
return "403 Forbidden";
}
}
*/
$oldFolder = $objsource->getFolder();
if($objsource->setFolder($objdest)) {
if($this->notifier) {
if($this->logger)
$this->logger->log('MOVE: Sending Notifications', PEAR_LOG_INFO);
$nl1 = $oldFolder->getNotifyList();
$nl2 = $objsource->getNotifyList();
$nl3 = $objdest->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($nl1['users'], $nl2['users'], $nl3['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($nl1['groups'], $nl2['groups'], $nl3['groups']), SORT_REGULAR)
);
$subject = "document_moved_email_subject";
$message = "document_moved_email_body";
$params = array();
$params['name'] = $objsource->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $objdest->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$objsource->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
} else {
return "500 Internal server error";
}
} elseif(get_class($objsource) == $this->dms->getClassname('folder')) {
/* Check if name already exists in the folder */
if(!$settings->_enableDuplicateSubFolderNames) {
if($objdest->hasSubFolderByName($objsource->getName())) {
return "403 Forbidden";
}
}
$oldFolder = $objsource->getParent();
if($objsource->setParent($objdest)) {
if($this->notifier) {
if($this->logger)
$this->logger->log('MOVE: Sending Notifications', PEAR_LOG_INFO);
$nl1 = $oldFolder->getNotifyList();
$nl2 = $objsource->getNotifyList();
$nl3 = $objdest->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($nl1['users'], $nl2['users'], $nl3['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($nl1['groups'], $nl2['groups'], $nl3['groups']), SORT_REGULAR)
);
$subject = "folder_moved_email_subject";
$message = "folder_moved_email_body";
$params = array();
$params['name'] = $objsource->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $objdest->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
} else {
return "500 Internal server error";
}
} else
return "500 Internal server error";
if($newdocname)
$objsource->setName($newdocname);
@ -940,12 +1201,11 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
function COPY($options, $del=false) /* {{{ */
function COPY($options) /* {{{ */
{
global $settings, $indexconf;
if(!$del)
$this->log_options('COPY', $options);
$this->log_options('COPY', $options);
// TODO Property updates still broken (Litmus should detect this?)
@ -974,6 +1234,8 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
// get dest folder or document
$objdest = $this->reverseLookup($options["dest"]);
// If the destination doesn't exists, then check if the parent folder exists
// and set $newdocname, which is later used to create a new document
$newdocname = '';
if(!$objdest) {
/* check if at least the dest directory exists */
@ -995,7 +1257,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
return "403 Forbidden";
}
/* If destination object is a document it must be overwritten */
/* If destination object is a document the source document will create a new version */
if(get_class($objdest) == $this->dms->getClassname('document')) {
if (!$options["overwrite"]) {
return "412 precondition failed";
@ -1009,13 +1271,19 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$content = $objsource->getLatestContent();
$fspath = $this->dms->contentDir.'/'.$content->getPath();
/* If the checksum of source and destination are equal, then do not copy */
if($content->getChecksum() == $objdest->getLatestContent()->getChecksum()) {
return "204 No Content";
}
/* save the content as a new version in the destination document */
if(!$objdest->addContent('', $this->user, $fspath, $content->getOriginalFileName(), $content->getFileType(), $content->getMimeType, array(), array(), 0)) {
if(!$objdest->addContent('', $this->user, $fspath, $content->getOriginalFileName(), $content->getFileType(), $content->getMimeType(), array(), array(), 0)) {
unlink($tmpFile);
return "409 Conflict";
}
$objdest->setName($objsource->getName());
/* Since 5.1.13 do not overwrite the name anymore
$objdest->setName($objsource->getName()); */
return "204 No Content";
} elseif(get_class($objdest) == $this->dms->getClassname('folder')) {
@ -1033,6 +1301,15 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if(!$newdocname)
$newdocname = $objsource->getName();
/* Check if name already exists in the folder */
/*
if(!$settings->_enableDuplicateDocNames) {
if($objdest->hasDocumentByName($newdocname)) {
return "403 Forbidden";
}
}
*/
/* get the latest content of the source object */
$content = $objsource->getLatestContent();
$fspath = $this->dms->contentDir.'/'.$content->getPath();
@ -1084,6 +1361,34 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$this->logger->log('COPY: error copying object', PEAR_LOG_ERR);
return "409 Conflict";
}
if($this->notifier) {
if($this->logger)
$this->logger->log('COPY: Sending Notifications', PEAR_LOG_INFO);
$fnl = $objdest->getNotifyList();
$dnl = $document->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR)
);
$subject = "new_document_email_subject";
$message = "new_document_email_body";
$params = array();
$params['name'] = $name;
$params['folder_name'] = $objdest->getName();
$params['folder_path'] = $objdest->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = '';
$params['version_comment'] = '';
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$objdest->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
}
return "201 Created";
}
} /* }}} */