Skip to content
Snippets Groups Projects
Verified Commit 94cb2169 authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #8402 get docserver_id from attachment himself

parent 3fa5ecf8
No related branches found
No related tags found
No related merge requests found
...@@ -119,7 +119,8 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -119,7 +119,8 @@ if (isset($_POST['add']) && $_POST['add']) {
} else { } else {
//CHECK DOCSERVER SPACE //CHECK DOCSERVER SPACE
$newSize = $docserverControler->checkSize( $newSize = $docserverControler->checkSize(
$docserver, $_SESSION['upfile'][$numAttach]['size'] $docserver,
$_SESSION['upfile'][$numAttach]['size']
); );
if ($newSize == 0) { if ($newSize == 0) {
$error = _DOCSERVER_ERROR.' : '._NOT_ENOUGH_DISK_SPACE.'. '._MORE_INFOS; ?> $error = _DOCSERVER_ERROR.' : '._NOT_ENOUGH_DISK_SPACE.'. '._MORE_INFOS; ?>
...@@ -144,7 +145,8 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -144,7 +145,8 @@ if (isset($_POST['add']) && $_POST['add']) {
//SAVE FILE ON DOCSERVER //SAVE FILE ON DOCSERVER
$storeResult = array(); $storeResult = array();
$storeResult = $docserverControler->storeResourceOnDocserver( $storeResult = $docserverControler->storeResourceOnDocserver(
$_SESSION['collection_id_choice'], $fileInfos $_SESSION['collection_id_choice'],
$fileInfos
); );
if ($attachment_types == 'outgoing_mail' && strpos($fileInfos['format'], 'xl') === false && strpos($fileInfos['format'], 'ppt') === false) { if ($attachment_types == 'outgoing_mail' && strpos($fileInfos['format'], 'xl') === false && strpos($fileInfos['format'], 'ppt') === false) {
$_SESSION['upfile'][$numAttach]['outgoingMail'] = true; $_SESSION['upfile'][$numAttach]['outgoingMail'] = true;
...@@ -436,8 +438,10 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -436,8 +438,10 @@ if (isset($_POST['add']) && $_POST['add']) {
$error = $resAttach->get_error(); $error = $resAttach->get_error();
} else { } else {
// Delete temporary backup // Delete temporary backup
$db->query("DELETE FROM res_attachments WHERE res_id = ? and status = 'TMP' and typist = ?", $db->query(
array($_SESSION['attachmentInfo'][$attachNum]['inProgressResId'], $_SESSION['user']['UserId'])); "DELETE FROM res_attachments WHERE res_id = ? and status = 'TMP' and typist = ?",
array($_SESSION['attachmentInfo'][$attachNum]['inProgressResId'], $_SESSION['user']['UserId'])
);
if ($_SESSION['history']['attachadd'] == 'true') { if ($_SESSION['history']['attachadd'] == 'true') {
$hist = new history(); $hist = new history();
...@@ -445,7 +449,10 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -445,7 +449,10 @@ if (isset($_POST['add']) && $_POST['add']) {
$_SESSION['collection_id_choice'] $_SESSION['collection_id_choice']
); );
$hist->add( $hist->add(
$view, $_SESSION['doc_id'], 'ADD', 'attachadd', $view,
$_SESSION['doc_id'],
'ADD',
'attachadd',
ucfirst(_DOC_NUM).$id.' ' ucfirst(_DOC_NUM).$id.' '
._NEW_ATTACH_ADDED.' '._TO_MASTER_DOCUMENT ._NEW_ATTACH_ADDED.' '._TO_MASTER_DOCUMENT
.$_SESSION['doc_id'], .$_SESSION['doc_id'],
...@@ -454,7 +461,10 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -454,7 +461,10 @@ if (isset($_POST['add']) && $_POST['add']) {
); );
$content = _NEW_ATTACH_ADDED; $content = _NEW_ATTACH_ADDED;
$hist->add( $hist->add(
RES_ATTACHMENTS_TABLE, $id, 'ADD', 'attachadd', RES_ATTACHMENTS_TABLE,
$id,
'ADD',
'attachadd',
$content.' ('.$title $content.' ('.$title
.') ', .') ',
$_SESSION['config']['databasetype'], $_SESSION['config']['databasetype'],
...@@ -514,7 +524,7 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -514,7 +524,7 @@ if (isset($_POST['add']) && $_POST['add']) {
} }
exit(); exit();
//BEGIN EDIT ATTACHMENT VALIDATE BUTTTON //BEGIN EDIT ATTACHMENT VALIDATE BUTTTON
} elseif (isset($_POST['edit']) && $_POST['edit']) { } elseif (isset($_POST['edit']) && $_POST['edit']) {
$resAttach = new resource(); $resAttach = new resource();
$status = 0; $status = 0;
...@@ -557,7 +567,8 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -557,7 +567,8 @@ if (isset($_POST['add']) && $_POST['add']) {
$storeResult = array(); $storeResult = array();
$storeResult = $docserverControler->storeResourceOnDocserver( $storeResult = $docserverControler->storeResourceOnDocserver(
$_SESSION['collection_id_choice'], $fileInfos $_SESSION['collection_id_choice'],
$fileInfos
); );
if (isset($storeResult['error']) && $storeResult['error'] != '') { if (isset($storeResult['error']) && $storeResult['error'] != '') {
...@@ -756,7 +767,8 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -756,7 +767,8 @@ if (isset($_POST['add']) && $_POST['add']) {
$storeResult['destination_dir'], $storeResult['destination_dir'],
$storeResult['file_destination_name'], $storeResult['file_destination_name'],
$storeResult['path_template'], $storeResult['path_template'],
$storeResult['docserver_id'], $_SESSION['data'], $storeResult['docserver_id'],
$_SESSION['data'],
$_SESSION['config']['databasetype'] $_SESSION['config']['databasetype']
); );
...@@ -799,16 +811,16 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -799,16 +811,16 @@ if (isset($_POST['add']) && $_POST['add']) {
//IF FILE IS EDITED //IF FILE IS EDITED
if ($_SESSION['upfile'][0]['upAttachment'] != false) { if ($_SESSION['upfile'][0]['upAttachment'] != false) {
//RETRIEVE CURRENT ATTACHMENT FILE //RETRIEVE CURRENT ATTACHMENT FILE
$stmt = $db->query('SELECT fingerprint, docserver_id FROM res_view_attachments WHERE '.$column_res." = ? and res_id_master = ? and status <> 'OBS'", array($_REQUEST['res_id'], $_SESSION['doc_id']));
$res = $stmt->fetchObject();
require_once 'core/class/docserver_types_controler.php'; require_once 'core/class/docserver_types_controler.php';
require_once 'core/docservers_tools.php'; require_once 'core/docservers_tools.php';
$docserverTypeControler = new docserver_types_controler(); $docserverTypeControler = new docserver_types_controler();
$docserverInfo = $docserverControler->getDocserverToInsert($collId); $docserver = $docserverControler->get($res->docserver_id);
$docserver = $docserverControler->get($docserverInfo->docserver_id); $docserverTypeObject = $docserverTypeControler->get($docserver->docserver_type_id);
$docserverTypeObject = $docserverTypeControler->get($docserver->docserver_type_id);
//HASH OLD AND NEW ATTACHMENT FILE //HASH OLD AND NEW ATTACHMENT FILE
$stmt = $db->query('SELECT fingerprint FROM res_view_attachments WHERE '.$column_res." = ? and res_id_master = ? and status <> 'OBS'", array($_REQUEST['res_id'], $_SESSION['doc_id']));
$res = $stmt->fetchObject();
$NewHash = Ds_doFingerprint($_SESSION['upfile'][0]['tmp_name'], $docserverTypeObject->fingerprint_mode); $NewHash = Ds_doFingerprint($_SESSION['upfile'][0]['tmp_name'], $docserverTypeObject->fingerprint_mode);
$OriginalHash = $res->fingerprint; $OriginalHash = $res->fingerprint;
...@@ -824,7 +836,8 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -824,7 +836,8 @@ if (isset($_POST['add']) && $_POST['add']) {
); );
$storeResult = array(); $storeResult = array();
$storeResult = $docserverControler->storeResourceOnDocserver( $storeResult = $docserverControler->storeResourceOnDocserver(
$_SESSION['collection_id_choice'], $fileInfos $_SESSION['collection_id_choice'],
$fileInfos
); );
if (isset($storeResult['error']) && $storeResult['error'] != '') { if (isset($storeResult['error']) && $storeResult['error'] != '') {
$error = $storeResult['error']; $error = $storeResult['error'];
...@@ -846,7 +859,8 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -846,7 +859,8 @@ if (isset($_POST['add']) && $_POST['add']) {
$set_update .= ', path = :path'; $set_update .= ', path = :path';
$set_update .= ', filename = :filename'; $set_update .= ', filename = :filename';
$set_update .= ', docserver_id = :docserver_id'; $set_update .= ', docserver_id = :docserver_id';
$arrayPDO = array_merge($arrayPDO, $arrayPDO = array_merge(
$arrayPDO,
array(':fingerprint' => $fingerprint, array(':fingerprint' => $fingerprint,
':filesize' => $filesize, ':filesize' => $filesize,
':path' => $storeResult['destination_dir'], ':path' => $storeResult['destination_dir'],
...@@ -939,7 +953,10 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -939,7 +953,10 @@ if (isset($_POST['add']) && $_POST['add']) {
$_SESSION['collection_id_choice'] $_SESSION['collection_id_choice']
); );
$hist->add( $hist->add(
$view, $_SESSION['doc_id'], 'UP', 'attachup', $view,
$_SESSION['doc_id'],
'UP',
'attachup',
ucfirst(_DOC_NUM).$id.' ' ucfirst(_DOC_NUM).$id.' '
._ATTACH_UPDATED, ._ATTACH_UPDATED,
$_SESSION['config']['databasetype'], $_SESSION['config']['databasetype'],
...@@ -947,7 +964,10 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -947,7 +964,10 @@ if (isset($_POST['add']) && $_POST['add']) {
); );
$content = _ATTACH_UPDATED; $content = _ATTACH_UPDATED;
$hist->add( $hist->add(
RES_ATTACHMENTS_TABLE, $id, 'UP', 'attachup', RES_ATTACHMENTS_TABLE,
$id,
'UP',
'attachup',
$_SESSION['info'].' ('.$title $_SESSION['info'].' ('.$title
.') ', .') ',
$_SESSION['config']['databasetype'], $_SESSION['config']['databasetype'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment