View | Details | Raw Unified | Return to bug 24201
Collapse All | Expand All

(-)a/C4/Auth.pm (-5 / +16 lines)
Lines 38-43 use Koha::Checkouts; Link Here
38
use Koha::DateUtils qw(dt_from_string);
38
use Koha::DateUtils qw(dt_from_string);
39
use Koha::Library::Groups;
39
use Koha::Library::Groups;
40
use Koha::Libraries;
40
use Koha::Libraries;
41
use Koha::Desks;
41
use Koha::Patrons;
42
use Koha::Patrons;
42
use Koha::Patron::Consents;
43
use Koha::Patron::Consents;
43
use POSIX qw/strftime/;
44
use POSIX qw/strftime/;
Lines 461-466 sub get_template_and_user { Link Here
461
        OpenLibraryCovers                                                  => C4::Context->preference("OpenLibraryCovers"),
462
        OpenLibraryCovers                                                  => C4::Context->preference("OpenLibraryCovers"),
462
        KohaAdminEmailAddress                                              => "" . C4::Context->preference("KohaAdminEmailAddress"),
463
        KohaAdminEmailAddress                                              => "" . C4::Context->preference("KohaAdminEmailAddress"),
463
        LoginBranchcode => ( C4::Context->userenv ? C4::Context->userenv->{"branch"}    : undef ),
464
        LoginBranchcode => ( C4::Context->userenv ? C4::Context->userenv->{"branch"}    : undef ),
465
        LoginDeskname                                                      => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ),
464
        LoginFirstname  => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ),
466
        LoginFirstname  => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ),
465
        LoginSurname    => C4::Context->userenv ? C4::Context->userenv->{"surname"}      : "Inconnu",
467
        LoginSurname    => C4::Context->userenv ? C4::Context->userenv->{"surname"}      : "Inconnu",
466
        emailaddress    => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef,
468
        emailaddress    => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef,
Lines 489-494 sub get_template_and_user { Link Here
489
            IntranetmainUserblock                                                      => C4::Context->preference("IntranetmainUserblock"),
491
            IntranetmainUserblock                                                      => C4::Context->preference("IntranetmainUserblock"),
490
            LibraryName                                                                => C4::Context->preference("LibraryName"),
492
            LibraryName                                                                => C4::Context->preference("LibraryName"),
491
            LoginBranchname                                                            => ( C4::Context->userenv ? C4::Context->userenv->{"branchname"} : undef ),
493
            LoginBranchname                                                            => ( C4::Context->userenv ? C4::Context->userenv->{"branchname"} : undef ),
494
            LoginDeskname                                                              => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ),
492
            advancedMARCEditor                                                         => C4::Context->preference("advancedMARCEditor"),
495
            advancedMARCEditor                                                         => C4::Context->preference("advancedMARCEditor"),
493
            canreservefromotherbranches                                                => C4::Context->preference('canreservefromotherbranches'),
496
            canreservefromotherbranches                                                => C4::Context->preference('canreservefromotherbranches'),
494
            intranetcolorstylesheet                                                    => C4::Context->preference("intranetcolorstylesheet"),
497
            intranetcolorstylesheet                                                    => C4::Context->preference("intranetcolorstylesheet"),
Lines 558-563 sub get_template_and_user { Link Here
558
            LibraryName                           => "" . C4::Context->preference("LibraryName"),
561
            LibraryName                           => "" . C4::Context->preference("LibraryName"),
559
            LibraryNameTitle                      => "" . $LibraryNameTitle,
562
            LibraryNameTitle                      => "" . $LibraryNameTitle,
560
            LoginBranchname                       => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "",
563
            LoginBranchname                       => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "",
564
            LoginDeskname                         => C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : "",
561
            OPACAmazonCoverImages                 => C4::Context->preference("OPACAmazonCoverImages"),
565
            OPACAmazonCoverImages                 => C4::Context->preference("OPACAmazonCoverImages"),
562
            OPACFRBRizeEditions                   => C4::Context->preference("OPACFRBRizeEditions"),
566
            OPACFRBRizeEditions                   => C4::Context->preference("OPACFRBRizeEditions"),
563
            OpacHighlightedWords                  => C4::Context->preference("OpacHighlightedWords"),
567
            OpacHighlightedWords                  => C4::Context->preference("OpacHighlightedWords"),
Lines 850-856 sub checkauth { Link Here
850
                $session->param('surname'),      $session->param('branch'),
854
                $session->param('surname'),      $session->param('branch'),
851
                $session->param('branchname'),   $session->param('flags'),
855
                $session->param('branchname'),   $session->param('flags'),
852
                $session->param('emailaddress'), $session->param('branchprinter'),
856
                $session->param('emailaddress'), $session->param('branchprinter'),
853
                $session->param('shibboleth')
857
                $session->param('shibboleth'),   $session->param('desk_id'),
858
                $session->param('desk_name'),
854
            );
859
            );
