Add stats notifications settings

[MAILPOET-1571]
This commit is contained in:
Pavel Dohnal
2018-12-10 11:31:21 +01:00
parent cc8e0db927
commit 195efad742
3 changed files with 77 additions and 13 deletions

View File

@@ -194,6 +194,15 @@ class Populator {
]); ]);
} }
$stats_notifications = Setting::getValue('stats_notifications');
if(empty($stats_notifications)) {
$sender = Setting::getValue('sender', []);
Setting::setValue('stats_notifications', [
'enabled' => true,
'address' => isset($sender['address'])? $sender['address'] : null,
]);
}
// reset mailer log // reset mailer log
MailerLog::resetMailerLog(); MailerLog::resetMailerLog();
} }

View File

@@ -98,6 +98,17 @@
} else { } else {
$('#settings_subscriber_email_notification_error').hide(); $('#settings_subscriber_email_notification_error').hide();
} }
console.log("whatever");
// if new subscriber notification is enabled but sender is empty, show error
var stats_notifications_enabled = $('input[name="stats_notifications[enabled]"]:checked').val(),
stats_notifications_address = $('input[name="stats_notifications[address]"]').val().trim();
if (stats_notifications_enabled && stats_notifications_address == '') {
$('#settings_stats_notifications_error').show();
window.location.href = '#basics';
errorFound = true;
} else {
$('#settings_stats_notifications_error').hide();
}
// stop processing if an error was found // stop processing if an error was found
if (errorFound) { if (errorFound) {
return false; return false;
@@ -182,6 +193,7 @@
$('#settings_re_captcha_tokens_error').hide(); $('#settings_re_captcha_tokens_error').hide();
$('#settings_subscriber_email_notification_error').hide(); $('#settings_subscriber_email_notification_error').hide();
$('#settings_stats_notifications_error').hide();
function toggleLinuxCronSettings() { function toggleLinuxCronSettings() {
if ($('input[name="cron_trigger[method]"]:checked').val() === '<%= cron_trigger.linux_cron %>') { if ($('input[name="cron_trigger[method]"]:checked').val() === '<%= cron_trigger.linux_cron %>') {

View File

@@ -281,6 +281,48 @@
</td> </td>
</tr> </tr>
<!-- Stats notifications -->
<tr>
<th scope="row">
<label for="subscription_unsubscribe_page">
<%= _x('Stats notifications', 'name of a setting to automatically send statistics (newsletter open rate, click rate, etc) by email') %>
</label>
<p class="description">
<%= __('Enter the email address that should receive your newsletters stats 24 hours after it has been sent.') %>
<td>
<p>
<label>
<input
type="radio"
name="stats_notifications[enabled]"
value="1"
<% if(settings.stats_notifications.enabled) %>
checked
<% endif %>
/><%= __('Yes') %>
</label>
&nbsp;
<label>
<input
type="radio"
name="stats_notifications[enabled]"
value=""
<% if not(settings.stats_notifications.enabled) %>
checked
<% endif %>
><%= __('No') %>
</label>
<br>
<input type="email"
id="stats_notifications[address]"
name="stats_notifications[address]"
value="<%= settings.stats_notifications.address %>"
placeholder="me@mydomain.com" >
<br>
<div id="settings_stats_notifications_error" class="mailpoet_error_item mailpoet_error">
<%= __('Please fill the email address.') %>
</div>
<!-- New subscriber emails notifications --> <!-- New subscriber emails notifications -->
<tr> <tr>
<th scope="row"> <th scope="row">
@@ -296,9 +338,9 @@
type="radio" type="radio"
name="subscriber_email_notification[enabled]" name="subscriber_email_notification[enabled]"
value="1" value="1"
<% if(settings.subscriber_email_notification.enabled) %> <% if(settings.subscriber_email_notification.enabled) %>
checked checked
<% endif %> <% endif %>
/><%= __('Yes') %> /><%= __('Yes') %>
</label> </label>
&nbsp; &nbsp;
@@ -307,21 +349,22 @@
type="radio" type="radio"
name="subscriber_email_notification[enabled]" name="subscriber_email_notification[enabled]"
value="" value=""
<% if not(settings.subscriber_email_notification.enabled) %> <% if not(settings.subscriber_email_notification.enabled) %>
checked checked
<% endif %> <% endif %>
/><%= __('No') %> /><%= __('No') %>
</label> </label>
<br> <br>
<input type="email" <input type="email"
id="subscriber_email_notification[address]" id="subscriber_email_notification[address]"
name="subscriber_email_notification[address]" name="subscriber_email_notification[address]"
value="<%= settings.subscriber_email_notification.address %>" value="<%= settings.subscriber_email_notification.address %>"
placeholder="me@mydomain.com" /> placeholder="me@mydomain.com" />
<br> <br>
<div id="settings_subscriber_email_notification_error" class="mailpoet_error_item mailpoet_error"> <div id="settings_subscriber_email_notification_error" class="mailpoet_error_item mailpoet_error">
<%= __('Please fill the email address.') %> <%= __('Please fill the email address.') %>
</div> </div>
<!-- shortcode: archive page --> <!-- shortcode: archive page -->
<tr> <tr>
<th scope="row"> <th scope="row">