include 'base.php';
User::protect();
include_class('links');
$category_id = $_GET['category_id'] > 0 && is_numeric($_GET['category_id']) ? $_GET['category_id'] : 0;
if ($category_id != 0) {
    $lc = LinkCategory::get($category_id);
    if (!db::isError($lc)) {
        // do nothing
    }
}
if ($_POST['submit'] && !db::isError($lc)) {
    $title = $_POST['title'];
    $description = $_POST['description'];
    if (!$lc) {
        $res = LinkCategory::add($title, $description);
    } else {
        $res = $lc->add($title, $description);
    }
    if (!db::isError($res)) {
        header('Location: links.php?category_id=' . $res->getID());
    }
}
$editors = array('description');
$section = 'links';
$page_title = 'Add Link Category';
include 'layout/header.php';
?>

<div id="breadcrumb">
	<a href="index.php">Audition &#62;</a>