}
 }
 // custom page hook that can be controlled by third-party plugin
 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_products_search_and_edit.php']['adminProductsSearchAndEditActionProductPostProc'])) {
     $params = array();
     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_products_search_and_edit.php']['adminProductsSearchAndEditActionProductPostProc'] as $funcRef) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
     }
 }
 // custom page hook that can be controlled by third-party plugin eof
 if (count($this->post['selectedProducts'])) {
     switch ($this->post['tx_multishop_pi1']['action']) {
         case 'delete':
             foreach ($this->post['selectedProducts'] as $old_categories_id => $array) {
                 foreach ($array as $pid) {
                     mslib_befe::deleteProduct($pid, $old_categories_id);
                 }
             }
             break;
         case 'move':
             if (is_numeric($this->post['tx_multishop_pi1']['target_categories_id']) and mslib_befe::canContainProducts($this->post['tx_multishop_pi1']['target_categories_id'])) {
                 foreach ($this->post['selectedProducts'] as $old_categories_id => $array) {
                     foreach ($array as $pid) {
                         $filter = array();
                         $filter[] = 'products_id=' . $pid;
                         if (mslib_befe::ifExists('1', 'tx_multishop_products', 'imported_product', $filter)) {
                             // lock changed columns
                             mslib_befe::updateImportedProductsLockedFields($pid, 'tx_multishop_products_to_categories', array('categories_id' => $this->post['tx_multishop_pi1']['target_categories_id']));
                         }
                         mslib_befe::moveProduct($pid, $this->post['tx_multishop_pi1']['target_categories_id'], $old_categories_id);
                     }
 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);
             }
         }
     }
 }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
$content .= '<div class="main-heading"><h1>' . $this->pi_getLL('admin_delete_product') . '</h1></div>';
if (is_numeric($_REQUEST['pid'])) {
    if ($_REQUEST['confirm']) {
        mslib_befe::deleteProduct($_REQUEST['pid'], $_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_cms', 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_products_description where products_id='" . $_REQUEST['pid'] . "'";
        $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
        $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
        if (is_numeric($row['products_id'])) {
            $content .= '<form class="admin_product_edit" name="admin_product_edit_' . $_REQUEST['pid'] . '" id="admin_product_edit_' . $_REQUEST['pid'] . '" method="post" action="' . mslib_fe::typolink($this->shop_pid . ',2003', 'tx_multishop_pi1[page_section]=' . $_REQUEST['action'] . '&pid=' . $_REQUEST['pid'], 1) . '">
			<input type="hidden" name="tx_multishop_pi1[referrer]" id="msAdminReferrer" value="' . $subpartArray['###VALUE_REFERRER###'] . '" >
			';
            $content .= '
                    $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);
                foreach ($array as $item) {
                    if ($item) {
                        $qry = $GLOBALS['TYPO3_DB']->sql_query($item);
                    }
                }
                $content .= '<p>' . $this->pi_getLL('admin_label_manufacturers_has_been_cleared') . '</p>';
                break;
             $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':
     // restore database
     if ($this->post['action'] == 'restore' and is_numeric($this->post['page_uid']) and ($_FILES['restore_file']['tmp_name'] or $this->post['custom_file'])) {
         // unzip first
         if (!$_FILES['restore_file']['error'] or $this->post['custom_file']) {