public function deleteCategory($categories_id) { if (!is_numeric($categories_id)) { return false; } if (is_numeric($categories_id)) { $str = $GLOBALS['TYPO3_DB']->SELECTquery('categories_id,categories_image,parent_id', 'tx_multishop_categories', "categories_id='" . $categories_id . "'", '', '', ''); $qry = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) { while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) { // remove any found products $str = $GLOBALS['TYPO3_DB']->SELECTquery('p.products_id, p2c.is_deepest, p2c.crumbar_identifier', 'tx_multishop_products p, tx_multishop_products_to_categories p2c', "p2c.categories_id='" . $categories_id . "' and p.products_id=p2c.products_id", '', '', ''); $products_query = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($products_query)) { while (($product = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($products_query)) != false) { if ($product['is_deepest'] > 0) { mslib_befe::deleteProduct($product['products_id'], $categories_id, true); if (!empty($product['crumbar_identifier'])) { //$qry = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_multishop_products_to_categories', "crumbar_identifier='" . $product['crumbar_identifier'] . "'"); } } } } // finally delete the category $filename = $row['categories_image']; $filter = array(); $filter[] = 'categories_image=\'' . addslashes($filename) . '\''; $count = mslib_befe::getCount('', 'tx_multishop_categories', '', $filter); if ($count < 2) { // Only delete the file is we have found 1 category using it mslib_befe::deleteCategoryImage($filename); } $tables = array(); $tables[] = 'tx_multishop_categories'; $tables[] = 'tx_multishop_categories_description'; //$tables[]='tx_multishop_products_to_categories'; if ($this->ms['MODULES']['ENABLE_CATEGORIES_TO_CATEGORIES']) { $tables[] = 'tx_multishop_categories_to_categories'; } foreach ($tables as $table) { if ($table == 'tx_multishop_categories_description') { $query = $GLOBALS['TYPO3_DB']->DELETEquery($table, 'categories_id=' . $categories_id); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } else { if ($table == 'tx_multishop_categories_to_categories') { $query = $GLOBALS['TYPO3_DB']->DELETEquery($table, 'categories_id=' . $categories_id . ' and page_uid=\'' . $this->shop_pid . '\''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // foreign $query = $GLOBALS['TYPO3_DB']->DELETEquery($table, 'foreign_categories_id=' . $categories_id . ' and foreign_page_uid=\'' . $this->shop_pid . '\''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } else { $query = $GLOBALS['TYPO3_DB']->DELETEquery($table, 'categories_id=' . $categories_id . ' and page_uid=\'' . $this->shop_pid . '\''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } } } // // first check if the category has subcategories to delete them as well $str = $GLOBALS['TYPO3_DB']->SELECTquery('categories_id', 'tx_multishop_categories', "parent_id = '" . $row['categories_id'] . "'", '', '', ''); $subcategories_query = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($subcategories_query)) { while (($subcategory = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subcategories_query)) != false) { mslib_befe::deleteCategory($subcategory['categories_id']); } } } } //hook to let other plugins further manipulate the create table query if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['deleteCategoryPostHook'])) { $params = array('categories_id' => $categories_id); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['deleteCategoryPostHook'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } } }
$query2 = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_orders', 'orders_id='.$row['orders_id']); $res2 = $GLOBALS['TYPO3_DB']->sql_query($query2); $query2 = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_orders_products', 'orders_id='.$row['orders_id']); $res2 = $GLOBALS['TYPO3_DB']->sql_query($query2); $query2 = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_orders_products_attributes', 'orders_id='.$row['orders_id']); $res2 = $GLOBALS['TYPO3_DB']->sql_query($query2); $query2 = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_orders_status_history', 'orders_id='.$row['orders_id']); $res2 = $GLOBALS['TYPO3_DB']->sql_query($query2); } */ $content .= '<p>' . $this->pi_getLL('admin_label_orders_has_been_cleared') . '</p>'; break; case 'categories': $query = $GLOBALS['TYPO3_DB']->sql_query("select categories_id from tx_multishop_categories where parent_id='0' and page_uid='" . $this->showCatalogFromPage . "'"); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)) != false) { mslib_befe::deleteCategory($row['categories_id']); } $content .= '<p>' . $this->pi_getLL('admin_label_categories_has_been_cleared') . '</p>'; break; case 'products': $query = $GLOBALS['TYPO3_DB']->sql_query("select products_id from tx_multishop_products where page_uid='" . $this->showCatalogFromPage . "'"); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)) != false) { mslib_befe::deleteProduct($row['products_id']); } $content .= '<p>' . $this->pi_getLL('admin_label_products_has_been_cleared') . '</p>'; break; case 'manufacturers': $string = 'TRUNCATE `tx_multishop_manufacturers`; TRUNCATE `tx_multishop_manufacturers_cms`; TRUNCATE `tx_multishop_manufacturers_info`;'; $array = explode("\n", $string);
// to find out case 'admin_categories': if ($this->ADMIN_USER) { if ($this->get['action'] == 'move_categories') { $selected_cats = count($this->post['movecats']); if ($selected_cats > 0) { if (isset($this->post['move_selected_categories'])) { $new_parent_id = $this->post['move_to_cat']; foreach ($this->post['movecats'] as $move_catid) { $sql_update = 'update tx_multishop_categories set parent_id = ' . $new_parent_id . ' where categories_id = ' . $move_catid; $GLOBALS['TYPO3_DB']->sql_query($sql_update); } } else { if (isset($this->post['delete_selected_categories'])) { foreach ($this->post['movecats'] as $move_catid) { mslib_befe::deleteCategory($move_catid); } } } } header('Location: ' . $this->FULL_HTTP_URL . mslib_fe::typolink($this->shop_pid . ',2003', 'tx_multishop_pi1[page_section]=admin_categories&cid=' . $this->get['categories_id'])); exit; } require \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'scripts/admin_pages/admin_categories.php'; } break; case 'admin_product_feeds': if ($this->ADMIN_USER) { require \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'scripts/admin_pages/admin_product_feeds.php'; } break;
<?php if (!defined('TYPO3_MODE')) { die('Access denied.'); } $content .= '<div class="main-heading"><h1>' . $this->pi_getLL('delete_category') . '</h1></div>'; if (is_numeric($_REQUEST['cid'])) { if ($_REQUEST['confirm']) { mslib_befe::deleteCategory($_REQUEST['cid']); if ($this->post['tx_multishop_pi1']['referrer']) { header("Location: " . $this->post['tx_multishop_pi1']['referrer']); exit; } else { header("Location: " . $this->FULL_HTTP_URL . mslib_fe::typolink($this->shop_pid . ',2003', 'tx_multishop_pi1[page_section]=admin_categories', 1)); exit; } } else { $subpartArray['###VALUE_REFERRER###'] = ''; if ($this->post['tx_multishop_pi1']['referrer']) { $subpartArray['###VALUE_REFERRER###'] = $this->post['tx_multishop_pi1']['referrer']; } else { $subpartArray['###VALUE_REFERRER###'] = $_SERVER['HTTP_REFERER']; } $str = "SELECT * from tx_multishop_categories_description where categories_id='" . $_REQUEST['cid'] . "'"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); if (is_numeric($row['categories_id'])) { $content .= '<form class="admin_categories_edit" name="admin_categories_edit_' . $_REQUEST['cid'] . '" id="admin_categories_edit_' . $_REQUEST['cid'] . '" method="post" action="' . mslib_fe::typolink($this->shop_pid . ',2003', 'tx_multishop_pi1[page_section]=' . $_REQUEST['action'] . '&categories_id=' . $_REQUEST['cid'], 1) . '"> <input type="hidden" name="tx_multishop_pi1[referrer]" id="msAdminReferrer" value="' . $subpartArray['###VALUE_REFERRER###'] . '" > '; $content .= '
$data['categories_id'][] = $row[0]; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('products_id', 'tx_multishop_products', 'page_uid=' . $_GET['page_uid'], ''); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) != false) { $data['products_id'][] = $row[0]; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('manufacturers_id', 'tx_multishop_manufacturers', 'page_uid=' . $_GET['page_uid'], ''); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) != false) { $data['manufacturers_id'][] = $row[0]; } $qry = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_multishop_configuration_values', 'page_uid=' . $_GET['page_uid']); $content .= '<li>Settings removed</li>'; $qry = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_multishop_specials', 'page_uid=' . $_GET['page_uid']); $content .= '<li>Specials removed</li>'; foreach ($data['categories_id'] as $id) { $tmp = mslib_befe::deleteCategory($id); } $content .= '<li>Categories removed</li>'; foreach ($data['products_id'] as $id) { $tmp = mslib_befe::deleteProduct($id); } $content .= '<li>Products removed</li>'; foreach ($data['manufacturers_id'] as $id) { $tmp = mslib_befe::deleteManufacturer($id); } $content .= '<li>Manufacturers removed</li>'; $content .= '</ul></fieldset>'; } // clears the current multishop data eof break; case 'restore':