Ejemplo n.º 1
0
<?php

include 'category.php';
if (isset($_GET['id'])) {
    if ($_GET['value'] == 'Delete') {
        $category = new category($_GET['id']);
        $category->delete();
        $jsondata = json_encode($category->getallcategory());
        echo $jsondata;
    }
    if ($_GET['value'] == 'Update') {
        $errors = [];
        $category = new category($_GET['id']);
        if (empty(trim($_GET['name']))) {
            $errors[] = "the name is empty";
            $_SESSION['errors'] = $errors;
        }
        if ($category->category_is_exist($_GET['name'])) {
            $errors[] = "the category is already exist";
            $_SESSION['errors'] = $errors;
        }
        if (empty(trim($_GET['desc']))) {
            $errors[] = "the desc is empty";
            $_SESSION['errors'] = $errors;
        }
        if (!empty($errors)) {
            $errors[] = $_GET["id"];
        } else {
            $category->category_name = $_GET['name'];
            $category->category_desc = $_GET['desc'];
            $category->update();
                }
            }
        }
        break;
    case 'delete_entry':
        // Check for dependencies
        $administration_category = new category($_POST['categories_id']);
        if ($administration_category->has_dependencies()) {
            $error_level = 2;
            // Related role(s) exist
            $_POST['action'] = '';
        }
        break;
    case 'delete_entry_confirmed':
        $administration_category = new category($_POST['categories_id']);
        $administration_category->delete();
        unset($_POST['categories_id']);
        $_POST['action'] = '';
        break;
}
// Create a new category object with id == 0 (default)
$_SESSION['category'] = new category();
// header //
require DIR_WS_INCLUDES . 'header.php';
?>
<!-- body //-->
  <table border="0" width="100%" cellspacing="3" cellpadding="3">
    <tr>
      <td width="<?php 
echo BOX_WIDTH;
?>
<?php

include 'categoryclass.php';
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    // get the 'id' variable from the URL
    $id = $_GET['id'];
    $categ = new category();
    $categ->delete($id);
    header("location:addcategory.php");
} else {
    header("location:addcategory.php");
}
Ejemplo n.º 4
0
                $_SESSION['category_manager']['error_msg'] = 'Please enter a name and description!';
            }
            localRedirect('/admin/category-manager.php');
            break;
        case 'update':
            if (!empty($_POST['catDesc']) and !empty($_POST['catName'])) {
                $result = category::update((int) $_POST['cat_parent'], $_POST['catName'], $_POST['catDesc']);
                $_SESSION['category_manager']['error_msg'] = PEAR::isError($result) ? 'Failed to insert category: ' . $result->message : 'Category updated';
            } else {
                $_SESSION['category_manager']['error_msg'] = 'Please enter a name and description!';
            }
            localRedirect('/admin/category-manager.php');
            break;
        case 'delete':
            if (!empty($_POST['cat_parent'])) {
                $result = category::delete($_POST['cat_parent']);
                $_SESSION['category_manager']['error_msg'] = PEAR::isError($result) ? 'Failed to delete category: ' . $result->message : 'Category deleted';
            } else {
                $_SESSION['category_manager']['error_msg'] = 'Please select a category';
            }
            localRedirect('/admin/category-manager.php');
            break;
        default:
            localRedirect('/admin/category-manager.php');
    }
}
/**
 * Create the menu, set the db to assoc mode
 */
require_once 'HTML/TreeMenu.php';
$treeMenu = new HTML_TreeMenu();
Ejemplo n.º 5
0
     foreach ($CATEGORY as $c) {
         update_category($c);
     }
     $do->cache();
     dmsg('更新成功', "?mid={$mid}&file={$file}");
     break;
 case 'cache':
     $do->repair();
     dmsg('更新成功', "?mid={$mid}&file={$file}");
     break;
 case 'delete':
     if ($catid) {
         $catids = $catid;
     }
     $catids or msg();
     $do->delete($catids);
     $NUM > 200 ? $do->cache() : $do->repair();
     dmsg('删除成功', $forward);
     break;
 case 'update':
     if (!$category || !is_array($category)) {
         msg();
     }
     $do->update($category);
     foreach ($category as $catid => $v) {
         $CATEGORY[$catid] = $db->get_one("SELECT * FROM {$table} WHERE catid={$catid}");
         update_category($CATEGORY[$catid]);
     }
     $NUM > 200 ? $do->cache() : $do->repair();
     dmsg('更新成功', $forward);
     break;
Ejemplo n.º 6
0
 public function delete_category($id)
 {
     if (!$this->user->is_logged_in()) {
         redirect("/user/main/userLogin", 'location');
     } else {
         $category = new category($id);
         $category->delete();
         redirect('/index.php/user/blog/categories', 'location');
     }
 }
Ejemplo n.º 7
0
<?php

if (isset($_REQUEST['i']) && !empty($_REQUEST['i'])) {
    $object_category = new category();
    $object_category->setId($_REQUEST['i']);
    if ($object_category->delete()) {
        print 'sucess';
    } else {
        print 'error';
    }
} else {
    print 'error';
}