/** * Create the category. * @return {int} ID of the new category. */ function createCategory() { if (!isset($_POST['category-title'], $_POST['category-parent'], $_POST['category-permalink'])) { header('Location: ../admin.php?error=missing_data_for_category'); exit; } $permalink = trim($_POST['category-permalink']); $category = new ae_CategoryModel(); if (isset($_POST['edit-id'])) { $category->setId($_POST['edit-id']); } $category->setTitle($_POST['category-title']); $category->setParent($_POST['category-parent']); if ($permalink != '') { $category->setPermalink($permalink); } $category->save(); return $category->getId(); }