Parial forum admin, add/edit forum is working

git-svn-id: file:///svn/phpbb/trunk@886 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Bart van Bragt 2001-08-15 22:13:50 +00:00
parent 816f2670fa
commit d4ca9eb809
3 changed files with 224 additions and 54 deletions

View file

@ -29,52 +29,171 @@ if($setmodules==1)
return;
}
function check_forum_name($forumname)
{
global $db;
$sql = "SELECT * from " . FORUMS_TABLE . "WHERE forum_name = '$forumname'";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't get list of Categories", "", __LINE__, __FILE__, $sql);
}
if ($db->sql_num_rows($result) > 0)
{
message_die(GENERAL_ERROR, "A forum with that name already exists", "", __LINE__, __FILE__, $sql);
}
}
//
// Include required files, get $phpEx and check permissions
//
require('pagestart.inc');
if($HTTP_POST_VARS['newcat'] != "")
if (isset($HTTP_POST_VARS['mode']))
{
$mode = 'newcat';
$catname = $HTTP_POST_VARS['catname'];
$mode = $HTTP_POST_VARS['mode'];
}
if(isset($HTTP_POST_VARS['newforum']))
elseif (isset($HTTP_GET_VARS['mode']))
{
$mode = 'newcat';
$forumname = $HTTP_POST_VARS['forumname'];
list($cat_id) = $HTTP_POST_VARS['newforum'];
$mode = $HTTP_GET_VARS['mode'];
}
else
{
unset($mode);
}
$template_header = "admin/page_header.tpl";
if(isset($mode))
if(isset($mode)) // Are we supposed to do something?
{
switch($mode)
{
case 'newcat':
case 'createforum': // Create a forum in the DB
// There is no problem having duplicate forum names so we won't check for it.
$sql = "INSERT INTO ".FORUMS_TABLE."(
forum_name,
cat_id,
forum_desc,
forum_status)
VALUES (
'".$HTTP_POST_VARS['forumname']."',
'".$HTTP_POST_VARS['cat_id']."',
'".$HTTP_POST_VARS['forumdesc']."',
'".$HTTP_POST_VARS['forumstatus']."')";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql);
}
print "Createforum: ". $HTTP_POST_VARS['forumname']." sql= <pre>$sql</pre>";
break;
case 'modforum': // Modify a forum in the DB
$sql = "UPDATE ".FORUMS_TABLE." SET
forum_name = '".$HTTP_POST_VARS['forumname']."',
cat_id = '".$HTTP_POST_VARS['cat_id']."',
forum_desc = '".$HTTP_POST_VARS['forumdesc']."',
forum_status = '".$HTTP_POST_VARS['forumstatus']."'
WHERE forum_id = '".$HTTP_POST_VARS['forum_id']."'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql);
}
print "Modforum: ". $HTTP_POST_VARS['forumname']." sql= <pre>$sql</pre>";
break;
case 'addcat':
print "Newcat: $catname";
break;
case 'newforum':
print "Newforum: cat = $cat_id name = $forumname";
case 'addforum':
case 'editforum':
if ($mode == 'editforum')
{
// $newmode determines if we are going to INSERT or UPDATE after posting?
$newmode = 'modforum';
$buttonvalue = 'Change';
$forum_id = $HTTP_GET_VARS['forum_id'];
$sql = " SELECT
forum_name,
cat_id,
forum_desc,
forum_status
FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't get Forum information", "", __LINE__, __FILE__, $sql);
}
if( $db->sql_numrows($result) != 1 )
{
message_die(GENERAL_ERROR, "Forum doesn't exist or multiple forums with ID $forum_id", "", __LINE__, __FILE__);
}
$row = $db->sql_fetchrow($result);
$forumname = $row['forum_name'];
$cat_id = $row['cat_id'];
$forumdesc = $row['forum_desc'];
$forumstatus = $row['forum_status'];
}
else
{
$newmode = 'createforum';
$buttonvalue = 'Create';
$forumname = stripslashes($HTTP_POST_VARS['forumname']);
$cat_id = $HTTP_POST_VARS['cat_id'];
$forumdesc = '';
$forumstatus = FORUM_UNLOCKED;
$forum_id = '';
}
$sql = "SELECT * FROM " . CATEGORIES_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't get list of Categories", "", __LINE__, __FILE__, $sql);
}
$cat_list = "";
while( $row = $db->sql_fetchrow($result) )
{
$s = "";
if ($row['cat_id'] == $cat_id)
{
$s = " SELECTED";
}
$catlist .= "<OPTION VALUE=\"$row[cat_id]\"$s>$row[cat_title]</OPTION>\n";
}
$forumstatus == FORUM_LOCKED ? $forumlocked = "selected" : $forumunlocked = "selected";
$statuslist = "<OPTION VALUE=\"".FORUM_UNLOCKED."\" $forumunlocked>Unlocked</OPTION>\n";
$statuslist .= "<OPTION VALUE=\"".FORUM_LOCKED."\" $forumlocked>Locked</OPTION>\n";
$template->set_filenames(array(
"body" => "admin/forum_edit_body.tpl")
);
$template->assign_vars(array(
'FORUMNAME' => $forumname,
'DESCRIPTION' => $forumdesc,
'S_CATLIST' => $catlist,
'S_STATUSLIST' => $statuslist,
'S_FORUMID' => $forum_id,
'S_NEWMODE' => $newmode,
'BUTTONVALUE' => $buttonvalue)
);
$template->pparse("body");
break;
default:
print "Oops! Wrong mode..";
}
include('page_footer_admin.'.$phpEx);
exit;
}
$template->set_filenames(array(
"body" => "admin/forums_body.tpl")
);
$viewcat = (!empty($HTTP_GET_VARS['viewcat'])) ? $HTTP_GET_VARS['viewcat'] : -1;
//
// Start page proper
//
$template->set_filenames(array(
"body" => "admin/forums_body.tpl")
);
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
WHERE f.cat_id = c.cat_id
@ -124,7 +243,7 @@ if($total_categories = $db->sql_numrows($q_categories))
"CAT_ID" => $cat_id,
"CAT_DESC" => stripslashes($category_rows[$i]['cat_title']),
"U_VIEWCAT" => append_sid("index.$phpEx?viewcat=$cat_id"),
"U_ADDFORUM" => append_sid("$PHPSELF?mode=addforum&cat=$cat_id"),
"U_ADDFORUM" => append_sid("$PHPSELF?mode=addforum&cat_id=$cat_id"),
"ADDFORUM" => "Add Forum")
);
$gen_cat[$cat_id] = 1;
@ -139,15 +258,28 @@ if($total_categories = $db->sql_numrows($q_categories))
"FORUM_NAME" => stripslashes($forum_rows[$j]['forum_name']),
"FORUM_DESC" => stripslashes($forum_rows[$j]['forum_desc']),
"ROW_COLOR" => $row_color,
"U_VIEWFORUM" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&" . $forum_rows[$j]['forum_posts']))
"U_VIEWFORUM" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&" . $forum_rows[$j]['forum_posts']),
"FORUM_EDIT" => "<a href='$PHPSELF?mode=editforum&forum_id=$forum_id'>Edit/Delete</a>",
"FORUM_UP" => "<a href='$PHPSELF?mode=order&pos=1&forum_id=$forum_id'>Move up</a>",
"FORUM_DOWN" => "<a href='$PHPSELF?mode=order&pos=-1&forum_id=$forum_id'>Move down</a>")
);
} // for ... forums
$template->assign_block_vars("catrow.forumrow", array(
"S_NEWFORUM" => "<INPUT TYPE='text' NAME='forumname'> <INPUT TYPE='submit' NAME='newforum[$cat_id]' VALUE='New Forum'>")
"S_ADDFORUM" => '<FORM METHOD="POST" ACTION="'.append_sid($PHP_SELF).'">
<INPUT TYPE="text" NAME="forumname">
<INPUT TYPE="hidden" NAME="cat_id" VALUE="'.$cat_id.'">
<INPUT TYPE="hidden" NAME="mode" VALUE="addforum">
<INPUT TYPE="submit" NAME="submit" VALUE="Create new Forum">',
"S_ADDFORUM_ENDFORM" => "</FORM>")
);
} // for ... categories
// Extra 'category' to create new categories at the end of the list.
$template->assign_block_vars("catrow", array(
"S_NEWCAT" => "<INPUT TYPE='text' NAME='catname'> <INPUT TYPE='submit' NAME='newcat' VALUE='New Category'>")
"S_ADDCAT" => '<FORM METHOD="POST" ACTION="'.append_sid($PHP_SELF).'">
<INPUT TYPE="text" NAME="catname">
<INPUT TYPE="hidden" NAME="mode" VALUE="addcat">
<INPUT TYPE="submit" NAME="submit" VALUE="Create new category">',
"S_ADDCAT_ENDFORM" => "</FORM>")
);
}// if ... total_categories
@ -156,14 +288,6 @@ else
message_die(GENERAL_MESSAGE, "There are no Categories or Forums on this board", "", __LINE__, __FILE__, $sql);
}
$othertext = "<a href='$PHPSELF?mode=addcat'>Add category</a><br>\n";
$template->assign_vars(array(
"S_FORMSTART" => "<FORM METHOD='post' ACTION='$PHP_SELF'>",
"S_FORMEND" => "</FORM>"
)
);
//
// Generate the page
//

