mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
0b22b8d657
|
@ -52,7 +52,7 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
|
||||||
$expires = $this->params['expires'];
|
$expires = $this->params['expires'];
|
||||||
$oldexpires = $document->getExpires();
|
$oldexpires = $document->getExpires();
|
||||||
if ($expires != $oldexpires) {
|
if ($expires != $oldexpires) {
|
||||||
if(!$this->callHook('preSetExpires', $document, $expires)) {
|
if(false === $this->callHook('preSetExpires', $document, $expires)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$document->setExpires($expires)) {
|
if(!$document->setExpires($expires)) {
|
||||||
|
@ -61,21 +61,21 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
|
||||||
|
|
||||||
$document->verifyLastestContentExpriry();
|
$document->verifyLastestContentExpriry();
|
||||||
|
|
||||||
if(!$this->callHook('postSetExpires', $document, $expires)) {
|
if(false === $this->callHook('postSetExpires', $document, $expires)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$keywords = $this->params['keywords'];
|
$keywords = $this->params['keywords'];
|
||||||
$oldkeywords = $document->getKeywords();
|
$oldkeywords = $document->getKeywords();
|
||||||
if ($oldkeywords != $keywords) {
|
if ($oldkeywords != $keywords) {
|
||||||
if(!$this->callHook('preSetKeywords', $document, $keywords, $oldkeywords)) {
|
if(false === $this->callHook('preSetKeywords', $document, $keywords, $oldkeywords)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$document->setKeywords($keywords)) {
|
if(!$document->setKeywords($keywords)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postSetKeywords', $document, $keywords, $oldkeywords)) {
|
if(false === $this->callHook('postSetKeywords', $document, $keywords, $oldkeywords)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,21 +95,21 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
|
||||||
|
|
||||||
if (count($categoriesarr) != count($oldcategories) ||
|
if (count($categoriesarr) != count($oldcategories) ||
|
||||||
array_diff($categories, $oldcatsids)) {
|
array_diff($categories, $oldcatsids)) {
|
||||||
if(!$this->callHook('preSetCategories', $document, $categoriesarr, $oldcategories)) {
|
if(false === $this->callHook('preSetCategories', $document, $categoriesarr, $oldcategories)) {
|
||||||
}
|
}
|
||||||
if(!$document->setCategories($categoriesarr)) {
|
if(!$document->setCategories($categoriesarr)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!$this->callHook('postSetCategories', $document, $categoriesarr, $oldcategories)) {
|
if(false === $this->callHook('postSetCategories', $document, $categoriesarr, $oldcategories)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif($oldcategories) {
|
} elseif($oldcategories) {
|
||||||
if(!$this->callHook('preSetCategories', $document, array(), $oldcategories)) {
|
if(false === $this->callHook('preSetCategories', $document, array(), $oldcategories)) {
|
||||||
}
|
}
|
||||||
if(!$document->setCategories(array())) {
|
if(!$document->setCategories(array())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!$this->callHook('postSetCategories', $document, array(), $oldcategories)) {
|
if(false === $this->callHook('postSetCategories', $document, array(), $oldcategories)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postEditDocument')) {
|
if(false === $this->callHook('postEditDocument')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -108,7 +108,7 @@ class SeedDMS_Controller_EditFolder extends SeedDMS_Controller_Common {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postEditFolder')) {
|
if(false === $this->callHook('postEditFolder')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -68,7 +68,7 @@ class SeedDMS_Controller_EmptyFolder extends SeedDMS_Controller_Common {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postEmptyFolder')) {
|
if(false === $this->callHook('postEmptyFolder')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -68,7 +68,7 @@ class SeedDMS_Controller_RemoveDocument extends SeedDMS_Controller_Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postRemoveDocument')) {
|
if(false === $this->callHook('postRemoveDocument')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -91,7 +91,7 @@ class SeedDMS_Controller_RemoveFolder extends SeedDMS_Controller_Common {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postRemoveFolder')) {
|
if(false === $this->callHook('postRemoveFolder')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SeedDMS_Controller_TransferDocument extends SeedDMS_Controller_Common {
|
||||||
if (!$document->transferToUser($newuser)) {
|
if (!$document->transferToUser($newuser)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if(!$this->callHook('postTransferDocument')) {
|
if(false === $this->callHook('postTransferDocument')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->callHook('postUpdateDocument', $document, $content)) {
|
if(false === $this->callHook('postUpdateDocument', $document, $content)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|
|
@ -158,6 +158,5 @@ if($settings->_enable2FactorAuthentication && $settings->_guestID != $user->getI
|
||||||
/* Update cookie lifetime */
|
/* Update cookie lifetime */
|
||||||
if($settings->_cookieLifetime) {
|
if($settings->_cookieLifetime) {
|
||||||
$lifetime = time() + intval($settings->_cookieLifetime);
|
$lifetime = time() + intval($settings->_cookieLifetime);
|
||||||
/* Turn off http only cookies if jumploader is enabled */
|
setcookie("mydms_session", $dms_session, $lifetime, $settings->_httpRoot, null, false, true);
|
||||||
setcookie("mydms_session", $dms_session, $lifetime, $settings->_httpRoot, null, null, !$settings->_enableLargeFileUpload);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,7 @@ class SeedDMS_Controller_Common {
|
||||||
*/
|
*/
|
||||||
function callHook($hook) { /* {{{ */
|
function callHook($hook) { /* {{{ */
|
||||||
$tmps = $this->getHookClassNames();
|
$tmps = $this->getHookClassNames();
|
||||||
|
$ret = null;
|
||||||
foreach($tmps as $tmp)
|
foreach($tmps as $tmp)
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) {
|
||||||
$this->lasthookresult = null;
|
$this->lasthookresult = null;
|
||||||
|
@ -238,29 +239,35 @@ class SeedDMS_Controller_Common {
|
||||||
if (method_exists($hookObj, $hook)) {
|
if (method_exists($hookObj, $hook)) {
|
||||||
switch(func_num_args()) {
|
switch(func_num_args()) {
|
||||||
case 4:
|
case 4:
|
||||||
$result = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2), func_get_arg(3));
|
$tmpret = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2), func_get_arg(3));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$result = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2));
|
$tmpret = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$result = $hookObj->$hook($this, func_get_arg(1));
|
$tmpret = $hookObj->$hook($this, func_get_arg(1));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
default:
|
default:
|
||||||
$result = $hookObj->$hook($this);
|
$tmpret = $hookObj->$hook($this);
|
||||||
}
|
}
|
||||||
if($result === false) {
|
if($tmpret === false) {
|
||||||
return $result;
|
return $tmpret;
|
||||||
}
|
}
|
||||||
if($result !== null) {
|
if($tmpret !== null) {
|
||||||
$this->lasthookresult = $result;
|
$this->lasthookresult = $tmpret;
|
||||||
|
if(is_string($tmpret)) {
|
||||||
|
$ret = ($ret === null) ? $tmpret : (is_string($ret) ? $ret.$tmpret : array_merge($ret, array($tmpret)));
|
||||||
|
} elseif(is_array($tmpret)) { // || is_object($tmpret)) {
|
||||||
|
$ret = ($ret === null) ? $tmpret : (is_string($ret) ? array_merge(array($ret), $tmpret) : array_merge($ret, $tmpret));
|
||||||
|
} else
|
||||||
|
$ret = $tmpret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->lasthookresult;
|
// return $this->lasthookresult;
|
||||||
}
|
}
|
||||||
return null;
|
return $ret;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,10 +280,12 @@ class SeedDMS_Controller_Common {
|
||||||
*/
|
*/
|
||||||
function hasHook($hook) { /* {{{ */
|
function hasHook($hook) { /* {{{ */
|
||||||
$tmps = $this->getHookClassNames();
|
$tmps = $this->getHookClassNames();
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])])) {
|
foreach($tmps as $tmp) {
|
||||||
foreach($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])] as $hookObj) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) {
|
||||||
if (method_exists($hookObj, $hook)) {
|
foreach($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)] as $hookObj) {
|
||||||
return true;
|
if (method_exists($hookObj, $hook)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,25 +291,43 @@ if (isset($_POST["grpIndRecipients"])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$docsource = 'upload';
|
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 ($_FILES['userfile']) {
|
||||||
|
$file_ary = reArrayFiles($_FILES['userfile']);
|
||||||
|
} else {
|
||||||
|
$file_ary = array();
|
||||||
|
}
|
||||||
|
|
||||||
if($settings->_dropFolderDir) {
|
if($settings->_dropFolderDir) {
|
||||||
if(isset($_POST["dropfolderfileadddocform"]) && $_POST["dropfolderfileadddocform"]) {
|
if(isset($_POST["dropfolderfileadddocform"]) && $_POST["dropfolderfileadddocform"]) {
|
||||||
$fullfile = $settings->_dropFolderDir.'/'.$user->getLogin().'/'.$_POST["dropfolderfileadddocform"];
|
$fullfile = $settings->_dropFolderDir.'/'.$user->getLogin().'/'.$_POST["dropfolderfileadddocform"];
|
||||||
if(file_exists($fullfile)) {
|
if(file_exists($fullfile)) {
|
||||||
$docsource = 'dropfolder';
|
|
||||||
/* Check if a local file is uploaded as well */
|
|
||||||
if(isset($_FILES["userfile"]['error'][0])) {
|
|
||||||
if($_FILES["userfile"]['error'][0] != 0)
|
|
||||||
$_FILES["userfile"] = array();
|
|
||||||
}
|
|
||||||
$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'][] = $_POST["dropfolderfileadddocform"];
|
'type' => $mimetype,
|
||||||
$_FILES["userfile"]['size'][] = filesize($fullfile);
|
'name' => $_POST["dropfolderfileadddocform"],
|
||||||
$_FILES["userfile"]['error'][] = 0;
|
'size' => filesize($fullfile),
|
||||||
|
'error' => 0,
|
||||||
|
'source' => 'dropfolder'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,11 +341,14 @@ 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',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,21 +360,26 @@ if($settings->_libraryFolder) {
|
||||||
$docsource = 'library';
|
$docsource = 'library';
|
||||||
$fullfile = tempnam(sys_get_temp_dir(), '');
|
$fullfile = tempnam(sys_get_temp_dir(), '');
|
||||||
if(SeedDMS_Core_File::copyFile($dms->contentDir . $content->getPath(), $fullfile)) {
|
if(SeedDMS_Core_File::copyFile($dms->contentDir . $content->getPath(), $fullfile)) {
|
||||||
/* Check if a local file is uploaded as well */
|
$file_ary[] = array(
|
||||||
if(isset($_FILES["userfile"]['error'][0])) {
|
'tmp_name' => $fullfile,
|
||||||
if($_FILES["userfile"]['error'][0] != 0)
|
'type' => $content->getMimeType(),
|
||||||
$_FILES["userfile"] = array();
|
'name' => $content->getOriginalFileName(),
|
||||||
}
|
'size' => $content->getFileSize(),
|
||||||
$_FILES["userfile"]['tmp_name'][] = $fullfile;
|
'error' => 0,
|
||||||
$_FILES["userfile"]['type'][] = $content->getMimeType();
|
'source' => 'library',
|
||||||
$_FILES["userfile"]['name'][] = $content->getOriginalFileName();
|
);
|
||||||
$_FILES["userfile"]['size'][] = $content->getFileSize();
|
|
||||||
$_FILES["userfile"]['error'][] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($controller->hasHook('getDocument')) {
|
||||||
|
$file_ary = array_merge($file_ary, $controller->callHook('getDocument', $_POST));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$file_ary) {
|
||||||
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if additional notification shall be added */
|
/* Check if additional notification shall be added */
|
||||||
$notusers = array();
|
$notusers = array();
|
||||||
|
@ -377,22 +403,22 @@ if(!empty($_POST['notification_groups'])) {
|
||||||
|
|
||||||
/* Check files for Errors first */
|
/* Check files for Errors first */
|
||||||
$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["size"]==0) {
|
||||||
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_zerosize"));
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_zerosize"));
|
||||||
}
|
}
|
||||||
if ($maxuploadsize && $_FILES["userfile"]["size"][$file_num] > $maxuploadsize) {
|
if ($maxuploadsize && $file["size"] > $maxuploadsize) {
|
||||||
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_maxsize"));
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_maxsize"));
|
||||||
}
|
}
|
||||||
if (/* is_uploaded_file($_FILES["userfile"]["tmp_name"][$file_num]) && */$_FILES['userfile']['error'][$file_num]!=0){
|
if($file['error']!=0) {
|
||||||
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
foreach($file_ary as $file) {
|
||||||
$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);
|
||||||
|
|
||||||
|
@ -403,7 +429,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
||||||
$userfiletype = $tmpfiletype;
|
$userfiletype = $tmpfiletype;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((count($_FILES["userfile"]["tmp_name"])==1)&&($_POST["name"]!=""))
|
if (!$file["tmp_name"] && ($_POST["name"]!=""))
|
||||||
$name = trim($_POST["name"]);
|
$name = trim($_POST["name"]);
|
||||||
else $name = utf8_basename($userfilename);
|
else $name = utf8_basename($userfilename);
|
||||||
|
|
||||||
|
@ -414,7 +440,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller->setParam('documentsource', $docsource);
|
$controller->setParam('documentsource', $file['source']);
|
||||||
$controller->setParam('folder', $folder);
|
$controller->setParam('folder', $folder);
|
||||||
$controller->setParam('fulltextservice', $fulltextservice);
|
$controller->setParam('fulltextservice', $fulltextservice);
|
||||||
$controller->setParam('name', $name);
|
$controller->setParam('name', $name);
|
||||||
|
|
|
@ -71,6 +71,38 @@ if ($document->isLocked()) {
|
||||||
else $document->setLocked(false);
|
else $document->setLocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reArrayFiles(&$file_post) {
|
||||||
|
$file_post['source'] = 'upload';
|
||||||
|
if($file_post['error'] != 4) // no file uploaded
|
||||||
|
return array($file_post);
|
||||||
|
else
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_FILES['userfile']) {
|
||||||
|
$file_ary = reArrayFiles($_FILES['userfile']);
|
||||||
|
} else {
|
||||||
|
$file_ary = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($settings->_dropFolderDir) {
|
||||||
|
if(isset($_POST["dropfolderfileform1"]) && $_POST["dropfolderfileform1"]) {
|
||||||
|
$fullfile = $settings->_dropFolderDir.'/'.$user->getLogin().'/'.$_POST["dropfolderfileform1"];
|
||||||
|
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["dropfolderfileform1"],
|
||||||
|
'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']);
|
||||||
|
@ -80,29 +112,38 @@ 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[0]) ? $names[0] : $uuid;
|
'type' => $mimetype,
|
||||||
$_FILES["userfile"]['size'] = filesize($fullfile);
|
'name' => isset($names[0]) ? $names[0] : $uuid,
|
||||||
$_FILES["userfile"]['error'] = 0;
|
'size' => filesize($fullfile),
|
||||||
|
'error' => 0,
|
||||||
|
'source' => 'upload',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] == 0) {
|
if($controller->hasHook('getDocument')) {
|
||||||
// if(!is_uploaded_file($_FILES["userfile"]["tmp_name"]))
|
$file_ary = array_merge($file_ary, $controller->callHook('getDocument', $_POST));
|
||||||
// UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")."lsajdflk");
|
}
|
||||||
|
|
||||||
if($_FILES["userfile"]["size"] == 0)
|
if(!$file_ary) {
|
||||||
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $file_ary[0];
|
||||||
|
if ($file['error'] == 0) {
|
||||||
|
if ($file["size"]==0) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
||||||
|
}
|
||||||
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
||||||
if ($maxuploadsize && $_FILES["userfile"]["size"] > $maxuploadsize) {
|
if ($maxuploadsize && $file["size"] > $maxuploadsize) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$userfiletmp = $_FILES["userfile"]["tmp_name"];
|
$userfiletmp = $file["tmp_name"];
|
||||||
$userfiletype = $_FILES["userfile"]["type"];
|
$userfiletype = $file["type"];
|
||||||
$userfilename = $_FILES["userfile"]["name"];
|
$userfilename = $file["name"];
|
||||||
|
|
||||||
if($settings->_overrideMimeType) {
|
if($settings->_overrideMimeType) {
|
||||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||||
|
@ -110,32 +151,15 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] == 0) {
|
||||||
if($tmpfiletype != 'application/octet-stream')
|
if($tmpfiletype != 'application/octet-stream')
|
||||||
$userfiletype = $tmpfiletype;
|
$userfiletype = $tmpfiletype;
|
||||||
}
|
}
|
||||||
} elseif($settings->_dropFolderDir) {
|
|
||||||
if($_POST['dropfolderfileform1']) {
|
|
||||||
$fullfile = $settings->_dropFolderDir.'/'.$user->getLogin().'/'.$_POST["dropfolderfileform1"];
|
|
||||||
if(file_exists($fullfile)) {
|
|
||||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
|
||||||
$mimetype = finfo_file($finfo, $fullfile);
|
|
||||||
$userfiletmp = $fullfile;
|
|
||||||
$userfiletype = $mimetype;
|
|
||||||
$userfilename= $_POST["dropfolderfileform1"];
|
|
||||||
} else {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_failed"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the uploaded file is identical to last version */
|
/* Check if the uploaded file is identical to last version */
|
||||||
$lc = $document->getLatestContent();
|
$lc = $document->getLatestContent();
|
||||||
if($lc->getChecksum() == SeedDMS_Core_File::checksum($userfiletmp)) {
|
if($lc->getChecksum() == SeedDMS_Core_File::checksum($userfiletmp)) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("identical_version"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("identical_version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
if(isset($_POST["comment"]))
|
if(isset($_POST["comment"]))
|
||||||
$comment = $_POST["comment"];
|
$comment = $_POST["comment"];
|
||||||
|
|
|
@ -64,9 +64,11 @@ $(document).ready(function() {
|
||||||
/* The fineuploader validation is actually checking all fields that can contain
|
/* The fineuploader validation is actually checking all fields that can contain
|
||||||
* a file to be uploaded. First checks if an alternative input field is set,
|
* a file to be uploaded. First checks if an alternative input field is set,
|
||||||
* second loops through the list of scheduled uploads, checking if at least one
|
* second loops through the list of scheduled uploads, checking if at least one
|
||||||
* file will be submitted.
|
* file will be submitted. param[0] is the fineuploader, param[1] is the
|
||||||
|
* field from the dropfolder
|
||||||
*/
|
*/
|
||||||
jQuery.validator.addMethod("fineuploader", function(value, element, params) {
|
jQuery.validator.addMethod("fineuploader", function(value, element, params) {
|
||||||
|
console.log(params);
|
||||||
if(params[1].val() != '')
|
if(params[1].val() != '')
|
||||||
return true;
|
return true;
|
||||||
uploader = params[0];
|
uploader = params[0];
|
||||||
|
@ -104,10 +106,12 @@ $(document).ready(function() {
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
'userfile[]': {
|
'userfile[]': {
|
||||||
alternatives: [$('#dropfolderfileadddocform'), $('#choosedocsearch<?= md5('librarydoc'.'adddocform') ?>')]
|
require_from_group: [1, ".fileupload-group"]
|
||||||
|
// alternatives: [$('#dropfolderfileadddocform'), $('#choosedocsearch<?= md5('librarydoc'.'adddocform') ?>')]
|
||||||
},
|
},
|
||||||
dropfolderfileadddocform: {
|
dropfolderfileadddocform: {
|
||||||
alternatives: [$("#userfile"), $('#choosedocsearch<?= md5('librarydoc'.'adddocform') ?>')]
|
require_from_group: [1, ".fileupload-group"]
|
||||||
|
// alternatives: [$("#userfile"), $('#choosedocsearch<?= md5('librarydoc'.'adddocform') ?>')]
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -170,6 +174,7 @@ $(document).ready(function() {
|
||||||
$accessop = $this->params['accessobject'];
|
$accessop = $this->params['accessobject'];
|
||||||
|
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/additional-methods.js"></script>'."\n", 'js');
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
|
||||||
if($enablelargefileupload) {
|
if($enablelargefileupload) {
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/fine-uploader/jquery.fine-uploader.min.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/fine-uploader/jquery.fine-uploader.min.js"></script>'."\n", 'js');
|
||||||
|
@ -412,6 +417,13 @@ $(document).ready(function() {
|
||||||
$this->getDocumentChooserHtml("adddocform", M_READ, -1, null, 'librarydoc', $libraryfolder, 1)
|
$this->getDocumentChooserHtml("adddocform", M_READ, -1, null, 'librarydoc', $libraryfolder, 1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if($arr = $this->callHook('addDocumentContentFile')) {
|
||||||
|
if(is_array($arr)) {
|
||||||
|
$this->formField($arr[0], $arr[1], isset($arr[2]) ? $arr[2] : null);
|
||||||
|
} elseif(is_string($arr)) {
|
||||||
|
echo $arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!$nodocumentformfields || !in_array('version_comment', $nodocumentformfields)) {
|
if(!$nodocumentformfields || !in_array('version_comment', $nodocumentformfields)) {
|
||||||
$this->formField(
|
$this->formField(
|
||||||
getMLText("comment_for_current_version"),
|
getMLText("comment_for_current_version"),
|
||||||
|
|
|
@ -1497,7 +1497,7 @@ $(document).ready(function() {
|
||||||
<div id="'.$id.'-upload-files">
|
<div id="'.$id.'-upload-files">
|
||||||
<div id="'.$id.'-upload-file" class="upload-file">
|
<div id="'.$id.'-upload-file" class="upload-file">
|
||||||
<div class="input-append">
|
<div class="input-append">
|
||||||
<input type="text" class="form-control" id="kkll'.$id.'" readonly>
|
<input type="text" class="form-control fileupload-group" id="kkll'.$id.'" readonly>
|
||||||
<span class="btn btn-secondary btn-file">
|
<span class="btn btn-secondary btn-file">
|
||||||
'.getMLText("browse").'… <input id="'.$id.'" type="file" name="'.$varname.'"'.($multiple ? " multiple" : "").($accept ? ' accept="'.$accept.'"' : "").' data-target-highlight="kkll'.$id.'">
|
'.getMLText("browse").'… <input id="'.$id.'" type="file" name="'.$varname.'"'.($multiple ? " multiple" : "").($accept ? ' accept="'.$accept.'"' : "").' data-target-highlight="kkll'.$id.'">
|
||||||
</span>
|
</span>
|
||||||
|
@ -2000,7 +2000,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function getDropFolderChooserHtml($formName, $dropfolderfile="", $showfolders=0) { /* {{{ */
|
function getDropFolderChooserHtml($formName, $dropfolderfile="", $showfolders=0) { /* {{{ */
|
||||||
$content = "<div class=\"input-append\">\n";
|
$content = "<div class=\"input-append\">\n";
|
||||||
$content .= "<input readonly type=\"text\" id=\"dropfolderfile".$formName."\" name=\"dropfolderfile".$formName."\" value=\"".htmlspecialchars($dropfolderfile)."\">";
|
$content .= "<input readonly type=\"text\" class=\"fileupload-group\" id=\"dropfolderfile".$formName."\" name=\"dropfolderfile".$formName."\" value=\"".htmlspecialchars($dropfolderfile)."\">";
|
||||||
$content .= "<button type=\"button\" class=\"btn\" id=\"clearfilename".$formName."\"><i class=\"fa fa-remove\"></i></button>";
|
$content .= "<button type=\"button\" class=\"btn\" id=\"clearfilename".$formName."\"><i class=\"fa fa-remove\"></i></button>";
|
||||||
$content .= $this->getModalBoxLink(
|
$content .= $this->getModalBoxLink(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Implementation of CategoryChooser view
|
* Implementation of DropFolderChooser view
|
||||||
*
|
*
|
||||||
* @category DMS
|
* @category DMS
|
||||||
* @package SeedDMS
|
* @package SeedDMS
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
require_once("SeedDMS/Preview.php");
|
require_once("SeedDMS/Preview.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which outputs the html page for CategoryChooser view
|
* Class which outputs the html page for DropFolderChooser view
|
||||||
*
|
*
|
||||||
* @category DMS
|
* @category DMS
|
||||||
* @package SeedDMS
|
* @package SeedDMS
|
||||||
|
@ -158,7 +158,7 @@ $('.folderselect').click(function(ev) {
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
echo '<script src="../out/out.DropFolderChooser.php?action=js&'.$_SERVER['QUERY_STRING'].'"></script>'."\n";
|
echo '<script src="../out/out.DropFolderChooser.php?action=js&'.$_SERVER['QUERY_STRING'].'"></script>'."\n";
|
||||||
} else {
|
} else {
|
||||||
echo "<div class=\"alert alert-danger\">".getMLText('invalid_dropfolder_folder')."</div>";
|
echo $this->errorMsg(getMLText('invalid_dropfolder_folder'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
|
@ -96,10 +96,12 @@ $(document).ready( function() {
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
userfile: {
|
userfile: {
|
||||||
alternatives: $('#dropfolderfileform1')
|
require_from_group: [1, ".fileupload-group"]
|
||||||
|
// alternatives: $('#dropfolderfileform1')
|
||||||
},
|
},
|
||||||
dropfolderfileform1: {
|
dropfolderfileform1: {
|
||||||
alternatives: $('#userfile')
|
require_from_group: [1, ".fileupload-group"]
|
||||||
|
// alternatives: $('#userfile')
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -147,6 +149,7 @@ console.log(element);
|
||||||
$documentid = $document->getId();
|
$documentid = $document->getId();
|
||||||
|
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/additional-methods.js"></script>'."\n", 'js');
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
|
||||||
if($enablelargefileupload) {
|
if($enablelargefileupload) {
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/fine-uploader/jquery.fine-uploader.min.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/fine-uploader/jquery.fine-uploader.min.js"></script>'."\n", 'js');
|
||||||
|
@ -238,6 +241,13 @@ console.log(element);
|
||||||
$this->getDropFolderChooserHtml("form1")
|
$this->getDropFolderChooserHtml("form1")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if($arr = $this->callHook('addDocumentContentFile')) {
|
||||||
|
if(is_array($arr)) {
|
||||||
|
$this->formField($arr[0], $arr[1], isset($arr[2]) ? $arr[2] : null);
|
||||||
|
} elseif(is_string($arr)) {
|
||||||
|
echo $arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!$nodocumentformfields || !in_array('version_comment', $nodocumentformfields)) {
|
if(!$nodocumentformfields || !in_array('version_comment', $nodocumentformfields)) {
|
||||||
$this->formField(
|
$this->formField(
|
||||||
getMLText("comment"),
|
getMLText("comment"),
|
||||||
|
|
|
@ -1436,7 +1436,7 @@ $(document).ready(function() {
|
||||||
<div id="'.$id.'-upload-files">
|
<div id="'.$id.'-upload-files">
|
||||||
<div id="'.$id.'-upload-file" class="upload-file">
|
<div id="'.$id.'-upload-file" class="upload-file">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control" id="kkll'.$id.'" readonly>
|
<input type="text" class="form-control fileupload-group" id="kkll'.$id.'" readonly>
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-secondary btn-file">
|
<button class="btn btn-secondary btn-file">
|
||||||
'.getMLText("browse").'… <input id="'.$id.'" type="file" name="'.$varname.'"'.($multiple ? " multiple" : "").($accept ? ' accept="'.$accept.'"' : "").' data-target-highlight="kkll'.$id.'">
|
'.getMLText("browse").'… <input id="'.$id.'" type="file" name="'.$varname.'"'.($multiple ? " multiple" : "").($accept ? ' accept="'.$accept.'"' : "").' data-target-highlight="kkll'.$id.'">
|
||||||
|
@ -1960,7 +1960,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function getDropFolderChooserHtml($formName, $dropfolderfile="", $showfolders=0) { /* {{{ */
|
function getDropFolderChooserHtml($formName, $dropfolderfile="", $showfolders=0) { /* {{{ */
|
||||||
$content = "<div class=\"input-group\">\n";
|
$content = "<div class=\"input-group\">\n";
|
||||||
$content .= "<input class=\"form-control\" readonly type=\"text\" id=\"dropfolderfile".$formName."\" name=\"dropfolderfile".$formName."\" value=\"".htmlspecialchars($dropfolderfile)."\">";
|
$content .= "<input class=\"form-control fileupload-group\" readonly type=\"text\" id=\"dropfolderfile".$formName."\" name=\"dropfolderfile".$formName."\" value=\"".htmlspecialchars($dropfolderfile)."\">";
|
||||||
$content .= '<div class="input-group-append">';
|
$content .= '<div class="input-group-append">';
|
||||||
$content .= "<button type=\"button\" class=\"btn btn-secondary\" id=\"clearfilename".$formName."\"><i class=\"fa fa-remove\"></i></button>";
|
$content .= "<button type=\"button\" class=\"btn btn-secondary\" id=\"clearfilename".$formName."\"><i class=\"fa fa-remove\"></i></button>";
|
||||||
$content .= $this->getModalBoxLink(
|
$content .= $this->getModalBoxLink(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user