PluginProbe
Private groups / trunk
Private groups vtrunk
trunk 1.5 1.6 1.7 1.8 1.8.1 1.9.1 1.9.2 2.0 2.0.1 2.2 2.3 2.4 2.5 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 116 releases
bbp-private-groups / includes / disable_groups.php

disable_groups.php in Private groups trunk, at includes/disable_groups.php

135 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //************************* Disable Groups *************************//
4
5 Function rpg_disable_groups() {
6 global $rpg_groups ;
7 global $rpg_disable_groups ;
8
9 ?>
10 <form method="post" action="options.php">
11 <?php wp_nonce_field( 'disable_groups', 'disable-nonce' ) ?>
12 <?php settings_fields( 'rpg_disable_groups' ); ?>
13 <p>
14 <?php _e('This plugin does not allow for the deletion of groups - sorry, but that is just the way it was written.' , 'bbp-private-groups' ) ; ?>
15 </p>
16 <p>
17 <?php _e('However this section allows you to disable groups <b> which have no forums or users associated with them </b>.' , 'bbp-private-groups' ) ; ?>
18 </p>
19 <p>
20 <?php _e('Tick a group, and this group will not be visible. Untick a group and you can make it visible and re-use that group.' , 'bbp-private-groups' ) ; ?>
21 </p>
22
23 <?php
24
25 //only display if no forums or users are associated with it.
26
27 //start with a list of groups and set them to false
28 $count=count ($rpg_groups) ;
29 for ($i = 0 ; $i < $count ; ++$i) {
30 $g=$i+1 ;
31 $name="group".$g ;
32 //set $check for the group number = false, so we can safely disbale if still false at the end
33 $check[$name] = false ;
34
35 }
36
37 //now go through the users to create a list of groups that are active
38 $users = get_users(array('meta_key' => 'private_group','compare' => 'EXISTS')) ;
39 if ( $users ) :
40 foreach ( $users as $user ) :
41 $private_group = get_user_meta($user->ID, 'private_group', true);
42 if (!empty ($private_group)) {
43 //if multiple groups
44 if (strpos($private_group, '*')!== FALSE) {
45 foreach ( $rpg_groups as $group => $details ) {
46 if (strpos($private_group, '*'.$group.'*') !== FALSE) {
47 $check[$group] = true ;
48 }
49 }
50 }
51 //if only one group
52 else {
53 $check[$private_group] = true ;
54 }
55 }
56 endforeach ;
57 endif ;
58
59
60 //now go through forums
61 global $wpdb;
62 $forum=bbp_get_forum_post_type() ;
63 $forums =$wpdb->get_col("select ID from $wpdb->posts where post_type = '$forum'") ;
64
65 update_option ('rew' , $forums ) ;
66 foreach ( $forums as $forum ) :
67 //cycle through each forum
68 $meta = (array)get_post_meta( $forum, '_private_group', false );
69 if (!empty ($meta)) {
70 foreach ($meta as $group ) :
71 //set check = true for each group set in this forum
72 $check[$group] = true ;
73 endforeach ;
74 }
75 endforeach ;
76
77
78 ?>
79 <table class="form-table">
80 <?php
81 $count=count ($rpg_groups) ;
82 for ($i = 0 ; $i < $count ; ++$i) {
83 $g=$i+1 ;
84 $name="group".$g ;
85 //only display if false
86 if ($check[$name] == false) {
87
88
89 $display=__( 'Group', 'bbp-private-groups' ).$g ;
90 $groupname=__('Group','bbp-private-groups').substr($name,5,strlen($name)) ;
91 $groupdisplay = $rpg_groups[$name] ;
92
93 $item="rpg_groups[".$name."]" ;
94 $value = (!empty ($rpg_groups[$name]) ? $rpg_groups[$name] : '' ) ;
95 ?>
96 <!------------------------- Group --------------------------------------------->
97 <tr valign="top">
98 <td>
99 <?php echo $groupname.' '.$groupdisplay ; ?>
100
101 </td>
102 <td>
103 <?php
104 $item1="rpg_disable_groups[".$name."]" ;
105 $item2 = (!empty( $rpg_disable_groups[$name] ) ? $rpg_disable_groups[$name] : '');
106 echo '<input name="'.$item1.'" id="'.$item1.'" type="checkbox" value="1" class="code" ' . checked( 1,$item2, false ) . ' />';
107 _e ('Disable this Group' , 'bbp-private-groups' );
108 ?>
109 </td>
110 <td>
111 </td>
112 </tr>
113 <?php
114 }
115
116
117
118 }
119
120 ?>
121
122 </table>
123 <!-- save the options -->
124 <p class="submit">
125 <input type="submit" class="button-primary" value="<?php _e( 'Save Groups', 'bbp-private-groups' ); ?>" />
126 </p>
127 </form>
128
129
130 </div><!--end sf-wrap-->
131 </div><!--end wrap-->
132
133 <?php
134 }
135 ?>