/** * @desc Elimina las categorías especificadas **/ function deleteCategos() { global $xoopsModule, $xoopsSecurity; $ids = rmc_server_var($_POST, 'ids', array()); //Verificamos si nos proporcionaron alguna categoria if (!is_array($ids) || empty($ids)) { redirectMsg('./categories.php', __('You must select at least one category to delete!', 'dtransport'), 1); } if (!$xoopsSecurity->check()) { redirectMsg('categories.php', __('Session token expired!', 'dtransport'), 1); } $errors = ''; foreach ($ids as $k) { //Verificamos si la categoría es válida if ($k <= 0) { $errors .= sprintf(__('Category ID "%s" is not valid!', 'dtransport'), $k); continue; } //verificamos si la categoría existe $cat = new DTCategory($k); if ($cat->isNew()) { $errors .= sprintf(__('Category "%s" does not exists!', 'dtransport'), $k); continue; } if (!$cat->delete()) { $errors .= sprintf(__('Category "%s" could not be deleted!', 'dtransport'), $cat->name()); } } if ($errors != '') { redirectMsg('categories.php', __('There was errors trying to delete categories', 'dtransport') . '<br />' . $errors, 1); die; } else { redirectMsg('categories.php', __('Categories deleted successfully!', 'dtransport'), 0); die; } }