mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-10 09:35:24 +02:00
Fixed deleting/creating with no forums/cats left, bug #459962
git-svn-id: file:///svn/phpbb/trunk@1015 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
19ca822630
commit
34c4e7c820
@ -52,6 +52,15 @@ function get_info($mode, $id)
|
|||||||
message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__);
|
message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$sql = "SELECT count(*) as total
|
||||||
|
FROM $table";
|
||||||
|
if( !$result = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
$count = $db->sql_fetchrow($result);
|
||||||
|
$count = $count['total'];
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM $table
|
FROM $table
|
||||||
@ -66,7 +75,9 @@ function get_info($mode, $id)
|
|||||||
message_die(GENERAL_ERROR, "Forum/Category doesn't exist or multiple forums/categories with ID $id", "", __LINE__, __FILE__);
|
message_die(GENERAL_ERROR, "Forum/Category doesn't exist or multiple forums/categories with ID $id", "", __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $db->sql_fetchrow($result);
|
$return = $db->sql_fetchrow($result);
|
||||||
|
$return['number'] = $count;
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_list($mode, $id, $select)
|
function get_list($mode, $id, $select)
|
||||||
@ -432,8 +443,10 @@ if(isset($mode)) // Are we supposed to do something?
|
|||||||
case 'deleteforum':
|
case 'deleteforum':
|
||||||
// Show form to delete a forum
|
// Show form to delete a forum
|
||||||
$forum_id = $HTTP_GET_VARS['forum_id'];
|
$forum_id = $HTTP_GET_VARS['forum_id'];
|
||||||
$to_ids = "<option value=\"-1\"$s>Delete all posts</option>\n";
|
$select_to = '<select name="to_id">';
|
||||||
$to_ids .= get_list('forum', $forum_id, 0);
|
$select_to .= "<option value=\"-1\"$s>Delete all posts</option>\n";
|
||||||
|
$select_to .= get_list('forum', $forum_id, 0);
|
||||||
|
$select_to .= '</select>';
|
||||||
$buttonvalue = "Move&Delete";
|
$buttonvalue = "Move&Delete";
|
||||||
$newmode = 'movedelforum';
|
$newmode = 'movedelforum';
|
||||||
$foruminfo = get_info('forum', $forum_id);
|
$foruminfo = get_info('forum', $forum_id);
|
||||||
@ -446,7 +459,7 @@ if(isset($mode)) // Are we supposed to do something?
|
|||||||
'NAME' => $name,
|
'NAME' => $name,
|
||||||
'S_FORUM_ACTION' => $PHP_SELF,
|
'S_FORUM_ACTION' => $PHP_SELF,
|
||||||
'S_FROM_ID' => $forum_id,
|
'S_FROM_ID' => $forum_id,
|
||||||
'S_TO_IDS' => $to_ids,
|
'S_SELECT_TO' => $select_to,
|
||||||
'S_NEWMODE' => $newmode,
|
'S_NEWMODE' => $newmode,
|
||||||
'BUTTONVALUE' => $buttonvalue)
|
'BUTTONVALUE' => $buttonvalue)
|
||||||
);
|
);
|
||||||
@ -509,12 +522,38 @@ if(isset($mode)) // Are we supposed to do something?
|
|||||||
case 'deletecat':
|
case 'deletecat':
|
||||||
// Show form to delete a category
|
// Show form to delete a category
|
||||||
$cat_id = $HTTP_GET_VARS['cat_id'];
|
$cat_id = $HTTP_GET_VARS['cat_id'];
|
||||||
$to_ids = get_list('category', $cat_id, 0);
|
|
||||||
$buttonvalue = "Move&Delete";
|
$buttonvalue = "Move&Delete";
|
||||||
$newmode = 'movedelcat';
|
$newmode = 'movedelcat';
|
||||||
$catinfo = get_info('category', $cat_id);
|
$catinfo = get_info('category', $cat_id);
|
||||||
$name = $catinfo['cat_title'];
|
$name = $catinfo['cat_title'];
|
||||||
|
|
||||||
|
if ($catinfo['number'] == 1)
|
||||||
|
{
|
||||||
|
$sql = "SELECT count(*) as total
|
||||||
|
FROM ". FORUMS_TABLE;
|
||||||
|
if( !$result = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Couldn't get Forum count", "", __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
$count = $db->sql_fetchrow($result);
|
||||||
|
$count = $count['total'];
|
||||||
|
print "count = $count";
|
||||||
|
if ($count > 0)
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "You need to delete all forums before you can delete this category");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$select_to = 'Nowhere to move';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$select_to = '<select name="to_id">';
|
||||||
|
$select_to .= get_list('category', $cat_id, 0);
|
||||||
|
$select_to .= '</select>';
|
||||||
|
}
|
||||||
|
|
||||||
$template->set_filenames(array(
|
$template->set_filenames(array(
|
||||||
"body" => "admin/forum_delete_body.tpl")
|
"body" => "admin/forum_delete_body.tpl")
|
||||||
);
|
);
|
||||||
@ -522,7 +561,7 @@ if(isset($mode)) // Are we supposed to do something?
|
|||||||
'NAME' => $name,
|
'NAME' => $name,
|
||||||
'S_FORUM_ACTION' => $PHP_SELF,
|
'S_FORUM_ACTION' => $PHP_SELF,
|
||||||
'S_FROM_ID' => $cat_id,
|
'S_FROM_ID' => $cat_id,
|
||||||
'S_TO_IDS' => $to_ids,
|
'S_SELECT_TO' => $select_to,
|
||||||
'S_NEWMODE' => $newmode,
|
'S_NEWMODE' => $newmode,
|
||||||
'BUTTONVALUE' => $buttonvalue)
|
'BUTTONVALUE' => $buttonvalue)
|
||||||
);
|
);
|
||||||
@ -534,6 +573,8 @@ if(isset($mode)) // Are we supposed to do something?
|
|||||||
$from_id = $HTTP_POST_VARS['from_id'];
|
$from_id = $HTTP_POST_VARS['from_id'];
|
||||||
$to_id = $HTTP_POST_VARS['to_id'];
|
$to_id = $HTTP_POST_VARS['to_id'];
|
||||||
|
|
||||||
|
if (isset($to_id))
|
||||||
|
{
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM " . CATEGORIES_TABLE . "
|
FROM " . CATEGORIES_TABLE . "
|
||||||
WHERE cat_id IN ($from_id, $to_id)";
|
WHERE cat_id IN ($from_id, $to_id)";
|
||||||
@ -553,6 +594,7 @@ if(isset($mode)) // Are we supposed to do something?
|
|||||||
{
|
{
|
||||||
message_die(GENERAL_ERROR, "Couldn't move forums to other category", "", __LINE__, __FILE__, $sql);
|
message_die(GENERAL_ERROR, "Couldn't move forums to other category", "", __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM " . CATEGORIES_TABLE ."
|
$sql = "DELETE FROM " . CATEGORIES_TABLE ."
|
||||||
WHERE cat_id = $from_id";
|
WHERE cat_id = $from_id";
|
||||||
@ -643,7 +685,8 @@ if($total_categories = $db->sql_numrows($q_categories))
|
|||||||
|
|
||||||
if( !$total_forums = $db->sql_numrows($q_forums) )
|
if( !$total_forums = $db->sql_numrows($q_forums) )
|
||||||
{
|
{
|
||||||
message_die(GENERAL_MESSAGE, $lang['No_forums']);
|
// We don't have any forums
|
||||||
|
|
||||||
}
|
}
|
||||||
$forum_rows = $db->sql_fetchrowset($q_forums);
|
$forum_rows = $db->sql_fetchrowset($q_forums);
|
||||||
|
|
||||||
@ -656,13 +699,6 @@ if($total_categories = $db->sql_numrows($q_categories))
|
|||||||
for($i = 0; $i < $total_categories; $i++)
|
for($i = 0; $i < $total_categories; $i++)
|
||||||
{
|
{
|
||||||
$cat_id = $category_rows[$i]['cat_id'];
|
$cat_id = $category_rows[$i]['cat_id'];
|
||||||
|
|
||||||
for($j = 0; $j < $total_forums; $j++)
|
|
||||||
{
|
|
||||||
$forum_id = $forum_rows[$j]['forum_id'];
|
|
||||||
|
|
||||||
if(!$gen_cat[$cat_id])
|
|
||||||
{
|
|
||||||
$template->assign_block_vars("catrow", array(
|
$template->assign_block_vars("catrow", array(
|
||||||
"CAT_ID" => $cat_id,
|
"CAT_ID" => $cat_id,
|
||||||
"CAT_DESC" => stripslashes($category_rows[$i]['cat_title']),
|
"CAT_DESC" => stripslashes($category_rows[$i]['cat_title']),
|
||||||
@ -674,12 +710,10 @@ if($total_categories = $db->sql_numrows($q_categories))
|
|||||||
"U_ADDFORUM" => append_sid("$PHP_SELF?mode=addforum&cat_id=$cat_id"),
|
"U_ADDFORUM" => append_sid("$PHP_SELF?mode=addforum&cat_id=$cat_id"),
|
||||||
"ADDFORUM" => "Add Forum")
|
"ADDFORUM" => "Add Forum")
|
||||||
);
|
);
|
||||||
$gen_cat[$cat_id] = 1;
|
|
||||||
}
|
for($j = 0; $j < $total_forums; $j++)
|
||||||
if( $forum_rows[$j]['cat_id'] != $cat_id)
|
|
||||||
{
|
{
|
||||||
continue;
|
$forum_id = $forum_rows[$j]['forum_id'];
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This should end up in the template using IF...ELSE...ENDIF
|
// This should end up in the template using IF...ELSE...ENDIF
|
||||||
@ -709,7 +743,7 @@ if($total_categories = $db->sql_numrows($q_categories))
|
|||||||
"S_ADDFORUM_ENDFORM" => "</FORM>")
|
"S_ADDFORUM_ENDFORM" => "</FORM>")
|
||||||
);
|
);
|
||||||
} // for ... categories
|
} // for ... categories
|
||||||
// Extra 'category' to create new categories at the end of the list.
|
}// if ... total_categories
|
||||||
$template->assign_block_vars("catrow", array(
|
$template->assign_block_vars("catrow", array(
|
||||||
"S_ADDCAT" => '<FORM METHOD="POST" ACTION="'.append_sid($PHP_SELF).'">
|
"S_ADDCAT" => '<FORM METHOD="POST" ACTION="'.append_sid($PHP_SELF).'">
|
||||||
<INPUT TYPE="text" NAME="catname">
|
<INPUT TYPE="text" NAME="catname">
|
||||||
@ -718,11 +752,6 @@ if($total_categories = $db->sql_numrows($q_categories))
|
|||||||
"S_ADDCAT_ENDFORM" => "</FORM>")
|
"S_ADDCAT_ENDFORM" => "</FORM>")
|
||||||
);
|
);
|
||||||
|
|
||||||
}// if ... total_categories
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message_die(GENERAL_MESSAGE, "There are no Categories or Forums on this board", "", __LINE__, __FILE__, $sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Generate the page
|
// Generate the page
|
||||||
|
Loading…
x
Reference in New Issue
Block a user