From 6b8c84f9c3943d24ec50eef0bc60f959315fd580 Mon Sep 17 00:00:00 2001 From: Anthony Borghi <anthony.borghi@veremes.com> Date: Mon, 3 Dec 2018 15:26:27 +0100 Subject: [PATCH] Squashed 'src/module_gtf/' changes from 77541a21..1fd3801a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1fd3801a Merge remote-tracking branch 'origin/next_version' into next_version 75bbe42b Merge branch 'master' into 'next_version' ff4f68a2 Merge branch 'bug/6-correctif-redmine-4096' into 'master' 15698aad Correction d'un bug à l'ajout d'une demande (choix du projet FME vide) 7469458d Merge branch 'bug/7-correction-redmine-4171' into 'master' 513a5941 Merge branch 'bug/1-correctif-redmine-4162' into 'master' 234979e4 pull subtree e618a214 pull subtree 33239adf pull_subtree merge 418944d7 Squashed 'src/vitis/' changes from b7d52a87..457060db 1fa29e28 passage du dependency sur next_app_gtf bb5dd054 Merge branch 'master' into next_version 34202ea2 pull subtree d5a39363 pull subtree 6f35e199 Squashed 'src/module_gtf/' changes from 73d00dca..d7bf5b35 44eb0f86 Squashed 'src/vitis/' changes from 771a5655..b7d52a87 e2a9a21e pull subtree 32f0ff6c Demande de Licence : message si le serveur SMTP n'est pas configuré 4be3f176 Création d'une demande avec un compte public dans les widgets 340d72e4 Correction du paramètre "length_sec" dans les templates de mail. 1b05d4e3 Squashed 'src/vitis/' changes from 40e7d46e..c4a0323f 0b32f130 Ajout du body du message dans aValues 64c05212 Ajout du body du message dans aValues fd045f3e Merge remote-tracking branch 'origin/next_version' into next_version 26c71b38 Merge remote-tracking branch 'origin/next_version' into next_version c4a0323f Merge branch 'bug/missing_one_tag' into 'master' 00f54fe4 Update crontab.txt 62f76723 pull subtree 6423b354 Squashed 'src/module_gtf/' changes from fd04f40..d7bf5b3 6b81f376 pull subtree 8b66db12 Squashed 'src/vitis/' changes from 771a565..40e7d46 97be2d90 link modules on branch app_gtf d7bf5b35 merge file 54c4195e merge file 85f17e4d Squashed 'src/module_gtf/' changes from 9c28fdd..fd04f40 8fd3acdd Squashed 'src/vitis/' changes from 01d199ce..771a5655 54623f3c pull subtree 71eb4b83 make push_subtrees executable eefafb81 Squashed 'src/module_gtf/' changes from 1d571171..73d00dca fd04f40f pull subtree a22d9b12 pull subtree b1f94f9f Squashed 'src/vitis/' changes from 355b5f8b..771a5655 383a3657 pull subtree 76895341 Merge branch 'change-name-tag' into 'master' af461eb9 Modification de la manière de modifier le crontab sur Linux pour éviter de donner des droits particulier e352595f Modification de la manière de modifier le crontab sur Linux pour éviter de donner des droits particulier 1ea2910b Update crontab.txt - Changement nom balise 8f957f34 pull subtree 1f024fa8 Squashed 'src/vitis/' changes from ac4fb9c0..827672a9 594f69fa Merge remote-tracking branch 'origin/next_version' into next_version 827672a9 update utils 021d052a update utils b37fccc5 update utils 5d9c5d95 Resolve git ignore on properties.json 9428eabe Update conf/properties.json 21c384e1 Squashed 'src/vitis/' changes from 355b5f8..ac4fb9c c2da09eb Squashed 'src/vitis/' changes from 355b5f8..ac4fb9c 3cd5b77c pull subtree 40ed2073 Add windows install doc on README.md 05ae67b1 add install/update.bat 92ad43c6 Add utils for windows install 3c5afe6c Modify symlinks strategy dae30054 Update Readme 8be158fb Squashed 'src/module_gtf/' content from commit 1d57117 f5030f47 add subtree ac4fb9c0 add subtree d2cf5d0d add subtree c56f5a1d Squashed 'src/closure/' content from commit 622066d 82408f30 Squashed 'src/vitis/' content from commit 355b5f8 65247182 add subtree 83cce5ca Reset sources 7fb843da set dependency.xml bbab977f Change __DIR__ by dirname($_SERVER['SCRIPT_FILENAME']) b1438204 update app template c5717edc Update readme 10346dce Squashed 'src/module_gtf/' content from commit 9c28fdd 2d488f46 add subtree 9c2ebb7c add subtree 98fcb48d Squashed 'src/closure/' content from commit 622066d be874a23 Squashed 'src/vitis/' content from commit 01d199c a7f230ce add subtree 6c1b3e3c Reset sources a195a4d9 Init from SVN 4ad29c4b add subtree 1ac46cd9 Squashed 'src/closure/' content from commit 622066d 635a2f96 add subtree 7593c383 Squashed 'src/vitis/' content from commit 01d199c b487cd6f Update from SVN 266e19a6 Initial commit git-subtree-dir: src/module_gtf git-subtree-split: 1fd3801aae5af6c89d681caf0b88bd97be135804 --- module/javascript/script_module.js | 4 +- module/lang/lang-en.json | 1 + module/lang/lang-fr.json | 2 + .../class/gtf_lib/gtf_object/Order.class.inc | 15 +- web_service/ws/License.class.inc | 128 ++++++++++-------- web_service/ws/UserOrders.class.inc | 9 +- 6 files changed, 88 insertions(+), 71 deletions(-) diff --git a/module/javascript/script_module.js b/module/javascript/script_module.js index 55586632..fbd07bc9 100644 --- a/module/javascript/script_module.js +++ b/module/javascript/script_module.js @@ -1120,7 +1120,9 @@ vitisApp.on('appMainDrtvLoaded', function () { $timeout(function () { // Evènement sur le <select> des projets Fme. document.getElementById("workspace_id").addEventListener("change", function () { - scope["loadSubForm"](this.value, scope, element); + angular.element(element).empty(); + if (this.value != "") + scope["loadSubForm"](this.value, scope, element); }); }, 100); } diff --git a/module/lang/lang-en.json b/module/lang/lang-en.json index c1006ff2..989140aa 100644 --- a/module/lang/lang-en.json +++ b/module/lang/lang-en.json @@ -467,6 +467,7 @@ "SEND_MAIL_SUCCESS_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Mail sent successfully", "LICENSE_FILE_INSTALL_ERROR_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Error while installing the license file.", "LICENSE_FILE_INSTALL_SUCCESS_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "License file successfully installed", + "SMTP_SERVER_PARAMETERS_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Please enter the settings of your SMTP server", "" : "", "FORM_NAME_ENGINE_GTF_ENGINE" : "Name", "FORM_SERVER_ENGINE_GTF_ENGINE" : "Server", diff --git a/module/lang/lang-fr.json b/module/lang/lang-fr.json index 691f41d6..70c607cc 100644 --- a/module/lang/lang-fr.json +++ b/module/lang/lang-fr.json @@ -416,6 +416,7 @@ "FORM_GTF_SCHEMA_CONFIGURATION_CONFIGURATION_GTF_CONFIG" : "Schéma de GTF", "FORM_GTF_HOME_CONFIGURATION_CONFIGURATION_GTF_CONFIG" : "Répertoire de GTF", "FORM_NOT_COMPRESSED_EXTENSION_CONFIGURATION_CONFIGURATION_GTF_CONFIG" : "Extensions des fichiers à ne pas compresser", + "FORM_NBR_ORDER_MAX_CONFIGURATION_CONFIGURATION_GTF_CONFIG" : "Nombre maximum de demandes traitées simultanément", "FORM_MAX_ATTEMPT_CONFIGURATION_CONFIGURATION_GTF_CONFIG" : "Nombre maximum de tentatives", "FORM_RADIO_TRUE_CONFIGURATION_CONFIGURATION_GTF_CONFIG" : "Oui", @@ -467,6 +468,7 @@ "SEND_MAIL_SUCCESS_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Mail envoyé avec succés", "LICENSE_FILE_INSTALL_ERROR_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Erreur pendant l'installation du fichier de licence.", "LICENSE_FILE_INSTALL_SUCCESS_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Fichier de licence installé avec succés", + "SMTP_SERVER_PARAMETERS_CONFIGURATION_CONFIGURATION_GTF_LICENSE" : "Veuillez renseigner les paramètres de votre serveur SMTP.", "" : "", "FORM_NAME_ENGINE_GTF_ENGINE" : "Nom", "FORM_SERVER_ENGINE_GTF_ENGINE" : "Serveur", diff --git a/web_service/class/gtf_lib/gtf_object/Order.class.inc b/web_service/class/gtf_lib/gtf_object/Order.class.inc index 41d43324..2908f6a3 100644 --- a/web_service/class/gtf_lib/gtf_object/Order.class.inc +++ b/web_service/class/gtf_lib/gtf_object/Order.class.inc @@ -10,7 +10,7 @@ require_once("vmlib/error.inc"); class orderLib extends GtfLib{ var $sPkField = "order_id"; var $sTable = "v_user_order"; - + /** * Class constructor * \param $oBd Connection object. @@ -37,7 +37,7 @@ class orderLib extends GtfLib{ $this->aFields['order_id']=$iOrderId; $this->sMessage = $this->oBd->getBDMessage(); }else{ - $this->aFields = $this->oBd->ligneSuivante ($oPDOresult); + $this->aFields = $this->oBd->ligneSuivante ($oPDOresult); // result_file (chemin du fichier de résultat), log_file (chemin du fichier de log) if (!empty($this->aFields['result_url'])) $this->aFields['result_file'] = $aProperties['dir_export'] . '/gtf/' . $this->aFields['result_url']; @@ -53,7 +53,7 @@ class orderLib extends GtfLib{ $this->aFields['order_id']=$iOrderId; $this->bEnErreur= -1; $this->iErrorCode=3; - $this->sMessage ="The order_id #".$iOrderId." doesn't exist"; + $this->sMessage ="The order_id #".$iOrderId." doesn't exist"; }else{ $this->bEnErreur= 0; } @@ -84,7 +84,7 @@ class orderLib extends GtfLib{ while($oEnginesId = $this->oBd->objetSuivant ($resultat)) $aEnginesId[] = $oEnginesId->gtf_engine_id; $this->oBd->fermeResultat(); - + if(count($aEnginesId)==0){ // Le tag correspondant n'a pas été trouvé, nous allons cherché la liste des moteur ayant comme tag |default| $sSql = $aSql['getEnginesDefaultTag']; @@ -113,7 +113,7 @@ class orderLib extends GtfLib{ writeToErrorLog(str_replace('[iOrderId]', $iOrderId, ERROR_0008)); $this->aFields['gtf_engine_id'] = 1; }else{ - $this->aFields['gtf_engine_id'] = $iEngine; + $this->aFields['gtf_engine_id'] = $iEngine; } } @@ -179,8 +179,7 @@ class orderLib extends GtfLib{ function formatOrderEmail() { // Calcule la date et heure de fin list($iHours, $iMinutes, $iSeconds) = explode(':', $this->aFields['length_sec']); - $oLengthSec = new DateInterval('PT' . intval($iHours) . 'H' . intval($iMinutes) . 'M' . intval($iSeconds) . 'S'); - $this->aFields['length_sec'] = $oLengthSec->format('%s'); + $this->aFields['length_sec'] = (intval($iHours) * 3600) + (intval($iMinutes) * 60) + intval($iSeconds); if (!empty($this->aFields['execution_date']) && !empty($this->aFields['length_sec'])) $this->aFields['process_date'] = date_add(date_create($this->aFields['execution_date']), new DateInterval('PT' . intval($this->aFields['length_sec']) . 'S')); // Format des dates @@ -199,4 +198,4 @@ class orderLib extends GtfLib{ } } } -?> \ No newline at end of file +?> diff --git a/web_service/ws/License.class.inc b/web_service/ws/License.class.inc index 33c0bcbd..f322a87b 100755 --- a/web_service/ws/License.class.inc +++ b/web_service/ws/License.class.inc @@ -170,64 +170,84 @@ class License extends GTF { } } } else if ($this->aValues["action"] == 'ask') { - $mail = new PHPMailer; - - $mail->isSMTP(); // Set mailer to use SMTP - //$mail->SMTPDebug = 3; // debugger level (3 all with connection) - $mail->Debugoutput = function($str, $level) {error_log("debug level $level; message: $str");}; - $mail->Host = $this->aProperties["smtp_host"]; // Specify main and backup SMTP servers - $mail->Port = $this->aProperties["smtp_port"]; // TCP port to connect to - $mail->SMTPAuth = $this->aProperties["smtp_authentification"]; // Enable SMTP authentication - // if authentication add parameter to connect SMTP - if ($this->aProperties["smtp_authentification"] === true){ - $mail->AuthType = 'LOGIN'; - $mail->Username = $this->aProperties["smtp_login"]; // SMTP username - $mail->Password = $this->aProperties["smtp_password"]; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted (deprecated) - } - $sTo = 'codes@veremes.com'; - $mail->AddAddress($sTo); - $mail->SetFrom($this->aProperties['mail_sender'], $this->aProperties['nickname_sender']); - $mail->AddReplyTo($this->aValues['reply_to']); - $mail->IsHTML(true); // Set email format to HTML - $mail->CharSet = 'UTF-8'; - $mail->Subject = $this->aValues['subject'] . $this->aValues['license_number']; - $mail->Body = /*utf8_decode*/('<html><body>' . $this->aValues['message'] . '</body></html>'); - $mail->AddCC($this->aValues['reply_to']); - - // Depuis PHP 5.6 -> vérification du certificat SSL. - if (!$this->aProperties['proxy_check_ssl']) { - $mail->SMTPOptions = array( - 'ssl' => array( - 'verify_peer' => false, - 'verify_peer_name' => false, - 'allow_self_signed' => true - ) - ); + // Vérification des paramètres du serveur smtp (vides ou par défaut -> erreur). + $aSmtpDefault = array( + 'smtp_host' => 'smtp.domaine.com', + 'smtp_port' => 26, + 'smtp_authentification' => true, + 'smtp_login' => 'login@domaine.com', + 'smtp_password' => 'password' + ); + $iSmtpCount = 0; + foreach ($aSmtpDefault as $sSmtpKey => $sSmtpValue) { + if (empty($this->aProperties[$sSmtpKey]) || $this->aProperties[$sSmtpKey] == $sSmtpValue) + $iSmtpCount++; } - - // - if (!$mail->send()) { - writeToErrorLog(ERROR_0023 . $sTo . '.'); - writeToErrorLog("Error message : " . $mail->ErrorInfo); - writeToLog("|WARN|PHP|Failed sending email to the following address : " . $sTo . ' and copy to : ' . $this->aValues['reply_to'], $this->aProperties['mail_log_file']); - $oError = new VitisError(1, 'SEND_MAIL_ERROR_CONFIGURATION_CONFIGURATION_GTF_LICENSE'); + if ($iSmtpCount == count($aSmtpDefault)) { + writeToErrorLog('the SMTP server is not configured'); + $oError = new VitisError(1, 'SMTP_SERVER_PARAMETERS_CONFIGURATION_CONFIGURATION_GTF_LICENSE'); $aXmlRacineAttribute['status'] = 0; $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - //$sErrorMessage = $sMail->getMessage(); - } else { - writeToLog("|INFORM|PHP| An email has been sent to the following address : " . $sTo . ' and copy to : ' . $this->aValues['reply_to'], $this->aProperties['mail_log_file']); - if(!empty($this->aProperties['SaveSentMail']) && $this->aProperties['SaveSentMail'] === true){ - $imap = new Imap($this->aProperties['imapBotSender_host'], $this->aProperties['imapBotSender_port'], $this->aProperties['imapBotSender_login'], $this->aProperties['imapBotSender_pwd'], $this->aProperties['imapBotSender_encrypt']); - if($imap->isConnected()===false) - writeToLog("|WARN|PHP| can't connect to the IMAP at hostname : " . $this->aProperties['imapBotSender_host'], $this->aProperties['mail_log_file']); - else{ - $imap->selectFolder("Sent"); - $imap->saveMessageInSent($mail->getSentMIMEMessage(), ""); + } + else { + $mail = new PHPMailer; + $mail->isSMTP(); // Set mailer to use SMTP + //$mail->SMTPDebug = 3; // debugger level (3 all with connection) + $mail->Debugoutput = function($str, $level) {error_log("debug level $level; message: $str");}; + $mail->Host = $this->aProperties["smtp_host"]; // Specify main and backup SMTP servers + $mail->Port = $this->aProperties["smtp_port"]; // TCP port to connect to + $mail->SMTPAuth = $this->aProperties["smtp_authentification"]; // Enable SMTP authentication + // if authentication add parameter to connect SMTP + if ($this->aProperties["smtp_authentification"] === true){ + $mail->AuthType = 'LOGIN'; + $mail->Username = $this->aProperties["smtp_login"]; // SMTP username + $mail->Password = $this->aProperties["smtp_password"]; // SMTP password + $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted (deprecated) + } + $sTo = 'codes@veremes.com'; + $mail->AddAddress($sTo); + $mail->SetFrom($this->aProperties['mail_sender'], $this->aProperties['nickname_sender']); + $mail->AddReplyTo($this->aValues['reply_to']); + $mail->IsHTML(true); // Set email format to HTML + $mail->CharSet = 'UTF-8'; + $mail->Subject = $this->aValues['subject'] . $this->aValues['license_number']; + $mail->Body = /*utf8_decode*/('<html><body>' . $this->aValues['message'] . '</body></html>'); + $mail->AddCC($this->aValues['reply_to']); + + // Depuis PHP 5.6 -> vérification du certificat SSL. + if (!$this->aProperties['proxy_check_ssl']) { + $mail->SMTPOptions = array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true + ) + ); + } + + // + if (!$mail->send()) { + writeToErrorLog(ERROR_0023 . $sTo . '.'); + writeToErrorLog("Error message : " . $mail->ErrorInfo); + writeToLog("|WARN|PHP|Failed sending email to the following address : " . $sTo . ' and copy to : ' . $this->aValues['reply_to'], $this->aProperties['mail_log_file']); + $oError = new VitisError(1, 'SEND_MAIL_ERROR_CONFIGURATION_CONFIGURATION_GTF_LICENSE'); + $aXmlRacineAttribute['status'] = 0; + $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + //$sErrorMessage = $sMail->getMessage(); + } else { + writeToLog("|INFORM|PHP| An email has been sent to the following address : " . $sTo . ' and copy to : ' . $this->aValues['reply_to'], $this->aProperties['mail_log_file']); + if(!empty($this->aProperties['SaveSentMail']) && $this->aProperties['SaveSentMail'] === true){ + $imap = new Imap($this->aProperties['imapBotSender_host'], $this->aProperties['imapBotSender_port'], $this->aProperties['imapBotSender_login'], $this->aProperties['imapBotSender_pwd'], $this->aProperties['imapBotSender_encrypt']); + if($imap->isConnected()===false) + writeToLog("|WARN|PHP| can't connect to the IMAP at hostname : " . $this->aProperties['imapBotSender_host'], $this->aProperties['mail_log_file']); + else{ + $imap->selectFolder("Sent"); + $imap->saveMessageInSent($mail->getSentMIMEMessage(), ""); + } } + $aXmlRacineAttribute['status'] = 1; + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); } - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); } } return $sMessage; @@ -235,4 +255,4 @@ class License extends GTF { } -?> \ No newline at end of file +?> diff --git a/web_service/ws/UserOrders.class.inc b/web_service/ws/UserOrders.class.inc index eb24ba40..c8b49b97 100755 --- a/web_service/ws/UserOrders.class.inc +++ b/web_service/ws/UserOrders.class.inc @@ -195,15 +195,8 @@ class UserOrders extends GTF { $this->aValues['user_id'] = $_SESSION['ses_user_id']; if (!empty($this->aValues['email_notifications'])) $this->aValues['email_notifications'] = str_replace(chr(13) . chr(10), ";", $this->aValues['email_notifications']); - // Si token public -> id du compte public. + // Si token public -> teste si le compte 'public' a un des groupes qui est lié au traitement. if ($this->aValues['token'] == $this->aProperties['public_token']) { - $aPrivateTokenValues = $this->aValues; - $aPrivateTokenValues['user'] = $_SESSION['ses_Login']; - $aPrivateTokenValues['password'] = $this->oConnection->oBd->mdp; - $oPrivateToken = new PrivateToken($this->aPath, $aPrivateTokenValues, $this->aProperties, $this->oConnection); - $oPrivateToken->POST(); - $this->aValues['user_id'] = $oPrivateToken->aFields['user_id']; - // Teste si le compte 'public' a un des groupes qui est lié au traitement. require $this->sRessourcesFile; $aParams['sSchemaGtf'] = array('value' => $this->aProperties['schema_gtf'], 'type' => 'schema_name'); $aParams['workspace_id'] = array('value' => $this->aValues['workspace_id'], 'type' => 'number'); -- GitLab