From 3eb7bd2ed039b82d965afed5ede22e54f08eec53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 2 Jun 2010 22:50:49 +0000 Subject: [PATCH] Add better message for notifications --- htdocs/core/class/notify.class.php | 47 +++++++++++++++++++++++++----- htdocs/langs/en_US/other.lang | 2 ++ htdocs/langs/fr_FR/other.lang | 2 ++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index b0c7e6f8090..2ad09fde739 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -120,11 +120,11 @@ class Notify * \param objet_type Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify. * \param objet_id Id of object the notification deals on * \param file Attach a file - * \return int <0 if KO or number of changes if OK + * \return int <0 if KO, or number of changes if OK */ function send($action, $socid, $texte, $objet_type, $objet_id, $file="") { - global $conf,$langs; + global $conf,$langs,$mysoc,$dolibarr_main_url_root; $langs->load("other"); @@ -154,11 +154,42 @@ class Notify if (strlen($sendto)) { - $application=(defined('MAIN_APPLICATION_TITLE')?MAIN_APPLICATION_TITLE:'Dolibarr'); - $subject = '['.$application.'] '.$langs->transnoentitiesnoconv("DolibarrNotification"); - $message = $texte; - $filename = explode("/",$file); - $msgishtml=0; + include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); + $application=($conf->global->MAIN_APPLICATION_TITLE?$conf->global->MAIN_APPLICATION_TITLE:'Dolibarr ERP/CRM'); + + $subject = '['.$application.'] '.$langs->transnoentitiesnoconv("DolibarrNotification"); + + $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n"; + $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n"; + $message.= "\n"; + $message.= $texte; + // Add link + switch($objet_type) + { + case 'ficheinter': + $link=DOL_URL_ROOT.'/fichinter/fiche.php?id='.$objet_id; + break; + case 'propal': + $link=DOL_URL_ROOT.'/comm/propal.php?id='.$objet_id; + break; + case 'facture': + $link=DOL_URL_ROOT.'/facture/fiche.php?facid='.$objet_id; + break; + case 'order': + $link=DOL_URL_ROOT.'/commande/fiche.php?facid='.$objet_id; + break; + case 'order_supplier': + $link=DOL_URL_ROOT.'/fourn/commande/fiche.php?facid='.$objet_id; + break; + } + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); + if ($link) $message.="\n".$urlwithouturlroot.$link; + + $filename = basename($file); + + $mimefile=dol_mimetype($file); + + $msgishtml=0; $replyto = $conf->notification->email_from; @@ -167,7 +198,7 @@ class Notify $replyto, $message, array($file), - array("application/pdf"), + array($mimefile), array($filename[sizeof($filename)-1]), '', '', 0, $msgishtml ); diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index d4eb4b2576b..eb6db347492 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -131,6 +131,8 @@ NewHeight=New height NewSizeAfterCropping=New size after cropping DefineNewAreaToPick=Define new area on image to pick (left click on image then drag until you reach the opposite corner) CurrentInformationOnImage=Informations on current image +YouReceiveMailBecauseOfNotification=You receive this message because your email has been added to list of targets to be informed of particular events into %s software of %s. +YouReceiveMailBecauseOfNotification2=This event is the following: ##### Bookmark ##### Bookmark=Bookmark diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index b6c15717785..77e32646da8 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -131,6 +131,8 @@ NewHeight=Nouvelle hauteur NewSizeAfterCropping=Nouvelles dimensions après recadrage DefineNewAreaToPick=Définissez la zone d'image à conserver (clic gauche sur l'image puis drag vers les coins opposés) CurrentInformationOnImage=Informations courantes sur l'image +YouReceiveMailBecauseOfNotification=Vous recevez ce message car votre email a été abonnée à certaines notifications automatiques pour vous informer d'évenements particuliers issus du logiciel %s de %s. +YouReceiveMailBecauseOfNotification2=L'évenement en question est le suivant: ##### Bookmark ##### Bookmark=Marque-page -- GitLab