Merge pull request #2634 from tiaris/3.7_mailing_user_bug

Fix #2589
This commit is contained in:
Laurent Destailleur 2015-04-18 17:45:11 +02:00
commit 64244a009d
2 changed files with 9 additions and 3 deletions

View File

@ -778,7 +778,7 @@ else
if ($conf->file->mailing_limit_sendbyweb == 0)
{
$text.=$langs->trans("MailingNeedCommand");
$text.='<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>';
$text.='<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.' '.$user->login.'</textarea>';
$text.='<br><br>';
}
$text.=$langs->trans('ConfirmSendingEmailing').'<br>';

View File

@ -40,6 +40,8 @@ if (! isset($argv[1]) || ! $argv[1]) {
exit(-1);
}
$id=$argv[1];
if (! isset($argv[2]) || !empty($argv[2])) $login = $argv[2];
else $login = '';
require_once ($path."../../htdocs/master.inc.php");
require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
@ -58,7 +60,9 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
$user = new User($db);
// for signature, we use user send as parameter
if (! empty($login)) $user->fetch('',$login);
// We get list of emailing to process
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body,";
@ -144,6 +148,8 @@ if ($resql)
$other4=$other[3];
$other5=$other[4];
// Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
$signature = (!empty($user->signature))?$user->signature:'';
$substitutionarray=array(
'__ID__' => $obj->source_id,
'__EMAIL__' => $obj->email,
@ -155,7 +161,7 @@ if ($resql)
'__OTHER3__' => $other3,
'__OTHER4__' => $other4,
'__OTHER5__' => $other5,
'__SIGNATURE__' => '', // Signature is empty when ran from command line (user is a bot)
'__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter)
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj2->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'
);