mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:54:30 -04: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'];
|
$client = $data['client'];
|
||||||
$invitation = $data['invitation'];
|
$invitation = $data['invitation'];
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
|
$passwordHTML = isset($data['password'])?'<p>'.trans('texts.password').': '.$data['password'].'<p>':false;
|
||||||
|
|
||||||
$variables = [
|
$variables = [
|
||||||
'$footer' => $account->getEmailFooter(),
|
'$footer' => $account->getEmailFooter(),
|
||||||
@ -275,15 +276,15 @@ class ContactMailer extends Mailer
|
|||||||
'$invoice' => $invoice->invoice_number,
|
'$invoice' => $invoice->invoice_number,
|
||||||
'$quote' => $invoice->invoice_number,
|
'$quote' => $invoice->invoice_number,
|
||||||
'$link' => $invitation->getLink(),
|
'$link' => $invitation->getLink(),
|
||||||
'$viewLink' => $invitation->getLink(),
|
'$password' => $passwordHTML,
|
||||||
'$viewButton' => Form::emailViewButton($invitation->getLink(), $invoice->getEntityType()),
|
'$viewLink' => $invitation->getLink().'$password',
|
||||||
'$paymentLink' => $invitation->getLink('payment'),
|
'$viewButton' => Form::emailViewButton($invitation->getLink(), $invoice->getEntityType()).'$password',
|
||||||
'$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')),
|
'$paymentLink' => $invitation->getLink('payment').'$password',
|
||||||
|
'$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password',
|
||||||
'$customClient1' => $account->custom_client_label1,
|
'$customClient1' => $account->custom_client_label1,
|
||||||
'$customClient2' => $account->custom_client_label2,
|
'$customClient2' => $account->custom_client_label2,
|
||||||
'$customInvoice1' => $account->custom_invoice_text_label1,
|
'$customInvoice1' => $account->custom_invoice_text_label1,
|
||||||
'$customInvoice2' => $account->custom_invoice_text_label2,
|
'$customInvoice2' => $account->custom_invoice_text_label2,
|
||||||
'$password' => isset($data['password'])?$data['password']:false,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Add variables for available payment types
|
// Add variables for available payment types
|
||||||
@ -293,9 +294,21 @@ class ContactMailer extends Mailer
|
|||||||
$variables["\${$camelType}Link"] = $invitation->getLink() . "/{$type}";
|
$variables["\${$camelType}Link"] = $invitation->getLink() . "/{$type}";
|
||||||
$variables["\${$camelType}Button"] = Form::emailPaymentButton($invitation->getLink('payment') . "/{$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 = str_replace(array_keys($variables), array_values($variables), $template);
|
||||||
$str = autolink($str, 100);
|
$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;
|
return $str;
|
||||||
}
|
}
|
||||||
|
@ -200,6 +200,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!};
|
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 = [
|
var vals = [
|
||||||
{!! json_encode($emailFooter) !!},
|
{!! json_encode($emailFooter) !!},
|
||||||
"{{ $account->getDisplayName() }}",
|
"{{ $account->getDisplayName() }}",
|
||||||
@ -211,11 +212,11 @@
|
|||||||
"First Name",
|
"First Name",
|
||||||
"0001",
|
"0001",
|
||||||
"0001",
|
"0001",
|
||||||
'6h2NWNdw6',
|
passwordHtml,
|
||||||
"{{ URL::to('/view/...') }}",
|
"{{ URL::to('/view/...') }}$password",
|
||||||
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}',
|
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password',
|
||||||
"{{ URL::to('/payment/...') }}",
|
"{{ URL::to('/payment/...') }}$password",
|
||||||
'{!! Form::flatButton('pay_now', '#36c157') !!}',
|
'{!! Form::flatButton('pay_now', '#36c157') !!}$password',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Add blanks for custom values
|
// Add blanks for custom values
|
||||||
@ -231,10 +232,18 @@
|
|||||||
{!! "vals.push('" . Form::flatButton('pay_now', '#36c157') . "');" !!}
|
{!! "vals.push('" . Form::flatButton('pay_now', '#36c157') . "');" !!}
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
var includesPasswordPlaceholder = str.indexOf('$password') != -1;
|
||||||
|
|
||||||
for (var i=0; i<keys.length; i++) {
|
for (var i=0; i<keys.length; i++) {
|
||||||
var regExp = new RegExp('\\$'+keys[i], 'g');
|
var regExp = new RegExp('\\$'+keys[i], 'g');
|
||||||
str = str.replace(regExp, vals[i]);
|
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;
|
return str;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user