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 200-231
if ( $op eq 'add_form' ) {
Link Here
|
200 |
output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } ); |
204 |
output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } ); |
201 |
my @ids = $cgi->multi_param('ids'); |
205 |
my @ids = $cgi->multi_param('ids'); |
202 |
|
206 |
|
203 |
try { |
207 |
if ($my_branch_as_staff) { |
204 |
Koha::Database->new->schema->txn_do( |
208 |
@ids = grep { |
205 |
sub { |
209 |
my $id = $_; |
206 |
my $contents = Koha::AdditionalContents->search( { id => \@ids } ); |
210 |
my $additional_content = Koha::AdditionalContents->find($id); |
|
|
211 |
defined $additional_content->branchcode |
212 |
&& $additional_content->branchcode eq C4::Context->userenv()->{'branch'}; |
213 |
} @ids; |
214 |
} |
215 |
if (@ids) { |
216 |
try { |
217 |
Koha::Database->new->schema->txn_do( |
218 |
sub { |
219 |
my $contents = Koha::AdditionalContents->search( { id => \@ids } ); |
207 |
|
220 |
|
208 |
if ( C4::Context->preference("AdditionalContentLog") ) { |
221 |
if ( C4::Context->preference("AdditionalContentLog") ) { |
209 |
while ( my $c = $contents->next ) { |
222 |
while ( my $c = $contents->next ) { |
210 |
my $translated_contents = $c->translated_contents; |
223 |
my $translated_contents = $c->translated_contents; |
211 |
while ( my $translated_content = $translated_contents->next ) { |
224 |
while ( my $translated_content = $translated_contents->next ) { |
212 |
logaction( |
225 |
logaction( |
213 |
'NEWS', 'DELETE', undef, |
226 |
'NEWS', 'DELETE', undef, |
214 |
sprintf( |
227 |
sprintf( |
215 |
"%s|%s|%s|%s", $c->code, $translated_content->lang, $translated_content->content |
228 |
"%s|%s|%s|%s", $c->code, $translated_content->lang, |
216 |
) |
229 |
$translated_content->content |
217 |
); |
230 |
) |
|
|
231 |
); |
232 |
} |
218 |
} |
233 |
} |
219 |
} |
234 |
} |
|
|
235 |
$contents->delete; |
220 |
} |
236 |
} |
221 |
$contents->delete; |
237 |
); |
222 |
} |
238 |
push @messages, { type => 'message', code => 'success_on_delete' }; |
223 |
); |
239 |
} catch { |
224 |
push @messages, { type => 'message', code => 'success_on_delete' }; |
240 |
warn $_; |
225 |
} catch { |
241 |
push @messages, { type => 'error', code => 'error_on_delete' }; |
226 |
warn $_; |
242 |
}; |
227 |
push @messages, { type => 'error', code => 'error_on_delete' }; |
243 |
} |
228 |
}; |
|
|
229 |
|
244 |
|
230 |
$op = 'list'; |
245 |
$op = 'list'; |
231 |
} |
246 |
} |
232 |
- |
|
|