From 0b08f125c9e7ee24a0118c8940288e9f305aa343 Mon Sep 17 00:00:00 2001 From: Chl Date: Wed, 13 Mar 2024 18:49:51 +0100 Subject: [PATCH 1/7] readme: specify 'customer invoice' Following the arrival of supplier invoice templates in Dolibarr 16, it's better to specify than this module only manage customer invoices. Adding the management of supplier invoice seems possible but I don't really see a use case at the moment. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ac0b28..2f736af 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ## Features -(en) This module sends by email the invoice generated with recurring invoices via scheduled jobs. +(en) This module sends by email the customer invoice generated with a recurring invoice template via scheduled jobs. -(fr) Ce module envoie par mail les factures générées automatiquement par les travaux planifiés et les factures modèles. +(fr) Ce module envoie par mail les factures clientes générées automatiquement par les travaux planifiés et les factures modèles. You can customize the mail globally or by recurring invoice. From 44c54ab3f7802eac028b4897802f135b4b576af7 Mon Sep 17 00:00:00 2001 From: Chl Date: Fri, 15 Mar 2024 01:22:09 +0100 Subject: [PATCH 2/7] $conf->global->MAIN_MAIL_ERRORS_TO is not always set --- class/actions_sendrecurringinvoicebymail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class/actions_sendrecurringinvoicebymail.class.php b/class/actions_sendrecurringinvoicebymail.class.php index fcae1d4..ceb5417 100644 --- a/class/actions_sendrecurringinvoicebymail.class.php +++ b/class/actions_sendrecurringinvoicebymail.class.php @@ -120,8 +120,8 @@ class Actionssendrecurringinvoicebymail 'to' => implode(', ', $mailObject->compileEmails('to', true)), 'cc' => implode(', ', $mailObject->compileEmails('cc', true)), 'bcc' => implode(', ', $mailObject->compileEmails('bcc', true)), - 'errorsTo' => $conf->global->MAIN_MAIL_ERRORS_TO, - 'replyTo' => $conf->global->MAIN_MAIL_ERRORS_TO, + 'errorsTo' => (isset($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : ''), + 'replyTo' => (isset($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : ''), 'subject' => $mailObject->subject, 'message' => $mailObject->body, 'ishtml' => $mailObject->body_ishtml, From e1ac0a6d69f0d5913bf74c8bdbebfff0bbecd72a Mon Sep 17 00:00:00 2001 From: Chl Date: Sat, 17 Aug 2024 21:27:57 +0200 Subject: [PATCH 3/7] Fix GH-11: HTML silently removed with Dolibarr 13+ The behaviour of GETPOST(..., 'alpha') changed with Dolibarr 13, copying 'alphanohtml'. Unfortunately, there is no retro-compatible option. Thus the 'none' filter seems the better call since there doesn't seem to have any big attack involving emails' body (except HTML+JS...) For the next big version, maybe use the 'restricthtml' filter, but it only appeared in Dolibarr 12. --- fiche-rec-tab1.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fiche-rec-tab1.php b/fiche-rec-tab1.php index 604ec6e..4efce12 100644 --- a/fiche-rec-tab1.php +++ b/fiche-rec-tab1.php @@ -146,8 +146,8 @@ do { $mailObject->sendcc_free = GETPOST('sendcc_free', 'alpha'); $mailObject->sendcc_thirdparty = in_array('thirdparty', GETPOST('sendcc_socpeople', 'array')); - $mailObject->subject = GETPOST('subject', 'alpha'); - $mailObject->body = GETPOST('body', 'alpha'); + $mailObject->subject = GETPOST('subject', 'none'); + $mailObject->body = GETPOST('body', 'none'); $mailObject->body_ishtml = (int)GETPOST('body_ishtml', 'int'); // Save into database From ab5a9c28613b294f5a0485b841dc921c11328ec2 Mon Sep 17 00:00:00 2001 From: Chl Date: Sat, 17 Aug 2024 21:36:25 +0200 Subject: [PATCH 4/7] Preparing 0.3.5 release --- ChangeLog.md | 8 ++++++++ core/modules/modsendrecurringinvoicebymail.class.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 8834495..521c60f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,13 @@ # CHANGELOG SENDRECURRINGINVOICEBYMAIL FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +## 0.3.5 + +Fix: + +* HTML formating was silently removed when used on Dolibarr v.13+ (GH-11) +* `$conf->global->MAIN_MAIL_ERRORS_TO` might not always be set (cause not found) + + ## 0.3.4 Fix: the hook was also triggered by supplier invoices. diff --git a/core/modules/modsendrecurringinvoicebymail.class.php b/core/modules/modsendrecurringinvoicebymail.class.php index b3517b4..d296454 100644 --- a/core/modules/modsendrecurringinvoicebymail.class.php +++ b/core/modules/modsendrecurringinvoicebymail.class.php @@ -69,7 +69,7 @@ class modsendrecurringinvoicebymail extends DolibarrModules $this->editor_url = 'https://code.bugness.org/Dolibarr/sendrecurringinvoicebymail'; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '0.3.4'; + $this->version = '0.3.5'; //Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; From f94ba084a3e616b21ca39909bc3be2ae8f8509a7 Mon Sep 17 00:00:00 2001 From: Chl Date: Mon, 19 Aug 2024 23:39:29 +0200 Subject: [PATCH 5/7] Disable Dolibarr filter on email addresses and subject 'was wondering if the filter change of Dolibarr 13 might have affected something else and, well, yes... So, following e1ac0a6d69f0d5913bf74c8bdbebfff0bbecd72a, we also disable the filter for the email addresses, else we get something like "Webmaster " becoming "Webmaster". --- fiche-rec-tab1.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fiche-rec-tab1.php b/fiche-rec-tab1.php index 4efce12..69fcb98 100644 --- a/fiche-rec-tab1.php +++ b/fiche-rec-tab1.php @@ -103,7 +103,7 @@ do { if (GETPOST('save')) { do { // Validate input data - if (! array_key_exists(GETPOST('fromtype', 'alpha'), $listFrom)) { + if (! array_key_exists(GETPOST('fromtype'), $listFrom)) { setEventMessages('Unexpected from value', null, 'errors'); break; } @@ -116,13 +116,13 @@ do { break; } // Validate some non-breaking stuff after feeding - if (empty(GETPOST('sendto_free', 'alpha')) && empty(GETPOST('sendto_socpeople', 'array'))) { + if (empty(GETPOST('sendto_free', 'none')) && empty(GETPOST('sendto_socpeople', 'array'))) { // Kinda weird behaviour from CMailFile but better alert the user beforehand // FIXME: check if there is a workaround ? setEventMessages("In some configuration, CMailFile doesn't allow empty 'to' recipient. You should set at least one.", null, 'warnings'); //break; } - if (! strlen(GETPOST('subject', 'alpha'))) { + if (! strlen(GETPOST('subject', 'none'))) { // Kinda weird behaviour from CMailFile but better alert the user beforehand // FIXME: check if there is a workaround ? setEventMessages("In some configuration, CMailFile doesn't allow empty subject. You should set one.", null, 'warnings'); @@ -140,10 +140,10 @@ do { $mailObject->fromtype = GETPOST('fromtype', 'alpha'); $mailObject->frommail = $listFrom[$mailObject->fromtype]; - $mailObject->sendto_free = GETPOST('sendto_free', 'alpha'); + $mailObject->sendto_free = GETPOST('sendto_free', 'none'); $mailObject->sendto_thirdparty = in_array('thirdparty', GETPOST('sendto_socpeople', 'array')); - $mailObject->sendcc_free = GETPOST('sendcc_free', 'alpha'); + $mailObject->sendcc_free = GETPOST('sendcc_free', 'none'); $mailObject->sendcc_thirdparty = in_array('thirdparty', GETPOST('sendcc_socpeople', 'array')); $mailObject->subject = GETPOST('subject', 'none'); From 26d25135d65d05bc5d99bba557c7841be3c8d222 Mon Sep 17 00:00:00 2001 From: Chl Date: Tue, 27 Aug 2024 01:43:39 +0200 Subject: [PATCH 6/7] Add workflow for generating zip file --- .../workflows/generate-release-zipfile.yml | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .forgejo/workflows/generate-release-zipfile.yml diff --git a/.forgejo/workflows/generate-release-zipfile.yml b/.forgejo/workflows/generate-release-zipfile.yml new file mode 100644 index 0000000..43b7ab2 --- /dev/null +++ b/.forgejo/workflows/generate-release-zipfile.yml @@ -0,0 +1,74 @@ +# Creates a module_sendrecurringinvoicebymail-X.Y.Z.zip file when pushing a tag +# +# This job is mainly useless (Forgejo already creates a usable .zip archive, +# minus the name) and serves more as a warmup for a decent CI/CD tryout. + +on: + push: + tags: + # For the time being, we only trigger on the tags clearly matching a + # '1.2.3' version pattern. + - '[0-9]+.[0-9]+.[0-9]+' + +env: + MYFILENAME: "module_sendrecurringinvoicebymail-${{ github.ref_name }}" + +jobs: + GenerateReleaseZipfile: + runs-on: docker + container: + image: code.bugness.org/chl/alpine-wget-git-zip:latest + steps: + - name: Download the automatic repository archive + run: | + # In case the repository is private, we build an authenticated URL + # with our action token. + MY_GITHUB_AUTHENTICATED_URL="$( echo "$GITHUB_SERVER_URL" | sed "s#^\(https\?://\)#\1$GITHUB_TOKEN\@#" )" + wget -O "$MYFILENAME.zip" "$MY_GITHUB_AUTHENTICATED_URL"/"$GITHUB_REPOSITORY"/archive/"$GITHUB_REF_NAME".zip + + - name: A bit of useless cleanup + run: | + #apk add zip + # On Forgejo, GITHUB_REPOSITORY="owner/repo" (and we just want the 'repo' part) + MY_REPOSITORY="$( echo "$GITHUB_REPOSITORY" | sed 's/.*\///' )" + zip -d "$MYFILENAME.zip" \ + "$MY_REPOSITORY/.editorconfig" \ + "$MY_REPOSITORY/.gitattributes" \ + "$MY_REPOSITORY/.gitignore" \ + "$MY_REPOSITORY/.tx*" + + - name: Upload artifact (using v4) + run: | + set -ex + + # The busybox version of wget does not offer --method=PUT as of 2024-08-26 + #apk add wget + + # We extract the Actions.Results:22:33 from ACTIONS_RUNTIME_TOKEN + # (base64 -d doesn't like when the '==' padding is missing, so 2>/dev/null and relying on the piping to forget about non-zero return code...) + read WORKFLOW_RUN_BACKEND_ID WORKFLOW_JOB_RUN_BACKEND_ID </dev/null | sed 's/.*Actions.Results:\([^:]\+\):\([^:" ]\+\).*/\1 \2/' ) + EOF + + # Get the upload URL + # note: we use the name without .zip, it seems to be added automatically. + RESPONSE="$( wget -O - \ + --header 'Content-Type:application/json' \ + --header "Authorization: Bearer $GITHUB_TOKEN" \ + --post-data "$( printf '{"version":4, "name":"%s", "workflow_run_backend_id":"%s", "workflow_job_run_backend_id":"%s"}' "$MYFILENAME" "$WORKFLOW_RUN_BACKEND_ID" "$WORKFLOW_JOB_RUN_BACKEND_ID" )" \ + "$GITHUB_SERVER_URL"/twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact + )" + # We get a JSON with an signedUploadUrl similar to : + # https://entrepot.xlii.si/twirp/github.actions.results.api.v1.ArtifactService/UploadArtifact?sig=yWWEI8tIIECp8D7E5TVh4_6G2pZxWaVdQcSYaCsx5s0=&expires=2024-08-26+07%3A20%3A49.886890537+%2B0200+CEST&artifactName=mymodule-1.2.3.zip&taskID=63 + SIGNED_UPLOAD_URL="$( echo "$RESPONSE" | sed -n 's/.*"signedUploadUrl" *: *"\([^"]\+\)".*/\1/p' )" + + # Upload our file + # (note: adding '&comp=block' at the end of the URL) + wget --method PUT --body-file "$MYFILENAME.zip" "$SIGNED_UPLOAD_URL&comp=block" + + # Finalize the artifact + wget -O - \ + --header 'Content-Type:application/json' \ + --header "Authorization: Bearer $GITHUB_TOKEN" \ + --post-data "$( printf '{"hash":"sha256:%s", "name":"%s", "size":"%d", "workflow_run_backend_id":"%s", "workflow_job_run_backend_id":"%s"}' "$( sha256sum $MYFILENAME.zip | sed 's/[[:space:]]\+.*//' )" "$MYFILENAME" "$( stat -c %s $MYFILENAME.zip )" "$WORKFLOW_RUN_BACKEND_ID" "$WORKFLOW_JOB_RUN_BACKEND_ID" )" \ + "$GITHUB_SERVER_URL"/twirp/github.actions.results.api.v1.ArtifactService/FinalizeArtifact From c26013ea03f4935ddc303fba776689f81e7e8c2c Mon Sep 17 00:00:00 2001 From: Chl Date: Tue, 27 Aug 2024 01:46:31 +0200 Subject: [PATCH 7/7] Preparing 0.3.6 release --- ChangeLog.md | 5 +++++ core/modules/modsendrecurringinvoicebymail.class.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 521c60f..cdf58df 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,10 @@ # CHANGELOG SENDRECURRINGINVOICEBYMAIL FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +## 0.3.6 + +Fix: freeform email addresses being "html-filtered" `Postmaster ` → `Postmaster` + + ## 0.3.5 Fix: diff --git a/core/modules/modsendrecurringinvoicebymail.class.php b/core/modules/modsendrecurringinvoicebymail.class.php index d296454..4a2cc1f 100644 --- a/core/modules/modsendrecurringinvoicebymail.class.php +++ b/core/modules/modsendrecurringinvoicebymail.class.php @@ -69,7 +69,7 @@ class modsendrecurringinvoicebymail extends DolibarrModules $this->editor_url = 'https://code.bugness.org/Dolibarr/sendrecurringinvoicebymail'; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '0.3.5'; + $this->version = '0.3.6'; //Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt';