punbb/admin_forums.php
author Dan
Wed, 11 Jul 2007 21:01:48 -0400
changeset 0 f9ffdbd96607
child 2 a8a21e1c7afa
permissions -rw-r--r--
Initial population
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
// Tell header.php to use the admin template
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
define('PUN_ADMIN_CONSOLE', 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
define('PUN_ROOT', './');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    30
require PUN_ROOT.'include/common.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
require PUN_ROOT.'include/common_admin.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    33
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
if ($pun_user['g_id'] > PUN_ADMIN)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
// Add a "default" forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
if (isset($_POST['add_forum']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
	confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
	$add_to_cat = intval($_POST['add_to_cat']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
	if ($add_to_cat < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
	$db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
	// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
	require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
	generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
	redirect('admin_forums.php', 'Forum added. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
// Delete a forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
else if (isset($_GET['del_forum']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
	confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
	$forum_id = intval($_GET['del_forum']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
	if ($forum_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
	if (isset($_POST['del_forum_comply']))	// Delete a forum with all posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
		@set_time_limit(0);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
		// Prune all posts and topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
		prune($forum_id, 1, -1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
		// Locate any "orphaned redirect topics" and delete them
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
		$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
		$num_orphans = $db->num_rows($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
		if ($num_orphans)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
			for ($i = 0; $i < $num_orphans; ++$i)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
				$orphans[] = $db->result($result, $i);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
			$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
		// Delete the forum and any forum specific group permissions
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
		$db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
		$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
		redirect('admin_forums.php', 'Forum deleted. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
	else	// If the user hasn't confirmed the delete
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
		$result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
		$forum_name = pun_htmlspecialchars($db->result($result));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
		require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
		generate_admin_menu('forums');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
		<h2><span>Confirm delete forum</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
			<form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
						<legend>Important! Read before deleting</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
							<p>Are you sure that you want to delete the forum "<?php echo $forum_name ?>"?</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
							<p>WARNING! Deleting a forum will delete all posts (if any) in that forum!</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
				<p><input type="submit" name="del_forum_comply" value="Delete" /><a href="javascript:history.go(-1)">Go back</a></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
		require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
// Update forum positions
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
else if (isset($_POST['update_positions']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
	confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
	while (list($forum_id, $disp_position) = @each($_POST['position']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
		if (!@preg_match('#^\d+$#', $disp_position))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
			message('Position must be a positive integer value.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
		$db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
	// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
	require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
	generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   149
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
	redirect('admin_forums.php', 'Forums updated. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
else if (isset($_GET['edit_forum']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
	$forum_id = intval($_GET['edit_forum']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
	if ($forum_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
	// Update group permissions for $forum_id
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
	if (isset($_POST['save']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
		confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
		// Start with the forum details
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
		$forum_name = trim($_POST['forum_name']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
		$forum_desc = pun_linebreaks(trim($_POST['forum_desc']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   168
		$cat_id = intval($_POST['cat_id']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   169
		$sort_by = intval($_POST['sort_by']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
		$redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   171
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   172
		if ($forum_name == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   173
			message('You must enter a forum name.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   174
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   175
		if ($cat_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   176
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   177
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   178
		$forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   179
		$redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   180
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   181
		$db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   182
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   183
		// Now let's deal with the permissions
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   184
		if (isset($_POST['read_forum_old']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   185
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   186
			$result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   187
			while ($cur_group = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   188
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   189
				$read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   190
				$post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   191
				$post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   192
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   193
				// Check if the new settings differ from the old
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   194
				if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   195
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   196
					// If the new settings are identical to the default settings for this group, delete it's row in forum_perms
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   197
					if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   198
						$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   199
					else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   200
					{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   201
						// Run an UPDATE and see if it affected a row, if not, INSERT
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   202
						$db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   203
						if (!$db->affected_rows())
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   204
							$db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   205
					}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   206
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   207
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   208
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   209
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   210
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   211
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   212
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   213
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   214
		redirect('admin_forums.php', 'Forum updated. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   215
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   216
	else if (isset($_POST['revert_perms']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   217
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   218
		confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   219
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   220
		$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   221
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   222
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   223
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   224
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   225
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   226
		redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   227
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   228
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   229
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   230
	// Fetch forum info
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   231
	$result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   232
	if (!$db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   233
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   234
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   235
	$cur_forum = $db->fetch_assoc($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   236
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   237
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   238
	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   239
	require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   240
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   241
	generate_admin_menu('forums');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   242
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   243
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   244
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   245
		<h2><span>Edit forum</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   246
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   247
			<form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   248
				<p class="submittop"><input type="submit" name="save" value="Save changes" tabindex="6" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   249
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   250
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   251
						<legend>Edit forum details</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   252
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   253
							<table class="aligntop" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   254
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   255
									<th scope="row">Forum name</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   256
									<td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   257
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   258
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   259
									<th scope="row">Description (HTML)</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   260
									<td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   261
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   262
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   263
									<th scope="row">Category</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   264
									<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   265
										<select name="cat_id" tabindex="3">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   266
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   267
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   268
	$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   269
	while ($cur_cat = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   270
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   271
		$selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   272
		echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   273
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   274
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   275
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   276
										</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   277
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   278
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   279
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   280
									<th scope="row">Sort topics by</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   281
									<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   282
										<select name="sort_by" tabindex="4">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   283
											<option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>>Last post</option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   284
											<option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>>Topic start</option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   285
										</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   286
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   287
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   288
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   289
									<th scope="row">Redirect URL</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   290
									<td><?php echo ($cur_forum['num_topics']) ? 'Only available in empty forums' : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   291
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   292
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   293
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   294
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   295
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   296
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   297
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   298
						<legend>Edit group permissions for this forum</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   299
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   300
							<p>In this form, you can set the forum specific permissions for the different user groups. If you haven't made any changes to this forums group permissions, what you see below is the default based on settings in <a href="admin_groups.php">User groups</a>. Administrators always have full permissions and are thus excluded. Permission settings that differ from the default permissions for the user group are marked red. The "Read forum" permission checkbox will be disabled if the group in question lacks the "Read board" permission. For redirect forums, only the "Read forum" permission is editable.</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   301
							<table id="forumperms" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   302
							<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   303
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   304
									<th class="atcl">&nbsp;</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   305
									<th>Read forum</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   306
									<th>Post replies</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   307
									<th>Post topics</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   308
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   309
							</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   310
							<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   311
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   312
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   313
	$result = $db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$db->prefix.'groups AS g LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   314
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   315
	while ($cur_perm = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   316
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   317
		$read_forum = ($cur_perm['read_forum'] != '0') ? true : false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   318
		$post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   319
		$post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   320
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   321
		// Determine if the current sittings differ from the default or not
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   322
		$read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   323
		$post_replies_def = (($post_replies && $cur_perm['g_post_replies'] == '0') || (!$post_replies && ($cur_perm['g_post_replies'] == '' || $cur_perm['g_post_replies'] == '1'))) ? false : true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   324
		$post_topics_def = (($post_topics && $cur_perm['g_post_topics'] == '0') || (!$post_topics && ($cur_perm['g_post_topics'] == '' || $cur_perm['g_post_topics'] == '1'))) ? false : true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   325
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   326
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   327
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   328
									<th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   329
									<td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   330
										<input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   331
										<input type="checkbox" name="read_forum_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($read_forum) ? ' checked="checked"' : ''; ?><?php echo ($cur_perm['g_read_board'] == '0') ? ' disabled="disabled"' : ''; ?> />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   332
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   333
									<td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   334
										<input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   335
										<input type="checkbox" name="post_replies_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_replies) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   336
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   337
									<td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   338
										<input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   339
										<input type="checkbox" name="post_topics_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_topics) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   340
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   341
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   342
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   343
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   344
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   345
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   346
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   347
							</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   348
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   349
							<div class="fsetsubmit"><input type="submit" name="revert_perms" value="Revert to default" /></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   350
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   351
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   352
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   353
				<p class="submitend"><input type="submit" name="save" value="Save changes" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   354
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   355
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   356
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   357
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   358
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   359
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   360
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   361
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   362
	require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   363
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   364
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   365
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   366
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   367
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   368
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   369
generate_admin_menu('forums');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   370
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   371
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   372
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   373
		<h2><span>Add forum</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   374
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   375
			<form method="post" action="admin_forums.php?action=adddel">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   376
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   377
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   378
						<legend>Create a new forum</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   379
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   380
							<table class="aligntop" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   381
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   382
									<th scope="row">Add forum to category<div><input type="submit" name="add_forum" value=" Add " tabindex="2" /></div></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   383
									<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   384
										<select name="add_to_cat" tabindex="1">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   385
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   386
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   387
	$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   388
	while ($cur_cat = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   389
		echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   390
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   391
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   392
										</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   393
										<span>Select the category to which you wish to add a new forum.</span>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   394
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   395
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   396
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   397
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   398
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   399
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   400
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   401
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   402
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   403
		<h2 class="block2"><span>Edit forums</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   404
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   405
			<form id="edforum" method="post" action="admin_forums.php?action=edit">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   406
				<p class="submittop"><input type="submit" name="update_positions" value="Update positions" tabindex="3" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   407
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   408
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   409
$tabindex_count = 4;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   410
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   411
// Display all the categories and forums
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   412
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   413
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   414
$cur_category = 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   415
while ($cur_forum = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   416
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   417
	if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   418
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   419
		if ($cur_category != 0)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   420
			echo "\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   421
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   422
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   423
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   424
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   425
						<legend>Category: <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   426
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   427
							<table cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   428
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   429
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   430
		$cur_category = $cur_forum['cid'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   431
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   432
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   433
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   434
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   435
									<th><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>">Edit</a> - <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>">Delete</a></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   436
									<td>Position&nbsp;&nbsp;<input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $tabindex_count ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   437
									&nbsp;&nbsp;<strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   438
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   439
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   440
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   441
	$tabindex_count += 2;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   442
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   443
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   444
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   445
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   446
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   447
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   448
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   449
				<p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   450
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   451
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   452
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   453
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   454
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   455
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   456
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   457
require PUN_ROOT.'footer.php';