2017-05-04 11:48:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of UpdateDocument controller
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @license GPL 2
|
|
|
|
* @version @version@
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class which does the busines logic for downloading a document
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
|
|
|
|
|
|
|
|
public function run() { /* {{{ */
|
|
|
|
$name = $this->getParam('name');
|
|
|
|
$comment = $this->getParam('comment');
|
|
|
|
|
|
|
|
/* Call preUpdateDocument early, because it might need to modify some
|
|
|
|
* of the parameters.
|
|
|
|
*/
|
2017-06-13 12:40:17 +00:00
|
|
|
if(false === $this->callHook('preUpdateDocument', $this->params['document'])) {
|
|
|
|
if(empty($this->errormsg))
|
|
|
|
$this->errormsg = 'hook_preUpdateDocument_failed';
|
2017-05-04 11:48:07 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-06-23 10:58:36 +00:00
|
|
|
$comment = $this->getParam('comment');
|
2017-05-04 11:48:07 +00:00
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$user = $this->params['user'];
|
|
|
|
$document = $this->params['document'];
|
|
|
|
$settings = $this->params['settings'];
|
2020-09-09 17:49:15 +00:00
|
|
|
$fulltextservice = $this->params['fulltextservice'];
|
2017-05-04 11:48:07 +00:00
|
|
|
$folder = $this->params['folder'];
|
|
|
|
$userfiletmp = $this->getParam('userfiletmp');
|
|
|
|
$userfilename = $this->getParam('userfilename');
|
|
|
|
$filetype = $this->getParam('filetype');
|
|
|
|
$userfiletype = $this->getParam('userfiletype');
|
|
|
|
$reviewers = $this->getParam('reviewers');
|
|
|
|
$approvers = $this->getParam('approvers');
|
|
|
|
$reqversion = $this->getParam('reqversion');
|
|
|
|
$comment = $this->getParam('comment');
|
|
|
|
$attributes = $this->getParam('attributes');
|
|
|
|
$workflow = $this->getParam('workflow');
|
|
|
|
$maxsizeforfulltext = $this->getParam('maxsizeforfulltext');
|
|
|
|
|
2019-01-17 17:27:10 +00:00
|
|
|
$content = $this->callHook('updateDocument');
|
|
|
|
if($content === null) {
|
2017-05-04 11:48:07 +00:00
|
|
|
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
|
2018-11-09 16:20:53 +00:00
|
|
|
if($contentResult=$document->addContent($comment, $user, $userfiletmp, utf8_basename($userfilename), $filetype, $userfiletype, $reviewers, $approvers, $version=0, $attributes, $workflow)) {
|
2017-05-04 11:48:07 +00:00
|
|
|
|
2018-11-09 16:20:53 +00:00
|
|
|
if ($this->hasParam('expires')) {
|
|
|
|
if($document->setExpires($this->getParam('expires'))) {
|
|
|
|
} else {
|
|
|
|
}
|
2017-05-04 11:48:07 +00:00
|
|
|
}
|
|
|
|
|
2019-01-17 17:27:10 +00:00
|
|
|
$content = $contentResult->getContent();
|
2018-11-09 16:20:53 +00:00
|
|
|
} else {
|
|
|
|
$this->errormsg = 'error_update_document';
|
|
|
|
$result = false;
|
2017-05-04 11:48:07 +00:00
|
|
|
}
|
2019-01-17 17:27:10 +00:00
|
|
|
} elseif($result === false) {
|
|
|
|
if(empty($this->errormsg))
|
|
|
|
$this->errormsg = 'hook_updateDocument_failed';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:49:15 +00:00
|
|
|
if($fulltextservice && ($index = $fulltextservice->Indexer()) && $content) {
|
|
|
|
$idoc = $fulltextservice->IndexedDocument($document);
|
2019-01-17 17:27:10 +00:00
|
|
|
if(false !== $this->callHook('preIndexDocument', $document, $idoc)) {
|
2021-01-08 09:07:12 +00:00
|
|
|
$lucenesearch = $fulltextservice->Search();
|
|
|
|
if($hit = $lucenesearch->getDocument((int) $document->getId())) {
|
|
|
|
$index->delete($hit->id);
|
|
|
|
}
|
2019-01-17 17:27:10 +00:00
|
|
|
$index->addDocument($idoc);
|
|
|
|
$index->commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-08 12:19:36 +00:00
|
|
|
if(false === $this->callHook('postUpdateDocument', $document, $content)) {
|
2017-05-04 11:48:07 +00:00
|
|
|
}
|
|
|
|
|
2019-01-17 17:27:10 +00:00
|
|
|
return $content;
|
2017-05-04 11:48:07 +00:00
|
|
|
} /* }}} */
|
|
|
|
}
|
|
|
|
|