diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php
index 17fea8fac4..2eed753a0c 100644
--- a/phpBB/admin/admin_forums.php
+++ b/phpBB/admin/admin_forums.php
@@ -67,7 +67,7 @@ switch ($mode)
case 'move_up':
case 'move_down':
$show_index = TRUE;
- $forum_id = intval($_GET['f']);
+ $forum_id = intval($_GET['this_f']);
$result = $db->sql_query('SELECT parent_id, left_id, right_id FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id");
if (!$row = $db->sql_fetchrow($result))
@@ -83,16 +83,16 @@ switch ($mode)
if ($mode == 'move_up')
{
$sql = 'SELECT forum_id, left_id, right_id
- FROM ' . FORUMS_TABLE . "
- WHERE parent_id = $parent_id AND right_id < $right_id
- ORDER BY right_id DESC";
+ FROM ' . FORUMS_TABLE . "
+ WHERE parent_id = $parent_id AND right_id < $right_id
+ ORDER BY right_id DESC";
}
else
{
$sql = 'SELECT forum_id, left_id, right_id
- FROM ' . FORUMS_TABLE . "
- WHERE parent_id = $parent_id AND left_id > $left_id
- ORDER BY left_id ASC";
+ FROM ' . FORUMS_TABLE . "
+ WHERE parent_id = $parent_id AND left_id > $left_id
+ ORDER BY left_id ASC";
}
$result = $db->sql_query_limit($sql, 1);
@@ -124,8 +124,8 @@ switch ($mode)
//
$forum_ids = array();
$sql = 'SELECT forum_id
- FROM ' . FORUMS_TABLE . '
- WHERE left_id > ' . $forum_info[$up_id]['left_id'] . ' AND right_id < ' . $forum_info[$up_id]['right_id'];
+ FROM ' . FORUMS_TABLE . '
+ WHERE left_id > ' . $forum_info[$up_id]['left_id'] . ' AND right_id < ' . $forum_info[$up_id]['right_id'];
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -134,57 +134,43 @@ switch ($mode)
}
$sql = 'UPDATE ' . FORUMS_TABLE . '
- SET left_id = left_id + ' . ($diff_up + 1) . ', right_id = right_id + ' . ($diff_up + 1) . '
- WHERE left_id > ' . $forum_info[$down_id]['left_id'] . ' AND right_id < ' . $forum_info[$down_id]['right_id'];
+ SET left_id = left_id + ' . ($diff_up + 1) . ', right_id = right_id + ' . ($diff_up + 1) . '
+ WHERE left_id > ' . $forum_info[$down_id]['left_id'] . ' AND right_id < ' . $forum_info[$down_id]['right_id'];
$db->sql_query($sql);
if (count($forum_ids))
{
$sql = 'UPDATE ' . FORUMS_TABLE . '
- SET left_id = left_id - ' . ($diff_down + 1) . ', right_id = right_id - ' . ($diff_down + 1) . '
- WHERE forum_id IN (' . implode(', ', $forum_ids) . ')';
+ SET left_id = left_id - ' . ($diff_down + 1) . ', right_id = right_id - ' . ($diff_down + 1) . '
+ WHERE forum_id IN (' . implode(', ', $forum_ids) . ')';
$db->sql_query($sql);
}
$sql = 'UPDATE ' . FORUMS_TABLE . '
- SET left_id = ' . $forum_info[$down_id]['left_id'] . ', right_id = ' . ($forum_info[$down_id]['left_id'] + $diff_up) . '
- WHERE forum_id = ' . $up_id;
+ SET left_id = ' . $forum_info[$down_id]['left_id'] . ', right_id = ' . ($forum_info[$down_id]['left_id'] + $diff_up) . '
+ WHERE forum_id = ' . $up_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . FORUMS_TABLE . '
- SET left_id = ' . ($forum_info[$up_id]['right_id'] - $diff_down) . ', right_id = ' . $forum_info[$up_id]['right_id'] . '
- WHERE forum_id = ' . $down_id;
+ SET left_id = ' . ($forum_info[$up_id]['right_id'] - $diff_down) . ', right_id = ' . $forum_info[$up_id]['right_id'] . '
+ WHERE forum_id = ' . $down_id;
$db->sql_query($sql);
break;
case 'create':
if (!trim($_POST['forum_name']))
{
- message_die(ERROR, 'Cannot create a forum without a name');
+ trigger_error('Cannot create a forum without a name');
}
- $parent_id = (!empty($_POST['parent_id'])) ? $_POST['parent_id'] : 0;
- $forum_status = (!empty($_POST['is_category'])) ? ITEM_CATEGORY : $_POST['forum_status'];
- $forum_name = str_replace("\'", "''", $_POST['forum_name']);
- $forum_desc = str_replace("\'", "''", $_POST['forum_desc']);
-
- $forum_style = (!empty($_POST['forum_style'])) ? intval($_POST['forum_style']) : 'NULL';
- $post_count_inc = (!empty($_POST['disable_post_count'])) ? 0 : 1;
- $moderated = (!empty($_POST['moderated'])) ? 1 : 0;
-
- $prune_enable = (!empty($_POST['prune_enable'])) ? 1 : 0;
- $prune_days = intval($_POST['prune_days']);
- $prune_freq = intval($_POST['prune_freq']);
-
- $result = $db->sql_query('SELECT MAX(forum_id) AS max_id FROM ' . FORUMS_TABLE);
- $forum_id = $db->sql_fetchfield('max_id', 0, $result) + 1;
+ $parent_id = (!empty($_POST['parent_id'])) ? intval($_POST['parent_id']) : 0;
if ($parent_id)
{
$result = $db->sql_query('SELECT left_id, right_id FROM ' . FORUMS_TABLE . " WHERE forum_id = $parent_id");
if (!$row = $db->sql_fetchrow($result))
{
- message_die(ERROR, 'Parent does not exist');
+ trigger_error('Parent does not exist', E_USER_ERROR);
}
extract($row);
@@ -197,21 +183,39 @@ switch ($mode)
else
{
$result = $db->sql_query('SELECT MAX(right_id) AS right_id FROM ' . FORUMS_TABLE);
+
$left_id = $db->sql_fetchfield('right_id', 0, $result) + 1;
$right_id = $left_id + 1;
}
- $sql = 'INSERT INTO ' . FORUMS_TABLE . " (forum_id, forum_name, forum_desc, parent_id, left_id, right_id, forum_status, forum_style, post_count_inc, moderated, prune_enable, prune_days, prune_freq)
- VALUES ($forum_id, '$forum_name', '$forum_desc', $parent_id, $left_id, $right_id, $forum_status, $forum_style, $post_count_inc, $moderated, $prune_enable, $prune_days, $prune_freq)";
- $db->sql_query($sql);
+ $sql = array(
+ 'parent_id' => $parent_id,
+ 'left_id' => $left_id,
+ 'right_id' => $right_id,
+ 'forum_status' => (!empty($_POST['is_category'])) ? ITEM_CATEGORY : intval($_POST['forum_status']),
+ 'forum_postable' => (!empty($_POST['is_category'])) ? 0 : 1,
+ 'forum_name' => sql_quote($_POST['forum_name']),
+ 'forum_desc' => sql_quote($_POST['forum_desc']),
+ 'forum_style' => (!empty($_POST['forum_style'])) ? intval($_POST['forum_style']) : 'NULL',
+ 'enable_post_count' => (!empty($_POST['disable_post_count'])) ? 0 : 1,
+ 'enable_icons' => (!empty($_POST['enable_icons'])) ? 1 : 0,
+ 'enable_moderate' => (!empty($_POST['moderated'])) ? 1 : 0,
+ 'enable_prune' => (!empty($_POST['prune_enable'])) ? 1 : 0,
+ 'prune_days' => intval($_POST['prune_days']),
+ 'prune_freq' => intval($_POST['prune_freq'])
+ );
- $message = $user->lang['Forums_updated'] . " " . sprintf($user->lang['Click_return_forumadmin'], '', ' ') . ' ' . sprintf($user->lang['Click_return_admin_index'], '', ' ');
- message_die(MESSAGE, $message);
+ $db->sql_query('INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql));
+
+ $forum_id = $db->sql_nextid();
+
+ // Redirect to permissions
+ redirect('admin_permissions.' . $phpEx . $SID . '&mode=forums&f=' . $forum_id);
break;
case 'modify':
- if (!$forum_id = intval($_POST['forum_id']))
+ if (!$forum_id = intval($_POST['f']))
{
message_die(ERROR, 'No forum specified');
}
@@ -233,20 +237,23 @@ switch ($mode)
}
$sql = array(
- 'forum_name' => (!empty($_POST['forum_name'])) ? $_POST['forum_name'] : $row['forum_name'],
- 'forum_desc' => (!empty($_POST['forum_desc'])) ? $_POST['forum_desc'] : $row['forum_desc'],
- 'forum_status' => (!empty($_POST['set_category']) && $action) ? ITEM_CATEGORY : intval($_POST['forum_status']),
- 'forum_style' => (!empty($_POST['forum_style'])) ? $_POST['forum_style'] : NULL,
'parent_id' => $parent_id,
- 'prune_enable' => (!empty($_POST['prune_enable'])) ? 1 : 0,
+ 'forum_name' => (!empty($_POST['forum_name'])) ? $_POST['forum_name'] : $row['forum_name'],
+ 'forum_desc' => (!empty($_POST['forum_desc'])) ? $_POST['forum_desc'] : $row['forum_desc'],
+ 'forum_status' => intval($_POST['forum_status']),
+ 'forum_postable' => (!empty($_POST['is_postable'])) ? 1 : 0,
+ 'forum_style' => (!empty($_POST['forum_style'])) ? $_POST['forum_style'] : NULL,
+ 'forum_image' => (!empty($_POST['forum_image'])) ? $_POST['forum_image'] : '',
+ 'display_on_index' => (!empty($_POST['display_on_index'])) ? 1 : 0,
+ 'enable_post_count' => (!empty($_POST['disable_post_count'])) ? 0 : 1,
+ 'enable_icons' => (!empty($_POST['topic_icons'])) ? 1 : 0,
+ 'enable_moderate' => (!empty($_POST['moderated'])) ? 1 : 0,
+ 'enable_prune' => (!empty($_POST['prune_enable'])) ? 1 : 0,
'prune_days' => intval($_POST['prune_days']),
'prune_freq' => intval($_POST['prune_freq']),
- 'display_on_index' => (!empty($_POST['display_on_index'])) ? 1 : 0,
- 'post_count_inc' => (!empty($_POST['disable_post_count'])) ? 0 : 1,
- 'moderated' => (!empty($_POST['moderated'])) ? 1 : 0,
);
- if (!empty($_POST['set_category']) && $action)
+ if (!empty($_POST['set_nonpostable']) && $action)
{
if ($action == 'move' && $_POST['to_forum_id'])
{
@@ -274,7 +281,7 @@ switch ($mode)
//
// wasn't this form submitted? is anyone trying to remotely delete forums
//
- message_die(ERROR, 'Did not submit');
+ trigger_error('Did not submit', E_USER_ERROR);
}
$action_subforums = (!empty($_POST['action_subforums'])) ? $_POST['action_subforums'] : '';
@@ -356,9 +363,8 @@ switch ($mode)
message_die(MESSAGE, $message);
break;
- case 'forum_sync':
- sync('forum', intval($_GET['f']));
- $show_index = TRUE;
+ case 'sync':
+ sync('forum', intval($_GET['this_f']));
break;
case 'add':
@@ -366,7 +372,7 @@ switch ($mode)
// Show form to create/modify a forum
if ($mode == 'edit')
{
- $forum_id = intval($_GET['f']);
+ $forum_id = intval($_GET['this_f']);
$row = get_forum_info($forum_id);
extract($row);
@@ -403,6 +409,7 @@ switch ($mode)
$newmode = 'create';
$buttonvalue = $user->lang['Create_forum'];
+ $forum_id = $parent_id;
$forum_desc = '';
$forum_style = '';
$forum_status = ITEM_UNLOCKED;
@@ -410,6 +417,7 @@ switch ($mode)
$post_count_inc = TRUE;
$moderated = FALSE;
+ $enable_icons = TRUE;
$prune_enabled = '';
$prune_days = 7;
@@ -419,10 +427,10 @@ switch ($mode)
$styles_list = make_styles_list($forum_style);
$forumlocked = ($forum_status == ITEM_LOCKED) ? ' selected="selected"' : '';
- $forumunlocked = ($forum_status == ITEM_UNLOCKED || $forum_status == ITEM_CATEGORY) ? ' selected="selected"' : '';
+ $forumunlocked = ($forum_status == ITEM_UNLOCKED) ? ' selected="selected"' : '';
- $forum_checked = ($forum_status != ITEM_CATEGORY) ? 'checked="checked" ' : '';
- $category_checked = ($forum_status == ITEM_CATEGORY) ? 'checked="checked" ' : '';
+ $postable_checked = ($forum_postable) ? 'checked="checked" ' : '';
+ $nonpostable_checked = (!$forum_postable) ? 'checked="checked" ' : '';
$statuslist = '' . $user->lang['Unlocked'] . " \n";
$statuslist .= '' . $user->lang['Locked'] . " \n";
@@ -438,81 +446,35 @@ switch ($mode)
lang['General_settings'] ?>
-
- lang['Forum_name'] : $user->lang['Category_name'] ?>
-
-
-
- lang['Forum_desc'] ?>
-
-
-
-
- lang['Forum_type'] ?>
- />lang['Forum'] ?> />lang['Category'] ?>
-
-
lang['Parent'] ?>
lang['No_parent'] ?>
- lang['Style'] ?>
- lang['Default_style'] ?>
+ lang['Forum_name']; ?>
+
+
+
+ lang['Forum_desc'] ?>
+
+
+
+ lang['FORUM_TYPE'] ?>
+ />lang['IS_POSTABLE'] ?> />lang['NOT_POSTABLE'] ?>
+
+
+ lang['Forum_settings'] ?>
- lang['Forum_settings'] ?>
-
-
- lang['Forum_status'] ?>
+ lang['FORUM_STATUS'] ?>
-
- lang['Options'] ?>
-
-
- lang['Forum_type'] ?>
+ lang['FORUM_TYPE'] ?>