Example #1
0
 public function Delete()
 {
     global $obj, $model, $param1;
     include_once 'Model/category.php';
     $model = new Category();
     $model->Id = $param1;
     if ($model->Delete()) {
         print '<span class="success">Category Deleted</span>';
     } else {
         print '<span class="error">' . $model->Error . '</span>';
     }
     include_once 'View/Category/index.php';
 }
// page vars
$page_title = "";
$id = $_REQUEST['id'];
// id required
if ($id == "") {
    header("Location:mainpage.php");
    exit;
}
// if form was submitted
if ($_POST['commit'] == "Cancel") {
    header("Location:category_list.php");
    exit;
}
if ($_POST['commit'] == "Delete Category") {
    $objCategory = new Category();
    $objCategory->Delete($id);
    header("Location:category_list.php");
    exit;
}
$objCategory = new Category($id);
include "includes/pagetemplate.php";
function PageContent()
{
    global $objCategory;
    global $id;
    ?>

            <div class="layout laymidwidth">

                <?php 
    $aLabels = array();
Example #3
0
     $new_category = new Category();
     if ($new_category->Create($name, $priority, $desc)) {
         $info .= lng('CAT_COMPLITE');
     } else {
         $info .= lng('CAT_EXIST');
     }
 } elseif ($id and $name and Filter::input('edit', 'post', 'bool')) {
     $category = new Category($id);
     if ($category->Edit($name, $priority, $desc)) {
         $info .= lng('CAT_UPDATED');
     } else {
         $info .= lng('CAT_EXIST');
     }
 } elseif ($id and Filter::input('delete', 'post', 'bool')) {
     $category = new Category($id);
     if ($category->Delete()) {
         $info .= lng('CAT_DELETED');
     } else {
         $info .= lng('CAT_NOT_EXIST');
     }
     $id = false;
 }
 $cat_list = CategoryManager::GetList($id);
 include View::Get('category_header.html', $st_subdir . 'category/');
 if ($id) {
     $cat_item = new Category($id);
     if ($cat_item->Exist()) {
         $cat_name = $cat_item->GetName();
         $cat_desc = $cat_item->GetDescription();
         $cat_priority = $cat_item->GetPriority();
         include View::Get('category_edit.html', $st_subdir . 'category/');
    }
    // Validate action
    if (!empty($_POST['action']) && in_array($_POST['action'], array('move', 'delete'))) {
        $data['action'] = $_POST['action'];
    } else {
        $errors['action'] = 'Invalid category action';
    }
    // Move videos if no errors were made
    if (empty($errors)) {
        // Move videos
        $query = "UPDATE " . DB_PREFIX . "videos SET cat_id = {$data['move']} WHERE cat_id = {$data['category']}";
        $db->Query($query);
        // Delete category if requested
        if ($data['action'] == 'delete') {
            $cat = new Category($data['category']);
            Category::Delete($data['category']);
            $message = "{$cat->cat_name} has been deleted.";
        } else {
            $message = 'Videos has been moved.';
        }
        // Output message
        $message_type = 'success';
        unset($data);
    } else {
        $message = 'The following errors were found. Please correct them and try again.';
        $message .= '<br /><br /> - ' . implode('<br /> - ', $errors);
        $message_type = 'error';
    }
}
// Retrieve Category names
$query = "SELECT " . DB_PREFIX . "categories.cat_id, cat_name, COUNT(video_id) AS video_count ";
Example #5
0
     USES_paypal_class_category();
     $id = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : 0;
     if ($id > 0) {
         $C = new Category($id);
         $C->DeleteImage();
         $view = 'editcat';
         $_REQUEST['id'] = $id;
     } else {
         $view = 'catlist';
     }
     break;
 case 'deletecat':
     USES_paypal_class_category();
     $C = new Category($_REQUEST['cat_id']);
     if (!$C->isUsed()) {
         $C->Delete();
     } else {
         $content .= "Category has related products, can't delete.";
     }
     $view = 'catlist';
     break;
 case 'delete_img':
     $img_id = (int) $_REQUEST['img_id'];
     Product::DeleteImage($img_id);
     $view = 'editproduct';
     break;
 case 'saveproduct':
     $P = new Product($_POST['id']);
     if (!$P->Save($_POST)) {
         $content .= PAYPAL_errMsg($P->PrintErrors());
         $view = 'editproduct';
     $myCategory->SetValues($_POST);
     $myCategory->SetValue('user_id', $myUser->GetPrimary());
     // Save the Make
     if ($myCategory->Save()) {
         SetAlert('Category Successfully Saved.', 'success');
         LogAction('Saved Category: ' . stripslashes($myCategory->GetValue('category')), 1);
         header('location:' . PATH . 'categories');
         die;
     }
 }
 // If Deleting
 if ($_POST['submit'] == 'delete') {
     $myCategory->SetValues($_POST);
     $name = stripslashes($myCategory->GetValue('category'));
     // Remove from the DB
     if (!$myCategory->Delete()) {
         throw new SimplException('Error deleting from the database, please try again.');
     }
     // Everything went fine
     SetAlert('Category Deleted Successfully', 'success');
     LogAction('Deleted Category: ' . $name, 1);
     header('location:' . PATH . 'categories');
     die;
 }
 // Set the requested primary key and get its info
 if ($_GET['id'] != '' && $myCategory->GetPrimary() == '') {
     $myCategory->SetPrimary((int) $_GET['id']);
     // Try to get the info
     if (!$myCategory->GetInfo()) {
         throw new SimplException('Invalid category, please try another.', 3, 'Access to invalid category - ' . $myCategory->GetPrimary(), PATH . 'categories');
     }
Example #7
0
 function Delete()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $categoryID = Kit::GetParam('categoryid', _POST, _INT);
     // Remove the category
     $resObject = new Category($db);
     if (!$resObject->Delete($categoryID)) {
         trigger_error($resObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse('Category deleted');
     $response->Respond();
 }