From f67f0df6099c976d87a7e1a15da0430309052936 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 12:11:39 +0100 Subject: [PATCH 01/32] Fix preview link not visible with long file names --- htdocs/core/class/html.formfile.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 74ea44c84e7..ebbdc22a097 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -716,13 +716,13 @@ class FormFile if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper // Show file name with link to download - $out.= ''; + $out.= ''; $out.= 'trans("File").': '.$file["name"]); - $out.= $file["name"]; + $out.= dol_trunc($file["name"], 150); $out.= ''."\n"; $out.= $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= ''; @@ -1087,7 +1087,7 @@ class FormFile print ''; // File name - print ''; + print ''; // Show file name with link to download //print "XX".$file['name']; //$file['name'] must be utf8 @@ -1110,7 +1110,7 @@ class FormFile } else { - print $file['name']; + print dol_trunc($file['name'], 200); print ''; } // Preview link From d233c152a7af042fa6ba716b8b66f19c8d75a7db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 14:18:05 +0100 Subject: [PATCH 02/32] Code comment --- htdocs/compta/facture/class/facture.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 12d6fa10769..7edc3b65b41 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3235,7 +3235,6 @@ class Facture extends CommonInvoice $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; $sql.= ' WHERE pf.'.$field.' = '.$this->id; - //$sql.= ' WHERE pf.'.$field.' = 1'; $sql.= ' AND pf.'.$field2.' = p.rowid'; $sql.= ' AND p.fk_paiement = t.id'; $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; From 8db6b1ecc03825b039348502ece1555f54025d12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 17:19:04 +0100 Subject: [PATCH 03/32] Fix package for debian --- build/debian/rules | 13 ++++++++++++- build/makepack-dolibarr.pl | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build/debian/rules b/build/debian/rules index 50866c03e68..1fe2360133f 100755 --- a/build/debian/rules +++ b/build/debian/rules @@ -10,12 +10,23 @@ export DH_OPTIONS=-v %: dh $@ +# Replace standard debian package actions with a new one +######################################################## + override_dh_auto_clean: # Do nothing. Added to disable launchpad to use bugged dh_auto_clean search for ant override_dh_auto_build: # Do nothing. Added to disable launchpad to use bugged dh_auto_build search for ant - + +#override_dh_compress: +# dh_compress --no-act -X.png + +# We disable this for png file because it modify content of original file so make +# the dolibarr signature not valid. +override_dh_strip_nondeterminism: + dh_strip_nondeterminism -X.png + override_dh_install: dh_install # Delete files diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 7da6d180dcb..aa73d4abf65 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -558,7 +558,7 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries - #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball for official debian, not for the rest $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`; @@ -915,8 +915,8 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mike42/escpos-php/LICENSE.md`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mobiledetect/mobiledetectlib/LICENSE.txt`; - # Removed files we don't need - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source`; + # Removed files we don't need (already removed) + #$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source`; # Rename upstream changelog to match debian rules $ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`; @@ -978,7 +978,7 @@ if ($nboftargetok) { $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/actions_mymodule.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_myobject.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_mymodule.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindex.php`; From c513ffe1f794e587a30290d5e8a9c7fe976c104c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 18:21:18 +0100 Subject: [PATCH 04/32] Fix debian package --- .../patches/use-etc-dolibarr-conf.patch | 26 ----------------- build/rpm/dolibarr-forrpm.patch | 28 ------------------- htdocs/filefunc.inc.php | 8 ++++-- htdocs/support/inc.php | 9 ++++-- 4 files changed, 11 insertions(+), 60 deletions(-) diff --git a/build/debian/patches/use-etc-dolibarr-conf.patch b/build/debian/patches/use-etc-dolibarr-conf.patch index 3bca20ee66f..04543e5fac6 100644 --- a/build/debian/patches/use-etc-dolibarr-conf.patch +++ b/build/debian/patches/use-etc-dolibarr-conf.patch @@ -9,19 +9,6 @@ Forwarded: not-needed Last-Update: 2013-07-29 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/htdocs/filefunc.inc.php -+++ b/htdocs/filefunc.inc.php -@@ -63,8 +63,8 @@ $conffiletoshowshort = "conf.php"; - $conffile = "conf/conf.php"; - $conffiletoshow = "htdocs/conf/conf.php"; - // For debian/redhat like systems --//$conffile = "/etc/dolibarr/conf.php"; --//$conffiletoshow = "/etc/dolibarr/conf.php"; -+$conffile = "/etc/dolibarr/conf.php"; -+$conffiletoshow = "/etc/dolibarr/conf.php"; - - - // Include configuration --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -73,8 +73,8 @@ $conffiletoshowshort = "conf.php"; @@ -34,17 +21,4 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +$conffiletoshow = "/etc/dolibarr/conf.php"; - // Load conf file if it is already defined ---- a/htdocs/support/inc.php -+++ b/htdocs/support/inc.php -@@ -69,8 +69,8 @@ $conffiletoshowshort = "conf.php"; - $conffile = "../conf/conf.php"; - $conffiletoshow = "htdocs/conf/conf.php"; - // For debian/redhat like systems --//$conffile = "/etc/dolibarr/conf.php"; --//$conffiletoshow = "/etc/dolibarr/conf.php"; -+$conffile = "/etc/dolibarr/conf.php"; -+$conffiletoshow = "/etc/dolibarr/conf.php"; - - // Load conf file if it is already defined diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch index 6c484345be9..ae9cf5cb2de 100644 --- a/build/rpm/dolibarr-forrpm.patch +++ b/build/rpm/dolibarr-forrpm.patch @@ -1,17 +1,3 @@ -diff -up htdocs/filefunc.inc.php.patch htdocs/filefunc.inc.php ---- htdocs/filefunc.inc.php.patch 2011-09-03 02:32:48.666952000 +0200 -+++ htdocs/filefunc.inc.php 2011-09-03 02:33:00.510952001 +0200 -@@ -63,8 +63,8 @@ - $conffile = "conf/conf.php"; - $conffiletoshow = "htdocs/conf/conf.php"; - // For debian/redhat like systems --//$conffile = "/etc/dolibarr/conf.php"; --//$conffiletoshow = "/etc/dolibarr/conf.php"; -+$conffile = "/etc/dolibarr/conf.php"; -+$conffiletoshow = "/etc/dolibarr/conf.php"; - - - // Include configuration diff -up htdocs/install/inc.php.patch htdocs/install/inc.php --- htdocs/install/inc.php.patch 2011-09-03 02:33:26.450952000 +0200 +++ htdocs/install/inc.php 2011-09-03 02:33:36.286952001 +0200 @@ -25,18 +11,4 @@ diff -up htdocs/install/inc.php.patch htdocs/install/inc.php +$conffiletoshow = "/etc/dolibarr/conf.php"; - // Load conf file if it is already defined -diff -up htdocs/support/inc.php.patch htdocs/support/inc.php ---- htdocs/support/inc.php.patch 2011-09-03 02:34:39.606952000 +0200 -+++ htdocs/support/inc.php 2011-09-03 02:33:59.814952000 +0200 -@@ -69,8 +69,8 @@ - $conffile = "../conf/conf.php"; - $conffiletoshow = "htdocs/conf/conf.php"; - // For debian/redhat like systems --//$conffile = "/etc/dolibarr/conf.php"; --//$conffiletoshow = "/etc/dolibarr/conf.php"; -+$conffile = "/etc/dolibarr/conf.php"; -+$conffiletoshow = "/etc/dolibarr/conf.php"; - - // Load conf file if it is already defined diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 256501048ba..f0f35ada857 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -62,9 +62,11 @@ $conffiletoshowshort = "conf.php"; $conffile = "conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php"; // For debian/redhat like systems -//$conffile = "/etc/dolibarr/conf.php"; -//$conffiletoshow = "/etc/dolibarr/conf.php"; - +if (! file_exists($conffile)) +{ + $conffile = "/etc/dolibarr/conf.php"; + $conffiletoshow = "/etc/dolibarr/conf.php"; +} // Include configuration // --- End of part replaced by Dolibarr packager makepack-dolibarr diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index 2ec9a70351b..c1cf83097b6 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -58,8 +58,11 @@ $conffiletoshowshort = "conf.php"; $conffile = "../conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php"; // For debian/redhat like systems -//$conffile = "/etc/dolibarr/conf.php"; -//$conffiletoshow = "/etc/dolibarr/conf.php"; +if (! file_exists($conffile)) +{ + $conffile = "/etc/dolibarr/conf.php"; + $conffiletoshow = "/etc/dolibarr/conf.php"; +} // Load conf file if it is already defined @@ -208,7 +211,7 @@ function pHeader($soutitre,$next,$action='none') // On force contenu dans format sortie header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print ''."\n"; From a4b155fc91eb3fdca514cd8592ebb2a375c7726f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 20:42:40 +0100 Subject: [PATCH 05/32] Fix typo and --- htdocs/langs/en_US/admin.lang | 14 +++++++------- htdocs/langs/en_US/errors.lang | 2 +- htdocs/langs/en_US/main.lang | 4 ++-- htdocs/langs/en_US/trips.lang | 2 +- htdocs/langs/en_US/users.lang | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f5daf6c8d27..2daa092c5db 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -341,7 +341,7 @@ ErrorCantUseRazIfNoYearInMask=Error, can't use option @ to reset counter each ye ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask. UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system. UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
It must be the octal value (for example, 0666 means read and write for everyone).
This parameter is useless on a Windows server. -SeeWikiForAllTeam=Take a look at the wiki page for full list of all actors and their organisation +SeeWikiForAllTeam=Take a look at the wiki page for full list of all actors and their organization UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache) DisableLinkToHelpCenter=Hide link "Need help or support" on login page DisableLinkToHelp=Hide link to online help "%s" @@ -910,8 +910,8 @@ TypeOfRevenueStamp=Type of revenue stamp VATManagement=VAT Management VATIsUsedDesc=By default when creating prospects, invoices, orders etc the VAT rate follows the active standard rule:
If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.
If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule.
If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 ( The VAT should be paid by the buyer to the customoffice of his country and not to the seller). End of rule.
If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.
If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.
In any othe case the proposed default is VAT=0. End of rule. VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals ou small companies. -VATIsUsedExampleFR=In France, it means companies or organisations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared. -VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organisations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices. +VATIsUsedExampleFR=In France, it means companies or organizations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared. +VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organizations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices. ##### Local Taxes ##### LTRate=Rate LocalTax1IsNotUsed=Do not use second tax @@ -976,7 +976,7 @@ Host=Server DriverType=Driver type SummarySystem=System information summary SummaryConst=List of all Dolibarr setup parameters -MenuCompanySetup=Company/Organisation +MenuCompanySetup=Company/Organization DefaultMenuManager= Standard menu manager DefaultMenuSmartphoneManager=Smartphone menu manager Skin=Skin theme @@ -992,8 +992,8 @@ PermanentLeftSearchForm=Permanent search form on left menu DefaultLanguage=Default language to use (language code) EnableMultilangInterface=Enable multilingual interface EnableShowLogo=Show logo on left menu -CompanyInfo=Company/organisation information -CompanyIds=Company/organisation identities +CompanyInfo=Company/organization information +CompanyIds=Company/organization identities CompanyName=Name CompanyAddress=Address CompanyZip=Zip @@ -1549,7 +1549,7 @@ SupposedToBeInvoiceDate=Invoice date used Buy=Buy Sell=Sell InvoiceDateUsed=Invoice date used -YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Setup - Company/Organisation), so there is no VAT options to setup. +YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Setup - Company/Organization), so there is no VAT options to setup. AccountancyCode=Accounting Code AccountancyCodeSell=Sale account. code AccountancyCodeBuy=Purchase account. code diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 4ed104af7df..f87a30ecfb2 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -127,7 +127,7 @@ ErrorFailedToAddToMailmanList=Failed to add record %s to Mailman list %s or SPIP ErrorFailedToRemoveToMailmanList=Failed to remove record %s to Mailman list %s or SPIP base ErrorNewValueCantMatchOldValue=New value can't be equal to old one ErrorFailedToValidatePasswordReset=Failed to reinit password. May be the reinit was already done (this link can be used only one time). If not, try to restart the reinit process. -ErrorToConnectToMysqlCheckInstance=Connect to database fails. Check Mysql server is running (in most cases, you can launch it from command line with 'sudo /etc/init.d/mysql start'). +ErrorToConnectToMysqlCheckInstance=Connect to database fails. Check database server is running (for example, with mysql/mariadb, you can launch it from command line with 'sudo service mysql start'). ErrorFailedToAddContact=Failed to add contact ErrorDateMustBeBeforeToday=The date cannot be greater than today ErrorPaymentModeDefinedToWithoutSetup=A payment mode was set to type %s but setup of module Invoice was not completed to define information to show for this payment mode. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 933412e8688..cde8a485e59 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -44,7 +44,7 @@ ErrorConstantNotDefined=Parameter %s not defined ErrorUnknown=Unknown error ErrorSQL=SQL Error ErrorLogoFileNotFound=Logo file '%s' was not found -ErrorGoToGlobalSetup=Go to 'Company/Organisation' setup to fix this +ErrorGoToGlobalSetup=Go to 'Company/Organization' setup to fix this ErrorGoToModuleSetup=Go to Module setup to fix this ErrorFailedToSendMail=Failed to send mail (sender=%s, receiver=%s) ErrorFileNotUploaded=File was not uploaded. Check that size does not exceed maximum allowed, that free space is available on disk and that there is not already a file with same name in this directory. @@ -421,7 +421,7 @@ ActionRunningShort=In progress ActionDoneShort=Finished ActionUncomplete=Uncomplete LatestLinkedEvents=Latest %s linked events -CompanyFoundation=Company/Organisation +CompanyFoundation=Company/Organization ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party AddressesForCompany=Addresses for this third party diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index a5ab097aa0e..2b254bf91e7 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -12,7 +12,7 @@ ShowTrip=Show expense report NewTrip=New expense report LastExpenseReports=Latest %s expense reports AllExpenseReports=All expense reports -CompanyVisited=Company/organisation visited +CompanyVisited=Company/organization visited FeesKilometersOrAmout=Amount or kilometers DeleteTrip=Delete expense report ConfirmDeleteTrip=Are you sure you want to delete this expense report? diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 3c1a8644bf0..b34be6b4421 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -67,8 +67,8 @@ InternalUser=Internal user ExportDataset_user_1=Dolibarr's users and properties DomainUser=Domain user %s Reactivate=Reactivate -CreateInternalUserDesc=This form allows you to create an user internal to your company/organisation. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card. -InternalExternalDesc=An internal user is a user that is part of your company/organisation.
An external user is a customer, supplier or other.

