2011-03-10 14:32:22 +00:00
|
|
|
<?php
|
|
|
|
// MyDMS. Document Management System
|
|
|
|
// Copyright (C) 2002-2005 Markus Westphal
|
|
|
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
2016-08-09 05:34:30 +00:00
|
|
|
// Copyright (C) 2010-2016 Uwe Steinmann
|
2011-03-10 14:32:22 +00:00
|
|
|
//
|
|
|
|
// 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");
|
2022-11-09 05:40:50 +00:00
|
|
|
include("../inc/inc.Utils.php");
|
2011-05-16 15:44:59 +00:00
|
|
|
include("../inc/inc.LogInit.php");
|
2011-03-10 14:32:22 +00:00
|
|
|
include("../inc/inc.Language.php");
|
2014-12-08 13:47:32 +00:00
|
|
|
include("../inc/inc.Init.php");
|
|
|
|
include("../inc/inc.Extension.php");
|
|
|
|
include("../inc/inc.DBInit.php");
|
2011-03-10 14:32:22 +00:00
|
|
|
include("../inc/inc.ClassUI.php");
|
|
|
|
include("../inc/inc.Authentication.php");
|
|
|
|
|
|
|
|
$file_param_name = 'file';
|
|
|
|
$file_name = $_FILES[ $file_param_name ][ 'name' ];
|
|
|
|
$source_file_path = $_FILES[ $file_param_name ][ 'tmp_name' ];
|
2014-03-21 07:10:23 +00:00
|
|
|
$fileId = basename($_POST['fileId']);
|
|
|
|
$partitionIndex = (int) $_POST['partitionIndex'];
|
|
|
|
$target_file_path =$settings->_stagingDir.$fileId."-".$partitionIndex;
|
2011-03-10 14:32:22 +00:00
|
|
|
if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
|
2014-03-21 07:10:23 +00:00
|
|
|
if($partitionIndex+1 == $_POST['partitionCount']) {
|
|
|
|
$fpnew = fopen($settings->_stagingDir.$fileId, 'w+');
|
2011-03-10 14:32:22 +00:00
|
|
|
for($i=0; $i<$_POST['partitionCount']; $i++) {
|
2014-03-21 07:10:23 +00:00
|
|
|
$content = file_get_contents($settings->_stagingDir.$fileId."-".$i, 'r');
|
2011-03-10 14:32:22 +00:00
|
|
|
fwrite($fpnew, $content);
|
2014-03-21 07:10:23 +00:00
|
|
|
unlink($settings->_stagingDir.$fileId."-".$i);
|
2011-03-10 14:32:22 +00:00
|
|
|
}
|
|
|
|
fclose($fpnew);
|
|
|
|
|
|
|
|
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
|
|
|
|
echo getMLText("invalid_doc_id");
|
|
|
|
}
|
|
|
|
|
|
|
|
$documentid = $_POST["documentid"];
|
|
|
|
$document = $dms->getDocument($documentid);
|
|
|
|
$folder = $document->getFolder();
|
|
|
|
|
|
|
|
if (!is_object($document)) {
|
|
|
|
echo getMLText("invalid_doc_id");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($document->getAccessMode($user) < M_READWRITE) {
|
|
|
|
echo getMLText("access_denied");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($document->isLocked()) {
|
|
|
|
$lockingUser = $document->getLockingUser();
|
|
|
|
if (($lockingUser->getID() != $user->getID()) && ($document->getAccessMode($user) != M_ALL)) {
|
|
|
|
echo getMLText("no_update_cause_locked");
|
|
|
|
}
|
|
|
|
else $document->setLocked(false);
|
|
|
|
}
|
|
|
|
|
2011-12-02 18:44:42 +00:00
|
|
|
$comment = $_POST["comment"];
|
2011-03-10 14:32:22 +00:00
|
|
|
|
2014-03-21 07:10:23 +00:00
|
|
|
$userfiletmp = $settings->_stagingDir.$fileId;
|
2011-03-10 14:32:22 +00:00
|
|
|
$userfiletype = $_FILES[ $file_param_name ]["type"];
|
|
|
|
$userfilename = $_FILES[ $file_param_name ]["name"];
|
|
|
|
|
2014-06-13 15:29:40 +00:00
|
|
|
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
2011-03-10 14:32:22 +00:00
|
|
|
|
2015-06-23 05:45:18 +00:00
|
|
|
if($settings->_overrideMimeType) {
|
|
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
|
|
|
$userfiletype = finfo_file($finfo, $userfiletmp);
|
|
|
|
}
|
|
|
|
|
2011-03-10 14:32:22 +00:00
|
|
|
// Get the list of reviewers and approvers for this document.
|
|
|
|
$reviewers = array();
|
|
|
|
$approvers = array();
|
|
|
|
|
|
|
|
// Retrieve the list of individual reviewers from the form.
|
|
|
|
$reviewers["i"] = array();
|
|
|
|
if (isset($_POST["indReviewers"])) {
|
|
|
|
foreach ($_POST["indReviewers"] as $ind) {
|
|
|
|
$reviewers["i"][] = $ind;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Retrieve the list of reviewer groups from the form.
|
|
|
|
$reviewers["g"] = array();
|
|
|
|
if (isset($_POST["grpReviewers"])) {
|
|
|
|
foreach ($_POST["grpReviewers"] as $grp) {
|
|
|
|
$reviewers["g"][] = $grp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Retrieve the list of individual approvers from the form.
|
|
|
|
$approvers["i"] = array();
|
|
|
|
if (isset($_POST["indApprovers"])) {
|
|
|
|
foreach ($_POST["indApprovers"] as $ind) {
|
|
|
|
$approvers["i"][] = $ind;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Retrieve the list of approver groups from the form.
|
|
|
|
$approvers["g"] = array();
|
|
|
|
if (isset($_POST["grpApprovers"])) {
|
|
|
|
foreach ($_POST["grpApprovers"] as $grp) {
|
|
|
|
$approvers["g"][] = $grp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add mandatory reviewers/approvers
|
2014-03-14 14:11:40 +00:00
|
|
|
$docAccess = $folder->getReadAccessList($settings->_enableAdminRevApp, $settings->_enableOwnerRevApp);
|
2011-03-10 14:32:22 +00:00
|
|
|
$res=$user->getMandatoryReviewers();
|
|
|
|
foreach ($res as $r){
|
|
|
|
|
|
|
|
if ($r['reviewerUserID']!=0){
|
|
|
|
foreach ($docAccess["users"] as $usr)
|
|
|
|
if ($usr->getID()==$r['reviewerUserID']){
|
|
|
|
$reviewers["i"][] = $r['reviewerUserID'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($r['reviewerGroupID']!=0){
|
|
|
|
foreach ($docAccess["groups"] as $grp)
|
|
|
|
if ($grp->getID()==$r['reviewerGroupID']){
|
|
|
|
$reviewers["g"][] = $r['reviewerGroupID'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$res=$user->getMandatoryApprovers();
|
|
|
|
foreach ($res as $r){
|
|
|
|
|
|
|
|
if ($r['approverUserID']!=0){
|
|
|
|
foreach ($docAccess["users"] as $usr)
|
|
|
|
if ($usr->getID()==$r['approverUserID']){
|
|
|
|
$approvers["i"][] = $r['approverUserID'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($r['approverGroupID']!=0){
|
|
|
|
foreach ($docAccess["groups"] as $grp)
|
|
|
|
if ($grp->getID()==$r['approverGroupID']){
|
|
|
|
$approvers["g"][] = $r['approverGroupID'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 15:09:49 +00:00
|
|
|
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
|
2011-03-10 14:32:22 +00:00
|
|
|
$contentResult=$document->addContent($comment, $user, $userfiletmp, basename($userfilename), $fileType, $userfiletype, $reviewers, $approvers);
|
2011-03-15 14:20:54 +00:00
|
|
|
unlink($userfiletmp);
|
2011-03-10 14:32:22 +00:00
|
|
|
if (is_bool($contentResult) && !$contentResult) {
|
|
|
|
echo getMLText("error_occured");
|
|
|
|
} else {
|
2020-09-09 17:49:15 +00:00
|
|
|
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
|
2016-08-02 15:09:49 +00:00
|
|
|
if($index) {
|
2020-09-09 17:49:15 +00:00
|
|
|
$lucenesearch = $fulltextservice->Search();
|
2016-08-02 15:09:49 +00:00
|
|
|
if($hit = $lucenesearch->getDocument((int) $document->getId())) {
|
|
|
|
$index->delete($hit->id);
|
|
|
|
}
|
2020-09-09 17:49:15 +00:00
|
|
|
$index->addDocument($fulltextservice->IndexedDocument($document));
|
2016-08-02 15:09:49 +00:00
|
|
|
$index->commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-10 14:32:22 +00:00
|
|
|
// Send notification to subscribers.
|
|
|
|
if ($notifier){
|
2013-03-06 11:53:25 +00:00
|
|
|
$notifyList = $document->getNotifyList();
|
2011-03-10 14:32:22 +00:00
|
|
|
$folder = $document->getFolder();
|
2013-03-06 11:53:25 +00:00
|
|
|
$subject = "document_updated_email_subject";
|
|
|
|
$message = "document_updated_email_body";
|
|
|
|
$params = array();
|
|
|
|
$params['name'] = $document->getName();
|
|
|
|
$params['folder_path'] = $folder->getFolderPathPlain();
|
|
|
|
$params['username'] = $user->getFullName();
|
2014-07-21 05:34:13 +00:00
|
|
|
$params['comment'] = $document->getComment();
|
|
|
|
$params['version_comment'] = $contentResult->getContent()->getComment();
|
2019-11-28 09:01:59 +00:00
|
|
|
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
|
2013-03-06 11:53:25 +00:00
|
|
|
$params['sitename'] = $settings->_siteName;
|
|
|
|
$params['http_root'] = $settings->_httpRoot;
|
|
|
|
$notifier->toList($user, $notifyList["users"], $subject, $message, $params);
|
|
|
|
foreach ($notifyList["groups"] as $grp) {
|
|
|
|
$notifier->toGroup($user, $grp, $subject, $message, $params);
|
|
|
|
}
|
|
|
|
// if user is not owner send notification to owner
|
2016-12-08 17:14:54 +00:00
|
|
|
// if ($user->getID() != $document->getOwner()->getID())
|
|
|
|
// $notifier->toIndividual($user, $document->getOwner(), $subject, $message, $params);
|
2011-03-10 14:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$expires = ($_POST["expires"] == "true") ? mktime(0,0,0, $_POST["expmonth"], $_POST["expday"], $_POST["expyear"]) : false;
|
|
|
|
|
|
|
|
if ($document->setExpires($expires)) {
|
|
|
|
if($notifier) {
|
2013-03-06 11:53:25 +00:00
|
|
|
$notifyList = $document->getNotifyList();
|
2011-03-10 14:32:22 +00:00
|
|
|
$folder = $document->getFolder();
|
|
|
|
// Send notification to subscribers.
|
2013-03-06 11:53:25 +00:00
|
|
|
$subject = "expiry_changed_email_subject";
|
|
|
|
$message = "expiry_changed_email_body";
|
|
|
|
$params = array();
|
|
|
|
$params['name'] = $document->getName();
|
|
|
|
$params['folder_path'] = $folder->getFolderPathPlain();
|
|
|
|
$params['username'] = $user->getFullName();
|
2019-11-28 09:01:59 +00:00
|
|
|
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
|
2013-03-06 11:53:25 +00:00
|
|
|
$params['sitename'] = $settings->_siteName;
|
|
|
|
$params['http_root'] = $settings->_httpRoot;
|
|
|
|
$notifier->toList($user, $notifyList["users"], $subject, $message, $params);
|
|
|
|
foreach ($notifyList["groups"] as $grp) {
|
|
|
|
$notifier->toGroup($user, $grp, $subject, $message, $params);
|
|
|
|
}
|
2011-03-10 14:32:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_log_line("?documentid=".$documentid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|