public function delete() { if (!$this->user->canModify('common/resource_library')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true)); } //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $rm = new AResourceManager(); $resource_id = (int) $this->request->get['resource_id']; if (has_value($this->request->get['object_name']) && has_value($this->request->get['object_id'])) { $rm->unmapResource($this->request->get['object_name'], $this->request->get['object_id'], $resource_id); } $result = $rm->deleteResource($resource_id); if (!$result) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $this->language->get('text_cant_delete'))); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($result)); }
/** * @param int $product_id * @return bool */ public function deleteProduct($product_id) { if (!(int) $product_id) { return false; } $rm = new AResourceManager(); $this->db->query("DELETE FROM " . $this->db->table("products") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("product_descriptions") . " WHERE product_id = '" . (int) $product_id . "'"); $resources = $rm->getResourcesList(array('object_name' => 'products', 'object_id' => (int) $product_id)); foreach ($resources as $r) { $rm->unmapResource('products', $product_id, $r['resource_id']); //if resource become orphan - delete it if (!$rm->isMapped($r['resource_id'])) { $rm->deleteResource($r['resource_id']); } } //delete product's downloads $this->load->model('catalog/download'); $downloads = $this->model_catalog_download->getProductDownloadsDetails($product_id, array('subsql_filter' => 'AND d.shared<>1')); foreach ($downloads as $d) { $this->model_catalog_download->deleteDownload($d['download_id']); } $this->db->query("DELETE FROM " . $this->db->table("product_options") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("product_option_descriptions") . " WHERE product_id = '" . (int) $product_id . "'"); $sql = "SELECT product_option_value_id FROM " . $this->db->table("product_option_values") . " WHERE product_id = '" . (int) $product_id . "'"; $result = $this->db->query($sql); foreach ($result->rows as $row) { $pd_opt_val_id = $row['product_option_value_id']; $resources = $rm->getResourcesList(array('object_name' => 'product_option_value', 'object_id' => (int) $pd_opt_val_id)); foreach ($resources as $r) { $rm->unmapResource('product_option_value', $pd_opt_val_id, $r['resource_id']); } } $this->db->query("DELETE FROM " . $this->db->table("product_option_values") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("product_option_value_descriptions") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("product_discounts") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("products_related") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("products_to_downloads") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("products_to_categories") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("reviews") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("products_to_stores") . " WHERE product_id = '" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("url_aliases") . " WHERE query = 'product_id=" . (int) $product_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("product_tags") . " WHERE product_id='" . (int) $product_id . "'"); $lm = new ALayoutManager(); $lm->deletePageLayout('pages/product/product', 'product_id', (int) $product_id); $this->cache->remove('product'); return true; }
/** * @param int $download_id * @return null */ public function deleteDownload($download_id) { $download_id = (int) $download_id; if (!$download_id) { return null; } $download = $this->getDownload($download_id); if (!$download) { return null; } $rm = new AResourceManager(); $rm->setType('download'); $path = ltrim($download['filename'], 'download/'); $rl_id = $rm->getIdFromHexPath($path); if ($rl_id && !$rm->isMapped($rl_id)) { $rm->deleteResource($rl_id); } $this->db->query("DELETE FROM " . $this->db->table("downloads") . " WHERE download_id = '" . (int) $download_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("download_descriptions") . " WHERE download_id = '" . (int) $download_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("download_attribute_values") . " WHERE download_id = '" . (int) $download_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("products_to_downloads") . " WHERE download_id = '" . (int) $download_id . "'"); }
<?php if (!defined('DIR_CORE')) { header('Location: static_pages/'); } $rm = new AResourceManager(); $rm->setType('image'); $resources = $rm->getResources('extensions', 'default_pp_standart'); //echo_array($resources);exit; if (is_array($resources)) { foreach ($resources as $resource) { $rm->deleteResource($resource['resource_id']); } }
/** * @param int $manufacturer_id */ public function deleteManufacturer($manufacturer_id) { $this->db->query("DELETE FROM " . $this->db->table("manufacturers") . " WHERE manufacturer_id = '" . (int) $manufacturer_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("manufacturers_to_stores") . " WHERE manufacturer_id = '" . (int) $manufacturer_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("url_aliases") . " WHERE query = 'manufacturer_id=" . (int) $manufacturer_id . "'"); $lm = new ALayoutManager(); $lm->deletePageLayout('pages/product/manufacturer', 'manufacturer_id', (int) $manufacturer_id); //delete resources $rm = new AResourceManager(); $resources = $rm->getResourcesList(array('object_name' => 'manufacturers', 'object_id' => (int) $manufacturer_id)); foreach ($resources as $r) { $rm->unmapResource('manufacturers', $manufacturer_id, $r['resource_id']); //if resource became orphan - delete it if (!$rm->isMapped($r['resource_id'])) { $rm->deleteResource($r['resource_id']); } } $this->cache->remove('manufacturer'); }
/** * @param int $category_id */ public function deleteCategory($category_id) { $this->db->query("DELETE FROM " . $this->db->table("categories") . " WHERE category_id = '" . (int) $category_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("category_descriptions") . " WHERE category_id = '" . (int) $category_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("categories_to_stores") . " WHERE category_id = '" . (int) $category_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("url_aliases") . " WHERE query = 'category_id=" . (int) $category_id . "'"); $this->db->query("DELETE FROM " . $this->db->table("products_to_categories") . " WHERE category_id = '" . (int) $category_id . "'"); //delete resources $rm = new AResourceManager(); $resources = $rm->getResourcesList(array('object_name' => 'categories', 'object_id' => (int) $category_id)); foreach ($resources as $r) { $rm->unmapResource('products', $category_id, $r['resource_id']); //if resource became orphan - delete it if (!$rm->isMapped($r['resource_id'])) { $rm->deleteResource($r['resource_id']); } } //remove layout $lm = new ALayoutManager(); $lm->deletePageLayout('pages/product/category', 'path', $category_id); //delete children categories $query = $this->db->query("SELECT category_id\n\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("categories") . "\n\t\t\t\t\t\t\t\t\tWHERE parent_id = '" . (int) $category_id . "'"); foreach ($query->rows as $result) { $this->deleteCategory($result['category_id']); } $this->cache->remove('category'); }
public function delete() { if (!$this->user->canModify('common/resource_library')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true)); } $rm = new AResourceManager(); if (!empty($this->request->get['resource_id'])) { $this->request->post['resources'] = array($this->request->get['resource_id']); } foreach ($this->request->post['resources'] as $resource_id) { $rm->deleteResource($resource_id); } $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(true)); }