1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-18 21:39:52 +02:00

Fixed: wrong parent_id, incorrect $mode case. Now I'm done checking if it was possible to screw up the tree, the answer was yes.

git-svn-id: file:///svn/phpbb/trunk@4516 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Ludovic Arnaud 2003-09-28 22:18:10 +00:00
parent 3e23d958ac
commit a32d43d94a

View File

@ -14,7 +14,6 @@
/*
TODO:
- check there's no way for an admin to screw up left_id and right_id values
- make a function to verify and/or fix the tree?
*/
@ -46,7 +45,6 @@ $forum_data = $errors = array();
switch ($mode)
{
case 'add':
case 'create':
$acl = 'a_forumadd';
break;
case 'delete':
@ -81,14 +79,14 @@ if (isset($_POST['update']))
case 'edit':
$forum_data = array(
'forum_id' => $forum_id,
'parent_id' => $parent_id
'forum_id' => $forum_id
);
// No break here
case 'add':
$forum_data += array(
'parent_id' => $parent_id,
'forum_type' => request_var('forum_type', FORUM_POST),
'forum_status' => request_var('forum_status', ITEM_UNLOCKED),
'forum_name' => request_var('forum_name', ''),
@ -118,7 +116,7 @@ if (isset($_POST['update']))
}
// Redirect to permissions
$message = ($mode == 'create') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
$message = ($mode == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], "<a href=\"admin_permissions.$phpEx$SID&amp;mode=forum&amp;submit_usergroups=true&amp;ug_type=forum&amp;action=usergroups&amp;f[forum][]=" . $forum_data['forum_id'] . '">', '</a>');
trigger_error($message);
@ -693,7 +691,7 @@ if ($mode == 'sync')
echo '<br /><div class="gen" align="center"><b>' . $user->lang['FORUM_RESYNCED'] . '</b></div>';
}
?><form method="post" action="<?php echo "admin_forums.$phpEx$SID" ?>"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
?><form method="post" action="<?php echo "admin_forums.$phpEx$SID&amp;parent_id=$parent_id" ?>"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td class="nav"><?php echo $navigation ?></td>
</tr>
@ -785,7 +783,7 @@ while ($row = $db->sql_fetchrow($result))
?>
<tr>
<td width="100%" colspan="6" class="cat"><input type="hidden" name="mode" value="add" /><input type="hidden" name="parent_id" value="<? echo $forum_id ?>" /><input class="post" type="text" name="forum_name" /> <input class="btnlite" type="submit" value="<?php echo $user->lang['CREATE_FORUM'] ?>" /></td>
<td width="100%" colspan="6" class="cat"><input type="hidden" name="mode" value="add" /><input class="post" type="text" name="forum_name" /> <input class="btnlite" type="submit" value="<?php echo $user->lang['CREATE_FORUM'] ?>" /></td>
</tr>
</table></form>
@ -901,10 +899,13 @@ function update_forum_data(&$forum_data)
{
return $errors;
}
elseif (empty($forum_data['forum_id']))
if (empty($forum_data['forum_id']))
{
// no forum_id means we're creating a new forum
$db->sql_transaction('begin');
if ($forum_data['parent_id'])
{
$sql = 'SELECT left_id, right_id
@ -928,8 +929,8 @@ function update_forum_data(&$forum_data)
WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id';
$db->sql_query($sql);
$forum_data['left_id'] = $right_id;
$forum_data['right_id'] = $right_id + 1;
$forum_data['left_id'] = $row['right_id'];
$forum_data['right_id'] = $row['right_id'] + 1;
}
else
{
@ -947,6 +948,8 @@ function update_forum_data(&$forum_data)
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data);
$db->sql_query($sql);
$db->sql_transaction('commit');
$forum_data['forum_id'] = $db->sql_nextid();
add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']);
}