Example #1
0
 public function deleteAction()
 {
     $request = new Request();
     $id = $request->getParam('id');
     $Category = new Category();
     $Category->deleteCategory($id);
     header('location: ' . Url::getUrl('category', 'list', array('status' => 10)));
 }
 public function actionDelete($category_id)
 {
     if (isset($_POST['submit'])) {
         Category::deleteCategory($category_id);
         header('Location: /admin/category');
     }
     require_once ROOT . '/views/admin_category/delete.php';
     return true;
 }
Example #3
0
function deleteCategory()
{
    $category = new Category();
    $category->setCategoryId($_REQUEST['id']);
    if ($category->deleteCategory()) {
        Common::jsonSuccess("Category Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
Example #4
0
function deleteCategory($id)
{
    global $bdd, $_TABLES;
    if (!is_null($bdd) && !is_null($_TABLES)) {
        $objCategory = new Category($bdd, $_TABLES);
        $objCategory->deleteCategory($id);
    } else {
        error_log("BDD ERROR : " . json_encode($bdd));
        error_log("TABLES ERROR : " . json_encode($_TABLES));
    }
}
 public function actionDelete($id)
 {
     if (isset($_POST['submit'])) {
         $result = Category::deleteCategory($id);
         if (!$result) {
             $_SESSION['message'] = 'Произошла ошибка при удалении.';
         }
         FunctionLibrary::redirectTo('/admin/category');
     }
     return true;
 }
 /**
  * Action для страницы "Удалить категорию"
  */
 public function actionDelete($id)
 {
     // Обработка формы
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Удаляем категорию
         Category::deleteCategory($id);
         // Перенаправляем пользователя на страницу управлениями категориями
         header('Location: /admin/category/');
     }
     require_once ROOT . '/views/admin_category/delete.php';
     return true;
 }
Example #7
0
        admin_redirect('category.php?act=add', '当前商品分类已经存在');
    }
} elseif ($act == 'delete') {
    //删除商品分类
    //获取要删除商品分类id
    $c_id = isset($_GET['id']) ? $_GET['id'] : 0;
    //判断数据合法性
    if ($c_id == 0) {
        admin_redirect('category.php', '没有选中要删除的分类!');
    }
    //验证商品分类是否可以被删除
    $category = new Category();
    $res = $category->isDelete($c_id);
    if ($res === true) {
        //可以删除
        if ($category->deleteCategory($c_id)) {
            //删除成功
            admin_redirect('category.php', '删除成功!', 1);
        } else {
            //删除失败
            admin_redirect('category.php', '删除失败');
        }
    } else {
        //不能删除
        admin_redirect('category.php', $res);
    }
} elseif ($act == 'edit') {
    //删除商品分类
    //获取要删除商品分类id
    $c_id = isset($_GET['id']) ? $_GET['id'] : 0;
    $category = new Category();
Example #8
0
 public function admin_delete_category($admin)
 {
     if (!Visitor::current()->group()->can("manage_categorize")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to manage categories.", "categorize"));
     }
     Category::deleteCategory($_REQUEST['id']);
     Flash::notice(__("Category deleted.", "categorize"), "/admin/?action=manage_category");
 }
<?php

session_start();
require_once '../classes/connection.class.php';
require_once '../classes/category.class.php';
require_once '../classes/locate.class.php';
$category_id = isset($_GET['category_id']) ? (int) $_GET['category_id'] : '';
$deleteCategoryObj = new Category();
$deleteCategoryObj->setCategoryID($category_id);
$flag = $deleteCategoryObj->deleteCategory();
/*echo '<pre>';
print_r($deleteBlogObj);
echo '</pre>';
exit;*/
if ($flag) {
    header('location:../index.php?page=category&action=view');
    $_SESSION['category_deleted'] = $deleteCategoryObj->msg = "The category successfully deleted";
} else {
    header('location:../index.php?page=category&action=view');
    $_SESSION['category_not_deleted'] = $deleteCategoryObj->msg = "The category couldn't be successfully deleted";
}
            header("Location: restaurants");
            exit;
        }
        $responseuri = $_POST['responseuri'];
        if (!isset($_POST['id'])) {
            header("Location: restaurants");
            exit;
        }
        $categoryid = $_POST['id'];
        try {
            $category = Category::get($categoryid, $userid);
            if ($category->hasParent()) {
                throw new ExceptionCustom('Invalid category.', ERROR_INVALID_VALUE);
            }
            $categoryname = $category->getProperty('name');
            Category::deleteCategory($categoryid, $userid);
            $formmessage = 'Category "' . $categoryname . '" deleted.';
            $formmessageclass = 'green';
            break;
        } catch (Exception $e) {
            $formmessage = $e->getMessage();
            trigger_error($formmessage);
            $formmessageclass = 'red';
            break;
        }
    } else {
        header("Location: logout");
        exit;
    }
} while (1 == 0);
include "common/sessionmessage.php";
Example #11
0
// Include common functions and declarations
require_once "../../include/common.php";
// Create Category object
$category = new Category(getGetValue("categoryId"));
// Check if current user has edit permissions
if (!$category->hasEditPermission()) {
    $login->printLoginForm();
    exit;
}
// Get referer value if any
$referer = getPostValue("referer");
// Delete category
if (!empty($_POST["deleteCategory"])) {
    // Delete category
    $category->deleteCategory();
    // Redirect to referer
    redirect(!empty($referer) ? $referer : scriptUrl . "/" . folderCategory . "/" . fileCategoryIndex);
} else {
    if (!empty($_GET["save"])) {
        $errors = $category->saveCategory();
        // Redirect to category index
        if ($errors->getNumberOfErrors() == 0) {
            redirect(!empty($referer) ? $referer : scriptUrl . "/" . folderCategory . "/" . fileCategoryIndex);
        }
    }
}
// Generate navigation info
$site->addNavigationLink(scriptUrl . "/" . folderAdmin, $lAdminIndex["Header"]);
$site->addNavigationLink(scriptUrl . "/" . folderCategory, $lCategoryIndex["Header"]);
$site->addNavigationLink(scriptUrl . "/" . folderCategory . "/" . fileCategoryEdit . (!empty($category->id) ? "?categoryId=" . $category->id : ""), empty($category->id) ? $lCategoryEdit["NewCategory"] : $lCategoryEdit["EditCategory"]);
<?php

