punbb/admin_groups.php
changeset 0 f9ffdbd96607
child 2 a8a21e1c7afa
equal deleted inserted replaced
-1:000000000000 0:f9ffdbd96607
       
     1 <?php
       
     2 /***********************************************************************
       
     3 
       
     4   Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
       
     5 
       
     6   This file is part of PunBB.
       
     7 
       
     8   PunBB is free software; you can redistribute it and/or modify it
       
     9   under the terms of the GNU General Public License as published
       
    10   by the Free Software Foundation; either version 2 of the License,
       
    11   or (at your option) any later version.
       
    12 
       
    13   PunBB is distributed in the hope that it will be useful, but
       
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16   GNU General Public License for more details.
       
    17 
       
    18   You should have received a copy of the GNU General Public License
       
    19   along with this program; if not, write to the Free Software
       
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       
    21   MA  02111-1307  USA
       
    22 
       
    23 ************************************************************************/
       
    24 
       
    25 
       
    26 // Tell header.php to use the admin template
       
    27 define('PUN_ADMIN_CONSOLE', 1);
       
    28 
       
    29 define('PUN_ROOT', './');
       
    30 require PUN_ROOT.'include/common.php';
       
    31 require PUN_ROOT.'include/common_admin.php';
       
    32 
       
    33 
       
    34 if ($pun_user['g_id'] > PUN_ADMIN)
       
    35 	message($lang_common['No permission']);
       
    36 
       
    37 
       
    38 // Add/edit a group (stage 1)
       
    39 if (isset($_POST['add_group']) || isset($_GET['edit_group']))
       
    40 {
       
    41 	if (isset($_POST['add_group']))
       
    42 	{
       
    43 		$base_group = intval($_POST['base_group']);
       
    44 
       
    45 		$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());
       
    46 		$group = $db->fetch_assoc($result);
       
    47 
       
    48 		$mode = 'add';
       
    49 	}
       
    50 	else	// We are editing a group
       
    51 	{
       
    52 		$group_id = intval($_GET['edit_group']);
       
    53 		if ($group_id < 1)
       
    54 			message($lang_common['Bad request']);
       
    55 
       
    56 		$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());
       
    57 		if (!$db->num_rows($result))
       
    58 			message($lang_common['Bad request']);
       
    59 
       
    60 		$group = $db->fetch_assoc($result);
       
    61 
       
    62 		$mode = 'edit';
       
    63 	}
       
    64 
       
    65 
       
    66 	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / User groups';
       
    67 	$required_fields = array('req_title' => 'Group title');
       
    68 	$focus_element = array('groups2', 'req_title');
       
    69 	require PUN_ROOT.'header.php';
       
    70 
       
    71 	generate_admin_menu('groups');
       
    72 
       
    73 ?>
       
    74 	<div class="blockform">
       
    75 		<h2><span>Group settings</span></h2>
       
    76 		<div class="box">
       
    77 			<form id="groups2" method="post" action="admin_groups.php" onsubmit="return process_form(this)">
       
    78 				<p class="submittop"><input type="submit" name="add_edit_group" value=" Save " /></p>
       
    79 				<div class="inform">
       
    80 					<input type="hidden" name="mode" value="<?php echo $mode ?>" />
       
    81 <?php if ($mode == 'edit'): ?>				<input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
       
    82 <?php endif; ?><?php if ($mode == 'add'): ?>				<input type="hidden" name="base_group" value="<?php echo $base_group ?>" />
       
    83 <?php endif; ?>					<fieldset>
       
    84 						<legend>Setup group options and permissions</legend>
       
    85 						<div class="infldset">
       
    86 							<p>Below options and permissions are the default permissions for the user group. These options apply if no forum specific permissions are in effect.</p>
       
    87 							<table class="aligntop" cellspacing="0">
       
    88 								<tr>
       
    89 									<th scope="row">Group title</th>
       
    90 									<td>
       
    91 										<input type="text" name="req_title" size="25" maxlength="50" value="<?php if ($mode == 'edit') echo pun_htmlspecialchars($group['g_title']); ?>" tabindex="1" />
       
    92 									</td>
       
    93 								</tr>
       
    94 								<tr>
       
    95 									<th scope="row">User title</th>
       
    96 									<td>
       
    97 										<input type="text" name="user_title" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($group['g_user_title']) ?>" tabindex="2" />
       
    98 										<span>This title will override any rank users in this group have attained. Leave blank to use default title or rank.</span>
       
    99 									</td>
       
   100 								</tr>
       
   101 <?php if ($group['g_id'] != PUN_ADMIN): ?>								<tr>
       
   102 									<th scope="row">Read board</th>
       
   103 									<td>
       
   104 										<input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1') echo ' checked="checked"' ?> tabindex="3" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '0') echo ' checked="checked"' ?> tabindex="4" />&nbsp;<strong>No</strong>
       
   105 										<span>Allow users in this group to view the board. This setting applies to every aspect of the board and can therefore not be overridden by forum specific settings. If this is set to "No", users in this group will only be able to login/logout and register.</span>
       
   106 									</td>
       
   107 								</tr>
       
   108 								<tr>
       
   109 									<th scope="row">Post replies</th>
       
   110 									<td>
       
   111 										<input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '1') echo ' checked="checked"' ?> tabindex="5" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="post_replies" value="0"<?php if ($group['g_post_replies'] == '0') echo ' checked="checked"' ?> tabindex="6" />&nbsp;<strong>No</strong>
       
   112 										<span>Allow users in this group to post replies in topics.</span>
       
   113 									</td>
       
   114 								</tr>
       
   115 								<tr>
       
   116 									<th scope="row">Post topics</th>
       
   117 									<td>
       
   118 										<input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1') echo ' checked="checked"' ?> tabindex="7" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '0') echo ' checked="checked"' ?> tabindex="8" />&nbsp;<strong>No</strong>
       
   119 										<span>Allow users in this group to post new topics.</span>
       
   120 									</td>
       
   121 								</tr>
       
   122 <?php if ($group['g_id'] != PUN_GUEST): ?>								<tr>
       
   123 									<th scope="row">Edit posts</th>
       
   124 									<td>
       
   125 										<input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_posts'] == '1') echo ' checked="checked"' ?> tabindex="11" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="edit_posts" value="0"<?php if ($group['g_edit_posts'] == '0') echo ' checked="checked"' ?> tabindex="12" />&nbsp;<strong>No</strong>
       
   126 										<span>Allow users in this group to edit their own posts.</span>
       
   127 									</td>
       
   128 								</tr>
       
   129 								<tr>
       
   130 									<th scope="row">Delete posts</th>
       
   131 									<td>
       
   132 										<input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '1') echo ' checked="checked"' ?> tabindex="13" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="delete_posts" value="0"<?php if ($group['g_delete_posts'] == '0') echo ' checked="checked"' ?> tabindex="14" />&nbsp;<strong>No</strong>
       
   133 										<span>Allow users in this group to delete their own posts.</span>
       
   134 									</td>
       
   135 								</tr>
       
   136 								<tr>
       
   137 									<th scope="row">Delete topics</th>
       
   138 									<td>
       
   139 										<input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1') echo ' checked="checked"' ?> tabindex="15" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '0') echo ' checked="checked"' ?> tabindex="16" />&nbsp;<strong>No</strong>
       
   140 										<span>Allow users in this group to delete their own topics (including any replies).</span>
       
   141 									</td>
       
   142 								</tr>
       
   143 								<tr>
       
   144 									<th scope="row">Set user title</th>
       
   145 									<td>
       
   146 										<input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1') echo ' checked="checked"' ?> tabindex="17" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '0') echo ' checked="checked"' ?> tabindex="18" />&nbsp;<strong>No</strong>
       
   147 										<span>Allow users in this group to set their own user title.</span>
       
   148 									</td>
       
   149 								</tr>
       
   150 <?php endif; ?>								<tr>
       
   151 									<th scope="row">Use search</th>
       
   152 									<td>
       
   153 										<input type="radio" name="search" value="1"<?php if ($group['g_search'] == '1') echo ' checked="checked"' ?> tabindex="19" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="search" value="0"<?php if ($group['g_search'] == '0') echo ' checked="checked"' ?> tabindex="20" />&nbsp;<strong>No</strong>
       
   154 										<span>Allow users in this group to use the search feature.</span>
       
   155 									</td>
       
   156 								</tr>
       
   157 								<tr>
       
   158 									<th scope="row">Search user list</th>
       
   159 									<td>
       
   160 										<input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1') echo ' checked="checked"' ?> tabindex="21" />&nbsp;<strong>Yes</strong>&nbsp;&nbsp;&nbsp;<input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '0') echo ' checked="checked"' ?> tabindex="22" />&nbsp;<strong>No</strong>
       
   161 										<span>Allow users in this group to freetext search for users in the user list.</span>
       
   162 									</td>
       
   163 								</tr>
       
   164 <?php if ($group['g_id'] != PUN_GUEST): ?>								<tr>
       
   165 									<th scope="row">Edit subjects interval</th>
       
   166 									<td>
       
   167 										<input type="text" name="edit_subjects_interval" size="5" maxlength="5" value="<?php echo $group['g_edit_subjects_interval'] ?>" tabindex="23" />
       
   168 										<span>Number of seconds after post time that users in this group may edit the subject of topics they've posted. Set to 0 to allow edits indefinitely.</span>
       
   169 									</td>
       
   170 								</tr>
       
   171 								<tr>
       
   172 									<th scope="row">Post flood interval</th>
       
   173 									<td>
       
   174 										<input type="text" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="24" />
       
   175 										<span>Number of seconds that users in this group have to wait between posts. Set to 0 to disable.</span>
       
   176 									</td>
       
   177 								</tr>
       
   178 								<tr>
       
   179 									<th scope="row">Search flood interval</th>
       
   180 									<td>
       
   181 										<input type="text" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="25" />
       
   182 										<span>Number of seconds that users in this group have to wait between searches. Set to 0 to disable.</span>
       
   183 									</td>
       
   184 								</tr>
       
   185 <?php endif; ?><?php endif; ?>							</table>
       
   186 <?php if ($group['g_id'] == PUN_MOD ): ?>							<p class="warntext">Please note that in order for a user in this group to have moderator abilities, he/she must be assigned to moderate one or more forums. This is done via the user administration page of the user's profile.</p>
       
   187 <?php endif; ?>						</div>
       
   188 					</fieldset>
       
   189 				</div>
       
   190 				<p class="submitend"><input type="submit" name="add_edit_group" value=" Save " tabindex="26" /></p>
       
   191 			</form>
       
   192 		</div>
       
   193 	</div>
       
   194 	<div class="clearer"></div>
       
   195 </div>
       
   196 <?php
       
   197 
       
   198 	require PUN_ROOT.'footer.php';
       
   199 }
       
   200 
       
   201 
       
   202 // Add/edit a group (stage 2)
       
   203 else if (isset($_POST['add_edit_group']))
       
   204 {
       
   205 	confirm_referrer('admin_groups.php');
       
   206 
       
   207 	// Is this the admin group? (special rules apply)
       
   208 	$is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == PUN_ADMIN) ? true : false;
       
   209 
       
   210 	$title = trim($_POST['req_title']);
       
   211 	$user_title = trim($_POST['user_title']);
       
   212 	$read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1';
       
   213 	$post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1';
       
   214 	$post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1';
       
   215 	$edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0';
       
   216 	$delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0';
       
   217 	$delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0';
       
   218 	$set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0';
       
   219 	$search = isset($_POST['search']) ? intval($_POST['search']) : '1';
       
   220 	$search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1';
       
   221 	$edit_subjects_interval = isset($_POST['edit_subjects_interval']) ? intval($_POST['edit_subjects_interval']) : '0';
       
   222 	$post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0';
       
   223 	$search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0';
       
   224 
       
   225 	if ($title == '')
       
   226 		message('You must enter a group title.');
       
   227 
       
   228 	$user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL';
       
   229 
       
   230 	if ($_POST['mode'] == 'add')
       
   231 	{
       
   232 		$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());
       
   233 		if ($db->num_rows($result))
       
   234 			message('There is already a group with the title \''.pun_htmlspecialchars($title).'\'.');
       
   235 
       
   236 		$db->query('INSERT INTO '.$db->prefix.'groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES(\''.$db->escape($title).'\', '.$user_title.', '.$read_board.', '.$post_replies.', '.$post_topics.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$set_title.', '.$search.', '.$search_users.', '.$edit_subjects_interval.', '.$post_flood.', '.$search_flood.')') or error('Unable to add group', __FILE__, __LINE__, $db->error());
       
   237 		$new_group_id = $db->insert_id();
       
   238 
       
   239 		// Now lets copy the forum specific permissions from the group which this group is based on
       
   240 		$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());
       
   241 		while ($cur_forum_perm = $db->fetch_assoc($result))
       
   242 			$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());
       
   243 	}
       
   244 	else
       
   245 	{
       
   246 		$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());
       
   247 		if ($db->num_rows($result))
       
   248 			message('There is already a group with the title \''.pun_htmlspecialchars($title).'\'.');
       
   249 
       
   250 		$db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_read_board='.$read_board.', 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_edit_subjects_interval='.$edit_subjects_interval.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error());
       
   251 	}
       
   252 
       
   253 	// Regenerate the quickjump cache
       
   254 	require_once PUN_ROOT.'include/cache.php';
       
   255 	generate_quickjump_cache();
       
   256 
       
   257 	redirect('admin_groups.php', 'Group '.(($_POST['mode'] == 'edit') ? 'edited' : 'added').'. Redirecting &hellip;');
       
   258 }
       
   259 
       
   260 
       
   261 // Set default group
       
   262 else if (isset($_POST['set_default_group']))
       
   263 {
       
   264 	confirm_referrer('admin_groups.php');
       
   265 
       
   266 	$group_id = intval($_POST['default_group']);
       
   267 	if ($group_id < 4)
       
   268 		message($lang_common['Bad request']);
       
   269 
       
   270 	$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());
       
   271 
       
   272 	// Regenerate the config cache
       
   273 	require_once PUN_ROOT.'include/cache.php';
       
   274 	generate_config_cache();
       
   275 
       
   276 	redirect('admin_groups.php', 'Default group set. Redirecting &hellip;');
       
   277 }
       
   278 
       
   279 
       
   280 // Remove a group
       
   281 else if (isset($_GET['del_group']))
       
   282 {
       
   283 	confirm_referrer('admin_groups.php');
       
   284 
       
   285 	$group_id = intval($_GET['del_group']);
       
   286 	if ($group_id < 5)
       
   287 		message($lang_common['Bad request']);
       
   288 
       
   289 	// Make sure we don't remove the default group
       
   290 	if ($group_id == $pun_config['o_default_user_group'])
       
   291 		message('The default group cannot be removed. In order to delete this group, you must first setup a different group as the default.');
       
   292 
       
   293 
       
   294 	// Check if this group has any members
       
   295 	$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());
       
   296 
       
   297 	// If the group doesn't have any members or if we've already selected a group to move the members to
       
   298 	if (!$db->num_rows($result) || isset($_POST['del_group']))
       
   299 	{
       
   300 		if (isset($_POST['del_group']))
       
   301 		{
       
   302 			$move_to_group = intval($_POST['move_to_group']);
       
   303 			$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());
       
   304 		}
       
   305 
       
   306 		// Delete the group and any forum specific permissions
       
   307 		$db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error());
       
   308 		$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());
       
   309 
       
   310 		// Regenerate the quickjump cache
       
   311 		require_once PUN_ROOT.'include/cache.php';
       
   312 		generate_quickjump_cache();
       
   313 
       
   314 		redirect('admin_groups.php', 'Group removed. Redirecting &hellip;');
       
   315 	}
       
   316 
       
   317 
       
   318 	list($group_title, $group_members) = $db->fetch_row($result);
       
   319 
       
   320 	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / User groups';
       
   321 	require PUN_ROOT.'header.php';
       
   322 
       
   323 	generate_admin_menu('groups');
       
   324 
       
   325 ?>
       
   326 	<div class="blockform">
       
   327 		<h2><span>Remove group</span></h2>
       
   328 		<div class="box">
       
   329 			<form id="groups" method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>">
       
   330 				<div class="inform">
       
   331 					<fieldset>
       
   332 						<legend>Move users currently in group</legend>
       
   333 						<div class="infldset">
       
   334 							<p>The group "<?php echo pun_htmlspecialchars($group_title) ?>" currently has <?php echo $group_members ?> members. Please select a group to which these members will be assigned upon removal.</p>
       
   335 							<label>Move users to
       
   336 							<select name="move_to_group">
       
   337 <?php
       
   338 
       
   339 	$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());
       
   340 
       
   341 	while ($cur_group = $db->fetch_assoc($result))
       
   342 	{
       
   343 		if ($cur_group['g_id'] == PUN_MEMBER)	// Pre-select the pre-defined Members group
       
   344 			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";
       
   345 		else
       
   346 			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";
       
   347 	}
       
   348 
       
   349 ?>
       
   350 							</select>
       
   351 							</br></label>
       
   352 						</div>
       
   353 					</fieldset>
       
   354 				</div>
       
   355 				<p><input type="submit" name="del_group" value="Delete group" /></p>
       
   356 			</form>
       
   357 		</div>
       
   358 	</div>
       
   359 	<div class="clearer"></div>
       
   360 </div>
       
   361 <?php
       
   362 
       
   363 	require PUN_ROOT.'footer.php';
       
   364 }
       
   365 
       
   366 
       
   367 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / User groups';
       
   368 require PUN_ROOT.'header.php';
       
   369 
       
   370 generate_admin_menu('groups');
       
   371 
       
   372 ?>
       
   373 	<div class="blockform">
       
   374 		<h2><span>Add/setup groups</span></h2>
       
   375 		<div class="box">
       
   376 			<form id="groups" method="post" action="admin_groups.php?action=foo">
       
   377 				<div class="inform">
       
   378 					<fieldset>
       
   379 						<legend>Add new group</legend>
       
   380 						<div class="infldset">
       
   381 							<table class="aligntop" cellspacing="0">
       
   382 								<tr>
       
   383 									<th scope="row">Base new group on<div><input type="submit" name="add_group" value=" Add " tabindex="2" /></div></th>
       
   384 									<td>
       
   385 										<select id="base_group" name="base_group" tabindex="1">
       
   386 <?php
       
   387 
       
   388 $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id>'.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
       
   389 
       
   390 while ($cur_group = $db->fetch_assoc($result))
       
   391 {
       
   392 	if ($cur_group['g_id'] == $pun_config['o_default_user_group'])
       
   393 		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";
       
   394 	else
       
   395 		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";
       
   396 }
       
   397 
       
   398 ?>
       
   399 										</select>
       
   400 										<span>Select a user group from which the new group will inherit it's permission settings. The next page will let you fine-tune said settings.</span>
       
   401 									</td>
       
   402 								</tr>
       
   403 							</table>
       
   404 						</div>
       
   405 					</fieldset>
       
   406 				</div>
       
   407 				<div class="inform">
       
   408 					<fieldset>
       
   409 						<legend>Set default group</legend>
       
   410 						<div class="infldset">
       
   411 							<table class="aligntop" cellspacing="0">
       
   412 								<tr>
       
   413 									<th scope="row">Default group<div><input type="submit" name="set_default_group" value=" Save " tabindex="4" /></div></th>
       
   414 									<td>
       
   415 										<select id="default_group" name="default_group" tabindex="3">
       
   416 <?php
       
   417 
       
   418 $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id>'.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
       
   419 
       
   420 while ($cur_group = $db->fetch_assoc($result))
       
   421 {
       
   422 	if ($cur_group['g_id'] == $pun_config['o_default_user_group'])
       
   423 		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";
       
   424 	else
       
   425 		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";
       
   426 }
       
   427 
       
   428 ?>
       
   429 										</select>
       
   430 										<span>This is the default user group, e.g. the group users are placed in when they register. For security reasons, users can't be placed in either the moderator or administrator user groups by default.</span>
       
   431 									</td>
       
   432 								</tr>
       
   433 							</table>
       
   434 						</div>
       
   435 					</fieldset>
       
   436 				</div>
       
   437 			</form>
       
   438 		</div>
       
   439 
       
   440 		<h2 class="block2"><span>Existing groups</span></h2>
       
   441 		<div class="box">
       
   442 			<div class="fakeform">
       
   443 				<div class="inform">
       
   444 					<fieldset>
       
   445 						<legend>Edit/remove groups</legend>
       
   446 						<div class="infldset">
       
   447 							<p>The pre-defined groups Guests, Administrators, Moderators and Members cannot be removed. They can however be edited. Please note though, that in some groups, some options are unavailable (e.g. the <em>edit posts</em> permission for guests). Administrators always have full permissions.</p>
       
   448 							<table cellspacing="0">
       
   449 <?php
       
   450 
       
   451 $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());
       
   452 
       
   453 while ($cur_group = $db->fetch_assoc($result))
       
   454 	echo "\t\t\t\t\t\t\t\t".'<tr><th scope="row"><a href="admin_groups.php?edit_group='.$cur_group['g_id'].'">Edit</a>'.(($cur_group['g_id'] > PUN_MEMBER) ? ' - <a href="admin_groups.php?del_group='.$cur_group['g_id'].'">Remove</a>' : '').'</th><td>'.pun_htmlspecialchars($cur_group['g_title']).'</td></tr>'."\n";
       
   455 
       
   456 ?>
       
   457 							</table>
       
   458 						</div>
       
   459 					</fieldset>
       
   460 				</div>
       
   461 			</div>
       
   462 		</div>
       
   463 	</div>
       
   464 	<div class="clearer"></div>
       
   465 </div>
       
   466 <?php
       
   467 
       
   468 require PUN_ROOT.'footer.php';