Merged in bugfix/HOR-4618 (pull request #6502)

HOR-4618

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2018-06-08 14:08:21 +00:00
committed by Julio Cesar Laura Avendaño
2 changed files with 163 additions and 156 deletions

View File

@@ -1438,8 +1438,14 @@ function checkTree($uidOriginFolder, $uidNewFolder)
}
}
/**
* Upload documents
*
* @return void
*/
function uploadExternalDocument()
{
$response = [];
$response['action'] = $_POST['action'] . " - " . $_POST['option'];
$response['error'] = "error";
$response['message'] = "error";
@@ -1451,7 +1457,7 @@ function uploadExternalDocument()
$sw_error = false;
$sw_error_exists = isset($_FILES['uploadedFile']['error']);
$emptyInstances = 0;
$quequeUpload=array();
$quequeUpload = [];
//overwrite files
if ($overwrite) {
for ($i = 0; $i < $uploadedInstances; $i++) {
@@ -1459,6 +1465,7 @@ function uploadExternalDocument()
}
}
// upload files & check for errors
$errors = [];
for ($i = 0; $i < $uploadedInstances; $i++) {
$errors[$i] = null;
$tmp = $_FILES['uploadedFile']['tmp_name'][$i];
@@ -1488,11 +1495,10 @@ function uploadExternalDocument()
continue;
}
//The uplaoded files seems to be correct and ready to be uploaded. Add to the Queque
$fileInfo=array("tempName"=>$tmp,"fileName"=>$items[$i]);
$fileInfo = ["tempName" => $tmp, "fileName" => $items[$i]];
$quequeUpload[] = $fileInfo;
}
} elseif (isset($_POST['selitems'])) {
$response="";
$response['msg'] = "correct reload";
$response['success'] = true;
if (isset($_REQUEST['option']) && isset($_REQUEST['copyMove'])) {
@@ -1503,23 +1509,25 @@ function uploadExternalDocument()
$response['success'] = 'success';
$response['node'] = '';
$_POST ['node'] = "";
$newFolderUid = checkTree($_REQUEST['dir'], ($_REQUEST['new_dir'] == 'root')? '/' : $_REQUEST['new_dir']);
$newFolderUid = checkTree(
$_REQUEST['dir'],
($_REQUEST['new_dir'] == 'root') ? '/' : $_REQUEST['new_dir']
);
}
$_POST['selitems'] = array();
$_POST['selitems'] = [];
} else {
$oAppDocument = new AppDocument();
$appDocument = new AppDocument();
if (isset($_POST['selitems']) && is_array($_POST['selitems'])) {
foreach ($_POST['selitems'] as $docId) {
$arrayDocId = explode('_', $docId);
$docInfo=$oAppDocument->load($arrayDocId[0]);
$docInfo = $appDocument->load($arrayDocId[0]);
$docInfo['FOLDER_UID'] = $_POST['new_dir'];
$docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s');
$oAppDocument->update($docInfo);
$appDocument->update($docInfo);
}
}
}
}
//G::pr($quequeUpload);
//Read. Instance Document classes
if (!empty($quequeUpload)) {
@@ -1544,34 +1552,32 @@ function uploadExternalDocument()
$docType = isset($_POST['docType']) ? $_GET['docType'] : "INPUT";
//save info
$oInputDocument = new InputDocument();
$inputDocument = new InputDocument();
if ($docUid != -1) {
$aID = $oInputDocument->load($docUid);
$aID = $inputDocument->load($docUid);
} else {
$oFolder=new AppFolder();
$folderStructure=$oFolder->getFolderStructure($folderId);
$aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']);
$folder = new AppFolder();
$folderStructure = $folder->getFolderStructure($folderId);
$aID = ['INP_DOC_DESTINATION_PATH' => $folderStructure['PATH']];
}
//Get the Custom Folder ID (create if necessary)
$oFolder=new AppFolder();
$folder = new AppFolder();
if ($docUid != -1) {
//krumo("jhl");
$folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $appId);
$folderId = $folder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $appId);
//Tags
$fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS'], $appId);
$fileTags = $folder->parseTags($aID['INP_DOC_TAGS'], $appId);
} else {
$folderId = $folderId;
$fileTags = "EXTERNAL";
}
foreach ($quequeUpload as $key => $fileObj) {
$oAppDocument = new AppDocument();
$appDocument = new AppDocument();
switch ($actionType) {
case "R":
//replace
$aFields = array(
$fields = [
'APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DOC_VERSION' => $docVersion,
@@ -1586,12 +1592,12 @@ function uploadExternalDocument()
'APP_DOC_FILENAME' => $fileObj['fileName'],
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags
);
$oAppDocument->update($aFields);
];
$appDocument->update($fields);
break;
case "NV":
//New Version
$aFields = array(
$fields = [
'APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DEL_INDEX' => 1,
@@ -1605,12 +1611,12 @@ function uploadExternalDocument()
'APP_DOC_FILENAME' => $fileObj['fileName'],
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags
);
$oAppDocument->create($aFields);
];
$appDocument->create($fields);
break;
default:
//New
$aFields = array(
$fields = [
'APP_UID' => $appId,
'DEL_INDEX' => isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
@@ -1623,38 +1629,36 @@ function uploadExternalDocument()
'APP_DOC_FILENAME' => $fileObj['fileName'],
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags
);
$oAppDocument->create($aFields);
];
$appDocument->create($fields);
break;
}
$sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion();
$appDocUid = $appDocument->getAppDocUid();
$docVersion = $appDocument->getDocVersion();
$info = pathinfo($oAppDocument->getAppDocFilename());
$info = pathinfo($appDocument->getAppDocFilename());
$ext = (isset($info['extension']) ? $info['extension'] : '');
//save the file
//if (!empty($_FILES['form'])) {
//if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP;
$file = G::getPathFromFileUID($appId, $sAppDocUid);
$sPathName .= $file[0];
$sFileName = $file[1] . "_" . $iDocVersion . '.' . $ext;
$pathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP;
$file = G::getPathFromFileUID($appId, $appDocUid);
$pathName .= $file[0];
$sFileName = $file[1] . "_" . $docVersion . '.' . $ext;
G::uploadFile($fileObj['tempName'], $sPathName, $sFileName); //upload
G::uploadFile($fileObj['tempName'], $pathName, $sFileName); //upload
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry = PluginRegistry::loadSingleton();
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
$pluginRegistry = PluginRegistry::loadSingleton();
if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
$oData['APP_UID'] = $appId;
$documentData = new uploadDocumentData(
$appId,
$_SESSION['USER_LOGGED'],
$sPathName . $sFileName,
$pathName . $sFileName,
$fileObj['fileName'],
$sAppDocUid
$appDocUid
);
//$oPluginRegistry->executeTriggers (PM_UPLOAD_DOCUMENT , $documentData);
//unlink ($sPathName . $sFileName);
}
//end plugin
if ($sw_error) {

View File

@@ -24,13 +24,16 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == "verifySession") {
print G::json_encode($response);
die();
} else {
//When the user has session we will to validate the permissions over other actions
/** Action: Reassign from openCase */
global $RBAC;
$proUid = $_SESSION['PROCESS'];
$appUid = $_SESSION['APPLICATION'];
$tasUid = $_SESSION['TASK'];
$proUid = isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : '';
$appUid = isset($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : '';
$tasUid = isset($_SESSION['TASK']) ? $_SESSION['TASK'] : '';
$response = new stdclass();
$userAuthorization = [];
if (!empty($proUid) && !empty($appUid)) {
$cases = new BmCases();
$userAuthorization = $cases->userAuthorization(
$RBAC->aUserInfo['USER_INFO']['USR_UID'],
@@ -49,10 +52,10 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == "verifySession") {
) {
$response->reassigncase = true;
$response->message = '';
} else {
}
}
$response->reassigncase = false;
$response->message = G::LoadTranslation('ID_NOT_ABLE_REASSIGN');
}
print G::json_encode($response);
die();