forked from Wavyzz/dolibarr
NEW: The notification module accept keyword __SUPERVISOR__ to send
notification to supervisor of user.
This commit is contained in:
@@ -232,10 +232,10 @@ foreach($listofnotifiedevents as $notifiedevent)
|
||||
foreach($arrayemail as $key=>$valuedet)
|
||||
{
|
||||
$valuedet=trim($valuedet);
|
||||
if (! empty($valuedet) && ! isValidEmail($valuedet)) $showwarning++;
|
||||
if (! empty($valuedet) && ! isValidEmail($valuedet,1)) $showwarning++;
|
||||
}
|
||||
if ((! empty($conf->global->$param)) && $showwarning) $s.=' '.img_warning($langs->trans("ErrorBadEMail"));
|
||||
print $form->textwithpicto($s,$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"),1,'help','',0,2);
|
||||
print $form->textwithpicto($s,$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"),1,'help','',0,2);
|
||||
print '<br>';
|
||||
}
|
||||
// New entry input fields
|
||||
|
||||
@@ -85,8 +85,8 @@ class CMailFile
|
||||
* CMailFile
|
||||
*
|
||||
* @param string $subject Topic/Subject of mail
|
||||
* @param string $to Recipients emails (RFC 2822: "Nom firstname <email>[, ...]" ou "email[, ...]" ou "<email>[, ...]")
|
||||
* @param string $from Sender email (RFC 2822: "Nom firstname <email>[, ...]" ou "email[, ...]" ou "<email>[, ...]")
|
||||
* @param string $to Recipients emails (RFC 2822: "Name firstname <email>[, ...]" or "email[, ...]" or "<email>[, ...]"). Note: the keyword '__SUPERVISOREMAIL__' is not allowed here and must be replaced by caller.
|
||||
* @param string $from Sender email (RFC 2822: "Name firstname <email>[, ...]" or "email[, ...]" or "<email>[, ...]")
|
||||
* @param string $msg Message
|
||||
* @param array $filename_list List of files to attach (full path of filename on file system)
|
||||
* @param array $mimetype_list List of MIME type of attached files
|
||||
@@ -98,9 +98,7 @@ class CMailFile
|
||||
* @param string $errors_to Email errors
|
||||
* @param string $css Css option
|
||||
*/
|
||||
function __construct($subject,$to,$from,$msg,
|
||||
$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),
|
||||
$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='')
|
||||
function __construct($subject,$to,$from,$msg,$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@@ -1023,9 +1021,9 @@ class CMailFile
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an address for SMTP protocol
|
||||
* Return a formatted address string for SMTP protocol
|
||||
*
|
||||
* @param string $address Example: 'John Doe <john@doe.com>' or 'john@doe.com'
|
||||
* @param string $address Example: 'John Doe <john@doe.com>, Alan Smith <alan@smith.com>' or 'john@doe.com, alan@smith.com'
|
||||
* @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between "
|
||||
* @param int $encode 1=Encode name to RFC2822
|
||||
* @return string If format 0: '<john@doe.com>' or 'John Doe <john@doe.com>' or '=?UTF-8?B?Sm9obiBEb2U=?= <john@doe.com>'
|
||||
|
||||
@@ -155,7 +155,7 @@ class Notify
|
||||
*/
|
||||
function send($notifcode, $object)
|
||||
{
|
||||
global $conf,$langs,$mysoc,$dolibarr_main_url_root;
|
||||
global $user,$conf,$langs,$mysoc,$dolibarr_main_url_root;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
@@ -373,8 +373,7 @@ class Notify
|
||||
}
|
||||
|
||||
$param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
|
||||
//if (! empty($conf->global->$param))
|
||||
//{
|
||||
|
||||
$sendto = $conf->global->$param;
|
||||
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
|
||||
if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
|
||||
@@ -458,6 +457,24 @@ class Notify
|
||||
$message.= $mesg;
|
||||
if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
|
||||
|
||||
// Replace keyword __SUPERVISOREMAIL__
|
||||
if (preg_match('/__SUPERVISOREMAIL__/', $sendto))
|
||||
{
|
||||
$newval='';
|
||||
if ($user->fk_user > 0)
|
||||
{
|
||||
$supervisoruser=new User($this->db);
|
||||
$supervisoruser->fetch($user->fk_user);
|
||||
if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
|
||||
}
|
||||
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
|
||||
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
|
||||
$sendto = preg_replace('/^[\s,]+/','',$sendto); // Clean start of string
|
||||
$sendto = preg_replace('/[\s,]+$/','',$sendto); // Clean end of string
|
||||
}
|
||||
|
||||
if ($sendto)
|
||||
{
|
||||
$mailfile = new CMailFile(
|
||||
$subject,
|
||||
$sendto,
|
||||
@@ -486,7 +503,7 @@ class Notify
|
||||
$error++;
|
||||
$this->errors[]=$mailfile->error;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1634,13 +1634,13 @@ function dol_print_address($address, $htmlid, $mode, $id)
|
||||
* Return true if email syntax is ok
|
||||
*
|
||||
* @param string $address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
||||
* @param int $acceptsupervisorkey If 1, the special string '__SUPERVISOREMAIL__' is also accepted as valid
|
||||
* @return boolean true if email syntax is OK, false if KO or empty string
|
||||
*/
|
||||
function isValidEmail($address)
|
||||
function isValidEmail($address, $acceptsupervisorkey=0)
|
||||
{
|
||||
if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
|
||||
return true;
|
||||
}
|
||||
if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') return true;
|
||||
if (filter_var($address, FILTER_VALIDATE_EMAIL)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1107,7 +1107,7 @@ ModuleCompanyCodeAquarium=Return an accountancy code built by:<br>%s followed by
|
||||
ModuleCompanyCodePanicum=Return an empty accountancy code.
|
||||
ModuleCompanyCodeDigitaria=Accountancy 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.
|
||||
UseNotifications=Use notifications
|
||||
NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined:<br>* per third parties contacts (customers or suppliers), one contact at time.<br>* or by setting a global target email address on module setup page.
|
||||
NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined:<br>* per third parties contacts (customers or suppliers), one contact at time.<br>* or by setting global target email addresses in module setup page.
|
||||
ModelModules=Documents templates
|
||||
DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...)
|
||||
WatermarkOnDraft=Watermark on draft document
|
||||
@@ -1604,5 +1604,5 @@ NoModueToManageStockIncrease=No module able to manage automatic stock increase h
|
||||
YouMayFindNotificationsFeaturesIntoModuleNotification=You may find options for EMail notifications by enabling and configuring the module "Notification".
|
||||
ListOfNotificationsPerContact=List of notifications per contact*
|
||||
ListOfFixedNotifications=List of fixed notifications
|
||||
GoOntoContactCardToAddMore=Go on the tab "Notifications" of a thirdparty contact to add or remove notifications for contact
|
||||
GoOntoContactCardToAddMore=Go on the tab "Notifications" of a thirdparty contact to add or remove notifications for contacts/addresses
|
||||
Threshold=Threshold
|
||||
|
||||
@@ -139,3 +139,5 @@ ListOfNotificationsDone=List all email notifications sent
|
||||
MailSendSetupIs=Configuration of email sending has been setup to '%s'. This mode can't be used to send mass emailing.
|
||||
MailSendSetupIs2=You must first go, with an admin account, into menu %sHome - Setup - EMails%s to change parameter <strong>'%s'</strong> to use mode '%s'. With this mode, you can enter setup of the SMTP server provided by your Internet Service Provider and use Mass emailing feature.
|
||||
MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s.
|
||||
YouCanAlsoUseSupervisorKeyword=You can also add the keyword <strong>__SUPERVISOREMAIL__</strong> to have email being sent to the supervisor of user (works only if an email is defined for this supervisor)
|
||||
NbOfTargetedContacts=Current number of targeted contact emails
|
||||
@@ -48,7 +48,7 @@ Notify_PROJECT_CREATE=Project creation
|
||||
Notify_TASK_CREATE=Task created
|
||||
Notify_TASK_MODIFY=Task modified
|
||||
Notify_TASK_DELETE=Task deleted
|
||||
SeeModuleSetup=See module setup
|
||||
SeeModuleSetup=See setup of module %s
|
||||
NbOfAttachedFiles=Number of attached files/documents
|
||||
TotalSizeOfAttachedFiles=Total size of attached files/documents
|
||||
MaxSize=Maximum size
|
||||
|
||||
@@ -264,18 +264,22 @@ if ($result > 0)
|
||||
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
$listtmp=explode(',',$val);
|
||||
$first=1;
|
||||
foreach($listtmp as $keyemail => $valemail)
|
||||
{
|
||||
if (! $first) print ', ';
|
||||
$first=0;
|
||||
$valemail=trim($valemail);
|
||||
//print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>';
|
||||
if (isValidEmail($valemail))
|
||||
if (isValidEmail($valemail, 1))
|
||||
{
|
||||
print ' <'.$valemail.'>';
|
||||
if ($valemail == '__SUPERVISOREMAIL__') print $valemail;
|
||||
else print ' <'.$valemail.'>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
print ' '.img_warning().' '.$langs->trans("ErrorBadEMail",$valemail);
|
||||
print ' '.img_warning().' '.$langs->trans("ErrorBadEMail",$valemail);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
@@ -286,7 +290,7 @@ if ($result > 0)
|
||||
print '<td>';
|
||||
print $langs->trans("Email");
|
||||
print '</td>';
|
||||
print '<td align="right">'.$langs->trans("SeeModuleSetup").'</td>';
|
||||
print '<td align="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user