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

(-)a/C4/Auth.pm (-30 / +31 lines)
Lines 495-529 sub get_template_and_user { Link Here
495
    if ( $in->{'type'} eq "intranet" ) {
495
    if ( $in->{'type'} eq "intranet" ) {
496
496
497
        $template->param(
497
        $template->param(
498
            advancedMARCEditor           => C4::Context->preference("advancedMARCEditor"),
498
            advancedMARCEditor            => C4::Context->preference("advancedMARCEditor"),
499
            AllowMultipleCovers          => C4::Context->preference('AllowMultipleCovers'),
499
            AllowMultipleCovers           => C4::Context->preference('AllowMultipleCovers'),
500
            AmazonCoverImages            => C4::Context->preference("AmazonCoverImages"),
500
            AmazonCoverImages             => C4::Context->preference("AmazonCoverImages"),
501
            StaffLoginRestrictLibraryByIP => C4::Context->preference("StaffLoginRestrictLibraryByIP"),
501
            StaffLoginRestrictLibraryByIP => C4::Context->preference("StaffLoginRestrictLibraryByIP"),
502
            can_see_cataloguing_module   => haspermission( $user, get_cataloguing_page_permissions() ) ? 1 : 0,
502
            can_see_cataloguing_module    => haspermission( $user, get_cataloguing_page_permissions() ) ? 1 : 0,
503
            canreservefromotherbranches  => C4::Context->preference('canreservefromotherbranches'),
503
            canreservefromotherbranches   => C4::Context->preference('canreservefromotherbranches'),
504
            EasyAnalyticalRecords        => C4::Context->preference('EasyAnalyticalRecords'),
504
            EasyAnalyticalRecords         => C4::Context->preference('EasyAnalyticalRecords'),
505
            EnableBorrowerFiles          => C4::Context->preference('EnableBorrowerFiles'),
505
            EnableBorrowerFiles           => C4::Context->preference('EnableBorrowerFiles'),
506
            FRBRizeEditions              => C4::Context->preference("FRBRizeEditions"),
506
            FRBRizeEditions               => C4::Context->preference("FRBRizeEditions"),
507
            IndependentBranches          => C4::Context->preference("IndependentBranches"),
507
            IndependentBranches           => C4::Context->preference("IndependentBranches"),
508
            intranetcolorstylesheet      => C4::Context->preference("intranetcolorstylesheet"),
508
            intranetcolorstylesheet       => C4::Context->preference("intranetcolorstylesheet"),
509
            IntranetFavicon              => C4::Context->preference("IntranetFavicon"),
509
            IntranetFavicon               => C4::Context->preference("IntranetFavicon"),
510
            IntranetmainUserblock        => C4::Context->preference("IntranetmainUserblock"),
510
            IntranetmainUserblock         => C4::Context->preference("IntranetmainUserblock"),
511
            IntranetNav                  => C4::Context->preference("IntranetNav"),
511
            IntranetNav                   => C4::Context->preference("IntranetNav"),
512
            intranetreadinghistory       => C4::Context->preference("intranetreadinghistory"),
512
            intranetreadinghistory        => C4::Context->preference("intranetreadinghistory"),
513
            IntranetReadingHistoryHolds  => C4::Context->preference("IntranetReadingHistoryHolds"),
513
            IntranetReadingHistoryHolds   => C4::Context->preference("IntranetReadingHistoryHolds"),
514
            intranetstylesheet           => C4::Context->preference("intranetstylesheet"),
514
            intranetstylesheet            => C4::Context->preference("intranetstylesheet"),
515
            IntranetUserCSS              => C4::Context->preference("IntranetUserCSS"),
515
            IntranetUserCSS               => C4::Context->preference("IntranetUserCSS"),
516
            IntranetUserJS               => C4::Context->preference("IntranetUserJS"),
516
            IntranetUserJS                => C4::Context->preference("IntranetUserJS"),
517
            LibraryName                  => C4::Context->preference("LibraryName"),
517
            LibraryName                   => C4::Context->preference("LibraryName"),
518
            LocalCoverImages             => C4::Context->preference('LocalCoverImages'),
518
            LocalCoverImages              => C4::Context->preference('LocalCoverImages'),
519
            OPACLocalCoverImages         => C4::Context->preference('OPACLocalCoverImages'),
519
            OPACLocalCoverImages          => C4::Context->preference('OPACLocalCoverImages'),
520
            PatronAutoComplete           => C4::Context->preference("PatronAutoComplete"),
520
            PatronAutoComplete            => C4::Context->preference("PatronAutoComplete"),
521
            pending_checkout_notes       => Koha::Checkouts->search( { noteseen => 0 } ),
521
            pending_checkout_notes        => Koha::Checkouts->search( { noteseen => 0 } ),
522
            plugins_enabled              => C4::Context->config("enable_plugins"),
522
            plugins_enabled               => C4::Context->config("enable_plugins"),
523
            StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"),
523
            StaffSerialIssueDisplayCount  => C4::Context->preference("StaffSerialIssueDisplayCount"),
524
            UseCourseReserves            => C4::Context->preference("UseCourseReserves"),
524
            UseCourseReserves             => C4::Context->preference("UseCourseReserves"),
525
            useDischarge                 => C4::Context->preference('useDischarge'),
525
            useDischarge                  => C4::Context->preference('useDischarge'),
526
            virtualshelves               => C4::Context->preference("virtualshelves"),
526
            virtualshelves                => C4::Context->preference("virtualshelves"),
527
        );
527
        );
528
    }
528
    }
529
    else {
529
    else {
Lines 1235-1246 sub checkauth { Link Here
1235
                        }
1235
                        }
1236
1236
1237
                        if (
1237
                        if (
1238
                            # If StaffLoginBranchBasedOnIP is enabled we will try to find a branch
1238
                            # If StaffLoginLibraryBasedOnIP is enabled we will try to find a branch
1239
                            # matching your ip, regardless of the choice you have passed in
1239
                            # matching your ip, regardless of the choice you have passed in
1240
                            (
1240
                            (
1241
                                  !C4::Context->preference('StaffLoginRestrictLibraryByIP')
1241
                                  !C4::Context->preference('StaffLoginRestrictLibraryByIP')
1242
                                && C4::Context->preference('StaffLoginBranchBasedOnIP')
1242
                                && C4::Context->preference('StaffLoginLibraryBasedOnIP')
1243
                            )
1243
                            )
1244
1244
                            # When StaffLoginRestrictLibraryByIP is enabled we will not choose a branch matching IP
1245
                            # When StaffLoginRestrictLibraryByIP is enabled we will not choose a branch matching IP
1245
                            # if your selected branch has no IP set
1246
                            # if your selected branch has no IP set
1246
                            || (   C4::Context->preference('StaffLoginRestrictLibraryByIP')
1247
                            || (   C4::Context->preference('StaffLoginRestrictLibraryByIP')
(-)a/installer/data/mysql/atomicupdate/bug_26176.pl (-2 / +15 lines)
Lines 3-9 use Koha::Installer::Output qw(say_warning say_failure say_success say_info); Link Here
3
3
4
return {
4
return {
5
    bug_number  => "26176",
5
    bug_number  => "26176",
6
    description => "Rename AutoLocation to StaffLoginRestrictLibraryByIP",
6
    description => "Rename AutoLocation and StaffLoginBranchBasedOnIP",
7
    up          => sub {
7
    up          => sub {
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
Lines 15-20 return { Link Here
15
        }
15
        }
16
        );
16
        );
17
17
18
        say $out "Renamed system preference 'AutoLocation' to 'StaffLoginRestrictLibraryByIP'";
18
        say_success( $out, "Renamed system preference 'AutoLocation' to 'StaffLoginRestrictLibraryByIP'" );
19
20
        $dbh->do(
21
            q{
22
            UPDATE systempreferences SET variable = "StaffLoginRestrictLibraryByIP"
23
            WHERE variable = "StaffLoginLibraryBasedOnIP"
24
        }
25
        );
26
27
        say_success(
28
            $out,
29
            "Renamed system preference 'StaffLoginLibraryBasedOnIP' to 'StaffLoginRestrictLibraryByIP'"
30
        );
31
19
    },
32
    },
20
};
33
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 735-742 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
735
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
735
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
736
('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'),
736
('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'),
737
('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff interface','Choice'),
737
('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff interface','Choice'),
738
('StaffLoginBranchBasedOnIP', '0','', 'Set the logged in library for the user based on their current IP','YesNo'),
739
('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'),
738
('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'),
739
('StaffLoginLibraryBasedOnIP', '0','', 'Set the logged in library for the user based on their current IP','YesNo'),
740
('StaffLoginRestrictLibraryByIP','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses based on branch','YesNo'),
740
('StaffLoginRestrictLibraryByIP','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses based on branch','YesNo'),
741
('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'),
741
('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'),
742
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the staff interface','Integer'),
742
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the staff interface','Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (-2 / +2 lines)
Lines 98-104 Administration: Link Here
98
                  1: "Yes"
98
                  1: "Yes"
99
                  0: "No"
99
                  0: "No"
100
            - <a href="/cgi-bin/koha/admin/branches.pl">Link to library administration</a>
100
            - <a href="/cgi-bin/koha/admin/branches.pl">Link to library administration</a>
101
            - 'Staff can only choose their library at login if they have the "loggedinlibrary" permission. This setting will override the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=StaffLoginBranchBasedOnIP">StaffLoginBranchBasedOnIP</a> system preference. In the event of multiple libraries with matching IPs, branchcode (alphabetically) will be the tie breaker.'
101
            - 'Staff can only choose their library at login if they have the "loggedinlibrary" permission. This setting will override the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=StaffLoginLibraryBasedOnIP">StaffLoginLibraryBasedOnIP</a> system preference. In the event of multiple libraries with matching IPs, branchcode (alphabetically) will be the tie breaker.'
102
        -
102
        -
103
            - "Enable check for change in remote IP address for session security: "
103
            - "Enable check for change in remote IP address for session security: "
104
            - pref: SessionRestrictionByIP
104
            - pref: SessionRestrictionByIP
Lines 109-115 Administration: Link Here
109
            - (Disable only when remote IP address changes frequently.)
109
            - (Disable only when remote IP address changes frequently.)
110
        -
110
        -
111
            - "Set logged in library for staff by matching their current IP to the library configuration: "
111
            - "Set logged in library for staff by matching their current IP to the library configuration: "
112
            - pref: StaffLoginBranchBasedOnIP
112
            - pref: StaffLoginLibraryBasedOnIP
113
              default: 0
113
              default: 0
114
              choices:
114
              choices:
115
                  1: "Yes"
115
                  1: "Yes"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt (-1 / +1 lines)
Lines 158-164 Link Here
158
            [% IF Koha.Preference('ForceLibrarySelection') %]
158
            [% IF Koha.Preference('ForceLibrarySelection') %]
159
                <span class="required">Required</span>
159
                <span class="required">Required</span>
160
            [% END %]
160
            [% END %]
161
            [% IF Koha.Preference('StaffLoginBranchBasedOnIP')%]
161
            [% IF Koha.Preference('StaffLoginLibraryBasedOnIP')%]
162
                <span class="warning">Note: Your selection may be overridden if your current IP matches a specified IP for a branch in Koha</span>
162
                <span class="warning">Note: Your selection may be overridden if your current IP matches a specified IP for a branch in Koha</span>
163
            [% END %]
163
            [% END %]
164
        </p>
164
        </p>
(-)a/t/db_dependent/Auth.t (-6 / +5 lines)
Lines 1292-1305 subtest 'checkpw() return values tests' => sub { Link Here
1292
    };
1292
    };
1293
};
1293
};
1294
1294
1295
subtest 'StaffLoginBranchBasedOnIP' => sub {
1295
subtest 'StaffLoginLibraryBasedOnIP' => sub {
1296
1296
1297
    plan tests => 7;
1297
    plan tests => 7;
1298
1298
1299
    $schema->storage->txn_begin;
1299
    $schema->storage->txn_begin;
1300
1300
1301
    t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 0 );
1301
    t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 0 );
1302
    t::lib::Mocks::mock_preference( 'StaffLoginBranchBasedOnIP',     0 );
1302
    t::lib::Mocks::mock_preference( 'StaffLoginLibraryBasedOnIP',    0 );
1303
1303
1304
    my $patron   = $builder->build_object( { class => 'Koha::Patrons',   value => { flags    => 1 } } );
1304
    my $patron   = $builder->build_object( { class => 'Koha::Patrons',   value => { flags    => 1 } } );
1305
    my $branch   = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => "127.0.0.1" } } );
