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

423 lines 16.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' : ''; ?>">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 if ($check==$name) $countu++ ;
303 }
304 echo $countu ;
305 ?>
306
307
308 <br>Forums in this group :
309 <?php global $wpdb;
310 $forum = bbp_get_forum_post_type() ;
311 $forums=$wpdb->get_col("select ID from $wpdb->posts where post_type='$forum'") ;
312 $countu=0 ;
313 echo '<ul><i>' ;
314 foreach ($forums as $forum) {
315 $meta = (array)get_post_meta( $forum, '_private_group', false );
316 foreach ($meta as $meta2) {
317 if ($meta2==$name) {
318 $ftitle=bbp_forum_title($forum) ;
319 echo '<li>'.$ftitle.'</li>' ;
320 $countu++ ;
321 }
322 }
323
324 }
325 echo '</ul></i>' ;
326
327 echo 'No. forums that have this group set : '.$countu ;
328 ?>
329 </td></tr>
330 <?php }
331
332 ?>
333
334 </table>
335
336 </form>
337 </div><!--end sf-wrap-->
338 </div><!--end wrap-->
339
340 <?php
341 }
342 ?>
343
344 <?php
345 //**** user management
346 if ($active_tab == 'user_management' ) {
347 $group = 'all' ;
348 pg_user_management($group) ;
349 }
350 ?>
351
352 <?php
353 //**** Help
354 if ($active_tab == 'help' ) {
355 pg_help();
356 }
357 ?>
358
359 <?php
360 //**** role assignment
361 if ($active_tab == 'role_assignment' ) {
362 pg_role_assignment() ;
363 }
364 //end of tab function
365 }
366
367
368
369
370
371
372
373 // register the plugin settings
374 function rpg_register_settings() {
375
376 register_setting( 'rpg_forum_settings', 'rpg_settingsf' );
377 register_setting( 'rpg_general_settings', 'rpg_settingsg' );
378 register_setting( 'rpg_group_settings', 'rpg_groups' );
379 register_setting( 'rpg_roles_settings', 'rpg_roles' );
380 }
381 //call register settings function
382 add_action( 'admin_init', 'rpg_register_settings' );
383
384 function rpg_settings_menu() {
385
386 // add settings page
387 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');
388 }
389 add_action('admin_menu', 'rpg_settings_menu');
390
391 /***************************** Checkbox functions **************************/
392 function activate_forum_visibility_checkbox() {
393 global $rpg_settingsf ;
394 $item5 = $rpg_settingsf['set_forum_visibility'] ;
395 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';
396 }
397 function freshness_checkbox() {
398 global $rpg_settingsf ;
399 $item4 = $rpg_settingsf['set_freshness_message'] ;
400 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';
401 }
402
403 function activate_hide_counts_checkbox() {
404 global $rpg_settingsg ;
405 $item1 = $rpg_settingsg['hide_counts'] ;
406 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';
407 }
408 function activate_descriptions_checkbox() {
409 global $rpg_settingsg ;
410 $item2 = $rpg_settingsg['activate_descriptions'] ;
411 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';
412 }
413 function activate_private_prefix_checkbox() {
414 global $rpg_settingsg ;
415 $item3 = $rpg_settingsg['activate_remove_private_prefix'] ;
416 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';
417 }
418 function activate_new_group() {
419 global $rpg_groups ;
420 $item6 = $rpg_groups['activate_new_group'] ;
421 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' ;
422 }
423