- added gui for uploading files with jumploader

This commit is contained in:
steinm 2011-03-10 14:32:22 +00:00
parent 8c6da8567a
commit d983759a0c
5 changed files with 587 additions and 0 deletions

219
op/op.AddMultiDocument.php Normal file
View File

@ -0,0 +1,219 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
// Copyright (C) 2011 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.Utils.php");
include("../inc/inc.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.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' ];
$target_file_path =$settings->_stagingDir.$_POST['fileId']."-".$_POST['partitionIndex'];
if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
if($_POST['partitionIndex']+1 == $_POST['partitionCount']) {
$fpnew = fopen($settings->_stagingDir.$_POST['fileId'], 'w+');
for($i=0; $i<$_POST['partitionCount']; $i++) {
$content = file_get_contents($settings->_stagingDir.$_POST['fileId']."-".$i, 'r');
fwrite($fpnew, $content);
unlink($settings->_stagingDir.$_POST['fileId']."-".$i);
}
fclose($fpnew);
if (!isset($_POST["folderid"]) || !is_numeric($_POST["folderid"]) || intval($_POST["folderid"])<1) {
echo getMLText("invalid_folder_id");
}
$folderid = $_POST["folderid"];
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
echo getMLText("invalid_folder_id");
}
$folderPathHTML = getFolderPathHTML($folder, true);
if ($folder->getAccessMode($user) < M_READWRITE) {
echo getMLText("access_denied");
}
if(isset($_POST["comment"]))
$comment = sanitizeString($_POST["comment"]);
else
$comment = '';
if(isset($_POST['version_comment']))
$version_comment = sanitizeString($_POST["version_comment"]);
else
$version_comment = '';
if(isset($_POST["keywords"]))
$keywords = sanitizeString($_POST["keywords"]);
else
$keywords = '';
$reqversion = (int)$_POST["reqversion"];
if ($reqversion<1) $reqversion=1;
$sequence = $_POST["sequence"];
if (!is_numeric($sequence)) {
$sequence = 1;
}
$expires = ($_POST["expires"] == "true") ? mktime(0,0,0, sanitizeString($_POST["expmonth"]), sanitizeString($_POST["expday"]), sanitizeString($_POST["expyear"])) : false;
// Get the list of reviewers and approvers for this document.
$reviewers = array();
$approvers = array();
$reviewers["i"] = array();
$reviewers["g"] = array();
$approvers["i"] = array();
$approvers["g"] = array();
// Retrieve the list of individual reviewers from the form.
if (isset($_POST["indReviewers"])) {
foreach ($_POST["indReviewers"] as $ind) {
$reviewers["i"][] = $ind;
}
}
// Retrieve the list of reviewer groups from the form.
if (isset($_POST["grpReviewers"])) {
foreach ($_POST["grpReviewers"] as $grp) {
$reviewers["g"][] = $grp;
}
}
// Retrieve the list of individual approvers from the form.
if (isset($_POST["indApprovers"])) {
foreach ($_POST["indApprovers"] as $ind) {
$approvers["i"][] = $ind;
}
}
// Retrieve the list of approver groups from the form.
if (isset($_POST["grpApprovers"])) {
foreach ($_POST["grpApprovers"] as $grp) {
$approvers["g"][] = $grp;
}
}
// add mandatory reviewers/approvers
$docAccess = $folder->getApproversList();
$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;
}
}
}
$userfiletmp = $settings->_stagingDir.$_POST['fileId'];;
$userfiletype = $_FILES[ $file_param_name ]["type"];
$userfilename = $_FILES[ $file_param_name ]["name"];
$lastDotIndex = strrpos(basename($userfilename), ".");
if (is_bool($lastDotIndex) && !$lastDotIndex) $fileType = ".";
else $fileType = substr($userfilename, $lastDotIndex);
if($_POST["name"] != "")
$name = sanitizeString($_POST["name"]);
else
$name = basename($userfilename);
$categories = sanitizeString($_POST["categoryids"]);
$cats = array();
if($categories) {
$catids = explode(',', $categories);
foreach($catids as $catid) {
$cats[] = $dms->getDocumentCategory($catid);
}
}
$res = $folder->addDocument($name, $comment, $expires, $user, $keywords,
$cats, $userfiletmp, basename($userfilename),
$fileType, $userfiletype, $sequence,
$reviewers, $approvers, $reqversion,$version_comment);
unlink($userfiletmp);
if (is_bool($res) && !$res) {
echo getMLText("error_occured");
} else {
$document = $res[0];
if(isset($GLOBALS['LETODMS_HOOKS']['postAddDocument'])) {
foreach($GLOBALS['LETODMS_HOOKS']['postAddDocument'] as $hookObj) {
if (method_exists($hookObj, 'postAddDocument')) {
$hookObj->postAddDocument($document);
}
}
}
// Send notification to subscribers.
if($notifier) {
$folder->getNotifyList();
$subject = "###SITENAME###: ".$folder->_name." - ".getMLText("new_document_email");
$message = getMLText("new_document_email")."\r\n";
$message .=
getMLText("name").": ".$name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$comment."\r\n".
getMLText("comment_for_current_version").": ".$version_comment."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $folder->_notifyList["users"], $subject, $message);
foreach ($folder->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?name=".$name."&folderid=".$folderid);
}
}
?>

213
op/op.UpdateDocument2.php Normal file
View File

@ -0,0 +1,213 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
//
// 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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
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' ];
$target_file_path =$settings->_stagingDir.$_POST['fileId']."-".$_POST['partitionIndex'];
if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
if($_POST['partitionIndex']+1 == $_POST['partitionCount']) {
$fpnew = fopen($settings->_stagingDir.$_POST['fileId'], 'w+');
for($i=0; $i<$_POST['partitionCount']; $i++) {
$content = file_get_contents($settings->_stagingDir.$_POST['fileId']."-".$i, 'r');
fwrite($fpnew, $content);
unlink($settings->_stagingDir.$_POST['fileId']."-".$i);
}
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);
}
$comment = sanitizeString($_POST["comment"]);
$userfiletmp = $_FILES["userfile"]["tmp_name"];
$userfiletmp = $settings->_stagingDir.$_POST['fileId'];;
$userfiletype = $_FILES[ $file_param_name ]["type"];
$userfilename = $_FILES[ $file_param_name ]["name"];
$lastDotIndex = strrpos(basename($userfilename), ".");
if (is_bool($lastDotIndex) && !$lastDotIndex)
$fileType = ".";
else
$fileType = substr($userfilename, $lastDotIndex);
// 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
$docAccess = $folder->getApproversList();
$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;
}
}
}
$contentResult=$document->addContent($comment, $user, $userfiletmp, basename($userfilename), $fileType, $userfiletype, $reviewers, $approvers);
if (is_bool($contentResult) && !$contentResult) {
echo getMLText("error_occured");
} else {
// Send notification to subscribers.
$document->getNotifyList();
if ($notifier){
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_updated_email");
$message = getMLText("document_updated_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
// if user is not owner send notification to owner
if ($user->getID()!= $document->_ownerID)
$notifier->toIndividual($user, $document->getOwner(), $subject, $message);
}
$expires = ($_POST["expires"] == "true") ? mktime(0,0,0, $_POST["expmonth"], $_POST["expday"], $_POST["expyear"]) : false;
if ($document->setExpires($expires)) {
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
// Send notification to subscribers.
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("expiry_changed_email");
$message = getMLText("expiry_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
} else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
add_log_line("?documentid=".$documentid);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
}
}
?>

BIN
out/jl_core_z.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,70 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
//
// 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.Utils.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
$folderid = $_GET["folderid"];
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
$folderPathHTML = getFolderPathHTML($folder, true);
if ($folder->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
UI::htmlStartPage(getMLText("folder_title", array("foldername" => $folder->getName())));
UI::globalNavigation($folder);
UI::pageNavigation($folderPathHTML, "view_folder", $folder);
?>
<script language="JavaScript">
var openDlg;
function chooseKeywords(target) {
openDlg = open("out.KeywordChooser.php?target="+target, "openDlg", "width=500,height=400,scrollbars=yes,resizable=yes");
}
function chooseCategory(form, cats) {
openDlg = open("out.CategoryChooser.php?form="+form+"&cats="+cats, "openDlg", "width=480,height=480,scrollbars=yes,resizable=yes,status=yes");
}
</script>
<?php
UI::contentHeading(getMLText("add_document"));
UI::contentContainerStart();
// Retrieve a list of all users and groups that have review / approve
// privileges.
$docAccess = $folder->getApproversList();
UI::printUploadApplet('../op/op.AddMultiDocument.php', array('folderid'=>$folderid));
UI::contentContainerEnd();
UI::htmlEndPage();
?>

View File

@ -0,0 +1,85 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
// Copyright (C) 2011 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.Utils.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
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"));
}
$documentid = $_GET["documentid"];
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$folder = $document->getFolder();
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
if ($document->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
}
UI::htmlStartPage(getMLText("document_title", array("documentname" => $document->getName())));
UI::globalNavigation($folder);
UI::pageNavigation($docPathHTML, "view_document");
UI::contentHeading(getMLText("update_document") . ": " . $document->getName());
UI::contentContainerStart();
if ($document->isLocked()) {
$lockingUser = $document->getLockingUser();
print "<table><tr><td class=\"warning\">";
printMLText("update_locked_msg", array("username" => $lockingUser->getFullName(), "email" => $lockingUser->getEmail()));
if ($lockingUser->getID() == $user->getID())
printMLText("unlock_cause_locking_user");
else if ($document->getAccessMode($user) == M_ALL)
printMLText("unlock_cause_access_mode_all");
else
{
printMLText("no_update_cause_locked");
print "</td></tr></table>";
UI::contentContainerEnd();
UI::htmlEndPage();
exit;
}
print "</td></tr></table><br>";
}
// Retrieve a list of all users and groups that have review / approve
// privileges.
$docAccess = $document->getApproversList();
UI::printUploadApplet('../op/op.UpdateDocument2.php', array('folderid'=>$folder->getId(), 'documentid'=>$document->getId()), 1, array('version_comment'=>1));
UI::contentContainerEnd();
UI::htmlEndPage();
?>