1305
    my $branch   = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => "127.0.0.1" } } );
Lines 1324-1343 subtest 'StaffLoginBranchBasedOnIP' => sub { Link Here
1324
    is( $session->param('branch'), $patron->branchcode, "Logged in branch is set to the patron's branchcode" );
1324
    is( $session->param('branch'), $patron->branchcode, "Logged in branch is set to the patron's branchcode" );
1325
1325
1326
    my $template;
1326
    my $template;
1327
    t::lib::Mocks::mock_preference( 'StaffLoginBranchBasedOnIP', 1 );
1327
    t::lib::Mocks::mock_preference( 'StaffLoginLibraryBasedOnIP', 1 );
1328
1328
1329
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' );
1329
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' );
1330
    is( $userid, $patron->userid, "User successfully logged in" );
1330
    is( $userid, $patron->userid, "User successfully logged in" );
1331
    $session = C4::Auth::get_session($sessionID);
1331
    $session = C4::Auth::get_session($sessionID);
1332
    is( $session->param('branch'), $branch->branchcode, "Logged in branch is set based on the IP from REMOTE_ADDR " );
1332
    is( $session->param('branch'), $branch->branchcode, "Logged in branch is set based on the IP from REMOTE_ADDR " );
1333
1333
1334
    # StaffLoginRestrictLibraryByIP overrides StaffLoginBranchBasedOnIP
1334
    # StaffLoginRestrictLibraryByIP overrides StaffLoginLibraryBasedOnIP
1335
    t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 1 );
1335
    t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 1 );
1336
    ( $userid, $cookie, $sessionID, $flags, $template ) =
1336
    ( $userid, $cookie, $sessionID, $flags, $template ) =
1337
        C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } );
1337
        C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } );
1338
    is(
1338
    is(
1339
        $template->{VARS}->{wrongip}, 1,
1339
        $template->{VARS}->{wrongip}, 1,
1340
        "StaffLoginRestrictLibraryByIP prevents StaffLoginBranchBasedOnIP from logging user in to another branch"
1340
        "StaffLoginRestrictLibraryByIP prevents StaffLoginLibraryBasedOnIP from logging user in to another branch"
1341
    );
1341
    );
1342
1342
1343
    t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 0 );
1343
    t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 0 );
1344
- 

Return to bug 26176