Project

General

Profile

Bug #441 » 441.diff

Boone Gorges, 2010-12-07 05:00 PM

View differences:

wp-content/plugins/bp-custom.php
860 860
}
861 861
//add_action( 'admin_head', 'cac_convert_subscriptions' );
862 862

  
863
function cac_convert_subscriptions_2() {
864
	global $wpdb, $bp
865
	;
866
	// Get a list of all group ids
867
	$gs_sql = $wpdb->prepare( "SELECT DISTINCT id, name FROM {$bp->groups->table_name}" );
868
	$gs = $wpdb->get_results( $gs_sql );
869
	
870
	$c = 0;
871
	
872
	$already_handled = array();
873
	
874
	// We'll handle one group at a time
875
	foreach( $gs as $g ) {
876
		if ( in_array( $g->id, $already_handled ) )
877
			continue;
878
		
879
		
880
		$ms_sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %s", $g->id );
881
		$ms = $wpdb->get_results( $ms_sql );
882
		
883
		// Format the member list
884
		$member_ids = array();
885
		foreach( $ms as $m ) {
886
			$member_ids[] = $m->user_id;
887
		}
888
		
889
		// get the sub list
890
		$subs = groups_get_groupmeta( $g->id, 'ass_subscribed_users' );
891
		
892
		foreach( $subs as $mid => $status ) {
893
		
894
			if ( !in_array( $mid, $member_ids ) ) {
895
				echo '<br />' . '<br />' . $g->name . '<br />';
896
		
897
				echo 'User ' . $mid . ' is not in the group but is subscribed<br />';
898
				
899
				unset( $subs[$mid] );
900
			}
901
			
902
			groups_update_groupmeta( $g->id, 'ass_subscribed_users', $subs );
903
		}
904
		
905
		unset ( $ms );
906
		//print_r( $subs );
907
		
908
		//print_r( $member_ids );
909
		
910
	}
911

  
912

  
913
}
914
//add_action( 'admin_head', 'cac_convert_subscriptions_2' );
915

  
863 916
// Fixes http://redmine.gc.cuny.edu/issues/show/353
864 917
function cac_default_group_email_setting( $setting ) {
865 918
	return 'supersub';
    (1-1/1)