function deleteCategory() { $category = new Category(); $category->setCategoryId($_REQUEST['id']); if ($category->deleteCategory()) { Common::jsonSuccess("Category Deleted Successfully"); } else { Common::jsonError("Error"); } }
require_once '../model/paths.php'; $session = new Session(); if (!$session->isLogin) { redirect("../login.php"); } $database = new Database(); $user = new User(); $category = new Category(); if (isset($_POST['categoryName'])) { $categoryName = $database->escapeString($_POST['categoryName']); $parent = $database->escapeString($_POST['parent']); $category->setCategory($categoryName); $category->setInherit($parent); if ($category->create($database)) { echo "true"; } else { echo "false"; } } else { if (isset($_POST['categoryId'])) { foreach ($_POST['categoryId'] as $categoryId) { $category->setCategoryId($categoryId); $category->delete($database); $category->deleteCategories($database); } echo "true"; } else { echo "Try again later"; } }
<?php require_once '../model/paths.php'; $session = new Session(); if (!$session->isLogin) { redirect("../login.php"); } $database = new Database(); $user = new User(); $category = new Category(); if ($_POST['category']) { $category->setCategoryId($database->escapeString($_POST['categoryId'])); foreach ($_POST as $key => $value) { if ($key == "categoryId" || $key == "submit") { continue; } $category->update($database, $key, $value); } redirect("../posts.php?posts=4&category={$_POST['categoryId']}"); } else { echo "<h2>Problem in editing category. Try again later or contact your administrator.</h2>"; }
$startPos++; } echo "true"; } else { if (isset($_POST['catIds']) && $_POST['catIds'] != "" && isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "true") { // add pages to the menu $menuId = $database->escapeString($_POST['menuId']); $appearName = $database->escapeString($_POST['appearName']); $links->setMenuId($menuId); $links->setIsCustomLink(0); $links->setHttp(""); $links->setPageId(0); $startPos = $links->numByMenu($database) + 1; foreach ($_POST['catIds'] as $id) { if ($appearName == "") { $category->setCategoryId($database->escapeString($id)); $category->getById($database); $links->setAppearName($category->getCategory()); } else { $links->setAppearName($appearName); } $links->setCategoryId($database->escapeString($id)); $links->setPosition($startPos); $links->create($database); $startPos++; } echo "true"; } else { if (isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "false" && isset($_POST['isCustomLink']) && $_POST['isCustomLink'] == "true") { // add pages to the menu $menuId = $database->escapeString($_POST['menuId']);