include "../../../classes/Database.php";
include "../../../classes/Connection.php";
include_once "../../../includes/bootstrap.php";
include "../../../classes/Category.php";
include "../../../classes/AdminAction.php";
include "../../../includes/security.funcs.inc";
include_once "../../../includes/Pagination.php";
//delete photo
if (isset($_REQUEST['delete'])) {
    Category::deleteCategory($_REQUEST['delete']);
    $updates = 'Delete product category content';
    AdminAction::addAdminAction($_SESSION['admin_name'], $updates);
}
?>
<!DOCTYPE html>  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">  
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  <link rel="stylesheet" type="text/css" media="screen" href="<?php 
echo $ROOT_URL;
?>
_admin/_assets/css/core3.css" /> 
  <link rel="stylesheet" type="text/css" media="screen" href="<?php 
echo $ROOT_URL;
?>
_admin/_assets/css/modules.css" /> 
</head>
$db = new Database();
$ca = new Category();
$category = $db->select($ca->getCategoryById($id))->fetch_assoc();
if (isset($_POST['submit'])) {
    //assign post variables
    $name = mysqli_real_escape_string($db->link, $_POST['name']);
    // simple validation
    if ($name == '') {
        // set error
        $error = 'Please fill out all required fields.';
    } else {
        $update_row = $db->update($ca->updateCategory($name, $id));
    }
}
if (isset($_POST['delete'])) {
    $delete_row = $db->delete($ca->deleteCategory($id));
}
?>

<form method="post" action="edit_category.php?id=<?php 
echo $id;
?>
">
  <div class="form-group">
    <label>Category Name</label>
    <input name="name" type="text" class="form-control" placeholder="Category" value="<?php 
echo $category['Name'];
?>
">
  </div>
  <div>