PluginProbe
Private groups / 1.7
Private groups v1.7
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 1.7, at includes/settings.php

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