From 8ef9a301b3b8c87a8937138e34969a428a164cfc Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 29 Sep 2018 14:51:52 +0200 Subject: [PATCH 1/8] add some significant info within notification mail --- htdocs/core/class/notify.class.php | 44 ++++++++++-------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 439e9b60d3c..27f74338db4 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2005 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2018 Philippe Grand * * 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 @@ -30,33 +31,13 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; */ class Notify { - /** - * @var int ID - */ - public $id; - - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + var $id; + var $db; + var $error; + var $errors=array(); var $author; - - /** - * @var string Ref - */ - public $ref; - + var $ref; var $date; var $duree; var $note; @@ -339,7 +320,12 @@ class Notify $oldref=(empty($object->oldref)?$object->ref:$object->oldref); $newref=(empty($object->newref)?$object->ref:$object->newref); - + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if (! empty($object->fk_project)) + { + $proj = new Project($this->db); + $proj->fetch($object->fk_project); + } // Check notification per third party $sql = "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; $sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; @@ -390,7 +376,7 @@ class Notify $outputlangs->setDefaultLang($obj->default_lang); } - $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); + $subject = '['.$mysoc->name.']['.$proj->title.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); switch ($notifcode) { case 'BILL_VALIDATE': @@ -572,7 +558,7 @@ class Notify $link = ''; $num++; - $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification"); + $subject = '['.$mysoc->name.'] ['.$proj->title.'] '.$langs->transnoentitiesnoconv("DolibarrNotification"); switch ($notifcode) { case 'BILL_VALIDATE': @@ -734,5 +720,5 @@ class Notify if (! $error) return $num; else return -1 * $error; } -} +} From 9a2fd7defefa0522a2da977e73352a90a59704be Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Sat, 29 Sep 2018 18:41:31 +0200 Subject: [PATCH 2/8] Update notify.class.php --- htdocs/core/class/notify.class.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 27f74338db4..414d4884dde 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -31,10 +31,26 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; */ class Notify { - var $id; - var $db; - var $error; - var $errors=array(); + /** + * @var int ID + */ + public $id; + + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error string + * @see errors + */ + public $error; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); var $author; var $ref; From 8acddb5babd4c55505e97d6691931d038b71d393 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Sat, 29 Sep 2018 18:43:50 +0200 Subject: [PATCH 3/8] Update notify.class.php --- htdocs/core/class/notify.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 414d4884dde..8aaed92372a 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -53,7 +53,12 @@ class Notify public $errors = array(); var $author; - var $ref; + + /** + * @var string Ref + */ + public $ref; + var $date; var $duree; var $note; From b32a9cc50efd414c7fba243102fde28590efa7e4 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 1 Oct 2018 09:13:02 +0200 Subject: [PATCH 4/8] fix if no project linked --- htdocs/core/class/notify.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 8aaed92372a..d93b3364ecc 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -35,30 +35,30 @@ class Notify * @var int ID */ public $id; - + /** * @var DoliDB Database handler. */ public $db; - + /** * @var string Error string * @see errors */ public $error; - + /** * @var string[] Error codes (or messages) */ public $errors = array(); var $author; - + /** * @var string Ref */ public $ref; - + var $date; var $duree; var $note; @@ -397,7 +397,8 @@ class Notify $outputlangs->setDefaultLang($obj->default_lang); } - $subject = '['.$mysoc->name.']['.$proj->title.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); + $projtitle=(empty($proj->title)?'':$proj->title); + $subject = '['.$mysoc->name.']['.$projtitle.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); switch ($notifcode) { case 'BILL_VALIDATE': From 0aae40f8aa73bdaffe29d83f0ecb81964df4439b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 1 Oct 2018 17:05:52 +0200 Subject: [PATCH 5/8] fix when there is no project --- htdocs/core/class/notify.class.php | 51 ++++++++++-------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index d93b3364ecc..f1b2d1736d9 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -31,34 +31,13 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; */ class Notify { - /** - * @var int ID - */ - public $id; - - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error string - * @see errors - */ - public $error; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + var $id; + var $db; + var $error; + var $errors=array(); var $author; - - /** - * @var string Ref - */ - public $ref; - + var $ref; var $date; var $duree; var $note; @@ -341,12 +320,7 @@ class Notify $oldref=(empty($object->oldref)?$object->ref:$object->oldref); $newref=(empty($object->newref)?$object->ref:$object->newref); - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - if (! empty($object->fk_project)) - { - $proj = new Project($this->db); - $proj->fetch($object->fk_project); - } + // Check notification per third party $sql = "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; $sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; @@ -376,6 +350,13 @@ class Notify if ($result) { $num = $this->db->num_rows($result); + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if (! empty($object->fk_project)) + { + $proj = new Project($this->db); + $proj->fetch($object->fk_project); + } + $projtitle=(empty($proj->title)?'':'['.$proj->title.']'); if ($num > 0) { @@ -397,8 +378,7 @@ class Notify $outputlangs->setDefaultLang($obj->default_lang); } - $projtitle=(empty($proj->title)?'':$proj->title); - $subject = '['.$mysoc->name.']['.$projtitle.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); + $subject = '['.$mysoc->name.']'.$projtitle.' '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); switch ($notifcode) { case 'BILL_VALIDATE': @@ -580,7 +560,7 @@ class Notify $link = ''; $num++; - $subject = '['.$mysoc->name.'] ['.$proj->title.'] '.$langs->transnoentitiesnoconv("DolibarrNotification"); + $subject = '['.$mysoc->name.'] '.$projtitle.' '.$langs->transnoentitiesnoconv("DolibarrNotification"); switch ($notifcode) { case 'BILL_VALIDATE': @@ -744,3 +724,4 @@ class Notify } } + From c22b80831d764518243c2281c845c0be719a9462 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 1 Oct 2018 17:14:28 +0200 Subject: [PATCH 6/8] fix regression --- htdocs/core/class/notify.class.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index f1b2d1736d9..eee25383931 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -31,17 +31,36 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; */ class Notify { - var $id; - var $db; - var $error; - var $errors=array(); + /** + * @var int ID + */ + public $id; + + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); var $author; var $ref; var $date; var $duree; var $note; - var $fk_project; + + /** + * @var int Project ID + */ + public $fk_project; // Les codes actions sont definis dans la table llx_notify_def From 2232bd3944274fea78bce32d91d4c9d90074ffa3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Oct 2018 19:30:03 +0200 Subject: [PATCH 7/8] Update notify.class.php --- htdocs/core/class/notify.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index eee25383931..a435ab583f7 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -369,13 +369,14 @@ class Notify if ($result) { $num = $this->db->num_rows($result); - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projtitle=''; if (! empty($object->fk_project)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $proj = new Project($this->db); $proj->fetch($object->fk_project); + $projtitle='('.$proj->title.')'; } - $projtitle=(empty($proj->title)?'':'['.$proj->title.']'); if ($num > 0) { @@ -397,7 +398,7 @@ class Notify $outputlangs->setDefaultLang($obj->default_lang); } - $subject = '['.$mysoc->name.']'.$projtitle.' '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); + $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); switch ($notifcode) { case 'BILL_VALIDATE': From 4fad28d3601216dafe892ee741be7ad5daabdf4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Oct 2018 19:30:45 +0200 Subject: [PATCH 8/8] Update notify.class.php --- htdocs/core/class/notify.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index a435ab583f7..d52166659ea 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -580,7 +580,7 @@ class Notify $link = ''; $num++; - $subject = '['.$mysoc->name.'] '.$projtitle.' '.$langs->transnoentitiesnoconv("DolibarrNotification"); + $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); switch ($notifcode) { case 'BILL_VALIDATE':