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

(-)a/installer/data/mysql/atomicupdate/bug_34631.pl (+18 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "34631",
6
    description => "Add new system preference IndependentBranchesAdditionalcontents",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        # Do you stuffs here
12
        $dbh->do(
13
            q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('IndependentBranchesAdditionalcontents','0',NULL,'Prevent staff (but not superlibrarians) from editing Additional contents in other libraries', 'YesNo')}
14
        );
15
16
        say $out "Added system preference 'IndependentBranchesAdditionalcontents'";
17
    },
18
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 336-341 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
336
('IncludeSeeAlsoFromInSearches','0','','Include see-also-from references in searches.','YesNo'),
336
('IncludeSeeAlsoFromInSearches','0','','Include see-also-from references in searches.','YesNo'),
337
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
337
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
338
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
338
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
339
('IndependentBranchesAdditionalcontents','0', NULL, 'Prevent staff (but not superlibrarians) from editing Additional contents in other libraries','YesNo'),
339
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
340
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
340
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
341
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
341
('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'),
342
('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+7 lines)
Lines 148-153 Administration: Link Here
148
              choices:
148
              choices:
149
                  1: "Yes"
149
                  1: "Yes"
150
                  0: "No"
150
                  0: "No"
151
        -
152
            - "Prevent staff (but not superlibrarians) from editing Additional contents in other libraries: "
153
            - pref: IndependentBranchesAdditionalcontents
154
              default: 0
155
              choices:
156
                  1: "Yes"
157
                  0: "No"
151
        -
158
        -
152
            - pref: ForceLibrarySelection
159
            - pref: ForceLibrarySelection
153
              choices:
160
              choices:
(-)a/tools/additional-contents.pl (-24 / +38 lines)
Lines 64-76 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
64
64
65
my @messages;
65
my @messages;
66
my $my_branch_as_staff =
66
my $my_branch_as_staff =
67
    C4::Context->preference("IndependentBranches")
67
    C4::Context->preference("IndependentBranchesAdditionalcontents")
68
    && !C4::Context->IsSuperLibrarian()
68
    && !C4::Context->IsSuperLibrarian()
69
    ? C4::Context->userenv()->{'branch'}
69
    ? C4::Context->userenv()->{'branch'}
70
    : undef;
70
    : undef;
71
if ( $op eq 'add_form' ) {
71
if ( $op eq 'add_form' ) {
72
72
73
    my $additional_content = Koha::AdditionalContents->find($id);
73
    my $additional_content = Koha::AdditionalContents->find($id);
74
    $additional_content =
75
           undef $my_branch_as_staff
76
        && $additional_content
77
        && C4::Context->userenv()->{'branch'} ne $additional_content->branchcode;
74
    my $translated_contents;
78
    my $translated_contents;
75
    if ($additional_content) {
79
    if ($additional_content) {
76
        $translated_contents = { map { $_->lang => $_ } $additional_content->translated_contents->as_list };
80
        $translated_contents = { map { $_->lang => $_ } $additional_content->translated_contents->as_list };
Lines 198-229 if ( $op eq 'add_form' ) { Link Here
198
    output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } );
202
    output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } );
199
    my @ids = $cgi->multi_param('ids');
203
    my @ids = $cgi->multi_param('ids');
200
204
201
    try {
205
    if ($my_branch_as_staff) {
202
        Koha::Database->new->schema->txn_do(
206
        @ids = grep {
203
            sub {
207
            my $id                 = $_;
204
                my $contents = Koha::AdditionalContents->search( { id => \@ids } );
208
            my $additional_content = Koha::AdditionalContents->find($id);
209
            defined $additional_content->branchcode
210
                && $additional_content->branchcode eq C4::Context->userenv()->{'branch'};
211
        } @ids;
212
    }
213
    if (@ids) {
214
        try {
215
            Koha::Database->new->schema->txn_do(
216
                sub {
217
                    my $contents = Koha::AdditionalContents->search( { id => \@ids } );
205
218
206
                if ( C4::Context->preference("NewsLog") ) {
219
                    if ( C4::Context->preference("NewsLog") ) {
207
                    while ( my $c = $contents->next ) {
220
                        while ( my $c = $contents->next ) {
208
                        my $translated_contents = $c->translated_contents;
221
                            my $translated_contents = $c->translated_contents;
209
                        while ( my $translated_content = $translated_contents->next ) {
222
                            while ( my $translated_content = $translated_contents->next ) {
210
                            logaction(
223
                                logaction(
211
                                'NEWS', 'DELETE', undef,
224
                                    'NEWS', 'DELETE', undef,
212
                                sprintf(
225
                                    sprintf(
213
                                    "%s|%s|%s|%s", $c->code, $translated_content->lang, $translated_content->content
226
                                        "%s|%s|%s|%s", $c->code, $translated_content->lang,
214
                                )
227
                                        $translated_content->content
215
                            );
228
                                    )
229
                                );
230
                            }
216
                        }
231
                        }
217
                    }
232
                    }
233
                    $contents->delete;
218
                }
234
                }
219
                $contents->delete;
235
            );
220
            }
236
            push @messages, { type => 'message', code => 'success_on_delete' };
221
        );
237
        } catch {
222
        push @messages, { type => 'message', code => 'success_on_delete' };
238
            warn $_;
223
    } catch {
239
            push @messages, { type => 'error', code => 'error_on_delete' };
224
        warn $_;
240
        };
225
        push @messages, { type => 'error', code => 'error_on_delete' };
241
    }
226
    };
227
242
228
    $op = 'list';
243
    $op = 'list';
229
}
244
}
230
- 

Return to bug 34631