Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed improvements for actual initialization of default settings for ... #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions bp-activity-subscription-forum-notif-inits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Initializes forum notification options in the users settings->notifications page
* for all existing users upon plugin installation
* only add the following options if BP's bundled forums are installed...
*
* @see bp-activity-subscription-functions.php line 2014, function ass_group_subscription_notification_settings()
* called by bp-activity-subscription.php line 77 during plugin activation
*
* @return true if success, false if failure (not used)
*/
function ass_forum_notif_activation_init() {

require_once( WP_PLUGIN_DIR.'/buddypress-group-email-subscription/bp-activity-subscription-functions.php' );

// get forum type
$forums = ass_get_forum_type();

// no forums installed? stop now!
if ( ! $forums ) {
return false;
}

if ( $forums == 'buddypress' ) :

$all_existing_users = get_users( array( 'fields'=>'ID' ) );
//trigger_error( 'debug:' . serialize( $all_existing_users ) ); //debug YD

if( count( $all_existing_users ) > 1000 )
return false; //we risk performance issue, so just don't try

foreach( $all_existing_users as $user ) {
add_user_meta( $user, 'ass_replies_to_my_topic', 'yes', true);
add_user_meta( $user, 'ass_replies_after_me_topic', 'yes', true);
}

endif;
return true;
}

/**
* Initializes forum notification options in the users settings->notifications page
* for a newly registered user, after plugin has been installed
*
* called by the user_register hook
* @see bp-activity-subscription-main.php line 66 in the plugin's main class constructor function
*/
function ass_forum_notif_new_user_init( $user_id ) {
add_user_meta( $user_id, 'ass_replies_to_my_topic', 'yes', true);
add_user_meta( $user_id, 'ass_replies_after_me_topic', 'yes', true);
}
?>
7 changes: 7 additions & 0 deletions bp-activity-subscription-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ function group_activity_subscription() {
// hook in the css and js
add_action( 'wp_print_styles', array( &$this , 'add_settings_stylesheet' ) );
add_action( 'wp_enqueue_scripts', array( &$this , 'ass_add_javascript' ),1 );

// hook in the new user forum notification default settings initialization
$forums = ass_get_forum_type();
if( $forums == 'buddypress' ) {
require_once( WP_PLUGIN_DIR.'/buddypress-group-email-subscription/bp-activity-subscription-forum-notif-inits.php' );
add_action('user_register', 'ass_forum_notif_new_user_init');
}
}

public function add_settings_stylesheet() {
Expand Down
10 changes: 7 additions & 3 deletions bp-activity-subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Plugin Name: BuddyPress Group Email Subscription
Plugin URI: http://wordpress.org/extend/plugins/buddypress-group-email-subscription/
Description: Allows group members to receive email notifications for group activity and forum posts instantly or as daily digest or weekly summary.
Author: Deryk Wenaus, boonebgorges, r-a-y
Revision Date: July 24, 2013
Version: 3.4-alpha
Author: Deryk Wenaus, boonebgorges, r-a-y, ydubois
Revision Date: August 21, 2013
Version: 3.5-yd
*/

/**
Expand Down Expand Up @@ -71,6 +71,10 @@ function activitysub_setup_digest_defaults() {
require_once( WP_PLUGIN_DIR.'/buddypress-group-email-subscription/bp-activity-subscription-digest.php' );
ass_set_daily_digest_time( '05', '00' );
ass_set_weekly_digest_time( '4' );

/** forum default email notification settings initializations **/
require_once( WP_PLUGIN_DIR.'/buddypress-group-email-subscription/bp-activity-subscription-forum-notif-inits.php' );
ass_forum_notif_activation_init();
}
register_activation_hook( __FILE__, 'activitysub_setup_digest_defaults' );

Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ For bug reports or to add patches or translation files, please visit the [GES Gi

== Changelog ==

= 3.5 =
* Initializes forum subscription default settings of existing users upon plugin installation
* Initializes forum subscription default settings of new registered users after plugin installation

= 3.4 =
* Reinstate bbPress "Subscribe" option in forum threads for group members not subscribed to "All Mail"
* Performance improvements in daily and weekly digests
Expand Down