mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
send notifications, check for duplicate folder/document names if configured
This commit is contained in:
parent
4b2b536fdb
commit
e571fe38a5
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
} /* }}} */
|
||||
|
|
Loading…
Reference in New Issue
Block a user