Commit cc656d05 authored by Amiya Sahu's avatar Amiya Sahu

Performance inprovement and options added

parent 6b2003c9
The MIT License (MIT)
Copyright (c) 2013 Amiya Sahu (developer.amiya@outlook.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
function reset_all_notification_options() {
qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT, false);
qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT, false);
qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT, false);
qa_opt(MINIMUM_USER_POINT_OPT, false);
qa_opt(MINIMUM_USER_POINT_VAL_OPT, false);
}
function reset_all_notification_points_options() {
qa_opt(MINIMUM_USER_POINT_OPT, false);
qa_opt(MINIMUM_USER_POINT_VAL_OPT, false);
}
function set_all_notification_options() {
$error = array();
//if plugin is enabled then atlest one option has to be enabled
if (options_selected()) {
qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT, !!qa_post_text(ALLOW_CAT_FOLLOWER_EMAILS_FIELD));
qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT, !!qa_post_text(ALLOW_TAG_FOLLOWER_EMAILS_FIELD));
qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT, !!qa_post_text(ALLOW_USER_FOLLOWER_EMAILS_FIELD));
$minimum_user_point_option = !!qa_post_text(MINIMUM_USER_POINT_FIELD);
if ($minimum_user_point_option) { //if minimum point option is checked
$minimum_user_point_value = qa_post_text(MINIMUM_USER_POINT_VAL_FIELD);
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(MINIMUM_USER_POINT_VAL_OPT, (int) $minimum_user_point_value);
} else if (!is_numeric($minimum_user_point_value) || $minimum_user_point_value <= 0) {
reset_all_notification_points_options();
//send a error message to UI
$error['enter_point_value'] = "The points value should be a numeric and non-zero positive integer ";
} else {
reset_all_notification_points_options();
//send a error message to UI
$error['enter_point_value'] = "The points value is required to enable the option ";
}
} else {
reset_all_notification_points_options();
}
} else {
//if none of the elements are selected disable the plugin and send a error message UI
qa_opt(ENABLE_PLUGIN, false);
reset_all_notification_options();
$error['no_options_selected'] = "Please choose atleast follower option to enable this plugin ";
}
return $error;
}
function options_selected() {
return ((!!qa_post_text(ALLOW_CAT_FOLLOWER_EMAILS_FIELD)) ||
(!!qa_post_text(ALLOW_TAG_FOLLOWER_EMAILS_FIELD)) ||
(!!qa_post_text(ALLOW_USER_FOLLOWER_EMAILS_FIELD)) );
}
<?php
/*
Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/
File: qa-plugin/example-page/qa-example-lang-default.php
Version: See define()s at top of qa-include/qa-base.php
Description: US English language phrases for example plugin
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
return array(
'plugin-enable' => 'Enable this plugin.',
'user-follower-enable' => 'Send email to the User followers ' ,
'tag-follower-enable' => 'Send email to the Tag following users ' ,
'cat-follower-enable' => 'Send email to the Category following users ' ,
'minimum-point-enable' => 'Enable minimum point to receive email (must choose atleast one option from above list and must provide a non-zero positive integer for minimum points value in below text-box )',
'minimum-point-input-lable' => 'Minimum Points for users to receive email',
'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',
'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",
);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
<?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.
...@@ -19,7 +19,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -19,7 +19,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
} }
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-category-email-notifications-event.php', 'qa_category_email_notifications_event', 'Category Email Notifications');
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