Bugzilla – Attachment 101684 Details for
Bug 24201
Attach desk to intranet session
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24201: Attach desk to intranet session
Bug-24201-Attach-desk-to-intranet-session.patch (text/plain), 20.84 KB, created by
Martin Renvoize (ashimema)
on 2020-03-25 11:15:54 UTC
(
hide
)
Description:
Bug 24201: Attach desk to intranet session
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-03-25 11:15:54 UTC
Size:
20.84 KB
patch
obsolete
>From 5fd8a6d2a76ed89952c0e03f1817a0872d2f4a7c Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Tue, 10 Dec 2019 15:02:31 +0100 >Subject: [PATCH] Bug 24201: Attach desk to intranet session >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When Desks are defined, a librarian can attach a desk to its session. > >Test plan: > >1. apply 13881 and create some desks >2. you should see âNO DESK SETâ in the intranet header >3. go to circulation > Set desk >4. you should see your desk name in the header, whatever the page >5. you can also set desk with the header menu > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Auth.pm | 21 ++- > C4/Context.pm | 7 +- > Koha/Template/Plugin/Desks.pm | 122 ++++++++++++++++++ > circ/selectdesk.pl | 87 +++++++++++++ > .../prog/en/includes/circ-nav.inc | 4 + > .../intranet-tmpl/prog/en/includes/header.inc | 15 +++ > .../prog/en/modules/circ/circulation-home.tt | 6 + > .../prog/en/modules/circ/selectdesk.tt | 62 +++++++++ > 8 files changed, 315 insertions(+), 9 deletions(-) > create mode 100644 Koha/Template/Plugin/Desks.pm > create mode 100755 circ/selectdesk.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index f3089f2ac9..aa5cc3816c 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -38,6 +38,7 @@ use Koha::Checkouts; > use Koha::DateUtils qw(dt_from_string); > use Koha::Library::Groups; > use Koha::Libraries; >+use Koha::Desks; > use Koha::Patrons; > use Koha::Patron::Consents; > use POSIX qw/strftime/; >@@ -461,6 +462,7 @@ sub get_template_and_user { > OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), > KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), > LoginBranchcode => ( C4::Context->userenv ? C4::Context->userenv->{"branch"} : undef ), >+ LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ), > LoginFirstname => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ), > LoginSurname => C4::Context->userenv ? C4::Context->userenv->{"surname"} : "Inconnu", > emailaddress => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef, >@@ -489,6 +491,7 @@ sub get_template_and_user { > IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), > LibraryName => C4::Context->preference("LibraryName"), > LoginBranchname => ( C4::Context->userenv ? C4::Context->userenv->{"branchname"} : undef ), >+ LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ), > advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), > canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), > intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), >@@ -558,6 +561,7 @@ sub get_template_and_user { > LibraryName => "" . C4::Context->preference("LibraryName"), > LibraryNameTitle => "" . $LibraryNameTitle, > LoginBranchname => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "", >+ LoginDeskname => C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : "", > OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), > OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), > OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), >@@ -848,8 +852,8 @@ sub checkauth { > $session->param('cardnumber'), $session->param('firstname'), > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), >- $session->param('emailaddress'), >- $session->param('shibboleth') >+ $session->param('emailaddress'), $session->param('shibboleth'), >+ $session->param('desk_id'), $session->param('desk_name') > ); > C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') ); > C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') ); >@@ -1162,7 +1166,8 @@ sub checkauth { > $session->param('cardnumber'), $session->param('firstname'), > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), >- $session->param('emailaddress'), $session->param('shibboleth') >+ $session->param('emailaddress'), $session->param('shibboleth'), >+ $session->param('desk_id'), $session->param('desk_name') > ); > > } >@@ -1440,7 +1445,8 @@ sub check_api_auth { > $session->param('cardnumber'), $session->param('firstname'), > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), >- $session->param('emailaddress') >+ $session->param('emailaddress'), $session->param('desk_id'), >+ $session->param('desk_name') > ); > > my $ip = $session->param('ip'); >@@ -1599,8 +1605,8 @@ sub check_api_auth { > $session->param('number'), $session->param('id'), > $session->param('cardnumber'), $session->param('firstname'), > $session->param('surname'), $session->param('branch'), >- $session->param('branchname'), $session->param('flags'), >- $session->param('emailaddress') >+ $session->param('emailaddress'), $session->param('shibboleth'), >+ $session->param('desk_id'), $session->param('desk_name') > ); > return ( "ok", $cookie, $sessionID ); > } else { >@@ -1688,7 +1694,8 @@ sub check_cookie_auth { > $session->param('cardnumber'), $session->param('firstname'), > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), >- $session->param('emailaddress') >+ $session->param('emailaddress'), $session->param('shibboleth'), >+ $session->param('desk_id'), $session->param('desk_name') > ); > > my $ip = $session->param('ip'); >diff --git a/C4/Context.pm b/C4/Context.pm >index df4b5dbbc6..6cb64be247 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -809,7 +809,8 @@ sub userenv { > C4::Context->set_userenv($usernum, $userid, $usercnum, > $userfirstname, $usersurname, > $userbranch, $branchname, $userflags, >- $emailaddress, $shibboleth); >+ $emailaddress, $shibboleth >+ $desk_id, $desk_name); > > Establish a hash of user environment variables. > >@@ -820,7 +821,7 @@ set_userenv is called in Auth.pm > #' > sub set_userenv { > shift @_; >- my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth)= >+ my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name)= > map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here > @_; > my $var=$context->{"activeuser"} || ''; >@@ -833,6 +834,8 @@ sub set_userenv { > #possibly a law problem > "branch" => $userbranch, > "branchname" => $branchname, >+ "desk_id" => $desk_id, >+ "desk_name" => $desk_name, > "flags" => $userflags, > "emailaddress" => $emailaddress, > "shibboleth" => $shibboleth, >diff --git a/Koha/Template/Plugin/Desks.pm b/Koha/Template/Plugin/Desks.pm >new file mode 100644 >index 0000000000..99fe2329e3 >--- /dev/null >+++ b/Koha/Template/Plugin/Desks.pm >@@ -0,0 +1,122 @@ >+package Koha::Template::Plugin::Desks; >+ >+# Copyright (C) BULAC 2020 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Koha; >+use C4::Context; >+use Koha::Desks; >+ >+=head1 NAME >+ >+Koha::Template::Plugin::Desks - A module for dealing with desks in templates >+ >+=head1 DESCRIPTION >+ >+This plugin contains getters functions, to fetch all desks a library >+got or the current one. >+ >+=head2 Methods >+ >+=head3 GetName >+ >+[% Desk.GetName(desk_id) %] >+ >+return desk name or empty string >+ >+=cut >+ >+sub GetName { >+ my ( $self, $desk_id ) = @_; >+ my $d = Koha::Desks->search( { desk_id => $desk_id} )->unblessed; >+ return @$d ? $d->{'desk_name'} : q{}; >+} >+ >+=head3 GetLoggedInDeskId >+ >+[% Desks.GetLoggedInDeskId %] >+ >+return the desk name that is attached to the session or empty string >+ >+=cut >+ >+sub GetLoggedInDeskId { >+ my ($self) = @_; >+ >+ return C4::Context->userenv ? >+ C4::Context->userenv->{'desk_id'} : >+ ''; >+} >+ >+=head3 all >+ >+[% Desks.all %] >+ >+returns all desks existing at the library >+ >+=cut >+ >+sub all { >+ my ( $self, $params ) = @_; >+ my $selected = $params->{selected}; >+ my $unfiltered = $params->{unfiltered} || 0; >+ my $search_params = $params->{search_params} || {}; >+ >+ if ( !$unfiltered ) { >+ $search_params->{only_from_group} = $params->{only_from_group} || 0; >+ } >+ >+ my $desks = $unfiltered >+ ? Koha::Desks->search( $search_params, { order_by => ['desk_name'] } )->unblessed >+ : Koha::Desks->search_filtered( $search_params, { order_by => ['desk_name'] } )->unblessed; >+ >+ for my $d ( @$desks ) { >+ if ( defined $selected and $d->{desk_id} eq $selected >+ or not defined $selected and C4::Context->userenv and $d->{branchcode} eq ( C4::Context->userenv->{desk_id} // q{} ) >+ ) { >+ $d->{selected} = 1; >+ } >+ } >+ >+ return $desks; >+} >+ >+=head3 defined >+ >+[% Desks.defined %] >+ >+return 1 if there is at least a desk defined for the library. >+ >+=cut >+ >+sub defined { >+ my ( $self ) = @_; >+ my $desks = Koha::Desks->search()->unblessed; >+ if (@$desks) { >+ return 1 ; >+ } >+ else { >+ return 0; >+ } >+} >+ >+1; >diff --git a/circ/selectdesk.pl b/circ/selectdesk.pl >new file mode 100755 >index 0000000000..7589bac5c3 >--- /dev/null >+++ b/circ/selectdesk.pl >@@ -0,0 +1,87 @@ >+#!/usr/bin/perl >+ >+# Copyright (C) 2020 BULAC >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+ >+use C4::Context; >+use C4::Output; >+use C4::Auth qw/:DEFAULT get_session/; >+use C4::Koha; >+use Koha::Desks; >+ >+my $query = CGI->new(); >+ >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "circ/selectdesk.tt", >+ query => $query, >+ type => "intranet", >+ debug => 1, >+ authnotrequired => 0, >+ flagsrequired => { catalogue => 1, }, >+ } >+); >+ >+my $sessionID = $query->cookie("CGISESSID"); >+my $session = get_session($sessionID); >+ >+my $branch = C4::Context->userenv->{'branch'}; >+my $searchfield = $query->param('searchfield'); >+my $desks_lists; >+if ($branch) { >+ $desks_lists = Koha::Desks->search( { branchcode => $branch } )->unblessed; >+} >+else { >+ $desks_lists = Koha::Desks->search( )->unblessed; >+} >+ >+my $desk_id = $query->param('desk_id'); >+ >+my $userenv_desk = C4::Context->userenv->{'desk_id'} || ''; >+my $updated = ''; >+ >+if ($desk_id) { >+ if ( !$userenv_desk or $userenv_desk ne $desk_id ) { >+ my $desk = Koha::Desks->find( { desk_id => $desk_id } ); >+ $template->param( LoginDeskname => $desk->desk_name ); >+ $template->param( LoginDeskid => $desk->desk_id ); >+ $session->param( desk_name => $desk->desk_name ); >+ $session->param( desk_id => $desk->desk_id ); >+ $updated = 1; >+ } >+} >+else { >+ $desk_id = $userenv_desk; >+} >+ >+$template->param( updated => \$updated ); >+ >+my $referer = $query->param('oldreferer') || $ENV{HTTP_REFERER}; >+if ($updated) { >+ print $query->redirect( $referer || '/cgi-bin/koha/mainpage.pl' ); >+} >+ >+$template->param( >+ referer => $referer, >+ desks_list => $desks_lists, >+ desk_id => $desk_id, >+); >+ >+output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >index 979871a0b9..7360e1f288 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >@@ -1,4 +1,5 @@ > [% USE Branches %] >+[% USE Desks %] > <div id="navmenu"> > <div id="navmenulist"> > >@@ -17,6 +18,9 @@ > [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %] > <li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li> > [% END %][% END %] >+ [% IF ( Desks.defined ) %] >+ <li><a href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a></li> >+ [% END %] > [% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %] > <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li> > [% END %][% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 868b22a418..e88abeb32b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -1,5 +1,6 @@ > [% USE raw %] > [% USE Branches %] >+[% USE Desks %] > [% USE Koha %] > <nav class="navbar"> > <div class="navbar-header"> >@@ -85,6 +86,15 @@ > <span class="logged-in-branch-code content_hidden">[% Branches.GetLoggedInBranchcode | html %]</span> > </strong> > [% END %] >+ <span class="separator">|</span> >+ <strong> >+ [% IF ( LoginDeskname == '' AND Desks.defined ) %] >+ <span class="logged-in-desk-name">NO DESK SET</span> >+ [% ELSIF ( LoginDeskname != '' ) %] >+ <span class="logged-in-desk-name">[% LoginDeskname | html %]</span> >+ <span class="logged-in-desk-id content_hidden">[% Desks.GetLoggedInDeskId | html %]</span> >+ [% END %] >+ </strong> > </span> > <b class="caret"></b> > </a> >@@ -118,6 +128,11 @@ > <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a> > </li> > [% END %] >+ [% IF Desks.defined %] >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a> >+ </li> >+ [% END %] > [% IF EnableSearchHistory %] > <li> > <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >index fbabec6745..5c17f284f9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE Koha %] > [% USE Branches %] >+[% USE Desks %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Circulation</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -33,6 +34,11 @@ > <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a> > </li> > [% END %] >+ [% IF Desks.defined %] >+ <li> >+ <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a> >+ </li> >+ [% END %] > [% IF ( fast_cataloging ) %] > [% IF ( CAN_user_editcatalogue_fast_cataloging ) %] > <li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt >new file mode 100644 >index 0000000000..f8315ac67e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt >@@ -0,0 +1,62 @@ >+[% USE Koha %] >+ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Circulation › Set Desk</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="circ_selectdesk" class="circ"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'circ-search.inc' %] >+ >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+› <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> >+› <a href="/cgi-bin/koha/circ/selectdesk.pl">Set Desk</a> >+</div> >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-12"> >+ <main> >+ <div class="row"> >+ >+ [% IF Koha.Preference('CircSidebar') %] >+ <div class="col-sm-10 col-sm-push-2"> >+ [% ELSE %] >+ <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"> >+ [% END %] >+ >+<form method="post" action="selectdesk.pl"> >+ <fieldset class="rows"> >+ <legend>Set desk</legend> >+ <ol> >+ <li><label for="desk">Choose desk:</label> >+ <select name="desk_id" id="desk_id"> >+ [% FOREACH desk IN desks_list %] >+ <option value="[% desk.desk_id|html %]">[% desk.desk_name|html %]</option> >+ [% END %] >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" id="cancel_set_desk" href="[% referer or '/cgi-bin/koha/circ/circulation.pl'|html %]">Cancel</a> >+ </fieldset> >+ <input type="hidden" name="oldreferer" value="[% referer or "/cgi-bin/koha/mainpage.pl" |html %]" /> >+ </form> >+ >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ [% IF Koha.Preference('CircSidebar') %] >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'circ-nav.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ [% END %] >+ </div> <!-- /.row --> >+ </main> >+ </div> <!-- /.col-sm-12 --> >+ </div> <!-- /.row --> >+ >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24201
:
96158
|
96164
|
96165
|
96166
|
101452
|
101564
|
101684
|
101697
|
101704
|
101705
|
101848
|
101865
|
101866
|
101877
|
101878
|
101879
|
101880
|
101881
|
101882
|
101883
|
103839
|
103840
|
105795
|
105869
|
105873
|
105874
|
105875
|
106576
|
107089
|
107090
|
107091
|
107092
|
107093
|
107094
|
107095
|
107096
|
107097
|
107667
|
107668
|
107669
|
107670
|
107671
|
107672
|
107673
|
107674
|
107675
|
107676
|
107677
|
107678
|
107679
|
107680
|
107728
|
107729
|
107730
|
107731
|
107732
|
107750
|
107751
|
107752
|
107815
|
107816
|
107817
|
107818
|
107951
|
107952
|
107967
|
107968
|
107980
|
107981