diff --git a/.gitignore b/.gitignore index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fb23a1f31378cce575900e083e4179591effa425 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,6 @@ +vas/rest/class/* +vas/rest/class/!*/ +vas/rest/class/!*.* +vas/sql/* +vas/sql/!*/ +vas/sql/!*.* diff --git a/client/javascript/app/controllers/htmlFormCtrl.js b/client/javascript/app/controllers/htmlFormCtrl.js old mode 100644 new mode 100755 diff --git a/client/javascript/app/controllers/initCtrl.js b/client/javascript/app/controllers/initCtrl.js old mode 100644 new mode 100755 index 70431eefb04a8ac083d1575ba2a078ca0641527f..48855c56c2092018d46d95c1faa98e94bc383767 --- a/client/javascript/app/controllers/initCtrl.js +++ b/client/javascript/app/controllers/initCtrl.js @@ -20,7 +20,6 @@ goog.require("vitis.modules.main"); vitisApp.initCtrl = function ($scope, $log, $q, envSrvc, sessionSrvc, propertiesSrvc, userSrvc, $translate) { // Informe l'application que le contrôleur a été chargée. vitisApp.broadcast('appInitCtrlLoaded'); - /** * getMainTemplateUrl function. * Change le template de l'élément principal de l'application. @@ -99,43 +98,6 @@ vitisApp.initCtrl = function ($scope, $log, $q, envSrvc, sessionSrvc, properties }); }; - - /** - * connectFromUrl function. - * Connexion à l'application avec les identifiants passés dans l'url. - * @param {string} oConnexionId Identifiants de connexion - **/ - $scope.$root["connectWithTokenUrl"] = function () { - $log.info("connectFromUrl"); - // Demande de token pour l'utilisateur. - ajaxRequest({ - "method": "POST", - "url": oClientProperties["web_server_name"] + "/" + oClientProperties["services_alias"] + "/" + sessionSrvc["web_service"] + "/" + sessionSrvc["web_service_controller"], - "scope": $scope, - "success": function (response) { - if (response["data"]["status"] == 1) { - // Cache le message d'erreur. - //$scope["hideErrorAlert"](); - // Sauve les données du token. - //sessionSrvc["token"] = oUrlParams['token']; - sessionSrvc["validity_date"] = response["data"]["validity_date"]; - sessionStorage["session_token"] = sessionSrvc["token"]; - // Sauve les données de l'utilisateur. - userSrvc["login"] = response["data"]["user"]; - userSrvc["id"] = parseInt(response["data"]["user_id"]); - userSrvc["privileges"] = response["data"]["privileges"]; - sessionStorage["user_login"] = response["data"]["user"]; - sessionStorage["user_id"] = userSrvc["id"]; - sessionStorage["privileges"] = userSrvc["privileges"]; - sessionSrvc["saveSessionToLocalStorage"](); - // - deferred.resolve(); - } else - sessionSrvc["disconnect"](); - } - }); - }; - // Sauve le nom de l'application (pour les modes de l'utilisateur) //sessionStorage["application"] = document.location.pathname.split("/").pop(); @@ -152,14 +114,6 @@ vitisApp.initCtrl = function ($scope, $log, $q, envSrvc, sessionSrvc, properties var deferred = $q.defer(); var promise = deferred.promise; - if (goog.isDefAndNotNull(oUrlParams['token'])){ - sessionStorage['session_token'] = oUrlParams['token']; - sessionSrvc["token"] = oUrlParams['token']; - sessionSrvc["saveSessionToLocalStorage"](); - $scope.$root["connectWithTokenUrl"](); - } else - deferred.resolve(); - // Connexion avec les identifiants passés dans l'url (si le cookie avec le token n'existe pas). var aUrlParamsKeys = Object.keys(oUrlParams); if (sessionSrvc["getAppLocalStorageItem"]("session_token") === null && aUrlParamsKeys.indexOf("login") !== -1 && aUrlParamsKeys.indexOf("password") !== -1) diff --git a/client/javascript/app/controllers/loginCtrl.js b/client/javascript/app/controllers/loginCtrl.js index a5456b97fd5b71d25c13cb4c0405b816fa331263..4e6e14618cdf92462865f9f573dbee866c13f221 100644 --- a/client/javascript/app/controllers/loginCtrl.js +++ b/client/javascript/app/controllers/loginCtrl.js @@ -432,7 +432,6 @@ vitisApp.loginCtrl = function ($scope, $translate, $rootScope, $q, sessionSrvc, $translate([sConnectionErrorMessage]).then(function (translations) { sConnectionErrorMessage = translations[sConnectionErrorMessage]; $scope["showErrorAlert"](sConnectionErrorMessage.replace('[IPAddress]', ipAddress)); - deferred.reject(); sConnectionErrorMessage = undefined; deferred.reject(); }); @@ -441,12 +440,6 @@ vitisApp.loginCtrl = function ($scope, $translate, $rootScope, $q, sessionSrvc, case 18: sConnectionErrorMessage = "FORM_LOGIN_CONNECTION_ERROR_MISSING_PRIVILEGES"; break; - // Base de données injoignable. - case 19: - sConnectionErrorMessage = "FORM_LOGIN_CONNECTION_ERROR_UNREACHABLE_DATABASE"; - $scope["showErrorAlert"](sConnectionErrorMessage); - deferred.reject(); - break; default: sConnectionErrorMessage = "FORM_LOGIN_CONNECTION_ERROR"; } diff --git a/client/javascript/app/script_client.js b/client/javascript/app/script_client.js index 02bda1b163d823f778c284e186dd91a290c803f2..1f56beac66fa8b60adbae277624b4c216d4d7af5 100644 --- a/client/javascript/app/script_client.js +++ b/client/javascript/app/script_client.js @@ -1725,34 +1725,4 @@ vitisApp.on('appInitCtrlLoaded', function () { } }); vitisApp.module.directive("appHideColumn", vitisApp.appHideColumn); - - /** - * addAjaxLoaderToElement function. - * Ajoute un loader Ajax à côté d'un élément HTML. - * @param {string} sElementId Id de l'élément html. - **/ - angular.element(vitisApp.appMainDrtv).scope()["addAjaxLoaderToElement"] = function (sElementId) { - $log.info("addAjaxLoaderToElement"); - var oElem = document.getElementById(sElementId); - if (oElem !== null) { - var oAjaxLoaderElem = document.createElement('span'); - oAjaxLoaderElem.className = "icon-refresh form-glyphicon-refresh-animate"; - oElem.parentNode.appendChild(oAjaxLoaderElem); - } - }; - - /** - * removeAjaxLoaderFromElement function. - * Supprime un loader Ajax placé à côté d'un élément HTML. - * @param {string} sElementId Id de l'élément html. - **/ - angular.element(vitisApp.appMainDrtv).scope()["removeAjaxLoaderFromElement"] = function (sElementId) { - $log.info("removeAjaxLoaderFromElement"); - var oElem = document.getElementById(sElementId); - if (oElem !== null) { - var oAjaxLoaderElem = oElem.parentNode.querySelector(".form-glyphicon-refresh-animate"); - if (oAjaxLoaderElem !== null) - oElem.parentNode.removeChild(oAjaxLoaderElem); - } - }; }); diff --git a/client/javascript/externs/formReader/formReaderCtrl.js b/client/javascript/externs/formReader/formReaderCtrl.js old mode 100644 new mode 100755 diff --git a/client/javascript/externs/formReader/formReaderDrtv.js b/client/javascript/externs/formReader/formReaderDrtv.js index 283bbc430a4b12761af760ab9563956ee0ac3e1e..48e7a37a22b78e1f1154bcaec9471d51e4a1c3a5 100644 --- a/client/javascript/externs/formReader/formReaderDrtv.js +++ b/client/javascript/externs/formReader/formReaderDrtv.js @@ -176,6 +176,8 @@ formReader.formReaderDirective = function ($q, formReaderService, propertiesSrvc } }); }); + } else { + console.error('Error: form not valid'); } }; @@ -711,6 +713,9 @@ formReader.appFormFieldSpecificParamsDrtv = function ($timeout, $translate, prop $(element)["datetimepicker"](oOptions); // Si sélection d'une date : mise à jour du modèle (NE PAS SUPPRIMER!). + $(element).on("dp.hide", function (e) { + scope["oFormValues"][scope["sFormDefinitionName"]][element[0].name] = element[0].value; + }); $(element).on("dp.change", function (e) { scope["oFormValues"][scope["sFormDefinitionName"]][element[0].name] = element[0].value; }); @@ -2151,8 +2156,8 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, // Récupère lélément en sélectionné formReaderService['getWebServiceData'](oFormWebService).then(function (aResult) { - var oSubformDefinition = aResult[0]['bo_json_form']; + var sSubformJSDefinition = aResult[0]['bo_json_form_js']; var oSubformValues = {}; var sModalId = 'formreader_' + scope['sFormUniqueName'] + '_grid_subform_modal'; @@ -2219,7 +2224,7 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, } }); - formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues); + formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues, sSubformJSDefinition); }); }; @@ -2247,6 +2252,7 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, }; var sModalId = 'formreader_' + scope['sFormUniqueName'] + '_grid_subform_modal'; var oSubformDefinition = oBusinessObject['json_form'][0]; + var sSubformJSDefinition = oBusinessObject['json_form_js']; var sSubformDefinitionName = 'insert'; // Grise le champ contenant la valeur du parent @@ -2288,7 +2294,7 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, }); }); }; - formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues); + formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues, sSubformJSDefinition); }; /** diff --git a/client/javascript/externs/formReader/formReaderSrvc.js b/client/javascript/externs/formReader/formReaderSrvc.js index 6ca6ef291e6a45bdf3b6298b998729bd7abddef5..613652f9c35ccf385e3b72c1c26432d8e0e8a09f 100644 --- a/client/javascript/externs/formReader/formReaderSrvc.js +++ b/client/javascript/externs/formReader/formReaderSrvc.js @@ -1230,15 +1230,15 @@ formReader.formReaderService = function ($translate, $rootScope, $q, $log, $time * @param {object} oSubformDefinition * @param {object} oSubformDefinitionName * @param {object} oSubformValues + * @param {string|null} sSubformJSDefinition */ - "showModalSubform": function (sModalId, oSubformScope, oSubformDefinition, oSubformDefinitionName, oSubformValues) { + "showModalSubform": function (sModalId, oSubformScope, oSubformDefinition, oSubformDefinitionName, oSubformValues, sSubformJSDefinition) { $log.log("showModalSubform"); var sToken = this['sToken']; var oProperties = this['oProperties']; - if (goog.isDefAndNotNull(oSubformScope['loadSubForm'])) { - + var loadForm = function(){ oSubformScope['loadSubForm']({ 'sFormDefinitionName': oSubformDefinitionName, 'oFormDefinition': oSubformDefinition, @@ -1246,6 +1246,30 @@ formReader.formReaderService = function ($translate, $rootScope, $q, $log, $time 'oProperties': oProperties, 'sToken': sToken }); + } + + if (goog.isDefAndNotNull(oSubformScope['loadSubForm'])) { + + if (goog.isDefAndNotNull(sSubformJSDefinition)) { + var sUrl = sSubformJSDefinition; + oVmap.log("initHtmlForm : javascript assoc. to : " + sUrl); + loadExternalJs([sUrl], { + "callback": function () { + loadForm(); + try { + if (goog.isDef(constructor_form)) { + constructor_form(oSubformScope, sUrl); + } + } catch (e) { + oVmap.log("constructor_form does not exist"); + } + }, + "async": true, + "scriptInBody": true + }); + } else { + loadForm(); + } $('#' + sModalId).modal('show'); } diff --git a/client/lang/lang-en.json b/client/lang/lang-en.json index 0038b8111b023f79ac39954b3ddc1e892fbeeb59..349fcf07df20a59f918709e36e4db469d4cfcffb 100644 --- a/client/lang/lang-en.json +++ b/client/lang/lang-en.json @@ -7,7 +7,6 @@ "FORM_LOGIN_CONNECTION_ERROR": "Connection failed. Incorrect user / password / domain or database not available", "FORM_LOGIN_CONNECTION_ERROR_FORBIDDEN_IP": "Connection failed. IP [IPAddress] forbiden", "FORM_LOGIN_CONNECTION_ERROR_MISSING_PRIVILEGES": "Connection failed. The user does not have the required privileges. Please contact your administrator.", - "FORM_LOGIN_CONNECTION_ERROR_UNREACHABLE_DATABASE": "The application is currently unavailable (database unreachable).", "FORM_LOGIN_REMEMBER_ME": "Remember connection?", "FORM_APP_STATUS_ERROR": "Unstable application", "FORM_VAS_STATUS_ERROR": "Unstable VAS", diff --git a/client/lang/lang-fr.json b/client/lang/lang-fr.json index 7dfe445bb0d0440f1fc6b9a0b41d979c21b9a308..5c5eb178de24b151ef22b6b2e7c0701363bc0297 100644 --- a/client/lang/lang-fr.json +++ b/client/lang/lang-fr.json @@ -7,7 +7,6 @@ "FORM_LOGIN_CONNECTION_ERROR": "Connexion refusée. Utilisateur / Mot de passe / domaine incorrect ou base de données non disponible.", "FORM_LOGIN_CONNECTION_ERROR_FORBIDDEN_IP": "Connexion refusée. Adresse IP [IPAddress] non autorisée", "FORM_LOGIN_CONNECTION_ERROR_MISSING_PRIVILEGES": "Connexion refusée. L'utilisateur ne dispose pas des privilèges requis. Merci de contacter votre administrateur.", - "FORM_LOGIN_CONNECTION_ERROR_UNREACHABLE_DATABASE": "L'application est actuellement indisponible (base de données injoignable).", "FORM_LOGIN_REMEMBER_ME": "Se souvenir de moi ?", "FORM_APP_STATUS_ERROR": "Application instable", "FORM_VAS_STATUS_ERROR": "VAS instable", diff --git a/client/less/htmlForm.less b/client/less/htmlForm.less index 99e18c281d2a56bae257aa96f5758214cc3b46c9..10480f56b30c5eefffc323ea0264d948b3675294 100755 --- a/client/less/htmlForm.less +++ b/client/less/htmlForm.less @@ -595,16 +595,3 @@ form .checkbox { .timepicker-picker > table, .bootstrap-datetimepicker-widget .picker-switch .table-condensed { margin: auto } - -// Loader ajax pour un element de formulaire. -.form-glyphicon-refresh-animate { - display: inline-block; - top: 3px !important; - left: 3px; - font-size: large; - font-weight: 800; - color: black; - -webkit-animation:spin 1.5s linear infinite; - -moz-animation:spin 1.5s linear infinite; - animation:spin 1.5s linear infinite; -} diff --git a/client/less/main.less b/client/less/main.less old mode 100644 new mode 100755 diff --git a/client/modules/vitis/forms/configuration/configuration_vitis_configuration.json b/client/modules/vitis/forms/configuration/configuration_vitis_configuration.json old mode 100644 new mode 100755 diff --git a/client/modules/vitis/forms/exploitation/exploitation_exploitation.json b/client/modules/vitis/forms/exploitation/exploitation_exploitation.json deleted file mode 100755 index a7b4cde99ba8412476eb7ffe7a66a37f9c7c9bed..0000000000000000000000000000000000000000 --- a/client/modules/vitis/forms/exploitation/exploitation_exploitation.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "search":{ - - }, - "update":{ - "name":"gtf_exploitation_shared_directory_update_form", - "title":"FORM_TITLE_EXPLOITATION_EXPLOITATION", - "initEvent":"initExploitationSharedDirectoryForm()", - "event":"", - "input_size":"xs", - "nb_cols":12, - "class":"project-directory-upload-form", - "rows":[ - { - "class":"shared-directory-treeview", - "fields":[ - { - "type":"treeview", - "name":"shared_directory", - "label":"", - "required":false, - "pattern":"", - "nb_cols":12, - "id":"shared_directory", - "options":{ - "showBorder":false, - "levels":0, - "showCheckbox":true, - "expandIcon":"glyphicon glyphicon-folder-close", - "collapseIcon":"glyphicon glyphicon-folder-open", - "highlightSelected":true, - "multiSelect":false, - "dataLoadingEvent": "sharedDirectoryTreeviewDataLoaded" - } - } - ] - }, - { - "fields":[ - { - "type":"button", - "class":"btn-ungroup btn-group-xs", - "nb_cols":12, - "buttons":[ - { - "type":"button", - "name":"btn_download_file", - "glyphicon":"download", - "class":"btn-primary btn-xs", - "event":"downloadFile()", - "tooltip": { - "title":"FORM_DOWNLOAD_FILE_EXPLOITATION_EXPLOITATION", - "placement": "bottom", - "trigger": "hover", - "container": "body" - }, - "visible":false - }, - { - "type":"button", - "name":"btn_refresh_treeview", - "glyphicon":"refresh", - "class":"btn-primary btn-xs", - "event":"refreshExploitationSharedDirectoryTreeview()", - "tooltip": { - "title":"FORM_RELOAD_DIRECTORY_EXPLOITATION_EXPLOITATION", - "placement": "bottom", - "trigger": "hover", - "container": "body" - } - }, - { - "type":"button", - "name":"btn_delete_file", - "glyphicon":"trash", - "class":"btn-primary btn-xs", - "event":"deleteSharedDirectoryFiles()", - "tooltip": { - "title":"FORM_DELETE_FILES_EXPLOITATION_EXPLOITATION", - "placement": "bottom", - "trigger": "hover" - } - } - ] - } - ] - }, - { - "class":"form-field-inline", - "fields":[ - { - "type":"upload", - "name":"file", - "label":"FORM_FILE_EXPLOITATION_EXPLOITATION", - "nb_cols":4 - }, - { - "type":"text", - "name":"directory_name", - "label":"FORM_DIRECTORY_EXPLOITATION_EXPLOITATION", - "nb_cols":4 - } - ] - }, - { - "class":"form-field-inline", - "fields":[ - { - "type":"button", - "class":"btn-ungroup btn-group-sm", - "nb_cols":4, - "buttons":[ - { - "type":"button", - "name":"btn_upload_file", - "label":"FORM_UPLOAD_FMW_FILE_EXPLOITATION_EXPLOITATION", - "event":"uploadSharedDirectoryFile()", - "class":"btn-primary" - } - ] - }, - { - "type":"button", - "class":"btn-ungroup btn-group-sm", - "nb_cols":4, - "buttons":[ - { - "type":"button", - "name":"btn_create_directory", - "label":"FORM_BTN_CREATE_DIRECTORY_EXPLOITATION_EXPLOITATION", - "event":"createSharedDirectoryFolder()", - "class":"btn-primary" - } - ] - } - ] - } - ] - }, - "insert":{ - - }, - "display":{ - "name":"gtf_exploitation_shared_directory_display_form", - "title":"FORM_TITLE_EXPLOITATION_EXPLOITATION", - "input_size":"xs", - "nb_cols":8, - "rows":[ - { - "fields":[ - { - "type":"hidden", - "name":"fmw_file", - "nb_cols":12 - } - ] - } - ] - } -} \ No newline at end of file diff --git a/client/modules/vitis/forms/user/user_vitis_user.json b/client/modules/vitis/forms/user/user_vitis_user.json old mode 100644 new mode 100755 diff --git a/client/modules/vitis/forms/users/users_vitis_users.json b/client/modules/vitis/forms/users/users_vitis_users.json old mode 100644 new mode 100755 diff --git a/client/modules/vitis/javascript/script_module.js b/client/modules/vitis/javascript/script_module.js old mode 100644 new mode 100755 index 716b8de908bc4dfb057afe25e838d92aa2463531..1f0e99b41d538a838143044510f0016012a6f4ce --- a/client/modules/vitis/javascript/script_module.js +++ b/client/modules/vitis/javascript/script_module.js @@ -1211,9 +1211,7 @@ vitisApp.on('appMainDrtvLoaded', function () { '</div>', link: function (scope, element, attrs) { - scope.$watch("row.entity." + scope["col"]["field"], function(val){ - scope.textValue = (goog.isDefAndNotNull(attrs["hidevalue"])) ? "" : val + "%"; - }); + scope.textValue = (goog.isDefAndNotNull(attrs["hidevalue"])) ? "" : scope["row"]["entity"][scope["col"]["field"]] + "%"; if (goog.isDefAndNotNull(attrs["mode"])) element[0].firstChild.className = element[0].firstChild.className + " progress-bar-" + attrs["mode"]; @@ -1695,261 +1693,4 @@ vitisApp.on('appMainDrtvLoaded', function () { envSrvc["oFormValues"][envSrvc["sFormDefinitionName"]]["tr_status_method"] = sMethod; // l'event submit du formulaire sera appelé après cette fonction }; - - /** - * loadVitisExploitation function. - * Chargement des sections du mode "exploitation". - **/ - angular.element(vitisApp.appMainDrtv).scope()["loadVitisExploitation"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var envSrvc = angular.element(vitisApp.appWorkspaceListDrtv).injector().get(["envSrvc"]); - // - $log.info("loadVitisExploitation"); - // Passage en mode "Update" (pour afficher les sections). - envSrvc["sMode"] = "update"; - }; - - /** - * initExploitationSharedDirectoryForm function. - * Chargement de l'arborescence du répertoire partagé. - **/ - angular.element(vitisApp.appMainDrtv).scope()["initExploitationSharedDirectoryForm"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var $rootScope = angular.element(vitisApp.appMainDrtv).injector().get(["$rootScope"]); - var $timeout = angular.element(vitisApp.appMainDrtv).injector().get(["$timeout"]); - var formSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["formSrvc"]); - var envSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["envSrvc"]); - // - $log.info("initExploitationSharedDirectoryForm"); - // Attends la fin de l'affichage du 1er formulaire. - var clearListener = $rootScope.$on('formExtracted', function (event) { - // Supprime le "listener". - clearListener(); - // - $timeout(function () { - $rootScope["loadExploitationSharedDirectoryTreeviewData"]().then(function(aNodes){ - $rootScope.$emit("sharedDirectoryTreeviewDataLoaded", aNodes); - }); - }); - // Huteur du treeview. - var oFormElementDefinition = formSrvc["getFormElementDefinition"]("shared_directory", envSrvc["sFormDefinitionName"]); - document.getElementById(oFormElementDefinition["id"] + "_treeview").style.height = document.getElementById("container_mode_exploitation").clientHeight - 221 + "px"; - }); - }; - - /** - * refreshExploitationSharedDirectoryTreeview function. - * Recharge les données du treeview du répertoire partagé. - **/ - angular.element(vitisApp.appMainDrtv).scope()["refreshExploitationSharedDirectoryTreeview"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var $rootScope = angular.element(vitisApp.appMainDrtv).injector().get(["$rootScope"]); - var envSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["envSrvc"]); - var formSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["formSrvc"]); - // - $log.info("refreshExploitationSharedDirectoryTreeview"); - $rootScope["loadExploitationSharedDirectoryTreeviewData"]().then(function(aNodes){ - var oFormElementDefinition = formSrvc["getFormElementDefinition"]("shared_directory", envSrvc["sFormDefinitionName"]); - var oTreeviewOptions = $("#" + oFormElementDefinition["id"] + "_treeview")["treeview"](true)["options"]; - $("#" + oFormElementDefinition["id"] + "_treeview")["treeview"](true)["remove"](); - oTreeviewOptions["data"] = aNodes; - $("#" + oFormElementDefinition["id"] + "_treeview")["treeview"](oTreeviewOptions); - // Huteur du treeview. - document.getElementById(oFormElementDefinition["id"] + "_treeview").style.height = document.getElementById("container_mode_exploitation").parentElement.clientHeight - 221 + "px"; - }); - }; - - /** - * loadExploitationSharedDirectoryTreeviewData function. - * Charge les données du treeview du répertoire partagé. - **/ - angular.element(vitisApp.appMainDrtv).scope()["loadExploitationSharedDirectoryTreeviewData"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var $q = angular.element(vitisApp.appStatisticsFormDrtv).injector().get(["$q"]); - var propertiesSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["propertiesSrvc"]); - // - $log.info("loadExploitationSharedDirectoryTreeviewData"); - var deferred = $q.defer(); - var promise = deferred.promise; - // Charge l'arborescence du répertoire partagé. - ajaxRequest({ - "method": "GET", - "url": propertiesSrvc["web_server_name"] + "/" + propertiesSrvc["services_alias"] + "/vitis/exploitations/SharedDirectory", - "success": function(response) { - if (response["data"]["status"] === 1) { - if (typeof (response["data"]) !== "undefined") - deferred.resolve(response["data"]["tree"]["data"]); - } - } - }); - return promise; - }; - - /** - * deleteSharedDirectoryFiles function. - * Charge les données du treeview du répertoire partagé. - **/ - angular.element(vitisApp.appMainDrtv).scope()["deleteSharedDirectoryFiles"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var $rootScope = angular.element(vitisApp.appMainDrtv).injector().get(["$rootScope"]); - var $translate = angular.element(vitisApp.appMainDrtv).injector().get(["$translate"]); - var propertiesSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["propertiesSrvc"]); - var envSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["envSrvc"]); - var formSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["formSrvc"]); - // - $log.info("deleteSharedDirectoryFiles"); - var oFormElementDefinition = formSrvc["getFormElementDefinition"]("shared_directory", envSrvc["sFormDefinitionName"]); - var aFileList = $("#" + oFormElementDefinition["id"] + "_treeview")["treeview"](true)["getChecked"](); - if (aFileList.length > 0) { - var oOptions = { - "className": "modal-warning", - "message": "CONFIRM_DELETE_FILES_EXPLOITATION_EXPLOITATION", - "callback": function(bResponse) { - if (bResponse) { - // Liste des fichiers et répertoires à supprimer. - var aFilePathList = []; - for (var i = 0; i < aFileList.length; i++) { - if (typeof(aFileList[i]["path"]["nodes"] != "undefined")) - aFilePathList.push(aFileList[i]["path"]); - else - aFilePathList.push(aFileList[i]["path"] + "/" + aFileList[i]["name"]); - } - // Suppression des fichiers et répertoires. - ajaxRequest({ - "method": "DELETE", - "url": propertiesSrvc["web_server_name"] + "/" + propertiesSrvc["services_alias"] + "/vitis/exploitations/SharedDirectory", - "params": { - "idList": aFilePathList.join("|") - }, - "success": function(response) { - if (response["data"]["status"] == 1) { - // Message et rechargement du treeview. - $translate("SUCCESSFUL_OPERATION").then(function (sTranslation) { - $.notify(sTranslation, "success"); - $rootScope["refreshExploitationSharedDirectoryTreeview"](); - }); - } - else { - // Affichage de la fenêtre modale d'erreur. - $rootScope["modalWindow"]("dialog", response["data"]["errorMessage"], {"className": "modal-danger"}); - } - } - }); - } - } - } - $rootScope["modalWindow"]("confirm", "", oOptions); - } - }; - - /** - * createSharedDirectoryFolder function. - * Création d'un répertoire dans le répertoire partagé. - **/ - angular.element(vitisApp.appMainDrtv).scope()["createSharedDirectoryFolder"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var $translate = angular.element(vitisApp.appMainDrtv).injector().get(["$translate"]); - var $rootScope = angular.element(vitisApp.appMainDrtv).injector().get(["$rootScope"]); - var propertiesSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["propertiesSrvc"]); - var envSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["envSrvc"]); - var formSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["formSrvc"]); - // - $log.info("createSharedDirectoryFolder"); - // Si un répertoire est sélectionné -> création à l'intérieur. - var sDirectoryPath = envSrvc["oFormValues"][envSrvc["sFormDefinitionName"]]["directory_name"]; - if (typeof(sDirectoryPath) == "string" && sDirectoryPath != "") { - var oFormElementDefinition = formSrvc["getFormElementDefinition"]("shared_directory", envSrvc["sFormDefinitionName"]); - var aFileList = $("#" + oFormElementDefinition["id"] + "_treeview")["treeview"](true)["getSelected"](); - if (aFileList.length > 0) - sDirectoryPath = aFileList[0]["path"] + "/" + sDirectoryPath; - // - var formData = new FormData(); - formData.append("directory_path", sDirectoryPath); - ajaxRequest({ - "method": "POST", - "url": propertiesSrvc["web_server_name"] + "/" + propertiesSrvc["services_alias"] + "/vitis/exploitations/SharedDirectory/Directory", - "data": formData, - "success": function(response) { - if (response["data"]["status"] == 1) { - // Message et rechargement du treeview. - $translate("SUCCESSFUL_OPERATION").then(function (sTranslation) { - $.notify(sTranslation, "success"); - $rootScope["refreshExploitationSharedDirectoryTreeview"](); - var sFormElementName = envSrvc['oFormDefinition'][envSrvc['sFormDefinitionName']]['name']; - document.querySelector("form[name='" + sFormElementName + "']").reset(); - }); - } - else { - // Affichage de la fenêtre modale d'erreur. - $rootScope["modalWindow"]("dialog", response["data"]["errorMessage"], {"className": "modal-danger"}); - } - } - }); - } - else { - // Affichage de la fenêtre modale d'erreur. - $rootScope["modalWindow"]("dialog", "FORM_NO_DIRECTORY_EXPLOITATION_EXPLOITATION", {"className": "modal-danger"}); - } - }; - - /** - * uploadSharedDirectoryFile function. - * Upload d'un fichier dans le répertoire partagé. - **/ - angular.element(vitisApp.appMainDrtv).scope()["uploadSharedDirectoryFile"] = function () { - // Injection des services. - var $log = angular.element(vitisApp.appMainDrtv).injector().get(["$log"]); - var $translate = angular.element(vitisApp.appMainDrtv).injector().get(["$translate"]); - var $rootScope = angular.element(vitisApp.appMainDrtv).injector().get(["$rootScope"]); - var propertiesSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["propertiesSrvc"]); - var envSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["envSrvc"]); - var formSrvc = angular.element(vitisApp.appMainDrtv).injector().get(["formSrvc"]); - // - $log.info("uploadSharedDirectoryFile"); - // Si un fichier est sélectionné -> upload. - var oFile = envSrvc["oFormValues"][envSrvc["sFormDefinitionName"]]["file"]; - if (typeof(oFile) != "undefined" && oFile["aFiles"].length > 0) { - // Upload dans un répertoire. - var sDirectoryPath = ""; - var oFormElementDefinition = formSrvc["getFormElementDefinition"]("shared_directory", envSrvc["sFormDefinitionName"]); - var aFileList = $("#" + oFormElementDefinition["id"] + "_treeview")["treeview"](true)["getSelected"](); - if (aFileList.length > 0) - sDirectoryPath = aFileList[0]["path"]; - // Création du formdata. - var formData = new FormData(); - formData.append("file", oFile["aFiles"][0]); - formData.append("directory_path", sDirectoryPath); - // - ajaxRequest({ - "method": "POST", - "url": propertiesSrvc["web_server_name"] + "/" + propertiesSrvc["services_alias"] + "/vitis/exploitations/SharedDirectory/File", - "data": formData, - "success": function(response) { - if (response["data"]["status"] == 1) { - // Message, rechargement du treeview, vidage du formulaire. - $translate("SUCCESSFUL_OPERATION").then(function (sTranslation) { - $.notify(sTranslation, "success"); - $rootScope["refreshExploitationSharedDirectoryTreeview"](); - var sFormElementName = envSrvc['oFormDefinition'][envSrvc['sFormDefinitionName']]['name']; - document.querySelector("form[name='" + sFormElementName + "']").reset(); - }); - } - else { - // Affichage de la fenêtre modale d'erreur. - $rootScope["modalWindow"]("dialog", response["data"]["errorMessage"], {"className": "modal-danger"}); - } - } - }); - } - else { - // Affichage de la fenêtre modale d'erreur. - $rootScope["modalWindow"]("dialog", "FORM_NO_FILE_EXPLOITATION_EXPLOITATION", {"className": "modal-danger"}); - } - }; }); \ No newline at end of file diff --git a/client/modules/vitis/lang/lang-en.json b/client/modules/vitis/lang/lang-en.json old mode 100644 new mode 100755 index dc98a487ebd474dde8d906521ce10687fd6b5a2f..c8132242ba9258b6005e2fd7d9f502e8311efd72 --- a/client/modules/vitis/lang/lang-en.json +++ b/client/modules/vitis/lang/lang-en.json @@ -326,21 +326,5 @@ "FORM_BILLINGGROUP_USERS_BILLINGGROUP": "Name", "FORM_DESCRIPTION_USERS_BILLINGGROUP": "Description", "FORM_AVAILABLE_USER_USERS_BILLINGGROUP": "Available users", - "FORM_LINKED_USER_USERS_BILLINGGROUP": "Users linked to group", - "" : "", - "FORM_TITLE_EXPLOITATION_EXPLOITATION" : "Shared directory", - "FORM_DOWNLOAD_FILE_EXPLOITATION_EXPLOITATION" : "Download file", - "FORM_RELOAD_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Reload directory", - "FORM_DELETE_FILES_EXPLOITATION_EXPLOITATION" : "Delete files", - "FORM_UPLOAD_FMW_FILE_EXPLOITATION_EXPLOITATION" : "Upload", - "FORM_FILE_EXPLOITATION_EXPLOITATION" : "File to upload", - "CONFIRM_DELETE_FILES_EXPLOITATION_EXPLOITATION" : "Delete selected files and directories ?", - "FORM_CREATE_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Create a directory", - "FORM_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Name of the directory to create", - "FORM_BTN_UPLOAD_FILE_EXPLOITATION_EXPLOITATION" : "Upload", - "FORM_BTN_CREATE_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Create", - "FORM_NO_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Please specify a name for the directory to create", - "FORM_NO_FILE_EXPLOITATION_EXPLOITATION" : "Please select a file to upload", - "DIRECTORY_CREATION_ERROR_EXPLOITATION_EXPLOITATION" : "Directory creation error", - "FILE_UPLOAD_ERROR_EXPLOITATION_EXPLOITATION" : "File creation error" + "FORM_LINKED_USER_USERS_BILLINGGROUP": "Users linked to group" } diff --git a/client/modules/vitis/lang/lang-fr.json b/client/modules/vitis/lang/lang-fr.json old mode 100644 new mode 100755 index c752c00a89122b4ccf90a5bb275a952f7ebfc775..a25cbd86a472840b7cd34f0aeb4db57686e83610 --- a/client/modules/vitis/lang/lang-fr.json +++ b/client/modules/vitis/lang/lang-fr.json @@ -328,21 +328,5 @@ "FORM_BILLINGGROUP_USERS_BILLINGGROUP": "Nom", "FORM_DESCRIPTION_USERS_BILLINGGROUP": "Description", "FORM_AVAILABLE_USER_USERS_BILLINGGROUP": "Utilisateurs disponibles", - "FORM_LINKED_USER_USERS_BILLINGGROUP": "Utilisateurs liés au groupe", - "" : "", - "FORM_TITLE_EXPLOITATION_EXPLOITATION" : "Répertoire partagé", - "FORM_DOWNLOAD_FILE_EXPLOITATION_EXPLOITATION" : "Télécharger le fichier", - "FORM_RELOAD_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Recharger le répertoire", - "FORM_DELETE_FILES_EXPLOITATION_EXPLOITATION" : "Supprimer les fichiers", - "FORM_UPLOAD_FMW_FILE_EXPLOITATION_EXPLOITATION" : "Uploader", - "FORM_FILE_EXPLOITATION_EXPLOITATION" : "Fichier à uploader", - "CONFIRM_DELETE_FILES_EXPLOITATION_EXPLOITATION" : "Supprimer les fichiers et répertoires sélectionnés ?", - "FORM_CREATE_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Créer un dossier", - "FORM_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Nom du dossier à créer", - "FORM_BTN_UPLOAD_FILE_EXPLOITATION_EXPLOITATION" : "Uploader", - "FORM_BTN_CREATE_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Créer", - "FORM_NO_DIRECTORY_EXPLOITATION_EXPLOITATION" : "Veuiller spécifier un nom pour le dossier à créer", - "FORM_NO_FILE_EXPLOITATION_EXPLOITATION" : "Veuiller sélectionner un fichier à uploader", - "DIRECTORY_CREATION_ERROR_EXPLOITATION_EXPLOITATION" : "Erreur de création du dossier", - "FILE_UPLOAD_ERROR_EXPLOITATION_EXPLOITATION" : "Erreur pendant l'upload du fichier" + "FORM_LINKED_USER_USERS_BILLINGGROUP": "Utilisateurs liés au groupe" } diff --git a/client/modules/vitis/less/main.less b/client/modules/vitis/less/main.less index bbfd6cb88daa780124cac53154b6278d493816d8..66adeeb6954871428c3685880d1a6a9bbb8ee302 100755 --- a/client/modules/vitis/less/main.less +++ b/client/modules/vitis/less/main.less @@ -7,5 +7,4 @@ @import 'updateConfiguration.less'; @import 'users.less'; @import 'activeDirectoryTree.less'; -@import 'webServiceHelp.less'; -@import 'sharedDirectory.less'; \ No newline at end of file +@import 'webServiceHelp.less'; \ No newline at end of file diff --git a/client/modules/vitis/less/sharedDirectory.less b/client/modules/vitis/less/sharedDirectory.less deleted file mode 100755 index 7672659599a8c4ad76d0f469e8114d4202d7a937..0000000000000000000000000000000000000000 --- a/client/modules/vitis/less/sharedDirectory.less +++ /dev/null @@ -1,3 +0,0 @@ -.shared-directory-treeview .treeview { - overflow-y: auto; -} \ No newline at end of file diff --git a/vas/doc/index.phtml b/vas/doc/index.phtml index 086cb768856aca4ecc21b4767186d05547388f71..d4fedf02fc3fd79b18c6da0ffab7f8110a02c8e3 100755 --- a/vas/doc/index.phtml +++ b/vas/doc/index.phtml @@ -1,6 +1,9 @@ <?php session_start(); -require_once '../rest/conf/properties.inc'; + +$_SERVER['VAS_PATH'] = pathinfo(dirname($_SERVER['SCRIPT_FILENAME']))['dirname']; + +require_once $_SERVER['VAS_PATH'] . '/rest/conf/properties.inc'; function returnOverview($sFolder, $parent) { $aModules = array(); @@ -17,10 +20,12 @@ function returnOverview($sFolder, $parent) { } } } + return $aModules; } -$aOverview = returnOverview(__DIR__ . "/../rest/ws", ""); +$aOverview = returnOverview($_SERVER['VAS_PATH'] . "/rest/ws", ""); +error_log('$aOverview: '. print_r($aOverview, true)); ?> <!DOCTYPE html> @@ -59,7 +64,7 @@ $aOverview = returnOverview(__DIR__ . "/../rest/ws", ""); sToken = json.PrivateToken.token; } else { sToken = code[0].outerText.split('<token>')[1].split('</token>')[0]; - } + } if (sToken != "") { $("input[name='token']").each(function () { $(this).attr("value", sToken); @@ -154,4 +159,3 @@ foreach ($aOverview as $key => $value) { </div> </body> </html> - diff --git a/vas/doc/swagger.php b/vas/doc/swagger.php index 3437171a291a5f277b6518b72ff0afdd04f8dab5..aca8acffc87a164aedf500bb1f31effd57cf8e5c 100755 --- a/vas/doc/swagger.php +++ b/vas/doc/swagger.php @@ -1,8 +1,9 @@ <?php +$_SERVER['VAS_PATH'] = pathinfo(dirname($_SERVER['SCRIPT_FILENAME']))['dirname']; header('Content-Type: application/json'); -require_once "../rest/conf/properties.inc"; +require_once $_SERVER['VAS_PATH'] . "/rest/conf/properties.inc"; require("vendor/autoload.php"); -$swagger = \Swagger\scan('../rest/ws/'.$_REQUEST['service']); +$swagger = \Swagger\scan($_SERVER['VAS_PATH'] . '/rest/ws/'.$_REQUEST['service']); $aServer = explode("://", $properties["web_server_name"]); $swagger = str_replace("[service_alias]", $properties["services_alias"], $swagger); $swagger = str_replace("[protocol]", $aServer[0], $swagger); diff --git a/vas/rest/class/aws_lib/AmazonAWS.class.inc b/vas/rest/class/aws_lib/AmazonAWS.class.inc old mode 100644 new mode 100755 index 223a0534b6262627e65631e7905eb9256825f8b9..67f30140fb630544249a97969ea0e7b51f7259c1 --- a/vas/rest/class/aws_lib/AmazonAWS.class.inc +++ b/vas/rest/class/aws_lib/AmazonAWS.class.inc @@ -13,7 +13,6 @@ Class AmazonAWS { public $sAwsRegion; public $aLastCurlRequestInfo; public $sHost; - public $sLogFilePath; // Chemin optionnel vers le fichier de log pour Amazon S3. private $sAwsAccessKeyId; private $sAwsSecretAccessKey; private $sHashingAlgorithmString; @@ -468,18 +467,5 @@ Class AmazonAWS { function generateAuthorizationHeader($sAlgorithm, $sCredentialScope, $sSignedHeaders, $sSignature) { return $sAlgorithm . ' Credential=' . $this->sAwsAccessKeyId . '/' . $sCredentialScope . ', SignedHeaders=' . $sSignedHeaders . ', Signature=' . $sSignature; } - - /** - * Write a message to the error log file. - * @param {string} $sMessage Message to write to the log file. - */ - function writeToErrorLog($sMessage) { - $aDebugBacktrace = debug_backtrace(); - $sLogMessage = '|ERROR|' . $aDebugBacktrace[1]['class'] . '::' . $aDebugBacktrace[1]['function'] . '| ' . $sMessage; - if (empty($this->sLogFilePath)) - writeToErrorLog($sLogMessage); - else - writeToLog($sLogMessage, $this->sLogFilePath); - } } ?> \ No newline at end of file diff --git a/vas/rest/class/aws_lib/AmazonS3.class.inc b/vas/rest/class/aws_lib/AmazonS3.class.inc old mode 100644 new mode 100755 index 32c7ed76f933ba2499f7cfa63c4a943cb4fa6bd9..f9bfdb4dcc555ceb4122ffec2b794e4a3180b82f --- a/vas/rest/class/aws_lib/AmazonS3.class.inc +++ b/vas/rest/class/aws_lib/AmazonS3.class.inc @@ -102,6 +102,9 @@ Class AmazonS3 extends AmazonAWS { } $sFullUrl = $sMethod . ' ' . $sUrl . ' HTTP/1.1'; + + error_log($sFullUrl); + return $this->generateAwsSignedHeaders($sFullUrl, $sBucketHost, self::API_COMPONENT_SERVICE, $aHeaders, $sRequestPayload, true, 'Now', true); } @@ -168,10 +171,8 @@ Class AmazonS3 extends AmazonAWS { // Transfert cURL. $sRequestResult = $this->curlRequest($sUrl, $sMethod, null, $aHeaders); // - if ($this->aLastCurlRequestInfo['http_code'] != 200) { - $this->writeToErrorLog($this->formatS3ErrorMessage($sRequestResult)); - return false; - } + if ($this->aLastCurlRequestInfo['http_code'] != 200) + writeToErrorLog($sRequestResult); else { if (!empty($sFilePath)) file_put_contents($sFilePath, $sRequestResult); @@ -190,23 +191,24 @@ Class AmazonS3 extends AmazonAWS { function uploadFile($sBucket, $sKey, $sFilePath) { if (file_exists($sFilePath)) { $sFileName = pathinfo($sFilePath, PATHINFO_BASENAME); + // Url vers le fichier. $sUrl = 'https://' . $sBucket . '.' . $this->sHost; + // Génération des entêtes pour la requete. $aPostData = $this->generatePostData($sBucket, $sKey); $aPostData['Content-Type'] = mime_content_type($sFilePath); $aPostData['file'] = new CurlFile(realpath($sFilePath), $aPostData['Content-Type'], $sFileName); + $aHeaders = array( 'Content-Type: multipart/form-data', ); + $sRequestResult = $this->curlRequest($sUrl, 'post', $aPostData, $aHeaders, true); - if ($this->aLastCurlRequestInfo['http_code'] != 204) { - $this->writeToErrorLog($this->formatS3ErrorMessage($sRequestResult)); - return false; - } + + if ($this->aLastCurlRequestInfo['http_code'] != 204) + writeToErrorLog($sRequestResult); } - else - return false; } /** @@ -227,12 +229,10 @@ Class AmazonS3 extends AmazonAWS { $aHeaders = $this->generateS3requestHeaders($sMethod, $sUrl, $sBucket, array('Content-Type: application/x-www-form-urlencoded'), ''); // Transfert cURL. $sRequestResult = $this->curlRequest($sUrl, $sMethod, null, $aHeaders); - if ($this->aLastCurlRequestInfo['http_code'] != 200) { - $this->writeToErrorLog("ERROR: ScanDir can't scan this prefix or this bucket"); - $this->writeToErrorLog($this->formatS3ErrorMessage($sRequestResult)); - return false; - } - else { + //error_log($sRequestResult); + if ($this->aLastCurlRequestInfo['http_code'] != 200){ + writeToErrorLog("ERROR: ScanDir can't scan this prefix or this bucket"); + } else { $oXMLContent= json_decode(json_encode(simplexml_load_string($sRequestResult)), true); $oFiles = $this->awsObjectListXmlToTree($oXMLContent, $bWithFileInfos); } @@ -332,44 +332,14 @@ Class AmazonS3 extends AmazonAWS { // Transfert cURL. $sRequestResult = $this->curlRequest($sUrl, $sMethod, null, $aHeaders); - if ($this->aLastCurlRequestInfo['http_code'] != 200) { - $this->writeToErrorLog("ERROR: it's impossible to delete this key in this bucket"); - $this->writeToErrorLog($this->formatS3ErrorMessage($sRequestResult)); - } else + if ($this->aLastCurlRequestInfo['http_code'] != 200){ + writeToErrorLog("ERROR: it's impossible to delete this key in this bucket"); + } else { $bReturn = true; + error_log($sRequestResult); + } return $bReturn; } - - /** - * Convert an error message returned by s3 (xml to object). - * @param {string} $sXmlErrorMessage Error message returned by s3 (xml format). - * @return object S3 Error - */ - function getS3ErrorObject($sXmlErrorMessage) { - $oSimpleXmlElement = simplexml_load_string($sXmlErrorMessage); - if (is_object($oSimpleXmlElement)) { - $oErrorMessage = new stdClass(); - foreach ($oSimpleXmlElement as $sProperty => $oValue) { - $oErrorMessage->$sProperty = $oValue->__toString(); - } - return $oErrorMessage; - } - else - return false; - } - - /** - * Format an error message returned by s3. - * @param {string} $sXmlErrorMessage Error message returned by s3 (xml format). - * @return string Error message - */ - function formatS3ErrorMessage($sXmlErrorMessage) { - $oErrorMessage = $this->getS3ErrorObject($sXmlErrorMessage); - if ($oErrorMessage !== false) - return ($oErrorMessage->Code . ' : ' . $oErrorMessage->Message); - else - return $sXmlErrorMessage; - } } ?> \ No newline at end of file diff --git a/vas/rest/class/vitis_lib/VitisError.class.inc b/vas/rest/class/vitis_lib/VitisError.class.inc index 1c52cfaa95a3a0479a910281e35cde8f25376703..0d61f69fcd02cf3cf89e8758a57bb2723d85eef4 100644 --- a/vas/rest/class/vitis_lib/VitisError.class.inc +++ b/vas/rest/class/vitis_lib/VitisError.class.inc @@ -4,7 +4,7 @@ require_once(__DIR__."/DbClass.class.inc"); class VitisError extends DbClass { - function __construct($iErrorId, $sErrorMessage="", $sMessage = ''){ + function __construct($iErrorId, $sMessage=""){ $this->aFields['errorCode']=$iErrorId; switch ($iErrorId){ case 1 : @@ -57,17 +57,9 @@ class VitisError extends DbClass { break; case 18 : $this->aFields['errorType']="Missing privileges"; - case 17 : - $this->aFields['errorType']="The request returned an error"; - break; - case 19 : - $this->aFields['errorType']="The database is unreachable"; break; } - $this->aFields['errorMessage']=$sErrorMessage; //Message renvoyé par la base de donnée - // Message d'erreur additionnel. - if (!empty($sMessage)) - $this->aFields['message'] = $sMessage; + $this->aFields['errorMessage']=$sMessage; //Message renvoyé par la base de donnée } } ?> \ No newline at end of file diff --git a/vas/rest/class/vmlib/BD.class.inc b/vas/rest/class/vmlib/BD.class.inc old mode 100644 new mode 100755 diff --git a/vas/rest/class/vmlib/error.inc b/vas/rest/class/vmlib/error.inc old mode 100644 new mode 100755 index 13db7b08ff362840fee0ef2bd2d8b84d0c63b52b..b36e043d301409462ee479bed0ea211463bb8a54 --- a/vas/rest/class/vmlib/error.inc +++ b/vas/rest/class/vmlib/error.inc @@ -19,10 +19,6 @@ define('ERROR_0008', "ERROR - Aucune méthode n'a permis d'affecté un moteur au // define('ERROR_0009', "ERROR - L'algorithme ne permet pas de retourner un numéro de moteur exploitable. Le numéro de moteur retourné n'est pas de type entier. Type de la valeur retournée par la méthode : "); // define('ERROR_0010', "ERROR - Le numéro du moteur retourné par l'algorithme n'existe pas dans la liste des moteurs disponible dans GTF."); define('ERROR_0011', "Erreur Le fichier [_FILES[sNomObjet][name]] n'est pas téléchargé sur le serveur"); -define('ERROR_0035', "Erreur de la suppression d'un processus d'une demande stoppée"); -define('ERROR_0036', "Erreur de la commande d'information d'un processus d'une demande stoppée"); -define('ERROR_0037', "Erreur pendant l'arrêt de la demande sur Fme Desktop."); -define('ERROR_0038', "Erreur pendant l'arrêt de la demande sur Fme Server."); // veremap/DownloadMaj.class.inc define('ERROR_0012', "Unable to write file"); diff --git a/vas/rest/class/vmlib/logUtil.inc b/vas/rest/class/vmlib/logUtil.inc old mode 100644 new mode 100755 index d7474ff379d5a0cf1850ac78f8ab2f5712560450..f1334250b8024768910a30fecc9ac5a58b72f681 --- a/vas/rest/class/vmlib/logUtil.inc +++ b/vas/rest/class/vmlib/logUtil.inc @@ -7,7 +7,7 @@ * Fonctions de mise en place de logs * * \author Olivier Gayte <olivier.gayte@veremes.com> - * \author Frédéric Mauro + * \author Fr�d�ric Mauro */ /* * Variable globale stockant une erreur. @@ -20,8 +20,8 @@ $sMessageLogError = ""; $sFolderLib = "vmlib"; /** * Converti une chaine ISO-8859-1 en UTF-8 - * \param $sString Chaîne de caractères à convertir. - * \return une chaine encodée en UTF-8 + * \param $sString Cha�ne de caract�res � convertir. + * \return une chaine encod�e en UTF-8 */ /* function Latin1ToUtf8($sString){ if( mb_detect_encoding($sString,"UTF-8, ISO-8859-1")!="UTF-8" ){ @@ -52,45 +52,22 @@ function writeToLog($sString, $sFileName) { return false; global $properties, $sMessageLogError, $sFolderLib; - // Si le répertoire de log n'existe pas : création + // Fred 05/06/2013 : Si le r�pertoire de log n'existe pas : cr�ation if (!is_dir(dirname($sFileName))) mkdir(dirname($sFileName), 0777, true); if (empty(pathinfo($sFileName, PATHINFO_EXTENSION))) return false; - - // Add Date and User informations before writing message in log file + loadLang($sFolderLib, $properties["language"], $sFolderLib . "/"); $sString = str_replace(chr(13), '[\n]', $sString); $sString = str_replace(chr(10), '[\n]', $sString); + $handle = fopen($sFileName, 'a'); if(isset($_SESSION['ses_Login']) && isset($_SERVER['REMOTE_ADDR']) && isset($_SERVER['REMOTE_PORT'])){ $sPrelog = date("d/n/Y H:i:s").' '.$_SESSION['ses_Login'].' '.$_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT']; } else { $sPrelog = date("d/n/Y H:i:s"); } - - $sMessageLogtoWrite = $sPrelog . $properties["log_delim"] . $sString . CR . LF; - - // Rename old file if greater than porperties log_size (maximum log size to open it through app in Kb) - // Get size of Log file in bytes - $iLogFileSize = filesize($sFileName); - - if($iLogFileSize !== false){ - // get size of log message - $iMessageLength = strlen($sMessageLogtoWrite); - $iTotalSizeKb = ($iLogFileSize + $iMessageLength) / 1024; - // compare with porperties log_size (maximum log size to open it through app in Kb) - if($iTotalSizeKb >= $properties['log_size'] - 1){ - // Rename of the original file to split log and keep the possibility to read it through application - $sFileSplitName = str_replace(".log", "." . date("Y_m_d_U") . ".log", $sFileName); - if(!rename($sFileName, $sFileSplitName)){ - $sMessageLogError = ERROR_IMPOSSIBLE_WRITE . $sFileName . ERROR_RIGHTS_ON_FILE . " (" . $sString . ")."; - } - } - } - - // create if needed and open log file to write log message inside. - $handle = fopen($sFileName, 'a'); - if (fwrite($handle, $sMessageLogtoWrite) === false) { + if (fwrite($handle, $sPrelog . $properties["log_delim"] . $sString . CR . LF) === false) { fclose($handle); if (is_writable($sFileName)) { $sMessageLogError = ERROR_IMPOSSIBLE_WRITE . $sFileName . ERROR_RIGHTS_ON_FILE . " (" . $sString . ")."; diff --git a/vas/rest/class/vmlib/phpUtil.inc b/vas/rest/class/vmlib/phpUtil.inc index dee4b832527ccda3d2af6ca01b50acc49085d063..08c287ba00d806bb737927d08cdc2a9f5ca93229 100755 --- a/vas/rest/class/vmlib/phpUtil.inc +++ b/vas/rest/class/vmlib/phpUtil.inc @@ -203,10 +203,9 @@ function getFileName($sFullFileName) { *@file vmlib/phpUtil.inc *@param string $sFolder *@param string $sDestination - *@param string $sPassword *@return boolean */ -function createZip($sFolder, $sDestination, $sExtensionToExclude = '', $sPassword = '', $bDeleteFiles = false) { +function createZip($sFolder, $sDestination, $sExtensionToExclude = '') { if (!empty($sExtensionToExclude)) { $aExtensionToExclude = explode('|', $sExtensionToExclude); } else { @@ -223,7 +222,6 @@ function createZip($sFolder, $sDestination, $sExtensionToExclude = '', $sPasswor $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($sFolder), RecursiveIteratorIterator::LEAVES_ONLY ); - $aCompressedFiles = array(); foreach ($files as $name => $file) { if (!$file->isDir()) { $filePath = $file->getRealPath(); @@ -236,23 +234,12 @@ function createZip($sFolder, $sDestination, $sExtensionToExclude = '', $sPasswor if (in_array($sExtension, $aExtensionToExclude)) { continue; } - if ($zip->addFile($filePath, $relativePath)) - $aCompressedFiles[] = $filePath; - // Mot de passe. - if (!empty($sPassword)) - $zip->setEncryptionName($oFileInfo->getFilename(), ZipArchive::EM_AES_256, $sPassword); + $zip->addFile($filePath, $relativePath); } } - if ($zip->close()) { - // Suppression des fichiers compressés. - if ($bDeleteFiles) { - foreach ($aCompressedFiles as $sFilePath) { - if (file_exists($sFilePath)) - unlink($sFilePath); - } - } - } + $zip->close(); + return file_exists($sDestination); } diff --git a/vas/rest/class/wab_lib/BusinessObject.class.inc b/vas/rest/class/wab_lib/BusinessObject.class.inc index 36ae854ee3dd0789c11f938c6eba90dda09a36bf..34c24838743268ee7a5b0f40694ddb4094775403 100755 --- a/vas/rest/class/wab_lib/BusinessObject.class.inc +++ b/vas/rest/class/wab_lib/BusinessObject.class.inc @@ -21,6 +21,7 @@ class WabBusinessObject { protected $aSql = array(); protected $bNoError = true; protected $sErrorMessage; + protected $aLastCurlRequestInfo = ""; /* * **************************************************** Class constructor @@ -31,7 +32,7 @@ class WabBusinessObject { public function __construct($oBd, $aTableInfo, $aValues, $aProperties, $className, $iId = null) { require 'BusinessObject.class.sql.inc'; - //$this->aTableInfo = $aTableInfo; + $this->aTableInfo = $aTableInfo; $this->oBd = $oBd; $this->aValues = $aValues; $this->aProperties = $aProperties; @@ -40,30 +41,12 @@ class WabBusinessObject { $this->history = ""; } - /* * **************************************************** - Sauve l'action réalisé par l'utilisateur - \sEvent : action réalisé (changement de statut...) - * **************************************************** */ - - private function addHistoryEvent($sEvent) { - $this->history .= date('d/m/Y H:i') . ' | ' . $_SESSION['ses_Login'] . ' | ' . $sEvent . PHP_EOL; - } - /* * **************************************************** + /* ***************************************************** Change le statut \sStatus : statut * **************************************************** */ -/* - protected function setStatus($sStatus) { - // Mode insertion ? - if (!empty($this->iId)) - $this->bo_id = $this->iId; - // - $this->status = $sStatus; - $this->addHistoryEvent($this->status); - $this->save(); - } -*/ + public function wabSetStatus($sSchema, $sTable, $sBoNameField, $mBoIdValue, $sStatusName, $sView = '') { require 'BusinessObject.class.sql.inc'; @@ -79,20 +62,24 @@ class WabBusinessObject { ); $oResultat = $this->oBd->executeWithParams($aSQL["getStatusId"], $aParams); - $this->status = $this->oBd->objetSuivant($oResultat)->status_id; + //$this->status = $this->oBd->objetSuivant($oResultat)->status_id; + $oStatus = $this->oBd->objetSuivant($oResultat); // ajout historique - $this->addHistoryEvent($this->status); - // UPDATE dans la table avec le boName + //$this->addHistoryEvent($this->status); + //$this->addHistoryEvent($oStatus->name); + // UPDATE dans la table avec le boName $sSql = $aSQL["updateStatus"]; $aParams = array( "SCHEMA" => array("value"=> $sSchema, "type"=> 'column_name'), "TABLE" => array("value"=> $sView, "type"=> 'column_name'), - "STATUS_ID" => array("value"=> $this->status, "type"=> 'number'), + "STATUS_ID" => array("value"=> $oStatus->status_id, "type"=> 'number'), "BOIDFIELD" => array("value"=> $sBoNameField, "type"=> 'column_name'), "BOID" => array("value"=> $mBoIdValue, "type"=> 'number') ); $this->oBd->executeWithParams($sSql, $aParams); + + $this->aValues["status_id"] = $oStatus->status_id; } public function wabGetStatus($sSchema, $sTable, $sBoNameField, $mBoIdValue) { @@ -109,13 +96,28 @@ class WabBusinessObject { $oResultat = $this->oBd->executeWithParams($sSql, $aParams); return $this->oBd->objetSuivant($oResultat)->name; } + + public function wabGetObject($sSchema, $sTable, $sBoNameField, $mBoIdValue){ + require 'BusinessObject.class.sql.inc'; + $aParams = array( + "SCHEMA" => array("value"=> $sSchema, "type"=> 'column_name'), + "TABLE" => array("value"=> $sTable, "type"=> 'column_name'), + "BOIDFIELD" => array("value"=> $sBoNameField, "type"=> 'column_name'), + "BOID" => array("value"=> $mBoIdValue, "type"=> 'number') + ); + + $oResultat = $this->oBd->executeWithParams($aSQL["getBoValues"], $aParams); + $oFields = (array) $this->oBd->objetSuivant($oResultat); + + return $oFields; + } /* * ******************************************************************** Ajoute une note \sLineAttribute : Champ de form. contenant la note à ajouter \sNoteAttribute : Champ de form. contenant l'historique des notes * ******************************************************************** */ - protected function addNote($sLineAttribute, $sNoteAttribute) { + public function addNote($sLineAttribute, $sNoteAttribute) { if (!empty($this->aValues[$sLineAttribute])) { // Mode insertion ? if (!empty($this->iId)) @@ -221,8 +223,10 @@ class WabBusinessObject { * ******************************************************************** */ function save() { - $aValues = $this->getClassParameters(); - $this->oBd->update($this->aTableInfo['schema_name'], str_replace($this->aTableInfo["module"] . "_", "", $this->aTableInfo['name']), $aValues, $this->aTableInfo['id_field'], $this->bo_id, $this->aTableInfo['id_field_type']); + //$aValues = $this->getClassParameters(); + //$this->oBd->update($this->aTableInfo['schema_name'], str_replace($this->aTableInfo["module"] . "_", "", $this->aTableInfo['name']), $aValues, $this->aTableInfo['id_field'], $this->bo_id, $this->aTableInfo['id_field_type']); + $aValues = $this->getClassParameters(); + $this->oBd->update($this->aTableInfo['schema_name'], $this->aTableInfo['name'], $aValues, $this->aTableInfo['id_field'], $this->bo_id, $this->aTableInfo['id_field_type']); } /* * ******************************************************************** @@ -253,44 +257,38 @@ class WabBusinessObject { $bNoError = true; - if($properties['web_server_name'] === "[HTTP_HOST]"){ - $properties['web_server_name'] = "https://localhost"; - } - - // Get token - $sToken = $this->getToken(); - - if ($sToken !== false) { - - //get workspace id - $sSQL = "SELECT workspace_id FROM [SCHEMA_GTF].workspace WHERE key = [WK_KEY];"; - $aParams = array( - "SCHEMA_GTF" => array('value'=> $this->aProperties["schema_gtf"], 'type' => 'column_name'), - "WK_KEY" => array('value'=> $sWorkspaceKey, 'type' => 'string'), - ); - $oWK = $this->oBd->executeWithParams($sSQL, $aParams); - // oBd en erreur - $iWKid = $this->oBd->objetSuivant ($oWK)->workspace_id; - // Insertion de la demande - $sUrl = $this->aProperties['web_server_name'] . '/' . $this->aProperties['services_alias'] . '/gtf/userorders'; - $postfields = array( - 'token'=>$sToken, - 'order_date' => date('Y-m-d'), - 'workspace_id'=>$iWKid, - 'priority_id'=>$iPriorityId, - 'email_option_id'=>$iEmailOptionId, - 'wk_params'=>$sWkParams, - 'xslstylesheet'=>$sXslStyleSheet - ); + //get workspace id + $sSQL = "SELECT workspace_id FROM [SCHEMA_GTF].workspace WHERE key = [WK_KEY];"; + $aParams = array( + "SCHEMA_GTF" => array('value'=> $this->aProperties["schema_gtf"], 'type' => 'column_name'), + "WK_KEY" => array('value'=> $sWorkspaceKey, 'type' => 'string'), + ); + $oWK = $this->oBd->executeWithParams($sSQL, $aParams); + // oBd en erreur + $iWKid = $this->oBd->objetSuivant ($oWK)->workspace_id; + // Insertion de la demande + $sUrl = $this->aProperties['web_server_name'] . '/' . $this->aProperties['services_alias'] . '/gtf/userorders'; + $postfields = array( + //'token'=>$sToken, + 'order_date' => date('Y-m-d'), + 'workspace_id'=>$iWKid, + 'priority_id'=>$iPriorityId, + 'email_option_id'=>$iEmailOptionId, + 'wk_params'=>$sWkParams, + 'xslstylesheet'=>$sXslStyleSheet + ); - if ( $sEmailNotifications != null){ - $postfields['email_notifications'] = $sEmailNotifications; - } + if ( $sEmailNotifications != null){ + $postfields['email_notifications'] = $sEmailNotifications; + } + + $oReturn = $this->contactCurrentApi("POST", 'gtf/userorders', $postfields , $sMode="json"); + + error_log(print_r($oReturn, true)); - $oReturn = $this->postCurlRequest ($sUrl, $postfields); - - } else + if($oReturn === false){ $sErrorMsg = 'Error while performing a cURL session (' . __METHOD__ . ' (get token))'; + } if ($sErrorMsg != '') { writeToErrorLog($sErrorMsg); @@ -349,32 +347,41 @@ class WabBusinessObject { /Retour : string token * ******************************************************************** */ - function getToken () { + function getToken ($sServerRestUrl = '', $aAuthParams = null) { - if($this->aProperties['web_server_name'] === "[HTTP_HOST]"){ - $this->aProperties['web_server_name'] = "https://localhost"; - } - $sUrl = $this->aProperties['web_server_name'] . '/' . $this->aProperties['services_alias'] . '/vitis/privatetoken'; + if($this->aProperties['web_server_name'] === "[HTTP_HOST]"){ + $this->aProperties['web_server_name'] = "https://localhost"; + } + + if(empty($sServerRestUrl)){ + $sServerRestUrl = $this->aProperties['web_server_name'] . '/' . $this->aProperties['services_alias']; + } - if(!empty($_SESSION["ses_Login"])){ + $sUrl = $sServerRestUrl . '/vitis/privatetoken'; + + if(!empty($aAuthParams)){ + $postfields = $aAuthParams; + } else if(!empty($_SESSION["ses_Login"])){ $sUserPassword = trim(des(rtrim(utf8_decode($_SESSION['ses_Login'])), hexToString(rtrim($_SESSION['ses_Password'])), 0, 0, null)); $postfields = array('user'=>$_SESSION["ses_Login"], 'password'=>$sUserPassword); } else { $postfields = array('user'=>$this->aProperties["login_bot"], 'password'=>$this->aProperties["pass_bot"]); } - $oToken = json_decode($this->postCurlRequest ($sUrl, $postfields)); + //$oToken = json_decode($this->postCurlRequest ($sUrl, $postfields)); + $oToken = json_decode($this->sendCurlRequest ("POST", $sUrl, json_encode($postfields), array("Accept: applicaton/json", "Content-Type: application/json"))); + return $oToken->token; } /* * ******************************************************************** - envoi une requete curl en POST + envoi une requete curl en POST (DEPRECATED) \$sUrl : Url pour envoyer la requete \$postfields : array contenant les paramètres à envoyer /Retour : string token * ******************************************************************** */ function postCurlRequest ($sUrl, $postfields) { - $ch = curl_init($sUrl); + /*$ch = curl_init($sUrl); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -382,9 +389,153 @@ class WabBusinessObject { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - return curl_exec($ch); + return curl_exec($ch);*/ + $this->sendCurlRequest("POST", $sUrl, $postfield, array("Accept: application/json")); + } + + function sendCurlRequest($sMethod, $sUrl, $aParams=array(), $aHeaders=array()){ + + $this->aLastCurlRequestInfo = ''; + // + $ch = curl_init(); + $sType = strtoupper($sMethod); + // Force la méthode de requête utilisée (GET, POST...). + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $sType); + // Url à utiliser. + if (($sType == 'GET' || $sType == 'DELETE') && !empty($aParams)) + $sUrl .= '?' . http_build_query($aParams); + curl_setopt($ch, CURLOPT_URL, $sUrl); + // ajout des en-tête + curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeaders); + // Retour sous forme de texte. + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + // Requête POST PUT parameters. + + if ($sType == 'POST' || $sType == 'PUT') { + if($sType == 'POST'){ + curl_setopt($ch, CURLOPT_POST, true); + } + // Chaîne de requête en encodage URL. + //if (is_array($aParamsaParams) && !$bMultipartFormData) + // $aParams = http_build_query($aParams); + // Données de la requête. + curl_setopt($ch, CURLOPT_POSTFIELDS, $aParams); + // + //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); + // Entête pour la requête en POST. + //$aHeaders[] = 'Content-Type: application/x-www-form-urlencoded'; + } + + curl_setopt($ch, CURLINFO_HEADER_OUT, true); + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + // Curl error: SSL certificate problem: unable to get local issuer certificate + // Curl error n°60 + curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + // + $output = curl_exec($ch); + // Erreur de la requête CURL. + if(curl_errno($ch)) { + writeToErrorLog('Curl error: ' . curl_error($ch)); + writeToErrorLog('Curl error n°' . curl_errno($ch)); + } + // Informations de la requête. + $aCurlInfo = curl_getinfo($ch); + $this->aLastCurlRequestInfo = $aCurlInfo; + + // Ferme la session CURL. + curl_close($ch); + return $output; + } + + function contactCurrentApi($sMethod, $sUrlPath, $aParams=array(), $sMode="json", $aAuthParams = null){ + + if($this->aProperties['web_server_name'] === "[HTTP_HOST]"){ + $this->aProperties['web_server_name'] = "https://localhost"; + } + + $sRestUrl = $this->aProperties['web_server_name'] . '/' . $this->aProperties['services_alias']; + + $this->contactAnotherApi($sMethod, $sRestUrl, $sUrlPath, $aParams, $sMode, $aAuthParams); } + function contactAnotherApi($sMethod, $sRestUrl, $sUrlPath, $aParams=array(), $sMode="json", $aAuthParams = null){ + $mToken = $this->getToken($sRestUrl, $aAuthParams); + + $sUrl = $sRestUrl . "/" . $sUrlPath; + + if($mToken !== false){ + + // modification des paramètres si besoin + $aSendParams = array(); + $aHeaders = array("token: " . $mToken); + + switch ($sMode) { + case 'json': + $aSendParams = json_encode($aParams); + $aHeaders[] = "Content-Type: application/json"; + $aHeaders[] = "Accept: application/json"; + break; + case 'query': + $sUrl .= '?' . http_build_query($aParams); + $aHeaders[] = "Accept: application/x-vm-json"; + break; + case 'urlencode': + $aSendParams = http_build_query($aParams); + $aHeaders[] = "Accept: application/x-www-form-urlencoded"; + break; + case 'formdata' : + $aSendParams = $aParams; + break; + } + + $sOutput = $this->sendCurlRequest($sMethod, $sUrl, $aSendParams, $aHeaders); + error_log(print_r($this->aLastCurlRequestInfo, true)); + return $sOutput; + } else { + writeToErrorLog("This user can't have a token on Calimap at URL : " . $sRestUrl); + return false; + } + } + + /********************************************************************** + Sauve l'historique deprecated + **********************************************************************/ + function saveHistory() { + $aHistoryValues = array('bo_id' => $this->aValues["my_vitis_id"], 'login' => $_SESSION['ses_Login'], 'comment' => $this->status, 'date' => date('Y-m-d H:i:s')); + $this->oBd->insert($this->aTableInfo['schema_name'], 'history', $aHistoryValues, $this->aTableInfo['schema_name'] . '.history_history_id_seq', 'history_id'); + } + /********************************************************************** + Sauve une note ou commentaire (history sert d'historique) + **********************************************************************/ + function addHistoryLine($sComment, $sHistoryTable, $iBoId){ + $sUser = 'u_scheduler'; + if(isset($_SESSION['ses_Login']) && !empty($_SESSION['ses_Login'])){ + $sUser = $_SESSION['ses_Login']; + } + + $aHistoryValues = array('bo_id' => $iBoId, 'login' => $sUser, 'comment' => $sComment, 'date' => date('Y-m-d H:i:s')); + $this->oBd->insert($this->aTableInfo['schema_name'], $sHistoryTable, $aHistoryValues, $this->aTableInfo['schema_name'] . '.seq_' . $sHistoryTable . "_id" , 'history_id'); + } + + function commitNoteLine($sNoteLineField, $sNoteTable, $sBoTable, $sFieldId, $iBoId){ + // get note line + $aFields = $this->wabGetObject($this->aTableInfo['schema_name'], $sBoTable, $sFieldId, $iBoId); + + if(!empty($aFields[$sNoteLineField])){ + $sUser = 'u_scheduler'; + if(isset($_SESSION['ses_Login']) && !empty($_SESSION['ses_Login'])){ + $sUser = $_SESSION['ses_Login']; + } + $aNoteValues = array('bo_id' => $iBoId, 'login' => $sUser, 'comment' => $aFields[$sNoteLineField], 'date' => date('Y-m-d H:i:s')); + $this->oBd->insert($this->aTableInfo['schema_name'], $sNoteTable, $aNoteValues, $this->aTableInfo['schema_name'] . '.seq_' . $sNoteTable . "_id", 'history_id'); + } + + // reset note line + $this->aValues[$sNoteLineField] = ""; + $this->save(); + } + } ?> diff --git a/vas/rest/class/wab_lib/BusinessObject.class.sql.inc b/vas/rest/class/wab_lib/BusinessObject.class.sql.inc index bf02e36db648547116d594e3689cc070a8d36fc8..a18ed1f2df0594917c4cdf5ec15499b422dd2273 100755 --- a/vas/rest/class/wab_lib/BusinessObject.class.sql.inc +++ b/vas/rest/class/wab_lib/BusinessObject.class.sql.inc @@ -1,5 +1,6 @@ <?php $aSQL["getStatusId"] = 'SELECT * FROM [SCHEMA].rt_[TABLE]_status WHERE name = [STATUS_NAME]'; - $aSQL["updateStatus"] = 'UPDATE [SCHEMA].v_[TABLE] SET status_id=[STATUS_ID] WHERE v_[TABLE].[BOIDFIELD]=[BOID]'; + $aSQL["getBoValues"] = 'SELECT * FROM [SCHEMA].[TABLE] WHERE [TABLE].[BOIDFIELD]=[BOID]'; + $aSQL["updateStatus"] = 'UPDATE [SCHEMA].[TABLE] SET status_id=[STATUS_ID] WHERE [TABLE].[BOIDFIELD]=[BOID]'; $aSQL["getStatusName"] = 'SELECT name FROM [SCHEMA].rt_[TABLE]_status WHERE status_id = (SELECT status_id FROM [SCHEMA].[TABLE] WHERE [TABLE].[BOIDFIELD]=[BOID])'; ?> \ No newline at end of file diff --git a/vas/rest/conf/properties.inc b/vas/rest/conf/properties.inc old mode 100644 new mode 100755 diff --git a/vas/rest/conf/selected_properties.inc b/vas/rest/conf/selected_properties.inc old mode 100644 new mode 100755 diff --git a/vas/rest/index.phtml b/vas/rest/index.phtml index 86af3b21c85db3857e6e5be0ffccaae43e8a50f7..d4b4cffa2cb95cad6d52b949c6476345429ae154 100755 --- a/vas/rest/index.phtml +++ b/vas/rest/index.phtml @@ -1,5 +1,7 @@ <?php +$_SERVER['VAS_PATH'] = pathinfo(dirname($_SERVER['SCRIPT_FILENAME']))['dirname']; + require_once("class/vitis_lib/VitisError.class.inc"); require_once("class/vmlib/cryptUtil.inc"); require_once("conf/properties.inc"); @@ -199,4 +201,4 @@ function customErrorHandler ($errno, $errstr, $errfile, $errline, $context){ } include ("index.vhtml"); -?> \ No newline at end of file +?> diff --git a/vas/rest/ws/vitis/Exploitations.class.inc b/vas/rest/ws/vitis/Exploitations.class.inc deleted file mode 100755 index 1703c2ce5b6eed19237293c8444271e3d0e4a709..0000000000000000000000000000000000000000 --- a/vas/rest/ws/vitis/Exploitations.class.inc +++ /dev/null @@ -1,362 +0,0 @@ -<?php - -/** - * \file Exploitations.class.inc - * \class Exploitations - * - * \author Yoann Perollet <yoann.perollet@veremes.com>. - * - * \brief This file contains the Exploitations php class - * - * This class defines Rest Api to Vitis exploitations - * - */ -require_once 'Vitis.class.inc'; -require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc'; -require_once(__DIR__ . '/../../class/vmlib/BdDataAccess.inc'); - -class Exploitations extends Vitis { - /** - * @SWG\Definition( - * definition="/exploitations", - * allOf={ - * @SWG\Schema(ref="#/definitions/exploitations") - * } - * ) - * * @SWG\Tag( - * name="Exploitations", - * description="Operations about Exploitations" - * ) - */ - - /** - * construct - * @param type $aPath url of the request - * @param type $aValues parameters of the request - * @param type $properties properties - * @param type $bShortcut false to reinit variables - * @param type $oConnection connection object - */ - function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) { - parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection); - $this->aSelectedFields = Array(); - } - - /** - * @SWG\Get(path="/exploitations/SharedDirectory", - * tags={"Exploitations"}, - * summary="Get shared directory tree", - * description="Request to get the shared directory tree", - * operationId="GET", - * produces={"application/json", "application/x-vm-json"}, - * @SWG\Parameter( - * name="token", - * in="query", - * description="user token", - * required=true, - * type="string" - * ), - * @SWG\Response( - * response=200, - * description="Poprerties Response", - * @SWG\Schema(ref="#/definitions/exploitations") - * ) - * ) - */ - - /** - * get Exploitations - * @return Exploitations - */ - function GET() { - // Arborescence du répertoire partagé. - if (strtolower($this->aPath[2]) == 'shareddirectory') { - $aTreeview = $this->getDirectoryTree($this->aProperties['shared_dir']); - if (!empty($aTreeview["data"][0]["nodes"])) - $this->aFields['tree']['data'] = $aTreeview["data"][0]["nodes"]; - else - $this->aFields['tree']['data'] = []; - } - // - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - return $sMessage; - } - - /** - * Get directory tree. - */ - function getDirectoryTree($sDirectoryPath) { - $aReturn = array('status' => 1, 'message' => ''); - // Création de l'arborescence des fichiers du répertoire. - if (!empty($sDirectoryPath)) { - $sDirectoryName = 'Downloads'; - if (is_string($sDirectoryPath)) { - if (is_dir($sDirectoryPath)) { - $aDirStructure = $this->getDirStructure($sDirectoryPath, $sDirectoryName, $sDirectoryName, ""); - $aTreeview["data"][] = $aDirStructure["data"]; - if (!empty($aDirStructure["files"])) { - foreach ($aDirStructure["files"] as $aFiles) { - $aTreeview["files"][] = $aFiles; - } - } - } else - writeToErrorLog('scandir(' . $sDirectoryPath . '): failed to open dir'); - } - } - return $aTreeview; - } - - /* - * Retourne l'arborescence d'un répertoire formaté pour "bootstrap-treeview". - */ - - function getDirStructure($sDirectoryPath, $sSubDirectoryName, $sDirectoryName, $sFolder) { - $aFilteredDir['data'] = array('text' => $sSubDirectoryName, 'selectable' => true, 'path' => $sFolder . '/' . $sSubDirectoryName); - $aDir = scandir($sDirectoryPath); - // Les répertoires sont affichés avant les fichiers (idem windows). - $aSortedDir = array(); - $aSortedFiles = array(); - foreach ($aDir as $sName) { - $sPath = $sDirectoryPath . '/' . $sName; - $sFileType = filetype($sPath); - if ($sFileType == 'dir') - $aSortedDir[] = $sName; - else - $aSortedFiles[] = $sName; - } - sort($aSortedDir, SORT_STRING|SORT_FLAG_CASE); - sort($aSortedFiles, SORT_STRING|SORT_FLAG_CASE); - $aDir = array_merge($aSortedDir, $aSortedFiles); - // - if ($sSubDirectoryName !== $sDirectoryName) - $sFolder .= '/' . $sSubDirectoryName; - - foreach ($aDir as $sName) { - $sPath = $sDirectoryPath . '/' . $sName; - $sFileType = filetype($sPath); - // Répertoire ? - if ($sFileType == 'dir') { - if ($sName != '.' && $sName != '..') { - if (is_dir($sPath)) { - $aDirStructure = $this->getDirStructure($sPath . '/', $sName, $sDirectoryName, $sFolder); - //if (!empty($aDirStructure['data']['nodes'])) { - // Structure du répertoire. - $aFilteredDir['data']['nodes'][] = $aDirStructure['data']; - // Liste des fichiers du répertoire. - if (!empty($aDirStructure["files"])) { - foreach ($aDirStructure["files"] as $aFiles) { - $aFilteredDir["files"][] = $aFiles; - } - } - //} - } else - writeToErrorLog('scandir(' . $sPath . '): failed to open dir'); - } - } - // fichier ? - if ($sFileType == 'file') { - // Taille + unité du fichier. - //$iFileSize = filesize($sPath); - $aFileInfos = stat($sPath); - $iFileSizeLabel = $aFileInfos['size']; - $aFileSizeUnity = array('o', 'Ko', 'Mo', 'Go', 'To'); - $i = 0; - while ($iFileSizeLabel > 1024) { - $iFileSizeLabel /= 1024; - $i++; - } - // Sauve la structure du fichier pour le treeview. - $sFileLabel = $sName . ' (' . round($iFileSizeLabel) . ' ' . $aFileSizeUnity[$i] . ')'; - $aFilteredDir['data']['nodes'][] = array( - 'folder' => $sFolder, - 'directory' => $sDirectoryName, - 'name' => $sName, - 'text' => $sFileLabel, - 'icon' => 'glyphicon glyphicon-file', - 'path' => str_replace('//', '/', $sFolder . '/' . '/' . $sName), - //'tags' => array('<span class="glyphicon glyphicon-trash"></span>'), - 'size' => $aFileInfos['size'], - 'selectable' => false - ); - // Sauve le nom et la date du fichier. - $aFilteredDir['files'][] = array( - 'path' => str_replace('//', '/', $sFolder . '/' . '/' . $sName), - //'last_modif' => floor((time() - $aFileInfos['mtime']) / (24 * 3600)) // dernière modif. (Nb jours). - ); - } - } - return $aFilteredDir; - } - - /** - * @SWG\Post(path="/exploitations/SharedDirectory/Directory", - * tags={"Exploitations"}, - * summary="Create directory", - * description="Request to create a directory", - * operationId="POST", - * produces={"application/xml", "application/json"}, - * @SWG\Parameter( - * name="token", - * in="formData", - * description="user token", - * required=true, - * type="string" - * ), - * @SWG\Parameter( - * name="directory_path", - * in="formData", - * description="path of the directory", - * required=true, - * type="string" - * ), - * @SWG\Response( - * response=200, - * description="Poprerties Response", - * @SWG\Schema(ref="#/definitions/exploitations/SharedDirectory") - * ) - * ) - */ - - /** - * @SWG\Post(path="/exploitations/SharedDirectory/File", - * tags={"Exploitations"}, - * summary="Ulpload file", - * description="Request to upload a file", - * operationId="POST", - * produces={"application/xml", "application/json"}, - * @SWG\Parameter( - * name="token", - * in="formData", - * description="user token", - * required=true, - * type="string" - * ), - * @SWG\Parameter( - * name="directory_path", - * in="formData", - * description="path of the directory", - * required=true, - * type="string" - * ), - * @SWG\Response( - * response=200, - * description="Poprerties Response", - * @SWG\Schema(ref="#/definitions/exploitations/SharedDirectory") - * ) - * ) - */ - - /** - * insert user - * @return id of the user created - */ - function POST() { - // Répertoire partagé. - if (strtolower($this->aPath[2]) == 'shareddirectory') { - // Création d'un répertoire. - if (strtolower($this->aPath[3]) == 'directory') { - if (!empty($this->aValues['directory_path'])) { - if (mkdir($this->aProperties['shared_dir'] . '/' . $this->aValues['directory_path'])) { - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } - else { - $oError = new VitisError(1, 'DIRECTORY_CREATION_ERROR_EXPLOITATION_EXPLOITATION'); - $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } - } - } - // Upload d'un fichier. - else if (strtolower($this->aPath[3]) == 'file') { - if (!empty($_FILES["file"])) { - if (!empty($this->aValues['directory_path'])) - $sFilePath = $this->aProperties['shared_dir'] . '/' . $this->aValues['directory_path'] . '/' . $_FILES["file"]["name"]; - else - $sFilePath = $this->aProperties['shared_dir'] . '/' . $_FILES["file"]["name"]; - if (!move_uploaded_file($_FILES['file']['tmp_name'], $sFilePath)) { - $oError = new VitisError(1, 'FILE_CREATION_ERROR_EXPLOITATION_EXPLOITATION'); - $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } - else { - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } - } - } - } - return $sMessage; - } - - /** - * @SWG\Delete(path="/exploitations/SharedDirectory", - * tags={"Exploitations"}, - * summary="delete shared directory files", - * description="Request to delete shared directory files", - * operationId="DELETE", - * produces={"application/json", "application/x-vm-json"}, - * @SWG\Parameter( - * name="token", - * in="query", - * description="user token", - * required=true, - * type="string" - * ), - * * @SWG\Parameter( - * name="idList", - * in="query", - * description="path of the files", - * required=true, - * type="string" - * ), - * @SWG\Response( - * response=200, - * description="Poprerties Response", - * @SWG\Schema(ref="#/definitions/exploitations/SharedDirectory") - * ) - * ) - */ - - /** - * delete exploitation files - */ - function DELETE() { - // Verify connection. - if (!empty($this->oConnection->oError)) { - $oError = $this->oConnection->oError; - $aXmlRacineAttribute['status'] = 0; - $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - return $sMessage; - } - // Privilège "vitis_admin" requis. - if (!in_array('vitis_admin', $this->oConnection->aPrivileges)) { - $oError = new VitisError(1, "Rights problem : you don't have right to delete shared directory files"); - $aXmlRacineAttribute['status'] = 0; - $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - return $sMessage; - } - // Suppression des fichiers. - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - if (!empty($this->aValues['idList'])) { - $aPathsToDelete = explode('|', $this->aValues['idList']); - $aDirToDelete = array(); - foreach ($aPathsToDelete as $sPath) { - $sPath = str_replace('//', '/', $this->aProperties['shared_dir'] . $sPath); - if (file_exists($sPath)) { - if (is_dir($sPath)) - array_unshift($aDirToDelete, $sPath); - else - unlink($sPath); - } - } - } - // Suppression des répertoires. - foreach ($aDirToDelete as $sPath) { - rmdir($sPath); - } - // - return $sMessage; - } -} -?> \ No newline at end of file diff --git a/vas/rest/ws/vitis/GenericQuerys.class.inc b/vas/rest/ws/vitis/GenericQuerys.class.inc old mode 100644 new mode 100755 diff --git a/vas/rest/ws/vitis/Modes.class.inc b/vas/rest/ws/vitis/Modes.class.inc old mode 100644 new mode 100755 index c838ebe1c37627b79b3783a89d8f601904e94653..f9754ec0d4f3c9291507b34474333f70bcac1b52 --- a/vas/rest/ws/vitis/Modes.class.inc +++ b/vas/rest/ws/vitis/Modes.class.inc @@ -34,8 +34,8 @@ class Modes extends Vitis { * construct * @param type $aPath url of the request * @param type $aValues parameters of the request - * @param type $properties properties - * @param type $bShortcut false to reinit variables + * @param type $properties properties + * @param type $bShortcut false to reinit variables * @param type $oConnection connection object */ function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) { @@ -131,11 +131,6 @@ class Modes extends Vitis { */ function GET() { if ($this->oConnection->oError == null) { - if (!empty($this->aProperties["public_token"]) && $this->aProperties["allow_public_connection"] === true){ - if($this->aProperties["public_token"] === $this->aValues['token']){ - $this->aValues["filter"] = '{"relation": "AND","operators":[{"column": "mode_id","compare_operator": "<>","value": "user"}]}'; - } - } if (isset($this->aValues['action']) && !empty($this->aValues['action'])) { if ($this->aValues['action'] == 'getAll') { $aReturn = $this->genericGet($this->aProperties['schema_framework'], "vm_mode_rolname", "mode_id", true); diff --git a/vas/rest/ws/vitis/PrivateToken.class.inc b/vas/rest/ws/vitis/PrivateToken.class.inc index 8295dcb302800b3391b9833d953d442b1070f955..649dc10c0bc7100d38721af81cab49b19706eab2 100644 --- a/vas/rest/ws/vitis/PrivateToken.class.inc +++ b/vas/rest/ws/vitis/PrivateToken.class.inc @@ -134,85 +134,76 @@ class PrivateToken extends Vitis { } if (!$bXMLError) { - // Teste si la base de données est joignable. - if (fsockopen($this->aProperties["server"], $this->aProperties["port"], $errno, $errstr) === false) { - $oError = new VitisError(19, "The database is unreachable"); + //connect to database + $oBd = new BD($this->aValues["user"], $this->aValues["password"], $this->aProperties["database"], $this->aProperties["server"], $this->aProperties["port"], $this->aProperties["sgbd"], $this->aProperties["page_encoding"]); + $_SESSION["ses_Login"] = $this->aValues["user"]; + $ciphertext = stringToHex(des($this->aValues["user"], $this->aValues["password"], 1, 0)); + $_SESSION["ses_Password"] = $ciphertext; + $_SESSION["ses_Remember"] = false; + $_SESSION["ses_Date"] = date('Y-m-d H:i:s', time() + ($this->aValues['duration'] * 60)); + if ($oBd->erreurRencontree) { + $oError = new VitisError(1, $oBd->sMessage); $aXmlRacineAttribute['status'] = 0; $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - writeToErrorLog("ERROR : " . $errstr . ' ' . $this->aValues["user"] . "'."); - } - else { - //connect to database - $oBd = new BD($this->aValues["user"], $this->aValues["password"], $this->aProperties["database"], $this->aProperties["server"], $this->aProperties["port"], $this->aProperties["sgbd"], $this->aProperties["page_encoding"]); - $_SESSION["ses_Login"] = $this->aValues["user"]; - $ciphertext = stringToHex(des($this->aValues["user"], $this->aValues["password"], 1, 0)); - $_SESSION["ses_Password"] = $ciphertext; - $_SESSION["ses_Remember"] = false; - $_SESSION["ses_Date"] = date('Y-m-d H:i:s', time() + ($this->aValues['duration'] * 60)); - if ($oBd->erreurRencontree) { - $oError = new VitisError(1, $oBd->sMessage); + $bXMLError = true; + } else { + // Privilège 'vitis_user' obligatoire. + $aParams['sLogin'] = array('value' => $this->aValues["user"], 'type' => 'string'); + $oPDOresult = $oBd->executeWithParams($aSql['getUserConnectionPrivileges'], $aParams); + if ($oBd->nombreLigne($oPDOresult) == 0) { + $oError = new VitisError(18, "No 'vitis_user' privilege."); $aXmlRacineAttribute['status'] = 0; $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - $bXMLError = true; + writeToErrorLog("ERROR : No 'vitis_user' privilege for user '" . $this->aValues["user"] . "'."); } else { - // Privilège 'vitis_user' obligatoire. - $aParams['sLogin'] = array('value' => $this->aValues["user"], 'type' => 'string'); - $oPDOresult = $oBd->executeWithParams($aSql['getUserConnectionPrivileges'], $aParams); + // L'utilisateur doit exister dans la table s_vitis.user + $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); + $aParams['sLogin'] = array('value' => $_SESSION["ses_Login"], 'type' => 'string'); + $oPDOresult = $oBd->executeWithParams($aSql['checkUser'], $aParams); if ($oBd->nombreLigne($oPDOresult) == 0) { - $oError = new VitisError(18, "No 'vitis_user' privilege."); + $oError = new VitisError(1, 'The user ' . $_SESSION["ses_Login"] . ' does not exist'); $aXmlRacineAttribute['status'] = 0; $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - writeToErrorLog("ERROR : No 'vitis_user' privilege for user '" . $this->aValues["user"] . "'."); + writeToErrorLog('ERROR : The user ' . $_SESSION["ses_Login"] . ' does not exist.'); } else { - // L'utilisateur doit exister dans la table s_vitis.user + //verify the ip from wich the user is connected + $aParams = array(); $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); $aParams['sLogin'] = array('value' => $_SESSION["ses_Login"], 'type' => 'string'); - $oPDOresult = $oBd->executeWithParams($aSql['checkUser'], $aParams); - if ($oBd->nombreLigne($oPDOresult) == 0) { - $oError = new VitisError(1, 'The user ' . $_SESSION["ses_Login"] . ' does not exist'); + $oPDOresult = $oBd->executeWithParams($aSql['checkIP'], $aParams); + $aFields = $oBd->ligneSuivante($oPDOresult); + $oMetadataAccess = new MetadataAccess($oBd, $_SESSION["ses_Login"], $_SESSION["ses_Password"], session_id(), $this->aProperties); + $bAuthorizedIp = $oMetadataAccess->checkUserIp($_SERVER['REMOTE_ADDR']); + if (!$bAuthorizedIp) { + $oError = new VitisError(11, 'Connection to the database forbidden with the ip \'' . $_SERVER['REMOTE_ADDR'] . '\'.'); $aXmlRacineAttribute['status'] = 0; $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - writeToErrorLog('ERROR : The user ' . $_SESSION["ses_Login"] . ' does not exist.'); + $bXMLError = true; + writeToErrorLog('ERROR : Connection to the database forbidden with the ip \'' . $_SERVER['REMOTE_ADDR'] . '\'.'); } else { - //verify the ip from wich the user is connected - $aParams = array(); - $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); - $aParams['sLogin'] = array('value' => $_SESSION["ses_Login"], 'type' => 'string'); - $oPDOresult = $oBd->executeWithParams($aSql['checkIP'], $aParams); - $aFields = $oBd->ligneSuivante($oPDOresult); - $oMetadataAccess = new MetadataAccess($oBd, $_SESSION["ses_Login"], $_SESSION["ses_Password"], session_id(), $this->aProperties); - $bAuthorizedIp = $oMetadataAccess->checkUserIp($_SERVER['REMOTE_ADDR']); - if (!$bAuthorizedIp) { - $oError = new VitisError(11, 'Connection to the database forbidden with the ip \'' . $_SERVER['REMOTE_ADDR'] . '\'.'); - $aXmlRacineAttribute['status'] = 0; - $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - $bXMLError = true; - writeToErrorLog('ERROR : Connection to the database forbidden with the ip \'' . $_SERVER['REMOTE_ADDR'] . '\'.'); - } else { - error_log('session_id():' . session_id()); + error_log('session_id():' . session_id()); - $oConnection = new Connection(Array('token' => session_id()), $this->aProperties); - $this->aFields['token'] = session_id(); - $this->aFields['user'] = $_SESSION["ses_Login"]; - $this->aFields['validity_date'] = date('Y-m-d H:i:s', time() + ($this->aValues['duration'] * 60)); - $this->aFields['user_id'] = $aFields['user_id']; - $this->aFields['privileges'] = $oConnection->aPrivileges; - if ($this->aValues['output'] === 'application/xml') { - $this->aFields['privileges'] = implode(',', $this->aFields['privileges']); - } - $_SESSION["ses_user_id"] = $aFields['user_id']; - $_SESSION["ses_restriction"] = $aFields['restriction']; - $aXmlRacineAttribute['status'] = 1; - $aParams = array(); - $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); - $aParams['user_id'] = array('value' => $aFields['user_id'], 'type' => 'number'); - $aParams['date'] = array('value' => gmdate('Y-m-d H:i:s'), 'type' => 'string'); - $oPDOresult = $oBd->executeWithParams($aSql['updateLastConnection'], $aParams); - $sLogString = "connection" . $this->aProperties["log_delim"] . $_SESSION["ses_Login"] . $this->aProperties["log_delim"] . session_id(); - writeToLog($sLogString, $this->aProperties["connexion_log_file"]); - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + $oConnection = new Connection(Array('token' => session_id()), $this->aProperties); + $this->aFields['token'] = session_id(); + $this->aFields['user'] = $_SESSION["ses_Login"]; + $this->aFields['validity_date'] = date('Y-m-d H:i:s', time() + ($this->aValues['duration'] * 60)); + $this->aFields['user_id'] = $aFields['user_id']; + $this->aFields['privileges'] = $oConnection->aPrivileges; + if ($this->aValues['output'] === 'application/xml') { + $this->aFields['privileges'] = implode(',', $this->aFields['privileges']); } + $_SESSION["ses_user_id"] = $aFields['user_id']; + $_SESSION["ses_restriction"] = $aFields['restriction']; + $aXmlRacineAttribute['status'] = 1; + $aParams = array(); + $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); + $aParams['user_id'] = array('value' => $aFields['user_id'], 'type' => 'number'); + $aParams['date'] = array('value' => gmdate('Y-m-d H:i:s'), 'type' => 'string'); + $oPDOresult = $oBd->executeWithParams($aSql['updateLastConnection'], $aParams); + $sLogString = "connection" . $this->aProperties["log_delim"] . $_SESSION["ses_Login"] . $this->aProperties["log_delim"] . session_id(); + writeToLog($sLogString, $this->aProperties["connexion_log_file"]); + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); } } } diff --git a/vas/rest/ws/vitis/Properties.class.inc b/vas/rest/ws/vitis/Properties.class.inc index d363c98601beb319ee43bce3dd2da87b4d247c80..c7f65b413b16534d0349e47a7b9a0a420d1ba76a 100755 --- a/vas/rest/ws/vitis/Properties.class.inc +++ b/vas/rest/ws/vitis/Properties.class.inc @@ -14,7 +14,7 @@ require_once(__DIR__ . '/../../class/vmlib/BdDataAccess.inc'); * \brief This file contains the Properties php class * * This class defines the rest api for properties - * + * */ class Properties extends Vitis { /** @@ -53,7 +53,7 @@ class Properties extends Vitis { } /** - * @SWG\Get(path="/properties", + * @SWG\Get(path="/properties", * tags={"Properties"}, * summary="Get properties", * description="Request to get properties", @@ -75,7 +75,7 @@ class Properties extends Vitis { */ /** - * + * * @return properties */ function GET() { @@ -85,19 +85,19 @@ class Properties extends Vitis { } else { $this->aFields = $this->aProperties; } - require_once __DIR__ . "/../../conf/version.inc"; + require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/version.inc"; if (VM_STATUS != "STABLE") { $this->aFields['VM_STATUS'] = "UNSTABLE"; } else { $this->aFields['VM_STATUS'] = "STABLE"; - if ($pointeur = opendir(__DIR__ . "/../../conf/")) { + if ($pointeur = opendir(dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/")) { while (($fichier = readdir($pointeur)) !== false) { if (($fichier != '.') && ($fichier != '..')) { - if (is_dir(__DIR__ . "/../../conf/" . $fichier)) { - $sTexte = file_get_contents(__DIR__ . "/../../conf/" . $fichier . "/version.inc"); + if (is_dir(dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/" . $fichier)) { + $sTexte = file_get_contents(dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/" . $fichier . "/version.inc"); if (strpos($sTexte, "define (\"VM_STATUS\", \"STABLE\");") == false) { $this->aFields['VM_STATUS'] = "UNSTABLE"; @@ -216,7 +216,7 @@ class Properties extends Vitis { * description="Poprerties Response", * @SWG\Schema(ref="#/definitions/properties") * ), - * + * * ) */ @@ -299,7 +299,7 @@ class Properties extends Vitis { // Message de retour $aMessage = array('status' => REQUEST_SUCCESS); - // Ouverture de php + // Ouverture de php $sPropertiesFile = PHP_START . PHP_EOL; // Texte à ajouter avant le tableau des properties @@ -343,14 +343,14 @@ class Properties extends Vitis { $sPropertiesFile .= PROPERTIES_FOOTER . PHP_EOL; } - // Fermeture de php + // Fermeture de php $sPropertiesFile .= PHP_END; // Sauve le fichier (LOCK_EX = accés exclusif au fichier) if ($this->aValues['module_name'] == 'vitis') - $sPathProperties = __DIR__ . '/../../conf/properties.inc'; + $sPathProperties = dirname($_SERVER['SCRIPT_FILENAME']) . '/conf/properties.inc'; else - $sPathProperties = __DIR__ . '/../../conf/' . $this->aValues['module_name'] . '/properties.inc'; + $sPathProperties = dirname($_SERVER['SCRIPT_FILENAME']) . '/conf/' . $this->aValues['module_name'] . '/properties.inc'; // if (file_put_contents($sPathProperties, $sPropertiesFile, LOCK_EX) === false) $aReturn = array('status' => 0, 'message' => "FORM_ERROR_FILE_WRITING_CONFIGURATION"); @@ -424,4 +424,4 @@ class Properties extends Vitis { } -?> \ No newline at end of file +?> diff --git a/vas/rest/ws/vitis/Versions.class.inc b/vas/rest/ws/vitis/Versions.class.inc index 62b9cfcc9ef13f02c3b310d0543c4d4228ee40e3..3a20a659f09122d360298d4fcc72dc131f54231b 100755 --- a/vas/rest/ws/vitis/Versions.class.inc +++ b/vas/rest/ws/vitis/Versions.class.inc @@ -1,204 +1,202 @@ -<?php - -require_once 'Vitis.class.inc'; -require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc'; -require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc'; - -/** - * \file versions.class.inc - * \class Versions - * - * \author Yoann Perollet <yoann.perollet@veremes.com>. - * - * \brief This file contains the Versions php class - * - * This class defines the rest api for versions - * - */ -class Versions extends Vitis { - /** - * @SWG\Definition( - * definition="/versions", - * allOf={ - * @SWG\Schema(ref="#/definitions/versions") - * } - * ) - * @SWG\Tag( - * name="Versions", - * description="Operations about versions" - * ) - */ - - /** - * construct - * @param type $aPath url of the request - * @param type $aValues parameters of the request - * @param type $versions ptroperties - */ - function __construct($aPath, $aValues, $properties) { - $this->aValues = $aValues; - $this->aPath = $aPath; - $this->aProperties = $properties; - if (!empty($this->aValues['token'])) { - $this->oConnection = new Connection($this->aValues, $this->aProperties); - } - } - - /** - * @SWG\Get(path="/versions", - * tags={"Versions"}, - * summary="Get versions", - * description="Request to get versions", - * operationId="GET", - * produces={"application/xml", "application/json", "application/x-vm-json"}, - * @SWG\Parameter( - * name="token", - * in="query", - * description="user token", - * required=false, - * type="string" - * ), - * @SWG\Response( - * response=200, - * description="Poprerties Response", - * @SWG\Schema(ref="#/definitions/versions") - * ) - * ) - */ - - /** - * - * @return versions - */ - function GET() { - if ($this->oConnection->oError == null) { - $this->getVersion(); - if (!empty($this->aValues['token']) && in_array("vitis_admin", $this->oConnection->aPrivileges)) { - - //$this->aFields = $this->aVersions; - $this->aFields['php_version'] = phpversion(); - - //*** PDO - $bPdo = false; - if (extension_loaded('pdo')) - $bPdo = true; - else - $bVeremap = false; - $this->aFields['pdo_extension_loaded'] = $bPdo; - - //*** PDO Postgresql - $bPdoPgsql = false; - if (extension_loaded('pdo_pgsql')) - $bPdoPgsql = true; - else - $bVeremap = false; - $this->aFields['pdo_pgsql_extension_loaded'] = $bPdoPgsql; - - //*** Curl - $bCurl = false; - if (extension_loaded('curl')) - $bCurl = true; - else - $bVeremap = false; - $this->aFields['curl_extension_loaded'] = $bCurl; - - //*** Xsl - $bXsl = false; - if (extension_loaded('xsl')) - $bXsl = true; - $this->aFields['xsl_extension_loaded'] = $bXsl; - - //*** Ldap - $bLdap = false; - if (extension_loaded('ldap')) - $bLdap = true; - $this->aFields['ldap_extension_loaded'] = $bLdap; - - // OS. - $this->aFields['os_version'] = php_uname(); - - // Info disque. - $this->aFields['disk_free_space'] = round(disk_free_space("/") / 1073741824) . ' Go'; - $this->aFields['disk_total_space'] = round(disk_total_space("/") / 1073741824) . ' Go'; - - // - $this->aFields['server_software'] = $_SERVER['SERVER_SOFTWARE']; - $this->aFields['server_addr'] = $_SERVER['SERVER_ADDR']; - $this->aFields['server_name'] = $_SERVER['SERVER_NAME']; - $this->aFields['server_port'] = $_SERVER['SERVER_PORT']; - - //** Postgresql et Postgis - $bPostgresql = false; - $bPostgis = false; - if (!$this->oConnection->oBd->erreurRencontree) { - $bPostgresql = true; - $sSql = "SHOW server_version"; - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); - $oPgVersion = $this->oConnection->oBd->objetSuivant($oPDOresult); - $sPostgresql = $oPgVersion->server_version; - $this->aFields['postgresql_version'] = $sPostgresql; - $this->oConnection->oBd->fermeResultat(); - - $aVersion = explode(".", $sPostgresql); - $bExtension = false; - if ($aVersion[0] >= 9) { - if ($aVersion[1] >= 1) { - $bExtension = true; - } - } - if ($bExtension == true) { - $sSql = "SELECT default_version FROM pg_catalog.pg_available_extensions where name = 'postgis';"; - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); - if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { - $bPostgis = true; - $sPostgis = $aPostgis['default_version']; - } else { - $bPostgis = false; - } - } else { - $sSql = "SELECT datname FROM pg_catalog.pg_database where datname = 'template_postgis_20';"; - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); - if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { - $bPostgis = true; - $sPostgis = '2.0'; - } else { - $bPostgis = false; - } - } - $this->aFields['postgis_version'] = $sPostgis; - $this->oConnection->oBd->fermeResultat(); - $sSql = 'SELECT distinct module_id from [sSchemaFramework].vm_mode'; - $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aParams); - while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { - $aModules[] = $aLigne['module_id']; - } - $iRecordset = $this->oConnection->oBd->fermeResultat(); - } - $this->aFields['postgresql'] = $bPostgresql; - $this->aFields['postgis'] = $bPostgis; - - // Recherche de mise à jour - // - if (!empty($this->aValues['app'])) { - $sUrl = "http://update.veremes.net/vai/" . $this->aValues['app'] . ".json"; - $json = file_get_contents($sUrl); - $data = json_decode($json, TRUE); - $this->aFields['appVersion'] = $data['version']; - } - } - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } else { - http_response_code(403); - $aXmlRacineAttribute['status'] = 0; - $this->aFields['errorMessage'] = "ERROR : invalid token"; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } - - return $sMessage; - } - -} - +<?php + +require_once 'Vitis.class.inc'; +require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc'; +require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc'; + +/** + * \file versions.class.inc + * \class Versions + * + * \author Yoann Perollet <yoann.perollet@veremes.com>. + * + * \brief This file contains the Versions php class + * + * This class defines the rest api for versions + * + */ +class Versions extends Vitis { + /** + * @SWG\Definition( + * definition="/versions", + * allOf={ + * @SWG\Schema(ref="#/definitions/versions") + * } + * ) + * @SWG\Tag( + * name="Versions", + * description="Operations about versions" + * ) + */ + + /** + * construct + * @param type $aPath url of the request + * @param type $aValues parameters of the request + * @param type $versions ptroperties + */ + function __construct($aPath, $aValues, $properties) { + $this->aValues = $aValues; + $this->aPath = $aPath; + $this->aProperties = $properties; + if (!empty($this->aValues['token'])) { + $this->oConnection = new Connection($this->aValues, $this->aProperties); + } + } + + /** + * @SWG\Get(path="/versions", + * tags={"Versions"}, + * summary="Get versions", + * description="Request to get versions", + * operationId="GET", + * produces={"application/xml", "application/json", "application/x-vm-json"}, + * @SWG\Parameter( + * name="token", + * in="query", + * description="user token", + * required=false, + * type="string" + * ), + * @SWG\Response( + * response=200, + * description="Poprerties Response", + * @SWG\Schema(ref="#/definitions/versions") + * ) + * ) + */ + + /** + * + * @return versions + */ + function GET() { + if ($this->oConnection->oError == null) { + $this->getVersion(); + if (!empty($this->aValues['token']) && in_array("vitis_admin", $this->oConnection->aPrivileges)) { + + //$this->aFields = $this->aVersions; + $this->aFields['php_version'] = phpversion(); + + //*** PDO + $bPdo = false; + if (extension_loaded('pdo')) + $bPdo = true; + else + $bVeremap = false; + $this->aFields['pdo_extension_loaded'] = $bPdo; + + //*** PDO Postgresql + $bPdoPgsql = false; + if (extension_loaded('pdo_pgsql')) + $bPdoPgsql = true; + else + $bVeremap = false; + $this->aFields['pdo_pgsql_extension_loaded'] = $bPdoPgsql; + + //*** Curl + $bCurl = false; + if (extension_loaded('curl')) + $bCurl = true; + else + $bVeremap = false; + $this->aFields['curl_extension_loaded'] = $bCurl; + + //*** Xsl + $bXsl = false; + if (extension_loaded('xsl')) + $bXsl = true; + $this->aFields['xsl_extension_loaded'] = $bXsl; + + //*** Ldap + $bLdap = false; + if (extension_loaded('ldap')) + $bLdap = true; + $this->aFields['ldap_extension_loaded'] = $bLdap; + + // OS. + $this->aFields['os_version'] = php_uname(); + + // Info disque. + $this->aFields['disk_free_space'] = round(disk_free_space("/") / 1073741824) . ' Go'; + $this->aFields['disk_total_space'] = round(disk_total_space("/") / 1073741824) . ' Go'; + + // + $this->aFields['server_software'] = $_SERVER['SERVER_SOFTWARE']; + $this->aFields['server_addr'] = $_SERVER['SERVER_ADDR']; + $this->aFields['server_name'] = $_SERVER['SERVER_NAME']; + $this->aFields['server_port'] = $_SERVER['SERVER_PORT']; + + //** Postgresql et Postgis + $bPostgresql = false; + $bPostgis = false; + if (!$this->oConnection->oBd->erreurRencontree) { + $bPostgresql = true; + $sSql = "SHOW server_version"; + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); + $oPgVersion = $this->oConnection->oBd->objetSuivant($oPDOresult); + $sPostgresql = $oPgVersion->server_version; + $this->aFields['postgresql_version'] = $sPostgresql; + $this->oConnection->oBd->fermeResultat(); + + $aVersion = explode(".", $sPostgresql); + $bExtension = false; + if ($aVersion[0] . $aVersion[1] >= 91) { + $bExtension = true; + } + if ($bExtension == true) { + $sSql = "SELECT default_version FROM pg_catalog.pg_available_extensions where name = 'postgis';"; + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); + if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { + $bPostgis = true; + $sPostgis = $aPostgis['default_version']; + } else { + $bPostgis = false; + } + } else { + $sSql = "SELECT datname FROM pg_catalog.pg_database where datname = 'template_postgis_20';"; + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); + if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { + $bPostgis = true; + $sPostgis = '2.0'; + } else { + $bPostgis = false; + } + } + $this->aFields['postgis_version'] = $sPostgis; + $this->oConnection->oBd->fermeResultat(); + $sSql = 'SELECT distinct module_id from [sSchemaFramework].vm_mode'; + $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aParams); + while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { + $aModules[] = $aLigne['module_id']; + } + $iRecordset = $this->oConnection->oBd->fermeResultat(); + } + $this->aFields['postgresql'] = $bPostgresql; + $this->aFields['postgis'] = $bPostgis; + + // Recherche de mise à jour + // + if (!empty($this->aValues['app'])) { + $sUrl = "http://update.veremes.net/vai/" . $this->aValues['app'] . ".json"; + $json = file_get_contents($sUrl); + $data = json_decode($json, TRUE); + $this->aFields['appVersion'] = $data['version']; + } + } + $aXmlRacineAttribute['status'] = 1; + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + } else { + http_response_code(403); + $aXmlRacineAttribute['status'] = 0; + $this->aFields['errorMessage'] = "ERROR : invalid token"; + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + } + + return $sMessage; + } + +} + ?> \ No newline at end of file diff --git a/vas/rest/ws/vitis/Vitis.class.inc b/vas/rest/ws/vitis/Vitis.class.inc old mode 100644 new mode 100755 diff --git a/vas/rest/ws/vitis/VitisSection.class.inc b/vas/rest/ws/vitis/VitisSection.class.inc index 1328958b8b1cf354a4bfa83ad2e96c06d3d89afb..cd1e1840875aac99b320e6738dbeeb319528b0d4 100755 --- a/vas/rest/ws/vitis/VitisSection.class.inc +++ b/vas/rest/ws/vitis/VitisSection.class.inc @@ -30,7 +30,7 @@ class VitisSection extends Vitis { */ function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) { parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection); - $this->aSelectedFields = Array("section_id", "tab_id", "event", "index", "label", "name", "link_table_name", "template", "ressource_id", "module_name"); + $this->aSelectedFields = Array("section_id", "tab_id", "event", "index", "label", "name", "link_table_name", "template", "ressource_id"); } /** diff --git a/vas/rest/ws/vitis/VitisSections.class.inc b/vas/rest/ws/vitis/VitisSections.class.inc index 3e7710cee087f81790610a140527bf029d79887e..fb91cfe1ed733f0a04683f7921e7db9b9cf13dd0 100755 --- a/vas/rest/ws/vitis/VitisSections.class.inc +++ b/vas/rest/ws/vitis/VitisSections.class.inc @@ -45,7 +45,7 @@ class VitisSections extends Vitis { */ function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) { parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection); - $this->aSelectedFields = Array("section_id", "tab_id", "event", "index", "label", "name", "link_table_name", "template", "ressource_id", "tab_name", "mode_id", "module_name"); + $this->aSelectedFields = Array("section_id", "tab_id", "event", "index", "label", "name", "link_table_name", "template", "ressource_id", "tab_name", "mode_id"); } /** diff --git a/vas/sql/sqlQueries.xml b/vas/sql/sqlQueries.xml old mode 100644 new mode 100755 diff --git a/vas/util/printserver/client/map/map.js b/vas/util/printserver/client/map/map.js index 2a870d9a00d0935c5b31cc776ac42210b8d84ed9..d6dcd882b6e15b31919e02a1799a6bb2b0212263 100755 --- a/vas/util/printserver/client/map/map.js +++ b/vas/util/printserver/client/map/map.js @@ -7,7 +7,7 @@ PrintMap = function (opt_options) { var this_ = this; - + this.mapSize = [document.getElementById('map').offsetWidth, document.getElementById('map').offsetHeight]; this.tileSize = (isDef(window.oProperties.print.tile_size) && window.oProperties.print.features_zoom >= 0) ? window.oProperties.print.tile_size : 2048; @@ -29,7 +29,7 @@ PrintMap = function (opt_options) { this.mapJsonParser = new MapJSON({ 'properties': window.oProperties }); - + this.view = this.mapJsonParser.getViewFromDef(this.mapDefinition, { 'size': this.mapSize, 'tileSize': [this.tileSize, this.tileSize] @@ -39,13 +39,13 @@ PrintMap = function (opt_options) { this.extent = this.getExtent(opt_options); - this.tileGrid = this.getTileGridFromDefinition(this.tileSize); - + this.tileGrid = this.getTileGridFromDefinition(this.tileSize); + this.layers = this.mapJsonParser.getLayersFromDef(this.mapDefinition, { 'size': this.mapSize, 'tileSize': [this.tileSize, this.tileSize] }); - + this.map = this.setMap(this.layers, this.view); this.featuresOverlay = this.setFeaturesOverlay(this.map); @@ -63,6 +63,9 @@ PrintMap = function (opt_options) { // Supprime tous les controls par défaut this.removeMapControls(); + // Taille des icones en fonction de la résolution demandée + this.setMapSymbolsResolution(this.map, this.resolutionCoeff) + // Si aucune étendue a été donnée et que seul un point a été donné, alors zoom sur this.defaultScale if (!isDef(opt_options.extent) && !isDef(this.features)) { if (this.features.length === 1 && this.features[0].getGeometry().getType() === 'Point') { @@ -310,7 +313,7 @@ PrintMap.prototype.getFeaturesFromEWKT = function (aEWKTFeatures) { }; /** - * Return true if EWKTGeom is an EWKT geometry + * Return true if EWKTGeom is an EWKT geometry * @param {string} EWKTGeom * @returns {boolean} */ @@ -367,4 +370,21 @@ PrintMap.prototype.getGeomFromEWKT = function (EWKTGeom, proj) { return null; } -}; \ No newline at end of file +}; + +/** + * For WMS layers set MAP.RESOLUTION and MAP.DEFRESOLUTION to rise the symbols size + * + * @param {object} olMap + * @param {integer} resolutionCoeff + */ +PrintMap.prototype.setMapSymbolsResolution = function (olMap, resolutionCoeff) { + + var newRes = resolutionCoeff * 72; + var aLayers = olMap.getLayers().getArray(); + for (var i = 0; i < aLayers.length; i++) { + if (aLayers[i].get('type') === 'imagewms' || aLayers[i].get('type') === 'tilewms') { + aLayers[i].getSource().updateParams({'MAP.RESOLUTION': newRes, 'MAP.DEFRESOLUTION': 72}); + } + } +}