PluginProbe
Private groups / 2.5
Private groups v2.5
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 / settings.php

settings.php in Private groups 2.5, at includes/settings.php

436 lines 17.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //new file
4
5 function rpg_settings_page()
6 {
7 global $rpg_settingsf ;
8 global $rpg_settingsg ;
9 global $rpg_groups;
10 global $rpg_group_last ;
11 global $rpg_roles ;
12
13
14 ?>
15 <div class="wrap">
16 <div id="upb-wrap" class="upb-help">
17 <h2><?php _e('Private Group Settings', 'bbp-private-groups'); ?></h2>
18 <?php
19 if ( ! isset( $_REQUEST['updated'] ) )
20 $_REQUEST['updated'] = false;
21 ?>
22 <?php if ( false !== $_REQUEST['updated'] ) : ?>
23 <div class="updated fade"><p><strong><?php _e( 'Group saved', 'bbp-private-groups'); ?> ); ?></strong></p></div>
24 <?php endif; ?>
25
26 <?php //tests if we have selected a tab ?>
27 <?php
28 if( isset( $_GET[ 'tab' ] ) ) {
29 if ($active_tab == 'user_management') pg_user_management($tab) ;
30 $active_tab = $_GET[ 'tab' ];}
31 else {$active_tab= 'forum_visibility_settings';
32 } // end if
33 ?>
34
35 <?php // sets up the tabs ?>
36 <h2 class="nav-tab-wrapper">
37
38 <a href="?page=bbp-private-group-settings&tab=forum_visibility_settings" class="nav-tab <?php echo $active_tab == 'forum_visibility_settings' ? 'nav-tab-active' : ''; ?>"><?php _e('Forum Visibility settings' , 'bbp-private-groups' ) ; ?></a>
39 <a href="?page=bbp-private-group-settings&tab=general_settings" class="nav-tab <?php echo $active_tab == 'general_settings' ? 'nav-tab-active' : ''; ?>"><?php _e('General Settings' , 'bbp-private-groups' ) ; ?></a>
40 <a href="?page=bbp-private-group-settings&tab=group_name_settings" class="nav-tab <?php echo $active_tab == 'group_name_settings' ? 'nav-tab-active' : ''; ?>"><?php _e('Group Name Settings' , 'bbp-private-groups' ) ; ?></a>
41 <a href="?page=bbp-private-group-settings&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>"><?php _e('Help' , 'bbp-private-groups' ) ; ?></a>
42 <a href="?page=bbp-private-group-settings&tab=management_information" class="nav-tab <?php echo $active_tab == 'Management_information' ? 'nav-tab-active' : ''; ?>"><?php _e('Management Information' , 'bbp-private-groups' ) ; ?></a>
43 <a href="?page=bbp-private-group-settings&tab=user_management" class="nav-tab <?php echo $active_tab == 'user_management' ? 'nav-tab-active' : ''; ?>"><?php _e('User Management' , 'bbp-private-groups' ) ; ?></a>
44 <a href="?page=bbp-private-group-settings&tab=role_assignment" class="nav-tab <?php echo $active_tab == 'role_assignment' ? 'nav-tab-active' : ''; ?>"><?php _e('Assign groups to roles' , 'bbp-private-groups' ) ; ?></a></h2>
45 <table class="form-table">
46 <tr>
47
48 <td>
49 <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
50 <input type="hidden" name="cmd" value="_s-xclick">
51 <input type="hidden" name="hosted_button_id" value="S6PZGWPG3HLEA">
52 <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
53 <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
54 </form>
55 </td><td>
56 <?php _e("If you find this plugin useful, please consider donating just a couple of dollars to help me develop and maintain it. You support will be appreciated", 'bbp-private-groups'); ?>
57
58
59 </td>
60 </tr>
61 </table>
62
63 <?php //************************* Forum Visibility settings *************************// ?>
64
65 <?php if( $active_tab == 'forum_visibility_settings' ) { ?>
66 <form method="post" action="options.php">
67
68 <?php settings_fields( 'rpg_forum_settings' ); ?>
69
70 <table class="form-table">
71
72 <!-------------------------------Forum visibility ---------------------------------------->
73
74 <tr valign="top">
75 <th><h3><?php _e('Forum Visibility', 'bbp-private-groups'); ?></h3></th>
76 <td><p><?php _e('By default only users with access to a forum will see the forum titles in the indexes. However you may want everyone to see that a forum exists (ie see the title) but not be able to access topics and replies within this. In this case, set the forum visibility below. If you want only logged in users to see these forums exist, then also set the forum to private within the dashboard>forums settings', 'bbp-private-groups') ?> <b> <?php _e ('See help tab for more information' , 'bbp-private-groups') ; ?></b></p></td>
77 </tr>
78
79 <!-- checkbox to activate -->
80 <tr valign="top">
81 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
82 <td>
83 <?php activate_forum_visibility_checkbox() ;?>
84 </td>
85 </tr>
86
87 <!-------------------------------Redirect Pages ---------------------------------------->
88
89 <tr valign="top">
90 <th><h3><?php _e('Redirect Pages', 'bbp-private-groups'); ?></h3></th>
91 <td><p><?php _e('<b>If you have activated forum visibility above</b>, then users without access will see forums headings and descriptions. When they click these forum titles, they need to be sent somewhere, if only to say that they do not have access. However this is an excellent opportunity to "sign them up" so you can send them to say a register or buy access page. ', 'bbp-private-groups'); ?></p></td>
92 </tr>
93
94 <tr valign="top">
95 <th><?php _e('URL of redirect page for LOGGED-IN user', 'bbp-private-groups'); ?></th>
96 <td>
97 <input id="rpg_settingsf[redirect_page1]" class="large-text" name="rpg_settingsf[redirect_page1]" type="text" value="<?php echo isset( $rpg_settingsf['redirect_page1'] ) ? esc_html( $rpg_settingsf['redirect_page1'] ) : '';?>" /><br/>
98 <label class="description" for="rpg_settingsf[redirect_page]"><?php _e( 'Enter the full url (permalink) of the page to redirect users without access to eg http://www.mysite.com/sign-up. If you leave this blank, users will see your sites "404 not-found" page', 'bbp-private-groups' ); ?></label><br/>
99 </td>
100 </tr>
101
102 <tr valign="top">
103 <th><?php _e('URL of redirect page for NON-LOGGED-IN', 'bbp-private-groups'); ?></th>
104 <td>
105 <input id="rpg_settingsf[redirect_page2]" class="large-text" name="rpg_settingsf[redirect_page2]" type="text" value="<?php echo isset( $rpg_settingsf['redirect_page2'] ) ? esc_html( $rpg_settingsf['redirect_page2'] ) : '';?>" /><br/>
106 <label class="description" for="rpg_settingsf[redirect_page]"><?php _e( 'Enter the full url (permalink) of the page to redirect users without access to eg http://www.mysite.com/sign-up. This can be the same as the LOGGED-IN page, just giving the opportunity to have different pages if you want them ! If you leave this blank, users will be sent to the Wordpress login page', 'bbp-private-groups' ); ?></label><br/>
107 </td>
108 </tr>
109
110 <!-------------------------------Freshness settings ---------------------------------------->
111
112 <tr valign="top">
113 <th><?php _e('Freshness Settings', 'bbp-private-groups'); ?></th>
114 <td><p><?php _e('<b>If you have activated forum visibility above</b>, for private group forums, when user does not have access, you can either show a message in freshness column, or leave it as the default time since last post. In both cases for users without access they will be taken to the redirect page above. ', 'bbp-private-groups'); ?></p></td>
115 </tr>
116
117 <!-- checkbox to activate -->
118 <tr valign="top">
119 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
120 <td>
121 <?php freshness_checkbox() ;?>
122 </td>
123 </tr>
124
125 <tr valign="top">
126 <th><?php _e('Freshness Message', 'bbp-private-groups'); ?></th>
127 <td>
128 <input id="rpg_settingsf[freshness_message]" class="large-text" name="rpg_settingsf[freshness_message]" type="text" value="<?php echo isset( $rpg_settingsf['freshness_message'] ) ? esc_html( $rpg_settingsf['freshness_message'] ) : '';?>" /><br/>
129 <label class="description" for="rpg_settingsf[redirect_page]"><?php _e( 'Enter the message to be shown e.g. Click here to sign up', 'bbp-private-groups' ); ?></label><br/>
130 </td>
131 </tr>
132
133 </table>
134
135 <!-- save the options -->
136 <p class="submit">
137 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bbp-private-groups' ); ?>" />
138 </p>
139
140 </form>
141 </div><!--end sf-wrap-->
142 </div><!--end wrap-->
143
144 <?php
145 }
146 ?>
147
148 <?php //************************* General settings *************************// ?>
149
150 <?php if( $active_tab == 'general_settings' ) { ?>
151 <form method="post" action="options.php">
152
153 <?php settings_fields( 'rpg_general_settings' ); ?>
154
155 <table class="form-table">
156 <!------------------------------- Hide topic/reply counts ------------------------------------------>
157 <tr valign="top">
158 <th colspan="2"><h3><?php _e('Hide topic and reply counts', 'bbp-private-groups'); ?></h3></th>
159 </tr>
160
161 <!-- checkbox to activate -->
162 <tr valign="top">
163 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
164 <td>
165 <?php activate_hide_counts_checkbox() ;?>
166 </td>
167 </tr>
168
169 <!------------------------------- Descriptions ------------------------------------------>
170 <tr valign="top">
171 <th colspan="2"><h3><?php _e('Show Descriptions', 'bbp-private-groups'); ?></h3></th>
172 </tr>
173
174 <!-- checkbox to activate -->
175 <tr valign="top">
176 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
177 <td>
178 <?php activate_descriptions_checkbox() ;?>
179 </td>
180 </tr>
181
182 <!------------------------------- Remove 'Private' prefix ------------------------------------------>
183 <tr valign="top">
184 <th colspan="2"><h3><?php _e("Remove 'Private' prefix", 'bbp-private-groups'); ?></h3></th>
185 </tr>
186
187 <!-- checkbox to activate -->
188 <tr valign="top">
189 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
190 <td>
191 <?php activate_private_prefix_checkbox() ;?>
192 </td>
193 </tr>
194 <tr valign="top">
195 <td></td><td><?php _e('By default bbPress shows the prefix "Private" before each private forum. Activate this checkbox to remove this prefix.', 'bbp-private-groups'); ?></td>
196 </tr>
197
198 </table>
199
200 <!-- save the options -->
201 <p class="submit">
202 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bbp-private-groups' ); ?>" />
203 </p>
204
205 </form>
206 </div><!--end sf-wrap-->
207 </div><!--end wrap-->
208
209 <?php
210 }
211 ?>
212
213
214
215
216 <?php //************************* Group name settings *************************// ?>
217 <?php if( $active_tab == 'group_name_settings' ) { ?>
218 <form method="post" action="options.php">
219
220 <?php settings_fields( 'rpg_group_settings' ); ?>
221
222 <table class="form-table">
223
224 <tr valign="top">
225 <th colspan="2"><p>
226 <?php _e('This section allows you to set up groups. Enter a Description for each group eg gamers, teachers, group1 etc.' , 'bbp-private-groups' ) ; ?></p></th>
227 </tr>
228 <?php
229 $count=count ($rpg_groups) ;
230 if ($count==1) $count=2 ;
231 for ($i = 0 ; $i < $count ; ++$i) {
232 $g=$i+1 ;
233 $display=__( 'Group', 'bbp-private-groups' ).$g ;
234 $name="group".$g ;
235 $item="rpg_groups[".$name."]" ;
236 ?>
237 <!------------------------- Group --------------------------------------------->
238 <tr valign="top">
239 <th><?php echo $display ?></th>
240 <td>
241 <?php echo '<input id="'.$item.'" class="large-text" name="'.$item.'" type="text" value="'.esc_html( $rpg_groups[$name] ).'"<br>' ;
242 ?>
243 </td>
244 </tr>
245 <?php }
246
247 ?>
248 <!-- checkbox to activate new group -->
249 <tr valign="top">
250 <th><?php _e('Add new group', 'bbp-private-groups'); ?></th>
251 <td>
252 <?php activate_new_group() ;?>
253
254 </td>
255 </tr>
256
257
258 </table>
259 <!-- save the options -->
260 <p class="submit">
261 <input type="submit" class="button-primary" value="<?php _e( 'Save Groups', 'bbp-private-groups' ); ?>" />
262 </p>
263 </form>
264 </div><!--end sf-wrap-->
265 </div><!--end wrap-->
266
267 <?php
268 }
269 ?>
270
271
272 <?php //************************* Management Info *************************// ?>
273 <?php if( $active_tab == 'management_information' ) {
274 ?>
275
276 <?php settings_fields( 'rpg_group_settings' ); ?>
277
278 <table class="form-table">
279
280 <tr valign="top">
281
282 </tr>
283 <?php
284 $count=count ($rpg_groups) ;
285 for ($i = 0 ; $i < $count ; ++$i) {
286 $g=$i+1 ;
287 $display=__( 'Group', 'bbp-private-groups' ).$g ;
288 $name="group".$g ;
289 $item="rpg_groups[".$name."]" ;
290 ?>
291 <!------------------------- Group --------------------------------------------->
292 <tr valign="top">
293 <th><?php echo $display ?></th>
294 <td>
295 <?php _e('Group name :', 'bbp-private-groups') ; ?>
296 <?php echo esc_html( $rpg_groups[$name] ).'<br>' ; ?>
297 <?php _e('No. users in this group : ' , 'bbp-private-groups') ; ?>
298 <?php
299 global $wpdb;
300 $users=$wpdb->get_col("select ID from $wpdb->users") ;
301 $countu=0 ;
302 foreach ($users as $user) {
303
304 $check= get_user_meta( $user, 'private_group',true);
305 //single user check
306 if ($check==$name) $countu++ ;
307 //multiple group set
308 if (strpos($check, '*'.$name.'*') !== FALSE) $countu++;
309 }
310 echo $countu ;
311 ?>
312
313
314 <br><?php _e('Forums in this group :' , 'bbp-private-groups') ; ?>
315 <?php global $wpdb;
316 $forum = bbp_get_forum_post_type() ;
317 $forums=$wpdb->get_col("select ID from $wpdb->posts where post_type='$forum'") ;
318 $countu=0 ;
319 echo '<ul><i>' ;
320 foreach ($forums as $forum) {
321 $meta = (array)get_post_meta( $forum, '_private_group', false );
322 foreach ($meta as $meta2) {
323 if ($meta2==$name) {
324 $ftitle=bbp_forum_title($forum) ;
325 echo '<li>'.$ftitle.'</li>' ;
326 $countu++ ;
327 }
328 }
329
330 }
331 echo '</ul></i>' ;
332
333 _e('No. forums that have this group set : ', 'bbp-private-groups' ) ;
334 echo $countu ;
335 ?>
336 </td></tr>
337 <?php }
338
339 ?>
340
341 </table>
342
343 </form>
344 </div><!--end sf-wrap-->
345 </div><!--end wrap-->
346
347 <?php
348 }
349 ?>
350
351 <?php
352 //**** user management
353 if ($active_tab == 'user_management' ) {
354 $group = 'all' ;
355 pg_user_management($group) ;
356 }
357 ?>
358
359 <?php
360 //**** Help
361 if ($active_tab == 'help' ) {
362 pg_help();
363 }
364 ?>
365
366 <?php
367 //**** role assignment
368 if ($active_tab == 'role_assignment' ) {
369 pg_role_assignment() ;
370 }
371 //end of tab function
372 }
373
374
375
376
377
378
379
380 // register the plugin settings
381 function rpg_register_settings() {
382
383 register_setting( 'rpg_forum_settings', 'rpg_settingsf' );
384 register_setting( 'rpg_general_settings', 'rpg_settingsg' );
385 register_setting( 'rpg_group_settings', 'rpg_groups' );
386 register_setting( 'rpg_roles_settings', 'rpg_roles' );
387 }
388 //call register settings function
389 add_action( 'admin_init', 'rpg_register_settings' );
390
391 function rpg_settings_menu() {
392
393 // add settings page
394 add_submenu_page('options-general.php', __('bbp Private Groups', 'bbp-private-groups'), __('bbp Private Groups', 'bbp-private-groups'), 'manage_options', 'bbp-private-group-settings', 'rpg_settings_page');
395 }
396 add_action('admin_menu', 'rpg_settings_menu');
397
398 /***************************** Checkbox functions **************************/
399 function activate_forum_visibility_checkbox() {
400 global $rpg_settingsf ;
401 $item5 = $rpg_settingsf['set_forum_visibility'] ;
402 echo '<input name="rpg_settingsf[set_forum_visibility]" id="rpg_settingsf[set_forum_visibility]" type="checkbox" value="1" class="code" ' . checked( 1,$item5, false ) . ' />' ;
403 _e ('Click to activate forum visibility' , 'bbp-private-groups') ;
404 }
405 function freshness_checkbox() {
406 global $rpg_settingsf ;
407 $item4 = $rpg_settingsf['set_freshness_message'] ;
408 echo '<input name="rpg_settingsf[set_freshness_message]" id="rpg_settingsf[set_freshness_message]" type="checkbox" value="1" class="code" ' . checked( 1,$item4, false ) . ' />' ;
409 _e ('Click to activate a freshness message', 'bbp-private-groups' );
410 }
411
412 function activate_hide_counts_checkbox() {
413 global $rpg_settingsg ;
414 $item1 = $rpg_settingsg['hide_counts'] ;
415 echo '<input name="rpg_settingsg[hide_counts]" id="rpg_settingsg[hide_counts]" type="checkbox" value="1" class="code" ' . checked( 1,$item1, false ) . ' />' ;
416 _e ('Hide topic and reply counts', 'bbp-private-groups' );
417 }
418 function activate_descriptions_checkbox() {
419 global $rpg_settingsg ;
420 $item2 = $rpg_settingsg['activate_descriptions'] ;
421 echo '<input name="rpg_settingsg[activate_descriptions]" id="rpg_settingsg[activate_descriptions]" type="checkbox" value="1" class="code" ' . checked( 1,$item2, false ) . ' />' ;
422 _e ('Show forum content (Descriptions) on main index' , 'bbp-private-groups' );
423 }
424 function activate_private_prefix_checkbox() {
425 global $rpg_settingsg ;
426 $item3 = $rpg_settingsg['activate_remove_private_prefix'] ;
427 echo '<input name="rpg_settingsg[activate_remove_private_prefix]" id="rpg_settingsg[activate_remove_private_prefix]" type="checkbox" value="1" class="code" ' . checked( 1,$item3, false ) . ' />' ;
428 _e ('Remove Private prefix' , 'bbp-private-groups' );
429 }
430 function activate_new_group() {
431 global $rpg_groups ;
432 $item6 = $rpg_groups['activate_new_group'] ;
433 echo '<input name="rpg_groups[activate_new_group]" id="rpg_groups[activate_new_group]" type="checkbox" value="1" class="code" />' ;
434 _e ('Click and then press "save groups" to add a new group' , 'bbp-private-groups' ) ;
435 }
436