Bugzilla – Attachment 39837 Details for
Bug 13881
Add ability to defined circulation desks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13881: Select desk in an intranet session
Bug-13881-Select-desk-in-an-intranet-session.patch (text/plain), 18.81 KB, created by
Nicolas Legrand
on 2015-06-04 09:47:33 UTC
(
hide
)
Description:
Bug 13881: Select desk in an intranet session
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2015-06-04 09:47:33 UTC
Size:
18.81 KB
patch
obsolete
>From fe0135295cf73580bdf7da1fd948e33f4573fb00 Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Thu, 4 Jun 2015 11:41:15 +0200 >Subject: [PATCH] Bug 13881: Select desk in an intranet session >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >the selected Desk appears in the header. The desk can be selecting in >the menu beside username, branchname. > >Test plan : > >1/ Go to the intranet administration, remove all desks if you have >any. The desks should not appear in the header. > >2/ add some desks in administration, without selecting some. The >message « NO DESK SET » should appear at the left of the branchname. > >3/ set a desk for your session. The desk deskcode should appear beside >the branchname. > >4/ change desk, the new name should appear also. >--- > C4/Auth.pm | 50 +++++++++-- > C4/Context.pm | 7 +- > circ/selectdesk.pl | 92 ++++++++++++++++++++ > .../intranet-tmpl/prog/en/includes/header.inc | 14 +++ > .../prog/en/modules/circ/selectdesk.tt | 50 +++++++++++ > 5 files changed, 204 insertions(+), 9 deletions(-) > 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 544bf7e..75caa08 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -29,6 +29,7 @@ use C4::Context; > use C4::Templates; # to get the template > use C4::Languages; > use C4::Branch; # GetBranches >+use C4::Desks; > use C4::Search::History; > use Koha; > use Koha::AuthUtils qw(hash_password); >@@ -390,6 +391,21 @@ sub get_template_and_user { > marcflavour => C4::Context->preference("marcflavour"), > persona => C4::Context->preference("persona"), > ); >+ if (C4::Context->userenv->{"branch"}) { >+ my $desksaref = GetDesks(C4::Context->userenv->{"branch"}); >+ if ($#$desksaref > -1) { >+ $template->param( >+ LoginDeskcode => ( C4::Context->userenv ? C4::Context->userenv->{"deskcode"} : undef ), >+ LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"deskname"} : undef ), >+ HasDesk => (1), >+ ); >+ } >+ else { >+ $template->param( >+ HasDesk => (undef), >+ ); >+ } >+ } > if ( $in->{'type'} eq "intranet" ) { > $template->param( > AmazonCoverImages => C4::Context->preference("AmazonCoverImages"), >@@ -403,6 +419,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->{"deskname"} : undef ), > advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), > canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), > intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), >@@ -475,6 +492,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->{"deskname"} : "", > OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), > OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), > OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), >@@ -765,7 +783,8 @@ sub checkauth { > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('branchprinter'), >- $session->param('persona'), $session->param('shibboleth') >+ $session->param('persona'), $session->param('shibboleth'), >+ $session->param('deskcode'), $session->param('deskname') > ); > C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') ); > C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') ); >@@ -989,7 +1008,8 @@ sub checkauth { > C4::Context->_unset_userenv($sessionID); > } > my ( $borrowernumber, $firstname, $surname, $userflags, >- $branchcode, $branchname, $branchprinter, $emailaddress ); >+ $branchcode, $branchname, $branchprinter, $emailaddress, >+ $deskcode, $deskname); > > if ( $return == 1 ) { > my $select = " >@@ -1065,6 +1085,8 @@ sub checkauth { > $session->param( 'surname', $surname ); > $session->param( 'branch', $branchcode ); > $session->param( 'branchname', $branchname ); >+ $session->param( 'deskcode', $deskcode ); >+ $session->param( 'deskname', $deskname ); > $session->param( 'flags', $userflags ); > $session->param( 'emailaddress', $emailaddress ); > $session->param( 'ip', $session->remote_addr() ); >@@ -1083,6 +1105,8 @@ sub checkauth { > $session->param( 'surname', C4::Context->config('user') ); > $session->param( 'branch', 'NO_LIBRARY_SET' ); > $session->param( 'branchname', 'NO_LIBRARY_SET' ); >+ $session->param( 'deskcode', 'NO_DESK_SET' ); >+ $session->param( 'deskname', 'NO_DESK_SET' ); > $session->param( 'flags', 1 ); > $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') ); > $session->param( 'ip', $session->remote_addr() ); >@@ -1097,7 +1121,8 @@ sub checkauth { > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('branchprinter'), >- $session->param('persona'), $session->param('shibboleth') >+ $session->param('persona'), $session->param('shibboleth'), >+ $session->param('deskcode'), $session->param('deskname') > ); > > } >@@ -1346,7 +1371,9 @@ 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('branchprinter') >+ $session->param('emailaddress'), $session->param('branchprinter'), >+ $session->param('persona'), $session->param('shibboleth'), >+ $session->param('deskcode'), $session->param('deskname') > ); > > my $ip = $session->param('ip'); >@@ -1433,7 +1460,8 @@ sub check_api_auth { > my ( > $borrowernumber, $firstname, $surname, > $userflags, $branchcode, $branchname, >- $branchprinter, $emailaddress >+ $branchprinter, $emailaddress, $deskcode, >+ $deskname > ); > my $sth = > $dbh->prepare( >@@ -1494,6 +1522,8 @@ sub check_api_auth { > $session->param( 'surname', $surname ); > $session->param( 'branch', $branchcode ); > $session->param( 'branchname', $branchname ); >+ $session->param( 'deskcode', $deskcode ); >+ $session->param( 'deskname', $deskname ); > $session->param( 'flags', $userflags ); > $session->param( 'emailaddress', $emailaddress ); > $session->param( 'ip', $session->remote_addr() ); >@@ -1508,6 +1538,8 @@ sub check_api_auth { > $session->param( 'surname', C4::Context->config('user') ); > $session->param( 'branch', 'NO_LIBRARY_SET' ); > $session->param( 'branchname', 'NO_LIBRARY_SET' ); >+ $session->param( 'deskcode', 'NO_DESK_SET' ); >+ $session->param( 'deskname', 'NO_DESK_SET' ); > $session->param( 'flags', 1 ); > $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') ); > $session->param( 'ip', $session->remote_addr() ); >@@ -1518,7 +1550,9 @@ 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('branchprinter') >+ $session->param('emailaddress'), $session->param('branchprinter'), >+ $session->param('persona'), $session->param('shibboleth'), >+ $session->param('deskcode'), $session->param('deskname'), > ); > return ( "ok", $cookie, $sessionID ); > } else { >@@ -1599,7 +1633,9 @@ 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('branchprinter') >+ $session->param('emailaddress'), $session->param('branchprinter'), >+ $session->param('persona'), $session->param('shibboleth'), >+ $session->param('deskcode'), $session->param('deskname'), > ); > > my $ip = $session->param('ip'); >diff --git a/C4/Context.pm b/C4/Context.pm >index a51f5c7..a81a3b9 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -1065,7 +1065,8 @@ sub userenv { > C4::Context->set_userenv($usernum, $userid, $usercnum, > $userfirstname, $usersurname, > $userbranch, $branchname, $userflags, >- $emailaddress, $branchprinter, $persona); >+ $emailaddress, $branchprinter, $persona, >+ $desk, $deskcode); > > Establish a hash of user environment variables. > >@@ -1076,7 +1077,7 @@ set_userenv is called in Auth.pm > #' > sub set_userenv { > shift @_; >- my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona, $shibboleth)= >+ my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona, $shibboleth, $deskcode, $deskname)= > map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here > @_; > my $var=$context->{"activeuser"} || ''; >@@ -1093,6 +1094,8 @@ sub set_userenv { > "emailaddress" => $emailaddress, > "branchprinter" => $branchprinter, > "persona" => $persona, >+ "deskcode" => $deskcode, >+ "deskname" => $deskname, > "shibboleth" => $shibboleth, > }; > $context->{userenv}->{$var} = $cell; >diff --git a/circ/selectdesk.pl b/circ/selectdesk.pl >new file mode 100755 >index 0000000..5b797e3 >--- /dev/null >+++ b/circ/selectdesk.pl >@@ -0,0 +1,92 @@ >+#!/usr/bin/perl >+ >+# 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 2 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+ >+use C4::Context; >+use C4::Output; >+use C4::Auth qw/:DEFAULT get_session/; >+use C4::Koha; >+use C4::Branch; >+use C4::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 = $query->param('branch'); >+my $desks; >+if ($branch) { >+ $desks = GetDesks($branch); >+} >+else { >+ $desks = GetDesks(); >+} >+my $deskloop = []; >+for my $desk (@$desks) { >+ push @$deskloop, GetDesk($desk); >+} >+ >+my $deskcode = $query->param('deskcode'); >+ >+my $userenv_desk = C4::Context->userenv->{'desk'} || ''; >+my $updated = ''; >+ >+if ($deskcode) { >+ if ( !$userenv_desk or $userenv_desk ne $deskcode ) { >+ my $desk = GetDesk($deskcode); >+ $template->param( LoginDeskname => $desk->{'deskname'} ); >+ $template->param( LoginDeskcode => $desk->{'deskcode'} ); >+ $session->param( deskname => $desk->{'deskname'} ); >+ $session->param( deskcode => $desk->{'deskcode'} ); >+ $updated = 1; >+ } >+} >+else { >+ $deskcode = $userenv_desk; >+} >+ >+$template->param( updated => \$updated ); >+ >+unless ( $deskcode ~~ $desks ) { >+ $deskcode = @$desks[0]; >+} >+ >+my $referer = $query->param('oldreferer') || $ENV{HTTP_REFERER}; >+if ($updated) { >+ print $query->redirect( $referer || '/cgi-bin/koha/mainpage.pl' ); >+} >+ >+$template->param( >+ referer => $referer, >+ deskloop => $deskloop, >+); >+ >+output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index e4caee8..fd77762 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -44,6 +44,17 @@ > <a href="#" id="drop3" role="button" class="dropdown-toggle" data-toggle="dropdown"> > [% IF ( loggedinusername ) %] > <span class="loggedinusername">[% loggedinusername %]</span> >+ [% IF ( LoginDeskcode ) %] >+ <span class="separator">|</span> >+ <strong> >+ <span id="logged-in-desk-name">[% LoginDeskcode %]</span> >+ </strong> >+ [% ELSIF (HasDesk) %] >+ <span class="separator">|</span> >+ <strong> >+ <span id="logged-in-desk-name">NO DESK SET</span> >+ </strong> >+ [% END %] > <span class="separator">|</span> > [% IF ( AutoLocation ) %] > <brand> >@@ -73,6 +84,9 @@ > <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a> > </li> > [% END %] >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a> >+ </li> > [% 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/selectdesk.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt >new file mode 100644 >index 0000000..f49c68c >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt >@@ -0,0 +1,50 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Circulation › Set library</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<style type="text/css"> >+ .noshow {display: none;} >+</style> >+</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 library</a> >+</div> >+ >+<div id="doc" class="yui-t7"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <form method="post" action="selectdesk.pl"> >+ <fieldset class="rows"> >+ <legend>Set desk</legend> >+ <ol> >+ <li><label for="desk">Choose desk:</label> >+ <select name="deskcode" id="deskcode"> >+ [% FOREACH deskloo IN deskloop %] >+ [% IF ( deskloo.selected ) %] >+ <option value="[% deskloo.deskcode %]" selected="selected">[% deskloo %]</option> >+ [% ELSE %] >+ <option value="[% deskloo.deskcode %]">[% deskloo.deskname %]</option> >+ [% END %] >+ [% 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' %]">Cancel</a> >+ </fieldset> >+ <div class="noshow"> >+ <input type="hidden" name="oldreferer" value="[% referer or "/cgi-bin/koha/mainpage.pl" |html %]" /> >+ </div> >+ </form> >+ </div> >+ </div> >+ </div> >+[% INCLUDE 'intranet-bottom.inc' %] >-- >1.7.10.4
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 13881
:
37808
|
39837
|
40186
|
40569
|
40709
|
40895
|
41233
|
42804
|
43664
|
93445
|
93446
|
93447
|
93452
|
93453
|
93454
|
95287
|
95288
|
95289
|
95293
|
95294
|
95295
|
101033
|
101050
|
101064
|
101065
|
101479
|
101543
|
101544
|
101545
|
101546
|
101547
|
105009