function delete($id = FALSE) { $c = new Category($id); $c->delete(); $this->session->set_flashdata('msg', '<div class="alert alert-success">Category was succesfully deleted.</div>'); redirect($this->agent->referrer()); }
/** * Delete category * * @param void * @return null */ function delete_category() { if ($this->active_category->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if ($this->request->isSubmitted()) { $delete = $this->active_category->delete(); if ($delete && !is_error($delete)) { if ($this->request->getFormat() == FORMAT_HTML) { flash_success('Category :category_name has been deleted', array('category_name' => $this->active_category->getName())); $this->redirectToUrl($this->smarty->get_template_vars('categories_url')); } else { $this->serveData($this->active_category, 'category'); } // if } else { if ($this->request->getFormat() == FORMAT_HTML) { flash_error('Failed to delete :category_name', array('category_name' => $this->active_category->getName())); $this->redirectToUrl($this->smarty->get_template_vars('categories_url')); } else { $this->serveData($delete); } // if } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
/** * 删除 */ public function actionDelete($id) { $id = (int) $id; $Category = new Category(); $Category->delete(array('cid' => $id)); WaveCommon::exportResult(true, '成功!'); }
public function testDelete() { $category = Category::getNewInstance(Category::getRootNode()); $category->save(); $field = SpecField::getNewInstance($category, SpecField::DATATYPE_TEXT, SpecField::TYPE_TEXT_SIMPLE); $field->handle->set('randomhandle'); $field->save(); $this->request->set('id', $field->getID()); $response = $this->controller->delete(); $this->assertIsA($response, 'JSONResponse'); $value = $response->getValue(); $this->assertEqual($value['status'], 'success'); // already deleted $response = $this->controller->delete(); $value = $response->getValue(); $this->assertEqual($value['status'], 'failure'); }
function admin_delete($id = null) { if (!$id) { $this->Session->setFlash('Invalid category id'); $this->redirect(array('action' => 'admin_index', 'admin' => true)); } elseif ($this->Category->delete($id)) { $this->Session->setFlash('Product was deleted successfully!'); $this->redirect(array('action' => 'admin_index', 'admin' => true)); } }
function delete($id) { if ($id) { $category = new Category($id); $module = $category->module; $category->delete(); set_notify('success', lang('delete_data_complete')); } redirect('galleries/admin/categories'); }
function delete($id) { if ($id) { $category = new Category($id); foreach ($category->gallery as $item) { $item->delete(); } $category->delete(); set_notify('success', lang('delete_data_complete')); } redirect('galleries/admin/categories'); }
function init() { $obj = new Category(); $func = array_shift($this->param); $id = array_shift($this->param); if ($func != '') { $_SERVER['REQUEST_METHOD'] = 'POST'; switch ($func) { case 'add': $data['parent_id'] = $id; $data['name'] = $_POST['name']; $data['active'] = true; try { $obj->add($data); } catch (Exception $e) { } header('Location: /admin_categories'); exit; break; case 'save': $data['name'] = $_POST['name']; try { $obj->update($id, $data); } catch (Exception $e) { } header('Location: /admin_categories'); exit; break; case 'delete': try { $obj->delete($id); } catch (Exception $e) { } header('Location: /admin_categories'); exit; break; case 'activate': try { $obj->invert($id); } catch (Exception $e) { } header('Location: /admin_categories'); exit; break; } } }
function doDelete($id) { $this->respondTo('html', function () use($id) { $response = $this->getResponse(); $flash = $this->getSession()->getFlashBag(); try { Category::delete($id); $response->redirect('App\\Admin\\Controllers\\CategoryController', 'index'); } catch (ResourceNotFoundException $e) { $flash->add('errors', "Cannot find Category #{$id}"); $response->redirect('App\\Admin\\Controllers\\CategoryController', 'index'); } catch (\Exception $e) { $flash->add('errors', 'Cannot delete Category #' . $id . ' (' . $e->getMessage() . ')'); $response->redirect('App\\Admin\\Controllers\\CategoryController', 'index'); } }); }
public function delete() { $Category = new Category($this->db, $this->plural_resorce); if (isset($_REQUEST['category_id'])) { $user_id = $_SESSION['id']; $category_id = $_REQUEST['category_id']; // カテゴリーを検査する(本当にユーザー自身のカテゴリかどうか) $sql = $Category->check($category_id); $record = mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); $table = mysqli_fetch_assoc($record); // 本当にユーザー自身のカテゴリだったら if ($table['user_id'] == $user_id) { // カテゴリーの削除 $sql = $Category->delete($category_id); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); // 削除したカテゴリーが設定されていたToDoのカテゴリ情報をクリア $sql = $Category->clear($category_id); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); } } header('Location: ../task/index'); exit; }
/** * Handles loading, saving and deleting categories in a workflow context * * @since 1.0 * @return void **/ function workflow () { global $Ecart; $db =& DB::get(); $defaults = array( 'page' => false, 'deleting' => false, 'delete' => false, 'id' => false, 'save' => false, 'duplicate' => false, 'next' => false ); $args = array_merge($defaults,$_REQUEST); extract($args,EXTR_SKIP); if (!defined('WP_ADMIN') || !isset($page) || $page != $this->Admin->pagename('categories')) return false; $adminurl = admin_url('admin.php'); if ($page == $this->Admin->pagename('categories') && !empty($deleting) && !empty($delete) && is_array($delete)) { foreach($delete as $deletion) { $Category = new Category($deletion); if (empty($Category->id)) continue; $db->query("UPDATE $Category->_table SET parent=0 WHERE parent=$Category->id"); $Category->delete(); } $redirect = (add_query_arg(array_merge($_GET,array('delete'=>null,'deleting'=>null)),$adminurl)); ecart_redirect($redirect); } if ($id && $id != "new") $Ecart->Category = new Category($id); else $Ecart->Category = new Category(); if ($save) { $this->save($Ecart->Category); $this->Notice = '<strong>'.stripslashes($Ecart->Category->name).'</strong> '.__('has been saved.','Ecart'); if ($next) { if ($next != "new") $Ecart->Category = new Category($next); else $Ecart->Category = new Category(); } else { if (empty($id)) $id = $Ecart->Category->id; $Ecart->Category = new Category($id); } } }
public function process() { // check if session is active $session = new Session($this->sessionId); if ($session->sessionId > 0) { // update session $session->update(); // process restricted functions switch ($this->f) { case 'checkLogin': return Login::checkLogin($session->sessionId); case 'getSession': return $session; case 'getWarehouse': if (isset($this->data->update)) { $warehouse = new Warehouse($session->warehouseId, $this->data->update); } else { $warehouse = new Warehouse($session->warehouseId); } $warehouse->dMail = $warehouse->getMail(); $warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled(); $warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled(); return $warehouse; case 'editWarehouse': if (!$session->restricted) { $data = $this->data; $warehouse = new Warehouse($session->warehouseId); // update warehouse data if (isset($data->name)) { $warehouse->name = $data->name; } if (isset($data->description)) { $warehouse->description = $data->description; } if (isset($data->country)) { $warehouse->country = $data->country; } if (isset($data->city)) { $warehouse->city = $data->city; } if (isset($data->password)) { $warehouse->setPassword($data->password); } if (isset($data->passwordRestricted)) { $warehouse->setPasswordRestricted($data->passwordRestricted); } if (isset($data->mail)) { $warehouse->setMail($data->mail); } if (isset($data->disableLocationLess)) { $warehouse->setDisableLocationLess($data->disableLocationLess); } if (isset($data->disablePaletteLess)) { $warehouse->setDisablePaletteLess($data->disablePaletteLess); } // update database entry return $warehouse->edit(); } break; case 'deleteWarehouse': if (!$session->restricted) { $warehouse = new Warehouse($session->warehouseId); if ($warehouse->id > 0 && $warehouse->delete()) { return $session->destroy(); } } break; case 'addCategory': if (!$session->restricted && isset($this->data->name)) { $category = new Category(null, $session->warehouseId); $category->name = $this->data->name; if (isset($this->data->parent)) { $category->parent = $this->data->parent; } if ($category->edit()) { return $category->id; } } break; case 'getCategory': if (isset($this->data->id) && isset($this->data->update)) { return new Category($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Category($this->data->id, $session->warehouseId); } break; case 'deleteCategory': if (!$session->restricted && isset($this->data->id)) { $category = new Category($this->data->id, $session->warehouseId); return $category->delete(); } break; case 'editCategory': if (isset($this->data->id)) { $data = $this->data; $category = new Category($this->data->id, $session->warehouseId); if (!$session->restricted) { if (isset($data->name)) { $category->name = $data->name; } if (isset($data->parent)) { $category->parent = $data->parent; } if (isset($data->male)) { $category->male = $data->male; } if (isset($data->female)) { $category->female = $data->female; } if (isset($data->children)) { $category->children = $data->children; } if (isset($data->baby)) { $category->baby = $data->baby; } if (isset($data->summer)) { $category->summer = $data->summer; } if (isset($data->winter)) { $category->winter = $data->winter; } } if (isset($data->demand)) { $category->demand = $data->demand; } if (isset($data->weight)) { $category->weight = $data->weight; } return $category->edit(); } break; case 'getCategories': if (isset($this->data->parent)) { return Category::getCategories($session->warehouseId, $this->data->parent); } else { return Category::getCategories($session->warehouseId); } case 'addLocation': if (!$session->restricted && isset($this->data->name)) { $location = new Location(null, $session->warehouseId); $location->name = $this->data->name; if ($location->edit()) { return $location->id; } return true; } break; case 'getLocation': if (isset($this->data->id) && isset($this->data->update)) { return new Location($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Location($this->data->id, $session->warehouseId); } break; case 'deleteLocation': if (!$session->restricted && isset($this->data->id)) { $location = new Location($this->data->id, $session->warehouseId); return $location->delete(); } break; case 'editLocation': if (!$session->restricted && isset($this->data->id) && isset($this->data->name)) { $location = new Location($this->data->id, $session->warehouseId); $location->name = $this->data->name; return $location->edit(); } break; case 'getLocations': return Location::getLocations($session->warehouseId); case 'addPalette': $palette = new Palette(null, $session->warehouseId); if (isset($this->data->locationId)) { $palette->locationId = $this->data->locationId; } if ($palette->edit()) { return $palette->id; } break; case 'getPalette': if (isset($this->data->id) && isset($this->data->update)) { return new Palette($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Palette($this->data->id, $session->warehouseId); } break; case 'deletePalette': if (isset($this->data->id)) { $palette = new Palette($this->data->id, $session->warehouseId); return $palette->delete(); } break; case 'editPalette': if (isset($this->data->id)) { $palette = new Palette($this->data->id, $session->warehouseId); if (isset($this->data->locationId)) { $palette->locationId = $this->data->locationId; } return $palette->edit(); } break; case 'getPalettes': return Palette::getPalettes($session->warehouseId); case 'getCarton': if (isset($this->data->id) && isset($this->data->update)) { return new Carton($this->data->id, $session->warehouseId, null, null, $this->data->update); } elseif (isset($this->data->id)) { return new Carton($this->data->id, $session->warehouseId); } break; case 'addCarton': $locationId = null; $paletteId = null; if (isset($this->data->location)) { $locationId = $this->data->location; } if (isset($this->data->palette)) { $paletteId = $this->data->palette; } $carton = new Carton(null, $session->warehouseId, $locationId, $paletteId); return $carton->id; case 'deleteCarton': if (isset($this->data->id)) { $carton = new Carton($this->data->id, $session->warehouseId); return $carton->delete(); } break; case 'editCarton': if (isset($this->data->id)) { $carton = new Carton($this->data->id, $session->warehouseId); if (isset($this->data->location)) { $carton->locationId = $this->data->location; } else { $carton->locationId = null; } if (isset($this->data->palette)) { $carton->paletteId = $this->data->palette; } else { $carton->paletteId = null; } return $carton->edit(); } break; case 'addArticle': if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) { return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0); } break; case 'getStock': return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false); case 'getBarcodeUri': if (isset($this->data->text)) { // create barcode object $bc = new Barcode39($this->data->text); if (isset($this->data->textSize)) { $bc->barcode_text_size = $this->data->textSize; } if (isset($this->data->barThin)) { $bc->barcode_bar_thin = $this->data->barThin; } if (isset($this->data->barThick)) { $bc->barcode_bar_thick = $this->data->barThick; } // generate barcode image $img = "barcode_" . mt_rand(0, 100) . ".png"; $bc->draw($img); // get data uri $uri = Barcode39::getDataURI($img); unlink($img); return $uri; } break; } } else { // process unrestricted function switch ($this->f) { case 'getActiveSessions': return Session::getActiveSessionsNumber(); case 'getWarehouses': return Warehouse::getWarehouses(); case 'addWarehouse': $data = $this->data; if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) { $warehouse = new Warehouse(); Log::debug('new warehouse' . $warehouse->id); $warehouse->name = $data->name; $warehouse->description = $data->description; $warehouse->country = $data->country; $warehouse->city = $data->city; $warehouse->setPassword($data->password); $warehouse->setMail($data->mail); return $warehouse->edit(); } break; case 'getCountries': return getCountries(); break; case 'getCountryCode': $data = $this->data; if (isset($data->name)) { return getCountryCode(null, $data->name); } return false; } } return false; }
public function uninstall() { foreach ($this->available_languages as $iso => $lang) { Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'CERTIFICATE_' . strtoupper($iso)); } $category = new Category((int) TSBuyerProtection::$CAT_ID); $category->delete(); Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'CAT_ID'); Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'SHOPSW'); Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'ET_CID'); Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'ET_LID'); Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'ENV_API'); Configuration::deleteByName(TSBuyerProtection::PREFIX_TABLE . 'SECURE_KEY'); return true; }
$data['status'] = 'OK'; $data['data'] = _('Category added successfully'); } } else { $data['data'] = _('Error! This category already exists'); } } else { $data['data'] = ossim_get_error_clean(); } } elseif ($action == 'delete_category') { $cat_id = GET('cat_id'); ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category')); $data['status'] = 'error'; $data['data'] = _('Error! Category not deleted'); if (!ossim_error()) { if (Category::delete($conn, $cat_id)) { $data['status'] = 'OK'; $data['data'] = _('Category deleted successfully'); } } else { $data['data'] = ossim_get_error_clean(); } } elseif ($action == 'delete_subcategory') { $subcat_id = GET('subcat_id'); $cat_id = GET('cat_id'); ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category')); ossim_valid($subcat_id, OSS_DIGIT, 'illegal:' . _('Subcategory')); $data['status'] = 'error'; $data['data'] = _('Error! Subcategory not deleted'); if (!ossim_error()) { if (Subcategory::delete($conn, $cat_id, $subcat_id)) {
} foreach ($languages as $lid => $l) { $name = tep_db_prepare_input($_POST['categories_name'][$lid]); $seo_text = tep_db_input($_POST['seo_text'][$lid]); $cat->updateDetailLanguage($lid, $name, $seo_text); } if ($cat_id_new) { $hm = $hidemenuscript == '' ? '' : '&hidemenu=true'; header('Location: ?open=setting-category&id=' . $cat->id . $hm); exit; } } elseif ($_POST['me_action'] == 'DELETECATEGORY') { $cid = tep_db_prepare_input($_POST['categories_id']); $cat = new Category($cid); $ctid = $cat->getCategoryTop()->id; $cat->delete(); $messagebox->add('A Category has been succesfully deleted,' . ' please refresh the list to see the update', 'green'); $_GET['id'] = 'new'; $_GET['ctid'] = $ctid; } } //START TEMPLATE $cat_id = tep_db_prepare_input($_GET['id']); if ($cat_id == 'new') { $cat_id = '0'; $cat = null; $parent_name = ''; $cat_prefix = ''; $ctid = tep_db_prepare_input($_GET['ctid']); $ct = new CategoryTop($ctid); $mod_title = 'Create New Category - ' . $ct->name;
/** * Delete several categories from database * * return boolean Deletion result */ public function deleteSelection($categories) { $return = 1; foreach ($categories as $id_category) { $category = new Category((int) $id_category); $return &= $category->delete(); } return $return; }
function testDelete() { $name = "Work stuff"; $id = 1; $test_category = new Category($name, $id); $test_category->save(); $description = "File reports"; $id2 = 2; $due_date = "2000-01-01"; $test_task = new Task($description, $id2, $due_date); $test_task->save(); $test_category->addTask($test_task); $test_category->delete(); $this->assertEquals([], $test_task->getCategories()); }
function testDeleteCategoryContacts() { //arrange $name = "Business"; $id = null; $test_category = new Category($name, $id); $test_category->save(); $contact_name = "Jane Doe"; $phone_number = "555-555-5555"; $address = "5 Main Street, Anytown, Anystate 55555"; $category_id = $test_category->getId(); $test_contact = new Contact($contact_name, $phone_number, $address, $id, $category_id); $test_contact->save(); //act $test_category->delete(); //assert $this->assertEquals([], Contact::getAll()); }
public static function delete($id) { session_start(); $headers = apache_request_headers(); $token = $headers['X-Auth-Token']; if (!$headers['X-Auth-Token']) { header('Invalid CSRF Token', true, 401); return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT); } else { if ($token != $_SESSION['form_token']) { header('Invalid CSRF Token', true, 401); return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT); } else { Category::delete($id); } } }
function testDeleteCategory() { //Arrange $name = "Work Stuff"; $id = 1; $test_category = new Category($name, $id); $test_category->save(); $name2 = "Home Stuff"; $id2 = 2; $test_category2 = new Category($name2, $id2); $test_category2->save(); //Act $test_category->delete(); //Assert $this->assertEquals([$test_category2], Category::getAll()); }
private function deleteTrashCategory() { $category = Category::getCategories(false, false, false, ' AND cl.`name` = \'' . pSQL($this->trash_category_name) . '\' '); if (!empty($category)) { $obj_category = new Category(); $obj_category->id = $category[0]['id_category']; return $obj_category->delete(); } }
public function delete() { $this->output->set_content_type('application/json'); $url = $this->uri->ruri_to_assoc(3); $category_id = isset($url['category_id']) ? intval($url['category_id']) : 0; if ($category_id !== 0) { $this->_transaction_isolation(); $this->db->trans_begin(); $category = new Category(); $category->get_by_id($category_id); $category->delete(); if ($this->db->trans_status()) { $this->db->trans_commit(); $this->output->set_output(json_encode(TRUE)); } else { $this->db->trans_rollback(); $this->output->set_output(json_encode(FALSE)); } } else { $this->output->set_output(json_encode(FALSE)); } }
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"; } }
private function delCategory() { $ctg = new Category($_GET["id"]); $ctg->delete(); header("Location: home.php"); }
function testDelete() { //Arrange $name = "Work stuff"; $id = 1; $test_category = new Category($name, $id); $test_category->save(); $description = "File reports"; $id2 = 2; $completed = 0; $due_date = null; $test_task = new Task($description, $id2, $completed, $due_date); $test_task->save(); //Act $test_category->addTask($test_task); $test_category->delete(); //Assert $this->assertEquals([], $test_task->getCategories()); }
private function truncateTables($case) { switch ((int) $case) { case $this->entities[$this->l('Categories')]: $categories = Db::getInstance()->ExecuteS('SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category` WHERE id_category != 1'); foreach ($categories as $category) { $c = new Category((int) $category['id_category']); $c->delete(); } break; case $this->entities[$this->l('Products')]: $products = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product`'); foreach ($products as $product) { $p = new Product((int) $product['id_product']); $p->delete(true); } break; case $this->entities[$this->l('Customers')]: $customers = Db::getInstance()->ExecuteS('SELECT `id_customer` FROM `' . _DB_PREFIX_ . 'customer`'); foreach ($customers as $customer) { $c = new Customer((int) $customer['id_customer']); $c->delete(); } break; case $this->entities[$this->l('Addresses')]: $addresses = Db::getInstance()->ExecuteS('SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address`'); foreach ($addresses as $address) { $a = new Address((int) $address['id_address']); $a->delete(); } break; case $this->entities[$this->l('Combinations')]: $products = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product`'); foreach ($products as $product) { $p = new Product((int) $product['id_product']); $p->deleteProductAttributes(); } break; case $this->entities[$this->l('Manufacturers')]: $manufacturers = Db::getInstance()->ExecuteS('SELECT `id_manufacturer` FROM `' . _DB_PREFIX_ . 'manufacturer`'); foreach ($manufacturers as $manufacturer) { $m = new Manufacturer((int) $manufacturer['id_manufacturer']); $m->delete(); } break; case $this->entities[$this->l('Suppliers')]: $suppliers = Db::getInstance()->ExecuteS('SELECT `id_supplier` FROM `' . _DB_PREFIX_ . 'supplier`'); foreach ($suppliers as $supplier) { $m = new Supplier((int) $supplier['id_supplier']); $m->delete(); } break; } Image::clearTmpDir(); return true; }
/** * Delete several categories from database * * return boolean Deletion result */ public function deleteSelection($categories) { $return = 1; foreach ($categories as $id_category) { $category = new Category($id_category); if ($category->isRootCategoryForAShop()) { return false; } else { $return &= $category->delete(); } } return $return; }
function admin() { global $Shopp; $db =& DB::get(); if (!defined('WP_ADMIN') || !isset($_GET['page'])) { return; } $Admin = $Shopp->Flow->Admin; $adminurl = $Shopp->wpadminurl . "admin.php"; $defaults = array('page' => false, 'deleting' => false, 'delete' => false, 'id' => false, 'save' => false, 'duplicate' => false, 'next' => false); $args = array_merge($defaults, $_REQUEST); extract($args, EXTR_SKIP); if (strstr($page, $Admin->categories)) { if ($page == "shopp-categories" && !empty($deleting) && !empty($delete) && is_array($delete)) { foreach ($delete as $deletion) { $Category = new Category($deletion); $db->query("UPDATE {$Category->_table} SET parent=0 WHERE parent={$Category->id}"); $Category->delete(); } $redirect = esc_url(add_query_arg(array_merge($_GET, array('delete[]' => null, 'deleting' => null)), $adminurl)); shopp_redirect($redirect); } if ($id && $id != "new") { $Shopp->Category = new Category($id); } else { $Shopp->Category = new Category(); } if ($save) { $this->save_category($Shopp->Category); $this->Notice = '<strong>' . stripslashes($Shopp->Category->name) . '</strong> ' . __('has been saved.', 'Shopp'); if ($next) { if ($next != "new") { $Shopp->Category = new Category($next); } else { $Shopp->Category = new Category(); } } else { if (empty($id)) { $id = $Shopp->Category->id; } $Shopp->Category = new Category($id); } } } // end $Admin->categories if (strstr($page, $Admin->products)) { if ($page == "shopp-products" && !empty($deleting) && !empty($delete) && is_array($delete)) { foreach ($delete as $deletion) { $Product = new Product($deletion); $Product->delete(); } $redirect = esc_url(add_query_arg(array_merge($_GET, array('delete' => null, 'deleting' => null)), $adminurl)); shopp_redirect($redirect); exit; } if ($duplicate) { $Product = new Product(); $Product->load($duplicate); $Product->duplicate(); shopp_redirect(add_query_arg('page', $Admin->products, $adminurl)); } if ($id && $id != "new") { $Shopp->Product = new Product($id); $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags')); } else { $Shopp->Product = new Product(); $Shopp->Product->published = "on"; } if ($save) { $this->save_product($Shopp->Product); $this->Notice = '<strong>' . stripslashes($Shopp->Product->name) . '</strong> ' . __('has been saved.', 'Shopp'); if ($next) { if ($next == "new") { $Shopp->Product = new Product(); $Shopp->Product->published = "on"; } else { $Shopp->Product = new Product($next); $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags')); } } else { if (empty($id)) { $id = $Shopp->Product->id; } $Shopp->Product = new Product($id); $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags')); } } } // end $Admin->products }
function batchDelete($p, $ids) { $c = new Category($this->db_conn); $i = 0; for ($i = 0; $i < count($ids); $i++) { $c->getData($ids[$i]); $c->delete(); } $this->gotoURL("category.php?action=list"); //$this->browse($p); }
/** * @param $id * @return mixed|void */ public function delete($id) { $this->category = $this->category->find($id); $this->category->articles()->delete($id); $this->category->delete(); }