Skip to content
Snippets Groups Projects
Verified Commit 1ef09ee4 authored by Damien's avatar Damien
Browse files

FEAT #12345 TIME 0:50 Migrate outgoing templates

parent 7be92bb2
No related branches found
No related tags found
No related merge requests found
<?php
$js = '';
$list_origin = '';
if (isset($_REQUEST['res_id']) && isset($_REQUEST['res_id_child'])) {
$res_child = $_REQUEST['res_id_child'];
if (!empty($_REQUEST['res_id'])) {
require_once 'core/class/class_core_tools.php';
require_once 'core/class/class_history.php';
require_once 'core/class/LinkController.php';
$Core_Tools = new core_tools();
$Core_Tools->load_lang();
$Class_LinkController = new LinkController();
$db = new Database();
$res_parent = $_REQUEST['res_id'];
if ($_REQUEST['mode'] == 'add') {
$self = false;
if ($res_child == $res_parent) {
$self = true;
} elseif (count($_SESSION['stockCheckbox']) == 1) {
$queryTest = 'SELECT * FROM res_linked WHERE res_parent=? AND res_child=? AND coll_id=?';
$arrayPDO = array($res_parent, $res_child, $_SESSION['collection_id_choice']);
$stmt = $db->query($queryTest, $arrayPDO);
$i = 0;
while ($test = $stmt->fetchObject()) {
++$i;
}
} elseif (count($_SESSION['stockCheckbox']) > 1) {
for ($j = 0; $j < count($_SESSION['stockCheckbox']); ++$j) {
$queryTest = 'SELECT * FROM res_linked WHERE res_parent=? AND res_child=? AND coll_id=?';
$arrayPDO = array($_SESSION['stockCheckbox'][$j], $res_child, $_SESSION['collection_id_choice']);
$stmt = $db->query($queryTest, $arrayPDO);
$i = 0;
while ($test = $stmt->fetchObject()) {
++$i;
}
}
}
if ($i == 0 && !$self && count($_SESSION['stockCheckbox']) == 1) {
$queryAddLink = 'INSERT INTO res_linked (res_parent, res_child, coll_id) VALUES(?, ?, ?)';
$arrayPDO = array($res_parent, $res_child, $_SESSION['collection_id_choice']);
$db->query($queryAddLink, $arrayPDO);
$hist2 = new history();
$hist2->add(
$_REQUEST['tableHist'],
$res_child,
'ADD',
'linkadd',
_LINKED_TO.$res_parent,
$_SESSION['config']['databasetype'],
'apps'
);
$altIdentifier = $Class_LinkController->getAltIdentifier($res_child);
$hist3 = new history();
$hist3->add(
$_REQUEST['tableHist'],
$res_parent,
'ADD',
'linkup',
_THE_DOCUMENT_LINK.$altIdentifier.' (n°'.$res_child.') '._NOW_LINK_WITH_THIS_ONE,
$_SESSION['config']['databasetype'],
'apps'
);
//$info = _THE_DOCUMENT_LINK . $altIdentifier.' (n°'.$res_child . ') ' . _NOW_LINK_WITH_THIS_ONE;
$allChronoNumber = $Class_LinkController->getAltIdentifierConcatened($_SESSION['stockCheckbox']);
if (count($_SESSION['stockCheckbox']) == 1) {
$info = _THE_DOCUMENT_LINK.$allChronoNumber.' '._NOW_LINK_WITH_THIS_ONE;
} elseif (count($_SESSION['stockCheckbox']) > 1 && count($_SESSION['stockCheckbox']) < 3) {
$info = _THE_DOCUMENTS_LINK.$allChronoNumber.' '._ARE_NOW_LINK_WITH_THIS_ONE;
} elseif (count($_SESSION['stockCheckbox']) >= 3) {
$info = _THE_DOCUMENT_LINK.$altIdentifier.' (n°'.$res_child.') '._ARE_NOW_LINK_WITH_MANY_DOCUMENTS;
}
} elseif ($i == 0 && !$self && count($_SESSION['stockCheckbox']) > 1) {
for ($j = 0; $j < count($_SESSION['stockCheckbox']); ++$j) {
$queryAddLink = 'INSERT INTO res_linked (res_parent, res_child, coll_id) VALUES(?, ?, ?)';
$arrayPDO = array($_SESSION['stockCheckbox'][$j], $res_child, $_SESSION['collection_id_choice']);
$db->query($queryAddLink, $arrayPDO);
$hist2 = new history();
$hist2->add(
$_REQUEST['tableHist'],
$res_child,
'ADD',
'linkadd',
_LINKED_TO.$res_parent,
$_SESSION['config']['databasetype'],
'apps'
);
$altIdentifier = $Class_LinkController->getAltIdentifier($res_child);
$hist3 = new history();
$hist3->add(
$_REQUEST['tableHist'],
$res_parent,
'ADD',
'linkup',
_THE_DOCUMENT_LINK.$altIdentifier.' (n°'.$res_child.') '._NOW_LINK_WITH_THIS_ONE,
$_SESSION['config']['databasetype'],
'apps'
);
//$info = _THE_DOCUMENT_LINKBBBB .$altIdentifier.' (n°'.$res_child . ') ' . _NOW_LINK_WITH_THIS_ONE;
}
//seek all chrono number
$allChronoNumber = $Class_LinkController->getAltIdentifierConcatened($_SESSION['stockCheckbox']);
if (count($_SESSION['stockCheckbox']) == 1) {
$info = _THE_DOCUMENT_LINK.$allChronoNumber.' '._NOW_LINK_WITH_THIS_ONE;
} elseif (count($_SESSION['stockCheckbox']) > 1 && count($_SESSION['stockCheckbox']) < 3) {
$info = _THE_DOCUMENTS_LINK.$allChronoNumber.' '._ARE_NOW_LINK_WITH_THIS_ONE;
} elseif (count($_SESSION['stockCheckbox']) >= 3) {
$info = _THE_DOCUMENT_LINK.$altIdentifier.' (n°'.$res_child.') '._ARE_NOW_LINK_WITH_MANY_DOCUMENTS;
}
}
} elseif ($_REQUEST['mode'] == 'del') {
//seek the alt_identifier of the $res_parent
$altIdentifier = $Class_LinkController->getAltIdentifier($res_parent);
$queryDelLink = 'DELETE FROM res_linked WHERE res_parent=? AND res_child=? and coll_id=?';
$arrayPDO = array($res_parent, $res_child, $_SESSION['collection_id_choice']);
$db->query($queryDelLink, $arrayPDO);
$hist2 = new history();
$hist2->add(
$_REQUEST['tableHist'],
$res_child,
'DEL',
'linkdel',
_LINK_TO_THE_DOCUMENT.$altIdentifier.' (n°'.$res_parent.') '._LINK_DELETED,
$_SESSION['config']['databasetype'],
'apps'
);
$info = _LINK_TO_THE_DOCUMENT.$altIdentifier.' (n°'.$res_parent.') '._LINK_DELETED;
$hist3 = new history();
$hist3->add(
$_REQUEST['tableHist'],
$res_parent,
'DEL',
'linkdel',
_THE_DOCUMENT_LINK.$altIdentifier.' (n°'.$res_child.') '._NO_LINK_WITH_THIS_ONE,
$_SESSION['config']['databasetype'],
'apps'
);
}
$js = "window.top.$('main_info').innerHTML = '".$info."';window.top.$('main_info').style.display = 'table-cell';setTimeout(function(){ window.top.$('main_info').style.display = 'none'; }, 10000);";
$formatText = '';
$nbLinkDesc = $Class_LinkController->nbDirectLink(
$_SESSION['doc_id'],
$_SESSION['collection_id_choice'],
'desc'
);
if ($nbLinkDesc > 0) {
//$formatText .= '<i class="fa fa-long-arrow-alt-right fa-2x"></i>';
$formatText .= $Class_LinkController->formatMap(
$Class_LinkController->getMap(
$_SESSION['doc_id'],
$_SESSION['collection_id_choice'],
'desc'
),
'desc'
);
$formatText .= '<br />';
}
$nbLinkAsc = $Class_LinkController->nbDirectLink(
$_SESSION['doc_id'],
$_SESSION['collection_id_choice'],
'asc'
);
if ($nbLinkAsc > 0) {
//$formatText .= '<i class="fa fa-long-arrow-alt-left fa-2x"></i>';
$formatText .= $Class_LinkController->formatMap(
$Class_LinkController->getMap(
$_SESSION['doc_id'],
$_SESSION['collection_id_choice'],
'asc'
),
'asc'
);
$formatText .= '<br />';
}
if ($self) {
$formatText .= '';
}
if ($i != 0) {
$formatText .= '<br />';
$formatText .= '<span style="color: rgba(255, 0, 0, 1); font-weight: bold; font-size: larger;">';
$formatText .= _LINK_ALREADY_EXISTS;
$formatText .= '</span>';
$formatText .= '<br />';
$formatText .= '<br />';
}
$nb = $Class_LinkController->nbDirectLink(
$_SESSION['doc_id'],
$_SESSION['collection_id_choice'],
'all'
);
$_SESSION['stockCheckbox'] = '';
$toolbarBagde_script = $_SESSION['config']['businessappurl'].'index.php?display=true&page=load_toolbar_links&origin=parent&resId='.$_SESSION['doc_id'].'&collId='.$_SESSION['collection_id_choice'];
$js .= 'loadToolbarBadge(\'links_tab\',\''.$toolbarBagde_script.'\');';
echo "{status : 0, links : '".addslashes($formatText)."', nb : '".$nb."', exec_js : '".addslashes($js)."'}";
//exit ();
//header("Location: index.php?page=".$_REQUEST['pageHeader']."&dir=".$_REQUEST['dirHeader']."&id=".$res_child);
}
} else {
/* $Links .= '<h2>';
$Links .= _ADD_A_LINK;
$Links .= '</h2>';
$Links .= '<br />';*/
$searchAdv = 'search_adv';
//formulaire
$Links .= '<form action="index.php" method="">';
$Links .= '<table width="100%" border="0" >';
$Links .= '<tr>';
$Links .= '<td style="text-align: center;">';
$Links .= '<input ';
$Links .= 'onclick="window.open(';
$Links .= '\''.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page='
.$searchAdv.'&mode=popup&action_form=show_res_id&modulename=attachments&init_search&exclude='.$_SESSION['doc_id'].'&nodetails&fromValidateMail\', ';
$Links .= '\'search_doc_for_attachment\', ';
$Links .= '\'scrollbars=yes,menubar=no,toolbar=no,resizable=yes,status=no,width=1100,height=775\'';
$Links .= ');"';
$Links .= 'type="button" ';
//$Links .= 'value="Rechercher un document"';
$Links .= 'value="'._ADD_A_LINK.'"';
$Links .= 'class="button" ';
$Links .= '/>';
$Links .= '</td>';
$Links .= '<td style="text-align: left;display:none;">';
$Links .= '<input ';
$Links .= 'type="hidden" ';
$Links .= 'name="res_id_child" ';
$Links .= 'value="'.$_SESSION['doc_id'].'" ';
$Links .= '>';
$Links .= '<input ';
$Links .= 'type="hidden" ';
$Links .= 'name="page" ';
$Links .= 'value="add_links" ';
$Links .= '>';
$Links .= '<input ';
$Links .= 'type="hidden" ';
$Links .= 'name="tableHist" ';
$Links .= 'id="tableHist" ';
$Links .= 'value="'.$table.'" ';
$Links .= '>';
//$Links .= '<label for="res_id_link">'.ucfirst(_DOC_NUM).':&nbsp;</label>';
$Links .= '<input ';
$Links .= 'type="text" ';
$Links .= 'disabled="disabled" ';
$Links .= 'readonly="readonly" ';
$Links .= 'name="res_id_link" ';
$Links .= 'id="res_id_link" ';
$Links .= '>';
if (_ID_TO_DISPLAY == 'chrono_number') {
$Links .= '<input ';
$Links .= 'type="text" ';
$Links .= 'disabled="disabled" ';
$Links .= 'readonly="readonly" ';
$Links .= 'name="input_chrono_id" ';
$Links .= 'id="input_chrono_id" ';
$Links .= '>';
}
$Links .= '</td>';
$Links .= '</tr>';
$Links .= '<tr>';
$Links .= '<td style="display:none;">';
$Links .= '<input ';
$Links .= 'type="button" id="attach_link"';
$Links .= 'class="button" ';
$Links .= 'onClick="if($(\'res_id_link\').value != \'\') addLinks(\''.$_SESSION['config']['businessappurl'].'index.php?page=add_links&display=true\', \''.$_SESSION['doc_id'].'\', $(\'res_id_link\').value, \'add\', $(\'tableHist\').value);';
$Links .= '$(\'res_id_link\').setValue(\'\');';
if (_ID_TO_DISPLAY == 'chrono_number') {
$Links .= '$(\'input_chrono_id\').setValue(\'\');';
}
$Links .= '"';
$Links .= 'value="&nbsp;&nbsp; '._LINK_ACTION.' &nbsp;&nbsp;" ';
$Links .= '>';
$Links .= '</td>';
$Links .= '<td>';
$Links .= '&nbsp;';
$Links .= '</td>';
$Links .= '</tr>';
$Links .= '</table>';
$Links .= '</form>';
}
<?php
require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php';
require_once 'core/class/LinkController.php';
if (!empty($_REQUEST['id'])) {
$_SESSION['doc_id'] = $_REQUEST['id'];
}
$security = new security();
$right = $security->test_right_doc('letterbox_coll', $_SESSION['doc_id']);
if (!$right) {
exit(_NO_RIGHT_TXT);
}
$core_tools = new core_tools();
$core_tools->load_lang();
$core_tools->load_html();
$core_tools->load_header('', true, false);
$core_tools->load_js();
$Class_LinkController = new LinkController();
$frm_str .= '<div id="loadLinks">';
$nbLinkDesc = $Class_LinkController->nbDirectLink(
$_SESSION['doc_id'],
'letterbox_coll',
'desc'
);
if ($nbLinkDesc > 0) {
$frm_str .= '<i class="fa fa-long-arrow-alt-right fa-2x"></i>';
$frm_str .= $Class_LinkController->formatMap(
$Class_LinkController->getMap(
$_SESSION['doc_id'],
'letterbox_coll',
'desc'
),
'desc'
);
$frm_str .= '<br />';
}
$nbLinkAsc = $Class_LinkController->nbDirectLink(
$_SESSION['doc_id'],
'letterbox_coll',
'asc'
);
if ($nbLinkAsc > 0) {
$frm_str .= '<i class="fa fa-long-arrow-alt-left fa-2x"></i>';
$frm_str .= $Class_LinkController->formatMap(
$Class_LinkController->getMap(
$_SESSION['doc_id'],
'letterbox_coll',
'asc'
),
'asc'
);
$frm_str .= '<br />';
}
$frm_str .= '</div>';
if ($core_tools->test_service('add_links', 'apps', false)) {
include 'apps/'.$_SESSION['config']['app_id'].'/add_links.php';
$frm_str .= $Links;
}
echo $frm_str;
......@@ -24,7 +24,7 @@ php ./migrateCustomValues.php
php ./migrateVersionAttachments.php
php ./migrateOutgoingAttachments.php
php ./migrateContacts.php
# migrateOutgoingTemplate always before migrateTemplates
php ./migrateOutgoingTemplate.php
# migrateTemplates always before migrateOutgoingTemplate
php ./migrateTemplates.php
php ./migrateOutgoingTemplate.php
php ./migrateLinkedResources.php
......@@ -188,6 +188,24 @@ $DATA_TO_REPLACE = [
'contact.phone' => '[recipient.phone]',
'contact.email' => '[recipient.email]',
'attachmentRecipient.company' => '[recipient.company]',
'attachmentRecipient.departement' => '[recipient.department]',
'attachmentRecipient.civility' => '[recipient.civility]',
'attachmentRecipient.lastname' => '[recipient.lastname]',
'attachmentRecipient.firstname' => '[recipient.firstname]',
'attachmentRecipient.function' => '[recipient.function]',
'attachmentRecipient.postal_address;strconv=no' => '[recipient.postal_address;strconv=no]',
'attachmentRecipient.postal_address' => '[recipient.postal_address]',
'attachmentRecipient.address_number' => '[recipient.address_number]',
'attachmentRecipient.address_street' => '[recipient.address_street]',
'attachmentRecipient.address_additional1' => '[recipient.address_additional1]',
'attachmentRecipient.address_additional2' => '[recipient.address_additional2]',
'attachmentRecipient.address_town' => '[recipient.address_town]',
'attachmentRecipient.address_postcode' => '[recipient.address_postcode]',
'attachmentRecipient.address_country' => '[recipient.address_country]',
'attachmentRecipient.phone' => '[recipient.phone]',
'attachmentRecipient.email' => '[recipient.email]',
'notes.identifier' => '[res_letterbox.res_id]',
'notes.subject' => '[res_letterbox.subject]',
'notes.note_text' => '[notes]',
......@@ -231,10 +249,13 @@ foreach ($customs as $custom) {
// BEGIN Change attachment all in outgoingMail
$templatesAllAttachmentTypes = TemplateModel::get([
'where' => ['template_target = ?', 'template_attachment_type = ?'],
'data' => ['attachments', 'all']
'where' => ['template_target = ?', 'template_attachment_type in (?)'],
'data' => ['attachments', ['all', 'outgoing_mail']]
]);
$migrated = 0;
$nonMigrated = 0;
foreach ($templatesAllAttachmentTypes as $template) {
$path = str_replace('#', '/', $template['template_path']);
......@@ -284,15 +305,6 @@ foreach ($customs as $custom) {
// END
TemplateModel::update([
'set' => [
'template_target' => 'indexingFile',
'template_attachment_type' => 'all'
],
'where' => ['template_target = ?', 'template_attachment_type = ?'],
'data' => ['attachments', 'outgoing_mail']
]);
foreach ($customFields as $customField) {
$idNewCustomField = ContactCustomFieldListModel::get([
'select' => ['id'],
......@@ -302,8 +314,6 @@ foreach ($customs as $custom) {
$DATA_TO_REPLACE["contact." . $customField['oldId']] = "[recipient.customField_{$idNewCustomField[0]['id']}]";
}
$migrated = 0;
$nonMigrated = 0;
$templates = TemplateModel::get([
'where' => ['template_target = ?', 'template_attachment_type = ?'],
'data' => ['indexingFile', 'all']
......@@ -374,7 +384,7 @@ foreach ($customs as $custom) {
if ($loadedXml) {
for ($i=count($loadedXml->attachment_types->type); $i >= 0; $i--) {
if (in_array($loadedXml->attachment_types->type[$i]->id, ['outgoing_mail', 'outgoing_mail_signed'])) {
if (in_array($loadedXml->attachment_types->type[$i]->id, ['outgoing_mail_signed'])) {
unset($loadedXml->attachment_types->type[$i]);
}
}
......
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
* @brief Other chrono for attachments
*
* Open a modal box to displays the indexing form, make the form checks and loads
* the result in database. Used by the core (manage_action.php page).
*
* @file
* @author <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup apps
*/
require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php';
require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_chrono.php';
require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php");
$core = new core_tools();
$core->test_user();
$db = new Database();
$array_attachment_types_get_chrono = "'".implode("','", $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']])."'";
$stmt = $db->query("SELECT distinct identifier FROM res_attachments WHERE res_id_master = ? and attachment_type IN (".$array_attachment_types_get_chrono.") and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id']));
$listIdentifier = array();
while ($res = $stmt->fetchObject()) {
array_push($listIdentifier, $res->identifier);
}
$stmt = $db->query("SELECT category_id, alt_identifier FROM res_letterbox WHERE res_id = ? ", array($_SESSION['doc_id']));
$res = $stmt->fetchObject();
$category_id = $res->category_id;
if ($category_id == "outgoing" && $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']] == "response_project") {
array_push($listIdentifier, $res->alt_identifier);
}
$countIdentifier = count($listIdentifier);
$listChrono .= '<option value="">S&eacute;lectionner le num&eacute;ro chrono</option>';
for ($cptsIdentifier = 0; $cptsIdentifier < $countIdentifier; $cptsIdentifier++) {
$listChrono .= '<option value="'.functions::show_string($listIdentifier[$cptsIdentifier]).'">'
. functions::show_string($listIdentifier[$cptsIdentifier])
. '</option>';
}
echo "{status: 1, chronoList: '".$listChrono."'}";
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
* @brief show_res_id
* @author dev <dev@maarch.org>
* @ingroup attachments
*/
$core = new core_tools();
$core->test_user();
?>
<script type="text/javascript">
var input_res = window.opener.$('res_id_link');
<?php
if (_ID_TO_DISPLAY == 'chrono_number') {
?>
var input_chrono_id = window.opener.$('input_chrono_id');
<?php
require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
$db = new Database();
$arrayChrono = array();
foreach ($_SESSION['stockCheckbox'] as $key => $value) {
$stmt = $db->query('SELECT alt_identifier FROM res_letterbox WHERE res_id = ?', array($value));
$res = $stmt->fetchObject();
$chrono = $res->alt_identifier;
array_push($arrayChrono, $chrono);
}
} ?>
//VALIDATE_MAIL (contact_check)
if (window.opener.document.getElementById('to_link') != null) {
window.opener.document.getElementById('iframe_tab').contentWindow.document.getElementById('res_id_link').value=<?php echo json_encode($_SESSION['stockCheckbox']); ?>;
<?php
if (_ID_TO_DISPLAY == 'chrono_number') {
?>
window.opener.document.getElementById('iframe_tab').contentWindow.document.getElementById('input_chrono_id').value==<?php echo json_encode($arrayChrono); ?>;
<?php
} ?>
window.opener.document.getElementById('iframe_tab').contentWindow.document.getElementById('attach_link').click();
} else if (input_res) {
//VALIDATE_MAIL
input_res.value=<?php echo json_encode($_SESSION['stockCheckbox']); ?>;
<?php
if (_ID_TO_DISPLAY == 'chrono_number') {
?>
input_chrono_id.value=<?php echo json_encode($arrayChrono); ?>;
<?php
} ?>
window.opener.$('attach_link').click();
} else { //INDEX_MLB
window.opener.$('res_id').value=<?php echo json_encode($_SESSION['stockCheckbox']); ?>;
<?php
if (_ID_TO_DISPLAY == 'chrono_number') {
?>
window.opener.$('chrono_id').value=<?php echo json_encode($arrayChrono); ?>;
<?php
} ?>
window.opener.$('attach').click();
}
self.close();
</script>
\ No newline at end of file
<?php
/*
* Copyright 2015 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework 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 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework 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 Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @brief Unset Chrono for attachments
*
* @file
* @author <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup apps
*/
$core = new core_tools();
$core->test_user();
unset($_SESSION['save_chrono_number']);
\ No newline at end of file
<?php
/*
* Copyright 2015 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework 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 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework 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 Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @brief Unset temporary saved attachments
*
* @file
* @author <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup apps
*/
$core = new core_tools();
$core->test_user();
$db = new Database();
$tableName = "res_attachments";
$stmt = $db->query(
"SELECT docserver_id, path, filename FROM ".$tableName." WHERE res_id_master = ? AND status = 'TMP' AND typist = ?",
[$_SESSION['doc_id'], $_SESSION['user']['UserId']]
);
if ($stmt->rowCount() !== 0) {
while ($line = $stmt->fetchObject()) {
$stmt = $db->query("SELECT path_template FROM docservers WHERE docserver_id = ?", array($line->docserver_id));
$lineDoc = $stmt->fetchObject();
$file = $lineDoc->path_template . $line->path . $line->filename;
$file = str_replace("#", DIRECTORY_SEPARATOR, $file);
unlink($file);
}
}
$db->query("DELETE FROM ".$tableName." WHERE res_id_master = ? and status = 'TMP' and typist = ?", [$_SESSION['doc_id'], $_SESSION['user']['UserId']]);
unset($_SESSION['attachmentInfo']);
unset($_SESSION['AttachmentContact']);
......@@ -17,18 +17,6 @@
<parameter name="display" value="true"/>
<parameter name="page" value="previous_attachments"/>
</requestDefinition>
<requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="get_other_chrono_attachment">
<parameter name="module" type="identifier" />
<parameter name="display" value="true"/>
<parameter name="page" value="get_other_chrono_attachment"/>
</requestDefinition>
<requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="get_other_chrono_attachment">
<parameter name="module" type="identifier" />
<parameter name="display" value="true"/>
<parameter name="page" value="get_other_chrono_attachment"/>
</requestDefinition>
<requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="view_attachment" >
<parameter name="module" type="identifier" />
<parameter name="display" value="true"/>
......
......@@ -19,11 +19,6 @@
<parameter name="res_id" type="integer" />
</validationRule>
<validationRule name="get_other_chrono_attachment" extends="standardForm" mode="error">
<parameter name="module" type="identifier" />
<parameter name="type_id" type="identifier" />
</validationRule>
<validationRule name="view_attachment" extends="standardForm" mode="error">
<parameter name="module" type="identifier" />
<parameter name="res_id_master" type="integer" />
......
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