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

426 lines 16.5 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' : ''; ?>">Forum Visibility settings</a>
39 <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>
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' : ''; ?>">Group Name Settings</a>
41 <a href="?page=bbp-private-group-settings&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
42 <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>
43 <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>
44 <a href="?page=bbp-private-group-settings&tab=role_assignment" class="nav-tab <?php echo $active_tab == 'role_assignment' ? 'nav-tab-active' : ''; ?>">Assign groups to roles</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-last-post'); ?>
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> See help tab for more information</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> This section allows you to set up groups. Enter a Description for each group eg gamers, teachers, group1 etc.</p></th>
226 </tr>
227 <?php
228 $count=count ($rpg_groups) ;
229 if ($count==1) $count=2 ;
230 for ($i = 0 ; $i < $count ; ++$i) {
231 $g=$i+1 ;
232 $name="group".$g ;
233 $item="rpg_groups[".$name."]" ;
234 ?>
235 <!------------------------- Group --------------------------------------------->
236 <tr valign="top">
237 <th><?php echo $name ?></th>
238 <td>
239 <?php echo '<input id="'.$item.'" class="large-text" name="'.$item.'" type="text" value="'.esc_html( $rpg_groups[$name] ).'"<br>' ;
240 ?>
241 </td>
242 </tr>
243 <?php }
244
245 ?>
246 <!-- checkbox to activate new group -->
247 <tr valign="top">
248 <th><?php _e('Add new group', 'bbp-private-groups'); ?></th>
249 <td>
250 <?php activate_new_group() ;?>
251
252 </td>
253 </tr>
254
255
256 </table>
257 <!-- save the options -->
258 <p class="submit">
259 <input type="submit" class="button-primary" value="<?php _e( 'Save Groups', 'bbp-private-groups' ); ?>" />
260 </p>
261 </form>
262 </div><!--end sf-wrap-->
263 </div><!--end wrap-->
264
265 <?php
266 }
267 ?>
268
269
270 <?php //************************* Management Info *************************// ?>
271 <?php if( $active_tab == 'management_information' ) {
272 ?>
273
274 <?php settings_fields( 'rpg_group_settings' ); ?>
275
276 <table class="form-table">
277
278 <tr valign="top">
279
280 </tr>
281 <?php
282 $count=count ($rpg_groups) ;
283 for ($i = 0 ; $i < $count ; ++$i) {
284 $g=$i+1 ;
285 $name="group".$g ;
286 $item="rpg_groups[".$name."]" ;
287 ?>
288 <!------------------------- Group --------------------------------------------->
289 <tr valign="top">
290 <th><?php echo $name ?></th>
291 <td>
292 Group name :
293 <?php echo esc_html( $rpg_groups[$name] ).'<br>' ; ?>
294 No. users in this group :
295 <?php
296 global $wpdb;
297 $users=$wpdb->get_col("select ID from $wpdb->users") ;
298 $countu=0 ;
299 foreach ($users as $user) {
300
301 $check= get_user_meta( $user, 'private_group',true);
302 //single user check
303 if ($check==$name) $countu++ ;
304 //multiple group set
305 if (strpos($check, '*'.$name.'*') !== FALSE) $countu++;
306 }
307 echo $countu ;
308 ?>
309
310
311 <br>Forums in this group :
312 <?php global $wpdb;
313 $forum = bbp_get_forum_post_type() ;
314 $forums=$wpdb->get_col("select ID from $wpdb->posts where post_type='$forum'") ;
315 $countu=0 ;
316 echo '<ul><i>' ;
317 foreach ($forums as $forum) {
318 $meta = (array)get_post_meta( $forum, '_private_group', false );
319 foreach ($meta as $meta2) {
320 if ($meta2==$name) {
321 $ftitle=bbp_forum_title($forum) ;
322 echo '<li>'.$ftitle.'</li>' ;
323 $countu++ ;
324 }
325 }
326
327 }
328 echo '</ul></i>' ;
329
330 echo 'No. forums that have this group set : '.$countu ;
331 ?>
332 </td></tr>
333 <?php }
334
335 ?>
336
337 </table>
338
339 </form>
340 </div><!--end sf-wrap-->
341 </div><!--end wrap-->
342
343 <?php
344 }
345 ?>
346
347 <?php
348 //**** user management
349 if ($active_tab == 'user_management' ) {
350 $group = 'all' ;
351 pg_user_management($group) ;
352 }
353 ?>
354
355 <?php
356 //**** Help
357 if ($active_tab == 'help' ) {
358 pg_help();
359 }
360 ?>
361
362 <?php
363 //**** role assignment
364 if ($active_tab == 'role_assignment' ) {
365 pg_role_assignment() ;
366 }
367 //end of tab function
368 }
369
370
371
372
373
374
375
376 // register the plugin settings
377 function rpg_register_settings() {
378
379 register_setting( 'rpg_forum_settings', 'rpg_settingsf' );
380 register_setting( 'rpg_general_settings', 'rpg_settingsg' );
381 register_setting( 'rpg_group_settings', 'rpg_groups' );
382 register_setting( 'rpg_roles_settings', 'rpg_roles' );
383 }
384 //call register settings function
385 add_action( 'admin_init', 'rpg_register_settings' );
386
387 function rpg_settings_menu() {
388
389 // add settings page
390 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');
391 }
392 add_action('admin_menu', 'rpg_settings_menu');
393
394 /***************************** Checkbox functions **************************/
395 function activate_forum_visibility_checkbox() {
396 global $rpg_settingsf ;
397 $item5 = $rpg_settingsf['set_forum_visibility'] ;
398 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';
399 }
400 function freshness_checkbox() {
401 global $rpg_settingsf ;
402 $item4 = $rpg_settingsf['set_freshness_message'] ;
403 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';
404 }
405
406 function activate_hide_counts_checkbox() {
407 global $rpg_settingsg ;
408 $item1 = $rpg_settingsg['hide_counts'] ;
409 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';
410 }
411 function activate_descriptions_checkbox() {
412 global $rpg_settingsg ;
413 $item2 = $rpg_settingsg['activate_descriptions'] ;
414 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';
415 }
416 function activate_private_prefix_checkbox() {
417 global $rpg_settingsg ;
418 $item3 = $rpg_settingsg['activate_remove_private_prefix'] ;
419 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';
420 }
421 function activate_new_group() {
422 global $rpg_groups ;
423 $item6 = $rpg_groups['activate_new_group'] ;
424 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' ;
425 }
426