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 / settings.php

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

457 lines 21.2 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 ( !empty($active_tab) && $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 <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>
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=topic_permissions" class="nav-tab <?php echo $active_tab == 'topic_permissions' ? 'nav-tab-active' : ''; ?>"><?php _e('Topic Permissions' , 'bbp-private-groups' ) ; ?></a>
40 <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>
41 <a href="?page=bbp-private-group-settings&tab=disable_groups" class="nav-tab <?php echo $active_tab == 'disable_groups' ? 'nav-tab-active' : ''; ?>"><?php _e('Disable Groups' , 'bbp-private-groups' ) ; ?></a>
42 <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>
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=widget_warning" class="nav-tab <?php echo $active_tab == 'widget_warning' ? 'nav-tab-active' : ''; ?>"><?php _e('Widget Warning !' , 'bbp-private-groups' ) ; ?></a>
45 <a href="?page=bbp-private-group-settings&tab=shortcode_warning" class="nav-tab <?php echo $active_tab == 'shortcode_warning' ? 'nav-tab-active' : ''; ?>"><?php _e('Shortcode Warning !' , 'bbp-private-groups' ) ; ?></a>
46 <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>
47 <a href="?page=bbp-private-group-settings&tab=plugin-info" class="nav-tab <?php echo $active_tab == 'plugin-info' ? 'nav-tab-active' : ''; ?>"><?php _e('Plugin Information' , 'bbp-private-groups' ) ; ?></a>
48 <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>
49 <a href="?page=bbp-private-group-settings&tab=programmershelp" class="nav-tab <?php echo $active_tab == 'programmershelp' ? 'nav-tab-active' : ''; ?>"><?php _e('Programmers Help' , 'bbp-private-groups' ) ; ?></a></h2>
50
51 <?php
52 if (class_exists('bbPress_Notify_noSpam') && !class_exists('bbpnns_private_groups_bridge'))
53 echo '<h1>WARNING !!! You have bbPress Notify (No Spam) active. This plugin will send <b>all</b> topics and replies to users as set and private groups does not filter these.<br>
54 Either <br> 1. Ensure that you understand this before using (maybe only use for those allowed to see everything eg admins)
55 or <br> 2. add <a href="https://usestrict.net/product/bbpress-notify-no-spam-private-groups-bridge/" target="_new">bbpnns_private_groups_bridge</a> to get the add-on so that bbpnns and private groups work together.</h1>' ;
56 ?>
57
58 <?php
59 if (function_exists('notify_new_topic') )
60 echo '<h1>WARNING !!! You have an old plugin bbPress Notify active. It is strongly recommended that you use <a href="https://en-gb.wordpress.org/plugins/bbpress-notify-nospam/" target="_new">bbPress Notify (No Spam)</a> instead which is supported.
61 <br>HOWEVER Both plugins will send <b>all</b> topics and replies to users as set and private groups does not filter these.<br>
62 Either <br> 1. Ensure that you understand this before using (maybe only use for those allowed to see everything eg admins)
63 or <br> 2. add <a href="https://usestrict.net/product/bbpress-notify-no-spam-private-groups-bridge/" target="_new">bbpnns_private_groups_bridge\</a> as well as <a href="https://en-gb.wordpress.org/plugins/bbpress-notify-nospam/" target="_new">bbPress Notify (No Spam)</a> to get the add-on so that bbpnns and private groups work together.</h1>' ;
64
65 ?>
66
67
68
69
70 <table class="form-table">
71 <tr>
72 <td>
73 <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
74 <input type="hidden" name="cmd" value="_s-xclick" />
75 <input type="hidden" name="hosted_button_id" value="GEMT7XS7C8PS4" />
76 <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
77 <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1" />
78 </form>
79 </td>
80 <td>
81 <?php _e('If you find this plugin useful, please consider donating just a few dollars to help me develop and maintain it. You support will be appreciated', 'bbp-style-pack'); ?>
82 </td>
83
84 </tr>
85 </table>
86
87 <?php //************************* Forum Visibility settings *************************// ?>
88
89 <?php if( $active_tab == 'forum_visibility_settings' ) { ?>
90 <form method="post" action="options.php">
91
92 <?php settings_fields( 'rpg_forum_settings' ); ?>
93
94 <table class="form-table">
95
96 <!-------------------------------Forum visibility ---------------------------------------->
97
98 <tr valign="top">
99 <th><h3><?php _e('Forum Visibility', 'bbp-private-groups'); ?></h3></th>
100 <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>
101 </tr>
102
103 <!-- checkbox to activate -->
104 <tr valign="top">
105 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
106 <td>
107 <?php activate_forum_visibility_checkbox() ;?>
108 </td>
109 </tr>
110
111 <!-------------------------------Redirect Pages ---------------------------------------->
112
113 <tr valign="top">
114 <th><h3><?php _e('Redirect Pages', 'bbp-private-groups'); ?></h3></th>
115 <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>
116 </tr>
117
118 <tr valign="top">
119 <th><?php _e('URL of redirect page for LOGGED-IN user', 'bbp-private-groups'); ?></th>
120 <td>
121 <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/>
122 <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/>
123 </td>
124 </tr>
125
126 <tr valign="top">
127 <th><?php _e('URL of redirect page for NON-LOGGED-IN', 'bbp-private-groups'); ?></th>
128 <td>
129 <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/>
130 <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/>
131 </td>
132 </tr>
133
134 <!-------------------------------Freshness settings ---------------------------------------->
135
136 <tr valign="top">
137 <th><?php _e('Freshness Settings', 'bbp-private-groups'); ?></th>
138 <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>
139 </tr>
140
141 <!-- checkbox to activate -->
142 <tr valign="top">
143 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
144 <td>
145 <?php freshness_checkbox() ;?>
146 </td>
147 </tr>
148
149 <tr valign="top">
150 <th><?php _e('Freshness Message', 'bbp-private-groups'); ?></th>
151 <td>
152 <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/>
153 <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/>
154 </td>
155 </tr>
156
157 </table>
158
159 <!-- save the options -->
160 <p class="submit">
161 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bbp-private-groups' ); ?>" />
162 </p>
163
164 </form>
165 </div><!--end sf-wrap-->
166 </div><!--end wrap-->
167
168 <?php
169 }
170 ?>
171
172 <?php //************************* General settings *************************// ?>
173
174 <?php if( $active_tab == 'general_settings' ) { ?>
175 <form method="post" action="options.php">
176
177 <?php settings_fields( 'rpg_general_settings' ); ?>
178
179 <table class="form-table">
180
181
182 <!------------------------------- Hide topic/reply counts ------------------------------------------>
183 <tr valign="top">
184 <th colspan="2"><h3><?php _e('Hide topic and reply counts', 'bbp-private-groups'); ?></h3></th>
185 </tr>
186 <!-- checkbox to activate -->
187 <tr valign="top">
188 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
189 <td>
190 <?php activate_hide_counts_checkbox() ;?>
191 </td>
192 </tr>
193 <!------------------------------- List Sub-forums as columns ------------------------------------------>
194 <tr valign="top">
195 <th colspan="2"><h3><?php _e('List Sub-forums in Columns', 'bbp-private-groups'); ?></h3></th>
196 </tr>
197
198 <!-- checkbox to activate -->
199 <tr valign="top">
200 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
201 <td>
202 <?php activate_sub_forums_checkbox() ;?>
203 </td>
204 </tr>
205
206 <!------------------------------- Descriptions ------------------------------------------>
207 <tr valign="top">
208 <th colspan="2"><h3><?php _e('Show Descriptions', 'bbp-private-groups'); ?></h3></th>
209 </tr>
210
211 <!-- checkbox to activate -->
212 <tr valign="top">
213 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
214 <td>
215 <?php activate_descriptions_checkbox() ;?>
216 </td>
217 </tr>
218
219 <!------------------------------- Remove 'Private' prefix ------------------------------------------>
220 <tr valign="top">
221 <th colspan="2"><h3><?php _e("Remove 'Private' prefix", 'bbp-private-groups'); ?></h3></th>
222 </tr>
223
224 <!-- checkbox to activate -->
225 <tr valign="top">
226 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
227 <td>
228 <?php activate_private_prefix_checkbox() ;?>
229 </td>
230 </tr>
231 <tr valign="top">
232 <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>
233 </tr>
234
235 </table>
236
237 <!-- save the options -->
238 <p class="submit">
239 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bbp-private-groups' ); ?>" />
240 </p>
241
242 </form>
243 </div><!--end sf-wrap-->
244 </div><!--end wrap-->
245
246 <?php
247 }
248 ?>
249
250
251
252
253 <?php //************************* Group name settings *************************// ?>
254 <?php if( $active_tab == 'group_name_settings' ) { ?>
255 <form method="post" action="options.php">
256 <?php global $rpg_disable_groups ;?>
257 <?php settings_fields( 'rpg_group_settings' ); ?>
258
259 <table class="form-table">
260
261 <tr valign="top">
262 <th colspan="3">
263 <p>
264 <?php _e('This section allows you to set up groups. Enter a Description for each group eg gamers, teachers, group1 etc.' , 'bbp-private-groups' ) ; ?>
265 </p>
266 </th>
267 </tr>
268 <?php
269 if (!empty ($rpg_groups)) $count=count ($rpg_groups) ;
270 else $count = 1 ;
271 //a new group is added if $rpg_groups['activate_new_group'] is set, as this becomes part of the count, so it looks like we have an extra group in the count
272 if ($count==1) $count=2 ;
273 for ($i = 0 ; $i < $count ; ++$i) {
274 $g=$i+1 ;
275 $display=__( 'Group', 'bbp-private-groups' ).$g ;
276 $name="group".$g ;
277 $item="rpg_groups[".$name."]" ;
278 $value = (!empty ($rpg_groups[$name]) ? $rpg_groups[$name] : '' ) ;
279 ?>
280 <!------------------------- Group --------------------------------------------->
281 <tr valign="top">
282 <th>
283 <?php echo $display ?>
284 </th>
285
286 <td>
287 <?php echo '<input id="'.$item.'" class="medium-text" name="'.$item.'" type="text" value="'.esc_html( $value ).'"<br>' ; ?>
288
289 <?php
290 if (!empty ($rpg_disable_groups[$name] ) ) {
291 _e('This group is disabled - to re-enable use the \'Disable Groups\' tab', 'bbp-private-groups' ) ;
292 }
293
294 ?>
295 </td>
296 </tr>
297 <?php
298 }
299
300 ?>
301 <!-- checkbox to activate new group -->
302 <tr valign="top">
303 <th>
304 <?php _e('Add new group', 'bbp-private-groups'); ?>
305 </th>
306
307 <td>
308 <?php activate_new_group() ;?>
309
310 </td>
311 </tr>
312
313
314 </table>
315 <!-- save the options -->
316 <p class="submit">
317 <input type="submit" class="button-primary" value="<?php _e( 'Save Groups', 'bbp-private-groups' ); ?>" />
318 </p>
319 </form>
320 </div><!--end sf-wrap-->
321 </div><!--end wrap-->
322
323 <?php
324 }
325
326
327
328
329 //**** management info
330 if( $active_tab == 'management_information' ) {
331 management_info () ;
332
333
334 }
335 //**** user management
336 if ($active_tab == 'user_management' ) {
337 $group = 'all' ;
338 pg_user_management($group) ;
339 }
340
341 //**** Help
342 if ($active_tab == 'help' ) {
343 pg_help();
344 }
345
346 //**** Plugin Info
347 if ($active_tab == 'plugin-info' ) {
348 pg_plugin_info();
349 }
350
351 //**** role assignment
352 if ($active_tab == 'role_assignment' ) {
353 pg_role_assignment() ;
354 }
355
356 //**** disable Groups
357 if ($active_tab == 'disable_groups' ) {
358 rpg_disable_groups() ;
359 }
360
361
362 //**** widget warning
363 if ($active_tab == 'widget_warning' ) {
364 pg_widget_warning() ;
365 }
366
367 //**** shortcode warning
368 if ($active_tab == 'shortcode_warning' ) {
369 pg_shortcode_warning() ;
370 }
371
372 //**** topic permissions
373 if ($active_tab == 'topic_permissions' ) {
374 rpg_topic_permissions() ;
375 }
376
377 //**** topic permissions
378 if ($active_tab == 'programmershelp' ) {
379 rpg_programmers_help() ;
380 }
381
382 //end of tab function
383 }
384
385
386 // register the plugin settings
387 function rpg_register_settings() {
388
389 register_setting( 'rpg_forum_settings', 'rpg_settingsf' );
390 register_setting( 'rpg_general_settings', 'rpg_settingsg' );
391 register_setting( 'rpg_group_settings', 'rpg_groups' );
392 register_setting( 'rpg_roles_settings', 'rpg_roles' );
393 register_setting( 'rpg_topic_permissions', 'rpg_topic_permissions' );
394 register_setting( 'rpg_disable_groups', 'rpg_disable_groups' );
395 }
396
397 //call register settings function
398 add_action( 'admin_init', 'rpg_register_settings' );
399
400 function rpg_settings_menu() {
401 //allows filter for which capability can access the settings page - default = 'manage_options'
402 $cap = apply_filters('rpg_plugin_settings_capability','manage_options');
403 // add settings page
404 add_submenu_page('options-general.php', __('bbp Private Groups', 'bbp-private-groups'), __('bbp Private Groups', 'bbp-private-groups'), $cap, 'bbp-private-group-settings', 'rpg_settings_page');
405 }
406 add_action('admin_menu', 'rpg_settings_menu');
407
408 /***************************** Checkbox functions **************************/
409 function activate_forum_visibility_checkbox() {
410 global $rpg_settingsf ;
411 $item5 = (!empty($rpg_settingsf['set_forum_visibility'] ) ? $rpg_settingsf['set_forum_visibility'] : '');
412 //$item5 = $rpg_settingsf['set_forum_visibility'] ;
413 echo '<input name="rpg_settingsf[set_forum_visibility]" id="rpg_settingsf[set_forum_visibility]" type="checkbox" value="1" class="code" ' . checked( 1,$item5, false ) . ' />' ;
414 _e ('Click to activate forum visibility' , 'bbp-private-groups') ;
415 }
416 function freshness_checkbox() {
417 global $rpg_settingsf ;
418 $item4 = (!empty($rpg_settingsf['set_freshness_message'] ) ? $rpg_settingsf['set_freshness_message'] : '');
419 //$item4 = $rpg_settingsf['set_freshness_message'] ;
420 echo '<input name="rpg_settingsf[set_freshness_message]" id="rpg_settingsf[set_freshness_message]" type="checkbox" value="1" class="code" ' . checked( 1,$item4, false ) . ' />' ;
421 _e ('Click to activate a freshness message', 'bbp-private-groups' );
422 }
423
424 function activate_sub_forums_checkbox() {
425 global $rpg_settingsg ;
426 $item1 = (!empty( $rpg_settingsg['list_sub_forums_as_column']) ? $rpg_settingsg['list_sub_forums_as_column'] : '');
427 //$item1 = $rpg_settingsg['list_sub_forums_as_column'] ;
428 echo '<input name="rpg_settingsg[list_sub_forums_as_column]" id="rpg_settingsg[list_sub_forums_as_column]" type="checkbox" value="1" class="code" ' . checked( 1,$item1, false ) . ' />' ;
429 _e ('List Sub-forums in column', 'bbp-private-groups' );
430 }
431 function activate_hide_counts_checkbox() {
432 global $rpg_settingsg ;
433 $item1 = (!empty( $rpg_settingsg['hide_counts'] ) ? $rpg_settingsg['hide_counts'] : '');
434 //$item1 = $rpg_settingsg['hide_counts'] ;
435 echo '<input name="rpg_settingsg[hide_counts]" id="rpg_settingsg[hide_counts]" type="checkbox" value="1" class="code" ' . checked( 1,$item1, false ) . ' />' ;
436 _e ('Hide topic and reply counts', 'bbp-private-groups' );
437 }
438 function activate_descriptions_checkbox() {
439 global $rpg_settingsg ;
440 $item2 = (!empty( $rpg_settingsg['activate_descriptions'] ) ? $rpg_settingsg['activate_descriptions'] : '');
441 //$item2 = $rpg_settingsg['activate_descriptions'] ;
442 echo '<input name="rpg_settingsg[activate_descriptions]" id="rpg_settingsg[activate_descriptions]" type="checkbox" value="1" class="code" ' . checked( 1,$item2, false ) . ' />' ;
443 _e ('Show sub-forum content (Descriptions) on main index - sub-forums will display in columns' , 'bbp-private-groups' );
444 }
445 function activate_private_prefix_checkbox() {
446 global $rpg_settingsg ;
447 $item3 = (!empty( $rpg_settingsg['activate_remove_private_prefix'] ) ? $rpg_settingsg['activate_remove_private_prefix'] : '');
448 //$item3 = $rpg_settingsg['activate_remove_private_prefix'] ;
449 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 ) . ' />' ;
450 _e ('Remove Private prefix' , 'bbp-private-groups' );
451 }
452 function activate_new_group() {
453 global $rpg_groups ;
454 $item6 = (!empty( $rpg_groups['activate_new_group'] ) ? $rpg_groups['activate_new_group'] : '');
455 echo '<input name="rpg_groups[activate_new_group]" id="rpg_groups[activate_new_group]" type="checkbox" value="1" class="code" />' ;
456 _e ('Click and then press "save groups" to add a new group' , 'bbp-private-groups' ) ;
457 }