<?php
// check rights
if ($login->check_rights()>=2):
// loading of reqired classes
include CLASSES_PATH."Forums.php";
// creating of instances
$forums=new Forums();
// add new
if ($_GET["action"]=="add" AND $_POST["name"]!="" AND isset($_POST["category"])) { $forums->add(); }
// move up
if ($_GET["action"]=="move_up" AND isset($_GET["position"])) { $forums->move_up(); }
// move down
if ($_GET["action"]=="move_down" AND isset($_GET["position"])) { $forums->move_down(); }
// delete
if ($_GET["action"]=="delete" AND isset($_GET["id"])) { $forums->delete(); }
?>

<h2><?php echo LANG_FORUMS; ?></h2>

<?php if (!isset($_GET["f2"])): ?>

<form action="./admin.php?f=forums&amp;action=add" method="post">

<div>

<p><strong><?php echo LANG_NEW_FORUM; ?>:</strong><br /><input type="text" name="name" style="width: 150px;"<?php if (isset($_POST["submit"]) AND $_POST["name"]=="") { echo " class=\"input-error\""; } ?> /></p>

<p><strong><?php echo LANG_IN_CATEGORY; ?>:</strong><br />
<select name="category" style="width: 200px;">
<?php $forums->select_category(); ?>
</select>
</p>

</div>

<div>

<p><input type="submit" name="submit" value="<?php echo LANG_SAVE; ?>" /></p>

</div>

</form>

<?php $forums->print_forums(); ?>

<?php endif; if (isset($_GET["f2"])): ?>

<?php
// update
if (isset($_POST["submit"]) AND $_POST["name"]!="") { $forums->update(); }
?>

<form action="./admin.php?f=forums&amp;f2=edit_forum&amp;id=<?php echo($_GET["id"]); ?>" method="post">

<div>

<p><strong><?php echo LANG_FORUM_NAME; ?>:</strong><br /><input type="text" name="name" style="width: 200px;" value="<?php echo htmlspecialchars($forums->forum_details("name")); ?>"<?php if (isset($_POST["submit"]) AND $_POST["name"]=="") { echo " class=\"input-error\""; } ?> /></p>

<p><strong><?php echo LANG_DESCRIPTION; ?>:</strong><br /><input type="text" name="description" style="width: 400px;" value="<?php echo htmlspecialchars($forums->forum_details("description")); ?>" /></p>

<p><strong><?php echo LANG_YOU_MUST_BE_LOGGED_TO_READING_POSTS; ?>:</strong><br /><input type="radio" name="read_ntbl" value="1"<?php if ($forums->forum_details("read_ntbl")==1) { echo " checked=\"checked\""; } ?> /> <?php echo LANG_YES; ?> <input type="radio" name="read_ntbl" value="0"<?php if ($forums->forum_details("read_ntbl")==0) { echo " checked=\"checked\""; } ?> /> <?php echo LANG_NO; ?>&nbsp;&nbsp;&nbsp;<select name="read_rights"><?php $forums->print_rights("read"); ?></select> <?php echo LANG_REQUIRED_RIGHTS; ?></p>

<p><strong><?php echo LANG_YOU_MUST_BE_LOGGED_TO_WRITING_POSTS; ?>:</strong><br /><input type="radio" name="write_ntbl" value="1"<?php if ($forums->forum_details("write_ntbl")==1) { echo " checked=\"checked\""; } ?> /> <?php echo LANG_YES; ?> <input type="radio" name="write_ntbl" value="0"<?php if ($forums->forum_details("write_ntbl")==0) { echo " checked=\"checked\""; } ?> /> <?php echo LANG_NO; ?>&nbsp;&nbsp;&nbsp;<select name="write_rights"><?php $forums->print_rights("write"); ?></select> <?php echo LANG_REQUIRED_RIGHTS; ?></p>

<p><strong><?php echo LANG_FORUM_IS_LOCKED; ?>:</strong><br /><input type="radio" name="locked" value="1"<?php if ($forums->forum_details("locked")==1) { echo " checked=\"checked\""; } ?> /> <?php echo LANG_YES; ?> <input type="radio" name="locked" value="0"<?php if ($forums->forum_details("locked")==0) { echo " checked=\"checked\""; } ?> /> <?php echo LANG_NO; ?></p>

</div>

<div>

<p><input type="submit" name="submit" value="<?php echo LANG_SAVE_CHANGES; ?>" /> <input type="button" onclick="parent.location='./admin.php?f=forums';" value="<?php echo LANG_BACK; ?>" /></p>

</div>

</form>

<?php endif; else: $access_denied=1; endif; ?>