| 
      
            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 | 
              -   | 
               | 
               |