function spa_save_usergroups_delete_usergroup() { check_admin_referer('forum-adminform_usergroupdelete', 'forum-adminform_usergroupdelete'); $usergroup_id = sp_esc_int($_POST['usergroup_id']); # dont allow updates to the default user groups $usergroup = spa_get_usergroups_row($usergroup_id); if ($usergroup->usergroup_locked) { $mess = spa_text('Sorry, the default User Groups cannot be deleted'); return $mess; } # remove all memberships for this user group spdb_query("DELETE FROM " . SFMEMBERSHIPS . " WHERE usergroup_id=" . $usergroup_id); # remove any permission sets using this user group $permissions = spdb_table(SFPERMISSIONS, "usergroup_id={$usergroup_id}"); if ($permissions) { foreach ($permissions as $permission) { spa_remove_permission_data($permission->permission_id); } } # remove any group default permissions using this user group spdb_query("DELETE FROM " . SFDEFPERMISSIONS . " WHERE usergroup_id=" . $usergroup_id); # remove the user group spdb_query("DELETE FROM " . SFMEMBERSHIPS . " WHERE usergroup_id=" . $usergroup_id); $success = spdb_query("DELETE FROM " . SFUSERGROUPS . " WHERE usergroup_id=" . $usergroup_id); if ($success == false) { $mess = spa_text('User group delete failed'); } else { $mess = spa_text('User group deleted'); # reset auths and memberships for everyone sp_reset_memberships(); sp_reset_auths(); do_action('sph_usergroup_del', $usergroup_id); } return $mess; }
function spa_usergroups_edit_usergroup_form($usergroup_id) { global $spPaths; ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#usergrouprow-<?php echo $usergroup_id; ?> ').addClass('inForm'); spjAjaxForm('sfusergroupedit<?php echo $usergroup_id; ?> ', 'sfreloadub'); }); </script> <?php $usergroup = spa_get_usergroups_row($usergroup_id); spa_paint_options_init(); $ahahURL = SFHOMEURL . 'index.php?sp_ahah=usergroups-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=editusergroup'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfusergroupedit<?php echo $usergroup->usergroup_id; ?> " name="sfusergroupedit<?php echo $usergroup->usergroup_id; ?> "> <?php echo sp_create_nonce('forum-adminform_usergroupedit'); spa_paint_open_tab(spa_text('User Groups') . ' - ' . spa_text('Manage User Groups'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Edit User Group'), 'true', 'edit-user-group'); ?> <input type="hidden" name="usergroup_id" value="<?php echo $usergroup->usergroup_id; ?> " /> <input type="hidden" name="ugroup_name" value="<?php echo sp_filter_title_display($usergroup->usergroup_name); ?> " /> <input type="hidden" name="ugroup_desc" value="<?php echo sp_filter_title_display($usergroup->usergroup_desc); ?> " /> <input type="hidden" name="ugroup_join" value="<?php echo $usergroup->usergroup_join; ?> " /> <input type="hidden" name="ugroup_ismod" value="<?php echo $usergroup->usergroup_is_moderator; ?> " /> <?php spa_paint_input(spa_text('User Group Name'), 'usergroup_name', sp_filter_title_display($usergroup->usergroup_name), false, true); spa_paint_input(spa_text('User Group Description'), 'usergroup_desc', sp_filter_title_display($usergroup->usergroup_desc), false, true); spa_paint_select_start(spa_text('Select Badge'), 'usergroup_badge', 'usergroup_badge'); spa_select_icon_dropdown('usergroup_badge', spa_text('Select Badge'), SF_STORE_DIR . '/' . $spPaths['ranks'] . '/', $usergroup->usergroup_badge, false); spa_paint_select_end('<small>(' . spa_text('Upload badges on the Components - Forum Ranks admin panel') . ')</small>'); spa_paint_checkbox(spa_text('Allow members to join usergroup'), 'usergroup_join', $usergroup->usergroup_join, false, false, false, '<small>' . spa_text('(Indicates that members are allowed to choose to join this usergroup on their profile page)') . '</small>'); spa_paint_checkbox(spa_text('Is moderator'), 'usergroup_is_moderator', $usergroup->usergroup_is_moderator, false, false, false, '<small>' . spa_text('(Indicates that members of this usergroup are considered Moderators)') . '</small>'); spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_usergroup_edit_panel'); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="sfusergroupedit<?php echo $usergroup->usergroup_id; ?> " name="sfusergroupedit<?php echo $usergroup->usergroup_id; ?> " value="<?php spa_etext('Update User Group'); ?> " /> <input type="button" class="button-primary" onclick="javascript:jQuery('#usergroup-<?php echo $usergroup->usergroup_id; ?> ').html('');jQuery('#usergrouprow-<?php echo $usergroup_id; ?> ').removeClass('inForm');" id="sfusergroupedit<?php echo $usergroup->usergroup_id; ?> " name="editusergroupcancel<?php echo $usergroup->usergroup_id; ?> " value="<?php spa_etext('Cancel'); ?> " /> </div> </form> <?php spa_paint_close_tab(); ?> <div class="sfform-panel-spacer"></div> <?php }
function spa_forums_view_forums_permission_form($forum_id) { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#forumrow-<?php echo $forum_id; ?> ').addClass('inForm'); }); </script> <?php $forum = spdb_table(SFFORUMS, "forum_id={$forum_id}", 'row'); spa_paint_options_init(); spa_paint_open_tab(spa_text('Forums') . ' - ' . spa_text('Manage Groups and Forums'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('View Forum Permissions'), false); $perms = sp_get_forum_permissions($forum->forum_id); if ($perms) { ?> <table class="sfmaintable" cellpadding="5" cellspacing="3"> <tr> <td align="center" colspan="3"><strong><?php echo spa_text('Current permission set for forum') . ' ' . sp_filter_title_display($forum->forum_name); ?> </strong></td> </tr> <?php foreach ($perms as $perm) { $usergroup = spa_get_usergroups_row($perm->usergroup_id); $role = spa_get_role_row($perm->permission_role); ?> <tr> <td class="sflabel"><?php echo sp_filter_title_display($usergroup->usergroup_name); ?> => <?php echo sp_filter_title_display($role->role_name); ?> </td> <td align="center"> <?php $base = SFHOMEURL . 'index.php?sp_ahah=forums-loader&sfnonce=' . wp_create_nonce('forum-ahah'); $target = "curperm-{$perm->permission_id}"; $image = SFADMINIMAGES; ?> <input type="button" class="spButton-tall" value="<?php echo sp_splice(spa_text('Edit Permission Set'), 0); ?> " onclick="spjLoadForm('editperm', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $perm->permission_id; ?> ');" /> <input type="button" class="spButton-tall" value="<?php echo sp_splice(spa_text('Delete Permission Set'), 0); ?> " onclick="spjLoadForm('delperm', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $perm->permission_id; ?> ');" /> </td> </tr> <tr class="sfinline-form"> <!-- This row will hold hidden forms for the current forum permission set --> <td colspan="3"> <div id="curperm-<?php echo $perm->permission_id; ?> "> </td> </tr> <?php } ?> <?php } else { ?> <table class="sfmaintable" cellpadding="5" cellspacing="3"> <tr> <td> <?php spa_etext('No permission sets for any usergroup'); ?> </td> </tr> <?php } ?> <tr> <td colspan="3" align="center"> <?php $base = SFHOMEURL . 'index.php?sp_ahah=forums-loader&sfnonce=' . wp_create_nonce('forum-ahah'); $target = "newperm-{$forum->forum_id}"; $image = SFADMINIMAGES; ?> <input type="button" class="spButton-tall" value="<?php echo sp_splice(spa_text('Add Permission'), 0); ?> " onclick="spjLoadForm('addperm', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $forum->forum_id; ?> ', 'sfopen');" /> </td> </tr> <tr class="sfinline-form"> <!-- This row will hold ahah forms for adding a new forum permission set --> <td colspan="3"> <div id="newperm-<?php echo $forum->forum_id; ?> "> </div> </td> </tr> </table> <?php spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); ?> <form> <div class="sfform-submit-bar"> <input type="button" class="button-primary" onclick="javascript:jQuery('#forum-<?php echo $forum->forum_id; ?> ').html('');jQuery('#forumrow-<?php echo $forum_id; ?> ').removeClass('inForm');" id="sfgroupdel<?php echo $forum->forum_id; ?> " name="forumcancel<?php echo $forum->forum_id; ?> " value="<?php spa_etext('Cancel'); ?> " /> </div> </form> <?php spa_paint_close_tab(); ?> <div class="sfform-panel-spacer"></div> <?php }
function spa_usergroups_delete_usergroup_form($usergroup_id) { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#usergrouprow-<?php echo $usergroup_id; ?> ').addClass('inForm'); spjAjaxForm('sfusergroupdel<?php echo $usergroup_id; ?> ', 'sfreloadub'); }); </script> <?php $usergroup = spa_get_usergroups_row($usergroup_id); spa_paint_options_init(); $ahahURL = SFHOMEURL . 'index.php?sp_ahah=usergroups-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=delusergroup'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfusergroupdel<?php echo $usergroup->usergroup_id; ?> " name="sfusergroupdel<?php echo $usergroup->usergroup_id; ?> "> <?php echo sp_create_nonce('forum-adminform_usergroupdelete'); spa_paint_open_tab(spa_text('User Groups') . ' - ' . spa_text('Manage User Groups'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Delete User Group'), 'true', 'delete-user-group'); ?> <input type="hidden" name="usergroup_id" value="<?php echo $usergroup->usergroup_id; ?> " /> <?php echo '<p>'; spa_etext("Warning! You are about to delete a User Group!"); echo '</p>'; echo '<p>'; spa_etext("This will remove the usergroup and also remove user memberships contained in this usergroup."); echo '</p>'; echo '<p>'; echo sprintf(spa_text('Please note that this action %s can NOT be reversed %s'), '<strong>', '</strong>'); echo '</p>'; echo '<p>'; spa_etext('Click on the Delete User Group button below to proceed'); echo '</p>'; spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_usergroup_delete_panel'); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="sfusergroupdel<?php echo $usergroup->usergroup_id; ?> " name="sfusergroupdel<?php echo $usergroup->usergroup_id; ?> " value="<?php spa_etext('Delete User Group'); ?> " /> <input type="button" class="button-primary" onclick="javascript:jQuery('#usergroup-<?php echo $usergroup->usergroup_id; ?> ').html('');jQuery('#usergrouprow-<?php echo $usergroup_id; ?> ').removeClass('inForm');" id="sfusergroupdel<?php echo $usergroup->usergroup_id; ?> " name="delusergroupcancel<?php echo $usergroup->usergroup_id; ?> " value="<?php spa_etext('Cancel'); ?> " /> </div> </form> <?php spa_paint_close_tab(); ?> <div class="sfform-panel-spacer"></div> <?php }