From 2cbfd6a27c037afbd7692d5ef305875ad0e0f1a9 Mon Sep 17 00:00:00 2001 From: Damien Burel <damien.burel@maarch.org> Date: Wed, 29 Mar 2017 14:28:03 +0200 Subject: [PATCH] [FIX] #5329 Check is on signable attachments --- .../js/{accounting.js => accounting.min.js} | 0 apps/maarch_entreprise/merged_jsAbstract.php | 2 +- core/Models/AttachmentModel.php | 21 +++++++++ core/Models/AttachmentModelAbstract.php | 47 +++++++++++++++++++ core/init.php | 2 + .../class/class_modules_tools_Abstract.php | 12 ++++- 6 files changed, 82 insertions(+), 2 deletions(-) rename apps/maarch_entreprise/js/{accounting.js => accounting.min.js} (100%) create mode 100644 core/Models/AttachmentModel.php create mode 100644 core/Models/AttachmentModelAbstract.php diff --git a/apps/maarch_entreprise/js/accounting.js b/apps/maarch_entreprise/js/accounting.min.js similarity index 100% rename from apps/maarch_entreprise/js/accounting.js rename to apps/maarch_entreprise/js/accounting.min.js diff --git a/apps/maarch_entreprise/merged_jsAbstract.php b/apps/maarch_entreprise/merged_jsAbstract.php index 71149633c0e..a1d2e0c9e4c 100644 --- a/apps/maarch_entreprise/merged_jsAbstract.php +++ b/apps/maarch_entreprise/merged_jsAbstract.php @@ -39,7 +39,7 @@ class MergedJsAbstract { } public function merge_lib() { - readfile('apps/maarch_entreprise/js/accounting.js'); + readfile('apps/maarch_entreprise/js/accounting.min.js'); include('apps/maarch_entreprise/js/functions.js'); readfile('apps/maarch_entreprise/js/prototype.js'); readfile('apps/maarch_entreprise/js/scriptaculous.js'); diff --git a/core/Models/AttachmentModel.php b/core/Models/AttachmentModel.php new file mode 100644 index 00000000000..a11ce4d2264 --- /dev/null +++ b/core/Models/AttachmentModel.php @@ -0,0 +1,21 @@ +<?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 Attachment Model +* @author dev@maarch.org +* @ingroup core +*/ + +namespace Core\Models; + +class AttachmentModel extends AttachmentModelAbstract +{ + // Do your stuff in this class +} diff --git a/core/Models/AttachmentModelAbstract.php b/core/Models/AttachmentModelAbstract.php new file mode 100644 index 00000000000..2419f2d52c1 --- /dev/null +++ b/core/Models/AttachmentModelAbstract.php @@ -0,0 +1,47 @@ +<?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 Status Model +* @author dev@maarch.org +* @ingroup core +*/ + +namespace Core\Models; + +require_once 'apps/maarch_entreprise/services/Table.php'; + +class AttachmentModelAbstract extends \Apps_Table_Service +{ + public static function getAttachmentsTypesByXML() + { + if (file_exists('custom/' .$_SESSION['custom_override_id']. '/apps/maarch_entreprise/xml/entreprise.xml')) { + $path = 'custom/' .$_SESSION['custom_override_id']. '/apps/maarch_entreprise/xml/entreprise.xml'; + } else { + $path = 'apps/maarch_entreprise/xml/entreprise.xml'; + } + + $xmlfile = simplexml_load_file($path); + $attachmentTypes = []; + $attachmentTypesXML = $xmlfile->attachment_types; + if (count($attachmentTypesXML) > 0) { + foreach ($attachmentTypesXML->type as $value) { + $label = defined((string) $value->label) ? constant((string) $value->label) : (string) $value->label; + $attachmentTypes[(string) $value->id] = [ + 'label' => $label, + 'icon' => (string)$value['icon'], + 'sign' => (empty($value['sign']) || (string)$value['sign'] == 'true') ? true : false + ]; + } + } + + return $attachmentTypes; + } + +} diff --git a/core/init.php b/core/init.php index d4c888260bb..707e41ca1cf 100644 --- a/core/init.php +++ b/core/init.php @@ -65,6 +65,8 @@ if (isset($_SESSION['custom_override_id']) ); } +require_once 'vendor/autoload.php'; + /** * Get an array that represents directory tree diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php index 17e6e2152b0..1fd48cec48d 100644 --- a/modules/visa/class/class_modules_tools_Abstract.php +++ b/modules/visa/class/class_modules_tools_Abstract.php @@ -31,6 +31,7 @@ define('FPDF_FONTPATH',$core_path.'apps/maarch_entreprise/tools/pdfb/fpdf_1_7/font/'); require($core_path.'apps/maarch_entreprise/tools/pdfb/fpdf_1_7/fpdf.php'); require($core_path.'apps/maarch_entreprise/tools/pdfb/fpdf_1_7/fpdi.php'); +use Core\Models\AttachmentModel; abstract class visa_Abstract extends Database { @@ -223,8 +224,17 @@ abstract class visa_Abstract extends Database public function checkResponseProject($res_id, $coll_id) { $this->errorMessageVisa = null; + $attachmentTypes = AttachmentModel::getAttachmentsTypesByXML(); + + $noSignableAttachments = []; + foreach ($attachmentTypes as $key => $value) { + if (!$value['sign']) { + $noSignableAttachments[] = $key; + } + } + $db = new Database(); - $stmt = $db->query("SELECT * FROM res_view_attachments WHERE res_id_master = ? AND coll_id = ? AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder', 'incoming_mail_attachment') ", array($res_id, $coll_id)); + $stmt = $db->query("SELECT * FROM res_view_attachments WHERE res_id_master = ? AND coll_id = ? AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN (?) ", [$res_id, $coll_id, $noSignableAttachments]); if ($stmt->rowCount() <= 0) { $this->errorMessageVisa = _NO_RESPONSE_PROJECT_VISA; return false; -- GitLab