function spa_forums_edit_group_form($group_id) { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#grouprow-<?php echo $group_id; ?> ').addClass('inForm'); spjAjaxForm('sfgroupedit<?php echo $group_id; ?> ', 'sfreloadfb'); }); </script> <?php global $spPaths; $group = $group = spdb_table(SFGROUPS, "group_id={$group_id}", 'row'); spa_paint_options_init(); $ahahURL = SFHOMEURL . 'index.php?sp_ahah=forums-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=editgroup'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfgroupedit<?php echo $group->group_id; ?> " name="sfgroupedit<?php echo $group->group_id; ?> "> <?php echo sp_create_nonce('forum-adminform_groupedit'); spa_paint_open_tab(spa_text('Forums') . ' - ' . spa_text('Manage Groups and Forums'), false); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Edit Group'), 'true', 'edit-forum-group'); ?> <input type="hidden" name="group_id" value="<?php echo $group->group_id; ?> " /> <input type="hidden" name="cgroup_name" value="<?php echo sp_filter_title_display($group->group_name); ?> " /> <input type="hidden" name="cgroup_desc" value="<?php echo sp_filter_text_edit($group->group_desc); ?> " /> <input type="hidden" name="cgroup_seq" value="<?php echo $group->group_seq; ?> " /> <input type="hidden" name="cgroup_icon" value="<?php echo esc_attr($group->group_icon); ?> " /> <input type="hidden" name="cgroup_rss" value="<?php echo $group->group_rss; ?> " /> <input type="hidden" name="cgroup_message" value="<?php echo sp_filter_text_edit($group->group_message); ?> " /> <?php spa_paint_input(spa_text('Group Name'), 'group_name', sp_filter_title_display($group->group_name), false, true); spa_paint_input(spa_text('Description'), 'group_desc', sp_filter_text_edit($group->group_desc), false, true); spa_paint_select_start(spa_text('Select Custom Icon'), 'group_icon', ''); spa_select_icon_dropdown('group_icon', spa_text('Select Custom Icon'), SF_STORE_DIR . '/' . $spPaths['custom-icons'] . '/', $group->group_icon, false); spa_paint_select_end(); spa_paint_input(spa_text('Replacement external RSS URL') . '<br />' . spa_text('Default') . ': <strong>' . sp_get_sfqurl(sp_build_url('', '', 0, 0, 0, 1)) . 'group=' . $group->group_id . '</strong>', 'group_rss', sp_filter_url_display($group->group_rss), false, true); spa_paint_wide_textarea('Special group message to be displayed above forums', 'group_message', sp_filter_text_edit($group->group_message)); do_action('sph_forums_edit_group_panel'); spa_paint_close_fieldset(); echo '<div class="sfoptionerror spaceabove">'; echo sprintf(sp_text('To re-order your Groups, Forums and SubForums use the %s Order Groups and Forums %s option from the Forums Menu'), '<b>', '</b>'); echo '</div>'; spa_paint_close_panel(); spa_paint_tab_right_cell(); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Default User Group Permissions'), false); echo '<strong>' . spa_text('Set default usergroup permission sets for this group') . '</strong><br />'; echo spa_text('Note - This will not will add or modify any current permissions. It is only a default setting for future forums created in this group. Existing default usergroup settings will be shown in the drop down menus'); # Permissions $usergroups = spa_get_usergroups_all(); $roles = sp_get_all_roles(); foreach ($usergroups as $usergroup) { echo '<input type="hidden" name="usergroup_id[]" value="' . $usergroup->usergroup_id . '" />'; spa_paint_select_start(sp_filter_title_display($usergroup->usergroup_name), 'role[]', ''); $defrole = spa_get_defpermissions_role($group->group_id, $usergroup->usergroup_id); if ($defrole == -1 || $defrole == '') { echo '<option value="-1">' . spa_text('Select permission set') . '</option>'; } foreach ($roles as $role) { $selected = ''; if ($defrole == $role->role_id) { $selected = 'selected="selected" '; } echo '<option ' . $selected . 'value="' . $role->role_id . '">' . sp_filter_title_display($role->role_name) . '</option>' . "\n"; } spa_paint_select_end(); } spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="groupedit<?php echo $group->group_id; ?> " name="groupedit<?php echo $group->group_id; ?> " value="<?php spa_etext('Update Group'); ?> " /> <input type="button" class="button-primary" onclick="javascript:jQuery('#group-<?php echo $group->group_id; ?> ').html('');jQuery('#grouprow-<?php echo $group_id; ?> ').removeClass('inForm');" id="sfgroupedit<?php echo $group->group_id; ?> " name="groupeditcancel<?php echo $group->group_id; ?> " value="<?php spa_etext('Cancel'); ?> " /> </div> </form> <?php spa_paint_close_tab(); ?> <div class="sfform-panel-spacer"></div> <?php }
function spa_save_forums_edit_group() { check_admin_referer('forum-adminform_groupedit', 'forum-adminform_groupedit'); $groupdata = array(); $group_id = sp_esc_int($_POST['group_id']); $groupdata['group_name'] = sp_filter_title_save(trim($_POST['group_name'])); $groupdata['group_desc'] = sp_filter_text_save(trim($_POST['group_desc'])); $groupdata['group_message'] = sp_filter_text_save(trim($_POST['group_message'])); $ug_list = array_unique($_POST['usergroup_id']); $perm_list = $_POST['role']; if (!empty($_POST['group_icon'])) { # Check new icon exists $groupdata['group_icon'] = sp_filter_title_save(trim($_POST['group_icon'])); $path = SFCUSTOMDIR . $groupdata['group_icon']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $groupdata['group_icon']); return $mess; } } else { $groupdata['group_icon'] = null; } if (isset($_POST['group_rss'])) { $groupdata['group_rss'] = sp_filter_save_cleanurl($_POST['group_rss']); } else { $groupdata['group_rss'] = sp_filter_save_cleanurl($_POST['cgroup_rss']); } # save the default permissions for the group for ($x = 0; $x < count($ug_list); $x++) { $ug = sp_esc_int($ug_list[$x]); $perm = sp_esc_int($perm_list[$x]); if (spa_get_defpermissions_role($group_id, $ug)) { $sql = 'UPDATE ' . SFDEFPERMISSIONS . "\n\t\t\t\t\tSET permission_role={$perm}\n\t\t\t\t\tWHERE group_id={$group_id} AND usergroup_id={$ug}"; spdb_query($sql); } else { if ($perm != -1) { spa_add_defpermission_row($group_id, $ug, $perm); } } } if ($groupdata['group_name'] == $_POST['cgroup_name'] && $groupdata['group_desc'] == $_POST['cgroup_desc'] && $groupdata['group_rss'] == $_POST['cgroup_rss'] && $groupdata['group_message'] == $_POST['cgroup_message'] && $groupdata['group_icon'] == $_POST['cgroup_icon']) { $mess = spa_text('No data changed'); } else { $sql = 'UPDATE ' . SFGROUPS . ' SET '; $sql .= 'group_name="' . $groupdata['group_name'] . '", '; $sql .= 'group_desc="' . $groupdata['group_desc'] . '", '; $sql .= 'group_icon="' . $groupdata['group_icon'] . '", '; $sql .= 'group_rss="' . $groupdata['group_rss'] . '", '; $sql .= 'group_message="' . $groupdata['group_message'] . '" '; $sql .= "WHERE group_id={$group_id}"; $success = spdb_query($sql); if ($success == false) { $mess = spa_text('Group record update failed'); do_action('sph_forum_group_edit', $group_id); } else { $mess = spa_text('Forum group record updated'); } } # clear out group cache tpo enable change_user sp_flush_cache('group'); return $mess; }