mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Finalize support for emailing passwords
This commit is contained in:
parent
0166576987
commit
82fadab632
@ -262,6 +262,7 @@ class ContactMailer extends Mailer
|
||||
$client = $data['client'];
|
||||
$invitation = $data['invitation'];
|
||||
$invoice = $invitation->invoice;
|
||||
$passwordHTML = isset($data['password'])?'<p>'.trans('texts.password').': '.$data['password'].'<p>':false;
|
||||
|
||||
$variables = [
|
||||
'$footer' => $account->getEmailFooter(),
|
||||
@ -275,15 +276,15 @@ class ContactMailer extends Mailer
|
||||
'$invoice' => $invoice->invoice_number,
|
||||
'$quote' => $invoice->invoice_number,
|
||||
'$link' => $invitation->getLink(),
|
||||
'$viewLink' => $invitation->getLink(),
|
||||
'$viewButton' => Form::emailViewButton($invitation->getLink(), $invoice->getEntityType()),
|
||||
'$paymentLink' => $invitation->getLink('payment'),
|
||||
'$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')),
|
||||
'$password' => $passwordHTML,
|
||||
'$viewLink' => $invitation->getLink().'$password',
|
||||
'$viewButton' => Form::emailViewButton($invitation->getLink(), $invoice->getEntityType()).'$password',
|
||||
'$paymentLink' => $invitation->getLink('payment').'$password',
|
||||
'$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password',
|
||||
'$customClient1' => $account->custom_client_label1,
|
||||
'$customClient2' => $account->custom_client_label2,
|
||||
'$customInvoice1' => $account->custom_invoice_text_label1,
|
||||
'$customInvoice2' => $account->custom_invoice_text_label2,
|
||||
'$password' => isset($data['password'])?$data['password']:false,
|
||||
];
|
||||
|
||||
// Add variables for available payment types
|
||||
@ -293,9 +294,21 @@ class ContactMailer extends Mailer
|
||||
$variables["\${$camelType}Link"] = $invitation->getLink() . "/{$type}";
|
||||
$variables["\${$camelType}Button"] = Form::emailPaymentButton($invitation->getLink('payment') . "/{$type}");
|
||||
}
|
||||
|
||||
|
||||
$includesPasswordPlaceholder = strpos($template, '$password') !== false;
|
||||
|
||||
$str = str_replace(array_keys($variables), array_values($variables), $template);
|
||||
$str = autolink($str, 100);
|
||||
|
||||
if(!$includesPasswordPlaceholder && $passwordHTML){
|
||||
$pos = strrpos($str, '$password');
|
||||
if($pos !== false)
|
||||
{
|
||||
$str = substr_replace($str, $passwordHTML, $pos, 9/* length of "$password" */);
|
||||
}
|
||||
}
|
||||
$str = str_replace('$password', '', $str);
|
||||
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
@ -200,6 +200,7 @@
|
||||
}
|
||||
|
||||
var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!};
|
||||
var passwordHtml = "{!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password?'<p>'.trans('texts.password').': 6h2NWNdw6<p>':'' !!}";
|
||||
var vals = [
|
||||
{!! json_encode($emailFooter) !!},
|
||||
"{{ $account->getDisplayName() }}",
|
||||
@ -211,11 +212,11 @@
|
||||
"First Name",
|
||||
"0001",
|
||||
"0001",
|
||||
'6h2NWNdw6',
|
||||
"{{ URL::to('/view/...') }}",
|
||||
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}',
|
||||
"{{ URL::to('/payment/...') }}",
|
||||
'{!! Form::flatButton('pay_now', '#36c157') !!}',
|
||||
passwordHtml,
|
||||
"{{ URL::to('/view/...') }}$password",
|
||||
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password',
|
||||
"{{ URL::to('/payment/...') }}$password",
|
||||
'{!! Form::flatButton('pay_now', '#36c157') !!}$password',
|
||||
];
|
||||
|
||||
// Add blanks for custom values
|
||||
@ -231,10 +232,18 @@
|
||||
{!! "vals.push('" . Form::flatButton('pay_now', '#36c157') . "');" !!}
|
||||
@endforeach
|
||||
|
||||
var includesPasswordPlaceholder = str.indexOf('$password') != -1;
|
||||
|
||||
for (var i=0; i<keys.length; i++) {
|
||||
var regExp = new RegExp('\\$'+keys[i], 'g');
|
||||
str = str.replace(regExp, vals[i]);
|
||||
}
|
||||
|
||||
if(!includesPasswordPlaceholder){
|
||||
var lastSpot = str.lastIndexOf('$password')
|
||||
str = str.slice(0, lastSpot) + str.slice(lastSpot).replace('$password', passwordHtml);
|
||||
}
|
||||
str = str.replace(/\$password/g,'');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user