PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
wpforo / admin / pages / usergroup.php

usergroup.php in wpForo Forum 3.1.6, at admin/pages/usergroup.php

493 lines 31.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if( ! defined( 'ABSPATH' ) ) exit;
4 if( ! WPF()->usergroup->can( 'vmg' ) ) exit;
5
6 $wpfaction = wpfval( $_GET, 'wpfaction' );
7 ?>
8
9 <div id="wpf-admin-wrap" class="wrap">
10 <div id="icon-users" class="icon32"><br/></div>
11 <h2 style="padding:30px 0 10px;line-height: 20px;">
12 <?php _e( 'Usergroups', 'wpforo' ) ?>
13 <a href="<?php echo admin_url( 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) . '&wpfaction=wpforo_usergroup_save_form' ) ?>" class="add-new-h2">
14 <?php _e( 'Add New', 'wpforo' ) ?>
15 </a>
16 </h2>
17 <?php WPF()->notice->show() ?>
18 <!-- ############################################################### Usergroup Main Form -->
19
20 <?php if( ! $wpfaction ) : ?>
21 <br/>
22 <form method="POST" class="wpforo-ajax-form">
23 <table id="usergroup_table" class="wp-list-table widefat fixed posts">
24 <thead>
25 <tr>
26 <?php if( wpforo_setting( 'authorization', 'role_synch' ) ): ?>
27 <th scope="col" id="role" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;">
28 <span>
29 <?php _e( 'User Role', 'wpforo' ) ?> &nbsp;
30 <a href="https://codex.wordpress.org/Roles_and_Capabilities" title="<?php _e( 'Read the documentation', 'wpforo' ) ?>" target="_blank" style="font-size: 14px;">
31 <i class="far fa-question-circle"></i>
32 </a>
33 </span>
34 </th>
35 <?php endif; ?>
36 <th scope="col" id="title" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e( 'Usergroup', 'wpforo' ) ?> &nbsp;<a
37 href="https://wpforo.com/docs/wpforo-v3/members/usergroups-and-permissions/" title="<?php _e( 'Read the documentation', 'wpforo' ) ?>" target="_blank"
38 style="font-size: 14px;"><i class="far fa-question-circle"></i></a></span></th>
39 <th scope="col" id="count" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e(
40 'Members',
41 'wpforo'
42 ) ?></span></th>
43 <th scope="col" id="default" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e(
44 'Default',
45 'wpforo'
46 ) ?></span></th>
47 <th scope="col" id="access" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e(
48 'Default Access',
49 'wpforo'
50 ) ?></span></th>
51 <th scope="col" id="color" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e(
52 'Color',
53 'wpforo'
54 ) ?></span></th>
55 <th scope="col" id="id" class="manage-column column-title" style="padding:10px; width: 4%; font-size:14px; padding-left:15px; font-weight:bold; text-align: center;"><span><?php _e(
56 'ID',
57 'wpforo'
58 ) ?></span></th>
59 </tr>
60 </thead>
61 <tbody id="the-list">
62 <?php $groups = WPF()->usergroup->usergroup_list_data(); ?>
63 <?php foreach( $groups as $group ) : ?>
64 <tr id="usergroup-<?php echo intval( $group['groupid'] ) ?>" class="format-standard hentry alternate iedit" valign="top">
65 <?php if( wpforo_setting( 'authorization', 'role_synch' ) ): ?>
66 <td class="post-title page-title column-title" style="border-bottom:1px dotted #CCCCCC; padding-left:20px;">
67 <?php
68 $ug_role = trim( (string) $group['role'] );
69 $ug_role = ( wp_roles()->is_role( $ug_role ) ) ? $ug_role = '<a href="' . admin_url( 'users.php?role=' . $group['role'] ) . '" title="' . __(
70 'View Users',
71 'wpforo'
72 ) . '" target="_blank"><i class="far fa-user"></i></a>' : '';
73 ?>
74 <span style="font-size: 16px; vertical-align: middle;"><?php echo $ug_role; ?></span> &nbsp;
75 <?php if( $group['groupid'] != 4 && $group['groupid'] != 1 ) : ?>
76 <select name="wpf_synch_roles[<?php echo $group['groupid'] ?>]" style="background:#FDFDFD; display:inline; max-width: 80%;">
77 <option value="">-- <?php _e( 'Not Selected', 'wpforo' ) ?> --</option>
78 <?php $selected = ( wpfval( $group, 'role' ) ) ? $group['role'] : ''; ?>
79 <?php wp_dropdown_roles( $selected ); ?>
80 </select>
81 <?php elseif( $group['groupid'] == 1 ): ?>
82 <span style="font-size: 14px; vertical-align: bottom;">&nbsp;<?php echo $group['role']; ?></span>
83 <input type="hidden" name="wpf_synch_roles[1]" value="administrator">
84 <?php endif; ?>
85 </td>
86 <?php endif; ?>
87 <td class="post-title page-title column-title" style="border-bottom:1px dotted #CCCCCC; padding-left:20px; background:#ffffff;">
88 <?php $edit_url = ( $group['groupid'] != 1 ? admin_url(
89 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) . '&groupid=' . $group['groupid'] . '&wpfaction=wpforo_usergroup_save_form'
90 ) : '#' ) ?>
91 <strong>
92 <a class="row-title" href="<?php echo esc_url( (string) $edit_url ) ?>" title="<?php _e( 'Usergroup Name', 'wpforo' ) ?>">
93 <?php echo esc_html( $group['name'] ) ?>
94 </a> <?php if( wpfval( $group, 'secondary' ) ): ?>&nbsp;<span style="font-size: 12px; color: #777777;" title="<?php _e( 'Also used as Secondary Usergroup' ); ?>"><i
95 class="fas fa-pause"></i></span><?php endif; ?>
96 </strong>
97 <div class="row-actions">
98 <span class="edit"><a title="<?php _e( 'Edit this usergroup', 'wpforo' ) ?>" href="<?php echo admin_url(
99 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) . '&groupid=' . intval( $group['groupid'] ) . '&wpfaction=wpforo_usergroup_save_form'
100 ) ?>"><?php _e( 'Edit', 'wpforo' ) ?></a> |</span>
101 <?php if( $group['groupid'] > 5 ): ?>
102 <span class="trash"><a class="submitdelete" title="<?php _e( 'Delete this usergroup', 'wpforo' ) ?>" href="<?php echo admin_url(
103 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) . '&groupid=' . intval( $group['groupid'] ) . '&wpfaction=usergroup_delete_form'
104 ) ?>"><?php _e( 'Delete', 'wpforo' ) ?></a> |</span>
105 <?php endif; ?>
106 <span class="view"><a title="<?php _e( 'View users list in this usergroup', 'wpforo' ) ?>"
107 href="<?php echo admin_url( 'admin.php?page=' . wpforo_prefix_slug( 'members' ) . '&filter_by_group=' . intval( $group['groupid'] ) ) ?>"
108 rel="permalink"><?php _e( 'View', 'wpforo' ) ?></a></span>
109 </div>
110 </td>
111 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff;">
112 <?php if( $group['groupid'] != 4 ) : ?>
113 <strong><a class="row-title" href="<?php echo admin_url( 'admin.php?page=' . wpforo_prefix_slug( 'members' ) . '&filter_by_group=' . intval( $group['groupid'] ) ) ?>"
114 title="<?php _e( 'The number of forum members with this usergroup. Click to view members.', 'wpforo' ) ?>"><i
115 class="fas fa-user"></i>&nbsp; <?php echo intval( $group['count'] ) ?></a></strong>
116 <?php endif; ?>
117 </td>
118 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff;">
119 <strong style="color: #00a636">
120 <?php if( $group['groupid'] == WPF()->usergroup->default_groupid ) : _e( 'is Default', 'wpforo' ); ?>
121 <?php elseif( $group['groupid'] == 4 || $group['groupid'] == 1 ) : ?>
122 <?php else : ?>
123 <a class="row-title" href="<?php echo wp_nonce_url(
124 admin_url( 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) . '&wpfaction=default_groupid_change&default_groupid=' . intval( $group['groupid'] ) ),
125 'wpforo-default-groupid-change-' . intval( $group['groupid'] )
126 ) ?>" title="<?php _e( 'Users get the Default Usergroup on registration', 'wpforo' ) ?>"><?php _e( 'Set as Default', 'wpforo' ) ?></a>
127 <?php endif ?>
128 </strong>
129 </td>
130 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff;">
131 <strong><?php echo wpfval( WPF()->perm->accesses, $group['access'], 'title' ); ?></strong>
132 </td>
133 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff;">
134 <strong><?php if( ! isset( $group['color'] ) || ! $group['color'] ): ?><?php _e( 'default (#15)', 'wpforo' ) ?><?php else: ?><input type="color"
135 value="<?php echo $group['color'] ?>"
136 disabled /><?php endif; ?></strong>
137 </td>
138 <td class="post-title page-title column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; background:#ffffff; text-align: center;">
139 <strong><?php echo $group['groupid'] ?></strong>
140 </td>
141 </tr>
142 <?php endforeach ?>
143 </tbody>
144 <tfoot>
145 <tr>
146 <?php if( wpforo_setting( 'authorization', 'role_synch' ) ): ?>
147 <td style="text-align: center;">
148 <button class="button button-primary wpf-synch-roles" title="<?php _e( 'Synchronize Users Usergroups and Roles', 'wpforo' ) ?>" style="margin: 5px auto;">
149 <?php _e( 'Synchronize', 'wpforo' ) ?>
150 <i class="fas wpf-spinner"></i>
151 </button>
152 <?php
153 $wpf_nonce = wp_create_nonce( 'wpforo_synch_roles' );
154 $wpf_data = wpforo_get_option( 'synch_roles', [] );
155 $wpf_id = ( wpfval( $wpf_data, 'id' ) ) ? intval( $wpf_data['id'] ) : 0;
156 $wpf_start = ( wpfval( $wpf_data, 'start' ) ) ? intval( $wpf_data['start'] ) : 0;
157 $wpf_step = ( wpfval( $wpf_data, 'step' ) ) ? intval( $wpf_data['step'] ) : 1;
158 $wpf_left = ( wpfval( $wpf_data, 'left' ) ) ? intval( $wpf_data['left'] ) : 0;
159 ?>
160 <input type="hidden" name="wpf-start-id" value="<?php echo intval( $wpf_id ) ?>" class="wpf-start-id"/>
161 <input type="hidden" name="wpf-start" value="<?php echo intval( $wpf_start ) ?>" class="wpf-start"/>
162 <input type="hidden" name="wpf-step" value="<?php echo intval( $wpf_step ) ?>" class="wpf-step"/>
163 <input type="hidden" name="wpf-left-users" value="<?php echo intval( $wpf_left ) ?>" class="wpf-left-users"/>
164 </td>
165 <?php endif; ?>
166 <td colspan="6" style="text-align:left; vertical-align: middle; padding:10px 20px;"><span class="wpf-progress"
167 style="font-size: 14px; display: inline-block; font-weight: 600; line-height: 18px;">&nbsp;</span>
168 </td>
169 </tr>
170 </tfoot>
171 </table>
172 </form>
173
174 <?php if( wpforo_setting( 'authorization', 'role_synch' ) ): ?>
175 <p class="description" style="box-shadow: 1px 1px 6px #cccccc; background: #f7f7f7; padding: 20px; width: 95%; margin: 20px 0 0; font-size: 14px;">
176 <span style="color: #ff4b3c; font-weight: 600;"><?php _e( 'Note:', 'wpforo' ) ?></span>
177 <?php _e(
178 'The [Synchronize] button changes all users Usergroups according to the users Roles. For example, if you select "Contributor" Role for "Registered" Usergroup, all users with "Contributor" Role will get "Registered" Usergroup in forum. The synchronization process may take a few seconds or dozens of minutes, it depends on the number of users. Please be patient, don\'t close this page and wait until the progress counter says 100% completed.',
179 'wpforo'
180 ); ?>
181 </p>
182 <?php endif; ?>
183
184 <p id="synch" style="margin: 4px;">&nbsp;</p>
185
186 <?php if( wpforo_setting( 'authorization', 'role_synch' ) ): ?>
187 <?php $roles_wug = WPF()->usergroup->get_roles();
188 $roles_ug = WPF()->usergroup->get_roles_ug();
189 $roles_users = count_users(); ?>
190 <?php if( ! empty( $roles_wug ) ): ?>
191 <h1 style="padding-bottom: 0; width: 97%; margin-bottom: 15px;">&nbsp;<?php _e( 'User Roles' ); ?></h1>
192 <p class="description" style="border-top: 1px solid #cccccc; background: #f7f7f7; padding: 15px 20px; width: 95%; margin: 10px 0 20px 0; font-size: 14px;">
193 <?php _e(
194 'In the table above (Usergroups) you can see the list of all available forum Usergroups. The first column of this table displays selected User Roles which are synched with certain Usergroup. However some User Roles are still not synced with any Usergroup of your forum. You can find not-synced User Roles in the table below (User Roles). If you use any of these not-synced User Roles and you want to grant some forum accesses to users of these User Roles you should create new Usergroups for each of them. Once new Usergroup is created, you should use the [Synchronize] button in the table above to synchronize User Roles with new Usergroups.'
195 ); ?>
196 </p>
197 <table id="usergroup_table" class="wp-list-table widefat fixed posts">
198 <thead>
199 <tr>
200 <th scope="col" id="role" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e(
201 'Role Name',
202 'wpforo'
203 ) ?></span></th>
204 <th scope="col" id="id" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e( 'User Role', 'wpforo' ) ?></span>
205 </th>
206 <th scope="col" id="title" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e(
207 'Usergroups',
208 'wpforo'
209 ) ?></span></th>
210 <th scope="col" id="count" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold;"><span><?php _e( 'Users', 'wpforo' ) ?></span>
211 </th>
212 <th scope="col" id="default" class="manage-column column-title" style="padding:10px; font-size:14px; padding-left:15px; font-weight:bold; width: 40%;"><span><?php _e(
213 'Status',
214 'wpforo'
215 ) ?></th>
216 </tr>
217 </thead>
218 <tbody id="the-list">
219 <?php foreach( $roles_wug as $role_key => $role_name ): ?>
220 <tr>
221 <td class="column-title"
222 style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#F9F9F9; font-weight: 600; font-size: 14px;"><?php echo $role_name; ?></td>
223 <td class="column-title"
224 style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff; color: #c420fa; font-weight: 600;"><?php echo $role_key; ?></td>
225 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff;"><?php echo ( wpfval(
226 $roles_ug,
227 $role_key
228 ) ) ? '<span style="color:#43a6df; font-weight: 600;">' . implode( ', ', $roles_ug[ $role_key ] ) . '</span>' : 'default'; ?></td>
229 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding-left:20px; background:#ffffff; font-weight: 600; font-size: 14px;">
230 <?php echo ( wpfval( $roles_users, 'avail_roles' ) && wpfval( $roles_users, 'avail_roles', $role_key ) && $roles_users['avail_roles'][ $role_key ] ) ? '<a href="' . admin_url(
231 'users.php?role=' . $role_key
232 ) . '" title="' . __( 'View Users', 'wpforo' ) . '" target="_blank"><i class="far fa-user"></i> &nbsp;' . intval(
233 $roles_users['avail_roles'][ $role_key ]
234 ) . '</a>' : 0; ?>
235 </td>
236 <td class="column-title" style="border-bottom:1px dotted #CCCCCC; vertical-align:middle; padding:10px; background:#ffffff;">
237 <?php if( ! wpfval( $roles_ug, $role_key ) ): ?>
238 <a href="<?php echo admin_url( 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) . '&wpfaction=wpforo_usergroup_save_form&role=' . $role_key ) ?>" class="add-new-h2"
239 style="display: inline-block; vertical-align: middle; top: 0;"><?php _e( 'Add Usergroup to synch', 'wpforo' ) ?></a>
240 <?php elseif( count( $roles_ug[ $role_key ] ) > 1 ): ?>
241 <span style="color: #f61700; font-weight: 600; padding: 0 5px; display: inline-block;"><?php _e( 'Not Synched', 'wpforo' ) ?></span>
242 <p class="wpf-info" style="padding: 0 4px;"><?php _e( 'One User Role cannot be synched with multiple Usergroups.', 'wpforo' ) ?></p>
243 <?php else: ?>
244 <span style="color: #00a636; font-weight: 600; padding: 0 5px; display: inline-block;"><?php _e( 'Synched', 'wpforo' ) ?></span>
245 <?php endif; ?>
246 </td>
247 </tr>
248 <?php endforeach; ?>
249 </tbody>
250 </table>
251 <?php endif; ?>
252 <script type="text/javascript">
253 jQuery(document).ready(function ($) {
254 $(document).on('click', '.wpf-synch-roles', function (e) {
255 e.preventDefault();
256 if ($('.wpf-left-users').val() >= 0) {
257 var btn = $(this);
258 btn.attr('disabled', 'disabled');
259 $('.fas', btn).addClass('fa-pulse fa-spinner').removeClass('wpf-spinner');
260 wpforo_update_roles(btn);
261 }
262 });
263
264 function wpforo_update_roles (btn) {
265 inprocess = true;
266 var data = btn.parents('.wpforo-ajax-form').serialize();
267 $.ajax({
268 type: 'POST',
269 url: ajaxurl,
270 data: {
271 wpforo_synch_roles_data: data,
272 action: 'wpforo_synch_roles',
273 checkthis: '<?php echo wp_create_nonce( "wpforo_synch_roles" ) ?>',
274 },
275 }).done(function (response) {
276 try {
277 var resp = JSON.parse(response);
278 $('.wpf-step').val(resp.step);
279 $('.wpf-start').val(resp.start);
280 $('.wpf-start-id').val(resp.id);
281 $('.wpf-left-users').val(resp.left);
282 if (resp.progress < 100) {
283 wpforo_update_roles(btn);
284 } else {
285 btn.removeAttr('disabled');
286 $('.fas', btn).removeClass('fa-pulse fa-spinner').addClass('wpf-spinner');
287 }
288 if (resp.progress <= 1) {
289 $('.wpf-progress').text(1 + '%');
290 } else {
291 if (resp.progress < 100) {
292 $('.wpf-progress').text(resp.progress + '%');
293 } else {
294 $('.wpf-progress').css({ 'color': '#00a636' });
295 $('.wpf-progress').text(resp.progress + '% <?php _e( 'Complete!', 'wpforo' ); ?>');
296 $('.wpf-left-users').val(0);
297 $('.wpf-step').val(0);
298 $('.wpf-start-id').val(0);
299 inprocess = false;
300 window.location.replace("<?php echo admin_url( 'admin.php?page=' . wpforo_prefix_slug( 'usergroups' ) ) ?>");
301 }
302 }
303 } catch (e) {
304 console.log(e);
305 }
306 });
307 }
308 });
309 </script>
310 <?php endif; ?>
311 <!-- ############################################################### Usergroup Main Form END -->
312 <?php elseif( $wpfaction === 'usergroup_delete_form' ) :
313 $groupid = intval( wpfval( $_GET, 'groupid' ) );
314 $users_count = WPF()->member->get_count( [ 'groupid' => $groupid ] );
315 ?>
316 <!-- ############################################################### DELETE Usergroup -->
317 <form method="POST">
318 <?php wp_nonce_field( 'wpforo-usergroup-delete' ) ?>
319 <input type="hidden" name="wpfaction" value="usergroup_delete">
320 <input type="hidden" name="usergroup[groupid]" value="<?php echo $groupid ?>">
321 <div class="form-wrap">
322 <div class="form-field form-required">
323 <div class="form-field">
324 <table>
325 <tr>
326 <td>
327 <label for="delete_ug" class="menu_delete" style="color: red;">
328 <?php _e( 'Delete Chosen Usergroup And Users', 'wpforo' ) ?>
329 </label>
330 </td>
331 <td>
332 <input id="delete_ug" type="radio" name="usergroup[delete]" value="1" onchange="mode_changer_ug(false);" <?php echo $users_count > 50 ? 'disabled' : '' ?>>
333 <?php if( $users_count > 50 ) : ?>
334 <span style="color: #a3a3a3">(<?php _e( 'This option has disabled because you have more than 50 users in this group.', 'wpforo' ) ?>)</span>
335 <?php endif ?>
336 </td>
337 </tr>
338 <tr>
339 <td>
340 <label for="marge">
341 <?php _e( 'Delete Chosen Usergroup And Join Users To Other Usergroup', 'wpforo' ) ?>
342 </label>
343 </td>
344 <td>
345 <input id="marge" type="radio" name="usergroup[delete]" value="0" checked onchange="mode_changer_ug(true);">
346 </td>
347 </tr>
348 <tr>
349 <td>
350 <select id="ug_select" name="usergroup[mergeid]" class="postform">
351 <?php WPF()->usergroup->show_selectbox( [], [ $groupid, 4 ] ) ?>
352 </select>
353 <p><?php _e( 'Users will be join this usergroup', 'wpforo' ) ?></p>
354 </td>
355 </tr>
356 </table>
357 </div>
358 <input id="ug_submit" type="submit" class="button button-primary" value="<?php _e( 'Delete', 'wpforo' ) ?>">
359 </div>
360 </div>
361 </form>
362 <!-- ############################################################### DELETE Usergroup -->
363 <?php elseif( $wpfaction === 'wpforo_usergroup_save_form' ) :
364 $group = WPF()->usergroup->fix_group( WPF()->usergroup->get_usergroup( wpfval( $_GET, 'groupid' ) ) ); ?>
365 <!-- ############################################################### Add / Edit Usergroup Form -->
366 <script type="text/javascript">
367 jQuery(document).ready(function ($) {
368 var foo = $('#wpf_usergroup_color');
369 var bar = $('#wpf_usergroup_colorx');
370 foo.on('change input propertychange', function () {
371 bar.val(foo.val()).trigger('change');
372 });
373 bar.on('change input propertychange', function () {
374 $('.wpf-color-stat-icon').remove();
375 var color_code = bar.val();
376 if (/^#[0-9A-F]{6}$/i.test(color_code)) {
377 foo.val(color_code);
378 bar.css('border-color', 'green');
379 bar.after('<span class="wpf-color-stat-icon dashicons dashicons-yes-alt" style="font-size: 30px; color: green;"></span>');
380 $('input[name="usergroup[wpfugc]"]').prop('checked', false);
381 setTimeout(function () {
382 $('.wpf-color-stat-icon.dashicons-yes-alt').remove();
383 }, 4000);
384 } else {
385 bar.css('border-color', 'red');
386 bar.after('<span class="wpf-color-stat-icon dashicons dashicons-warning" style="font-size: 30px; color: red;"></span>');
387 }
388 });
389 });
390 </script>
391 <div class="wpf-info-bar" style="margin-top:20px;">
392 <div class="form-wrap">
393 <form id="add_ug" method="POST">
394 <?php if( $group['groupid'] ) : wp_nonce_field( 'wpforo-usergroup-edit' ) ?>
395 <input type="hidden" name="wpfaction" value="usergroup_edit">
396 <?php else : wp_nonce_field( 'wpforo-usergroup-add' ) ?>
397 <input type="hidden" name="wpfaction" value="usergroup_add">
398 <?php endif; ?>
399 <input type="hidden" name="usergroup[groupid]" value="<?php echo $group['groupid'] ?>">
400 <div style="width:100%; margin-bottom:12px;">
401 <div style="display:block; float:left; padding-right:20px; width:30%; padding-bottom:15px;">
402 <div class="wpf-label-big">
403 <?php _e( 'Usergroup Name', 'wpforo' );
404 if( $group['groupid'] === 4 ) echo '<span>: ' . __( 'Guest', 'wpforo' ) . '</span>'; ?>
405 &nbsp;<a href="https://wpforo.com/docs/wpforo-v3/members/usergroups-and-permissions/" title="<?php _e( 'Read the documentation', 'wpforo' ) ?>" target="_blank"
406 style="font-size: 14px;"><i class="far fa-question-circle"></i></a><br>
407 </div>
408 <input name="usergroup[name]" <?php echo $group['groupid'] === 4 ? 'type="hidden"' : 'type="text"'; ?> value="<?php echo esc_attr( $group['name'] ) ?>" required
409 style="background:#FDFDFD; min-width:320px;">
410 <div style="display:inline-block; margin-top:10px;">
411 <label for="wpf_usergroup_color" style="display:inline-block;"><?php _e( 'Usergroup Color', 'wpforo' ) ?>: </label>
412 <input id="wpf_usergroup_color" style="display:inline-block; vertical-align:middle; width:100px;" type="color" name="usergroup[color]" onchange=""
413 value="<?php echo $group['color'] ?>">
414 <input id="wpf_usergroup_colorx" style="display:inline-block; vertical-align:middle; width:100px; padding:1px 5px;" type="text" name="usergroup[colorx]" maxlength="7"
415 value="<?php echo $group['color'] ?>">
416 <label style="text-align:right;"><?php _e( 'use default link color', 'wpforo' ); ?>
417 <input type="checkbox" name="usergroup[wpfugc]" value="default" <?php echo ! $group['color'] ? 'checked="checked"' : '' ?>>
418 </label>
419 </div>
420 </div>
421 <?php if( $group['groupid'] === 4 ) : ?>
422 <input type="hidden" name="usergroup[role]" value="">
423 <?php elseif( $group['groupid'] === 1 ) : ?>
424 <input type="hidden" name="usergroup[role]" value="administrator">
425 <?php else: ?>
426 <div style="display:block; float:left; width:20%; padding-bottom:15px;">
427 <div class="wpf-label-big"><?php _e( 'User Role', 'wpforo' ) ?></div>
428 <select name="usergroup[role]" style="background:#FDFDFD; display:block;">
429 <option value="">-- <?php _e( 'Not Selected', 'wpforo' ) ?> --</option>
430 <?php if( $role = wpfval( $_GET, 'role' ) ) {
431 $selected = sanitize_title( $role );
432 } else {
433 $selected = $group['role'] ?: '';
434 }
435 wp_dropdown_roles( $selected ); ?>
436 </select>
437 </div>
438 <?php endif; ?>
439 <div style="display:block; float:left; width:40%;">
440 <?php if( ! $group['groupid'] ): ?>
441 <div class="wpf-label-big"><?php _e( 'Default Forum Access', 'wpforo' ) ?></div>
442 <select name="usergroup[access]" style="background:#FDFDFD; display:block;">
443 <?php WPF()->perm->show_accesses_selectbox( 'standard' ); ?>
444 </select>
445 <div class="wpf-info" style="line-height:17px; display:block; margin-top:6px;">
446 <?php _e( 'This is only used when a new Usergroup is created, it automatically gets the selected Forum Access in all forums.', 'wpforo' ) ?>
447 </div>
448 <?php endif; ?>
449 <div style="padding: 10px 1px 5px;">
450 <label>
451 <input type="checkbox" name="usergroup[visible]" value="1" <?php echo $group['visible'] ? 'checked' : '' ?>>
452 <?php _e( 'Display on Members List', 'wpforo' ) ?>
453 </label>
454 <?php if( in_array( $group['groupid'], [ 1, 2, 4 ] ) ): ?>
455 <input type="hidden" name="usergroup[secondary]" value="0">
456 <?php else: ?>
457 <label>
458 <input type="checkbox" name="usergroup[secondary]" value="1" <?php echo $group['secondary'] ? 'checked' : '' ?>>
459 <?php _e( 'Can be also used as Secondary Usergroup', 'wpforo' ) ?>
460 </label>
461 <?php endif; ?>
462 </div>
463 </div>
464 <div style="clear:both;"></div>
465 </div>
466 <?php $n = 0;
467 foreach( WPF()->usergroup->cans as $can => $name ) : ?>
468 <?php if( ! ( $n % 4 ) ): ?>
469 </table>
470 <table class="wpf-table-box-left" style="margin-right:15px; margin-bottom:15px; min-width:320px;">
471 <?php endif; ?>
472 <tr>
473 <th class="wpf-dw-td-nowrap">
474 <label class="wpf-td-label" for="wpf-can-<?php echo esc_attr( $can ) ?>">
475 <?php echo esc_html( __( $name, 'wpforo' ) ) ?>
476 </label>
477 </th>
478 <td class="wpf-dw-td-value">
479 <input id="wpf-can-<?php echo esc_attr( $can ) ?>" type="checkbox" value="1"
480 name="usergroup[cans][<?php echo esc_attr( $can ) ?>]" <?php echo $group['cans'][ $can ] ? 'checked' : '' ?>>
481 </td>
482 </tr>
483 <?php $n ++;
484 endforeach; ?>
485 </table>
486 <div class="clear"></div>
487 <input type="submit" class="button button-primary" value="<?php _e( 'save', 'wpforo' ); ?>">
488 </form>
489 </div>
490 </div>
491 <!-- ############################################################### END of Add / Edit Usergroup -->
492 <?php endif; ?>
493