summaryrefslogtreecommitdiff
path: root/Postman/Postman-Configuration
diff options
context:
space:
mode:
authoryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2018-04-04 19:17:51 +0000
committeryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2018-04-04 19:17:51 +0000
commit62b95f35576ea9b9178b900f9480fed0466211a2 (patch)
tree746cfdf1c0cdc8408b312870f881ed3684d8d60b /Postman/Postman-Configuration
parenta83767b57bb15075e775f2336cfd77225b155799 (diff)
downloadPost-SMTP-62b95f35576ea9b9178b900f9480fed0466211a2.zip
notification & new gmail client
Diffstat (limited to 'Postman/Postman-Configuration')
-rw-r--r--Postman/Postman-Configuration/PostmanConfigurationController.php71
-rw-r--r--Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php77
-rw-r--r--Postman/Postman-Configuration/postman_manual_config.js23
-rw-r--r--Postman/Postman-Configuration/postman_wizard.js20
4 files changed, 188 insertions, 3 deletions
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php
index 97972c2..6abb5e2 100644
--- a/Postman/Postman-Configuration/PostmanConfigurationController.php
+++ b/Postman/Postman-Configuration/PostmanConfigurationController.php
@@ -200,6 +200,7 @@ class PostmanConfigurationController {
print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', Postman::TEXT_DOMAIN ) );
print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', Postman::TEXT_DOMAIN ) );
print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', Postman::TEXT_DOMAIN ) );
+ print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', Postman::TEXT_DOMAIN ) );
print '</ul>';
print '<form method="post" action="options.php">';
// This prints out all hidden setting fields
@@ -248,6 +249,24 @@ class PostmanConfigurationController {
do_settings_sections( PostmanAdminController::NETWORK_OPTIONS );
do_settings_sections( PostmanAdminController::ADVANCED_OPTIONS );
print '</section>';
+
+ print '<section id="notifications">';
+ do_settings_sections( PostmanAdminController::NOTIFICATIONS_OPTIONS );
+
+ $currentKey = $this->options->getNotificationService();
+ $pushover = $currentKey == 'pushover' ? 'block' : 'none';
+ $slack = $currentKey == 'slack' ? 'block' : 'none';
+
+ echo '<div id="pushover_cred" style="display: ' . $pushover . ';">';
+ do_settings_sections( PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED );
+ echo '</div>';
+
+ echo '<div id="slack_cred" style="display: ' . $slack . ';">';
+ do_settings_sections( PostmanAdminController::NOTIFICATIONS_SLACK_CRED );
+ echo '</div>';
+
+ print '</section>';
+
submit_button();
print '</form>';
print '</div>';
@@ -362,7 +381,57 @@ class PostmanConfigurationController {
}
print '</fieldset>';
- // Wizard Step 5
+ // Wizard Step 5 - Notificiations
+ printf( '<h5>%s</h5>', __( 'Notifications', Postman::TEXT_DOMAIN ) );
+ print '<fieldset>';
+ printf( '<legend>%s</legend>', __( 'Select a notify service to notify you when an email is failed to delivered.', Postman::TEXT_DOMAIN ) );
+
+ ?>
+ <select id="input_notification_service" class="input_notification_service" name="postman_options[notification_service]">
+ <option value="default">Email</option>
+ <option value="pushover">Pushover</option>
+ <option value="slack">Slack</option>
+ </select>
+ <div id="pushover_cred" style="display: none;">
+ <h2><?php _e( 'Pushover Credentials', Postman::TEXT_DOMAIN ); ?></h2>
+ <table class="form-table">
+ <tbody>
+ <tr>
+ <th scope="row"><?php _e( 'Pushover User Key', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="password" id="pushover_user" name="postman_options[pushover_user]" value="">
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e( 'Pushover App Token', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="password" id="pushover_token" name="postman_options[pushover_token]" value="">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="slack_cred" style="display: none;">
+ <h2><?php _e( 'Slack Credentials', Postman::TEXT_DOMAIN ); ?></h2>
+ <table class="form-table">
+ <tbody>
+ <tr>
+ <th scope="row"><?php _e( 'Slack webhook', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="password" id="slack_token" name="postman_options[slack_token]" value="">
+ <a target="_blank" class="" href="https://slack.postmansmtp.com/">
+ <?php _e( 'Get your webhook URL here.', Postman::TEXT_DOMAIN ); ?>
+ </a>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+
+ <?php
+ print '</fieldset>';
+
+ // Wizard Step 6
printf( '<h5>%s</h5>', _x( 'Finish', 'The final step of the Wizard', Postman::TEXT_DOMAIN ) );
print '<fieldset>';
printf( '<legend>%s</legend>', _x( 'You\'re Done!', 'Wizard Step Title', Postman::TEXT_DOMAIN ) );
diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
index e3a68b3..1daedf2 100644
--- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
+++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
@@ -174,6 +174,45 @@ class PostmanSettingsRegistry {
$this,
'temporaryDirectoryCallback',
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
+
+ // Notifications
+ add_settings_section( PostmanAdminController::NOTIFICATIONS_SECTION, _x( 'Notifications Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'printNotificationsSectionInfo',
+ ), PostmanAdminController::NOTIFICATIONS_OPTIONS );
+
+ add_settings_field( PostmanOptions::NOTIFICATION_SERVICE, _x( 'Notification Service', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'notification_service_callback',
+ ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
+
+ // Pushover
+ add_settings_section( 'pushover_credentials', _x( 'Pushover Credentials', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'printNotificationsSectionInfo',
+ ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED );
+
+ add_settings_field( PostmanOptions::PUSHOVER_USER, _x( 'Pushover User Key', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'pushover_user_callback',
+ ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' );
+
+ add_settings_field( PostmanOptions::PUSHOVER_TOKEN, _x( 'Pushover App Token', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'pushover_token_callback',
+ ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' );
+
+ // Slack
+ add_settings_section( 'slack_credentials', _x( 'Slack Credentials', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'printNotificationsSectionInfo',
+ ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED );
+
+ add_settings_field( PostmanOptions::SLACK_TOKEN, _x( 'Slack Webhook', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'slack_token_callback',
+ ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' );
+
}
}
@@ -207,11 +246,19 @@ class PostmanSettingsRegistry {
public function printNetworkSectionInfo() {
print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', Postman::TEXT_DOMAIN );
}
+
/**
* Print the Section text
*/
public function printAdvancedSectionInfo() {
}
+
+ /**
+ * Print the Section text
+ */
+ public function printNotificationsSectionInfo() {
+ }
+
/**
* Print the Section text
*/
@@ -345,7 +392,7 @@ class PostmanSettingsRegistry {
* Get the settings option array and print one of its values
*/
public function log_level_callback() {
- $inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_blank" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
+ $inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL );
$currentKey = $this->options->getLogLevel();
$this->printSelectOption( __( 'Off', Postman::TEXT_DOMAIN ), PostmanLogger::OFF_INT, $currentKey );
@@ -356,6 +403,32 @@ class PostmanSettingsRegistry {
$this->printSelectOption( __( 'Error', Postman::TEXT_DOMAIN ), PostmanLogger::ERROR_INT, $currentKey );
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
}
+
+ public function notification_service_callback() {
+ $inputDescription = __( 'Select the notification service you want to recieve alerts about failed emails.' );
+ printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_SERVICE );
+ $currentKey = $this->options->getNotificationService();
+
+ $this->printSelectOption( __( 'Email', Postman::TEXT_DOMAIN ), 'default', $currentKey );
+ $this->printSelectOption( __( 'Pushover', Postman::TEXT_DOMAIN ), 'pushover', $currentKey );
+ $this->printSelectOption( __( 'Slack', Postman::TEXT_DOMAIN ), 'slack', $currentKey );
+ printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
+ }
+
+ public function pushover_user_callback() {
+ printf( '<input type="password" id="pushover_user" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PUSHOVER_USER, $this->options->getPushoverUser() );
+ }
+
+ public function pushover_token_callback() {
+ printf( '<input type="password" id="pushover_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PUSHOVER_TOKEN, $this->options->getPushoverToken() );
+ }
+
+ public function slack_token_callback() {
+ printf( '<input type="password" id="slack_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::SLACK_TOKEN, $this->options->getPushoverToken() );
+ echo '<a target="_blank" href="https://slack.postmansmtp.com/">' . __( 'Get your webhook URL here', Postman::TEXT_DOMAIN ) . '</a>';
+
+ }
+
private function printSelectOption( $label, $optionKey, $currentKey ) {
$optionPattern = '<option value="%1$s" %2$s>%3$s</option>';
printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label );
@@ -369,9 +442,11 @@ class PostmanSettingsRegistry {
$this->printSelectOption( __( 'Delete All Emails', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_IGNORE, $currentKey );
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
}
+
public function stealthModeCallback() {
printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages', Postman::TEXT_DOMAIN ) );
}
+
public function temporaryDirectoryCallback() {
$inputDescription = __( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' );
printf( '<input type="text" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() );
diff --git a/Postman/Postman-Configuration/postman_manual_config.js b/Postman/Postman-Configuration/postman_manual_config.js
index 14d4d9f..e7668b7 100644
--- a/Postman/Postman-Configuration/postman_manual_config.js
+++ b/Postman/Postman-Configuration/postman_manual_config.js
@@ -23,6 +23,26 @@ jQuery(document).ready(
switchBetweenPasswordAndOAuth();
});
+ jQuery('select#input_notification_service').change(function() {
+ var selected = $( this ).val();
+
+ if ( selected == 'default' ) {
+ $('#slack_cred').fadeOut('fast');
+ $('#pushover_cred').fadeOut('fast');
+ }
+
+ if ( selected == 'pushover' ) {
+ $('#slack_cred').fadeOut('fast');
+ $('#pushover_cred').fadeIn();
+ }
+
+ if ( selected == 'slack' ) {
+ $('#pushover_cred').fadeOut('fast');
+ $('#slack_cred').fadeIn();
+ }
+ });
+
+
// add an event on the authentication input field
// on user changing the auth type, determine whether to show
// password or oauth section
@@ -52,6 +72,7 @@ jQuery(document).ready(
}
}
});
+
function reloadOauthSection() {
var hostname = jQuery(postman_hostname_element_name).val();
var transport = jQuery('#input_transport_type').val();
@@ -74,5 +95,5 @@ function switchBetweenPasswordAndOAuth() {
var transportName = jQuery('select#input_transport_type').val();
transports.forEach(function(item) {
item.handleTransportChange(transportName);
- })
+ });
}
diff --git a/Postman/Postman-Configuration/postman_wizard.js b/Postman/Postman-Configuration/postman_wizard.js
index 097fd65..8e1a68c 100644
--- a/Postman/Postman-Configuration/postman_wizard.js
+++ b/Postman/Postman-Configuration/postman_wizard.js
@@ -492,6 +492,26 @@ function handleConfigurationResponse(response) {
}
}
+
+ jQuery('select#input_notification_service').change(function() {
+ var selected = $( this ).val();
+
+ if ( selected == 'default' ) {
+ $('#slack_cred').fadeOut('fast');
+ $('#pushover_cred').fadeOut('fast');
+ }
+
+ if ( selected == 'pushover' ) {
+ $('#slack_cred').fadeOut('fast');
+ $('#pushover_cred').fadeIn();
+ }
+
+ if ( selected == 'slack' ) {
+ $('#pushover_cred').fadeOut('fast');
+ $('#slack_cred').fadeIn();
+ }
+ });
+
// add an event on the user port override field
jQuery('input.user_socket_override').change(function() {
userOverrideMenu();