diff --git a/module/javascript/script_module.js b/module/javascript/script_module.js index 5558663235c31ed48a18d3e75b77898f287d972d..fbd07bc90c128c795025aee28c2a4d1c0d431e82 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 c1006ff20fa1f5a0ebdb9971a7a219413308e168..989140aa4325eb6201699c9362f3f232b3aabc63 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 691f41d64966ec515519ce437c16a43791dc1966..70c607cc370491cd4b3fc58ba20eb6b64a4f93ea 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 41d43324e68ee69c21c61dd89f12a1d6775eee6e..2908f6a32486332da9ad90f5ed97a5e308a0b225 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 33c0bcbdc7411541a7d7324de45a2b4c4328a993..f322a87bb8ed2493691ce5e300cabbe1e8f7f201 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 eb24ba40e5fac89bc15d4d0ca9a2e56b346da25d..c8b49b977a7ea4e82679e6b1ecb253a3c831be54 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');