In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display) +CreateInternalUserDesc=This form allows you to create an user internal to your company/organization. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card. +InternalExternalDesc=An internal user is a user that is part of your company/organization.
An external user is a customer, supplier or other.

In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display) PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group. Inherited=Inherited UserWillBeInternalUser=Created user will be an internal user (because not linked to a particular third party) From b3e567c31055c0e913faecade2f6d48d2b59b549 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 20:47:28 +0100 Subject: [PATCH 06/32] Fix rpm package for apache 2.4, selinux and php packages --- build/makepack-dolibarr.pl | 4 +-- build/rpm/dolibarr-forrpm.patch | 2 +- build/rpm/dolibarr_fedora.spec | 3 +-- build/rpm/dolibarr_generic.spec | 11 ++++---- build/rpm/dolibarr_mandriva.spec | 1 - build/rpm/dolibarr_opensuse.spec | 1 - build/rpm/httpd-dolibarr.conf | 44 +++++++++++++++++++++++++++----- 7 files changed, 46 insertions(+), 20 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index aa73d4abf65..839a8092a7c 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -767,8 +767,8 @@ if ($nboftargetok) { $cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'"; $ret=`$cmd`; - # Removed files we don't need - $ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/htdocs/includes/ckeditor/_source`; + # Removed files we don't need (already removed before) + #$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/htdocs/includes/ckeditor/_source`; print "Set permissions on files/dir\n"; $ret=`chmod -R 755 $BUILDROOT/$FILENAMETGZ2`; diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch index ae9cf5cb2de..5ea52664b98 100644 --- a/build/rpm/dolibarr-forrpm.patch +++ b/build/rpm/dolibarr-forrpm.patch @@ -1,7 +1,7 @@ diff -up htdocs/install/inc.php.patch htdocs/install/inc.php --- htdocs/install/inc.php.patch 2011-09-03 02:33:26.450952000 +0200 +++ htdocs/install/inc.php 2011-09-03 02:33:36.286952001 +0200 -@@ -71,8 +71,8 @@ +@@ -74,8 +74,8 @@ $conffile = "../conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php"; // For debian/redhat like systems diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 077aaeb9483..db3ca84ec03 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -25,7 +25,7 @@ BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build Group: Applications/Productivity -Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysql, php-adodb, php-nusoap, dejavu-sans-fonts +Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysqli, php-adodb, php-nusoap, dejavu-sans-fonts Requires: mysql-server, mysql #BuildRequires: desktop-file-utils @@ -215,7 +215,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico -%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 5b39bac7761..efffb54d092 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -46,7 +46,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} Group: Applications/Productivity -Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysql, php-adodb, php-nusoap, dejavu-sans-fonts +Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysqli, php-adodb, php-nusoap, dejavu-sans-fonts, php-mbstring, php-xml Requires: mysql-server, mysql BuildRequires: desktop-file-utils %else @@ -63,9 +63,9 @@ Requires: mysql-community-server, mysql-community-server-client BuildRequires: update-desktop-files fdupes %else Group: Applications/Productivity -Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap +Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mbstring, php-xml Requires: mysql-server, mysql -Requires: php-mysql >= 4.1.0 +Requires: php-mysqli >= 4.1.0 %endif %endif %endif @@ -295,7 +295,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico -%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt @@ -441,8 +440,8 @@ if [ "x$os" = "xfedora-redhat" -a -s /sbin/restorecon ]; then %else echo Add SE Linux permissions for dolibarr # semanage add records into /etc/selinux/targeted/contexts/files/file_contexts.local - semanage fcontext -a -t httpd_sys_script_rw_t "/etc/dolibarr(/.*?)" - semanage fcontext -a -t httpd_sys_script_rw_t "/var/lib/dolibarr(/.*?)" + semanage fcontext -a -t httpd_sys_rw_content_t "/etc/dolibarr(/.*)?" + semanage fcontext -a -t httpd_sys_rw_content_t "/var/lib/dolibarr(/.*)?" restorecon -R -v /etc/dolibarr restorecon -R -v /var/lib/dolibarr %endif diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 1034615c80a..438f2bd096d 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -212,7 +212,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico -%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index eb1887f229f..aa3844073a7 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -223,7 +223,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico -%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/build/rpm/httpd-dolibarr.conf b/build/rpm/httpd-dolibarr.conf index 5e778e15b38..1126d4fe442 100644 --- a/build/rpm/httpd-dolibarr.conf +++ b/build/rpm/httpd-dolibarr.conf @@ -15,8 +15,14 @@ Alias /dolibarr /usr/share/dolibarr/htdocs # Directory for web pages - Order deny,allow - Allow from all + = 2.3> + Require all granted + + + Order deny,allow + Allow from all + + DirectoryIndex index.php Options +FollowSymLinks +Indexes @@ -60,27 +66,51 @@ Alias /dolibarr /usr/share/dolibarr/htdocs # Directory for public pages - AllowOverride All + = 2.3> + Require all granted + + Order deny,allow Allow from all + + + AllowOverride All # Config files - AllowOverride All + = 2.3> + Require all granted + + Order deny,allow Allow from all + + + AllowOverride All # Directory for data files - AllowOverride All + = 2.3> + Require all granted + + Order deny,allow Allow from all + + + AllowOverride All - AllowOverride All - Order deny,allow + = 2.3> + Require all granted + + + Order allow,deny Allow from all + + + AllowOverride All From 9bed2ce8e2a25918a9ea0c5a8463e02153eb7f88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 22:00:34 +0100 Subject: [PATCH 07/32] Fix ignore file integrity check on filefunc.inc.php for deb/rpm package --- .../patches/use-etc-dolibarr-conf.patch | 13 +++++++++++ build/rpm/dolibarr-forrpm.patch | 14 ++++++++++++ build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_generic.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + htdocs/admin/system/dolibarr.php | 2 +- htdocs/core/lib/files.lib.php | 22 +++++++++++++++---- htdocs/filefunc.inc.php | 22 ++++--------------- 9 files changed, 54 insertions(+), 23 deletions(-) diff --git a/build/debian/patches/use-etc-dolibarr-conf.patch b/build/debian/patches/use-etc-dolibarr-conf.patch index 04543e5fac6..07346ad4e63 100644 --- a/build/debian/patches/use-etc-dolibarr-conf.patch +++ b/build/debian/patches/use-etc-dolibarr-conf.patch @@ -9,6 +9,19 @@ Forwarded: not-needed Last-Update: 2013-07-29 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/htdocs/filefunc.inc.php ++++ b/htdocs/filefunc.inc.php +@@ -63,8 +63,8 @@ $conffiletoshowshort = "conf.php"; + $conffile = "conf/conf.php"; + $conffiletoshow = "htdocs/conf/conf.php"; + // For debian/redhat like systems +-//$conffile = "/etc/dolibarr/conf.php"; +-//$conffiletoshow = "/etc/dolibarr/conf.php"; ++$conffile = "/etc/dolibarr/conf.php"; ++$conffiletoshow = "/etc/dolibarr/conf.php"; + + + // Include configuration --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -73,8 +73,8 @@ $conffiletoshowshort = "conf.php"; diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch index 5ea52664b98..5413702efa3 100644 --- a/build/rpm/dolibarr-forrpm.patch +++ b/build/rpm/dolibarr-forrpm.patch @@ -1,3 +1,17 @@ +diff -up htdocs/filefunc.inc.php.patch htdocs/filefunc.inc.php +--- htdocs/filefunc.inc.php.patch 2011-09-03 02:32:48.666952000 +0200 ++++ htdocs/filefunc.inc.php 2011-09-03 02:33:00.510952001 +0200 +@@ -63,8 +63,8 @@ + $conffile = "conf/conf.php"; + $conffiletoshow = "htdocs/conf/conf.php"; + // For debian/redhat like systems +-//$conffile = "/etc/dolibarr/conf.php"; +-//$conffiletoshow = "/etc/dolibarr/conf.php"; ++$conffile = "/etc/dolibarr/conf.php"; ++$conffiletoshow = "/etc/dolibarr/conf.php"; + + + // Include configuration diff -up htdocs/install/inc.php.patch htdocs/install/inc.php --- htdocs/install/inc.php.patch 2011-09-03 02:33:26.450952000 +0200 +++ htdocs/install/inc.php 2011-09-03 02:33:36.286952001 +0200 diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index db3ca84ec03..6df6ccf052e 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -215,6 +215,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico +%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index efffb54d092..f99836b7f74 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -295,6 +295,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico +%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 438f2bd096d..1034615c80a 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -212,6 +212,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico +%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index aa3844073a7..eb1887f229f 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -223,6 +223,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/*.ico +%_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php %_datadir/dolibarr/htdocs/*.txt diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 8c4711f98c0..c36db521f70 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -49,7 +49,7 @@ $version='0.0'; if ($action == 'getlastversion') { - $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); + $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); $sfurl = simplexml_load_string($result['content']); } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 206d1bb8099..f62fb14c68b 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2777,28 +2777,42 @@ function dol_readcachefile($directory, $filename) */ function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathref = '', &$checksumconcat = array()) { + global $conffile; + $exclude = 'install'; foreach ($dir->md5file as $file) // $file is a simpleXMLElement { $filename = $path.$file['name']; $file_list['insignature'][] = $filename; + $expectedmd5 = (string) $file; //if (preg_match('#'.$exclude.'#', $filename)) continue; if (!file_exists($pathref.'/'.$filename)) { - $file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file); + $file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5); } else { $md5_local = md5_file($pathref.'/'.$filename); - if ($md5_local != (string) $file) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file, 'md5'=>(string) $md5_local); - $checksumconcat[] = $md5_local; + + if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php') // For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package + { + $checksumconcat[] = $expectedmd5; + } + else + { + if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local); + $checksumconcat[] = $md5_local; + } } } - foreach ($dir->dir as $subdir) getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat); + foreach ($dir->dir as $subdir) // $subdir['name'] is '' or '/accountancy/admin' for example + { + getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat); + } return $file_list; } diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index f0f35ada857..3e9fffae38b 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -62,30 +62,16 @@ $conffiletoshowshort = "conf.php"; $conffile = "conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php"; // For debian/redhat like systems -if (! file_exists($conffile)) -{ - $conffile = "/etc/dolibarr/conf.php"; - $conffiletoshow = "/etc/dolibarr/conf.php"; -} +//$conffile = "/etc/dolibarr/conf.php"; +//$conffiletoshow = "/etc/dolibarr/conf.php"; + // Include configuration // --- End of part replaced by Dolibarr packager makepack-dolibarr -// Replace conf filename with "conf" parameter on url by GET -/* Disabled. This is a serious security hole -if (! empty($_GET['conf'])) -{ - $confname=basename($_GET['conf']); - setcookie('dolconf', $confname, 0, '/'); - $conffile = 'conf/'.$confname.'.php'; -} else { - $confname=basename(empty($_COOKIE['dolconf']) ? 'conf' : $_COOKIE['dolconf']); - $conffile = 'conf/'.$confname.'.php'; -} -*/ // Include configuration -$result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect +$result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session { From 5c5d2cbefab36d744bc125c98011d88ea06adb0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 23:49:08 +0100 Subject: [PATCH 08/32] Fix smtp warning message --- htdocs/admin/mails.php | 15 ++++++++++++--- htdocs/langs/en_US/admin.lang | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index d482322a054..f6868eb7348 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -689,10 +689,19 @@ else print ''; - if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && ! in_array($action, array('testconnect', 'test', 'testhtml'))) + if (! in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = ''; + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') + { + $text.= $langs->trans("WarningPHPMail"); + } + //$conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS='1.2.3.4'; + if (! empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) + { + $text.= ($text?'
':'').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); + } + if ($text) print info_admin($text); } // Run the test to connect diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2daa092c5db..30df45facd2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -448,7 +448,8 @@ ModuleCompanyCodePanicum=Return an empty accounting code. ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... -WarningPHPMail=WARNING: Some email providers (like Yahoo) does not allow you to send an email from another server than the Yahoo server if the email address used as a sender is your Yahoo email (like myemail@yahoo.com, myemail@yahoo.fr, ...). Your current setup use the server of the application to send email, so some recipients (the one compatible with the restrictive DMARC protocol), will ask Yahoo if they can accept your email and Yahoo will respond "no" because the server is not a server owned by Yahoo, so few of your sent Emails may not be accepted.
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). +WarningPHPMail=WARNING: It is often better to setup outgoing email to use the email server of your provider than the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted.
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). +WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of your ERP CRM application: %s. ClickToShowDescription=Click to show description DependsOn=This module need the module(s) RequiredBy=This module is required by module(s) From 46c941c823735364e05b8d0ff5cd13f8d0dd7240 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Feb 2018 23:57:35 +0100 Subject: [PATCH 09/32] Translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 30df45facd2..efb9839ade2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -448,7 +448,7 @@ ModuleCompanyCodePanicum=Return an empty accounting code. ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... -WarningPHPMail=WARNING: It is often better to setup outgoing email to use the email server of your provider than the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted.
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). +WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted (be car also to your email provider sending quota).
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of your ERP CRM application: %s. ClickToShowDescription=Click to show description DependsOn=This module need the module(s) From ab6d0d2530ecffabbe66a3076d87c3e21ab6da79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Feb 2018 01:16:52 +0100 Subject: [PATCH 10/32] Fix errors --- htdocs/contrat/class/contrat.class.php | 4 +- htdocs/core/lib/functions.lib.php | 100 ++++++++++++------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0e4b7a1c8f9..190de79aa17 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -283,7 +283,7 @@ class Contrat extends CommonObject if ($result < 0) { $error++; - $this->errors = $contratline->error; + $this->error = $contratline->error; $this->errors = $contratline->errors; break; } @@ -338,7 +338,7 @@ class Contrat extends CommonObject if ($result < 0) { $error++; - $this->errors = $contratline->error; + $this->error = $contratline->error; $this->errors = $contratline->errors; break; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 62bda6b57cb..0cc2fb0446f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2205,19 +2205,19 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep if (dol_strlen($phone) == 10) { $newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2); } - elseif (dol_strlen($newphone) == 7) + elseif (dol_strlen($phone) == 7) { $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2); } - elseif (dol_strlen($newphone) == 9) + elseif (dol_strlen($phone) == 9) { $newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2); } - elseif (dol_strlen($newphone) == 11) + elseif (dol_strlen($phone) == 11) { $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); } - elseif (dol_strlen($newphone) == 12) + elseif (dol_strlen($phone) == 12) { $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } @@ -2230,252 +2230,252 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep } } elseif (strtoupper($countrycode) == "PT" ) - {//Portugal - if (dol_strlen($object) == 13) + {//Portugal + if (dol_strlen($phone) == 13) {//ex: +351_ABC_DEF_GHI $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "SR" ) {//Suriname - if (dol_strlen($object) == 10) + if (dol_strlen($phone) == 10) {//ex: +597_ABC_DEF $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3); } - elseif (dol_strlen($object) == 11) + elseif (dol_strlen($phone) == 11) {//ex: +597_ABC_DEFG $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,4); } } elseif (strtoupper($countrycode) == "DE" ) {//Allemagne - if (dol_strlen($object) == 14) + if (dol_strlen($phone) == 14) {//ex: +49_ABCD_EFGH_IJK $newphone= substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,4).$separ.substr($newphone,11,3); } - elseif (dol_strlen($object) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +49_ABC_DEFG_HIJ $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,4).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "ES") {//Espagne - if (dol_strlen($object) == 12) + if (dol_strlen($phone) == 12) {//ex: +34_ABC_DEF_GHI $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); } } elseif (strtoupper($countrycode) == "BF") {// Burkina Faso - if (dol_strlen($newphone) == 12) + if (dol_strlen($phone) == 12) {//ex : +22 A BC_DE_FG_HI $newphone= substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } elseif (strtoupper($countrycode) == "RO") {// Roumanie - if (dol_strlen($newphone) == 12) + if (dol_strlen($phone) == 12) {//ex : +40 AB_CDE_FG_HI $newphone= substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } elseif (strtoupper($countrycode) == "TR") - {//Turquie - if (dol_strlen($object) == 13) + {//Turquie + if (dol_strlen($phone) == 13) {//ex : +90 ABC_DEF_GHIJ $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); } } elseif (strtoupper($countrycode) == "US") {//Etat-Unis - if (dol_strlen($newphone) == 12) + if (dol_strlen($phone) == 12) {//ex: +1 ABC_DEF_GHIJ $newphone= substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,3).$separ.substr($newphone,8,4); } } elseif (strtoupper($countrycode) == "MX") {//Mexique - if (dol_strlen($newphone) == 12) + if (dol_strlen($phone) == 12) {//ex: +52 ABCD_EFG_HI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2); } - elseif (dol_strlen($newphone) == 11) + elseif (dol_strlen($phone) == 11) {//ex: +52 AB_CD_EF_GH - $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); + $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); } - elseif (dol_strlen($newphone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +52 ABC_DEF_GHIJ - $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); + $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); } } elseif (strtoupper($countrycode) == "ML") {//Mali - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +223 AB_CD_EF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } elseif (strtoupper($countrycode) == "TH") {//Thaïlande - if(dol_strlen($newphone) == 11) + if(dol_strlen($phone) == 11) {//ex: +66_ABC_DE_FGH $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3); } - elseif(dol_strlen($newphone) == 12) + elseif(dol_strlen($phone) == 12) {//ex: +66_A_BCD_EF_GHI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,3); } } elseif (strtoupper($countrycode) == "MU") {//Maurice - if(dol_strlen($newphone) == 11) + if(dol_strlen($phone) == 11) {//ex: +230_ABC_DE_FG $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); } - elseif(dol_strlen($newphone) == 12) + elseif(dol_strlen($phone) == 12) {//ex: +230_ABCD_EF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,4).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } elseif (strtoupper($countrycode) == "ZA") {//Afrique du sud - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +27_AB_CDE_FG_HI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } elseif (strtoupper($countrycode) == "SY") {//Syrie - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +963_AB_CD_EF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } - elseif(dol_strlen($newphone) == 13) + elseif(dol_strlen($phone) == 13) {//ex: +963_AB_CD_EF_GHI $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "AE") {//Emirats Arabes Unis - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +971_ABC_DEF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2); } - elseif(dol_strlen($newphone) == 13) + elseif(dol_strlen($phone) == 13) {//ex: +971_ABC_DEF_GHI $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); } - elseif(dol_strlen($newphone) == 14) + elseif(dol_strlen($phone) == 14) {//ex: +971_ABC_DEF_GHIK $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,4); } } elseif (strtoupper($countrycode) == "DZ") {//Algérie - if(dol_strlen($newphone) == 13) + if(dol_strlen($phone) == 13) {//ex: +213_ABC_DEF_GHI $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "BE") {//Belgique - if(dol_strlen($newphone) == 11) + if(dol_strlen($phone) == 11) {//ex: +32_ABC_DE_FGH $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3); } - elseif(dol_strlen($newphone) == 12) + elseif(dol_strlen($phone) == 12) {//ex: +32_ABC_DEF_GHI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); } } elseif (strtoupper($countrycode) == "PF") {//Polynésie française - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +689_AB_CD_EF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } elseif (strtoupper($countrycode) == "CO") {//Colombie - if(dol_strlen($newphone) == 13) + if(dol_strlen($phone) == 13) {//ex: +57_ABC_DEF_GH_IJ $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); } } elseif (strtoupper($countrycode) == "JO") {//Jordanie - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +962_A_BCD_EF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,1).$separ.substr($newphone,5,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); } } elseif (strtoupper($countrycode) == "MG") {//Madagascar - if(dol_strlen($newphone) == 13) - {//ex: +261_AB_CD_EF_GHI + if(dol_strlen($phone) == 13) + {//ex: +261_AB_CD_EF_GHI $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "GB") {//Royaume uni - if(dol_strlen($newphone) == 13) + if(dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ $newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "CH") {//Suisse - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +41_AB_CDE_FG_HI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } - elseif(dol_strlen($newphone) == 15) + elseif(dol_strlen($phone) == 15) {// +41_AB_CDE_FGH_IJKL $newphone =$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,3).$separ.substr($newphone,11,4); } } elseif (strtoupper($countrycode) == "TN") {//Tunisie - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +216_AB_CDE_FGH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); } } elseif (strtoupper($countrycode) == "GF") {//Guyane francaise - if(dol_strlen($newphone) == 13) + if(dol_strlen($phone) == 13) {//ex: +594_ABC_DE_FG_HI (ABC=594 de nouveau) $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); } } elseif (strtoupper($countrycode) == "GP") {//Guadeloupe - if(dol_strlen($newphone) == 13) + if(dol_strlen($phone) == 13) {//ex: +590_ABC_DE_FG_HI (ABC=590 de nouveau) $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); } } elseif (strtoupper($countrycode) == "MQ") {//Martinique - if(dol_strlen($newphone) == 13) + if(dol_strlen($phone) == 13) {//ex: +596_ABC_DE_FG_HI (ABC=596 de nouveau) $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); } } elseif (strtoupper($countrycode) == "IT") {//Italie - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +39_ABC_DEF_GHI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); } - elseif(dol_strlen($newphone) == 13) + elseif(dol_strlen($phone) == 13) {//ex: +39_ABC_DEF_GH_IJ $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); } } elseif(strtoupper($countrycode) == "AU") {//Australie - if(dol_strlen($newphone) == 12) + if(dol_strlen($phone) == 12) {//ex: +61_A_BCDE_FGHI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,4).$separ.substr($newphone,8,4); } From 60a77a6d857953afcf2c908f233ff28a083340e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 14:56:37 +0100 Subject: [PATCH 11/32] Add option to grab images into same dir or subdir --- htdocs/core/lib/website.lib.php | 105 +++-- htdocs/langs/en_US/website.lang | 5 + htdocs/website/class/websitepage.class.php | 5 +- htdocs/website/index.php | 476 +++++++++++---------- 4 files changed, 315 insertions(+), 276 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 8a7e14f8b0d..785231c6c87 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -222,9 +222,11 @@ function includeContainer($containeralias) * @param string $tmp Content to parse * @param string $action Var $action * @param string $modifylinks 0=Do not modify content, 1=Replace links with a link to viewimage + * @param int $grabimages 0=Do not grab images, 1=Grab images + * @param string $grabimagesinto 'root' or 'subpage' * @return void */ -function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0) +function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage') { global $conf; @@ -252,15 +254,18 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } $linkwithoutdomain = $regs[2][$key]; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + $dirforimages = '/'.$objectpage->pageurl; + if ($grabimagesinto == 'root') $dirforimages=''; + + // Define $filetosave and $filename + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } - - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); @@ -272,30 +277,33 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify if (empty($alreadygrabbed[$urltograbbis])) { - $tmpgeturl = getURLContent($urltograbbis); - if ($tmpgeturl['curl_error_no']) + if ($grabimages) { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $action='create'; - } - elseif ($tmpgeturl['http_code'] != '200') - { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); - $action='create'; - } - else - { - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. + $tmpgeturl = getURLContent($urltograbbis); + if ($tmpgeturl['curl_error_no']) + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); + $action='create'; + } + elseif ($tmpgeturl['http_code'] != '200') + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); + $action='create'; + } + else + { + $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. - dol_mkdir(dirname($filetosave)); + dol_mkdir(dirname($filetosave)); - $fp = fopen($filetosave, "w"); - fputs($fp, $tmpgeturl['content']); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); + $fp = fopen($filetosave, "w"); + fputs($fp, $tmpgeturl['content']); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); + } } } @@ -344,30 +352,33 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify if (empty($alreadygrabbed[$urltograbbis])) { - $tmpgeturl = getURLContent($urltograbbis); - if ($tmpgeturl['curl_error_no']) + if ($grabimages) { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $action='create'; - } - elseif ($tmpgeturl['http_code'] != '200') - { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); - $action='create'; - } - else - { - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. + $tmpgeturl = getURLContent($urltograbbis); + if ($tmpgeturl['curl_error_no']) + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); + $action='create'; + } + elseif ($tmpgeturl['http_code'] != '200') + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); + $action='create'; + } + else + { + $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. - dol_mkdir(dirname($filetosave)); + dol_mkdir(dirname($filetosave)); - $fp = fopen($filetosave, "w"); - fputs($fp, $tmpgeturl['content']); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); + $fp = fopen($filetosave, "w"); + fputs($fp, $tmpgeturl['content']); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); + } } } diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 996c6160deb..7a5c3a60849 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -69,3 +69,8 @@ WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts YouMustDefineTheHomePage=You must first define the default Home page OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is intiliazed by grabbing it from an external page (WYSIWYG editor will not be available) OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabber from an external site +GrabImagesInto=Grab also images found into css and page. +ImagesShouldBeSavedInto=Images should be saved into directory +WebsiteRootOfImages=Root directory for website images +SubdirOfPage=Sub-directory dedicated to page +AliasPageAlreadyExists=Alias page %s already exists \ No newline at end of file diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 408f5d194ae..f4848c70c91 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -113,13 +113,16 @@ class WebsitePage extends CommonObject */ public function create(User $user, $notrigger = false) { + $this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1); + $this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1); + return $this->createCommon($user, $notrigger); } /** * Load object in memory from the database * - * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one found. + * @param int $id Id object. If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set. * @param string $website_id Web site id (page name must also be filled if this parameter is used) * @param string $page Page name (website id must also be filled if this parameter is used) * diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8db771113ca..156d3ef8229 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -261,6 +261,9 @@ if ($action == 'addcontainer') if (GETPOST('fetchexternalurl','alpha')) { $urltograb=GETPOST('externalurl','alpha'); + $grabimages=GETPOST('grabimages','alpha'); + $grabimagesinto=GETPOST('grabimagesinto','alpha'); + //var_dump($grabimages);exit; } if ($urltograb) @@ -275,234 +278,248 @@ if ($action == 'addcontainer') { $urltograb.='/'; } + $pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam))); $urltograbdirwithoutslash = dirname($urltograb.'.'); $urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash); // Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots // and $urltograbdirrootwithoutslash is https://www.dolimed.com - $tmp = getURLContent($urltograb); - if ($tmp['curl_error_no']) + // Check pageurl is not already used + $tmpwebsitepage = new WebsitePage($db); + $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); + if ($result > 0) { + setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); $error++; - setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); $action='createcontainer'; } - elseif ($tmp['http_code'] != '200') + + if (! $error) { - $error++; - setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); - $action='createcontainer'; - } - else - { - // Remove comments - $tmp['content'] = removeHtmlComment($tmp['content']); - - preg_match('/(.*)<\/head>/is', $tmp['content'], $reg); - $head = $reg[1]; - - $objectpage->type_container = 'page'; - $objectpage->pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam))); - if (empty($objectpage->pageurl)) - { - $tmpdomain = getDomainFromURL($urltograb); - $objectpage->pageurl=$tmpdomain.'-home'; - } - - if (preg_match('/(.*)<\/title>/ims', $head, $regtmp)) + $tmp = getURLContent($urltograb); + if ($tmp['curl_error_no']) { - $objectpage->title = $regtmp[1]; + $error++; + setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); + $action='createcontainer'; } - if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) + elseif ($tmp['http_code'] != '200') { - $objectpage->description = $regtmp[1]; + $error++; + setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); + $action='createcontainer'; } - if (preg_match('/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) + else { - $objectpage->keywords = $regtmp[1]; + // Remove comments + $tmp['content'] = removeHtmlComment($tmp['content']); + + preg_match('/<head>(.*)<\/head>/is', $tmp['content'], $reg); + $head = $reg[1]; + + $objectpage->type_container = 'page'; + $objectpage->pageurl = $pageurl; + if (empty($objectpage->pageurl)) + { + $tmpdomain = getDomainFromURL($urltograb); + $objectpage->pageurl=$tmpdomain.'-home'; + } + + if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp)) + { + $objectpage->title = $regtmp[1]; + } + if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) + { + $objectpage->description = $regtmp[1]; + } + if (preg_match('/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) + { + $objectpage->keywords = $regtmp[1]; + } + if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) + { + $tmplang=explode('-', $regtmp[1]); + $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); + } + + $objectpage->content = $tmp['content']; + $objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content); + $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); + + $absoluteurlinaction=$urltograbdirwithoutslash; + // TODO Replace 'action="$urltograbdirwithoutslash' into action="/" + // TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..." + // TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/" + // TODO Replace 'a href="$urltograbdirwithoutslash..."' into a href="..." + + // Now loop to fetch all css files. Include them inline into header of page + $objectpage->htmlheader = $tmp['content']; + $objectpage->htmlheader = preg_replace('/^.*<head(\s[^>]*)*>/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<\/head(\s[^>]*)*>.*$/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<base(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="robot(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="keywords(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="title(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="description(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="generator(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + //$objectpage->htmlheader = preg_replace('/<meta name="verify-v1[^>]*>\n*/ims', '', $objectpage->htmlheader); + //$objectpage->htmlheader = preg_replace('/<meta name="msvalidate.01[^>]*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<title>[^<]*<\/title>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<link[^>]*rel="shortcut[^>]*>\n/ims', '', $objectpage->htmlheader); + + // Now loop to fetch JS + $tmp = $objectpage->htmlheader; + + preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs); + foreach ($regs[0] as $key => $val) + { + dol_syslog("We will grab the resource found into script tag ".$regs[2][$key]); + + $linkwithoutdomain = $regs[2][$key]; + if (preg_match('/^\//', $regs[2][$key])) + { + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + } + else + { + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file + } + + //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + if (preg_match('/^http/', $regs[2][$key])) + { + $urltograbbis = $regs[2][$key]; + $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); + //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + } + + //print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - '; + //print $linkwithoutdomain.' - '.$urltograbbis."<br>\n"; + + // Test if this is an external URL of grabbed web site. If yes, we do not load resource + $domaintograb = getDomainFromURL($urltograbdirwithoutslash); + $domaintograbbis = getDomainFromURL($urltograbbis); + if ($domaintograb != $domaintograbbis) continue; + + /* + $tmpgeturl = getURLContent($urltograbbis); + if ($tmpgeturl['curl_error_no']) + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); + $action='createcontainer'; + } + elseif ($tmpgeturl['http_code'] != '200') + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); + $action='createcontainer'; + } + else + { + dol_mkdir(dirname($filetosave)); + + $fp = fopen($filetosave, "w"); + fputs($fp, $tmpgeturl['content']); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } + */ + + //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp); + } + $objectpage->htmlheader = trim($tmp); + + + // Now loop to fetch CSS + $pagecsscontent = "\n".'<style>'."\n"; + + preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs); + foreach ($regs[0] as $key => $val) + { + dol_syslog("We will grab the resource found into link tag ".$regs[2][$key]); + + $linkwithoutdomain = $regs[2][$key]; + if (preg_match('/^\//', $regs[2][$key])) + { + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + } + else + { + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file + } + + //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + if (preg_match('/^http/', $regs[2][$key])) + { + $urltograbbis = $regs[2][$key]; + $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); + //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + } + + //print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - '; + //print $linkwithoutdomain.' - '.$urltograbbis."<br>\n"; + + // Test if this is an external URL of grabbed web site. If yes, we do not load resource + $domaintograb = getDomainFromURL($urltograbdirwithoutslash); + $domaintograbbis = getDomainFromURL($urltograbbis); + if ($domaintograb != $domaintograbbis) continue; + + $tmpgeturl = getURLContent($urltograbbis); + if ($tmpgeturl['curl_error_no']) + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); + $action='createcontainer'; + } + elseif ($tmpgeturl['http_code'] != '200') + { + $error++; + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); + $action='createcontainer'; + } + else + { + //dol_mkdir(dirname($filetosave)); + + //$fp = fopen($filetosave, "w"); + //fputs($fp, $tmpgeturl['content']); + //fclose($fp); + //if (! empty($conf->global->MAIN_UMASK)) + // @chmod($file, octdec($conf->global->MAIN_UMASK)); + + // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n"; + + getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); + + $pagecsscontent.=$tmpgeturl['content']."\n"; + + $objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key],'/').'\n*/ims', '', $objectpage->htmlheader); + } + } + + $pagecsscontent.='</style>'."\n"; + //var_dump($pagecsscontent); + + //print dol_escape_htmltag($tmp);exit; + $objectpage->htmlheader .= $pagecsscontent; + + + // Now loop to fetch all images into page + $tmp = $objectpage->content; + + getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto); + + //print dol_escape_htmltag($tmp);exit; + $objectpage->content = $tmp; + + $objectpage->grabbed_from = $urltograb; } - if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) - { - $tmplang=explode('-', $regtmp[1]); - $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); - } - - $objectpage->content = $tmp['content']; - $objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content); - $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); - - $absoluteurlinaction=$urltograbdirwithoutslash; - // TODO Replace 'action="$urltograbdirwithoutslash' into action="/" - // TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..." - // TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/" - // TODO Replace 'a href="$urltograbdirwithoutslash..."' into a href="..." - - // Now loop to fetch all css files. Include them inline into header of page - $objectpage->htmlheader = $tmp['content']; - $objectpage->htmlheader = preg_replace('/^.*<head(\s[^>]*)*>/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<\/head(\s[^>]*)*>.*$/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<base(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="robot(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="keywords(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="title(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="description(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="generator(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - //$objectpage->htmlheader = preg_replace('/<meta name="verify-v1[^>]*>\n*/ims', '', $objectpage->htmlheader); - //$objectpage->htmlheader = preg_replace('/<meta name="msvalidate.01[^>]*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<title>[^<]*<\/title>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<link[^>]*rel="shortcut[^>]*>\n/ims', '', $objectpage->htmlheader); - - // Now loop to fetch JS - $tmp = $objectpage->htmlheader; - - preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs); - foreach ($regs[0] as $key => $val) - { - dol_syslog("We will grab the resource found into script tag ".$regs[2][$key]); - - $linkwithoutdomain = $regs[2][$key]; - if (preg_match('/^\//', $regs[2][$key])) - { - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot - } - else - { - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file - } - - //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; - if (preg_match('/^http/', $regs[2][$key])) - { - $urltograbbis = $regs[2][$key]; - $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - } - - //print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - '; - //print $linkwithoutdomain.' - '.$urltograbbis."<br>\n"; - - // Test if this is an external URL of grabbed web site. If yes, we do not load resource - $domaintograb = getDomainFromURL($urltograbdirwithoutslash); - $domaintograbbis = getDomainFromURL($urltograbbis); - if ($domaintograb != $domaintograbbis) continue; - - /* - $tmpgeturl = getURLContent($urltograbbis); - if ($tmpgeturl['curl_error_no']) - { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $action='createcontainer'; - } - elseif ($tmpgeturl['http_code'] != '200') - { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); - $action='createcontainer'; - } - else - { - dol_mkdir(dirname($filetosave)); - - $fp = fopen($filetosave, "w"); - fputs($fp, $tmpgeturl['content']); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - */ - - //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp); - } - $objectpage->htmlheader = trim($tmp); - - - // Now loop to fetch CSS - $pagecsscontent = "\n".'<style>'."\n"; - - preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs); - foreach ($regs[0] as $key => $val) - { - dol_syslog("We will grab the resource found into link tag ".$regs[2][$key]); - - $linkwithoutdomain = $regs[2][$key]; - if (preg_match('/^\//', $regs[2][$key])) - { - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot - } - else - { - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file - } - - //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; - if (preg_match('/^http/', $regs[2][$key])) - { - $urltograbbis = $regs[2][$key]; - $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - } - - //print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - '; - //print $linkwithoutdomain.' - '.$urltograbbis."<br>\n"; - - // Test if this is an external URL of grabbed web site. If yes, we do not load resource - $domaintograb = getDomainFromURL($urltograbdirwithoutslash); - $domaintograbbis = getDomainFromURL($urltograbbis); - if ($domaintograb != $domaintograbbis) continue; - - $tmpgeturl = getURLContent($urltograbbis); - if ($tmpgeturl['curl_error_no']) - { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $action='createcontainer'; - } - elseif ($tmpgeturl['http_code'] != '200') - { - $error++; - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); - $action='createcontainer'; - } - else - { - //dol_mkdir(dirname($filetosave)); - - //$fp = fopen($filetosave, "w"); - //fputs($fp, $tmpgeturl['content']); - //fclose($fp); - //if (! empty($conf->global->MAIN_UMASK)) - // @chmod($file, octdec($conf->global->MAIN_UMASK)); - - // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - $pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n"; - - getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1); - - $pagecsscontent.=$tmpgeturl['content']."\n"; - - $objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key],'/').'\n*/ims', '', $objectpage->htmlheader); - } - } - - $pagecsscontent.='</style>'."\n"; - //var_dump($pagecsscontent); - - //print dol_escape_htmltag($tmp);exit; - $objectpage->htmlheader .= $pagecsscontent; - - - // Now loop to fetch all images - $tmp = $objectpage->content; - - getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1); - - //print dol_escape_htmltag($tmp);exit; - $objectpage->content = $tmp; - - $objectpage->grabbed_from = $urltograb; } } else @@ -1895,27 +1912,30 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<!-- Edit or create page/container -->'."\n"; //print '<div class="fichecenter">'; - if ($conf->global->MAIN_FEATURES_LEVEL >= 1) + if ($action == 'createcontainer') { - if ($action == 'createcontainer') - { - print '<br>'; + print '<br>'; - print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>'; - print '<table class="border" width="100%">'; - print '<tr><td class="titlefield">'; - print $langs->trans("URL"); - print '</td><td>'; - print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="https://externalsite/pagetofetch"> '; - print '<input class="button" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">'; - print '<br><br>'.info_admin($langs->trans("OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0, '1'); - print '</td></tr>'; - print '</table>'; + print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>'; + print '<table class="border" width="100%">'; + print '<tr><td class="titlefield">'; + print $langs->trans("URL"); + print '</td><td>'; + print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="https://externalsite/pagetofetch"> '; + print '<input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans("GrabImagesInto"); + print ' '; + print $langs->trans("ImagesShouldBeSavedInto").' '; + $arraygrabimagesinto=array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); + print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto')?GETPOST('grabimagesinto'):'root'); + print '<br>'; + print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">'; + print '<br>'.info_admin($langs->trans("OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0, '1'); + print '</td></tr>'; + print '</table>'; - print '<br>'; + print '<br>'; - print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>'; - } + print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>'; } print '<table class="border" width="100%">'; From f3114765a3ed5b3b483a9f7aafcc6202250871e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 16:46:29 +0100 Subject: [PATCH 12/32] Work on website module --- htdocs/core/lib/website.lib.php | 41 +++++++++ htdocs/langs/en_US/website.lang | 4 +- htdocs/website/index.php | 144 ++++++++++++++++++-------------- 3 files changed, 123 insertions(+), 66 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 785231c6c87..dbd3acd794a 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -164,6 +164,47 @@ function dolWebsiteSaveContent($content) */ +/** + * Make a redirect to another container + * + * @param string $containeralias Path to file to include (must be a page from website root. Example: 'mypage.php' means 'mywebsite/mypage.php') + * @return void + */ +function redirectToContainer($containeralias) +{ + global $db, $website; + + $newurl = ''; + + if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server + { + // Check new container exists + $tmpwebsitepage=new WebsitePage($db); + $result = $tmpwebsitepage->fetch(0, $website->id, $containeralias); + unset($tmpwebsitepage); + if ($result > 0) + { + $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $_SERVER["REQUEST_URI"]); + } + } + else // When page called from virtual host server + { + $newurl = '/'.$containeralias; + } + + if ($newurl) + { + header("Location: ".$newurl); + exit; + } + else + { + print "Error, page contains a reditect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; + exit; + } +} + + /** * Clean an HTML page to report only content, so we can include it into another page. * It outputs content of file sanitized from html and body part. diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 7a5c3a60849..df799470b6d 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -41,7 +41,7 @@ VirtualHostUrlNotDefined=URL of the virtual host served by external web server n NoPageYet=No pages yet SyntaxHelp=Help on specific syntax tips YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor. -YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong><?php ?></strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong><?php includeContainer('alias_of_container_to_include'); ?></strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong><a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"></strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong><a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"></strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong><a href="/document.php?hashp=publicsharekeyoffile"></strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong><a href="/viewimage.php?modulepart=medias&file=[relative_dir/]filename.ext"></strong><br> +YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong><?php ?></strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong><?php includeContainer('alias_of_container_to_include'); ?></strong><br><br><span class="fa fa-bug"></span> You can make a redirect to another Page/Container with the following syntax:<br><strong><?php redirectToContainer('alias_of_container_to_redirect_to'); ?></strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong><a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"></strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong><a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"></strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong><a href="/document.php?hashp=publicsharekeyoffile"></strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong><a href="/viewimage.php?modulepart=medias&file=[relative_dir/]filename.ext"></strong><br> ClonePage=Clone page/container CloneSite=Clone site SiteAdded=Web site added @@ -68,7 +68,7 @@ WEBSITE_USE_WEBSITE_ACCOUNTS=Enable the web site account table WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts (login/pass) for each website / thirdparty YouMustDefineTheHomePage=You must first define the default Home page OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is intiliazed by grabbing it from an external page (WYSIWYG editor will not be available) -OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabber from an external site +OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabbed from an external site GrabImagesInto=Grab also images found into css and page. ImagesShouldBeSavedInto=Images should be saved into directory WebsiteRootOfImages=Root directory for website images diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 156d3ef8229..55119ef418d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -210,6 +210,7 @@ if ($action == 'addsite') if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF','alpha'))) { $error++; + $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); } @@ -330,6 +331,10 @@ if ($action == 'addcontainer') { $objectpage->title = $regtmp[1]; } + if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) + { + if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> + } if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { $objectpage->description = $regtmp[1]; @@ -344,6 +349,8 @@ if ($action == 'addcontainer') $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); } + $tmp['content'] = preg_replace('/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims', '', $tmp['content']); + $objectpage->content = $tmp['content']; $objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content); $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); @@ -359,11 +366,12 @@ if ($action == 'addcontainer') $objectpage->htmlheader = preg_replace('/^.*<head(\s[^>]*)*>/ims', '', $objectpage->htmlheader); $objectpage->htmlheader = preg_replace('/<\/head(\s[^>]*)*>.*$/ims', '', $objectpage->htmlheader); $objectpage->htmlheader = preg_replace('/<base(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="robot(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="keywords(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="title(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="description(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<meta name="generator(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta http-equiv="content-type"([^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="robots"([^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="title"([^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="description"([^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="keywords"([^>]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/<meta name="generator"([^>]*)*>\n*/ims', '', $objectpage->htmlheader); //$objectpage->htmlheader = preg_replace('/<meta name="verify-v1[^>]*>\n*/ims', '', $objectpage->htmlheader); //$objectpage->htmlheader = preg_replace('/<meta name="msvalidate.01[^>]*>\n*/ims', '', $objectpage->htmlheader); $objectpage->htmlheader = preg_replace('/<title>[^<]*<\/title>\n*/ims', '', $objectpage->htmlheader); @@ -432,7 +440,7 @@ if ($action == 'addcontainer') //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp); } - $objectpage->htmlheader = trim($tmp); + $objectpage->htmlheader = trim($tmp)."\n"; // Now loop to fetch CSS @@ -503,11 +511,11 @@ if ($action == 'addcontainer') } } - $pagecsscontent.='</style>'."\n"; + $pagecsscontent.='</style>'; //var_dump($pagecsscontent); //print dol_escape_htmltag($tmp);exit; - $objectpage->htmlheader .= $pagecsscontent; + $objectpage->htmlheader .= trim($pagecsscontent)."\n"; // Now loop to fetch all images into page @@ -543,18 +551,21 @@ if ($action == 'addcontainer') { if (empty($objectpage->pageurl)) { + $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); $error++; $action='createcontainer'; } else if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) { + $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); $error++; $action='createcontainer'; } if (empty($objectpage->title)) { + $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); $error++; $action='createcontainer'; @@ -915,14 +926,16 @@ if ($action == 'setashome') if ($action == 'updatemeta') { $db->begin(); + $object->fetch(0, $website); $objectpage->fk_website = $object->id; // Check parameters - if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) + if (! preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) { $error++; + $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); $action='editmeta'; } @@ -931,7 +944,7 @@ if ($action == 'updatemeta') if ($res <= 0) { $error++; - dol_print_error($db, 'Page not found'); + setEventMessages('Page not found '.$objectpage->error, $objectpage->errors, 'errors'); } if (! $error) @@ -944,7 +957,7 @@ if ($action == 'updatemeta') $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); - $objectpage->htmlheader = GETPOST('htmlheader', 'none'); + $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $res = $objectpage->update($user); if (! $res > 0) @@ -952,67 +965,70 @@ if ($action == 'updatemeta') $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); } + } - if (! $error) + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + if (! $error) + { + $filemaster=$pathofwebsite.'/master.inc.php'; + $fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; + $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + + dol_mkdir($pathofwebsite); + + + // Now generate the master.inc.php page + dol_syslog("We regenerate the master file (because we update meta)"); + dol_delete_file($filemaster); + + $mastercontent = '<?php'."\n"; + $mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n"; + $mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n"; + //$mastercontent.= "include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';"."\n"; + //$mastercontent.= '$website = new WebSite($db)'."\n"; + $mastercontent.= '?>'."\n"; + $result = file_put_contents($filemaster, $mastercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); + + if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + + + // Now generate the alias.php page + if (! empty($fileoldalias)) { - $db->commit(); + dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); + dol_delete_file($fileoldalias); + } - $filemaster=$pathofwebsite.'/master.inc.php'; - $fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + // Save page alias + $result=dolSavePageAlias($filealias, $object, $objectpage); + if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); - dol_mkdir($pathofwebsite); - - - // Now generate the master.inc.php page - dol_syslog("We regenerate the master file (because we update meta)"); - dol_delete_file($filemaster); - - $mastercontent = '<?php'."\n"; - $mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n"; - $mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n"; - //$mastercontent.= "include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';"."\n"; - //$mastercontent.= '$website = new WebSite($db)'."\n"; - $mastercontent.= '?>'."\n"; - $result = file_put_contents($filemaster, $mastercontent); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); - - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); - - - // Now generate the alias.php page - if (! empty($fileoldalias)) - { - dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); - dol_delete_file($fileoldalias); - } - - // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); - - // Save page of content - $result=dolSavePageContent($filetpl, $object, $objectpage); - if ($result) - { - setEventMessages($langs->trans("Saved"), null, 'mesgs'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); - //exit; - } - else - { - setEventMessages('Failed to write file '.$filetpl, null, 'errors'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); - //exit; - } - - $action='preview'; + // Save page of content + $result=dolSavePageContent($filetpl, $object, $objectpage); + if ($result) + { + setEventMessages($langs->trans("Saved"), null, 'mesgs'); + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + //exit; } else { - $db->rollback(); + setEventMessages('Failed to write file '.$filetpl, null, 'errors'); + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); + //exit; } + + $action='preview'; } } From a0078baeb6d3dbb8879a864974f612959be745bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 18:07:59 +0100 Subject: [PATCH 13/32] Fix webpage --- htdocs/website/index.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 55119ef418d..5afea1d8bb3 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -287,13 +287,16 @@ if ($action == 'addcontainer') // and $urltograbdirrootwithoutslash is https://www.dolimed.com // Check pageurl is not already used - $tmpwebsitepage = new WebsitePage($db); - $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); - if ($result > 0) + if ($pageurl) { - setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); - $error++; - $action='createcontainer'; + $tmpwebsitepage = new WebsitePage($db); + $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); + if ($result > 0) + { + setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); + $error++; + $action='createcontainer'; + } } if (! $error) @@ -2003,7 +2006,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td class="titlefieldcreate fieldrequired">'; print $langs->trans('WEBSITE_PAGENAME'); print '</td><td>'; - print '<input type="text" class="flat maxwidth300" name="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).'">'; + print '<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).'">'; print '</td></tr>'; print '<tr><td class="fieldrequired">'; From 576fda9c4a465c67f649261ff54bc0a5b24228aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 18:17:42 +0100 Subject: [PATCH 14/32] Sort --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5afea1d8bb3..d2ee6f0c6c9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1454,7 +1454,7 @@ if (count($object->records) > 0) { print '</div>'; // Close current websitebar to open a new one - $array=$objectpage->fetchAll($object->id); + $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); $atleastonepage=(is_array($array) && count($array) > 0); From 1ee128ff13b478252b2c2f0a030af78fdb994e77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 19:47:42 +0100 Subject: [PATCH 15/32] NEW Add type of website container/page into dictionary --- htdocs/admin/dict.php | 36 +++++------ htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formwebsite.class.php | 63 +++++++++++++++++++ .../mysql/data/llx_c_type_container.sql | 37 +++++++++++ .../install/mysql/migration/7.0.0-8.0.0.sql | 16 +++++ .../mysql/tables/llx_c_type_container.key.sql | 21 +++++++ .../mysql/tables/llx_c_type_container.sql | 36 +++++++++++ htdocs/langs/en_US/admin.lang | 1 + htdocs/website/index.php | 5 +- 9 files changed, 193 insertions(+), 24 deletions(-) create mode 100644 htdocs/install/mysql/data/llx_c_type_container.sql create mode 100644 htdocs/install/mysql/tables/llx_c_type_container.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_type_container.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 438c7cd5227..fbb0b5f38c5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -93,7 +93,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,25,0); // Name of SQL tables of dictionaries $tabname=array(); @@ -121,7 +121,7 @@ $tabname[21]= MAIN_DB_PREFIX."c_availability"; $tabname[22]= MAIN_DB_PREFIX."c_input_reason"; $tabname[23]= MAIN_DB_PREFIX."c_revenuestamp"; $tabname[24]= MAIN_DB_PREFIX."c_type_resource"; -//$tabname[25]= MAIN_DB_PREFIX."c_email_templates"; +$tabname[25]= MAIN_DB_PREFIX."c_type_container"; $tabname[26]= MAIN_DB_PREFIX."c_units"; $tabname[27]= MAIN_DB_PREFIX."c_stcomm"; $tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; @@ -160,7 +160,7 @@ $tablib[21]= "DictionaryAvailability"; $tablib[22]= "DictionarySource"; $tablib[23]= "DictionaryRevenueStamp"; $tablib[24]= "DictionaryResourceType"; -//$tablib[25]= "DictionaryEMailTemplates"; +$tablib[25]= "DictionaryTypeOfContainer"; $tablib[26]= "DictionaryUnits"; $tablib[27]= "DictionaryProspectStatus"; $tablib[28]= "DictionaryHolidayTypes"; @@ -199,7 +199,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; +$tabsql[25]= "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; @@ -237,8 +237,8 @@ $tabsqlsort[20]="code ASC, libelle ASC"; $tabsqlsort[21]="code ASC, label ASC"; $tabsqlsort[22]="code ASC, label ASC"; $tabsqlsort[23]="country ASC, taux ASC"; -$tabsqlsort[24]="code ASC,label ASC"; -//$tabsqlsort[25]="label ASC"; +$tabsqlsort[24]="code ASC, label ASC"; +$tabsqlsort[25]="t.module ASC, t.code ASC, t.label ASC"; $tabsqlsort[26]="code ASC"; $tabsqlsort[27]="code ASC"; $tabsqlsort[28]="country ASC, code ASC"; @@ -277,7 +277,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -//$tabfield[25]= "label,type_template,private,position,topic,content_lines,content"; +$tabfield[25]= "code,label"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; @@ -316,7 +316,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -//$tabfieldvalue[25]= "label,type_template,private,position,topic,content_lines,content"; +$tabfieldvalue[25]= "code,label"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; @@ -355,7 +355,7 @@ $tabfieldinsert[21]= "code,label"; $tabfieldinsert[22]= "code,label"; $tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[24]= "code,label"; -//$tabfieldinsert[25]= "label,type_template,private,position,topic,content_lines,content,entity"; +$tabfieldinsert[25]= "code,label"; $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; @@ -396,7 +396,7 @@ $tabrowid[21]= "rowid"; $tabrowid[22]= "rowid"; $tabrowid[23]= ""; $tabrowid[24]= ""; -//$tabrowid[25]= ""; +$tabrowid[25]= ""; $tabrowid[26]= ""; $tabrowid[27]= "id"; $tabrowid[28]= ""; @@ -435,7 +435,7 @@ $tabcond[21]= ! empty($conf->propal->enabled); $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); $tabcond[23]= true; $tabcond[24]= ! empty($conf->resource->enabled); -//$tabcond[25]= true; // && ! empty($conf->global->MAIN_EMAIL_EDIT_TEMPLATE_FROM_DIC); +$tabcond[25]= ! empty($conf->website->enabled); $tabcond[26]= ! empty($conf->product->enabled); $tabcond[27]= ! empty($conf->societe->enabled); $tabcond[28]= ! empty($conf->holiday->enabled); @@ -474,7 +474,7 @@ $tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent'); $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); -//$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'content_lines'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode')); $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); @@ -513,7 +513,7 @@ $tabfieldcheck[21] = array(); $tabfieldcheck[22] = array(); $tabfieldcheck[23] = array(); $tabfieldcheck[24] = array(); -//$tabfieldcheck[25] = array(); +$tabfieldcheck[25] = array(); $tabfieldcheck[26] = array(); $tabfieldcheck[27] = array(); $tabfieldcheck[28] = array(); @@ -1072,8 +1072,7 @@ if ($id) if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='width100'; } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { - if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - else $valuetoshow=$langs->trans("Label"); + $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); } if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); @@ -1298,12 +1297,7 @@ if ($id) if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field]=='position') { $align='right'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { - //if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - //else $valuetoshow=$langs->trans("Label"); - $valuetoshow=$langs->trans("Label"); - } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='libelle_facture') { //$valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); $valuetoshow=$langs->trans("LabelOnDocuments"); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index af9bd644caf..3339b2b054e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1184,7 +1184,7 @@ class FormOther /** - * Return a HTML select list of bank accounts + * Return a HTML select list of a dictionary * * @param string $htmlname Name of select zone * @param string $dictionarytable Dictionary table diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 6981ecc343f..4f92b2e9449 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -95,4 +95,67 @@ class FormWebsite return $out; } + + /** + * Return a HTML select list of a dictionary + * + * @param string $htmlname Name of select zone + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function selectTypeOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='') + { + global $langs, $conf, $user; + + $langs->load("admin"); + + $sql = "SELECT rowid, code, label, entity"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; + $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; + $sql.= " ORDER BY label"; + + dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + if ($num) + { + print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; + if ($useempty == 1 || ($useempty == 2 && $num > 1)) + { + print '<option value="-1"> </option>'; + } + + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($selected == $obj->rowid || $selected == $obj->code) + { + print '<option value="'.$obj->code.'" selected>'; + } + else + { + print '<option value="'.$obj->code.'">'; + } + print $obj->label; + print '</option>'; + $i++; + } + print "</select>"; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + } + else + { + print $langs->trans("NoTypeOfPagePleaseEditDictionary"); + } + } + else { + dol_print_error($this->db); + } + } + } diff --git a/htdocs/install/mysql/data/llx_c_type_container.sql b/htdocs/install/mysql/data/llx_c_type_container.sql new file mode 100644 index 00000000000..1e915412a12 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_type_container.sql @@ -0,0 +1,37 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> +-- Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> +-- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> +-- Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> +-- Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be> +-- Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> +-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> +-- +-- 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 <http://www.gnu.org/licenses/>. +-- +-- + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +-- +-- Type of website page/container +-- + +insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); + diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 9bfe0bd2915..014f2d5eeff 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -35,3 +35,19 @@ ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit; ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount; + +create table llx_c_type_container +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + label varchar(64) NOT NULL, + module varchar(32) NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); + + + + diff --git a/htdocs/install/mysql/tables/llx_c_type_container.key.sql b/htdocs/install/mysql/tables/llx_c_type_container.key.sql new file mode 100644 index 00000000000..7a81f352f63 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_container.key.sql @@ -0,0 +1,21 @@ +-- ======================================================================== +-- Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net> +-- +-- 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 <http://www.gnu.org/licenses/>. +-- +-- ======================================================================== + + +ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); + diff --git a/htdocs/install/mysql/tables/llx_c_type_container.sql b/htdocs/install/mysql/tables/llx_c_type_container.sql new file mode 100644 index 00000000000..33be89a67f4 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_container.sql @@ -0,0 +1,36 @@ +-- ======================================================================== +-- Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net> +-- +-- +-- 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 <http://www.gnu.org/licenses/>. +-- +-- Defini les types de contact d'un element sert de reference pour +-- la table llx_element_contact +-- +-- element est le nom de la table utilisant le type de contact. +-- i.e. contact, facture, projet, societe (sans le llx_ devant). +-- Libelle est un texte decrivant le type de contact. +-- active precise si cette valeur est 'active' ou 'archive'. +-- +-- ======================================================================== + +create table llx_c_type_container +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + label varchar(64) NOT NULL, + module varchar(32) NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 537da9bdb0b..91a503ba6a6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -885,6 +885,7 @@ DictionaryRevenueStamp=Amount of revenue stamps DictionaryPaymentConditions=Payment terms DictionaryPaymentModes=Payment modes DictionaryTypeContact=Contact/Address types +DictionaryTypeOfContainer=Type of website pages/containers DictionaryEcotaxe=Ecotax (WEEE) DictionaryPaperFormat=Paper formats DictionaryFormatCards=Cards formats diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d2ee6f0c6c9..77edf7728c3 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; @@ -1245,6 +1246,7 @@ if (GETPOST('exportsite','alpha')) $form = new Form($db); $formadmin = new FormAdmin($db); $formwebsite = new FormWebsite($db); +$formother = new FormOther($db); $help_url=''; @@ -1999,8 +2001,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('WEBSITE_TYPE_CONTAINER'); print '</td><td>'; - $arrayoftype=array('page'=>$langs->trans("Page"), 'banner'=>$langs->trans("Banner"), 'blogpost'=>$langs->trans("BlogPost"), 'other'=>$langs->trans("Other")); - print $form->selectarray('WEBSITE_TYPE_CONTAINER', $arrayoftype, $type_container); + print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER')?GETPOST('WEBSITE_TYPE_CONTAINER'):'page')); print '</td></tr>'; print '<tr><td class="titlefieldcreate fieldrequired">'; From 31d0679876fc3b1952b00922cd19d3b0c7f724f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 19:52:51 +0100 Subject: [PATCH 16/32] Add data --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 014f2d5eeff..a0ec8f58e37 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -48,6 +48,11 @@ create table llx_c_type_container ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); +insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); + From 3eef9fd57a300540b1eca48a275e4e88cade3906 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 21:31:03 +0100 Subject: [PATCH 17/32] Fix doc --- htdocs/langs/en_US/website.lang | 7 +++--- htdocs/website/index.php | 40 +++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index df799470b6d..035d0661c95 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -34,9 +34,10 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on <strong>%s</strong><br>then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server. -PreviewSiteServedByWebServer=Preview %s in a new tab.<br><br>The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:<br><strong>%s</strong><br>URL served by external server:<br><strong>%s</strong> -PreviewSiteServedByDolibarr=Preview %s in a new tab.<br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and click on the other preview button. +SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on<br><strong>%s</strong><br>then enter here the virtual hostname you have created, so the preview can be done also using this dedicated web server access instead of only using Dolibarr server. +CheckVirtualHostPerms=Check also that virtual host has read access on files into<br><strong>%s</strong> +PreviewSiteServedByWebServer=<u>Preview %s in a new tab.</u><br><br>The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:<br><strong>%s</strong><br>URL served by external server:<br><strong>%s</strong> +PreviewSiteServedByDolibarr=<u>Preview %s in a new tab.</u><br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined NoPageYet=No pages yet SyntaxHelp=Help on specific syntax tips diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 77edf7728c3..1b4bd000e38 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1413,29 +1413,37 @@ if (count($object->records) > 0) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { - print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/website/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/website/index.php?website='.$website; + + $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/website/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($htmltext).'">'; + print $form->textwithpicto('', $htmltext, 1, 'preview'); print '</a>'; print '<div class="websiteinputurl" id="websiteinputurl">'; print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">'; - $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); + $htmltext =$langs->trans("SetHereVirtualHost", $dataroot); + $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print '</div>'; - $urlext=$virtualurl; - $urlint=$urlwithroot.'/public/website/index.php?website='.$website; if (empty($object->fk_default_home)) { + $htmltext = '<span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br>'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); + $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); print '<span class="websitebuttonsitepreview websitebuttonsitepreviewdisabled cursornotallowed" id="previewsiteextdisabled" href="" target="tab'.$website.'ext" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', '<span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br>'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'), 1, 'preview_ext'); + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</span>'; } else { + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); + $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); print '<a class="websitebuttonsitepreview'.($urlext?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'ext" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'), 1, 'preview_ext'); + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</a>'; } } @@ -1585,8 +1593,11 @@ if (count($object->records) > 0) $realpage=$urlwithroot.'/public/website/index.php?website='.$website.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; - print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); + $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + + print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($htmltext).'">'; + print $form->textwithpicto('', $htmltext, 1, 'preview'); print '</a>'; // View page in new Tab print '<div class="websiteinputurl" id="websiteinputpage">'; @@ -1597,8 +1608,11 @@ if (count($object->records) > 0) $urlext=$virtualurl.'/'.$pagealias.'.php'; $urlint=$urlwithroot.'/public/website/index.php?website='.$website; - print '<a class="websitebuttonsitepreview'.($virtualurl?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'ext" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'), 1, 'preview_ext'); + + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); + + print '<a class="websitebuttonsitepreview'.($virtualurl?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</a>'; //print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">'; @@ -1884,7 +1898,9 @@ if ($action == 'createsite') print '</td></tr>'; print '<tr><td>'; - print $form->textwithpicto($langs->trans('Virtualhost'), $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'), 1, 'help', '', 0, 2, 'tooltipvirtual'); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'); + $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'tooltipvirtual'); print '</td><td>'; print '<input type="text" class="flat minwidth300" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).'">'; print '</td></tr>'; From bfbe03d55d9f7e736bdb099f23e38944e14b93f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 21:57:30 +0100 Subject: [PATCH 18/32] Fix tooltip doc --- htdocs/langs/en_US/website.lang | 4 +++- htdocs/website/index.php | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 035d0661c95..6e67062b859 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -35,7 +35,9 @@ SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on<br><strong>%s</strong><br>then enter here the virtual hostname you have created, so the preview can be done also using this dedicated web server access instead of only using Dolibarr server. -CheckVirtualHostPerms=Check also that virtual host has read access on files into<br><strong>%s</strong> +CheckVirtualHostPerms=Check also that virtual host has <strong>%s</strong> on files into<br><strong>%s</strong> +ReadPerm=Read permission +WritePerm=Write permission PreviewSiteServedByWebServer=<u>Preview %s in a new tab.</u><br><br>The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:<br><strong>%s</strong><br>URL served by external server:<br><strong>%s</strong> PreviewSiteServedByDolibarr=<u>Preview %s in a new tab.</u><br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1b4bd000e38..84d2c19b9de 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1417,7 +1417,8 @@ if (count($object->records) > 0) $urlint=$urlwithroot.'/public/website/index.php?website='.$website; $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/website/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($htmltext).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview'); print '</a>'; @@ -1426,14 +1427,18 @@ if (count($object->records) > 0) print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">'; $htmltext =$langs->trans("SetHereVirtualHost", $dataroot); - $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='<br>'; + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print '</div>'; if (empty($object->fk_default_home)) { $htmltext = '<span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br>'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); - $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='<br>'; + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print '<span class="websitebuttonsitepreview websitebuttonsitepreviewdisabled cursornotallowed" id="previewsiteextdisabled" href="" target="tab'.$website.'ext" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</span>'; @@ -1441,7 +1446,9 @@ if (count($object->records) > 0) else { $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); - $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='<br>'; + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print '<a class="websitebuttonsitepreview'.($urlext?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'ext" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</a>'; @@ -1594,7 +1601,8 @@ if (count($object->records) > 0) $pagealias = $websitepage->pageurl; $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($htmltext).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview'); @@ -1899,7 +1907,10 @@ if ($action == 'createsite') print '<tr><td>'; $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'); - $htmltext.='<br><br>'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='<br>'; + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); + print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'tooltipvirtual'); print '</td><td>'; print '<input type="text" class="flat minwidth300" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).'">'; From 1f412bd1d487ad7e22041ed75a3b2778b7eb0b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 22:10:15 +0100 Subject: [PATCH 19/32] Fix infinite redirects --- htdocs/core/lib/website.lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index dbd3acd794a..c8e59c4e6af 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -184,7 +184,23 @@ function redirectToContainer($containeralias) unset($tmpwebsitepage); if ($result > 0) { - $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $_SERVER["REQUEST_URI"]); + $currenturi = $_SERVER["REQUEST_URI"]; + if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) + { + if ($regtmp[0] == $containeralias) + { + print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containeralias."' in web site '".$website->ref."'"; + exit; + } + else + { + $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $currenturi); + } + } + else + { + $newurl = $currenturi.'&pageref='.urlencode($containeralias); + } } } else // When page called from virtual host server @@ -199,7 +215,7 @@ function redirectToContainer($containeralias) } else { - print "Error, page contains a reditect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; + print "Error, page contains a redirect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; exit; } } From 1cb58a308c0de687982e71f16a9f789dba02150f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 22:25:12 +0100 Subject: [PATCH 20/32] Fix redirect --- htdocs/core/lib/website.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index c8e59c4e6af..b4475d5f907 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -205,7 +205,7 @@ function redirectToContainer($containeralias) } else // When page called from virtual host server { - $newurl = '/'.$containeralias; + $newurl = '/'.$containeralias.'.php'; } if ($newurl) From 5ada5c18f91a2a287019229da81d29594e6363bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 23:19:54 +0100 Subject: [PATCH 21/32] url in generator --- htdocs/core/lib/website.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index b4475d5f907..ac1016af7b8 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -515,7 +515,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n"; $tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n"; $tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n"; - $tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.'" />'."\n"; + $tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n"; $tplcontent.= '<!-- Include link to CSS file -->'."\n"; $tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n"; $tplcontent.= '<!-- Include HTML header from common file -->'."\n"; From 9230c6757b7bdcc233aceecfc3c793ceaff925b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 23:31:35 +0100 Subject: [PATCH 22/32] Fix error when removing dir with some subdirs --- htdocs/ecm/dir_card.php | 27 ++++++++++++++++++--------- htdocs/langs/en_US/ecm.lang | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index e313787b01f..e2b031305d9 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -160,23 +160,28 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') { // Fetch was already done $result=$ecmdir->delete($user); + if ($result <= 0) + { + $langs->load('errors'); + setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors'); + } } else { - $resbool = dol_delete_dir($upload_dir); + $resbool = dol_delete_dir($upload_dir, 1); if ($resbool) $result = 1; - else $result = 0; + else + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors'); + $result = 0; + } } if ($result > 0) { header("Location: ".$backtourl); exit; } - else - { - $langs->load('errors'); - setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors'); - } } // Update dirname or description @@ -281,6 +286,7 @@ if ($module == 'ecm') llxHeader(); // Built the file List +$filearrayall=dol_dir_list($upload_dir,"all",0,'','',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $totalsize=0; foreach($filearray as $key => $file) @@ -469,7 +475,7 @@ if ($action != 'edit' && $action != 'delete') print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>'; } - if (count($filearray) == 0) + if (count($filearrayall) == 0) { if ($permtoadd) { @@ -482,7 +488,10 @@ if ($action != 'edit' && $action != 'delete') } else { - print '<a class="butActionRefused" href="#" title="'.$langs->trans("CannotRemoveDirectoryContainsFiles").'">'.$langs->trans('Delete').'</a>'; + if (count($filearray) > 0) + print '<a class="butActionRefused" href="#" title="'.$langs->trans("CannotRemoveDirectoryContainsFiles").'">'.$langs->trans('Delete').'</a>'; + else + print '<a class="butActionRefused" href="#" title="'.$langs->trans("CannotRemoveDirectoryContainsFilesOrDirs").'">'.$langs->trans('Delete').'</a>'; } print '</div>'; } diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index fe5600004ed..588044f18df 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -39,6 +39,7 @@ ShowECMSection=Show directory DeleteSection=Remove directory ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b>? ECMDirectoryForFiles=Relative directory for files +CannotRemoveDirectoryContainsFilesOrDirs=Removed not possible because it contains some files or sub-directories CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files ECMFileManager=File manager ECMSelectASection=Select a directory in the tree... From 5f51af505f698e4bb5a75d1e3fd4be1c2e9a4af8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 19 Feb 2018 23:52:45 +0100 Subject: [PATCH 23/32] NEW Can delete dir content in media and ECM module recursively --- htdocs/core/class/html.form.class.php | 2 +- htdocs/ecm/class/ecmdirectory.class.php | 18 ++++++++++---- htdocs/ecm/dir_card.php | 33 +++++++++++++++++++------ htdocs/langs/en_US/other.lang | 2 ++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4e8f67d6552..ba0ea7a37c2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3652,7 +3652,7 @@ class Form $more.='<tr>'; $more.='<td>'.$input['label'].' </td><td align="left">'; $more.='<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr; - if (! is_bool($input['value']) && $input['value'] != 'false') $more.=' checked'; + if (! is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') $more.=' checked'; if (is_bool($input['value']) && $input['value']) $more.=' checked'; if (isset($input['disabled'])) $more.=' disabled'; $more.=' /></td>'; diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 019a749b6ef..a3669f909e9 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -325,11 +325,12 @@ class EcmDirectory // extends CommonObject /** * Delete object on database and/or on disk * - * @param User $user User that delete - * @param string $mode 'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented) - * @return int <0 if KO, >0 if OK + * @param User $user User that delete + * @param string $mode 'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented) + * @param int $deletedirrecursive 1=Agree to delete content recursiveley (otherwise an error will be returned when trying to delete) + * @return int <0 if KO, >0 if OK */ - function delete($user, $mode='all') + function delete($user, $mode='all', $deletedirrecursive=0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -368,7 +369,14 @@ class EcmDirectory // extends CommonObject if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output . "/" . $relativepath; - $result=@dol_delete_dir($file); + if ($deletedirrecursive) + { + $result=@dol_delete_dir_recursive($file, 0, 0); + } + else + { + $result=@dol_delete_dir($file, 0); + } } if ($result || ! @is_dir(dol_osencode($file))) diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index e2b031305d9..14f0ee18e8c 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -156,10 +156,12 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') $backtourl = DOL_URL_ROOT."/ecm/index.php"; if ($module == 'medias') $backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1"; + $deletedirrecursive = (GETPOST('deletedirrecursive','alpha') == 'on' ? 1 : 0); + if ($module == 'ecm') { // Fetch was already done - $result=$ecmdir->delete($user); + $result=$ecmdir->delete($user, 'all', $deletedirrecursive); if ($result <= 0) { $langs->load('errors'); @@ -168,7 +170,14 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') } else { - $resbool = dol_delete_dir($upload_dir, 1); + if ($deletedirrecursive) + { + $resbool = dol_delete_dir_recursive($upload_dir, 0, 1); + } + else + { + $resbool = dol_delete_dir($upload_dir, 1); + } if ($resbool) $result = 1; else { @@ -475,8 +484,8 @@ if ($action != 'edit' && $action != 'delete') print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>'; } - if (count($filearrayall) == 0) - { + //if (count($filearrayall) == 0) + //{ if ($permtoadd) { print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete_dir'.($module?'&module='.$module:'').'§ion='.$section.'">'.$langs->trans('Delete').'</a>'; @@ -485,14 +494,14 @@ if ($action != 'edit' && $action != 'delete') { print '<a class="butActionDeleteRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>'; } - } + /*} else { if (count($filearray) > 0) print '<a class="butActionRefused" href="#" title="'.$langs->trans("CannotRemoveDirectoryContainsFiles").'">'.$langs->trans('Delete').'</a>'; else print '<a class="butActionRefused" href="#" title="'.$langs->trans("CannotRemoveDirectoryContainsFilesOrDirs").'">'.$langs->trans('Delete').'</a>'; - } + }*/ print '</div>'; } @@ -506,7 +515,17 @@ if ($action == 'delete') if ($action == 'delete_dir') { $relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath); - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1); + + //Form to close proposal (signed or not) + if (count($filearrayall) > 0) + { + $langs->load("other"); + $formquestion = array( + array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'<br>'.$langs->trans("DeleteAlsoContentRecursively"),'value' => '0') // Field to complete private note (not replace) + ); + } + + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 1585504479e..c4cb693716d 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -22,6 +22,8 @@ JumpToLogin=Disconnected. Go to login page... MessageForm=Message on online payment form MessageOK=Message on validated payment return page MessageKO=Message on canceled payment return page +ContentOfDirectoryIsNotEmpty=Content of this directory is not empty. +DeleteAlsoContentRecursively=Check to delete all content recursiveley YearOfInvoice=Year of invoice date PreviousYearOfInvoice=Previous year of invoice date From 6ef3b330e45b1370566889b1874e997f7033522d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 00:04:43 +0100 Subject: [PATCH 24/32] Fix output dir of grab --- htdocs/core/lib/website.lib.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ac1016af7b8..b4c542edf9c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -289,11 +289,14 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $error=0; + dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); + $alreadygrabbed=array(); if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 + // Search X in "img...src=X" preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs); foreach ($regs[0] as $key => $val) @@ -388,16 +391,20 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } $linkwithoutdomain = $regs[2][$key]; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + + $dirforimages = '/'.$objectpage->pageurl; + if ($grabimagesinto == 'root') $dirforimages=''; + + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); From 0a00bdcb7319d929eb54e5d7aa5f81a4fe663147 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 05:45:42 +0100 Subject: [PATCH 25/32] FIX Search criteria on vat --- htdocs/accountancy/customer/lines.php | 43 ++++++++----------- htdocs/accountancy/expensereport/lines.php | 48 +++++++++------------ htdocs/accountancy/supplier/lines.php | 50 +++++++++------------- 3 files changed, 58 insertions(+), 83 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2d197de8c9f..c4c3d03ee97 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -113,7 +113,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; + $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); @@ -204,7 +204,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("fd.tva_tx", $search_vat); + $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -223,7 +223,7 @@ if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= natural_search("s.tva_intra", $search_tva_intra); + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -245,28 +245,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; - + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; @@ -370,7 +361,7 @@ if ($result) { print '</a>'; print '</td>'; - print '<td align="center">' . $objp->country .'</td>'; + print '<td>' . $objp->country .'</td>'; print '<td>' . $objp->tva_intra . '</td>'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index df039bf4093..5c7347403d9 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -61,10 +61,10 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; +$offset = $limit * $page; if (! $sortfield) $sortfield = "erd.date, erd.rowid"; if (! $sortorder) { @@ -170,19 +170,19 @@ if (strlen(trim($search_expensereport))) { $sql .= " AND er.ref like '%" . $search_expensereport . "%'"; } if (strlen(trim($search_label))) { - $sql .= " AND f.label like '%" . $search_label . "%'"; + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= " AND er.comments like '%" . $search_desc . "%'"; + $sql .= natural_search("er.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= " AND erd.total_ht like '%" . $search_amount . "%'"; + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= " AND aa.account_number like '%" . $search_account . "%'"; + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; + $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -219,25 +219,18 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_expensereport) - $param .= "&search_expensereport=" . $search_expensereport; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_expensereport) $param .= "&search_expensereport=" . urlencode($search_expensereport); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; @@ -297,7 +290,6 @@ if ($result) { $expensereport_static = new ExpenseReport($db); - $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label; @@ -347,7 +339,7 @@ if ($result) { print '</form>'; } else { - print $db->error(); + print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index b8b1ed9206d..af9d82e5056 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -65,8 +65,8 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) @@ -195,10 +195,10 @@ if (strlen(trim($search_amount))) { $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account, 1); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -214,10 +214,10 @@ else if ($search_year > 0) $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } if (strlen(trim($search_country))) { - $sql .= " AND (co.label like'" . $search_country . "%')"; + $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')"; + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy @@ -241,27 +241,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; @@ -277,7 +269,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 1); print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>'; $moreforfilter = ''; @@ -389,7 +381,7 @@ if ($result) { print '</form>'; } else { - print $db->error(); + print $db->lasterror(); } From eb0073c33015835bf6dffc5e43fa07feeb29e0ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 05:53:53 +0100 Subject: [PATCH 26/32] Fix upgrade missing steps --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 11 +++++++++++ htdocs/install/upgrade2.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 4ffe73ac6ea..6e9e480cdb0 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -684,3 +684,14 @@ ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL; ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); + +create table llx_facture_rec_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + + +ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d20357dd20c..560bf3d2593 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3977,7 +3977,7 @@ function migrate_reset_blocked_log($db,$langs,$conf) } else { - print ' - '.$langs->trans('AlreadyInV7'); + print ' - '.$langs->trans('AlreadyInV7').'<br>'; } } else From cb644665bd4199164e7e7bc8d2a0d698e00f89d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 00:04:43 +0100 Subject: [PATCH 27/32] Fix output dir of grab --- htdocs/core/lib/website.lib.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 8a7e14f8b0d..81031d5e49c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -230,11 +230,14 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $error=0; + dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); + $alreadygrabbed=array(); if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 + // Search X in "img...src=X" preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs); foreach ($regs[0] as $key => $val) @@ -323,16 +326,20 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } $linkwithoutdomain = $regs[2][$key]; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + + $dirforimages = '/'.$objectpage->pageurl; + if ($grabimagesinto == 'root') $dirforimages=''; + + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); From aa1ede6f742c18510e4315aafcd3df97308b7857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 05:45:42 +0100 Subject: [PATCH 28/32] FIX Search criteria on vat --- htdocs/accountancy/customer/lines.php | 43 ++++++++----------- htdocs/accountancy/expensereport/lines.php | 48 +++++++++------------ htdocs/accountancy/supplier/lines.php | 50 +++++++++------------- 3 files changed, 58 insertions(+), 83 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2d197de8c9f..c4c3d03ee97 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -113,7 +113,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; + $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); @@ -204,7 +204,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("fd.tva_tx", $search_vat); + $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -223,7 +223,7 @@ if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= natural_search("s.tva_intra", $search_tva_intra); + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -245,28 +245,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; - + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; @@ -370,7 +361,7 @@ if ($result) { print '</a>'; print '</td>'; - print '<td align="center">' . $objp->country .'</td>'; + print '<td>' . $objp->country .'</td>'; print '<td>' . $objp->tva_intra . '</td>'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index df039bf4093..5c7347403d9 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -61,10 +61,10 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; +$offset = $limit * $page; if (! $sortfield) $sortfield = "erd.date, erd.rowid"; if (! $sortorder) { @@ -170,19 +170,19 @@ if (strlen(trim($search_expensereport))) { $sql .= " AND er.ref like '%" . $search_expensereport . "%'"; } if (strlen(trim($search_label))) { - $sql .= " AND f.label like '%" . $search_label . "%'"; + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= " AND er.comments like '%" . $search_desc . "%'"; + $sql .= natural_search("er.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= " AND erd.total_ht like '%" . $search_amount . "%'"; + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= " AND aa.account_number like '%" . $search_account . "%'"; + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; + $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -219,25 +219,18 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_expensereport) - $param .= "&search_expensereport=" . $search_expensereport; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_expensereport) $param .= "&search_expensereport=" . urlencode($search_expensereport); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; @@ -297,7 +290,6 @@ if ($result) { $expensereport_static = new ExpenseReport($db); - $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label; @@ -347,7 +339,7 @@ if ($result) { print '</form>'; } else { - print $db->error(); + print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index b8b1ed9206d..af9d82e5056 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -65,8 +65,8 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) @@ -195,10 +195,10 @@ if (strlen(trim($search_amount))) { $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account, 1); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -214,10 +214,10 @@ else if ($search_year > 0) $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } if (strlen(trim($search_country))) { - $sql .= " AND (co.label like'" . $search_country . "%')"; + $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')"; + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy @@ -241,27 +241,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; @@ -277,7 +269,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 1); print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>'; $moreforfilter = ''; @@ -389,7 +381,7 @@ if ($result) { print '</form>'; } else { - print $db->error(); + print $db->lasterror(); } From 87a3019e73636b5a03fea19614e249b762e36650 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 05:53:53 +0100 Subject: [PATCH 29/32] Fix upgrade missing steps --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 11 +++++++++++ htdocs/install/upgrade2.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 4ffe73ac6ea..6e9e480cdb0 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -684,3 +684,14 @@ ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL; ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); + +create table llx_facture_rec_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + + +ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d20357dd20c..560bf3d2593 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3977,7 +3977,7 @@ function migrate_reset_blocked_log($db,$langs,$conf) } else { - print ' - '.$langs->trans('AlreadyInV7'); + print ' - '.$langs->trans('AlreadyInV7').'<br>'; } } else From 16fca2ee353d8b7d11f270db2b32c880e01f2ce7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 10:05:11 +0100 Subject: [PATCH 30/32] Fix bad link --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 01ea8d93de3..19612349214 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3257,7 +3257,7 @@ else if ($id > 0 || ! empty($ref)) // Invoice content - $linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; $morehtmlref='<div class="refidno">'; // Ref customer From 17c210ca98481134b7d9ac3b45e35d26224c673d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 11:16:13 +0100 Subject: [PATCH 31/32] Normalize links href to Dolibarr internal naming --- htdocs/website/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 84d2c19b9de..959529eb44e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -527,6 +527,11 @@ if ($action == 'addcontainer') getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto); + // Normalize links href to Dolibarr internal naming + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2.php"', $tmp); + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2-\3.php"', $tmp); + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2-\3-\4.php"', $tmp); + //print dol_escape_htmltag($tmp);exit; $objectpage->content = $tmp; From 346a0becac95403b643149534ab654eede388031 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 20 Feb 2018 13:20:24 +0100 Subject: [PATCH 32/32] Propagate context --- htdocs/contrat/class/contrat.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 190de79aa17..12e08984411 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -279,6 +279,8 @@ class Contrat extends CommonObject // Open lines not already open if ($contratline->statut != 4) { + $contratline->context = $this->context; + $result = $contratline->active_line($user, $date_start, -1); if ($result < 0) {