Permalink
Browse files

Proposed improvements for actual initialization of default settings f…

…or forum subscription.
  • Loading branch information...
1 parent dd65d52 commit 5a4bf1195d10ae92a2f726e19839a84cfcdf9f6a @yannbug yannbug committed Aug 21, 2013
View
52 bp-activity-subscription-forum-notif-inits.php
@@ -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);
+}
+?>
View
7 bp-activity-subscription-main.php
@@ -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() {
View
10 bp-activity-subscription.php
@@ -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
*/
/**
@@ -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' );
View
4 readme.txt
@@ -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

1 comment on commit 5a4bf11

@yannbug
Celyan SAS member
Please sign in to comment.