855
            C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
860
            C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
856
            C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
861
            C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
Lines 1167-1173 sub checkauth { Link Here
1167
                    $session->param('surname'),      $session->param('branch'),
1172
                    $session->param('surname'),      $session->param('branch'),
1168
                    $session->param('branchname'),   $session->param('flags'),
1173
                    $session->param('branchname'),   $session->param('flags'),
1169
                    $session->param('emailaddress'), $session->param('branchprinter'),
1174
                    $session->param('emailaddress'), $session->param('branchprinter'),
1170
                    $session->param('shibboleth')
1175
                    $session->param('shibboleth'), $session->param('desk_id'),
1176
                    $session->param('desk_name'),
1171
                );
1177
                );
1172
1178
1173
            }
1179
            }
Lines 1434-1440 sub check_api_auth { Link Here
1434
                $session->param('cardnumber'),   $session->param('firstname'),
1440
                $session->param('cardnumber'),   $session->param('firstname'),
1435
                $session->param('surname'),      $session->param('branch'),
1441
                $session->param('surname'),      $session->param('branch'),
1436
                $session->param('branchname'),   $session->param('flags'),
1442
                $session->param('branchname'),   $session->param('flags'),
1437
                $session->param('emailaddress'), $session->param('branchprinter')
1443
                $session->param('emailaddress'), $session->param('branchprinter'),
1444
                $session->param('desk_id'),      $session->param('desk_name'),
1438
            );
1445
            );
1439
1446
1440
            my $ip       = $session->param('ip');
1447
            my $ip       = $session->param('ip');
Lines 1595-1601 sub check_api_auth { Link Here
1595
                $session->param('cardnumber'),   $session->param('firstname'),
1602
                $session->param('cardnumber'),   $session->param('firstname'),
1596
                $session->param('surname'),      $session->param('branch'),
1603
                $session->param('surname'),      $session->param('branch'),
1597
                $session->param('branchname'),   $session->param('flags'),
1604
                $session->param('branchname'),   $session->param('flags'),
1598
                $session->param('emailaddress'), $session->param('branchprinter')
1605
                $session->param('emailaddress'), $session->param('branchprinter'),
1606
                $session->param('shibboleth'), $session->param('desk_id'),
1607
                $session->param('desk_name'),
1599
            );
1608
            );
1600
            return ( "ok", $cookie, $sessionID );
1609
            return ( "ok", $cookie, $sessionID );
1601
        } else {
1610
        } else {
Lines 1683-1689 sub check_cookie_auth { Link Here
1683
            $session->param('cardnumber'),   $session->param('firstname'),
1692
            $session->param('cardnumber'),   $session->param('firstname'),
1684
            $session->param('surname'),      $session->param('branch'),
1693
            $session->param('surname'),      $session->param('branch'),
1685
            $session->param('branchname'),   $session->param('flags'),
1694
            $session->param('branchname'),   $session->param('flags'),
1686
            $session->param('emailaddress'), $session->param('branchprinter')
1695
            $session->param('emailaddress'), $session->param('branchprinter'),
1696
            $session->param('shibboleth'),   $session->param('desk_id'),
1697
            $session->param('desk_name'),
1687
        );
1698
        );
1688
1699
1689
        my $ip       = $session->param('ip');
1700
        my $ip       = $session->param('ip');