View file

@ -0,0 +1,52 @@
<br clear="all" />
<h1>Edit Forum</h1>
<p>The form below will allow you to customize all the general board options. For User and Forum configurations use the related links on the left hand side.</p>
<form action="{S_FORUM_ACTION}" method="POST">
<table width="99%" cellpadding="1" cellspacing="0" border="0" align="center">
<tr>
<td class="tablebg" width="100%"><table width="100%" cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="cat" colspan="2"><span class="cattitle">General Forum Settings</span></td>
</tr>
<tr>
<td class="row1">Forum Name:</td>
<td class="row2"><input type="text" size="25" name="forumname" value="{FORUMNAME}"></td>
</tr>
<tr>
<td class="row1">Description:</td>
<td class="row2"><textarea ROWS="15" COLS="45" WRAP="VIRTUAL" name="forumdesc">{DESCRIPTION}</TEXTAREA></td>
</tr>
<tr>
<td class="row1">Category:</td>
<td class="row2">
<select name="cat_id">
{S_CATLIST}
</select>
</td>
</tr>
<tr>
<td class="row1">Forum Status:</td>
<td class="row2">
<select name="forumstatus">
{S_STATUSLIST}
</select>
</td>
</tr>
<tr>
<td class="row2" colspan="2" align="center">
<input type="hidden" name="mode" value="{S_NEWMODE}">
<input type="hidden" name="forum_id" value="{S_FORUMID}">
<input type="submit" name="submit" value="{BUTTONVALUE}">
</td>
</tr>
</table></td>
</tr>
</table>
</form>
<br clear="all">

