mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 13:06:14 +00:00
add attachment from dropfolder dir
This commit is contained in:
parent
774d17c3f9
commit
755f601d7b
|
@ -51,6 +51,47 @@ if ($document->getAccessMode($user, 'addDocumentFile') < M_READWRITE) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reArrayFiles(&$file_post) {
|
||||||
|
$file_ary = array();
|
||||||
|
$file_count = count($file_post['name']);
|
||||||
|
$file_keys = array_keys($file_post);
|
||||||
|
|
||||||
|
for ($i=0; $i<$file_count; $i++) {
|
||||||
|
if($file_post['error'][$i] != 4) { // no file uploaded
|
||||||
|
foreach ($file_keys as $key) {
|
||||||
|
$file_ary[$i][$key] = $file_post[$key][$i];
|
||||||
|
}
|
||||||
|
$file_ary[$i]['source'] = 'upload';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file_ary;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($_FILES['userfile'])) {
|
||||||
|
$file_ary = reArrayFiles($_FILES['userfile']);
|
||||||
|
} else {
|
||||||
|
$file_ary = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($settings->_dropFolderDir) {
|
||||||
|
if(isset($_POST["dropfolderfileaddfileform"]) && $_POST["dropfolderfileaddfileform"]) {
|
||||||
|
$fullfile = $settings->_dropFolderDir.'/'.$user->getLogin().'/'.$_POST["dropfolderfileaddfileform"];
|
||||||
|
if(file_exists($fullfile)) {
|
||||||
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||||
|
$mimetype = finfo_file($finfo, $fullfile);
|
||||||
|
$file_ary[] = array(
|
||||||
|
'tmp_name' => $fullfile,
|
||||||
|
'type' => $mimetype,
|
||||||
|
'name' => $_POST["dropfolderfileaddfileform"],
|
||||||
|
'size' => filesize($fullfile),
|
||||||
|
'error' => 0,
|
||||||
|
'source' => 'dropfolder'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$prefix = 'userfile';
|
$prefix = 'userfile';
|
||||||
if(isset($_POST[$prefix.'-fine-uploader-uuids']) && $_POST[$prefix.'-fine-uploader-uuids']) {
|
if(isset($_POST[$prefix.'-fine-uploader-uuids']) && $_POST[$prefix.'-fine-uploader-uuids']) {
|
||||||
$uuids = explode(';', $_POST[$prefix.'-fine-uploader-uuids']);
|
$uuids = explode(';', $_POST[$prefix.'-fine-uploader-uuids']);
|
||||||
|
@ -60,34 +101,43 @@ if(isset($_POST[$prefix.'-fine-uploader-uuids']) && $_POST[$prefix.'-fine-upload
|
||||||
if(file_exists($fullfile)) {
|
if(file_exists($fullfile)) {
|
||||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||||
$mimetype = finfo_file($finfo, $fullfile);
|
$mimetype = finfo_file($finfo, $fullfile);
|
||||||
$_FILES["userfile"]['tmp_name'][] = $fullfile;
|
$file_ary[] = array(
|
||||||
$_FILES["userfile"]['type'][] = $mimetype;
|
'tmp_name' => $fullfile,
|
||||||
$_FILES["userfile"]['name'][] = isset($names[$i]) ? $names[$i] : $uuid;
|
'type' => $mimetype,
|
||||||
$_FILES["userfile"]['size'][] = filesize($fullfile);
|
'name' => isset($names[$i]) ? $names[$i] : $uuid,
|
||||||
$_FILES["userfile"]['error'][] = 0;
|
'size' => filesize($fullfile),
|
||||||
|
'error' => 0,
|
||||||
|
'source' => 'upload',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$file_ary) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_failed"));
|
||||||
|
}
|
||||||
|
|
||||||
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
||||||
for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
foreach($file_ary as $file) {
|
||||||
if ($_FILES["userfile"]["size"][$file_num]==0) {
|
if($file['error']==1) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize"));
|
||||||
}
|
}
|
||||||
if ($maxuploadsize && $_FILES["userfile"]["size"][$file_num] > $maxuploadsize) {
|
if($file['error']!=0) {
|
||||||
UI::exitError(getMLText("folder_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize"));
|
|
||||||
}
|
|
||||||
if (is_uploaded_file($_FILES["userfile"]["tmp_name"][$file_num]) && $_FILES['userfile']['error'][$file_num] != 0){
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_failed"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_failed"));
|
||||||
}
|
}
|
||||||
if($_FILES["userfile"]["error"][$file_num]) {
|
if ($file["size"]==0) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
||||||
}
|
}
|
||||||
|
if ($maxuploadsize && $file["size"] > $maxuploadsize) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(count($_FILES["userfile"]["tmp_name"]) == 1 && !empty($_POST['name']))
|
foreach($file_ary as $file) {
|
||||||
|
if(count($file_ary) == 1 && !empty($_POST['name']))
|
||||||
$name = $_POST["name"];
|
$name = $_POST["name"];
|
||||||
else
|
else
|
||||||
$name = $_FILES["userfile"]['name'][$file_num];
|
$name = $file['name'];
|
||||||
$comment = $_POST["comment"];
|
$comment = $_POST["comment"];
|
||||||
$version = (int) $_POST["version"];
|
$version = (int) $_POST["version"];
|
||||||
$public = (isset($_POST["public"]) && $_POST["public"] == 'true') ? 1 : 0;
|
$public = (isset($_POST["public"]) && $_POST["public"] == 'true') ? 1 : 0;
|
||||||
|
@ -99,9 +149,9 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$userfiletmp = $_FILES["userfile"]["tmp_name"][$file_num];
|
$userfiletmp = $file["tmp_name"];
|
||||||
$userfiletype = $_FILES["userfile"]["type"][$file_num];
|
$userfiletype = $file["type"];
|
||||||
$userfilename = $_FILES["userfile"]["name"][$file_num];
|
$userfilename = $file["name"];
|
||||||
|
|
||||||
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,16 @@ class SeedDMS_View_AddFile extends SeedDMS_Theme_Style {
|
||||||
$enablelargefileupload = $this->params['enablelargefileupload'];
|
$enablelargefileupload = $this->params['enablelargefileupload'];
|
||||||
$partitionsize = $this->params['partitionsize'];
|
$partitionsize = $this->params['partitionsize'];
|
||||||
$maxuploadsize = $this->params['maxuploadsize'];
|
$maxuploadsize = $this->params['maxuploadsize'];
|
||||||
|
$dropfolderdir = $this->params['dropfolderdir'];
|
||||||
|
|
||||||
header('Content-Type: application/javascript; charset=UTF-8');
|
header('Content-Type: application/javascript; charset=UTF-8');
|
||||||
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
|
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
|
||||||
if($enablelargefileupload)
|
if($enablelargefileupload)
|
||||||
$this->printFineUploaderJs($this->params['settings']->_httpRoot.'op/op.UploadChunks.php', $partitionsize, $maxuploadsize);
|
$this->printFineUploaderJs($this->params['settings']->_httpRoot.'op/op.UploadChunks.php', $partitionsize, $maxuploadsize);
|
||||||
|
|
||||||
|
if($dropfolderdir) {
|
||||||
|
$this->printDropFolderChooserJs("addfileform");
|
||||||
|
}
|
||||||
$this->printFileChooserJs();
|
$this->printFileChooserJs();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -58,14 +63,18 @@ $(document).ready( function() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}, "<?php printMLText("js_no_file");?>");
|
}, "<?php printMLText("js_no_file");?>");
|
||||||
$("#form1").validate({
|
$("#addfileform").validate({
|
||||||
debug: false,
|
debug: false,
|
||||||
ignore: ":hidden:not(.do_validate)",
|
ignore: ":hidden:not(.do_validate)",
|
||||||
<?php
|
<?php
|
||||||
if($enablelargefileupload) {
|
if($enablelargefileupload) {
|
||||||
?>
|
?>
|
||||||
submitHandler: function(form) {
|
submitHandler: function(form) {
|
||||||
userfileuploader.uploadStoredFiles();
|
/* fileuploader may not have any files if drop folder is used */
|
||||||
|
if(userfileuploader.getUploads().length)
|
||||||
|
userfileuploader.uploadStoredFiles();
|
||||||
|
else
|
||||||
|
form.submit();
|
||||||
},
|
},
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -74,14 +83,18 @@ $(document).ready( function() {
|
||||||
<?php
|
<?php
|
||||||
if($enablelargefileupload) {
|
if($enablelargefileupload) {
|
||||||
?>
|
?>
|
||||||
fineuploaderuuids: {
|
'userfile-fine-uploader-uuids': {
|
||||||
fineuploader: [ userfileuploader ]
|
fineuploader: [ userfileuploader, $('#dropfolderfileaddfileform') ]
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
'userfile[]': {
|
'userfile[]': {
|
||||||
required: true
|
require_from_group: [1, ".fileupload-group"],
|
||||||
|
maxsize: <?= $maxuploadsize ?>
|
||||||
|
},
|
||||||
|
dropfolderfileaddfileform: {
|
||||||
|
require_from_group: [1, ".fileupload-group"]
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -113,6 +126,7 @@ $(document).ready( function() {
|
||||||
$enablelargefileupload = $this->params['enablelargefileupload'];
|
$enablelargefileupload = $this->params['enablelargefileupload'];
|
||||||
$uploadedattachmentispublic = $this->params['uploadedattachmentispublic'];
|
$uploadedattachmentispublic = $this->params['uploadedattachmentispublic'];
|
||||||
$maxuploadsize = $this->params['maxuploadsize'];
|
$maxuploadsize = $this->params['maxuploadsize'];
|
||||||
|
$dropfolderdir = $this->params['dropfolderdir'];
|
||||||
|
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
|
||||||
|
@ -132,7 +146,7 @@ $(document).ready( function() {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<form class="form-horizontal" action="../op/op.AddFile.php" enctype="multipart/form-data" method="post" name="form1" id="form1">
|
<form class="form-horizontal" action="../op/op.AddFile.php" enctype="multipart/form-data" method="post" name="addfileform" id="addfileform">
|
||||||
<input type="hidden" name="documentid" value="<?php print $document->getId(); ?>">
|
<input type="hidden" name="documentid" value="<?php print $document->getId(); ?>">
|
||||||
<?php
|
<?php
|
||||||
$this->contentContainerStart();
|
$this->contentContainerStart();
|
||||||
|
@ -140,6 +154,12 @@ $(document).ready( function() {
|
||||||
getMLText("local_file"),
|
getMLText("local_file"),
|
||||||
($enablelargefileupload ? $this->getFineUploaderHtml() : $this->getFileChooserHtml('userfile[]', false))
|
($enablelargefileupload ? $this->getFineUploaderHtml() : $this->getFileChooserHtml('userfile[]', false))
|
||||||
);
|
);
|
||||||
|
if($dropfolderdir) {
|
||||||
|
$this->formField(
|
||||||
|
getMLText("dropfolder_file"),
|
||||||
|
$this->getDropFolderChooserHtml("addfileform")
|
||||||
|
);
|
||||||
|
}
|
||||||
$options = array();
|
$options = array();
|
||||||
$options[] = array("", getMLText('document'));
|
$options[] = array("", getMLText('document'));
|
||||||
$versions = $document->getContent();
|
$versions = $document->getContent();
|
||||||
|
@ -198,4 +218,3 @@ $(document).ready( function() {
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user