(-)a/C4/Context.pm (-2 / +5 lines)
Lines 856-862 sub userenv { Link Here
856
  C4::Context->set_userenv($usernum, $userid, $usercnum,
856
  C4::Context->set_userenv($usernum, $userid, $usercnum,
857
                           $userfirstname, $usersurname,
857
                           $userfirstname, $usersurname,
858
                           $userbranch, $branchname, $userflags,
858
                           $userbranch, $branchname, $userflags,
859
                           $emailaddress, $branchprinter, $shibboleth);
859
                           $emailaddress, $branchprinter, $shibboleth
860
                           $desk_id, $desk_name);
860
861
861
Establish a hash of user environment variables.
862
Establish a hash of user environment variables.
862
863
Lines 867-873 set_userenv is called in Auth.pm Link Here
867
#'
868
#'
868
sub set_userenv {
869
sub set_userenv {
869
    shift @_;
870
    shift @_;
870
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $shibboleth)=
871
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $shibboleth, $desk_id, $desk_name)=
871
    map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
872
    map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
872
    @_;
873
    @_;
873
    my $var=$context->{"activeuser"} || '';
874
    my $var=$context->{"activeuser"} || '';
Lines 880-885 sub set_userenv { Link Here
880
        #possibly a law problem
881
        #possibly a law problem
881
        "branch"     => $userbranch,
882
        "branch"     => $userbranch,
882
        "branchname" => $branchname,
883
        "branchname" => $branchname,
884
        "desk_id"    => $desk_id,
885
        "desk_name"  => $desk_name,
883
        "flags"      => $userflags,
886
        "flags"      => $userflags,
884
        "emailaddress"     => $emailaddress,
887
        "emailaddress"     => $emailaddress,
885
        "branchprinter"    => $branchprinter,
888
        "branchprinter"    => $branchprinter,
(-)a/Koha/Template/Plugin/Desks.pm (+79 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Desks;
2
3
# Copyright BULAC 2019
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
use C4::Context;
27
use Koha::Desks;
28
29
sub GetName {
30
    my ( $self, $desk_id ) = @_;
31
    my $d = Koha::Desks->search( { desk_id => $desk_id} )->unblessed;
32
    return @$d ? $d->{'desk_name'} : q{};
33
}
34
35
sub GetLoggedInDeskId {
36
    my ($self) = @_;
37
38
    return C4::Context->userenv ?
39
        C4::Context->userenv->{'desk_id'} :
40
        '';
41
}
42
43
sub all {
44
    my ( $self, $params ) = @_;
45
    my $selected = $params->{selected};
46
    my $unfiltered = $params->{unfiltered} || 0;
47
    my $search_params = $params->{search_params} || {};
48
49
    if ( !$unfiltered ) {
50
        $search_params->{only_from_group} = $params->{only_from_group} || 0;
51
    }
52
53
    my $desks = $unfiltered
54
      ? Koha::Desks->search( $search_params, { order_by => ['desk_name'] } )->unblessed
55
      : Koha::Desks->search_filtered( $search_params, { order_by => ['desk_name'] } )->unblessed;
56
57
    for my $d ( @$desks ) {
58
        if (       defined $selected and $d->{desk_id} eq $selected
59
            or not defined $selected and C4::Context->userenv and $d->{branchcode} eq ( C4::Context->userenv->{desk_id} // q{} )
60
        ) {
61
            $d->{selected} = 1;
62
        }
63
    }
64
65
    return $desks;
66
}
67
68
sub defined {
69
    my ( $self ) = @_;
70
    my $desks = Koha::Desks->search()->unblessed;
71
    if (@$desks) {
72
        return 1 ;
73
    }
74
    else {
75
        return 0;
76
    }
77
}
78
79
1;
(-)a/circ/selectdesk.pl (+87 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2019 BULAC
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth qw/:DEFAULT get_session/;
26
use C4::Koha;
27
use Koha::Desks;
28
29
my $query = CGI->new();
30
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => "circ/selectdesk.tt",
34
        query           => $query,
35
        type            => "intranet",
36
        debug           => 1,
37
        authnotrequired => 0,
38
        flagsrequired   => { catalogue => 1, },
39
    }
40
);
41
42
my $sessionID = $query->cookie("CGISESSID");
43
my $session   = get_session($sessionID);
44
45
my $branch = C4::Context->userenv->{'branch'};
46
my $searchfield = $query->param('searchfield');
47
my $desks_lists;
48
if ($branch) {
49
    $desks_lists = Koha::Desks->search( { branchcode => $branch } )->unblessed;
50
}
51
else {
52
    $desks_lists = Koha::Desks->search( )->unblessed;
53
}
54
55
my $desk_id = $query->param('desk_id');
56
57
my $userenv_desk = C4::Context->userenv->{'desk_id'} || '';
58
my $updated = '';
59
60
if ($desk_id) {
61
    if ( !$userenv_desk or $userenv_desk ne $desk_id ) {
62
        my $desk = Koha::Desks->find( { desk_id => $desk_id } );
63
        $template->param( LoginDeskname => $desk->desk_name );
64
        $template->param( LoginDeskid => $desk->desk_id );
65
        $session->param( desk_name => $desk->desk_name );
66
        $session->param( desk_id => $desk->desk_id );
67
        $updated = 1;
68
    }
69
}
70
else {
71
    $desk_id = $userenv_desk;
72
}
73
74
$template->param( updated => \$updated );
75
76
my $referer = $query->param('oldreferer') || $ENV{HTTP_REFERER};
77
if ($updated) {
78
    print $query->redirect( $referer || '/cgi-bin/koha/mainpage.pl' );
79
}
80
81
$template->param(
82
    referer    => $referer,
83
    desks_list => $desks_lists,
84
    desk_id     => $desk_id,
85
);
86
87
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (+15 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Desks %]
3
[% USE Koha %]
4
[% USE Koha %]
4
<nav class="navbar">
5
<nav class="navbar">
5
    <div class="navbar-header">
6
    <div class="navbar-header">
Lines 86-91 Link Here
86
                                [% END %]
87
                                [% END %]
87
                            </strong>
88
                            </strong>
88
                        [% END %]
89
                        [% END %]
90
                         <span class="separator">|</span>
91
                        <strong>
92
                                [% IF ( LoginDeskname == '' AND Desks.defined ) %]
93
                                   <span class="logged-in-desk-name">NO DESK SET</span>
94
                                [% ELSIF ( LoginDeskname != '' ) %]
95
                                    <span class="logged-in-desk-name">[% LoginDeskname | html %]</span>
96
                                    <span class="logged-in-desk-id content_hidden">[% Desks.GetLoggedInDeskId | html %]</span>
97
                                [% END %]
98
                            </strong>
89
                    </span>
99
                    </span>
90
                    <b class="caret"></b>
100
                    <b class="caret"></b>
91
                </a>
101
                </a>
Lines 123-128 Link Here
123
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
133
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
124
                    </li>
134
                    </li>
125
                    [% END %]
135
                    [% END %]
136
                    [% IF Desks.defined %]
137
                    <li>
138
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a>
139
                    </li>
140
                    [% END %]
126
                    [% IF EnableSearchHistory %]
141
                    [% IF EnableSearchHistory %]
127
                    <li>
142
                    <li>
128
                        <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
143
                        <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt (+6 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Desks %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Circulation</title>
6
<title>Koha &rsaquo; Circulation</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
Lines 33-38 Link Here
33
                            <a class="circ-button" href="/cgi-bin/koha/circ/selectbranchprinter.pl"><i class="fa fa-home"></i> Set library</a>
34
                            <a class="circ-button" href="/cgi-bin/koha/circ/selectbranchprinter.pl"><i class="fa fa-home"></i> Set library</a>
34
                        </li>
35
                        </li>
35
                    [% END %]
36
                    [% END %]
37
                    [% IF Desks.defined %]
38
                        <li>
39
                            <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a>
40
                        </li>
41
                    [% END %]
36
                    [% IF ( fast_cataloging ) %]
42
                    [% IF ( fast_cataloging ) %]
37
                        [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
43
                        [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
38
                            <li>
44
                            <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectdesk.tt (-1 / +66 lines)
Line 0 Link Here
0
- 
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Circulation &rsaquo; Set Desk</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<style type="text/css">
5
    .noshow {display: none;}
6
</style>
7
</head>
8
<body id="circ_selectdesk" class="circ">
9
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'circ-search.inc' %]
11
12
<div id="breadcrumbs">
13
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
14
&rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
15
&rsaquo; <a href="/cgi-bin/koha/circ/selectdesk.pl">Set Desk</a>
16
</div>
17
18
<div class="main container-fluid">
19
    <div class="row">
20
        <div class="col-sm-12">
21
            <main>
22
                <div class="row">
23
24
                [% IF Koha.Preference('CircSidebar') %]
25
                    <div class="col-sm-10 col-sm-push-2">
26
                [% ELSE %]
27
                    <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
28
                [% END %]
29
30
<form method="post" action="selectdesk.pl">
31
  <fieldset class="rows">
32
    <legend>Set desk</legend>
33
    <ol>
34
      <li><label for="desk">Choose desk:</label>
35
        <select name="desk_id" id="desk_id">
36
        [% FOREACH desk IN desks_list %]
37
        <option value="[% desk.desk_id %]">[% desk.desk_name %]</option>
38
        [% END %]
39
        </select>
40
      </li>
41
    </ol>
42
    </fieldset>
43
    <fieldset class="action">
44
      <input type="submit" value="Submit" />
45
      <a class="cancel" id="cancel_set_desk" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
46
     </fieldset>
47
     <div class="noshow">
48
       <input type="hidden" name="oldreferer" value="[% referer or "/cgi-bin/koha/mainpage.pl" |html %]" />
49
     </div>
50
 </form>
51
52
                    [% IF Koha.Preference('CircSidebar') %]
53
                            </div> <!-- /.col-sm-10.col-sm-push-2 -->
54
                            <div class="col-sm-2 col-sm-pull-10">
55
                                <aside>
56
                                    [% INCLUDE 'circ-nav.inc' %]
57
                                </aside>
58
                            </div> <!-- /.col-sm-2.col-sm-pull-10 -->
59
                    [% END %]
60
                    </div>
61
                </div> <!-- /.row -->
62
            </main>
63
        </div> <!-- /.col-sm-12 -->
64
    </div> <!-- /.row -->
65
66
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 24201