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

(-)a/installer/data/mysql/atomicupdate/bug_32682_add_permission.pl (-13 / +18 lines)
Lines 15-35 return { Link Here
15
        }
15
        }
16
        );
16
        );
17
17
18
        # permissions
19
        say $out "Added new permission 'view_checkout_history'";
18
        say $out "Added new permission 'view_checkout_history'";
20
19
21
        # $dbh->do(
20
        my $IntranetBrowsingHistory = C4::Context->preference('intranetreadinghistory');
22
        #     q{
21
        if ($IntranetBrowsingHistory) {
23
        #     INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code)
24
        #     SELECT borrowernumber, 10, 'view_checkout_history' FROM user_permissions WHERE code = 'remaining_permissions'
25
        # }
26
        # );
27
22
28
        # TODO: migrate libraries' "intranetreadinghistory" syspref (will this require us to not fully remove it until we're sure everyone has migrated off of it?)
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
        }
29
39
30
        # Other information
31
        say_success( $out, "Use green for success" );
32
        say_warning( $out, "Use yellow for warning/a call to action" );
33
        say_info( $out, "Use blue for further information" );
34
    },
40
    },
35
};
41
};
36
- 

Return to bug 32682