documents can be transfered to another user

include document links, attachments, locks
This commit is contained in:
Uwe Steinmann 2017-12-05 18:38:06 +01:00
parent b68cfe3893
commit 8a26b51ff3
4 changed files with 301 additions and 0 deletions

View File

@ -0,0 +1,53 @@
<?php
/**
* Implementation of TransferDocument controller
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2017 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) 2017 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_Controller_TransferDocument extends SeedDMS_Controller_Common {
public function run() {
$dms = $this->params['dms'];
$user = $this->params['user'];
$settings = $this->params['settings'];
$document = $this->params['document'];
$newuser = $this->params['newuser'];
$folder = $document->getFolder();
if(false === $this->callHook('preTransferDocument')) {
if(empty($this->errormsg))
$this->errormsg = 'hook_preTransferDocument_failed';
return null;
}
$result = $this->callHook('transferDocument', $document);
if($result === null) {
if (!$document->transferToUser($newuser)) {
return false;
} else {
if(!$this->callHook('postTransferDocument')) {
}
}
}
return true;
}
}

View File

@ -0,0 +1,96 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010-2016 Uwe Steinmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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.
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");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassController.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$controller = Controller::factory($tmp[1]);
if (!$user->isAdmin()) {
UI::exitError(getMLText("document"),getMLText("access_denied"));
}
/* Check if the form data comes from a trusted request */
if(!checkFormKey('transferdocument')) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
}
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$documentid = $_POST["documentid"];
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
if (!isset($_POST["userid"]) || !is_numeric($_POST["userid"]) || intval($_POST["userid"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$userid = $_POST["userid"];
$newuser = $dms->getUser($userid);
if (!is_object($newuser)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$folder = $document->getFolder();
$controller->setParam('document', $document);
$controller->setParam('newuser', $newuser);
if(!$controller->run()) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("error_transfer_document"));
}
if ($notifier){
/* Get the notify list before removing the document */
$nl = $document->getNotifyList();
$subject = "document_transfered_email_subject";
$message = "document_transfered_email_body";
$params = array();
$params['name'] = $document->getName();
$params['newuser'] = $newuser->getFullName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$notifier->toList($user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message, $params);
}
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_transfer_document')));
add_log_line("?documentid=".$documentid);
header("Location:../out/out.ViewFolder.php?folderid=".$folder->getID());
?>

View File

@ -0,0 +1,67 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010-2016 Uwe Steinmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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.
include("../inc/inc.Settings.php");
include("../inc/inc.LogInit.php");
include("../inc/inc.Utils.php");
include("../inc/inc.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassAccessOperation.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
if (!$user->isAdmin()) {
UI::exitError(getMLText("document"),getMLText("access_denied"));
}
if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$document = $dms->getDocument($_GET["documentid"]);
if (!is_object($document)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$users = $dms->getAllUsers($settings->_sortUsersInList);
if (is_bool($users)) {
UI::exitError(getMLText("admin_tools"),getMLText("internal_error"));
}
$folder = $document->getFolder();
/* Create object for checking access to certain operations */
$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings);
if($view) {
$view->setParam('folder', $folder);
$view->setParam('document', $document);
$view->setParam('allusers', $users);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}
?>

View File

@ -0,0 +1,85 @@
<?php
/**
* Implementation of TransferDocument view
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2017 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
require_once("class.Bootstrap.php");
/**
* Class which outputs the html page for TransferDocument view
*
* @category DMS
* @package SeedDMS
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2017 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_TransferDocument extends SeedDMS_Bootstrap_Style {
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$allusers = $this->params['allusers'];
$document = $this->params['document'];
$folder = $this->params['folder'];
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
$this->contentHeading(getMLText("transfer_document"));
$this->contentContainerStart();
?>
<form class="form-horizontal" action="../op/op.TransferDocument.php" name="form1" method="post">
<input type="hidden" name="documentid" value="<?php print $document->getID();?>">
<?php echo createHiddenFieldWithKey('transferdocument'); ?>
<div class="control-group">
<label class="control-label" for="assignTo">
<?php printMLText("transfer_to_user"); ?>:
</label>
<div class="controls">
<select name="userid" class="chzn-select">
<?php
$owner = $document->getOwner();
foreach ($allusers as $currUser) {
if ($currUser->isGuest() || ($currUser->getID() == $owner->getID()))
continue;
print "<option value=\"".$currUser->getID()."\"";
if($folder->getAccessMode($currUser) < M_READ)
print " disabled data-warning=\"".getMLText('transfer_no_read_access')."\"";
elseif($folder->getAccessMode($currUser) < M_READWRITE)
print " data-warning=\"".getMLText('transfer_no_write_access')."\"";
print ">" . htmlspecialchars($currUser->getLogin()." - ".$currUser->getFullName());
}
?>
</select>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn"><i class="icon-remove"></i> <?php printMLText("transfer_document");?></button>
</div>
</div>
</form>
<?php
$this->contentContainerEnd();
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */
}
?>