Skip to content

Commit

Permalink
Bug 37826: Remove the use of the script_name variable where it is unn…
Browse files Browse the repository at this point in the history
…ecessary

Most of the places where a "script_name" variable used it is not
strictly necessary. Because it is also used inconsistently, I think it's
better to simply remove the use of the variable where it isn't strictly
necessary.

This patch removes creation of the template variable from several
scripts and updates the corresponding template with the URL itself.

To test, apply the patch and restart services. Test the following pages,
including the various permutations where they are present, e.g. New,
Edit, Delete.

- Administration -> Cities and towns -> Search via the header search
  form
- Administratoin -> Currencies and exchange rates -> Search via the
  header search form
- Administration -> Desks
- Administration -> Budgets
- Administration -> Authority types
- Administration -> Authority types -> MARC structure -> Subfields
- Administration -> Classification configuration
- Administration -> MARC bibliographic framework
- Administration -> MARC bibliographic framework -> MARC structure ->
  Subfields
- Administration -> Record matching rules
- Administration -> OAI repositories
- Administration -> Patron attribute types
- Administration -> System preferences -> Local use
- Administration -> Z39.50/SRU servers
- Acquisitions -> Vendor -> Contracts
- Acquisitions -> Vendor -> Basket -> Export as CSV
- Acquisitions -> Vendor -> Basket -> Edit basket
- Acquisitions -> Vendor -> Basket groups
- Tools -> Import patrons
- Tools -> Notices and slips

Sponsored-by: Athens County Public Libraries
Signed-off-by: Phil Ringnalda <[email protected]>
Signed-off-by: Katrin Fischer <[email protected]>
  • Loading branch information
oleonard authored and kfischer committed Dec 27, 2024
1 parent 03392b6 commit 8a433d4
Show file tree
Hide file tree
Showing 36 changed files with 81 additions and 127 deletions.
6 changes: 2 additions & 4 deletions admin/auth_subfields_structure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
my $tagsubfield = $input->param('tagsubfield');
my $authtypecode = $input->param('authtypecode');
my $op = $input->param('op') || '';
my $script_name = "/cgi-bin/koha/admin/auth_subfields_structure.pl";

my ($template, $borrowernumber, $cookie) = get_template_and_user(
{ template_name => "admin/auth_subfields_structure.tt",
Expand All @@ -47,12 +46,12 @@
$tagfield =~ s/\,//g;

if ($op) {
$template->param(script_name => $script_name,
$template->param(
tagfield =>$tagfield,
authtypecode => $authtypecode,
$op => 1); # we show only the TMPL_VAR names $op
} else {
$template->param(script_name => $script_name,
$template->param(
tagfield =>$tagfield,
authtypecode => $authtypecode,
else => 1); # we show only the TMPL_VAR names $op
Expand Down Expand Up @@ -237,7 +236,6 @@
);
$template->param(
ass => $ass,
delete_link => $script_name,
);
}
elsif ( $op eq 'cud-delete_confirmed' ) {
Expand Down
4 changes: 1 addition & 3 deletions admin/auth_tag_structure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
$searchfield =~ s/\,//g;


my $script_name = "/cgi-bin/koha/admin/auth_tag_structure.pl";

my $dbh = C4::Context->dbh;

# open template
Expand Down Expand Up @@ -70,7 +68,7 @@
}
}
}
$template->param(script_name => $script_name);

$template->param(authority_types => $authority_types );
if ($op && $op ne 'cud-authtype_create_confirm') {
$template->param($op => 1);
Expand Down
3 changes: 0 additions & 3 deletions admin/classsources.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
use Koha::ClassSortRules;
use Koha::ClassSplitRules;

my $script_name = "/cgi-bin/koha/admin/classsources.pl";

my $input = CGI->new;
my $op = $input->param('op') || 'list';
my $cn_source = $input->param('cn_source');
Expand All @@ -53,7 +51,6 @@
);

my @messages;
$template->param( script_name => $script_name );

if ( $op eq "add_source" ) {
my $class_source =
Expand Down
4 changes: 0 additions & 4 deletions admin/marc_subfields_structure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
my $pkfield = "tagfield";
my $offset = $input->param('offset');
$offset = 0 if not defined $offset or $offset < 0;
my $script_name = "/cgi-bin/koha/admin/marc_subfields_structure.pl";

my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
Expand All @@ -57,7 +56,6 @@

if ($op) {
$template->param(
script_name => $script_name,
tagfield => $tagfield,
frameworkcode => $frameworkcode,
framework => $framework,
Expand All @@ -66,7 +64,6 @@
}
else {
$template->param(
script_name => $script_name,
tagfield => $tagfield,
frameworkcode => $frameworkcode,
framework => $framework,
Expand Down Expand Up @@ -320,7 +317,6 @@
);
$template->param(
mss => $mss,
delete_link => $script_name,
);

# END $OP eq DELETE_CONFIRM
Expand Down
5 changes: 0 additions & 5 deletions admin/marctagstructure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
my $dspchoice = $input->cookie("marctagstructure_selectdisplay") // $input->param('select_display');
my $pagesize = 20;

my $script_name = "/cgi-bin/koha/admin/marctagstructure.pl";

my $dbh = C4::Context->dbh;
my $cache = Koha::Caches->get_instance();

Expand Down Expand Up @@ -76,7 +74,6 @@
$template->param(
frameworks => $frameworks,
framework => $framework,
script_name => $script_name,
( $op || 'else' ) => 1,
);

Expand Down Expand Up @@ -319,13 +316,11 @@
$template->param(isprevpage => $offset,
prevpage=> $offset-$pagesize,
searchfield => $searchfield,
script_name => $script_name
);
}
if ($offset+$pagesize<$cnt) {
$template->param(nextpage =>$offset+$pagesize,
searchfield => $searchfield,
script_name => $script_name
);
}
} #---- END $OP eq DEFAULT
Expand Down
4 changes: 0 additions & 4 deletions admin/matching-rules.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
use C4::Output qw( output_html_with_http_headers );
use C4::Matcher qw/valid_normalization_routines/;

my $script_name = "/cgi-bin/koha/admin/matching-rules.pl";

our $input = CGI->new;
my $op = $input->param('op') || '';

Expand All @@ -39,8 +37,6 @@
flagsrequired => { parameters => 'manage_matching_rules' },
});

$template->param(script_name => $script_name);

my $matcher_id = $input->param("matcher_id");

$template->param( max_matchpoint => 0 );
Expand Down
6 changes: 3 additions & 3 deletions admin/oai_servers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
flagsrequired => { parameters => 'manage_search_targets' },
}
);
my $script_name = "/cgi-bin/koha/admin/oai_servers.pl";
my $path = C4::Context->config('intrahtdocs') . "/prog/";

$template->param( script_name => $script_name, xslt_path => $path );
my $path = C4::Context->config('intrahtdocs') . "/prog/";

$template->param( xslt_path => $path );

my $schema = Koha::Database->new()->schema();

Expand Down
5 changes: 0 additions & 5 deletions admin/patron-attr-types.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
use Koha::Libraries;
use Koha::Patron::Categories;

my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";

our $input = CGI->new;
my $op = $input->param('op') || '';

Expand All @@ -47,9 +45,6 @@
}
);


$template->param(script_name => $script_name);

my $code = $input->param("code");

my $display_list = 0;
Expand Down
20 changes: 4 additions & 16 deletions admin/systempreferences.pl
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,9 @@ sub GetPrefParams {
$searchfield =~ s/\,//g;

if ($op) {
$template->param(
script_name => $script_name,
$op => 1
); # we show only the TMPL_VAR names $op
$template->param( $op => 1 ); # we show only the TMPL_VAR names $op
} else {
$template->param(
script_name => $script_name,
else => 1
); # we show only the TMPL_VAR names $op
$template->param( else => 1 ); # we show only the TMPL_VAR names $op
}

if ( $op eq 'update_and_reedit' ) {
Expand Down Expand Up @@ -260,17 +254,11 @@ sub GetPrefParams {
$value = join ' ', @currentorder;
if ($orderchanged) {
$op = 'add_form';
$template->param(
script_name => $script_name,
$op => 1
); # we show only the TMPL_VAR names $op
$template->param( $op => 1 ); # we show only the TMPL_VAR names $op
} else {
$op = '';
$searchfield = '';
$template->param(
script_name => $script_name,
else => 1
); # we show only the TMPL_VAR names $op
$template->param( else => 1 ); # we show only the TMPL_VAR names $op
}
}
my $variable = $input->param('variable');
Expand Down
2 changes: 0 additions & 2 deletions admin/z3950servers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
type => "intranet",
flagsrequired => { parameters => 'manage_search_targets' },
});
my $script_name = "/cgi-bin/koha/admin/z3950servers.pl";
$template->param( script_name => $script_name );

my $schema = Koha::Database->new()->schema();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[% WRAPPER tabs id="header_search" %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="city_search" bt_active= 1 %]
<form action="[% script_name | html %]" method="get">
<form action="/cgi-bin/koha/admin/cities.pl" method="get">
<div class="form-title">
<label class="control-label" for="city_name_filter"><span class="control-text">Search cities</span> <i class="fa fa-fw fa-building" aria-hidden="true"></i></label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[% WRAPPER tabs id="header_search" %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="contract_description_search" bt_active= 1 %]
<form action="[% script_name | html %]" method="get">
<form action="/cgi-bin/koha/admin/aqcontract.pl" method="get">
<div class="form-title">
<label class="control-label" for="searchfield"><span class="control-text">Search contracts</span> <i class="fa-solid fa-fw fa-pen-to-square" aria-hidden="true"></i></label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[% WRAPPER tabs id="header_search" %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="currency_search" bt_active= 1 %]
<form action="[% script_name | html %]" method="get">
<form action="/cgi-bin/koha/admin/currency.pl" method="get">
<div class="form-title">
<label class="control-label" for="description"><span class="control-text">Search currencies</span> <i class="fa-solid fa-fw fa-dollar-sign" aria-hidden="true"></i></label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[% WRAPPER tabs id="header_search" %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="desk_search" bt_active= 1 %]
<form action="[% script_name|html %]" method="get">
<form action="/cgi-bin/koha/admin/desks.pl" method="get">
<div class="form-title">
<label class="control-label" for="search_desk_name"><span class="control-text">Search desks</span> <i class="fa fa-fw fa-desktop" aria-hidden="true"></i></label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[% WRAPPER tabs id= "header_search" %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="patron_category_search" bt_active= 1 %]
<form action="[% script_name | html %]" method="get">
<form action="/cgi-bin/koha/admin/categories.pl" method="get">
<div class="form-title">
<label class="control-label" for="category_search"><span class="control-text">Search patron categories</span> <i class="fa fa-fw fa-id-card" aria-hidden="true"></i></label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[% PROCESS 'patron-search.inc' %]
[% BLOCK csv_export %]
<div class="btn-group">
<a id="exportbutton" class="btn btn-default" href="[% script_name | url %]?op=export&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]"><i class="fa fa-download"></i> Export as CSV</a>
<a id="exportbutton" class="btn btn-default" href="/cgi-bin/koha/acqui/basket.pl?op=export&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]"><i class="fa fa-download"></i> Export as CSV</a>
<button type="button" class="btn btn-default btn-sm dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle dropdown</span>
</button>
Expand Down
8 changes: 4 additions & 4 deletions koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
[% IF ( grouping ) %]
[% IF (closedbg) %]
<div id="toolbar" class="btn-toolbar">
<div class="btn-group"><a href="[% script_name | url %]?op=reopen&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;mode=singlebg" class="btn btn-default" id="reopenbutton"><i class="fa fa-download"></i> Reopen basket group</a></div>
<div class="btn-group"><a href="[% script_name | url %]?op=export&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="exportbutton"><i class="fa fa-download"></i> Export basket group as CSV</a></div>
<div class="btn-group"><a href="[% script_name | url %]?op=print&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Print basket group in PDF</a></div>
<div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=reopen&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;mode=singlebg" class="btn btn-default" id="reopenbutton"><i class="fa fa-download"></i> Reopen basket group</a></div>
<div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=export&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="exportbutton"><i class="fa fa-download"></i> Export basket group as CSV</a></div>
<div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=print&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Print basket group in PDF</a></div>
[% IF (ediaccount) %]
<div class="btn-group"><a href="[% script_name | url %]?op=ediprint&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div>
<div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=ediprint&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div>
[% END %]
</div>
[% END %]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<h1>Edit basket [% basketname | html %]</h1>
[% ELSE %]<h1>Add a basket to [% booksellername | html %]</h1>
[% END %]
<form name="Aform" action="[% script_name | html %]" method="post" class="validated">
<form name="Aform" action="/cgi-bin/koha/acqui/basketheader.pl" method="post" class="validated">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
<fieldset class="rows">
Expand Down
10 changes: 5 additions & 5 deletions koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
</a>
<ul class="dropdown-menu dropdown-menu-end" role="menu" aria-labelledby="budgetmenu_[% block_budget.budget_period_id | html %]">
<li>
<a class="dropdown-item" href="[% script_name | url %]?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="dropdown-item" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
</li>
[% IF block_budget.count %]
<li data-bs-toggle="tooltip" data-bs-placement="left" title="[% block_budget.count | html %] fund(s) are attached to this budget. You must delete all attached funds before deleting this budget.">
<a class="dropdown-item disabled" aria-disabled="true" href="#"><i class="fa fa-trash-can"></i> Delete</a>
</li>
[% ELSE %]
<li>
<a class="dropdown-item" href="[% script_name | url %]?op=delete_confirm&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
<a class="dropdown-item" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=delete_confirm&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
</li>
[% END %]
<li>
<a class="dropdown-item" href="[% script_name | url %]?op=duplicate_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-copy"></i> Duplicate</a>
<a class="dropdown-item" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=duplicate_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-copy"></i> Duplicate</a>
</li>
<li>
<a class="dropdown-item" href="[% script_name | url %]?op=close_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-times-circle"></i> Close</a>
<a class="dropdown-item" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=close_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-times-circle"></i> Close</a>
</li>
[% IF ( block_budget.budget_period_locked ) %]
<li data-bs-toggle="tooltip" data-bs-placement="left" title="Budget is locked">
Expand Down Expand Up @@ -319,7 +319,7 @@
<!-- "delete" and "cancel" buttons -->
<!-- ############################################################# -->

<form action="[% script_name | html %]" method="post">
<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-delete_confirmed" />
<input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
Expand Down
8 changes: 4 additions & 4 deletions koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<tr><th scope="row">Contract end date:</th><td>[% contractenddate | $KohaDates %]</td></tr>
<tr><th scope="row">Vendor:</th><td>[% booksellername | html %]</td></tr>
</table>
<form action="[% script_name | html %]" method="post">
<form action="/cgi-bin/koha/admin/aqcontract.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-delete_confirmed" />
<input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
Expand Down Expand Up @@ -170,14 +170,14 @@
[% FOREACH loo IN loop %]
<tr>
<td>
<a href="[% loo.script_name | url %]?op=add_form&amp;booksellerid=[% loo.booksellerid | uri %]&amp;contractnumber=[% loo.contractnumber | uri %]">[% loo.contractname | html %]</a>
<a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;booksellerid=[% loo.booksellerid | uri %]&amp;contractnumber=[% loo.contractnumber | uri %]">[% loo.contractname | html %]</a>
</td>
<td>[% loo.contractdescription | html %]</td>
<td>[% loo.contractstartdate | html %]</td>
<td>[% loo.contractenddate | html %]</td>
<td class="actions">
<a href="[% loo.script_name | url %]?op=add_form&amp;contractnumber=[% loo.contractnumber | uri %]&amp;booksellerid=[% loo.booksellerid | uri %]" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a href="[% loo.script_name | url %]?op=delete_confirm&amp;contractnumber=[% loo.contractnumber | uri %]&amp;booksellerid=[% loo.booksellerid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</a>
<a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% loo.contractnumber | uri %]&amp;booksellerid=[% loo.booksellerid | uri %]" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a href="/cgi-bin/koha/admin/aqcontract.pl?op=delete_confirm&amp;contractnumber=[% loo.contractnumber | uri %]&amp;booksellerid=[% loo.booksellerid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</a>
</td>
</tr>
[% END %]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
[% IF ( heading_edit_subfields_p ) %]Edit MARC subfields constraints for field [% tagfield | html %] authority [% authtypecode | html %][% END %]
[% ELSE %][% action | html %][% END %]</h1>
<div class="hint">You can drag and drop the subfield tabs to change the order.</div>
<form action="[% script_name | html %]" name="Aform" method="post">
<form action="/cgi-bin/koha/admin/auth_subfields_structure.pl" name="Aform" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-add_validate" />
<input type="hidden" name="tagfield" value="[% tagfield | html %]" />
Expand Down Expand Up @@ -385,7 +385,7 @@
</table>
</div> <!-- /.page-section -->

<form action="[% script_name | html %]" method="get">
<form action="/cgi-bin/koha/admin/auth_subfields_structure.pl" method="get">
<fieldset class="action"><input type="hidden" name="op" value="add_form" />
<input type="hidden" name="tagfield" value="[% edit_tagfield | html %]" />
<input type="hidden" name="authtypecode" value="[% edit_authtypecode | html %]" />
Expand Down
Loading

0 comments on commit 8a433d4

Please sign in to comment.