From 8e384bc3903c7ef459f2b3596bd9dea802e453a7 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Wed, 2 Oct 2019 09:41:02 +0100 Subject: [PATCH] FIX #11730 TIME 0:05 send acknowledgement receipt in sent_to_contact action & FIX #11824 restriction note was already on primary entity & FIX #11936 reload loading file if probleme with convertion --- .../indexing_searching/file_iframe.php | 1 + apps/maarch_entreprise/lang/fr.php | 4 +-- modules/notes/notes.php | 9 +++++-- modules/notes/notes_ajax_content.php | 27 +++++++++---------- modules/sendmail/js/functions.js | 18 +++++++++++-- modules/sendmail/mail_form_to_contact.php | 6 ++++- modules/sendmail/sendmail_to_contact_ajax.php | 26 ++++++++++++++++++ src/core/lang/lang-fr.php | 4 +-- 8 files changed, 72 insertions(+), 23 deletions(-) create mode 100644 modules/sendmail/sendmail_to_contact_ajax.php diff --git a/apps/maarch_entreprise/indexing_searching/file_iframe.php b/apps/maarch_entreprise/indexing_searching/file_iframe.php index 3c1484e3c1a..73f83698f03 100755 --- a/apps/maarch_entreprise/indexing_searching/file_iframe.php +++ b/apps/maarch_entreprise/indexing_searching/file_iframe.php @@ -95,6 +95,7 @@ if (isset($_GET['num'])) { readfile($loc); exit(); } else { + echo '<script language="javascript">document.location.reload(true);</script>'; echo '<br/><br/><div class="error" style="display:block">'._PROBLEM_LOADING_FILE_TMP_DIR. " : {$return['errors']}" .'.</div>'; exit(); } diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 8f729845432..0736f8752fb 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -40,13 +40,13 @@ if (!defined('_ADD_ATTACHMENT_TO_SEND_TO_CONTACT')) { define('_ADD_ATTACHMENT_TO_SEND_TO_CONTACT', "Veuillez ajouter une pièce jointe avant d'envoyer ce courrier au contact"); } if (!defined('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT')) { - define('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT', 'Envoyer au contact avec une pièce jointe obligatoire'); + define('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT', 'Envoyer au contact avec une pièce jointe obligatoire et accusé de réception'); } if (!defined('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT_DESC')) { define('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT_DESC', "Ouvre une modal d'envoi de mail avec l'email du contact associé au document en tant que destinataire, présence OBLIGATOIRE de pièce(s) jointe(s) à l'envoi."); } if (!defined('_SEND_ATTACHMENTS_TO_CONTACT')) { - define('_SEND_ATTACHMENTS_TO_CONTACT', 'Envoyer au contact'); + define('_SEND_ATTACHMENTS_TO_CONTACT', 'Envoyer au contact avec accusé de réception'); } if (!defined('_SEND_ATTACHMENTS_TO_CONTACT_DESC')) { define('_SEND_ATTACHMENTS_TO_CONTACT_DESC', "Ouvre une modal d'envoi de mail avec l'email du contact associé au document en tant que destinataire."); diff --git a/modules/notes/notes.php b/modules/notes/notes.php index e0556d9f9fd..ceb7ba7853e 100755 --- a/modules/notes/notes.php +++ b/modules/notes/notes.php @@ -125,12 +125,17 @@ if (isset($_REQUEST['load'])) { //Where clause $where_tab = array(); - // + + $rawUserEntities = \Entity\models\EntityModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['entity_id']]); + $userEntities = array_column($rawUserEntities, 'entity_id'); + $userEntities = !empty($userEntities) ? $userEntities : ['']; + $where_tab[] = "identifier = ?"; $where_tab[] = "type = ?"; - $where_tab[] = "notes.id in (select notes.id from notes left join note_entities on notes.id = note_entities.note_id where item_id IS NULL OR item_id = '".$_SESSION['user']['primaryentity']['id']."' or notes.user_id = '".$_SESSION['user']['UserId']."')"; + $where_tab[] = "notes.id in (select notes.id from notes left join note_entities on notes.id = note_entities.note_id where item_id IS NULL OR item_id in (?) or notes.user_id = '".$_SESSION['user']['UserId']."')"; $arrayPDO = array($identifier); $arrayPDO[] = 'resource'; + $arrayPDO[] = $userEntities; //Build where $where = implode(' and ', $where_tab); diff --git a/modules/notes/notes_ajax_content.php b/modules/notes/notes_ajax_content.php index faf3d0084bd..c05adb07809 100755 --- a/modules/notes/notes_ajax_content.php +++ b/modules/notes/notes_ajax_content.php @@ -184,9 +184,9 @@ switch ($mode) { if ($state_entity == false) { $content .= '<option value="' .$entitiesList[$i]->entity_id.'" alt="' - .$entitiesList[$i]->short_label.'" title="' - .$entitiesList[$i]->short_label.'">' - .$entitiesList[$i]->short_label.'</option>'; + .functions::xssafe($entitiesList[$i]->short_label).'" title="' + .functions::xssafe($entitiesList[$i]->short_label).'">' + .functions::xssafe($entitiesList[$i]->short_label).'</option>'; } } $content .= '</select><br/> </td>'; @@ -203,10 +203,10 @@ switch ($mode) { if ($state_entity == true || ($entitiesForRestriction && in_array($entitiesList[$i]->entity_id, $entitiesForRestriction))) { $content .= '<option value="' .$entitiesList[$i]->entity_id.'" alt="' - .$entitiesList[$i]->short_label.'" title="' - .$entitiesList[$i]->short_label.'" selected="selected">' - .$entitiesList[$i]->short_label.'</option>'; - } + .functions::xssafe($entitiesList[$i]->short_label).'" title="' + .functions::xssafe($entitiesList[$i]->short_label).'" selected="selected">' + .functions::xssafe($entitiesList[$i]->short_label).'</option>'; + } } $content .= '</select></td>'; $content .= '</tr></table>'; @@ -375,9 +375,9 @@ switch ($mode) { if (!in_array($entitiesList[$i], $notesEntities)) { $content .= '<option value="' .$entitiesList[$i]->entity_id.'" alt="' - .$entitiesList[$i]->short_label.'" title="' - .$entitiesList[$i]->short_label.'">' - .$entitiesList[$i]->short_label.'</option>'; + .functions::xssafe($entitiesList[$i]->short_label).'" title="' + .functions::xssafe($entitiesList[$i]->short_label).'">' + .functions::xssafe($entitiesList[$i]->short_label).'</option>'; } } $content .= '</select><br/> </td>'; @@ -392,9 +392,9 @@ switch ($mode) { for ($i=0;$i<count($notesEntities);$i++) { $content .= '<option value="' .$notesEntities[$i]->entity_id.'" alt="' - .$notesEntities[$i]->short_label.'" title="' - .$notesEntities[$i]->short_label.'" selected="selected">' - .$notesEntities[$i]->short_label.'</option>'; + .functions::xssafe($notesEntities[$i]->short_label).'" title="' + .functions::xssafe($notesEntities[$i]->short_label).'" selected="selected">' + .functions::xssafe($notesEntities[$i]->short_label).'</option>'; } $content .= '</select></td>'; $content .= '</tr></table>'; @@ -540,4 +540,3 @@ switch ($mode) { echo "{status : " . $status . ", msg_result : '" . $msgResult . "', content : '" . addslashes(_parse($content)) . "', error : '" . addslashes($error) . "', exec_js : '".addslashes($js)."'}"; exit (); ?> - diff --git a/modules/sendmail/js/functions.js b/modules/sendmail/js/functions.js index 371aa7e2cc2..0614a7fb782 100755 --- a/modules/sendmail/js/functions.js +++ b/modules/sendmail/js/functions.js @@ -222,7 +222,7 @@ function validEmailForm(path, form_id) { }); } -function validEmailFormForSendToContact(path, form_id) { +function validEmailFormForSendToContact(path, form_id, path2, status) { tinyMCE.triggerSave(); new Ajax.Request(path, { @@ -234,7 +234,7 @@ function validEmailFormForSendToContact(path, form_id) { eval("response = "+answer.responseText); if(response.status == 0){ eval(response.exec_js); - parent.document.getElementById('storage').click(); + changeStatusForActionSendToContact(path2, status); window.parent.destroyModal('form_email'); } else { alert(response.error); @@ -244,6 +244,20 @@ function validEmailFormForSendToContact(path, form_id) { }); } +function changeStatusForActionSendToContact(path, status){ + console.log(path); + new Ajax.Request(path, + { + asynchronous:false, + method:'post', + parameters: {status : status}, + encoding: 'UTF-8', + onSuccess : function(){ + parent.document.getElementById('storage').click(); + } + }); +} + function extractEmailAdress(field, item) { var fullAdress = item.innerHTML; field.value = fullAdress.match(/\(([^)]+)\)/)[1]; diff --git a/modules/sendmail/mail_form_to_contact.php b/modules/sendmail/mail_form_to_contact.php index c6c5af15cad..5019e3dcf33 100755 --- a/modules/sendmail/mail_form_to_contact.php +++ b/modules/sendmail/mail_form_to_contact.php @@ -105,6 +105,10 @@ $path_to_script = $_SESSION['config']['businessappurl'] .'index.php?display=true&module=sendmail&page=sendmail_ajax_content&identifier=' .$identifier.'&origin='.$origin.$parameters; +$path_to_script_ajax = $_SESSION['config']['businessappurl'] + .'index.php?display=true&module=sendmail&page=sendmail_to_contact_ajax&identifier=' + .$identifier.'&origin='.$origin.$parameters; + $core_tools->load_lang(); $core_tools->load_html(); $core_tools->load_header('', true, false); @@ -504,7 +508,7 @@ if ($mode == 'add') { //Send $id_action = 500; $content .= ' <input style="display:none;" type="button" name="valid" value=" '._SEND_EMAIL - .' " id="valid" class="button" onclick="validEmailFormForSendToContact(\''.$path_to_script.'&mode=added&for=send&action='.$_GET['action'].'\', \'formEmail\');" /> '; + .' " id="valid" class="button" onclick="validEmailFormForSendToContact(\''.$path_to_script.'&mode=added&for=send&action='.$_GET['action'].'\', \'formEmail\',\''.$path_to_script_ajax.'&mode=added&for=send\', \''.$_SESSION['status'].'\');" /> '; $content .= '</div>'; $content .= '</form>'; $content .= '</div>'; diff --git a/modules/sendmail/sendmail_to_contact_ajax.php b/modules/sendmail/sendmail_to_contact_ajax.php new file mode 100644 index 00000000000..8accc2c8c20 --- /dev/null +++ b/modules/sendmail/sendmail_to_contact_ajax.php @@ -0,0 +1,26 @@ +<?php + +require_once 'core/class/class_security.php'; + +$security = new security(); +$right = $security->test_right_doc('letterbox_coll', $_REQUEST['identifier']); + +//REDIRECT IF NO RIGHT +if (!$right) { + $_SESSION['error'] = _NO_RIGHT_TXT; + echo "<script language=\"javascript\" type=\"text/javascript\">window.top.location.href='index.php';</script>"; + exit(); +} + +$user = \SrcCore\models\DatabaseModel::select([ + 'select' => ['id'], + 'table' => ['users'], + 'where' => ['user_id = ?'], + 'data' => [$_SESSION['user']['UserId']], + ]); + +\SrcCore\models\DatabaseModel::insertMultiple([ + 'table' => 'acknowledgement_receipts', + 'columns' => ['res_id', 'type', 'format', 'user_id', 'contact_address_id', 'creation_date', 'send_date', 'docserver_id', 'path', 'filename', 'fingerprint'], + 'values' => [[$_REQUEST['identifier'], 'simple', 'html', $user[0]['id'], 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 0, 0, 0]] +]); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index ee7f754493a..c5f505cd97f 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -330,9 +330,9 @@ define('_PROCEED_WORKFLOW', 'Poursuivre le circuit de visa'); define('_PROCEED_WORKFLOW_DESC', 'Met à jour la date du visa de l\'actuel viseur / signataire présent dans le circuit de visa du courrier (\'process_date\' de la table listinstance).'); define('_VISA_MAIL', 'Viser le courrier'); define('_VISA_MAIL_DESC', 'Ouvre la page du parapheur afin de pouvoir viser / signer le document.'); -define('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT', 'Envoyer au contact avec une pièce jointe obligatoire'); +define('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT', 'Envoyer au contact avec une pièce jointe obligatoire et accusé de réception'); define('_SEND_TO_CONTACT_WITH_MANDATORY_ATTACHMENT_DESC', "Ouvre une modal d'envoi de mail avec l'email du contact associé au courrier en tant que destinataire, présence OBLIGATOIRE de pièce(s) jointe(s) à l'envoi."); -define('_SEND_ATTACHMENTS_TO_CONTACT', 'Envoyer au contact'); +define('_SEND_ATTACHMENTS_TO_CONTACT', 'Envoyer au contact avec accusé de réception'); define('_SEND_ATTACHMENTS_TO_CONTACT_DESC', "Ouvre une modal d'envoi de mail avec l'email du contact associé au courrier en tant que destinataire."); define("_VIEW_ATTACHMENTS", "Voir les pièces jointes"); define("_VIEW_ATTACHMENTS_DESC", "Voir les pièces jointes"); -- GitLab