From 44c223450a282f5353c729c6530b22c76f4858a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 May 2009 12:08:54 +0000 Subject: [PATCH] New: Now webservice module must be activated to enable call of webservice server.php page. --- htdocs/admin/paybox.php | 6 +- htdocs/admin/system/modules.php | 79 +++++----- htdocs/admin/webservices.php | 138 ++++++++++++++++++ htdocs/includes/modules/modLdap.class.php | 1 + htdocs/includes/modules/modSociete.class.php | 1 + htdocs/includes/modules/modSyslog.class.php | 3 +- .../includes/modules/modWebServices.class.php | 22 +-- htdocs/langs/en_US/admin.lang | 11 +- htdocs/langs/fr_FR/admin.lang | 7 +- htdocs/webservices/server.php | 10 +- 10 files changed, 224 insertions(+), 54 deletions(-) create mode 100644 htdocs/admin/webservices.php diff --git a/htdocs/admin/paybox.php b/htdocs/admin/paybox.php index c0f30e910f2..be8087c2e73 100644 --- a/htdocs/admin/paybox.php +++ b/htdocs/admin/paybox.php @@ -17,9 +17,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** \file htdocs/admin/aybox.php - * \ingroup bookmark - * \brief Page to setup bookmark module +/** \file htdocs/admin/paybox.php + * \ingroup paybox + * \brief Page to setup paybox module * \version $Id$ */ diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index bc545572355..bcc06983ec5 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -30,7 +30,7 @@ $langs->load("install"); $langs->load("other"); if (!$user->admin) - accessforbidden(); +accessforbidden(); /* @@ -53,21 +53,21 @@ $modules_names = array(); $modules_files = array(); while (($file = readdir($handle))!==false) { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, strlen($file) - 10); + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, strlen($file) - 10); - if ($modName) - { - include_once(DOL_DOCUMENT_ROOT."/includes/modules/".$file); - $objMod = new $modName($db); + if ($modName) + { + include_once(DOL_DOCUMENT_ROOT."/includes/modules/".$file); + $objMod = new $modName($db); - $modules[$objMod->numero]=$objMod; - $modules_names[$objMod->numero]=$objMod->name; + $modules[$objMod->numero]=$objMod; + $modules_names[$objMod->numero]=$objMod->name; $modules_files[$objMod->numero]=$file; - $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic'; - } - } + $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic'; + } + } } print ''; print ''; @@ -82,37 +82,46 @@ ksort($sortorder); $rights_ids = array(); foreach($sortorder as $numero=>$name) { - $idperms=""; - $var=!$var; - // Module - print ""; - // Version - print ''; - // Id - print ''; - // Permissions - if ($modules[$numero]->rights) + if (! empty($picto[$numero])) { - foreach($modules[$numero]->rights as $rights) - { - $idperms.=($idperms?", ":"").$rights[0]; - array_push($rights_ids, $rights[0]); - } + if (eregi('^/',$picto[$numero])) print img_picto($alt,$picto[$numero],'',1); + else print img_object($alt,$picto[$numero]); } - print ''; - print "\n"; + else + { + print img_object($alt,$picto[$numero]); + } + print ' '.$modules[$numero]->getName(); + print ""; + // Version + print ''; + // Id + print ''; + // Permissions + if ($modules[$numero]->rights) + { + foreach($modules[$numero]->rights as $rights) + { + $idperms.=($idperms?", ":"").$rights[0]; + array_push($rights_ids, $rights[0]); + } + } + print ''; + print "\n"; } print '
"; + $idperms=""; + $var=!$var; + // Module + print "
"; $alt=$name.' - '.$modules_files[$numero]; - print img_object($alt,$picto[$numero]).' '.$modules[$numero]->getName(); - print "'.$modules[$numero]->getVersion().''.$numero.''.($idperms?$idperms:" ").'
'.$modules[$numero]->getVersion().''.$numero.''.($idperms?$idperms:" ").'
'; print '
'; sort($rights_ids); foreach($rights_ids as $right_id) { - if ($old == $right_id) - print "Attention doublon sur la permission : $right_id
"; - $old = $right_id; + if ($old == $right_id) + print "Warning duplicate id on permission : ".$right_id."
"; + $old = $right_id; } llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/admin/webservices.php b/htdocs/admin/webservices.php new file mode 100644 index 00000000000..da07de4708c --- /dev/null +++ b/htdocs/admin/webservices.php @@ -0,0 +1,138 @@ + + * Copyright (C) 2005-2009 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** \file htdocs/admin/webservices.php + * \ingroup webservices + * \brief Page to setup webservices module + * \version $Id$ + */ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); + +$langs->load("admin"); + +if (!$user->admin) + accessforbidden(); + + +if ($_POST["action"] == 'setvalue' && $user->admin) +{ + //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE",$_POST["PAYBOX_IBS_DEVISE"],'chaine',0,'',$conf->entity); + + if ($result >= 0) + { + $mesg='
'.$langs->trans("SetupSaved").'
'; + } + else + { + dol_print_error($db); + } +} + + +/* + * View + */ + +llxHeader(); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("WebServicesSetup"),$linkback,'setup'); + +print $langs->trans("WebServicesDesc")."
\n"; + + +if ($mesg) print '
'.$mesg; + +/* +print '
'; +print '
'; +print ''; + +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + + +$var=!$var; +print ''; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print $langs->trans("PAYBOX_IBS_DEVISE").''; +print ''; +print '
'.$langs->trans("Example").': 978 (EUR)'; +print '
'; +print '
'; +*/ + + +print '

'; + +// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' +$firstpart=$dolibarr_main_url_root; +$regex=DOL_URL_ROOT.'$'; +$firstpart=eregi_replace($regex,'',$firstpart); + +print ''.$langs->trans("WSDLCanBeDownloadedHere").':
'; +$url=$firstpart.DOL_URL_ROOT.'/webservices/server.php?wsdl'; +print img_picto('','puce.png').' '.''.$url."
\n"; +print '
'; + +print ''.$langs->trans("EndPointIs").':
'; +$url=$firstpart.DOL_URL_ROOT.'/webservices/server.php'; +print img_picto('','puce.png').' '.''.$url."
\n"; +print '
'; + +/* +if ($conf->commande->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=order&ref=order_ref'."
\n"; + print '
'; +} +if ($conf->facture->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=invoice&ref=invoice_ref'."
\n"; +// print $langs->trans("SetupPayBoxToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."
\n"; + print '
'; +} +if ($conf->contrat->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=contractline&ref=contractline_ref'."
\n"; + print '
'; +} +if ($conf->adherent->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=membersubscription&ref=member_ref'."
\n"; + print '
'; +} +*/ + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/includes/modules/modLdap.class.php b/htdocs/includes/modules/modLdap.class.php index 711d1ca803a..f4ccddda59f 100644 --- a/htdocs/includes/modules/modLdap.class.php +++ b/htdocs/includes/modules/modLdap.class.php @@ -53,6 +53,7 @@ class modLdap extends DolibarrModules $this->description = "Synchronisation Ldap"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 1; // Data directories to create when module is enabled diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index c07cc15416a..674b402e278 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -64,6 +64,7 @@ class modSociete extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->config_page_url = array("societe.php"); + // Name of image file used for this module. $this->picto='company'; // Data directories to create when module is enabled diff --git a/htdocs/includes/modules/modSyslog.class.php b/htdocs/includes/modules/modSyslog.class.php index 37487c00393..d60c487b054 100644 --- a/htdocs/includes/modules/modSyslog.class.php +++ b/htdocs/includes/modules/modSyslog.class.php @@ -62,7 +62,8 @@ class modSyslog extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 2; - //$this->picto='phoning'; + // Name of image file used for this module. + $this->picto='generic'; // Data directories to create when module is enabled $this->dirs = array(); diff --git a/htdocs/includes/modules/modWebServices.class.php b/htdocs/includes/modules/modWebServices.class.php index 6f1588f8c53..ee395dc3678 100644 --- a/htdocs/includes/modules/modWebServices.class.php +++ b/htdocs/includes/modules/modWebServices.class.php @@ -17,16 +17,16 @@ */ /** - \defgroup webservices Module WebServices - \brief Module to enable the Dolibarr server of web services - \brief $Id$ + * \defgroup webservices Module WebServices + * \brief Module to enable the Dolibarr server of web services + * \brief $Id$ */ /** - \file htdocs/includes/modules/modWebServices.class.php - \ingroup webservices - \brief File to describe webservices module -*/ + * \file htdocs/includes/modules/modWebServices.class.php + * \ingroup webservices + * \brief File to describe webservices module + */ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); @@ -47,15 +47,17 @@ class modWebServices extends DolibarrModules $this->db = $DB; $this->numero = 2600; - $this->family = "projects"; + $this->family = "technic"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Enable the Dolibarr web services server"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; - $this->picto='generic'; + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) + $this->special = 1; + // Name of image file used for this module. + $this->picto='generic'; // Data directories to create when module is enabled $this->dirs = array(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5b0960eb9ee..5c16d154e10 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -13,7 +13,7 @@ HTMLCharset=Charset for generated HTML pages DBStoringCharset=Database charset to store data DBSortingCharset=Database charset to sort data WarningModuleNotActive=Module %s must be enabled -WarningOnlyPermissionOfActivatedModules=Only permissions related to activated modules are shown here. You can activate other modules in the Setup - Module page. +WarningOnlyPermissionOfActivatedModules=Only permissions related to activated modules are shown here. You can activate other modules in the Home->Setup->Modules page. DolibarrSetup=Dolibarr setup DolibarrUser=Dolibarr user InternalUser=Internal user @@ -646,7 +646,7 @@ SystemAreaForAdminOnly=This area is available for administrator users only. None CompanyFundationDesc=Edit on this page all known information of the company or fundation you need to manage DisplayDesc=You can choose each parameter related to the Dolibarr look and feel here AvailableModules=Available modules -ToActivateModule=To activate modules, go on setup Area. +ToActivateModule=To activate modules, go on setup Area (Home->Setup->Modules). SessionTimeOut=Time out for session SessionExplanation=This number guarantee that session will never expire before this delay. But PHP sessoin management does not guaranty that session always expire after this delay: This occurs if a system to clean cache session is running.
Note: with no particular system, internal PHP process will clean session every about %s/%s access but only during access made by other sessions. TriggersAvailable=Available triggers @@ -1042,4 +1042,9 @@ CashDeskIdWareHouse=Datawarehous to user for sells ##### Bookmark ##### BookmarkSetup=Bookmark module setup BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or externale web sites on your left menu. -NbOfBoomarkToShow=Maximum number of bookmarks to show in left menu \ No newline at end of file +NbOfBoomarkToShow=Maximum number of bookmarks to show in left menu +##### WebServices ##### +WebServicesSetup=Webservices module setup +WebServicesDesc=By enabling this module, Dolibarr become a web service server to provide miscellaneous web services. +WSDLCanBeDownloadedHere=WSDL descriptor file of provided serviceses can be download here +EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint available at Url diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 5be6fc962ce..631e913de57 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -645,7 +645,7 @@ SystemAreaForAdminOnly = Cet espace n'est accessible qu'aux utilisateurs de type CompanyFundationDesc = Éditer sur cette page toutes les informations connues sur la société ou association que vous devez gérer DisplayDesc = Vous pouvez choisir ici tous les paramètres liés à l'apparence de Dolibarr AvailableModules = Modules disponibles -ToActivateModule = Pour activer des modules, aller dans l'espace Configuration. +ToActivateModule = Pour activer des modules, aller dans l'espace Configuration (Accueil->Configuration->Modules). SessionTimeOut = Time out des sessions SessionExplanation = Ce nombre garantie que la session n'expire pas avant ce délai. Mais la gestion de session PHP ne garantie pas que la session expire après ce délai: Ce sera le cas si un systeme de nettoyage des caches sessions est en place.
Note: Sans mécanisme special, le mécanisme interne à PHP nettoie la session tous les %s/%s accès environ mais uniquement lors d'accès fait par d'autres sessions. TriggersAvailable = Triggers disponibles @@ -1042,3 +1042,8 @@ CashDeskIdWareHouse = Entrepot à utiliser pour les ventes BookmarkSetup = Configuration du module Bookmark BookmarkDesc = Ce module vous permet de gérer des liens et raccourcis. Il permet aussi d'ajouter n'importe quelle page de Dolibarr ou lien web dans le menu d'accès rapide sur la gauche. NbOfBoomarkToShow = Nombre maximum de marques-pages à afficher dans le menu +##### WebServices ##### +WebServicesSetup=Configuration du module Webservices +WebServicesDesc=En activant ce module, Dolibarr devient aussi serveur de web services offrant des web services divers. +WSDLCanBeDownloadedHere=Le descripteur WSDL des services fournis peut etre récupéré ici +EndPointIs=Les clients SOAP doivent envoyer leur requetes vers l'endpoint Dolibarr à l'URL diff --git a/htdocs/webservices/server.php b/htdocs/webservices/server.php index 88a330f5db3..6bbd4445e6d 100644 --- a/htdocs/webservices/server.php +++ b/htdocs/webservices/server.php @@ -32,7 +32,15 @@ require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP dol_syslog("Call Dolibarr webservices interfaces"); -// TODO Enable and test if module web services is enabled +// Enable and test if module web services is enabled +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) +{ + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive",'WebServices').'.

'; + print $langs->trans("ToActivateModule"); + exit; +} // Create the soap Object $server = new soap_server();