PluginProbe
Private groups / 2.0
Private groups v2.0
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.0, at includes/settings.php

456 lines 18.3 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
12
13 ?>
14 <div class="wrap">
15 <div id="upb-wrap" class="upb-help">
16 <h2><?php _e('Private Group Settings', 'bbp-private-groups'); ?></h2>
17 <?php
18 if ( ! isset( $_REQUEST['updated'] ) )
19 $_REQUEST['updated'] = false;
20 ?>
21 <?php if ( false !== $_REQUEST['updated'] ) : ?>
22 <div class="updated fade"><p><strong><?php _e( 'Group saved', 'bbp-private-groups'); ?> ); ?></strong></p></div>
23 <?php endif; ?>
24
25 <?php //tests if we have selected a tab ?>
26 <?php
27 if( isset( $_GET[ 'tab' ] ) ) {
28 if ($active_tab == 'user_management') pg_user_management($tab) ;
29 $active_tab = $_GET[ 'tab' ];}
30 else {$active_tab= 'forum_visibility_settings';
31 } // end if
32 ?>
33
34 <?php // sets up the tabs ?>
35 <h2 class="nav-tab-wrapper">
36
37 <a href="?page=bbp-private-group-settings&tab=forum_visibility_settings" class="nav-tab <?php echo $active_tab == 'forum_visibility_settings' ? 'nav-tab-active' : ''; ?>">Forum Visibility settings</a>
38 <a href="?page=bbp-private-group-settings&tab=general_settings" class="nav-tab <?php echo $active_tab == 'general_settings' ? 'nav-tab-active' : ''; ?>">General Settings</a>
39 <a href="?page=bbp-private-group-settings&tab=group_name_settings" class="nav-tab <?php echo $active_tab == 'group_name_settings' ? 'nav-tab-active' : ''; ?>">Group Name Settings</a>
40 <a href="?page=bbp-private-group-settings&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
41 <a href="?page=bbp-private-group-settings&tab=management_information" class="nav-tab <?php echo $active_tab == 'Management_information' ? 'nav-tab-active' : ''; ?>">Management Information</a>
42 <a href="?page=bbp-private-group-settings&tab=user_management" class="nav-tab <?php echo $active_tab == 'user_management' ? 'nav-tab-active' : ''; ?>">User Management</a></h2>
43 <table class="form-table">
44 <tr>
45
46 <td>
47 <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
48 <input type="hidden" name="cmd" value="_s-xclick">
49 <input type="hidden" name="hosted_button_id" value="S6PZGWPG3HLEA">
50 <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.">
51 <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
52 </form>
53 </td><td>
54 <?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-last-post'); ?>
55
56
57 </td>
58 </tr>
59 </table>
60
61 <?php //************************* Forum Visibility settings *************************// ?>
62
63 <?php if( $active_tab == 'forum_visibility_settings' ) { ?>
64 <form method="post" action="options.php">
65
66 <?php settings_fields( 'rpg_forum_settings' ); ?>
67
68 <table class="form-table">
69
70 <!-------------------------------Forum visibility ---------------------------------------->
71
72 <tr valign="top">
73 <th><h3><?php _e('Forum Visibility', 'bbp-private-groups'); ?></h3></th>
74 <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> See help tab for more information</b></p></td>
75 </tr>
76
77 <!-- checkbox to activate -->
78 <tr valign="top">
79 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
80 <td>
81 <?php activate_forum_visibility_checkbox() ;?>
82 </td>
83 </tr>
84
85 <!-------------------------------Redirect Pages ---------------------------------------->
86
87 <tr valign="top">
88 <th><h3><?php _e('Redirect Pages', 'bbp-private-groups'); ?></h3></th>
89 <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>
90 </tr>
91
92 <tr valign="top">
93 <th><?php _e('URL of redirect page for LOGGED-IN user', 'bbp-private-groups'); ?></th>
94 <td>
95 <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/>
96 <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/>
97 </td>
98 </tr>
99
100 <tr valign="top">
101 <th><?php _e('URL of redirect page for NON-LOGGED-IN', 'bbp-private-groups'); ?></th>
102 <td>
103 <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/>
104 <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/>
105 </td>
106 </tr>
107
108 <!-------------------------------Freshness settings ---------------------------------------->
109
110 <tr valign="top">
111 <th><?php _e('Freshness Settings', 'bbp-private-groups'); ?></th>
112 <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>
113 </tr>
114
115 <!-- checkbox to activate -->
116 <tr valign="top">
117 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
118 <td>
119 <?php freshness_checkbox() ;?>
120 </td>
121 </tr>
122
123 <tr valign="top">
124 <th><?php _e('Freshness Message', 'bbp-private-groups'); ?></th>
125 <td>
126 <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/>
127 <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/>
128 </td>
129 </tr>
130
131 </table>
132
133 <!-- save the options -->
134 <p class="submit">
135 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bbp-private-groups' ); ?>" />
136 </p>
137
138 </form>
139 </div><!--end sf-wrap-->
140 </div><!--end wrap-->
141
142 <?php
143 }
144 ?>
145
146 <?php //************************* General settings *************************// ?>
147
148 <?php if( $active_tab == 'general_settings' ) { ?>
149 <form method="post" action="options.php">
150
151 <?php settings_fields( 'rpg_general_settings' ); ?>
152
153 <table class="form-table">
154 <!------------------------------- Hide topic/reply counts ------------------------------------------>
155 <tr valign="top">
156 <th colspan="2"><h3><?php _e('Hide topic and reply counts', 'bbp-private-groups'); ?></h3></th>
157 </tr>
158
159 <!-- checkbox to activate -->
160 <tr valign="top">
161 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
162 <td>
163 <?php activate_hide_counts_checkbox() ;?>
164 </td>
165 </tr>
166
167 <!------------------------------- Descriptions ------------------------------------------>
168 <tr valign="top">
169 <th colspan="2"><h3><?php _e('Show Descriptions', 'bbp-private-groups'); ?></h3></th>
170 </tr>
171
172 <!-- checkbox to activate -->
173 <tr valign="top">
174 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
175 <td>
176 <?php activate_descriptions_checkbox() ;?>
177 </td>
178 </tr>
179
180 <!------------------------------- Remove 'Private' prefix ------------------------------------------>
181 <tr valign="top">
182 <th colspan="2"><h3><?php _e("Remove 'Private' prefix", 'bbp-private-groups'); ?></h3></th>
183 </tr>
184
185 <!-- checkbox to activate -->
186 <tr valign="top">
187 <th><?php _e('Activate', 'bbp-private-groups'); ?></th>
188 <td>
189 <?php activate_private_prefix_checkbox() ;?>
190 </td>
191 </tr>
192 <tr valign="top">
193 <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>
194 </tr>
195
196 </table>
197
198 <!-- save the options -->
199 <p class="submit">
200 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bbp-private-groups' ); ?>" />
201 </p>
202
203 </form>
204 </div><!--end sf-wrap-->
205 </div><!--end wrap-->
206
207 <?php
208 }
209 ?>
210
211
212
213
214 <?php //************************* Group name settings *************************// ?>
215 <?php if( $active_tab == 'group_name_settings' ) { ?>
216 <form method="post" action="options.php">
217
218 <?php settings_fields( 'rpg_group_settings' ); ?>
219
220 <table class="form-table">
221
222 <tr valign="top">
223 <th colspan="2"><p> This section allows you to set up groups. Enter a Description for each group eg gamers, teachers, group1 etc.</p></th>
224 </tr>
225 <?php
226 $count=count ($rpg_groups) ;
227 if ($count==1) $count=2 ;
228 for ($i = 0 ; $i < $count ; ++$i) {
229 $g=$i+1 ;
230 $name="group".$g ;
231 $item="rpg_groups[".$name."]" ;
232 ?>
233 <!------------------------- Group --------------------------------------------->
234 <tr valign="top">
235 <th><?php echo $name ?></th>
236 <td>
237 <?php echo '<input id="'.$item.'" class="large-text" name="'.$item.'" type="text" value="'.esc_html( $rpg_groups[$name] ).'"<br>' ;
238 ?>
239 </td>
240 </tr>
241 <?php }
242
243 ?>
244 <!-- checkbox to activate new group -->
245 <tr valign="top">
246 <th><?php _e('Add new group', 'bbp-private-groups'); ?></th>
247 <td>
248 <?php activate_new_group() ;?>
249
250 </td>
251 </tr>
252
253
254 </table>
255 <!-- save the options -->
256 <p class="submit">
257 <input type="submit" class="button-primary" value="<?php _e( 'Save Groups', 'bbp-private-groups' ); ?>" />
258 </p>
259 </form>
260 </div><!--end sf-wrap-->
261 </div><!--end wrap-->
262
263 <?php
264 }
265 ?>
266
267 <?php //************************* help page *************************// ?>
268 <?php if( $active_tab == 'help' ) { ?>
269 <form method="post" action="options.php">
270
271 <table class="form-table">
272
273 <tr valign="top">
274 <th colspan="2">
275
276 <h3>Forum Visibility Settings</h3>
277
278 <p>You have various display options</p>
279
280 <h4><span style="color:blue">Only logged in users see group forums, and even then only ones that they have access to.</span></h4>
281
282 <p><i>Description : </i> the default view. Allows up to 8 groups with unique combination of access to forums, but they only see those they have access to.</p>
283
284 <p><i>To set : </i>Do not set the visibility.</p>
285
286 <h4><span style="color:blue">All forum titles (and optionally descriptions) visible to both logged on and non-logged on users.</span></h4>
287
288 <p><i>Description: </i>Users and non-users will be able to see that group forums exist, but not access topics/replies.</p>
289
290 <p><i>Possible Usage : </i>show that lots of forums exist, with ability to go to “sign-up” page.</p>
291
292 <p><i>To set: </i>Set visibility to public below and set forums to public in each forum’s attributes (dashboard>forums).</p>
293
294 <h4><span style="color:blue">Public forums titles (and optionally descriptions) visible to logged on and non-logged on users.
295 Private forums set visible to logged on users</span></h4>
296
297 <p><i>Description : </i>Non-logged in will only see group forums that are public, but not access topics/replies. Logged in users will see and access topics/replies for Private Group forums that are set to public, private forums that have no groups set will be accessible to all logged in users, but private group forums that the user does not belong to will be hidden. </p>
298
299 <p><i>Possible Usage : </i>Show some group forums exists, whilst keeping others visible only for private groups. Allows rich display options for each group, and user.</p>
300
301 <p><i>To set : </i>Set visibility to public below and set any private forums to private in that forum’s attributes (dashboard>forums). </p>
302
303 </th>
304 </tr>
305 <a href="http://www.rewweb.co.uk/wp-content/uploads/2014/04/private-group-roles1.jpg"><img src="http://www.rewweb.co.uk/wp-content/uploads/2014/04/private-group-roles1.jpg"/> </a>
306 </form>
307 </div><!--end sf-wrap-->
308 </div><!--end wrap-->
309 <?php
310 }
311 ?>
312
313 <?php //************************* Management Info *************************// ?>
314 <?php if( $active_tab == 'management_information' ) {
315 ?>
316
317 <?php settings_fields( 'rpg_group_settings' ); ?>
318
319 <table class="form-table">
320
321 <tr valign="top">
322
323 </tr>
324 <?php
325 $count=count ($rpg_groups) ;
326 for ($i = 0 ; $i < $count ; ++$i) {
327 $g=$i+1 ;
328 $name="group".$g ;
329 $item="rpg_groups[".$name."]" ;
330 ?>
331 <!------------------------- Group --------------------------------------------->
332 <tr valign="top">
333 <th><?php echo $name ?></th>
334 <td>
335 Group name :
336 <?php echo esc_html( $rpg_groups[$name] ).'<br>' ; ?>
337 No. users in this group :
338 <?php
339 global $wpdb;
340 $users=$wpdb->get_col("select ID from $wpdb->users") ;
341 $countu=0 ;
342 foreach ($users as $user) {
343
344 $check= get_user_meta( $user, 'private_group',true);
345 if ($check==$name) $countu++ ;
346 }
347 echo $countu ;
348 ?>
349
350
351 <br>Forums in this group :
352 <?php global $wpdb;
353 $forum = bbp_get_forum_post_type() ;
354 $forums=$wpdb->get_col("select ID from $wpdb->posts where post_type='$forum'") ;
355 $countu=0 ;
356 echo '<ul><i>' ;
357 foreach ($forums as $forum) {
358 $meta = (array)get_post_meta( $forum, '_private_group', false );
359 foreach ($meta as $meta2) {
360 if ($meta2==$name) {
361 $ftitle=bbp_forum_title($forum) ;
362 echo '<li>'.$ftitle.'</li>' ;
363 $countu++ ;
364 }
365 }
366
367 }
368 echo '</ul></i>' ;
369
370 echo 'No. forums that have this group set : '.$countu ;
371 ?>
372 </td></tr>
373 <?php }
374
375 ?>
376
377 </table>
378
379 </form>
380 </div><!--end sf-wrap-->
381 </div><!--end wrap-->
382
383 <?php
384 }
385 ?>
386
387 <?php
388 //**** user management
389 if ($active_tab == 'user_management' ) {
390 $group = 'all' ;
391 pg_user_management($group) ;
392 }
393
394
395
396
397
398
399 //end of tab function
400 }
401
402
403
404
405
406
407
408 // register the plugin settings
409 function rpg_register_settings() {
410
411 register_setting( 'rpg_forum_settings', 'rpg_settingsf' );
412 register_setting( 'rpg_general_settings', 'rpg_settingsg' );
413 register_setting( 'rpg_group_settings', 'rpg_groups' );
414 }
415 //call register settings function
416 add_action( 'admin_init', 'rpg_register_settings' );
417
418 function rpg_settings_menu() {
419
420 // add settings page
421 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');
422 }
423 add_action('admin_menu', 'rpg_settings_menu');
424
425 /***************************** Checkbox functions **************************/
426 function activate_forum_visibility_checkbox() {
427 global $rpg_settingsf ;
428 $item5 = $rpg_settingsf['set_forum_visibility'] ;
429 echo '<input name="rpg_settingsf[set_forum_visibility]" id="rpg_settingsf[set_forum_visibility]" type="checkbox" value="1" class="code" ' . checked( 1,$item5, false ) . ' /> Click to activate forum visibility';
430 }
431 function freshness_checkbox() {
432 global $rpg_settingsf ;
433 $item4 = $rpg_settingsf['set_freshness_message'] ;
434 echo '<input name="rpg_settingsf[set_freshness_message]" id="rpg_settingsf[set_freshness_message]" type="checkbox" value="1" class="code" ' . checked( 1,$item4, false ) . ' /> Click to activate a freshness message';
435 }
436
437 function activate_hide_counts_checkbox() {
438 global $rpg_settingsg ;
439 $item1 = $rpg_settingsg['hide_counts'] ;
440 echo '<input name="rpg_settingsg[hide_counts]" id="rpg_settingsg[hide_counts]" type="checkbox" value="1" class="code" ' . checked( 1,$item1, false ) . ' /> Hide topic and reply counts';
441 }
442 function activate_descriptions_checkbox() {
443 global $rpg_settingsg ;
444 $item2 = $rpg_settingsg['activate_descriptions'] ;
445 echo '<input name="rpg_settingsg[activate_descriptions]" id="rpg_settingsg[activate_descriptions]" type="checkbox" value="1" class="code" ' . checked( 1,$item2, false ) . ' /> Show forum content (Descriptions) on main index';
446 }
447 function activate_private_prefix_checkbox() {
448 global $rpg_settingsg ;
449 $item3 = $rpg_settingsg['activate_remove_private_prefix'] ;
450 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 ) . ' /> Remove Private prefix';
451 }
452 function activate_new_group() {
453 global $rpg_groups ;
454 $item6 = $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" /> Click and then press "save groups" to add a new group' ;
456 }