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

(-)a/installer/data/mysql/atomicupdate/bug_32682_add_permission.pl (+41 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "32682",
6
    description => "Add permission for viewing patron reading history",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        $dbh->do(
12
            q{
13
            INSERT IGNORE permissions (module_bit, code, description) VALUES
14
            (4, 'view_checkout_history', 'Viewing checkout history')
15
        }
16
        );
17
18
        say $out "Added new permission 'view_checkout_history'";
19
20
        my $IntranetBrowsingHistory = C4::Context->preference('intranetreadinghistory');
21
        if ($IntranetBrowsingHistory) {
22
23
            my $insert_sth = $dbh->prepare(
24
                "INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) VALUES (?, ?, ?)");
25
26
            my $sth = $dbh->prepare("SELECT borrowernumber FROM user_permissions WHERE code = 'edit_borrowers'");
27
            $sth->execute();
28
29
            my @borrowernumbers;
30
            while ( my ($borrowernumber) = $sth->fetchrow_array() ) {
31
                push @borrowernumbers, $borrowernumber;
32
            }
33
34
            my @rows_to_insert = ( map { [ $_, 4, "view_checkout_history" ] } @borrowernumbers );
35
            foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); }
36
37
            say_success( $out, "view_checkout_history added to all borrowers with edit_borrowers" );
38
        }
39
40
    },
41
};
(-)a/installer/data/mysql/mandatory/userpermissions.sql (-1 / +1 lines)
Lines 51-56 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   ( 4, 'list_borrowers', 'Search, list and view patrons'),
51
   ( 4, 'list_borrowers', 'Search, list and view patrons'),
52
   ( 4, 'send_messages_to_borrowers', 'Send messages to patrons'),
52
   ( 4, 'send_messages_to_borrowers', 'Send messages to patrons'),
53
   ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
53
   ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
54
   ( 4, 'view_checkout_history', 'Viewing checkout history'),
54
   ( 6, 'place_holds', 'Place holds for patrons'),
55
   ( 6, 'place_holds', 'Place holds for patrons'),
55
   ( 6, 'modify_holds_priority', 'Modify holds priority'),
56
   ( 6, 'modify_holds_priority', 'Modify holds priority'),
56
   ( 6, 'alter_hold_targets', 'Move holds between items and records'),
57
   ( 6, 'alter_hold_targets', 'Move holds between items and records'),
57
- 

Return to bug 32682