public function __construct() { global $osC_Language, $osC_MessageStack; parent::__construct(); $this->_page_contents = 'delete.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { if (osC_Products_Admin::delete($_GET[$this->_module])) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'])); } }
public function __construct() { global $osC_Language, $osC_MessageStack; parent::__construct(); if (isset($_POST['batch']) && is_array($_POST['batch']) && !empty($_POST['batch'])) { $this->_page_contents = 'batch_delete.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { $error = false; foreach ($_POST['batch'] as $id) { if (!osC_Products_Admin::delete($id)) { $error = true; break; } } if ($error === false) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'])); } } }
function deleteProduct() { global $toC_Json, $osC_Language, $osC_Image; $osC_Image = new osC_Image_Admin(); if (osC_Products_Admin::delete($_REQUEST['products_id'])) { $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed')); } else { $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed')); } echo $toC_Json->encode($response); }
function delete($id) { global $osC_Database, $osC_CategoryTree; $error = false; if (is_numeric($id)) { $osC_CategoryTree->setBreadcrumbUsage(false); $categories = array_merge(array(array('id' => $id, 'text' => '')), $osC_CategoryTree->getTree($id)); $products = array(); $products_delete = array(); foreach ($categories as $c_entry) { $Qproducts = $osC_Database->query('select products_id from :table_products_to_categories where categories_id = :categories_id'); $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qproducts->bindInt(':categories_id', $c_entry['id']); $Qproducts->execute(); while ($Qproducts->next()) { $products[$Qproducts->valueInt('products_id')]['categories'][] = $c_entry['id']; } } foreach ($products as $key => $value) { $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id not in :categories_id'); $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qcheck->bindInt(':products_id', $key); $Qcheck->bindRaw(':categories_id', '("' . implode('", "', $value['categories']) . '")'); $Qcheck->execute(); if ($Qcheck->valueInt('total') < 1) { $products_delete[$key] = $key; } } osc_set_time_limit(0); foreach ($categories as $c_entry) { $osC_Database->startTransaction(); $Qimage = $osC_Database->query('select categories_image from :table_categories where categories_id = :categories_id'); $Qimage->bindTable(':table_categories', TABLE_CATEGORIES); $Qimage->bindInt(':categories_id', $c_entry['id']); $Qimage->execute(); $image = $Qimage->value('categories_image'); if (!empty($image)) { $Qcheck = $osC_Database->query('select count(*) as image_count from :table_categories where categories_image = :categories_image'); $Qcheck->bindTable(':table_categories', TABLE_CATEGORIES); $Qcheck->bindValue(':categories_image', $image); $Qcheck->execute(); if ($Qcheck->valueInt('image_count') == 1) { $path = realpath('../' . DIR_WS_IMAGES . 'categories') . '\\' . $image; if (file_exists($path)) { unlink($path); } } } $Qc = $osC_Database->query('delete from :table_categories where categories_id = :categories_id'); $Qc->bindTable(':table_categories', TABLE_CATEGORIES); $Qc->bindInt(':categories_id', $c_entry['id']); $Qc->setLogging($_SESSION['module'], $id); $Qc->execute(); if ($osC_Database->isError()) { $error = true; } if ($error === false) { $Qratings = $osC_Database->query('delete from :table_categories_ratings where categories_id = :categories_id'); $Qratings->bindTable(':table_categories_ratings', TABLE_CATEGORIES_RATINGS); $Qratings->bindInt(':categories_id', $id); $Qratings->setLogging($_SESSION['module'], $id); $Qratings->execute(); if ($osC_Database->isError()) { $error = true; } } if ($error === false) { $Qcd = $osC_Database->query('delete from :table_categories_description where categories_id = :categories_id'); $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcd->bindInt(':categories_id', $c_entry['id']); $Qcd->setLogging($_SESSION['module'], $id); $Qcd->execute(); if (!$osC_Database->isError()) { $Qp2c = $osC_Database->query('delete from :table_products_to_categories where categories_id = :categories_id'); $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qp2c->bindInt(':categories_id', $c_entry['id']); $Qp2c->setLogging($_SESSION['module'], $id); $Qp2c->execute(); if (!$osC_Database->isError()) { $osC_Database->commitTransaction(); osC_Cache::clear('categories'); osC_Cache::clear('category_tree'); osC_Cache::clear('also_purchased'); osC_Cache::clear('sefu-products'); osC_Cache::clear('new_products'); if (!osc_empty($Qimage->value('categories_image'))) { $Qcheck = $osC_Database->query('select count(*) as total from :table_categories where categories_image = :categories_image'); $Qcheck->bindTable(':table_categories', TABLE_CATEGORIES); $Qcheck->bindValue(':categories_image', $Qimage->value('categories_image')); $Qcheck->execute(); if ($Qcheck->numberOfRows() === 0) { if (file_exists(realpath('../' . DIR_WS_IMAGES . 'categories/' . $Qimage->value('categories_image')))) { @unlink(realpath('../' . DIR_WS_IMAGES . 'categories/' . $Qimage->value('categories_image'))); } } } } else { $osC_Database->rollbackTransaction(); } } else { $osC_Database->rollbackTransaction(); } } else { $osC_Database->rollbackTransaction(); } } foreach ($products_delete as $id) { osC_Products_Admin::delete($id); } osC_Cache::clear('categories'); osC_Cache::clear('category_tree'); osC_Cache::clear('also_purchased'); osC_Cache::clear('sefu-products'); osC_Cache::clear('new_products'); return true; } return false; }
function delete($id, $delete_image = false, $delete_products = false) { global $osC_Database; if ($delete_image === true) { $Qimage = $osC_Database->query('select manufacturers_image from :table_manufacturers where manufacturers_id = :manufacturers_id'); $Qimage->bindTable(':table_manufacturers', TABLE_MANUFACTURERS); $Qimage->bindInt(':manufacturers_id', $id); $Qimage->execute(); if ($Qimage->numberOfRows() && !osc_empty($Qimage->value('manufacturers_image'))) { if (file_exists(realpath('../' . DIR_WS_IMAGES . 'manufacturers/' . $Qimage->value('manufacturers_image')))) { @unlink(realpath('../' . DIR_WS_IMAGES . 'manufacturers/' . $Qimage->value('manufacturers_image'))); } } } $Qm = $osC_Database->query('delete from :table_manufacturers where manufacturers_id = :manufacturers_id'); $Qm->bindTable(':table_manufacturers', TABLE_MANUFACTURERS); $Qm->bindInt(':manufacturers_id', $id); $Qm->setLogging($_SESSION['module'], $id); $Qm->execute(); $Qmi = $osC_Database->query('delete from :table_manufacturers_info where manufacturers_id = :manufacturers_id'); $Qmi->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO); $Qmi->bindInt(':manufacturers_id', $id); $Qmi->setLogging($_SESSION['module'], $id); $Qmi->execute(); if ($delete_products === true) { $Qproducts = $osC_Database->query('select products_id from :table_products where manufacturers_id = :manufacturers_id'); $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindInt(':manufacturers_id', $id); $Qproducts->execute(); while ($Qproducts->next()) { osC_Products_Admin::delete($Qproducts->valueInt('products_id')); } } else { $Qupdate = $osC_Database->query('update :table_products set manufacturers_id = null where manufacturers_id = :manufacturers_id'); $Qupdate->bindTable(':table_products', TABLE_PRODUCTS); $Qupdate->bindInt(':manufacturers_id', $id); $Qupdate->setLogging($_SESSION['module'], $id); $Qupdate->execute(); } osC_Cache::clear('manufacturers'); return true; }