/** * @desc Elimina de la base de datos la información del trabajo **/ function shop_delete_products() { global $xoopsSecurity, $xoopsModule; $ids = rmc_server_var($_POST, 'ids', 0); $page = rmc_server_var($_POST, 'page', 1); $bname = rmc_server_var($_POST, 'bname', ''); $ruta = "page={$page}&bname={$bname}"; //Verificamos que nos hayan proporcionado un trabajo para eliminar if (!is_array($ids)) { redirectMsg('products.php?' . $ruta, __('You must select one product at least!', 'shop'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('products.php?' . $ruta, __('Session token expired!', 'shop'), 1); die; } $errors = ''; foreach ($ids as $k) { //Verificamos si el trabajo es válido if ($k <= 0) { $errors .= sprintf(__('Product ID "%s" is not valid!', 'shop'), $k); continue; } //Verificamos si el trabajo existe $product = new ShopProduct($k); if ($product->isNew()) { $errors .= sprintf(__('Product with ID "%s" does not exists!', 'shop'), $k); continue; } if (!$product->delete()) { $errors .= sprintf(__('Product "%s" could not be deleted!', 'shop'), $product->title()); } } if ($errors != '') { redirectMsg('products.php?' . $ruta, __('Errors ocurred while trying to delete products', 'shop') . '<br />' . $errors, 1); die; } else { redirectMsg('products.php?' . $ruta, __('Prodducts deleted successfully!', 'shop'), 0); die; } }