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');
<?php
/*
Amiya Sahu
Amiya Sahu
File: qa-plugin/qa-category-email-notifications/qa-category-email-notifications-event.php
Version: 0.9
Date: 2013-02-21
Description: Event module class for category email notifications plugin
*/
define('ALLOW_CAT_FOLLOWER_EMAILS', true);
define('ALLOW_TAG_FOLLOWER_EMAILS', false);
define('ALLOW_USER_FOLLOWER_EMAILS', true);
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
define('EMAIL_NOTF_PLUGIN_DIR', __DIR__);
include_once EMAIL_NOTF_PLUGIN_DIR . '/plugin-constants.php';
class qa_category_email_notifications_event {
function process_event($event, $userid, $handle, $cookieid, $params) {
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
switch ($event) {
case 'q_post':
/* $categoryid = $params['categoryid'];
$tags = $params['tags'];*/
$categoryid = qa_get($params , 'categoryid');
$tags = qa_get($params , 'tags');
$emails = array();
if (ALLOW_CAT_FOLLOWER_EMAILS && !! $categoryid ) {
$cat_follower_emails = qa_db_select_with_pending($this->qa_db_category_favorite_emails_selectspec($categoryid));
$emails = array_merge($emails , $cat_follower_emails);
}
if (ALLOW_TAG_FOLLOWER_EMAILS && !!$tags ) {
$tag_follower_emails = qa_db_select_with_pending($this->qa_db_tag_favorite_emails_selectspec($tags));
$emails = array_merge($emails , $tag_follower_emails);
}
if (ALLOW_USER_FOLLOWER_EMAILS) {
$user_follower_emails = qa_db_select_with_pending($this->qa_db_user_follower_emails_selectspec(qa_get_logged_in_userid()));
$emails = array_merge($emails , $user_follower_emails);
}
$emails = $this->combine_emails($emails);
for ($i = 0; $i < count($emails); $i++) {
$bcclist = array();
for ($j = 0; $j < 75 && $i < count($emails); $j++, $i++) {
$bcclist[] = $emails[$i]['email'];
}
$this->category_email_notification_send_notification($bcclist, null, null, qa_lang('emails/q_posted_subject'), qa_lang('emails/q_posted_body'), array(
'^q_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'),
'^q_title' => $params['title'], // don't censor title or content here since we want the admin to see bad words
'^q_content' => $params['text'],
'^url' => qa_q_path($params['postid'], $params['title'], true),
)
);
}
break;
}
}
function qa_db_category_favorite_emails_selectspec($categoryid)
/*
*/ {
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
return array(
'columns' => array('DISTINCT ^users.email'),
'source' => "^users JOIN ^userfavorites ON ^userfavorites.userid=^users.userid "
. "WHERE ^userfavorites.entityid=$ AND ^userfavorites.entitytype=$ AND ^users.email !=$",
'arguments' => array($categoryid, QA_ENTITY_CATEGORY, qa_get_logged_in_user_field('email')),
'sortasc' => 'title',
);
}
function qa_db_tag_favorite_emails_selectspec($tags){
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
return array(
'columns' => array('DISTINCT ^users.email'),
'source' => "^users JOIN ^userfavorites ON ^userfavorites.userid=^users.userid WHERE ^userfavorites.entityid IN
( SELECT wordid from ^words where ^words.word IN ($) ) AND ^userfavorites.entitytype=$ AND ^users.email !=$",
'arguments' => array(qa_tagstring_to_tags($tags), QA_ENTITY_TAG, qa_get_logged_in_user_field('email')),
'sortasc' => 'title',
);
}
function qa_db_user_follower_emails_selectspec($userid) {
require_once QA_INCLUDE_DIR.'qa-app-updates.php';
return array(
'columns' => array('DISTINCT ^users.email'),
'source' => "^users JOIN ^userpoints ON ^users.userid=^userpoints.userid JOIN ^userfavorites ON ^users.userid=^userfavorites.userid WHERE ^userfavorites.entityid=$ AND ^userfavorites.entitytype=$",
'arguments' => array($userid, QA_ENTITY_USER),
'sortasc' => 'handle',
);
}
function qa_db_user_follower_emails_selectspec1($user_id) {
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
return array(
'columns' => array('DISTINCT ^users.email'),
'source' => "^users JOIN ^userfavorites ON ^userfavorites.userid=^users.userid WHERE ^userfavorites.entityid = $ AND ^userfavorites.entitytype=$ ",
'arguments' => array( $user_id , QA_ENTITY_USER ),
'sortasc' => 'title',
);
}
function combine_emails( $emails_id_list ) {
$unique_email_ids = array();
$return_email_datas = array();
foreach ($emails_id_list as $email_data) {
$email = $email_data['email'];
if (!in_array($email, $unique_email_ids)){
$return_email_datas[] = $email_data ;
$unique_email_ids[] = $email ;
}
}
return $return_email_datas;
}
function category_email_notification_send_notification($bcclist, $email, $handle, $subject, $body, $subs)
/*
*/ {
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
global $qa_notifications_suspended;
if ($qa_notifications_suspended > 0)
return false;
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
$subs['^site_title'] = qa_opt('site_title');
$subs['^handle'] = $handle;
$subs['^email'] = $email;
$subs['^open'] = "\n";
$subs['^close'] = "\n";
return $this->category_email_send_email(array(
'fromemail' => qa_opt('from_email'),
'fromname' => qa_opt('site_title'),
'toemail' => $email,
'toname' => $handle,
'bcclist' => $bcclist,
'subject' => strtr($subject, $subs),
'body' => (empty($handle) ? '' : qa_lang_sub('emails/to_handle_prefix', $handle)) . strtr($body, $subs),
'html' => false,
));
}
function category_email_send_email($params){
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->From = $params['fromemail'];
$mailer->Sender = $params['fromemail'];
$mailer->FromName = $params['fromname'];
if (isset($params['toemail'])) {
$mailer->AddAddress($params['toemail'], $params['toname']);
}
$mailer->Subject = $params['subject'];
$mailer->Body = $params['body'];
if (isset($params['bcclist'])) {
foreach ($params['bcclist'] as $email) {
$mailer->AddBCC($email);
public $log_file_name, $log_file_exists, $log_file;
function process_event($event, $userid, $handle, $cookieid, $params) {
if ($this->plugin_enabled_from_admin_panel()) { //proceed only if the plugin is enabled
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
switch ($event) {
case 'q_post':
$categoryid = $this->qa_get($params, 'categoryid');
$tags = $this->qa_get($params, 'tags');
$emails = qa_db_select_with_pending($this->qa_db_notificaton_emails_selectspec(qa_get_logged_in_userid(), $tags, $categoryid));
$emails = $this->combine_emails($emails);
for ($i = 0; $i < count($emails); $i++) {
$bcclist = array();
for ($j = 0; $j < 75 && $i < count($emails); $j++, $i++) {
$bcclist[] = $emails[$i]['email'];
}
$this->category_email_notification_send_notification($bcclist, null, null, qa_lang('emails/q_posted_subject'), qa_lang('notify/q_posted_body'),
array(
'^q_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'),
'^q_title' => $params['title'], // don't censor title or content here since we want the admin to see bad words
'^q_content' => $params['text'],
'^url' => qa_q_path($params['postid'], $params['title'], true),
'^site_url' => qa_opt("site_url"),
)
);
}
break;
} //switch
}//if
}
function qa_db_notificaton_emails_selectspec($userid, $tags, $categoryid) {
if ($this->plugin_enabled_from_admin_panel()) { //proceed only if the plugin is enabled
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
$source = '';
$arguments = array();
if (!!qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT)) {
$source .= (!!$source) ? ' UNION ' : '';
$source .= "( SELECT ^users.email , 'U' as favorited , ^userpoints.points from ^users JOIN ^userpoints ON ^users.userid=^userpoints.userid JOIN ^userfavorites ON ^users.userid=^userfavorites.userid WHERE ^userfavorites.entityid=$ AND ^userfavorites.entitytype=$ AND ^users.email !=$ )";
$args = array($userid, QA_ENTITY_USER, qa_get_logged_in_user_field('email'));
$arguments = array_merge($arguments, $args);
}
if (!!qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT) && !!$tags) {
$source .= (!!$source) ? ' UNION ' : '';
$source .= "( SELECT ^users.email , 'T' as favorited , ^userpoints.points from ^users JOIN ^userpoints ON ^users.userid=^userpoints.userid JOIN ^userfavorites ON ^userfavorites.userid=^users.userid WHERE ^userfavorites.entityid IN
( SELECT wordid from ^words where ^words.word IN ($) ) AND ^userfavorites.entitytype=$ AND ^users.email !=$ )";
$args = array(qa_tagstring_to_tags($tags), QA_ENTITY_TAG, qa_get_logged_in_user_field('email'));
$arguments = array_merge($arguments, $args);
}
if (!!qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT) && !!$categoryid) {
$source .= (!!$source) ? ' UNION ' : '';
$source .= "( SELECT ^users.email , 'C' as favorited , ^userpoints.points from ^users JOIN ^userpoints ON ^users.userid=^userpoints.userid JOIN ^userfavorites ON ^userfavorites.userid=^users.userid "
. "WHERE ^userfavorites.entityid=$ AND ^userfavorites.entitytype=$ AND ^users.email !=$ )";
$args = array($categoryid, QA_ENTITY_CATEGORY, qa_get_logged_in_user_field('email'));
$arguments = array_merge($arguments, $args);
}
$where_clause = '';
if (!!qa_opt(MINIMUM_USER_POINT_OPT)) {
//generate where clause
$min_user_points = qa_opt(MINIMUM_USER_POINT_VAL_OPT);
$where_clause = ((!!$min_user_points && ( $min_user_points > 0) )) ? 'where result.points > ' . $min_user_points : '';
}
return array(
'columns' => array(' * '),
'source' => ' ( ' . $source . ' ) as result ' . $where_clause,
'arguments' => $arguments,
'sortasc' => 'title',
);
} //if plugin is enabled
}
//qa_db_notificaton_emails_selectspec
function combine_emails($emails_id_list) {
$unique_email_ids = array();
$return_email_datas = array();
foreach ($emails_id_list as $email_data) {
$email = $email_data['email'];
if (!in_array($email, $unique_email_ids)) {
$return_email_datas[] = $email_data;
$unique_email_ids[] = $email;
}
}
return $return_email_datas;
}
function category_email_notification_send_notification($bcclist, $email, $handle, $subject, $body, $subs){
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
global $qa_notifications_suspended;
if ($qa_notifications_suspended > 0) return false;
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
$subs['^site_title'] = qa_opt('site_title');
$subs['^handle'] = $handle;
$subs['^email'] = $email;
$subs['^open'] = "\n";
$subs['^close'] = "\n";
return $this->category_email_send_email(array(
'fromemail' => qa_opt('from_email'),
'fromname' => qa_opt('site_title'),
'toemail' => $email,
'toname' => $handle,
'bcclist' => $bcclist,
'subject' => strtr($subject, $subs),
'body' => (empty($handle) ? '' : qa_lang_sub('emails/to_handle_prefix', $handle)) . strtr($body, $subs),
'html' => false,
));
}
function category_email_send_email($params) {
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->From = $params['fromemail'];
$mailer->Sender = $params['fromemail'];
$mailer->FromName = $params['fromname'];
if (isset($params['toemail'])) {
$mailer->AddAddress($params['toemail'], $params['toname']);
}
$mailer->Subject = $params['subject'];
$mailer->Body = $params['body'];
if (isset($params['bcclist'])) {
foreach ($params['bcclist'] as $email) {
$mailer->AddBCC($email);
}
}
if ($params['html']) $mailer->IsHTML(true);
if (qa_opt('smtp_active')) {
$mailer->IsSMTP();
$mailer->Host = qa_opt('smtp_address');
$mailer->Port = qa_opt('smtp_port');
if (qa_opt('smtp_secure')) $mailer->SMTPSecure = qa_opt('smtp_secure');
if (qa_opt('smtp_authenticate')) {
$mailer->SMTPAuth = true;
$mailer->Username = qa_opt('smtp_username');
$mailer->Password = qa_opt('smtp_password');
}
}
}
return $mailer->Send();
}
public function qa_get($param, $name = '') {
return isset($param[$name]) ? $param[$name] : '';
}
function admin_form(&$qa_content) {
if ($params['html'])
$mailer->IsHTML(true);
//add the functions
require_once EMAIL_NOTF_PLUGIN_DIR . '/functions.php';
// Process form input
if (qa_opt('smtp_active')) {
$mailer->IsSMTP();
$mailer->Host = qa_opt('smtp_address');
$mailer->Port = qa_opt('smtp_port');
$saved = false;
if (qa_opt('smtp_secure'))
$mailer->SMTPSecure = qa_opt('smtp_secure');
if (qa_clicked(SAVE_BUTTON)) {
$enable_plugin = !!qa_post_text(ENABLE_PLUGIN_FIELD);
qa_opt(ENABLE_PLUGIN, $enable_plugin);
if (!$enable_plugin) {
//if the plugin is disabled then turn off all features
reset_all_notification_options();
} else {
$response = set_all_notification_options();
//$error will be false if the
$error = (isset($response) && is_array($response) && !empty($response)) ? true : false;
}
if (qa_opt('smtp_authenticate')) {
$mailer->SMTPAuth = true;
$mailer->Username = qa_opt('smtp_username');
$mailer->Password = qa_opt('smtp_password');
if (isset($response) && isset($error) && !!$error) {
$err_enter_point_value = $this->qa_get($response, 'enter_point_value');
$err_no_options_selected = $this->qa_get($response, 'no_options_selected');
}
$saved = true;
}
} else {
}
return $mailer->Send();
}
public function qa_get($param , $name=''){
return isset($param[$name]) ? $param[$name] : '';
}
// Create the form for display
qa_set_display_rules($qa_content, array(
EAMIL_NOTF_DEBUG_MODE_OPT => ENABLE_PLUGIN_FIELD,
ALLOW_CAT_FOLLOWER_EMAILS_OPT => ENABLE_PLUGIN_FIELD,
ALLOW_TAG_FOLLOWER_EMAILS_OPT => ENABLE_PLUGIN_FIELD,
ALLOW_USER_FOLLOWER_EMAILS_OPT => ENABLE_PLUGIN_FIELD,
MINIMUM_USER_POINT_OPT => ENABLE_PLUGIN_FIELD,
MINIMUM_USER_POINT_VAL_OPT => ENABLE_PLUGIN_FIELD,
));
return array(
'ok' => ($saved && !$error ) ? 'Email Notification Settings Saved ' : null,
'fields' => array(
array(
'label' => qa_lang('notify/plugin-enable'),
'tags' => 'name="' . ENABLE_PLUGIN_FIELD . '" id="' . ENABLE_PLUGIN_FIELD . '"',
'value' => qa_opt(ENABLE_PLUGIN),
'type' => 'checkbox',
'error' => qa_html(@$err_no_options_selected),
),
array(
'id' => ALLOW_USER_FOLLOWER_EMAILS_OPT,
'label' => qa_lang('notify/user-follower-enable'),
'tags' => 'name="' . ALLOW_USER_FOLLOWER_EMAILS_FIELD . '" id="' . ALLOW_USER_FOLLOWER_EMAILS_FIELD . '"',
'value' => qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT),
'type' => 'checkbox',
),
array(
'id' => ALLOW_TAG_FOLLOWER_EMAILS_OPT,
'label' => qa_lang('notify/tag-follower-enable'),
'tags' => 'name="' . ALLOW_TAG_FOLLOWER_EMAILS_FIELD . '" id="' . ALLOW_TAG_FOLLOWER_EMAILS_FIELD . '"',
'value' => qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT),
'type' => 'checkbox',
),
array(
'id' => ALLOW_CAT_FOLLOWER_EMAILS_OPT,
'label' => qa_lang('notify/cat-follower-enable'),
'tags' => 'name="' . ALLOW_CAT_FOLLOWER_EMAILS_FIELD . '" id="' . ALLOW_CAT_FOLLOWER_EMAILS_FIELD . '"',
'value' => qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT),
'type' => 'checkbox',
),
array(
'id' => MINIMUM_USER_POINT_OPT,
'label' => qa_lang('notify/minimum-point-enable'),
'tags' => 'name="' . MINIMUM_USER_POINT_FIELD . '" id="' . MINIMUM_USER_POINT_FIELD . '"',
'value' => qa_opt(MINIMUM_USER_POINT_OPT),
'type' => 'checkbox',
),
array(
'id' => MINIMUM_USER_POINT_VAL_OPT,
'label' => qa_lang('notify/minimum-point-input-lable'),
'value' => qa_html(qa_opt(MINIMUM_USER_POINT_VAL_OPT)),
'tags' => 'name="' . MINIMUM_USER_POINT_VAL_FIELD . '" id="' . MINIMUM_USER_POINT_VAL_FIELD . '" ',
'error' => qa_html(@$err_enter_point_value),
),
),
'buttons' => array(
array(
'label' => qa_lang('notify/save-button'),
'tags' => 'name="' . SAVE_BUTTON . '"',
),
),
);
}
public function plugin_enabled_from_admin_panel() {
return ( (!!qa_opt(ENABLE_PLUGIN)) &&
(
(!!qa_opt(ALLOW_CAT_FOLLOWER_EMAILS_OPT)) ||
(!!qa_opt(ALLOW_TAG_FOLLOWER_EMAILS_OPT)) ||
(!!qa_opt(ALLOW_USER_FOLLOWER_EMAILS_OPT))
)
);
}
}
;
/*
Omit PHP closing tag to help avoid accidental output
*/
......@@ -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_phrases('language/qa-email-notification-lang-*.php', 'notify');
/*
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