[1] | 1 | <?php |
---|
| 2 | |
---|
[3] | 3 | /** |
---|
| 4 | * Copyright (C) 2008-2011 FluxBB |
---|
| 5 | * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
---|
| 6 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
---|
| 7 | */ |
---|
[1] | 8 | |
---|
| 9 | // Tell header.php to use the admin template |
---|
| 10 | define('PUN_ADMIN_CONSOLE', 1); |
---|
| 11 | |
---|
[3] | 12 | define('PUN_ROOT', dirname(__FILE__).'/'); |
---|
[1] | 13 | require PUN_ROOT.'include/common.php'; |
---|
| 14 | require PUN_ROOT.'include/common_admin.php'; |
---|
| 15 | |
---|
| 16 | |
---|
[3] | 17 | if ($pun_user['g_id'] != PUN_ADMIN) |
---|
[1] | 18 | message($lang_common['No permission']); |
---|
| 19 | |
---|
[3] | 20 | // Load the admin_censoring.php language file |
---|
| 21 | require PUN_ROOT.'lang/'.$admin_language.'/admin_groups.php'; |
---|
[1] | 22 | |
---|
| 23 | // Add/edit a group (stage 1) |
---|
| 24 | if (isset($_POST['add_group']) || isset($_GET['edit_group'])) |
---|
| 25 | { |
---|
| 26 | if (isset($_POST['add_group'])) |
---|
| 27 | { |
---|
| 28 | $base_group = intval($_POST['base_group']); |
---|
| 29 | |
---|
[3] | 30 | $result = $db->query('SELECT * FROM '.$db->prefix.'groups WHERE g_id='.$base_group) or error('Unable to fetch user group info', __FILE__, __LINE__, $db->error()); |
---|
[1] | 31 | $group = $db->fetch_assoc($result); |
---|
| 32 | |
---|
| 33 | $mode = 'add'; |
---|
| 34 | } |
---|
[3] | 35 | else // We are editing a group |
---|
[1] | 36 | { |
---|
| 37 | $group_id = intval($_GET['edit_group']); |
---|
| 38 | if ($group_id < 1) |
---|
| 39 | message($lang_common['Bad request']); |
---|
| 40 | |
---|
[3] | 41 | $result = $db->query('SELECT * FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch user group info', __FILE__, __LINE__, $db->error()); |
---|
[1] | 42 | if (!$db->num_rows($result)) |
---|
| 43 | message($lang_common['Bad request']); |
---|
| 44 | |
---|
| 45 | $group = $db->fetch_assoc($result); |
---|
| 46 | |
---|
| 47 | $mode = 'edit'; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
[3] | 51 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
---|
| 52 | $required_fields = array('req_title' => $lang_admin_groups['Group title label']); |
---|
[1] | 53 | $focus_element = array('groups2', 'req_title'); |
---|
[3] | 54 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
[1] | 55 | require PUN_ROOT.'header.php'; |
---|
| 56 | |
---|
| 57 | generate_admin_menu('groups'); |
---|
| 58 | |
---|
| 59 | ?> |
---|
| 60 | <div class="blockform"> |
---|
[3] | 61 | <h2><span><?php echo $lang_admin_groups['Group settings head'] ?></span></h2> |
---|
[1] | 62 | <div class="box"> |
---|
| 63 | <form id="groups2" method="post" action="admin_groups.php" onsubmit="return process_form(this)"> |
---|
[3] | 64 | <p class="submittop"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" /></p> |
---|
[1] | 65 | <div class="inform"> |
---|
| 66 | <input type="hidden" name="mode" value="<?php echo $mode ?>" /> |
---|
[3] | 67 | <?php if ($mode == 'edit'): ?> <input type="hidden" name="group_id" value="<?php echo $group_id ?>" /> |
---|
| 68 | <?php endif; ?><?php if ($mode == 'add'): ?> <input type="hidden" name="base_group" value="<?php echo $base_group ?>" /> |
---|
[1] | 69 | <?php endif; ?> <fieldset> |
---|
[3] | 70 | <legend><?php echo $lang_admin_groups['Group settings subhead'] ?></legend> |
---|
[1] | 71 | <div class="infldset"> |
---|
[3] | 72 | <p><?php echo $lang_admin_groups['Group settings info'] ?></p> |
---|
[1] | 73 | <table class="aligntop" cellspacing="0"> |
---|
| 74 | <tr> |
---|
[3] | 75 | <th scope="row"><?php echo $lang_admin_groups['Group title label'] ?></th> |
---|
[1] | 76 | <td> |
---|
| 77 | <input type="text" name="req_title" size="25" maxlength="50" value="<?php if ($mode == 'edit') echo pun_htmlspecialchars($group['g_title']); ?>" tabindex="1" /> |
---|
| 78 | </td> |
---|
| 79 | </tr> |
---|
| 80 | <tr> |
---|
[3] | 81 | <th scope="row"><?php echo $lang_admin_groups['User title label'] ?></th> |
---|
[1] | 82 | <td> |
---|
| 83 | <input type="text" name="user_title" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($group['g_user_title']) ?>" tabindex="2" /> |
---|
[3] | 84 | <span><?php echo $lang_admin_groups['User title help'] ?></span> |
---|
[1] | 85 | </td> |
---|
| 86 | </tr> |
---|
[3] | 87 | <?php if ($group['g_id'] != PUN_ADMIN): if ($group['g_id'] != PUN_GUEST): if ($mode != 'edit' || $pun_config['o_default_user_group'] != $group['g_id']): ?> <tr> |
---|
| 88 | <th scope="row"> <?php echo $lang_admin_groups['Mod privileges label'] ?></th> |
---|
[1] | 89 | <td> |
---|
[3] | 90 | <input type="radio" name="moderator" value="1"<?php if ($group['g_moderator'] == '1') echo ' checked="checked"' ?> tabindex="3" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="moderator" value="0"<?php if ($group['g_moderator'] == '0') echo ' checked="checked"' ?> tabindex="4" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 91 | <span><?php echo $lang_admin_groups['Mod privileges help'] ?></span> |
---|
[1] | 92 | </td> |
---|
| 93 | </tr> |
---|
| 94 | <tr> |
---|
[3] | 95 | <th scope="row"><?php echo $lang_admin_groups['Edit profile label'] ?></th> |
---|
[1] | 96 | <td> |
---|
[3] | 97 | <input type="radio" name="mod_edit_users" value="1"<?php if ($group['g_mod_edit_users'] == '1') echo ' checked="checked"' ?> tabindex="5" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_edit_users" value="0"<?php if ($group['g_mod_edit_users'] == '0') echo ' checked="checked"' ?> tabindex="6" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 98 | <span><?php echo $lang_admin_groups['Edit profile help'] ?></span> |
---|
[1] | 99 | </td> |
---|
| 100 | </tr> |
---|
| 101 | <tr> |
---|
[3] | 102 | <th scope="row"><?php echo $lang_admin_groups['Rename users label'] ?></th> |
---|
[1] | 103 | <td> |
---|
[3] | 104 | <input type="radio" name="mod_rename_users" value="1"<?php if ($group['g_mod_rename_users'] == '1') echo ' checked="checked"' ?> tabindex="7" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_rename_users" value="0"<?php if ($group['g_mod_rename_users'] == '0') echo ' checked="checked"' ?> tabindex="8" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 105 | <span><?php echo $lang_admin_groups['Rename users help'] ?></span> |
---|
[1] | 106 | </td> |
---|
| 107 | </tr> |
---|
[3] | 108 | <tr> |
---|
| 109 | <th scope="row"><?php echo $lang_admin_groups['Change passwords label'] ?></th> |
---|
| 110 | <td> |
---|
| 111 | <input type="radio" name="mod_change_passwords" value="1"<?php if ($group['g_mod_change_passwords'] == '1') echo ' checked="checked"' ?> tabindex="9" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_change_passwords" value="0"<?php if ($group['g_mod_change_passwords'] == '0') echo ' checked="checked"' ?> tabindex="10" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 112 | <span><?php echo $lang_admin_groups['Change passwords help'] ?></span> |
---|
| 113 | </td> |
---|
| 114 | </tr> |
---|
| 115 | <tr> |
---|
| 116 | <th scope="row"><?php echo $lang_admin_groups['Ban users label'] ?></th> |
---|
| 117 | <td> |
---|
| 118 | <input type="radio" name="mod_ban_users" value="1"<?php if ($group['g_mod_ban_users'] == '1') echo ' checked="checked"' ?> tabindex="11" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_ban_users" value="0"<?php if ($group['g_mod_ban_users'] == '0') echo ' checked="checked"' ?> tabindex="12" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 119 | <span><?php echo $lang_admin_groups['Ban users help'] ?></span> |
---|
| 120 | </td> |
---|
| 121 | </tr> |
---|
| 122 | <?php endif; endif; ?> <tr> |
---|
| 123 | <th scope="row"><?php echo $lang_admin_groups['Read board label'] ?></th> |
---|
| 124 | <td> |
---|
| 125 | <input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1') echo ' checked="checked"' ?> tabindex="13" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '0') echo ' checked="checked"' ?> tabindex="14" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 126 | <span><?php echo $lang_admin_groups['Read board help'] ?></span> |
---|
| 127 | </td> |
---|
| 128 | </tr> |
---|
| 129 | <tr> |
---|
| 130 | <th scope="row"><?php echo $lang_admin_groups['View user info label'] ?></th> |
---|
| 131 | <td> |
---|
| 132 | <input type="radio" name="view_users" value="1"<?php if ($group['g_view_users'] == '1') echo ' checked="checked"' ?> tabindex="15" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="view_users" value="0"<?php if ($group['g_view_users'] == '0') echo ' checked="checked"' ?> tabindex="16" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 133 | <span><?php echo $lang_admin_groups['View user info help'] ?></span> |
---|
| 134 | </td> |
---|
| 135 | </tr> |
---|
| 136 | <tr> |
---|
| 137 | <th scope="row"><?php echo $lang_admin_groups['Post replies label'] ?></th> |
---|
| 138 | <td> |
---|
| 139 | <input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '1') echo ' checked="checked"' ?> tabindex="17" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="post_replies" value="0"<?php if ($group['g_post_replies'] == '0') echo ' checked="checked"' ?> tabindex="18" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 140 | <span><?php echo $lang_admin_groups['Post replies help'] ?></span> |
---|
| 141 | </td> |
---|
| 142 | </tr> |
---|
| 143 | <tr> |
---|
| 144 | <th scope="row"><?php echo $lang_admin_groups['Post topics label'] ?></th> |
---|
| 145 | <td> |
---|
| 146 | <input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1') echo ' checked="checked"' ?> tabindex="19" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '0') echo ' checked="checked"' ?> tabindex="20" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 147 | <span><?php echo $lang_admin_groups['Post topics help'] ?></span> |
---|
| 148 | </td> |
---|
| 149 | </tr> |
---|
[1] | 150 | <?php if ($group['g_id'] != PUN_GUEST): ?> <tr> |
---|
[3] | 151 | <th scope="row"><?php echo $lang_admin_groups['Edit posts label'] ?></th> |
---|
[1] | 152 | <td> |
---|
[3] | 153 | <input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_posts'] == '1') echo ' checked="checked"' ?> tabindex="21" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="edit_posts" value="0"<?php if ($group['g_edit_posts'] == '0') echo ' checked="checked"' ?> tabindex="22" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 154 | <span><?php echo $lang_admin_groups['Edit posts help'] ?></span> |
---|
[1] | 155 | </td> |
---|
| 156 | </tr> |
---|
| 157 | <tr> |
---|
[3] | 158 | <th scope="row"><?php echo $lang_admin_groups['Delete posts label'] ?></th> |
---|
[1] | 159 | <td> |
---|
[3] | 160 | <input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '1') echo ' checked="checked"' ?> tabindex="23" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="delete_posts" value="0"<?php if ($group['g_delete_posts'] == '0') echo ' checked="checked"' ?> tabindex="24" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 161 | <span><?php echo $lang_admin_groups['Delete posts help'] ?></span> |
---|
[1] | 162 | </td> |
---|
| 163 | </tr> |
---|
| 164 | <tr> |
---|
[3] | 165 | <th scope="row"><?php echo $lang_admin_groups['Delete topics label'] ?></th> |
---|
[1] | 166 | <td> |
---|
[3] | 167 | <input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1') echo ' checked="checked"' ?> tabindex="25" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '0') echo ' checked="checked"' ?> tabindex="26" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 168 | <span><?php echo $lang_admin_groups['Delete topics help'] ?></span> |
---|
[1] | 169 | </td> |
---|
| 170 | </tr> |
---|
| 171 | <tr> |
---|
[3] | 172 | <th scope="row"><?php echo $lang_admin_groups['Set own title label'] ?></th> |
---|
[1] | 173 | <td> |
---|
[3] | 174 | <input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1') echo ' checked="checked"' ?> tabindex="27" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '0') echo ' checked="checked"' ?> tabindex="28" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 175 | <span><?php echo $lang_admin_groups['Set own title help'] ?></span> |
---|
[1] | 176 | </td> |
---|
| 177 | </tr> |
---|
| 178 | <?php endif; ?> <tr> |
---|
[3] | 179 | <th scope="row"><?php echo $lang_admin_groups['User search label'] ?></th> |
---|
[1] | 180 | <td> |
---|
[3] | 181 | <input type="radio" name="search" value="1"<?php if ($group['g_search'] == '1') echo ' checked="checked"' ?> tabindex="29" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="search" value="0"<?php if ($group['g_search'] == '0') echo ' checked="checked"' ?> tabindex="30" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 182 | <span><?php echo $lang_admin_groups['User search help'] ?></span> |
---|
[1] | 183 | </td> |
---|
| 184 | </tr> |
---|
| 185 | <tr> |
---|
[3] | 186 | <th scope="row"><?php echo $lang_admin_groups['User list search label'] ?></th> |
---|
[1] | 187 | <td> |
---|
[3] | 188 | <input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1') echo ' checked="checked"' ?> tabindex="31" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '0') echo ' checked="checked"' ?> tabindex="32" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 189 | <span><?php echo $lang_admin_groups['User list search help'] ?></span> |
---|
[1] | 190 | </td> |
---|
| 191 | </tr> |
---|
| 192 | <?php if ($group['g_id'] != PUN_GUEST): ?> <tr> |
---|
[3] | 193 | <th scope="row"><?php echo $lang_admin_groups['Send e-mails label'] ?></th> |
---|
[1] | 194 | <td> |
---|
[3] | 195 | <input type="radio" name="send_email" value="1"<?php if ($group['g_send_email'] == '1') echo ' checked="checked"' ?> tabindex="33" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="send_email" value="0"<?php if ($group['g_send_email'] == '0') echo ' checked="checked"' ?> tabindex="34" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
| 196 | <span><?php echo $lang_admin_groups['Send e-mails help'] ?></span> |
---|
[1] | 197 | </td> |
---|
| 198 | </tr> |
---|
[3] | 199 | <?php endif; ?> <tr> |
---|
| 200 | <th scope="row"><?php echo $lang_admin_groups['Post flood label'] ?></th> |
---|
| 201 | <td> |
---|
| 202 | <input type="text" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="35" /> |
---|
| 203 | <span><?php echo $lang_admin_groups['Post flood help'] ?></span> |
---|
| 204 | </td> |
---|
| 205 | </tr> |
---|
[1] | 206 | <tr> |
---|
[3] | 207 | <th scope="row"><?php echo $lang_admin_groups['Search flood label'] ?></th> |
---|
[1] | 208 | <td> |
---|
[3] | 209 | <input type="text" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="36" /> |
---|
| 210 | <span><?php echo $lang_admin_groups['Search flood help'] ?></span> |
---|
[1] | 211 | </td> |
---|
| 212 | </tr> |
---|
[3] | 213 | <?php if ($group['g_id'] != PUN_GUEST): ?> <tr> |
---|
| 214 | <th scope="row"><?php echo $lang_admin_groups['E-mail flood label'] ?></th> |
---|
| 215 | <td> |
---|
| 216 | <input type="text" name="email_flood" size="5" maxlength="4" value="<?php echo $group['g_email_flood'] ?>" tabindex="37" /> |
---|
| 217 | <span><?php echo $lang_admin_groups['E-mail flood help'] ?></span> |
---|
| 218 | </td> |
---|
| 219 | </tr> |
---|
[1] | 220 | <tr> |
---|
[3] | 221 | <th scope="row"><?php echo $lang_admin_groups['Report flood label'] ?></th> |
---|
[1] | 222 | <td> |
---|
[3] | 223 | <input type="text" name="report_flood" size="5" maxlength="4" value="<?php echo $group['g_report_flood'] ?>" tabindex="38" /> |
---|
| 224 | <span><?php echo $lang_admin_groups['Report flood help'] ?></span> |
---|
[1] | 225 | </td> |
---|
| 226 | </tr> |
---|
[3] | 227 | <?php endif; endif; ?> </table> |
---|
| 228 | <?php if ($group['g_moderator'] == '1' ): ?> <p class="warntext"><?php echo $lang_admin_groups['Moderator info'] ?></p> |
---|
[1] | 229 | <?php endif; ?> </div> |
---|
| 230 | </fieldset> |
---|
| 231 | </div> |
---|
[3] | 232 | <p class="submitend"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="39" /></p> |
---|
[1] | 233 | </form> |
---|
| 234 | </div> |
---|
| 235 | </div> |
---|
| 236 | <div class="clearer"></div> |
---|
| 237 | </div> |
---|
| 238 | <?php |
---|
| 239 | |
---|
| 240 | require PUN_ROOT.'footer.php'; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | // Add/edit a group (stage 2) |
---|
| 245 | else if (isset($_POST['add_edit_group'])) |
---|
| 246 | { |
---|
| 247 | confirm_referrer('admin_groups.php'); |
---|
| 248 | |
---|
| 249 | // Is this the admin group? (special rules apply) |
---|
| 250 | $is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == PUN_ADMIN) ? true : false; |
---|
| 251 | |
---|
[3] | 252 | $title = pun_trim($_POST['req_title']); |
---|
| 253 | $user_title = pun_trim($_POST['user_title']); |
---|
| 254 | $moderator = isset($_POST['moderator']) && $_POST['moderator'] == '1' ? '1' : '0'; |
---|
| 255 | $mod_edit_users = $moderator == '1' && isset($_POST['mod_edit_users']) && $_POST['mod_edit_users'] == '1' ? '1' : '0'; |
---|
| 256 | $mod_rename_users = $moderator == '1' && isset($_POST['mod_rename_users']) && $_POST['mod_rename_users'] == '1' ? '1' : '0'; |
---|
| 257 | $mod_change_passwords = $moderator == '1' && isset($_POST['mod_change_passwords']) && $_POST['mod_change_passwords'] == '1' ? '1' : '0'; |
---|
| 258 | $mod_ban_users = $moderator == '1' && isset($_POST['mod_ban_users']) && $_POST['mod_ban_users'] == '1' ? '1' : '0'; |
---|
[1] | 259 | $read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1'; |
---|
[3] | 260 | $view_users = (isset($_POST['view_users']) && $_POST['view_users'] == '1') || $is_admin_group ? '1' : '0'; |
---|
[1] | 261 | $post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1'; |
---|
| 262 | $post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1'; |
---|
| 263 | $edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0'; |
---|
| 264 | $delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0'; |
---|
| 265 | $delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0'; |
---|
| 266 | $set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0'; |
---|
| 267 | $search = isset($_POST['search']) ? intval($_POST['search']) : '1'; |
---|
| 268 | $search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1'; |
---|
[3] | 269 | $send_email = (isset($_POST['send_email']) && $_POST['send_email'] == '1') || $is_admin_group ? '1' : '0'; |
---|
[1] | 270 | $post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0'; |
---|
| 271 | $search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0'; |
---|
[3] | 272 | $email_flood = isset($_POST['email_flood']) ? intval($_POST['email_flood']) : '0'; |
---|
| 273 | $report_flood = isset($_POST['report_flood']) ? intval($_POST['report_flood']) : '0'; |
---|
[1] | 274 | |
---|
| 275 | if ($title == '') |
---|
[3] | 276 | message($lang_admin_groups['Must enter title message']); |
---|
[1] | 277 | |
---|
| 278 | $user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL'; |
---|
| 279 | |
---|
| 280 | if ($_POST['mode'] == 'add') |
---|
| 281 | { |
---|
[3] | 282 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\'') or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); |
---|
[1] | 283 | if ($db->num_rows($result)) |
---|
[3] | 284 | message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title))); |
---|
[1] | 285 | |
---|
[3] | 286 | $db->query('INSERT INTO '.$db->prefix.'groups (g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES(\''.$db->escape($title).'\', '.$user_title.', '.$moderator.', '.$mod_edit_users.', '.$mod_rename_users.', '.$mod_change_passwords.', '.$mod_ban_users.', '.$read_board.', '.$view_users.', '.$post_replies.', '.$post_topics.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$set_title.', '.$search.', '.$search_users.', '.$send_email.', '.$post_flood.', '.$search_flood.', '.$email_flood.', '.$report_flood.')') or error('Unable to add group', __FILE__, __LINE__, $db->error()); |
---|
[1] | 287 | $new_group_id = $db->insert_id(); |
---|
| 288 | |
---|
| 289 | // Now lets copy the forum specific permissions from the group which this group is based on |
---|
[3] | 290 | $result = $db->query('SELECT forum_id, read_forum, post_replies, post_topics FROM '.$db->prefix.'forum_perms WHERE group_id='.intval($_POST['base_group'])) or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error()); |
---|
[1] | 291 | while ($cur_forum_perm = $db->fetch_assoc($result)) |
---|
[3] | 292 | $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$new_group_id.', '.$cur_forum_perm['forum_id'].', '.$cur_forum_perm['read_forum'].', '.$cur_forum_perm['post_replies'].', '.$cur_forum_perm['post_topics'].')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
[1] | 293 | } |
---|
| 294 | else |
---|
| 295 | { |
---|
[3] | 296 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\' AND g_id!='.intval($_POST['group_id'])) or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); |
---|
[1] | 297 | if ($db->num_rows($result)) |
---|
[3] | 298 | message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title))); |
---|
[1] | 299 | |
---|
[3] | 300 | $db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_moderator='.$moderator.', g_mod_edit_users='.$mod_edit_users.', g_mod_rename_users='.$mod_rename_users.', g_mod_change_passwords='.$mod_change_passwords.', g_mod_ban_users='.$mod_ban_users.', g_read_board='.$read_board.', g_view_users='.$view_users.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_send_email='.$send_email.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.', g_email_flood='.$email_flood.', g_report_flood='.$report_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error()); |
---|
[1] | 301 | } |
---|
| 302 | |
---|
[3] | 303 | // Regenerate the quick jump cache |
---|
| 304 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
| 305 | require PUN_ROOT.'include/cache.php'; |
---|
[1] | 306 | |
---|
[3] | 307 | $group_id = $_POST['mode'] == 'add' ? $new_group_id : intval($_POST['group_id']); |
---|
| 308 | generate_quickjump_cache($group_id); |
---|
| 309 | |
---|
| 310 | if ($_POST['mode'] == 'edit') |
---|
| 311 | redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']); |
---|
| 312 | else |
---|
| 313 | redirect('admin_groups.php', $lang_admin_groups['Group added redirect']); |
---|
[1] | 314 | } |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | // Set default group |
---|
| 318 | else if (isset($_POST['set_default_group'])) |
---|
| 319 | { |
---|
| 320 | confirm_referrer('admin_groups.php'); |
---|
| 321 | |
---|
| 322 | $group_id = intval($_POST['default_group']); |
---|
[3] | 323 | |
---|
| 324 | // Make sure it's not the admin or guest groups |
---|
| 325 | if ($group_id == PUN_ADMIN || $group_id == PUN_GUEST) |
---|
[1] | 326 | message($lang_common['Bad request']); |
---|
| 327 | |
---|
[3] | 328 | // Make sure it's not a moderator group |
---|
| 329 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_id='.$group_id.' AND g_moderator=0') or error('Unable to check group moderator status', __FILE__, __LINE__, $db->error()); |
---|
| 330 | if (!$db->num_rows($result)) |
---|
| 331 | message($lang_common['Bad request']); |
---|
[1] | 332 | |
---|
[3] | 333 | $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); |
---|
| 334 | |
---|
[1] | 335 | // Regenerate the config cache |
---|
[3] | 336 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
| 337 | require PUN_ROOT.'include/cache.php'; |
---|
| 338 | |
---|
[1] | 339 | generate_config_cache(); |
---|
| 340 | |
---|
[3] | 341 | redirect('admin_groups.php', $lang_admin_groups['Default group redirect']); |
---|
[1] | 342 | } |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | // Remove a group |
---|
| 346 | else if (isset($_GET['del_group'])) |
---|
| 347 | { |
---|
| 348 | confirm_referrer('admin_groups.php'); |
---|
| 349 | |
---|
[3] | 350 | $group_id = isset($_POST['group_to_delete']) ? intval($_POST['group_to_delete']) : intval($_GET['del_group']); |
---|
[1] | 351 | if ($group_id < 5) |
---|
| 352 | message($lang_common['Bad request']); |
---|
| 353 | |
---|
| 354 | // Make sure we don't remove the default group |
---|
| 355 | if ($group_id == $pun_config['o_default_user_group']) |
---|
[3] | 356 | message($lang_admin_groups['Cannot remove default message']); |
---|
[1] | 357 | |
---|
| 358 | // Check if this group has any members |
---|
[3] | 359 | $result = $db->query('SELECT g.g_title, COUNT(u.id) FROM '.$db->prefix.'groups AS g INNER JOIN '.$db->prefix.'users AS u ON g.g_id=u.group_id WHERE g.g_id='.$group_id.' GROUP BY g.g_id, g_title') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
---|
[1] | 360 | |
---|
| 361 | // If the group doesn't have any members or if we've already selected a group to move the members to |
---|
| 362 | if (!$db->num_rows($result) || isset($_POST['del_group'])) |
---|
| 363 | { |
---|
[3] | 364 | if (isset($_POST['del_group_comply']) || isset($_POST['del_group'])) |
---|
[1] | 365 | { |
---|
[3] | 366 | if (isset($_POST['del_group'])) |
---|
| 367 | { |
---|
| 368 | $move_to_group = intval($_POST['move_to_group']); |
---|
| 369 | $db->query('UPDATE '.$db->prefix.'users SET group_id='.$move_to_group.' WHERE group_id='.$group_id) or error('Unable to move users into group', __FILE__, __LINE__, $db->error()); |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | // Delete the group and any forum specific permissions |
---|
| 373 | $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error()); |
---|
| 374 | $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
| 375 | |
---|
| 376 | redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']); |
---|
[1] | 377 | } |
---|
[3] | 378 | else |
---|
| 379 | { |
---|
| 380 | $result = $db->query('SELECT g_title FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group title', __FILE__, __LINE__, $db->error()); |
---|
| 381 | $group_title = $db->result($result); |
---|
[1] | 382 | |
---|
[3] | 383 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
---|
| 384 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
| 385 | require PUN_ROOT.'header.php'; |
---|
[1] | 386 | |
---|
[3] | 387 | generate_admin_menu('groups'); |
---|
[1] | 388 | |
---|
[3] | 389 | ?> |
---|
| 390 | <div class="blockform"> |
---|
| 391 | <h2><span><?php echo $lang_admin_groups['Group delete head'] ?></span></h2> |
---|
| 392 | <div class="box"> |
---|
| 393 | <form method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>"> |
---|
| 394 | <div class="inform"> |
---|
| 395 | <input type="hidden" name="group_to_delete" value="<?php echo $group_id ?>" /> |
---|
| 396 | <fieldset> |
---|
| 397 | <legend><?php echo $lang_admin_groups['Confirm delete subhead'] ?></legend> |
---|
| 398 | <div class="infldset"> |
---|
| 399 | <p><?php printf($lang_admin_groups['Confirm delete info'], pun_htmlspecialchars($group_title)) ?></p> |
---|
| 400 | <p class="warntext"><?php echo $lang_admin_groups['Confirm delete warn'] ?></p> |
---|
| 401 | </div> |
---|
| 402 | </fieldset> |
---|
| 403 | </div> |
---|
| 404 | <p class="buttons"><input type="submit" name="del_group_comply" value="<?php echo $lang_admin_common['Delete'] ?>" tabindex="1" /><a href="javascript:history.go(-1)" tabindex="2"><?php echo $lang_admin_common['Go back'] ?></a></p> |
---|
| 405 | </form> |
---|
| 406 | </div> |
---|
| 407 | </div> |
---|
| 408 | <div class="clearer"></div> |
---|
| 409 | </div> |
---|
| 410 | <?php |
---|
| 411 | |
---|
| 412 | require PUN_ROOT.'footer.php'; |
---|
| 413 | } |
---|
[1] | 414 | } |
---|
| 415 | |
---|
| 416 | list($group_title, $group_members) = $db->fetch_row($result); |
---|
| 417 | |
---|
[3] | 418 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
---|
| 419 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
[1] | 420 | require PUN_ROOT.'header.php'; |
---|
| 421 | |
---|
| 422 | generate_admin_menu('groups'); |
---|
| 423 | |
---|
| 424 | ?> |
---|
| 425 | <div class="blockform"> |
---|
[3] | 426 | <h2><span><?php echo $lang_admin_groups['Delete group head'] ?></span></h2> |
---|
[1] | 427 | <div class="box"> |
---|
| 428 | <form id="groups" method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>"> |
---|
| 429 | <div class="inform"> |
---|
| 430 | <fieldset> |
---|
[3] | 431 | <legend><?php echo $lang_admin_groups['Move users subhead'] ?></legend> |
---|
[1] | 432 | <div class="infldset"> |
---|
[3] | 433 | <p><?php printf($lang_admin_groups['Move users info'], pun_htmlspecialchars($group_title), forum_number_format($group_members)) ?></p> |
---|
| 434 | <label><?php echo $lang_admin_groups['Move users label'] ?> |
---|
[1] | 435 | <select name="move_to_group"> |
---|
| 436 | <?php |
---|
| 437 | |
---|
[3] | 438 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' AND g_id!='.$group_id.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
---|
[1] | 439 | |
---|
| 440 | while ($cur_group = $db->fetch_assoc($result)) |
---|
| 441 | { |
---|
[3] | 442 | if ($cur_group['g_id'] == PUN_MEMBER) // Pre-select the pre-defined Members group |
---|
[1] | 443 | echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
| 444 | else |
---|
| 445 | echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | ?> |
---|
| 449 | </select> |
---|
[3] | 450 | <br /></label> |
---|
[1] | 451 | </div> |
---|
| 452 | </fieldset> |
---|
| 453 | </div> |
---|
[3] | 454 | <p class="buttons"><input type="submit" name="del_group" value="<?php echo $lang_admin_groups['Delete group'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
---|
[1] | 455 | </form> |
---|
| 456 | </div> |
---|
| 457 | </div> |
---|
| 458 | <div class="clearer"></div> |
---|
| 459 | </div> |
---|
| 460 | <?php |
---|
| 461 | |
---|
| 462 | require PUN_ROOT.'footer.php'; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | |
---|
[3] | 466 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
---|
| 467 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
[1] | 468 | require PUN_ROOT.'header.php'; |
---|
| 469 | |
---|
| 470 | generate_admin_menu('groups'); |
---|
| 471 | |
---|
| 472 | ?> |
---|
| 473 | <div class="blockform"> |
---|
[3] | 474 | <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2> |
---|
[1] | 475 | <div class="box"> |
---|
[3] | 476 | <form id="groups" method="post" action="admin_groups.php"> |
---|
[1] | 477 | <div class="inform"> |
---|
| 478 | <fieldset> |
---|
[3] | 479 | <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend> |
---|
[1] | 480 | <div class="infldset"> |
---|
| 481 | <table class="aligntop" cellspacing="0"> |
---|
| 482 | <tr> |
---|
[3] | 483 | <th scope="row"><?php echo $lang_admin_groups['New group label'] ?><div><input type="submit" name="add_group" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="2" /></div></th> |
---|
[1] | 484 | <td> |
---|
| 485 | <select id="base_group" name="base_group" tabindex="1"> |
---|
| 486 | <?php |
---|
| 487 | |
---|
[3] | 488 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN.' AND g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
---|
[1] | 489 | |
---|
| 490 | while ($cur_group = $db->fetch_assoc($result)) |
---|
| 491 | { |
---|
| 492 | if ($cur_group['g_id'] == $pun_config['o_default_user_group']) |
---|
| 493 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
| 494 | else |
---|
| 495 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | ?> |
---|
| 499 | </select> |
---|
[3] | 500 | <span><?php echo $lang_admin_groups['New group help'] ?></span> |
---|
[1] | 501 | </td> |
---|
| 502 | </tr> |
---|
| 503 | </table> |
---|
| 504 | </div> |
---|
| 505 | </fieldset> |
---|
| 506 | </div> |
---|
| 507 | <div class="inform"> |
---|
| 508 | <fieldset> |
---|
[3] | 509 | <legend><?php echo $lang_admin_groups['Default group subhead'] ?></legend> |
---|
[1] | 510 | <div class="infldset"> |
---|
| 511 | <table class="aligntop" cellspacing="0"> |
---|
| 512 | <tr> |
---|
[3] | 513 | <th scope="row"><?php echo $lang_admin_groups['Default group label'] ?><div><input type="submit" name="set_default_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="4" /></div></th> |
---|
[1] | 514 | <td> |
---|
| 515 | <select id="default_group" name="default_group" tabindex="3"> |
---|
| 516 | <?php |
---|
| 517 | |
---|
[3] | 518 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id>'.PUN_GUEST.' AND g_moderator=0 ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
---|
[1] | 519 | |
---|
| 520 | while ($cur_group = $db->fetch_assoc($result)) |
---|
| 521 | { |
---|
| 522 | if ($cur_group['g_id'] == $pun_config['o_default_user_group']) |
---|
| 523 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
| 524 | else |
---|
| 525 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | ?> |
---|
| 529 | </select> |
---|
[3] | 530 | <span><?php echo $lang_admin_groups['Default group help'] ?></span> |
---|
[1] | 531 | </td> |
---|
| 532 | </tr> |
---|
| 533 | </table> |
---|
| 534 | </div> |
---|
| 535 | </fieldset> |
---|
| 536 | </div> |
---|
| 537 | </form> |
---|
| 538 | </div> |
---|
| 539 | |
---|
[3] | 540 | <h2 class="block2"><span><?php echo $lang_admin_groups['Existing groups head'] ?></span></h2> |
---|
[1] | 541 | <div class="box"> |
---|
| 542 | <div class="fakeform"> |
---|
| 543 | <div class="inform"> |
---|
| 544 | <fieldset> |
---|
[3] | 545 | <legend><?php echo $lang_admin_groups['Edit groups subhead'] ?></legend> |
---|
[1] | 546 | <div class="infldset"> |
---|
[3] | 547 | <p><?php echo $lang_admin_groups['Edit groups info'] ?></p> |
---|
[1] | 548 | <table cellspacing="0"> |
---|
| 549 | <?php |
---|
| 550 | |
---|
[3] | 551 | $cur_index = 5; |
---|
[1] | 552 | |
---|
[3] | 553 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups ORDER BY g_id') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
---|
| 554 | |
---|
[1] | 555 | while ($cur_group = $db->fetch_assoc($result)) |
---|
[3] | 556 | echo "\t\t\t\t\t\t\t\t".'<tr><th scope="row"><a href="admin_groups.php?edit_group='.$cur_group['g_id'].'" tabindex="'.$cur_index++.'">'.$lang_admin_groups['Edit link'].'</a>'.(($cur_group['g_id'] > PUN_MEMBER) ? ' | <a href="admin_groups.php?del_group='.$cur_group['g_id'].'" tabindex="'.$cur_index++.'">'.$lang_admin_groups['Delete link'].'</a>' : '').'</th><td>'.pun_htmlspecialchars($cur_group['g_title']).'</td></tr>'."\n"; |
---|
[1] | 557 | |
---|
| 558 | ?> |
---|
| 559 | </table> |
---|
| 560 | </div> |
---|
| 561 | </fieldset> |
---|
| 562 | </div> |
---|
| 563 | </div> |
---|
| 564 | </div> |
---|
| 565 | </div> |
---|
| 566 | <div class="clearer"></div> |
---|
| 567 | </div> |
---|
| 568 | <?php |
---|
| 569 | |
---|
| 570 | require PUN_ROOT.'footer.php'; |
---|