mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-09 19:26:53 +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:
@ -14,7 +14,6 @@
|
|||||||
/*
|
/*
|
||||||
TODO:
|
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?
|
- make a function to verify and/or fix the tree?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -46,7 +45,6 @@ $forum_data = $errors = array();
|
|||||||
switch ($mode)
|
switch ($mode)
|
||||||
{
|
{
|
||||||
case 'add':
|
case 'add':
|
||||||
case 'create':
|
|
||||||
$acl = 'a_forumadd';
|
$acl = 'a_forumadd';
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
@ -81,14 +79,14 @@ if (isset($_POST['update']))
|
|||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$forum_data = array(
|
$forum_data = array(
|
||||||
'forum_id' => $forum_id,
|
'forum_id' => $forum_id
|
||||||
'parent_id' => $parent_id
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// No break here
|
// No break here
|
||||||
|
|
||||||
case 'add':
|
case 'add':
|
||||||
$forum_data += array(
|
$forum_data += array(
|
||||||
|
'parent_id' => $parent_id,
|
||||||
'forum_type' => request_var('forum_type', FORUM_POST),
|
'forum_type' => request_var('forum_type', FORUM_POST),
|
||||||
'forum_status' => request_var('forum_status', ITEM_UNLOCKED),
|
'forum_status' => request_var('forum_status', ITEM_UNLOCKED),
|
||||||
'forum_name' => request_var('forum_name', ''),
|
'forum_name' => request_var('forum_name', ''),
|
||||||
@ -118,7 +116,7 @@ if (isset($_POST['update']))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to permissions
|
// 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&mode=forum&submit_usergroups=true&ug_type=forum&action=usergroups&f[forum][]=" . $forum_data['forum_id'] . '">', '</a>');
|
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], "<a href=\"admin_permissions.$phpEx$SID&mode=forum&submit_usergroups=true&ug_type=forum&action=usergroups&f[forum][]=" . $forum_data['forum_id'] . '">', '</a>');
|
||||||
|
|
||||||
trigger_error($message);
|
trigger_error($message);
|
||||||
@ -693,7 +691,7 @@ if ($mode == 'sync')
|
|||||||
echo '<br /><div class="gen" align="center"><b>' . $user->lang['FORUM_RESYNCED'] . '</b></div>';
|
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&parent_id=$parent_id" ?>"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="nav"><?php echo $navigation ?></td>
|
<td class="nav"><?php echo $navigation ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -785,7 +783,7 @@ while ($row = $db->sql_fetchrow($result))
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<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>
|
</tr>
|
||||||
</table></form>
|
</table></form>
|
||||||
|
|
||||||
@ -901,10 +899,13 @@ function update_forum_data(&$forum_data)
|
|||||||
{
|
{
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
elseif (empty($forum_data['forum_id']))
|
|
||||||
|
if (empty($forum_data['forum_id']))
|
||||||
{
|
{
|
||||||
// no forum_id means we're creating a new forum
|
// no forum_id means we're creating a new forum
|
||||||
|
|
||||||
|
$db->sql_transaction('begin');
|
||||||
|
|
||||||
if ($forum_data['parent_id'])
|
if ($forum_data['parent_id'])
|
||||||
{
|
{
|
||||||
$sql = 'SELECT left_id, right_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';
|
WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id';
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
$forum_data['left_id'] = $right_id;
|
$forum_data['left_id'] = $row['right_id'];
|
||||||
$forum_data['right_id'] = $right_id + 1;
|
$forum_data['right_id'] = $row['right_id'] + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -947,6 +948,8 @@ function update_forum_data(&$forum_data)
|
|||||||
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data);
|
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
$forum_data['forum_id'] = $db->sql_nextid();
|
$forum_data['forum_id'] = $db->sql_nextid();
|
||||||
add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']);
|
add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user