View file

@ -1,32 +1,26 @@
<p>Use this page to manage your forums and categories</p>
{S_FORMSTART}
<div align="center"><table width="98%" cellpadding="1" cellspacing="0" border="0">
<tr>
<td class="tablebg"><table width="100%" cellpadding="3" cellspacing="1" border="0">
<tr>
<th>&nbsp;</td>
<th>&nbsp;{L_FORUM}&nbsp;</td>
<th>&nbsp;{L_TOPICS}&nbsp;</td>
<th>&nbsp;{L_POSTS}&nbsp;</td>
<th>&nbsp;{L_LASTPOST}&nbsp;</td>
<th>&nbsp;{L_MODERATOR}&nbsp;</td>
</tr>
<!-- BEGIN catrow -->
<tr>
<td class="cat" colspan="6"><span class="cattitle"><b><a href="{catrow.U_VIEWCAT}">{catrow.CAT_DESC}</a></b>&nbsp;</span>{catrow.S_NEWCAT}</td>
</tr>
<td class="cat" colspan="6"><span class="cattitle"><b><a href="{catrow.U_VIEWCAT}">{catrow.CAT_DESC}</a></b></span>{catrow.S_ADDCAT}</span></td>
</tr>{catrow.S_ADDCAT_ENDFORM}
<!-- BEGIN forumrow -->
<tr>
<td class="row1" align="center" valign="middle" width="7%">{catrow.forumrow.FOLDER}</td>
<td class="row2"><span class="gen">{catrow.forumrow.S_NEWFORUM}<a href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a></span><br><span class="gensmall">{catrow.forumrow.FORUM_DESC}</span></td>
<td class="row1" width="5%" align="center" valign="middle"><span class="gen">{catrow.forumrow.TOPICS}</span></td>
<td class="row2" width="5%" align="center" valign="middle"><span class="gen">{catrow.forumrow.POSTS}</span></td>
<td class="row1" width="15%" align="center" valign="middle"><span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
<td class="row2" width="5%" align="center" valign="middle"><span class="gensmall">{catrow.forumrow.MODERATORS}</span></td></tr>
<td class="row1" align="center" valign="middle">{catrow.forumrow.FOLDER}</td>
<td class="row2"><span class="gen">{catrow.forumrow.S_ADDFORUM}{catrow.forumrow.S_NEWFORUM}<a href="{catrow.forumrow.U_VIEWFORUM}" target="_new">{catrow.forumrow.FORUM_NAME}</a></span><br><span class="gensmall">{catrow.forumrow.FORUM_DESC}</span></td>
{catrow.forumrow.S_ADDFORUM_ENDFORM}
<td class="row1" align="center" valign="middle"><span class="gen">{catrow.forumrow.FORUM_EDIT}</span></td>
<td class="row2" align="center" valign="middle"><span class="gen">{catrow.forumrow.FORUM_UP} {catrow.forumrow.FORUM_DOWN}</span></td>
<td class="row1" align="center" valign="middle"><span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
<td class="row2" align="center" valign="middle"><span class="gensmall">{catrow.forumrow.MODERATORS}</span></td></tr>
</tr>
<!-- END forumrow -->
<!-- END catrow -->
</table></td>
</tr>
</table></div>
{S_FORMEND}