From 8b61fd5c1a1ee5c6464c426c1a1644f4b93c23ad Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 21 Oct 2022 00:31:31 +0200 Subject: [PATCH 1/3] Lang --- htdocs/langs/en_US/cron.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 9705f8823b0..021de63de05 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -84,6 +84,7 @@ MakeLocalDatabaseDumpShort=Local database backup MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql', 'pgsql', 'auto'), 1, 'auto' or filename to build, number of backup files to keep MakeSendLocalDatabaseDumpShort=Send local database backup MakeSendLocalDatabaseDump=Send local database backup by email. Parameters are: to, from, subject, message, filename (Name of file sent), filter ('sql' for backup of database only) +BackupIsTooLargeSend=Sorry, last backup file is too large to be send by email WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run. DATAPOLICYJob=Data cleaner and anonymizer JobXMustBeEnabled=Job %s must be enabled From 0e5f01dd13fec2a74c2905c457132ad99dc8a80a Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 21 Oct 2022 00:33:04 +0200 Subject: [PATCH 2/3] Add param --- htdocs/core/class/utils.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 9a330c7aba5..daaebd09ecf 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -1237,9 +1237,10 @@ class Utils * @param string $message Message * @param string $filename List of files to attach (full path of filename on file system) * @param string $filter Filter file send + * @param string $sizelimit Limit size to send file * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - public function sendBackup($sendto = '', $from = '', $subject = '', $message = '', $filename = '', $filter = '') + public function sendBackup($sendto = '', $from = '', $subject = '', $message = '', $filename = '', $filter = '', $sizelimit = 100000000) { global $conf, $langs; From 1db5ab30a944aa41718a1540234a0c8a48960234 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 21 Oct 2022 00:34:52 +0200 Subject: [PATCH 3/3] Link download file in mail --- htdocs/core/class/utils.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index daaebd09ecf..1d3df8191a6 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -1298,9 +1298,13 @@ class Utils } if ($filepath) { - if ($filesize > 100000000) { - $output = 'Sorry, last backup file is too large to be send by email'; - $error++; + if ($filesize > $sizelimit) { + $message .= '
'.$langs->trans("BackupIsTooLargeSend"); + $documenturl = $dolibarr_main_url_root.'/document.php?modulepart=systemtools&atachement=1&file=backup/'.urlencode($filename[0]); + $message .= '
Lien de téléchargement'; + $filepath = ''; + $mimetype = ''; + $filename = ''; } } else { $output = 'No backup file found';