From dcee0c20a979d4093d4895dfaf827d85eb9951b9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 16 Jan 2026 16:16:46 +0100 Subject: [PATCH] Bug 41653: Move addPrefs and addPermissions under the Koha namespace --- .../tables/items/catalogue_detail.inc | 46 +++++++-------- .../prog/en/modules/acqui/invoice.tt | 4 +- .../prog/en/modules/acqui/orderreceive.tt | 18 +++--- .../prog/en/modules/acqui/parcel.tt | 6 +- .../prog/en/modules/bookings/list.tt | 6 +- .../prog/en/modules/catalogue/detail.tt | 12 ++-- .../prog/en/modules/catalogue/itemsearch.tt | 8 +-- .../prog/en/modules/circ/returns.tt | 4 +- .../prog/en/modules/ill/ill-requests.tt | 4 +- .../prog/en/modules/members/boraccount.tt | 4 +- .../prog/en/modules/members/pay.tt | 4 +- .../modules/patron_lists/patron-lists-tab.tt | 4 +- .../prog/en/modules/patroncards/edit-batch.tt | 10 ++-- .../intranet-tmpl/prog/en/modules/pos/pay.tt | 4 +- .../prog/en/modules/reserve/request.tt | 6 +- .../prog/en/modules/suggestion/suggestion.tt | 8 +-- .../en/modules/tools/manage-marc-import.tt | 2 +- .../prog/en/modules/tools/modborrowers.tt | 6 +- .../prog/en/modules/tools/upload.tt | 4 +- .../prog/en/modules/virtualshelves/shelves.tt | 6 +- koha-tmpl/intranet-tmpl/prog/js/stores.js | 12 ++-- .../bootstrap/en/modules/opac-detail.tt | 56 +++++++++---------- .../bootstrap/en/modules/opac-messaging.tt | 4 +- .../en/modules/opac-readingrecord.tt | 4 +- .../bootstrap/en/modules/opac-user.tt | 10 ++-- .../bootstrap/en/modules/sco/sco-main.tt | 6 +- koha-tmpl/opac-tmpl/bootstrap/js/stores.js | 12 ++-- 27 files changed, 133 insertions(+), 137 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 375ef0f37f1..38082c4713f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -132,7 +132,7 @@ const analyze = [% analyze ? 1 : 0 | html %]; const hidden_count = [% hidden_count ? 1 : 0 | html %]; const bundlesEnabled = [% bundlesEnabled ? 1 : 0 | html %]; - addPrefs({ + Koha.addPrefs({ LocalCoverImages: [% Koha.Preference('LocalCoverImages') ? 1 : 0 | html %], OPACLocalCoverImages: [% Koha.Preference('OPACLocalCoverImages') ? 1 : 0 | html %], EnableItemGroups: [% Koha.Preference('EnableItemGroups') ? 1 : 0 | html %], @@ -148,7 +148,7 @@ canreservefromotherbranches: [% Koha.Preference('canreservefromotherbranches') ? 1 : 0 | html %], SpineLabelShowPrintOnBibDetails: [% Koha.Preference('SpineLabelShowPrintOnBibDetails') ? 1 : 0 | html %], }); - addPermissions({ + Koha.addPermissions({ CAN_user_editcatalogue_edit_items: [% CAN_user_editcatalogue_edit_items ? 1 : 0 | html %], }); const logged_in_branchcode = '[% Branches.GetLoggedInBranchcode() | html %]'; @@ -306,27 +306,27 @@ // Do we need separate/new endpoints or do we hack the somewhere client-side? let item_table_url = `/api/v1/biblios/${biblionumber}/items?`; let embed = ["+strings,_status,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"]; - if (prefs.LocalCoverImages) { + if (Koha.prefs.LocalCoverImages) { embed.push("cover_image_ids"); } - if (prefs.EnableItemGroups) { + if (Koha.prefs.EnableItemGroups) { embed.push("item_group_item.item_group.description"); } if (is_serial) { embed.push("serial_item.serial"); } - if (prefs.UseRecalls) { + if (Koha.prefs.UseRecalls) { embed.push("recall", "recall+strings", "recall.patron"); } embed.push("in_bundle", "bundle_host", "bundle_host.biblio", "bundle_items_lost+count", "bundle_items_not_lost+count"); - if (prefs.UseCourseReserves) { + if (Koha.prefs.UseCourseReserves) { embed.push("course_item.course_reserves.course"); } - if (prefs.ClaimReturnedLostValue) { + if (Koha.prefs.ClaimReturnedLostValue) { embed.push("return_claims"); } - if (prefs.EasyAnalyticalRecords) { + if (Koha.prefs.EasyAnalyticalRecords) { // For host records embed.push("biblio.title"); } @@ -350,8 +350,8 @@ user_colvis[tab_id] = user_colvis_bak; } let default_filters = {}; - if (prefs.SeparateHoldings) { - let branch = prefs.SeparateHoldingsBranch == "homebranch" ? "me.home_library_id" : "me.holding_library_id"; + if (Koha.prefs.SeparateHoldings) { + let branch = Koha.prefs.SeparateHoldingsBranch == "homebranch" ? "me.home_library_id" : "me.holding_library_id"; if (tab_id == "holdings") { default_filters[branch] = logged_in_branchcode; } else { @@ -387,7 +387,7 @@ } }, }, - ...(prefs.LocalCoverImages + ...(Koha.prefs.LocalCoverImages ? [ { data: "", @@ -419,7 +419,7 @@ }, ] : []), - ...(prefs.item_level_itypes + ...(Koha.prefs.item_level_itypes ? [ { data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype @@ -431,7 +431,7 @@ render: function (data, type, row, meta) { let node = ""; let item_type_description = row._strings.item_type_id ? row._strings.item_type_id.str : row.item_type_id; - if (prefs.noItemTypeImages) { + if (Koha.prefs.noItemTypeImages) { let image_location = item_type_image_locations[row.item_type_id]; node += image_location ? ' '.format(escape_str(image_location), escape_str(item_type_description), escape_str(item_type_description)) : ""; } @@ -493,7 +493,7 @@ return escape_str(row._strings.collection_code ? row._strings.collection_code.str : row.collection_code); }, }, - ...(prefs.EnableItemGroups + ...(Koha.prefs.EnableItemGroups ? [ { data: "item_group_item.item_group.description", @@ -539,7 +539,7 @@ } else if (serial && serial.serialseq) { nodes += '%s'.format(escape_str(serial.serialseq)); } - if (prefs.DisplayPublishedDate) { + if (Koha.prefs.DisplayPublishedDate) { if (serial && serial.publisheddate) { nodes += ' (%s)'.format($date(serial.publisheddate)); } @@ -619,7 +619,7 @@ } else { nodes += '%s'.format(_("Waiting at %s since %s.".format(row.first_hold._strings.pickup_library_id.str, $date(row.first_hold.waiting_date)))); } - if (prefs.canreservefromotherbranches) { + if (Koha.prefs.canreservefromotherbranches) { if (row.first_hold.waiting_date || row.first_hold.priority == 1) { // Hacky for patron_to_html in case we simply want to display the patron's library name row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) }; @@ -633,7 +633,7 @@ } } - if (prefs.UseRecalls) { + if (Koha.prefs.UseRecalls) { if (row.recall && row.item_id === row.recall.item_id) { if (row.recall.waiting_date) { nodes += '%s'.format( @@ -806,7 +806,7 @@ return escape_str(row.internal_notes); }, }, - ...(prefs.EasyAnalyticalRecords + ...(Koha.prefs.EasyAnalyticalRecords ? [ { data: "biblio.title", @@ -840,7 +840,7 @@ }, ] : []), - ...(prefs.UseCourseReserves + ...(Koha.prefs.UseCourseReserves ? [ { data: "course_item.course_reserves.course.course_name", @@ -868,7 +868,7 @@ }, ] : []), - ...(prefs.SpineLabelShowPrintOnBibDetails + ...(Koha.prefs.SpineLabelShowPrintOnBibDetails ? [ { data: "", @@ -880,13 +880,13 @@ }, ] : []), - ...(permissions.CAN_user_editcatalogue_edit_items + ...(Koha.permissions.CAN_user_editcatalogue_edit_items ? [ { data: function (row, type, val, meta) { let nodes = ""; if (can_edit_items_from.includes(row.home_library_id) || !can_edit_items_from.length) { - if (prefs.LocalCoverImages || prefs.OPACLocalCoverImages) { + if (Koha.prefs.LocalCoverImages || prefs.OPACLocalCoverImages) { nodes += '
'; nodes += ' %s'.format( @@ -963,7 +963,7 @@ container.find(".bottom.pager").remove(); } - if (prefs.SpineLabelShowPrintOnBibDetails) { + if (Koha.prefs.SpineLabelShowPrintOnBibDetails) { $(".print-label").on("click", function (e) { e.preventDefault(); link = $(this).attr("href"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index ae09cbc0a6f..ab85377de7f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -577,7 +577,7 @@ [% INCLUDE 'datatables.inc' %] [% Asset.js("js/modals/edifact-modal.js") | $raw %] @@ -726,7 +726,7 @@ params["quantity"] = row.quantity; params["quantityrec"] = row.quantity_received; params["origquantityrec"] = origrec; - var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; + var effective_create_items = row.basket.create_items || Koha.prefs.AcqCreateItem; params["tax_rate"] = effective_create_items == "receiving" ? row.tax_rate_on_receiving : row.tax_rate_on_ordering; params["replacementprice"] = row.replacement_price; params["unitprice"] = invoiceincgst == "1" ? row.unit_price_tax_included || row.ecost_tax_included : row.unit_price_tax_excluded || row.ecost_tax_excluded; @@ -924,7 +924,7 @@ if (val === null) $(this).val($("option:first-child", this).attr("value")); val = $(this).val(); var row = $("#order_edit").data("row"); - var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; + var effective_create_items = row.basket.create_items || Koha.prefs.AcqCreateItem; if (effective_create_items == "receiving") { row.tax_rate_on_receiving = val; } else { @@ -1051,7 +1051,7 @@ orderable: false, data: function (row, type, val, meta) { if (row.invoice) { - if (permissions.CAN_user_acquisition) { + if (Koha.permissions.CAN_user_acquisition) { return '' + row.invoice.invoice_number + ""; } return row.invoice.invoice_number; @@ -1123,7 +1123,7 @@ var set_editor = function () { var modal = $("#order_edit"); var row = modal.data("row"); - var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; + var effective_create_items = row.basket.create_items || Koha.prefs.AcqCreateItem; var origrec = $("#order_edit").data("origrec") || {}; if (!origrec.hasOwnProperty(row.order_id)) { origrec[row.order_id] = row.quantity_received; @@ -1262,7 +1262,7 @@ $("#acq-create-ordering").hide(); if (row.items && row.items.length) { row.items.forEach(function (item, index) { - cloneItemBlock(index, prefs.UniqueItemFields, function (block_id) { + cloneItemBlock(index, Koha.prefs.UniqueItemFields, function (block_id) { var block = $("#" + block_id).hide(); Object.keys(item).forEach(function (key) { block @@ -1271,14 +1271,14 @@ .find("*[name=field_value]") .val(item[key].field_value); }); - addItemInList(block_id, prefs.UniqueItemFields); + addItemInList(block_id, Koha.prefs.UniqueItemFields); block.find("input[name='buttonPlus']").val(window.MSG_ADDITEM_JS_UPDATEITEM); block.find("input[name='buttonPlusMulti']").remove(); block.find("input[name='multiValue']").remove(); }); }); } - cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields); + cloneItemBlock((row.items && row.items.length) || 0, Koha.prefs.UniqueItemFields); } else if (effective_create_items == "ordering") { $("#acq-create-receiving").hide(); $("#acq-create-ordering").show(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 83f64eda165..048cef09325 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -356,12 +356,12 @@ } @@ -121,7 +121,7 @@ end: dayjs(booking.end_date).toDate(), content: !isActive ? `${patronContent}` : patronContent, className: booking.status === "cancelled" ? "cancelled" : "", - ...(permissions.CAN_user_circulate_manage_bookings ? { editable: !["cancelled", "completed"].includes(booking.status) ? { remove: true, updateTime: true } : false } : { editable: false }), + ...(Koha.permissions.CAN_user_circulate_manage_bookings ? { editable: !["cancelled", "completed"].includes(booking.status) ? { remove: true, updateTime: true } : false } : { editable: false }), type: "range", group: booking.item_id ?? 0, }); @@ -371,7 +371,7 @@ render: function (data, type, row, meta) { let result = ""; const is_readonly = ["cancelled", "completed"].includes(row.status); - if (permissions.CAN_user_circulate_manage_bookings && !is_readonly) { + if (Koha.permissions.CAN_user_circulate_manage_bookings && !is_readonly) { result += ` '.format(row.suggestion_id, _("Delete")); } }, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index 472d5d80ac7..48d8a0b6deb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -462,7 +462,7 @@ const theme = "[% theme | html %]"; const import_batch_id = "[% import_batch_id | html %]"; const record_type = "[% record_type | html %]"; - addPermissions({ + Koha.addPermissions({ CAN_user_editcatalogue_edit_catalogue: [% CAN_user_editcatalogue_edit_catalogue ? 1 : 0 | html %], }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index 5cca9f84fed..42d4957c99d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -494,7 +494,7 @@ const has_patrons = [% borrowers ? 1 : 0 | html %] const op = "[% op | html %]"; - addPermissions({ + Koha.addPermissions({ CanUpdatePasswordExpiration: [% CanUpdatePasswordExpiration ? 1 : 0 | html %], CanUpdateProtectPatron: [% CanUpdateProtectPatron ? 1 : 0 | html %], }); @@ -526,7 +526,7 @@ selections_column.is_hidden = 1; } - if (!permissions.CanUpdatePasswordExpiration) { + if (!Koha.permissions.CanUpdatePasswordExpiration) { let password_expiration_date_column = table_settings.columns.find(c => c.columnname == "batch_patron_edit_password_expiration_date"); password_expiration_date_column.is_hidden = 1; password_expiration_date_column.cannot_be_modified = 1; @@ -534,7 +534,7 @@ password_expiration_date_column.force_visibility = 1; } - if (!permissions.CanUpdateProtectPatron) { + if (!Koha.permissions.CanUpdateProtectPatron) { let protected_column = table_settings.columns.find(c => c.columnname == "batch_patron_edit_protected"); protected_column.is_hidden = 1; protected_column.cannot_be_modified = 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt index 2f12b0d95e4..4734fe43ff6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt @@ -370,7 +370,7 @@ table_settings['columns'].splice(5, 1); } - addPrefs({ + Koha.addPrefs({ OPACBaseURL: "[% Koha.Preference('OPACBaseURL') | html %]", }); const msg_alert = "[% msg | html %]"; @@ -490,7 +490,7 @@ } } function Choose(hashval) { - var res = prefs.OPACBaseURL; + var res = Koha.prefs.OPACBaseURL; res = res.replace(/\/$/, ""); res = res + "/cgi-bin/koha/opac-retrieve-file.pl?id=" + hashval; var index = plugin_index; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 22d9a88bc8b..b7d4c68dd17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -718,17 +718,17 @@ [% IF shelf AND op == 'view' %]