From 2b966e630b328df1641aeca03e9adb0b6fda68e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Oct 2017 19:49:48 +0100 Subject: [PATCH 1/6] Doc --- ChangeLog | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0a334a9c84..e0c9ad462a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,8 +18,7 @@ FIX: API to get object does not return data of linked objects FIX: Bad localtax apply FIX: Bad ressource list in popup in gantt view FIX: bankentries search conciliated if val 0 -FIX: hook formObjectOptions() must use $expe and not $object which i… -FIX: hook formObjectOptions() must use $expe and not $object which is an order here +FIX: hook formObjectOptions() must use $expe and not $object FIX: make of link to other object during creation FIX: Missing function getLinesArray FIX: old batch not shown in multi shipping From 3db101ffdda18d203133f0321b399858bd1de938 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Oct 2017 01:06:07 +0100 Subject: [PATCH 2/6] Clean packager --- build/makepack-dolibarr.pl | 4 + htdocs/includes/stripe/build.php | 0 htdocs/modulebuilder/template/.gitattributes | 2 +- .../template/dev/dolistore/README.md | 87 ------------------- .../template/dev/dolistore/keywords-de.txt | 0 .../template/dev/dolistore/keywords-en.txt | 0 .../template/dev/dolistore/keywords-es.txt | 0 .../template/dev/dolistore/keywords-fr.txt | 0 .../template/dev/dolistore/keywords-it.txt | 0 .../template/dev/dolistore/long_desc-de.html | 0 .../template/dev/dolistore/long_desc-en.html | 0 .../template/dev/dolistore/long_desc-es.html | 0 .../template/dev/dolistore/long_desc-fr.html | 0 .../template/dev/dolistore/long_desc-it.html | 0 .../template/dev/dolistore/name-de.txt | 1 - .../template/dev/dolistore/name-en.txt | 1 - .../template/dev/dolistore/name-es.txt | 1 - .../template/dev/dolistore/name-fr.txt | 1 - .../template/dev/dolistore/name-it.txt | 1 - .../template/dev/dolistore/short_desc-de.html | 0 .../template/dev/dolistore/short_desc-en.html | 0 .../template/dev/dolistore/short_desc-es.html | 0 .../template/dev/dolistore/short_desc-fr.html | 0 .../template/dev/dolistore/short_desc-it.html | 0 .../template/dev/git-hooks/post-commit | 0 .../template/dev/git-hooks/pre-commit | 0 .../template/dev/git-hooks/pre-push | 0 .../modulebuilder/template/dev/newmodule.sh | 68 --------------- .../template/scripts/myobject.php | 0 29 files changed, 5 insertions(+), 161 deletions(-) mode change 100644 => 100755 htdocs/includes/stripe/build.php delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/README.md delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-de.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-en.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-es.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-fr.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/keywords-it.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-de.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-en.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-es.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-fr.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/long_desc-it.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-de.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-en.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-es.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-fr.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/name-it.txt delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-de.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-en.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-es.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-fr.html delete mode 100644 htdocs/modulebuilder/template/dev/dolistore/short_desc-it.html mode change 100644 => 100755 htdocs/modulebuilder/template/dev/git-hooks/post-commit mode change 100644 => 100755 htdocs/modulebuilder/template/dev/git-hooks/pre-commit mode change 100644 => 100755 htdocs/modulebuilder/template/dev/git-hooks/pre-push delete mode 100644 htdocs/modulebuilder/template/dev/newmodule.sh mode change 100644 => 100755 htdocs/modulebuilder/template/scripts/myobject.php diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index e0fa89d924d..2802e55c702 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -571,6 +571,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mobiledetect/mobiledetectlib/.gitmodules`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/parsedown/LICENSE.txt`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/.gitattributes`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/license.md`; @@ -579,6 +580,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Examples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/unitTests`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/license.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/LICENSE`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/ae_fonts_*`; @@ -590,6 +592,8 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; + print "Remove subdir of custom dir\n"; print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; diff --git a/htdocs/includes/stripe/build.php b/htdocs/includes/stripe/build.php old mode 100644 new mode 100755 diff --git a/htdocs/modulebuilder/template/.gitattributes b/htdocs/modulebuilder/template/.gitattributes index 58065c729fc..0d2c67e38e6 100644 --- a/htdocs/modulebuilder/template/.gitattributes +++ b/htdocs/modulebuilder/template/.gitattributes @@ -13,7 +13,7 @@ *.lang text eol=lf *.txt text eol=lf *.md text eol=lf -*.bat text eol=crlf +*.bat text eol=lf # Denote all files that are truly binary and should not be modified. *.ico binary diff --git a/htdocs/modulebuilder/template/dev/dolistore/README.md b/htdocs/modulebuilder/template/dev/dolistore/README.md deleted file mode 100644 index d322d2c98fe..00000000000 --- a/htdocs/modulebuilder/template/dev/dolistore/README.md +++ /dev/null @@ -1,87 +0,0 @@ -Dolistore -========= - -[Dolistore](https://dolistore.com) is the marketplace for Dolibarr modules. - -This directory contains templates assets that may be useful for publication. - -Images ------- - -### Logo - -See [img folder README](../img/README.md). - -### Screenshots - -Texts ------ - -All texts needs 5 languages versions for: -- en (English) -- fr (Français) -- es (Español) -- it (Italiano) -- de (Deutsch) - -### Name - -The module's marketed name. - -### Price - -Expressed in Euro (€). -Keep in mind that Dolistore will keep a 20% markup. - -### Categories - -- [x] Modules/Plugins -- [ ] Skins and Templates -- [ ] Tools and documentation -- [ ] Skins -- [ ] Document templates -- [ ] System tools -- [ ] CRM -- [ ] ECM -- [ ] Human Relationship -- [ ] Products, Services or Stock -- [ ] Project or collaborative -- [ ] Interfaces -- [ ] Other -- [ ] Reporting or search -- [ ] User's interface -- [ ] 2Report sub-modules -- [ ] Accountancy - -*The list may change. Check [Dolistore](https://dolistore.com) for up-to-date information.* - -### Short description - -A short description of the modules main features. -400 characters max. - -### Keywords - -Comma separated lists. -eg: ```template,dev,module``` - -### Long description - -The long description of your module. - -Suggested technical data: - -Version: 1.0.0 -Publisher: MyCompany -Licence: GPLv3+ -User interface language(s): English -Help/Support: None / Forum www.dolibarr.org / Mail at contact@example.com -Prerequisites: -- Dolibarr min version: 3.8 -- Dolibarr max version: 3.9.* -- PHP: ≥5.3 -Install: -- Download the module's archive file (.zip file) from DoliStore.com. -- Put the file into the custom directory of Dolibarr. -- Uncompress the zip file, for example with ```unzip modulefile_version.zip``` command. -- Module is then available and can be activated. diff --git a/htdocs/modulebuilder/template/dev/dolistore/keywords-de.txt b/htdocs/modulebuilder/template/dev/dolistore/keywords-de.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/keywords-en.txt b/htdocs/modulebuilder/template/dev/dolistore/keywords-en.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/keywords-es.txt b/htdocs/modulebuilder/template/dev/dolistore/keywords-es.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/keywords-fr.txt b/htdocs/modulebuilder/template/dev/dolistore/keywords-fr.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/keywords-it.txt b/htdocs/modulebuilder/template/dev/dolistore/keywords-it.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/long_desc-de.html b/htdocs/modulebuilder/template/dev/dolistore/long_desc-de.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/long_desc-en.html b/htdocs/modulebuilder/template/dev/dolistore/long_desc-en.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/long_desc-es.html b/htdocs/modulebuilder/template/dev/dolistore/long_desc-es.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/long_desc-fr.html b/htdocs/modulebuilder/template/dev/dolistore/long_desc-fr.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/long_desc-it.html b/htdocs/modulebuilder/template/dev/dolistore/long_desc-it.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/name-de.txt b/htdocs/modulebuilder/template/dev/dolistore/name-de.txt deleted file mode 100644 index d177fbf2ba9..00000000000 --- a/htdocs/modulebuilder/template/dev/dolistore/name-de.txt +++ /dev/null @@ -1 +0,0 @@ -Mein modul diff --git a/htdocs/modulebuilder/template/dev/dolistore/name-en.txt b/htdocs/modulebuilder/template/dev/dolistore/name-en.txt deleted file mode 100644 index bf608d557d4..00000000000 --- a/htdocs/modulebuilder/template/dev/dolistore/name-en.txt +++ /dev/null @@ -1 +0,0 @@ -My module diff --git a/htdocs/modulebuilder/template/dev/dolistore/name-es.txt b/htdocs/modulebuilder/template/dev/dolistore/name-es.txt deleted file mode 100644 index a0ec54ad842..00000000000 --- a/htdocs/modulebuilder/template/dev/dolistore/name-es.txt +++ /dev/null @@ -1 +0,0 @@ -My módulo diff --git a/htdocs/modulebuilder/template/dev/dolistore/name-fr.txt b/htdocs/modulebuilder/template/dev/dolistore/name-fr.txt deleted file mode 100644 index 310ebcf10a5..00000000000 --- a/htdocs/modulebuilder/template/dev/dolistore/name-fr.txt +++ /dev/null @@ -1 +0,0 @@ -Mon module diff --git a/htdocs/modulebuilder/template/dev/dolistore/name-it.txt b/htdocs/modulebuilder/template/dev/dolistore/name-it.txt deleted file mode 100644 index a196c1511a1..00000000000 --- a/htdocs/modulebuilder/template/dev/dolistore/name-it.txt +++ /dev/null @@ -1 +0,0 @@ -Il mio modulo diff --git a/htdocs/modulebuilder/template/dev/dolistore/short_desc-de.html b/htdocs/modulebuilder/template/dev/dolistore/short_desc-de.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/short_desc-en.html b/htdocs/modulebuilder/template/dev/dolistore/short_desc-en.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/short_desc-es.html b/htdocs/modulebuilder/template/dev/dolistore/short_desc-es.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/short_desc-fr.html b/htdocs/modulebuilder/template/dev/dolistore/short_desc-fr.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/dolistore/short_desc-it.html b/htdocs/modulebuilder/template/dev/dolistore/short_desc-it.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/template/dev/git-hooks/post-commit b/htdocs/modulebuilder/template/dev/git-hooks/post-commit old mode 100644 new mode 100755 diff --git a/htdocs/modulebuilder/template/dev/git-hooks/pre-commit b/htdocs/modulebuilder/template/dev/git-hooks/pre-commit old mode 100644 new mode 100755 diff --git a/htdocs/modulebuilder/template/dev/git-hooks/pre-push b/htdocs/modulebuilder/template/dev/git-hooks/pre-push old mode 100644 new mode 100755 diff --git a/htdocs/modulebuilder/template/dev/newmodule.sh b/htdocs/modulebuilder/template/dev/newmodule.sh deleted file mode 100644 index 92f4875cbf6..00000000000 --- a/htdocs/modulebuilder/template/dev/newmodule.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# Copyright (C) 2014 Raphaël Doursenaud -# -# 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 3 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, see . - -VERSION=0.0.1 -USAGE="Usage: newmodule.sh NewName" - -# TODO: check depedencies presence (find, sed and rename) -# TODO: allow execution from build directory -# TODO: validate parameter -# TODO: use multiple word parameter, for example "My module is awesome" which should lead to "MyModuleIsAwesome" and "mymoduleisawesome" so we can also fix language strings -# TODO: add module ID management (language files…) -# TODO: add oneliner description management -# TODO: add copyright management - -if [ $# == 0 ] ; then - echo ${USAGE} - exit 1; -fi - -ToLower () { - echo $(echo $1 | tr '[:upper:]' '[:lower:]') -} -ToUpper () { - echo $(echo $1 | tr '[:lower:]' '[:upper:]') -} - -CAMELORIG="MyModule" -LOWERORIG=$(ToLower ${CAMELORIG}) -UPPERORIG=$(ToUpper ${CAMELORIG}) -cameltarget=$(echo $1) -lowertarget=$(ToLower $1) -uppertarget=$(ToUpper $1) -thisscript=`basename $0` - -# Rewrite occurences -find . -not -iwholename '*.git*' -not -name "${thisscript}" -type f -print0 | xargs -0 sed -i'' -e"s/${CAMELORIG}/${cameltarget}/g" -find . -not -iwholename '*.git*' -not -name "${thisscript}" -type f -print0 | xargs -0 sed -i'' -e"s/${LOWERORIG}/${lowertarget}/g" -find . -not -iwholename '*.git*' -not -name "${thisscript}" -type f -print0 | xargs -0 sed -i'' -e"s/${UPPERORIG}/${uppertarget}/g" - -# Rename files -for file in $(find . -not -iwholename '*.git*' -name "*${CAMELORIG}*" -type f) -do - rename ${CAMELORIG} ${cameltarget} ${file} -done -for file in $(find . -not -iwholename '*.git*' -name "*${LOWERORIG}*" -type f) -do - rename ${LOWERORIG} ${lowertarget} ${file} -done -for file in $(find . -not -iwholename '*.git*' -name "*${UPPERORIG}*" -type f) -do - rename ${UPPERORIG} ${uppertarget} ${file} -done - -# TODO: add instructions about renaming vars (ack --php -i my) -# TODO: add instructions about renaming files (ls -R|grep -i my) diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php old mode 100644 new mode 100755 From a6879775bb787b34a38f055ae97c1c2eec382045 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Nov 2017 19:58:46 +0100 Subject: [PATCH 3/6] FIX Search into language is ok for file into external modules two. --- htdocs/admin/translation.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 51a7d32522e..651335d0a6d 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -338,6 +338,9 @@ if ($mode == 'searchkey') $recordtoshow=array(); + // Search modules dirs + $modulesdir = dolGetModulesDirs(); + $nbempty=0; /*var_dump($langcode); var_dump($transkey); @@ -351,22 +354,23 @@ if ($mode == 'searchkey') } else { - // Load all translations keys - foreach($conf->file->dol_document_root as $keydir => $searchdir) + // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root) + foreach($modulesdir as $keydir => $tmpsearchdir) { - // Directory of translation files - $dir_lang = $searchdir."/langs/".$langcode; - $dir_lang_osencoded=dol_osencode($dir_lang); + $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/' - $filearray=dol_dir_list($dir_lang_osencoded,'files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1); + // Directory of translation files + $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels + $dir_lang_osencoded=dol_osencode($dir_lang); - foreach($filearray as $file) - { - $tmpfile=preg_replace('/.lang/i', '', basename($file['name'])); - $newlang->load($tmpfile, 0, 0, '', 0); // Load translation files + database overwrite - $newlangfileonly->load($tmpfile, 0, 0, '', 1); // Load translation files only - //print 'After loading lang '.$tmpfile.', newlang has '.count($newlang->tab_translate).' records
'."\n"; - } + $filearray=dol_dir_list($dir_lang_osencoded,'files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1); + foreach($filearray as $file) + { + $tmpfile=preg_replace('/.lang/i', '', basename($file['name'])); + $newlang->load($tmpfile, 0, 0, '', 0); // Load translation files + database overwrite + $newlangfileonly->load($tmpfile, 0, 0, '', 1); // Load translation files only + //print 'After loading lang '.$tmpfile.', newlang has '.count($newlang->tab_translate).' records
'."\n"; + } } // Now search into translation array From 91fbb4da416f774bab4df40e21eac419311d30ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Nov 2017 20:12:15 +0100 Subject: [PATCH 4/6] Fix changelog --- ChangeLog | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0c9ad462a1..e5966d0eec7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,6 @@ English Dolibarr ChangeLog ***** ChangeLog for 6.0.3 compared to 6.0.2 ***** - FIX: #7211 Update qty dispatched on qty change FIX: #7458 FIX: #7593 @@ -31,7 +30,6 @@ FIX: wrong key in selectarray FIX: wrong personnal project time spent ***** ChangeLog for 6.0.2 compared to 6.0.1 ***** - FIX: #7148 FIX: #7288 FIX: #7366 renaming table with pgsql @@ -65,7 +63,6 @@ FIX: wrong basePath in the swagger view FIX: Implementation of a Luracast recommandation for the REST api server ***** ChangeLog for 6.0.1 compared to 6.0.* ***** - FIX: #7000 Dashboard link for late pending payment supplier invoices do not work FIX: #7325 Default VAT rate when editing template invoices is 0% FIX: #7330 @@ -107,7 +104,6 @@ FIX: CVE-2017-9840, CVE-2017-14238, CVE-2017-14239, CVE-2017-14240, CVE-2017-142 CVE-2017-14242 ***** ChangeLog for 6.0.0 compared to 5.0.* ***** - NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). NEW: Add a payment module for Stripe. NEW: Add module "Product variant" (like red, blue for the product shoes) From 192dc43b876919c51be8360ea1660dd253577b50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Nov 2017 01:16:42 +0100 Subject: [PATCH 5/6] Fix regression --- htdocs/api/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index a0e8d337f5d..a102ad67539 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -128,7 +128,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' | foreach ($modulesdir as $dir) { // Search available module - dol_syslog("Scan directory ".$dir." for module descriptor to after search for API files"); + dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); $handle=@opendir(dol_osencode($dir)); if (is_resource($handle)) @@ -140,13 +140,13 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' | $module = strtolower($regmod[1]); $moduledirforclass = getModuleDirForApiClass($module); $modulenameforenabled = $module; - if ($module == 'propale') { $moduleforenabled='propal'; } + if ($module == 'propale') { $modulenameforenabled='propal'; } - //dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass); + dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass); // Defined if module is enabled $enabled=true; - if (empty($conf->$moduleforenabled->enabled)) $enabled=false; + if (empty($conf->$modulenameforenabled->enabled)) $enabled=false; if ($enabled) { From 59df957181506c92401e7f4c986482f1c13c1eee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Nov 2017 01:42:04 +0100 Subject: [PATCH 6/6] Fix return HTTP code 501 if calling a non existing api --- htdocs/api/index.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index a102ad67539..7bb062c03df 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -235,7 +235,13 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' if ($module == 'order') { $classname='Commande'; } //var_dump($classfile);var_dump($classname);exit; - require_once $dir_part_file; + $res = include_once $dir_part_file; + if (! $res) + { + print 'API not found (failed to include API file)'; + header('HTTP/1.1 501 API not found (failed to include API file)'); + exit(0); + } if (class_exists($classname.'Api')) $api->r->addAPIClass($classname.'Api', '/'); } else @@ -246,7 +252,14 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' $dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php'); $classname=ucwords($module); - require_once $dir_part_file; + $res = include_once $dir_part_file; + if (! $res) + { + print 'API not found (failed to include API file)'; + header('HTTP/1.1 501 API not found (failed to include API file)'); + exit(0); + } + if (class_exists($classname)) $api->r->addAPIClass($classname); } }