Commit 4a3199cb authored by Amiya Sahu's avatar Amiya Sahu

Code Cleanup and languages added

parent cc656d05
...@@ -6,16 +6,16 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -6,16 +6,16 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
} }
function reset_all_notification_options() { function reset_all_notification_options() {
qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT, false); qa_opt('ami_email_notf_allow_cat_follower', false);
qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT, false); qa_opt('ami_email_notf_allow_tag_follower', false);
qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT, false); qa_opt('ami_email_notf_allow_user_follower', false);
qa_opt(MINIMUM_USER_POINT_OPT, false); qa_opt('ami_email_notf_min_point', false);
qa_opt(MINIMUM_USER_POINT_VAL_OPT, false); qa_opt('ami_email_notf_min_point_val', false);
} }
function reset_all_notification_points_options() { function reset_all_notification_points_options() {
qa_opt(MINIMUM_USER_POINT_OPT, false); qa_opt('ami_email_notf_min_point', false);
qa_opt(MINIMUM_USER_POINT_VAL_OPT, false); qa_opt('ami_email_notf_min_point_val', false);
} }
function set_all_notification_options() { function set_all_notification_options() {
...@@ -23,38 +23,38 @@ function set_all_notification_options() { ...@@ -23,38 +23,38 @@ function set_all_notification_options() {
$error = array(); $error = array();
//if plugin is enabled then atlest one option has to be enabled //if plugin is enabled then atlest one option has to be enabled
if (options_selected()) { if (options_selected()) {
qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT, !!qa_post_text(ALLOW_CAT_FOLLOWER_EMAILS_FIELD)); qa_opt('ami_email_notf_allow_cat_follower', !!qa_post_text('ami_email_notf_allow_cat_follower'));
qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT, !!qa_post_text(ALLOW_TAG_FOLLOWER_EMAILS_FIELD)); qa_opt('ami_email_notf_allow_tag_follower', !!qa_post_text('ami_email_notf_allow_tag_follower'));
qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT, !!qa_post_text(ALLOW_USER_FOLLOWER_EMAILS_FIELD)); qa_opt('ami_email_notf_allow_user_follower', !!qa_post_text('ami_email_notf_allow_user_follower'));
$minimum_user_point_option = !!qa_post_text(MINIMUM_USER_POINT_FIELD); $minimum_user_point_option = !!qa_post_text('ami_email_notf_min_point');
if ($minimum_user_point_option) { //if minimum point option is checked if ($minimum_user_point_option) { //if minimum point option is checked
$minimum_user_point_value = qa_post_text(MINIMUM_USER_POINT_VAL_FIELD); $minimum_user_point_value = qa_post_text('ami_email_notf_min_point_val');
if (!!$minimum_user_point_value && is_numeric($minimum_user_point_value) && $minimum_user_point_value > 0) { //if the minimum point value is provided then only set else reset if (!!$minimum_user_point_value && is_numeric($minimum_user_point_value) && $minimum_user_point_value > 0) { //if the minimum point value is provided then only set else reset
qa_opt(MINIMUM_USER_POINT_OPT, $minimum_user_point_option); qa_opt('ami_email_notf_min_point', $minimum_user_point_option);
qa_opt(MINIMUM_USER_POINT_VAL_OPT, (int) $minimum_user_point_value); qa_opt('ami_email_notf_min_point_val', (int) $minimum_user_point_value);
} else if (!is_numeric($minimum_user_point_value) || $minimum_user_point_value <= 0) { } else if (!is_numeric($minimum_user_point_value) || $minimum_user_point_value <= 0) {
reset_all_notification_points_options(); reset_all_notification_points_options();
//send a error message to UI //send a error message to UI
$error['enter_point_value'] = "The points value should be a numeric and non-zero positive integer "; $error['enter_point_value'] = qa_lang('point_value_should_numeric');
} else { } else {
reset_all_notification_points_options(); reset_all_notification_points_options();
//send a error message to UI //send a error message to UI
$error['enter_point_value'] = "The points value is required to enable the option "; $error['enter_point_value'] = qa_lang('point_value_required'); ;
} }
} else { } else {
reset_all_notification_points_options(); reset_all_notification_points_options();
} }
} else { } else {
//if none of the elements are selected disable the plugin and send a error message UI //if none of the elements are selected disable the plugin and send a error message UI
qa_opt(ENABLE_PLUGIN, false); qa_opt('ami_email_notf_enable_plugin', false);
reset_all_notification_options(); reset_all_notification_options();
$error['no_options_selected'] = "Please choose atleast follower option to enable this plugin "; $error['no_options_selected'] = qa_lang('choose_atleast_one_opt');
} }
return $error; return $error;
} }
function options_selected() { function options_selected() {
return ((!!qa_post_text(ALLOW_CAT_FOLLOWER_EMAILS_FIELD)) || return ((!!qa_post_text('ami_email_notf_allow_cat_follower')) ||
(!!qa_post_text(ALLOW_TAG_FOLLOWER_EMAILS_FIELD)) || (!!qa_post_text('ami_email_notf_allow_tag_follower')) ||
(!!qa_post_text(ALLOW_USER_FOLLOWER_EMAILS_FIELD)) ); (!!qa_post_text('ami_email_notf_allow_user_follower')) );
} }
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
'debug-mode-enable' => 'Enable debug mode ( requires event logger plugin to be enabled with log file option , to get the search results to the log file . Not recomended if you are not a developer ) . ', 'debug-mode-enable' => 'Enable debug mode ( requires event logger plugin to be enabled with log file option , to get the search results to the log file . Not recomended if you are not a developer ) . ',
'save-button' => 'Save Changes', 'save-button' => 'Save Changes',
'q_posted_body' => "A new question has been asked by ^q_handle:\n\nThe Question is : ^open^q_title\n\nDescription : ^open^q_content^close\n\nClick below to see the question:\n\n^url\n\nThank you,\n\n^site_title ^open^site_url", 'q_posted_body' => "A new question has been asked by ^q_handle:\n\nThe Question is : ^open^q_title\n\nDescription : ^open^q_content^close\n\nClick below to see the question:\n\n^url\n\nThank you,\n\n^site_title ^open^site_url",
'choose_atleast_one_opt' => 'Please choose atleast follower option to enable this plugin ' ,
'point_value_required' => 'The points value is required to enable the option ' ,
'point_value_should_numeric' => 'The points value should be a numeric and non-zero positive integer',
); );
......
<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
//define the option prefix
define('PLUGIN_NAME', 'qa_email_notf_');
//define enable and disable options
define('ENABLE_PLUGIN', PLUGIN_NAME . 'enable_plugin');
define('ENABLE_PLUGIN_FIELD', PLUGIN_NAME . 'enable_plugin_field');
//define the options
define('EAMIL_NOTF_DEBUG_MODE_OPT', PLUGIN_NAME . 'debug_mode');
define('ALLOW_CAT_FOLLOWER_EMAILS_OPT', PLUGIN_NAME . 'allow_cat_follower_emails');
define('ALLOW_TAG_FOLLOWER_EMAILS_OPT', PLUGIN_NAME . 'allow_tag_follower_emails');
define('ALLOW_USER_FOLLOWER_EMAILS_OPT', PLUGIN_NAME . 'allow_user_follower_emails');
define('MINIMUM_USER_POINT_OPT', PLUGIN_NAME . 'min_point');
define('MINIMUM_USER_POINT_VAL_OPT', PLUGIN_NAME . 'min_point_val');
//define the admin form fields and buttons
define('EAMIL_NOTF_DEBUG_MODE_FIELD', PLUGIN_NAME . 'debug_mode_field');
define('ALLOW_CAT_FOLLOWER_EMAILS_FIELD', PLUGIN_NAME . 'allow_cat_follower_emails_field');
define('ALLOW_TAG_FOLLOWER_EMAILS_FIELD', PLUGIN_NAME . 'allow_tag_follower_emails_field');
define('ALLOW_USER_FOLLOWER_EMAILS_FIELD', PLUGIN_NAME . 'allow_user_follower_emails_field');
define('MINIMUM_USER_POINT_FIELD', PLUGIN_NAME . 'min_point_field');
define('MINIMUM_USER_POINT_VAL_FIELD', PLUGIN_NAME . 'min_point_val_field');
define('SAVE_BUTTON', PLUGIN_NAME . 'save_button');
This diff is collapsed.
<?php <?php
/* /*
Plugin Name: Email Notifications Plugin Name: Category/Tag Email Notification
Plugin URI: http://amiyasahu.com Plugin URI: http://amiyasahu.com
Plugin Description: Sends email for new questions, to users who favoritised the category where it was posted Plugin Description: Sends email for new questions, to users who is following a catogory or
Plugin Version: 0.1 Plugin Version: 0.1
Plugin Date: 2014-04-20 Plugin Date: 2014-04-20
Plugin Author: Amiya Sahu Plugin Author: Amiya Sahu
...@@ -18,8 +18,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -18,8 +18,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
exit; exit;
} }
qa_register_plugin_module('event', 'qa-category-email-notifications-event.php', 'qa_category_email_notifications_event', 'Category Email Notifications'); qa_register_plugin_module('event', 'qa-email-notifications-event.php', 'qa_email_notifications_event', 'Category/Tag Email Notifications');
qa_register_plugin_phrases('language/qa-email-notification-lang-*.php', 'notify'); qa_register_plugin_phrases('language/qa-email-notification-lang-*.php', 'notify');
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment