[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Menu options: Fixed menu option deletion
"Baraka Kinywa \(@bkinywa24\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <692c3c4c4c77f_2a204a6087605b@gitlab-sidekiq-low-urgency-cpu-bound-v2-5df5c99858-zggkf.mail> |
Baraka Kinywa pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
1bae0ae7 by Espoir Baraka at 2025-11-30T14:36:39+02:00
[FIX] Menu options: Fixed menu option deletion
---
* [FIX] Menu options: Fixed menu option deletion
---
* [FIX] Menu options: Fixed menu option deletion
See merge request tikiwiki/tiki!9128
(cherry picked from commit 3630c8b3c25c77c9a10de0127d3c86e6081fa117)
See merge request tikiwiki/tiki!9153
- - - - -
2 changed files:
- src/js/jquery-tiki/tiki-admin_menu_options.js
- tiki-admin_menu_options.php
Changes:
=====================================
src/js/jquery-tiki/tiki-admin_menu_options.js
=====================================
@@ -2,9 +2,15 @@
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+//
+// This JavaScript file is a handler for tiki-admin_menu_options.php
+// It contains shared knowledge about the menu options management interface
+// and handles the client-side interactions for menu option editing and deletion.
import Sortable from "sortablejs";
+var ADMIN_MENU_OPTIONS_SCRIPT = "tiki-admin_menu_options.php";
+
$(function () {
var dirty = false,
$options = $("#options");
@@ -104,11 +110,43 @@ $(function () {
$options.on("click", ".option-remove", function () {
if (confirm(tr("Are you sure you want to remove this option?"))) {
- var tab = $(this).siblings("a.option-edit").attr("href");
- $("#deletemenu").val(tab.split("&")[3]);
- $("form").submit();
- $(this).parents("li").first().remove();
- setDirty();
+ var $li = $(this).parents("li").first();
+ var optionId = $li.data("id");
+ if (optionId) {
+ var $form = $("form");
+ var menuId = $form.find("input[name=menuId]").val();
+ var ticket = $form.find("input[name=ticket]").val();
+
+ // Submit deletion via POST
+ $.post(
+ ADMIN_MENU_OPTIONS_SCRIPT,
+ {
+ deletemenu: optionId,
+ menuId: menuId,
+ ticket: ticket,
+ },
+ function () {
+ dirty = false;
+ location.reload();
+ }
+ ).fail(function (jqXHR, textStatus, errorThrown) {
+ var errorMessage = tr("An error occurred while deleting the menu option.");
+ if (textStatus) {
+ errorMessage += " " + tr("Status:") + " " + textStatus;
+ }
+ if (errorThrown) {
+ errorMessage += " (" + errorThrown + ")";
+ }
+ if (jqXHR && jqXHR.status) {
+ errorMessage += " [" + jqXHR.status;
+ if (jqXHR.statusText) {
+ errorMessage += " " + jqXHR.statusText;
+ }
+ errorMessage += "]";
+ }
+ feedback(errorMessage, "error");
+ });
+ }
}
return false;
});
=====================================
tiki-admin_menu_options.php
=====================================
@@ -30,10 +30,15 @@ $auto_query_args = [
'preview_bootstrap',
];
-if (! empty($_REQUEST["deletemenu"])) {
- $content = $_REQUEST["deletemenu"];
- $content = explode("=", $content)[1];
- $menulib->remove_menu_option($content);
+if (! empty($_REQUEST["deletemenu"]) && $access->checkCsrf()) {
+ $optionId = (int) $_REQUEST["deletemenu"];
+ if ($optionId > 0) {
+ // Verify the option exists and belongs to the current menu
+ $option = $menulib->get_menu_option($optionId);
+ if ($option && $option['menuId'] == $_REQUEST["menuId"]) {
+ $menulib->remove_menu_option($optionId);
+ }
+ }
}
$smarty->assign('menuId', $_REQUEST["menuId"]);
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/1bae0ae708dc6562b94ee4b359e31e07468d222a
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/1bae0ae708dc6562b94ee4b359e31e07468d222a
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs