From 7d19914167dc10854b914369c6b9cd51da6483e2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Aug 2018 09:57:29 -0300 Subject: [PATCH] Bug 21137: Replace USER_INFO with logged_in_user This patch set does several things: - it removes USER_INFO and BORROWER_INFO These 2 variables contained logged-in patron's info. They must be accessed from logged_in_user - Use patron-title.inc for the breadcrumb at the OPAC, for consistencies --- C4/Auth.pm | 4 +--- C4/InstallAuth.pm | 2 +- admin/aqbudgets.pl | 5 +---- admin/aqplan.pl | 12 ++++++++---- koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc | 10 +++++----- .../intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt | 2 +- .../intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt | 4 ++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt | 4 ++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-search-history.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt | 2 +- 16 files changed, 29 insertions(+), 30 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index e27b1b3ad7..f0f3eb8611 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -145,7 +145,7 @@ See C<&checkauth> for an explanation of these parameters. The C is then used to find the correct template for the page. The authenticated users details are loaded onto the -template in the HTML::Template LOOP variable C. Also the +template in the logged_in_user variable (which is a Koha::Patron object). Also the C is passed to the template. This can be used in templates if cookies are disabled. It needs to be put as and input to every authenticated page. @@ -285,8 +285,6 @@ sub get_template_and_user { ); } - $template->param( "USER_INFO" => $patron->unblessed ) if $borrowernumber != 0; - my $all_perms = get_all_subpermissions(); my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow diff --git a/C4/InstallAuth.pm b/C4/InstallAuth.pm index 5f5f213331..67319b3db6 100644 --- a/C4/InstallAuth.pm +++ b/C4/InstallAuth.pm @@ -96,7 +96,7 @@ InstallAuth - Authenticates Koha users for Install process The C is then used to find the correct template for the page. The authenticated users details are loaded onto the - template in the HTML::Template LOOP variable C. Also the + template in the logged_in_user variable (which is a Koha::Patron object). Also the C is passed to the template. This can be used in templates if cookies are disabled. It needs to be put as and input to every authenticated page. diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index 5aeb8b9786..44f0d7fd08 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -89,9 +89,6 @@ if ( $budget_period_id ) { # ------- get periods stuff ------------------ -# USED FOR PERMISSION COMPARISON LATER -my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'}; - $template->param( show_mine => $show_mine, op => $op, @@ -235,7 +232,7 @@ if ( $op eq 'list' ) { ); my @budgets = @{ - GetBudgetHierarchy( $$period{budget_period_id}, undef, ( $show_mine ? $borrower_id : 0 )) + GetBudgetHierarchy( $$period{budget_period_id}, undef, ( $show_mine ? $borrowernumber : 0 )) }; my $period_total = 0; diff --git a/admin/aqplan.pl b/admin/aqplan.pl index f01e5e8b13..0ba3d25fef 100755 --- a/admin/aqplan.pl +++ b/admin/aqplan.pl @@ -84,8 +84,8 @@ $template->param( # ------- get periods stuff ------------------ -my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'}; -my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}->{'branchcode'}; + +my $borrower_branchcode = my $branch_code = C4::Context->userenv->{'branch'}; my $authcat = $input->param('authcat'); my $show_active = $input->param('show_active') // 0; @@ -108,7 +108,11 @@ $authcat = 'Asort1' if not defined $authcat; # defaults to Asort if no authcat my $budget_id = $input->param('budget_id'); my $op = $input->param("op") // q{}; -my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}->{'borrowernumber'}:'' ); +my $budgets_ref = GetBudgetHierarchy( + $budget_period_id, + $show_mine ? $borrower_branchcode : '', + $show_mine ? $borrowernumber : '' +); # build categories list my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' "); @@ -315,7 +319,7 @@ foreach my $budget (@budgets) { if ( $period->{budget_period_locked} == 1 ) { $budget_lock = 1; } elsif ( $budget->{budget_permission} == 1 ) { - $budget_lock = 1 if $borrower_id != $budget->{'budget_owner_id'}; + $budget_lock = 1 if $borrowernumber != $budget->{'budget_owner_id'}; } elsif ( $budget->{budget_permission} == 2 ) { $budget_lock = 1 if $borrower_branchcode ne $budget->{budget_branchcode}; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc index d052fd9b1d..25902afe67 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -620,7 +620,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $( sel ).on( event, function (e) { e.preventDefault(); handler( e, Preferences.user[pref] ); - Preferences.Save( [% USER_INFO.borrowernumber %] ); + Preferences.Save( [% logged_in_user.borrowernumber %] ); showPreference(pref); } ); } @@ -645,7 +645,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $( document ).on( 'change', 'input.search-toggle-server', function() { var server_id = $( this ).closest('li').data('server-id'); Preferences.user.selected_search_targets[server_id] = this.checked; - Preferences.Save( [% USER_INFO.borrowernumber %] ); + Preferences.Save( [% logged_in_user.borrowernumber %] ); } ); break; } @@ -683,7 +683,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr delete Preferences.user.macros[name]; } - Preferences.Save( [% USER_INFO.borrowernumber %] ); + Preferences.Save( [% logged_in_user.borrowernumber %] ); } function showSavedMacros( macros ) { @@ -980,7 +980,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $( '#switch-editor' ).click( function() { if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return; - $.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'basic', { expires: 365, path: '/' } ); + $.cookie( 'catalogue_editor_[% logged_in_user.borrowernumber %]', 'basic', { expires: 365, path: '/' } ); if ( state.backend == 'catalog' ) { window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + state.recordID; @@ -1093,7 +1093,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr }; // Start editor - Preferences.Load( [% USER_INFO.borrowernumber || 0 %] ); + Preferences.Load( [% logged_in_user.borrowernumber || 0 %] ); displayPreferences(editor); makeAuthorisedValueWidgets( '' ); Search.Init( { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 2f31727fbd..f8bf448156 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -111,7 +111,7 @@ if ( !confirm( breedingid ? _("This record cannot be transferred to the advanced editor. Continue?") : _("Any changes will not be saved. Continue?") ) ) return false; - $.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'advanced', { expires: 365, path: '/' } ); + $.cookie( 'catalogue_editor_[% logged_in_user.borrowernumber %]', 'advanced', { expires: 365, path: '/' } ); var biblionumber = [% biblionumber || "null" %]; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt index 7305bd54b6..fd2d8ba97b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt @@ -236,7 +236,7 @@ }); $("#useadvanced").click(function(){ - $.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'advanced', { expires: 365, path: '/' } ); + $.cookie( 'catalogue_editor_[% logged_in_user.borrowernumber %]', 'advanced', { expires: 365, path: '/' } ); return true; }); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 15d185fe76..95b025f277 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -103,7 +103,7 @@ [% END %] [% END %] [% IF ( loggedinusername ) %] -
  • +
  • [% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt index 805b072130..e47844e2c7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt @@ -9,8 +9,8 @@