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

(-)a/C4/Auth.pm (-2 / +2 lines)
Lines 1570-1576 sub getuserflags { Link Here
1570
            $userflags->{$flag} = 0;
1570
            $userflags->{$flag} = 0;
1571
        }
1571
        }
1572
    }
1572
    }
1573
1574
    # get subpermissions and merge with top-level permissions
1573
    # get subpermissions and merge with top-level permissions
1575
    my $user_subperms = get_user_subpermissions($userid);
1574
    my $user_subperms = get_user_subpermissions($userid);
1576
    foreach my $module (keys %$user_subperms) {
1575
    foreach my $module (keys %$user_subperms) {
Lines 1666-1672 sub haspermission { Link Here
1666
    my ($userid, $flagsrequired) = @_;
1665
    my ($userid, $flagsrequired) = @_;
1667
    my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
1666
    my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
1668
    $sth->execute($userid);
1667
    $sth->execute($userid);
1669
    my $flags = getuserflags($sth->fetchrow(), $userid);
1668
    my $row = $sth->fetchrow();
1669
    my $flags = getuserflags($row, $userid);
1670
    if ( $userid eq C4::Context->config('user') ) {
1670
    if ( $userid eq C4::Context->config('user') ) {
1671
        # Super User Account from /etc/koha.conf
1671
        # Super User Account from /etc/koha.conf
1672
        $flags->{'superlibrarian'} = 1;
1672
        $flags->{'superlibrarian'} = 1;
(-)a/C4/Serials.pm (-66 / +50 lines)
Lines 20-25 package C4::Serials; Link Here
20
20
21
use strict;
21
use strict;
22
use warnings;
22
use warnings;
23
use C4::Context;
23
use C4::Dates qw(format_date format_date_in_iso);
24
use C4::Dates qw(format_date format_date_in_iso);
24
use Date::Calc qw(:all);
25
use Date::Calc qw(:all);
25
use POSIX qw(strftime);
26
use POSIX qw(strftime);
Lines 215-229 sub GetSerialInformation { Link Here
215
    my ($serialid) = @_;
216
    my ($serialid) = @_;
216
    my $dbh        = C4::Context->dbh;
217
    my $dbh        = C4::Context->dbh;
217
    my $query      = qq|
218
    my $query      = qq|
218
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |;
219
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid
219
    if (   C4::Context->preference('IndependentBranches')
220
        && C4::Context->userenv
221
        && C4::Context->userenv->{'flags'} != 1
222
        && C4::Context->userenv->{'branch'} ) {
223
        $query .= "
224
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
225
    }
226
    $query .= qq|             
227
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
220
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
228
        WHERE  serialid = ?
221
        WHERE  serialid = ?
229
    |;
222
    |;
Lines 262-267 sub GetSerialInformation { Link Here
262
    $data->{ "status" . $data->{'serstatus'} } = 1;
255
    $data->{ "status" . $data->{'serstatus'} } = 1;
263
    $data->{'subscriptionexpired'} = HasSubscriptionExpired( $data->{'subscriptionid'} ) && $data->{'status'} == 1;
256
    $data->{'subscriptionexpired'} = HasSubscriptionExpired( $data->{'subscriptionid'} ) && $data->{'status'} == 1;
264
    $data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} );
257
    $data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} );
258
    $data->{cannotedit} = not can_edit_subscription( $data );
265
    return $data;
259
    return $data;
266
}
260
}
267
261
Lines 320-334 sub GetSubscription { Link Here
320
                subscriptionhistory.*,
314
                subscriptionhistory.*,
321
                aqbooksellers.name AS aqbooksellername,
315
                aqbooksellers.name AS aqbooksellername,
322
                biblio.title AS bibliotitle,
316
                biblio.title AS bibliotitle,
323
                subscription.biblionumber as bibnum);
317
                subscription.biblionumber as bibnum
324
    if (   C4::Context->preference('IndependentBranches')
325
        && C4::Context->userenv
326
        && C4::Context->userenv->{'flags'} != 1
327
        && C4::Context->userenv->{'branch'} ) {
328
        $query .= "
329
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
330
    }
331
    $query .= qq(             
332
       FROM subscription
318
       FROM subscription
333
       LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
319
       LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
334
       LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
320
       LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
Lines 336-351 sub GetSubscription { Link Here
336
       WHERE subscription.subscriptionid = ?
322
       WHERE subscription.subscriptionid = ?
337
    );
323
    );
338
324
339
    #     if (C4::Context->preference('IndependentBranches') &&
340
    #         C4::Context->userenv &&
341
    #         C4::Context->userenv->{'flags'} != 1){
342
    # #       $debug and warn "flags: ".C4::Context->userenv->{'flags'};
343
    #       $query.=" AND subscription.branchcode IN ('".C4::Context->userenv->{'branch'}."',\"\")";
344
    #     }
345
    $debug and warn "query : $query\nsubsid :$subscriptionid";
325
    $debug and warn "query : $query\nsubsid :$subscriptionid";
346
    my $sth = $dbh->prepare($query);
326
    my $sth = $dbh->prepare($query);
347
    $sth->execute($subscriptionid);
327
    $sth->execute($subscriptionid);
348
    return $sth->fetchrow_hashref;
328
    my $subscription = $sth->fetchrow_hashref;
329
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
330
    return $subscription;
349
}
331
}
350
332
351
=head2 GetFullSubscription
333
=head2 GetFullSubscription
Lines 369-383 sub GetFullSubscription { Link Here
369
            aqbooksellers.name as aqbooksellername,
351
            aqbooksellers.name as aqbooksellername,
370
            biblio.title as bibliotitle,
352
            biblio.title as bibliotitle,
371
            subscription.branchcode AS branchcode,
353
            subscription.branchcode AS branchcode,
372
            subscription.subscriptionid AS subscriptionid |;
354
            subscription.subscriptionid AS subscriptionid
373
    if (   C4::Context->preference('IndependentBranches')
374
        && C4::Context->userenv
375
        && C4::Context->userenv->{'flags'} != 1
376
        && C4::Context->userenv->{'branch'} ) {
377
        $query .= "
378
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
379
    }
380
    $query .= qq|
381
  FROM      serial 
355
  FROM      serial 
382
  LEFT JOIN subscription ON 
356
  LEFT JOIN subscription ON 
383
          (serial.subscriptionid=subscription.subscriptionid )
357
          (serial.subscriptionid=subscription.subscriptionid )
Lines 391-397 sub GetFullSubscription { Link Here
391
    $debug and warn "GetFullSubscription query: $query";
365
    $debug and warn "GetFullSubscription query: $query";
392
    my $sth = $dbh->prepare($query);
366
    my $sth = $dbh->prepare($query);
393
    $sth->execute($subscriptionid);
367
    $sth->execute($subscriptionid);
394
    return $sth->fetchall_arrayref( {} );
368
    my $subscriptions = $sth->fetchall_arrayref( {} );
369
    for my $subscription ( @$subscriptions ) {
370
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
371
    }
372
    return $subscriptions;
395
}
373
}
396
374
397
=head2 PrepareSerialsData
375
=head2 PrepareSerialsData
Lines 486-498 sub GetSubscriptionsFromBiblionumber { Link Here
486
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
464
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
487
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
465
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
488
        $subs->{ "status" . $subs->{'status'} }             = 1;
466
        $subs->{ "status" . $subs->{'status'} }             = 1;
489
        $subs->{'cannotedit'} =
490
          (      C4::Context->preference('IndependentBranches')
491
              && C4::Context->userenv
492
              && C4::Context->userenv->{flags} % 2 != 1
493
              && C4::Context->userenv->{branch}
494
              && $subs->{branchcode}
495
              && ( C4::Context->userenv->{branch} ne $subs->{branchcode} ) );
496
467
497
        if ( $subs->{enddate} eq '0000-00-00' ) {
468
        if ( $subs->{enddate} eq '0000-00-00' ) {
498
            $subs->{enddate} = '';
469
            $subs->{enddate} = '';
Lines 501-506 sub GetSubscriptionsFromBiblionumber { Link Here
501
        }
472
        }
502
        $subs->{'abouttoexpire'}       = abouttoexpire( $subs->{'subscriptionid'} );
473
        $subs->{'abouttoexpire'}       = abouttoexpire( $subs->{'subscriptionid'} );
503
        $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
474
        $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
475
        $subs->{cannotedit} = not can_edit_subscription( $subs );
504
        push @res, $subs;
476
        push @res, $subs;
505
    }
477
    }
506
    return \@res;
478
    return \@res;
Lines 526-541 sub GetFullSubscriptionsFromBiblionumber { Link Here
526
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
498
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
527
            biblio.title as bibliotitle,
499
            biblio.title as bibliotitle,
528
            subscription.branchcode AS branchcode,
500
            subscription.branchcode AS branchcode,
529
            subscription.subscriptionid AS subscriptionid|;
501
            subscription.subscriptionid AS subscriptionid
530
    if (   C4::Context->preference('IndependentBranches')
531
        && C4::Context->userenv
532
        && C4::Context->userenv->{'flags'} != 1
533
        && C4::Context->userenv->{'branch'} ) {
534
        $query .= "
535
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
536
    }
537
538
    $query .= qq|      
539
  FROM      serial 
502
  FROM      serial 
540
  LEFT JOIN subscription ON 
503
  LEFT JOIN subscription ON 
541
          (serial.subscriptionid=subscription.subscriptionid)
504
          (serial.subscriptionid=subscription.subscriptionid)
Lines 548-554 sub GetFullSubscriptionsFromBiblionumber { Link Here
548
          |;
511
          |;
549
    my $sth = $dbh->prepare($query);
512
    my $sth = $dbh->prepare($query);
550
    $sth->execute($biblionumber);
513
    $sth->execute($biblionumber);
551
    return $sth->fetchall_arrayref( {} );
514
    my $subscriptions = $sth->fetchall_arrayref( {} );
515
    for my $subscription ( @$subscriptions ) {
516
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
517
    }
518
    return $subscriptions;
552
}
519
}
553
520
554
=head2 GetSubscriptions
521
=head2 GetSubscriptions
Lines 623-641 sub GetSubscriptions { Link Here
623
    $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params );
590
    $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params );
624
    $sth = $dbh->prepare($sql);
591
    $sth = $dbh->prepare($sql);
625
    $sth->execute(@bind_params);
592
    $sth->execute(@bind_params);
626
    my @results;
593
    my $subscriptions = $sth->fetchall_arrayref( {} );
627
594
    for my $subscription ( @$subscriptions ) {
628
    while ( my $line = $sth->fetchrow_hashref ) {
595
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
629
        $line->{'cannotedit'} =
596
    }
630
          (      C4::Context->preference('IndependentBranches')
597
    return @$subscriptions;
631
              && C4::Context->userenv
632
              && C4::Context->userenv->{flags} % 2 != 1
633
              && C4::Context->userenv->{branch}
634
              && $line->{branchcode}
635
              && ( C4::Context->userenv->{branch} ne $line->{branchcode} ) );
636
        push @results, $line;
637
    }
638
    return @results;
639
}
598
}
640
599
641
=head2 SearchSubscriptions
600
=head2 SearchSubscriptions
Lines 713-718 sub SearchSubscriptions { Link Here
713
    my $results = $sth->fetchall_arrayref( {} );
672
    my $results = $sth->fetchall_arrayref( {} );
714
    $sth->finish;
673
    $sth->finish;
715
674
675
    for my $subscription ( @$results ) {
676
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
677
        $subscription->{cannotdisplay} =
678
            ( C4::Context->preference("IndependentBranches")
679
                and $subscription->{branchcode} ne C4::Context->userenv->{'branch'} ) ? 1 : 0;
680
    }
681
716
    return @$results;
682
    return @$results;
717
}
683
}
718
684
Lines 2553-2558 sub subscriptionCurrentlyOnOrder { Link Here
2553
    return $sth->fetchrow_array;
2519
    return $sth->fetchrow_array;
2554
}
2520
}
2555
2521
2522
sub can_edit_subscription {
2523
    my ( $subscription, $userid ) = @_;
2524
    my $flags = C4::Context->userenv->{flags};
2525
    $userid ||= C4::Context->userenv->{'id'};
2526
    my $independent_branches = C4::Context->preference('IndependentBranches');
2527
    return 1 unless $independent_branches;
2528
    if( $flags % 2 == 1 # superlibrarian
2529
        or C4::Auth::haspermission( $userid, {serials => 'superserials'}),
2530
        or C4::Auth::haspermission( $userid, {serials => 'edit_subscription'}),
2531
        or not defined $subscription->{branchcode}
2532
        or $subscription->{branchcode} eq ''
2533
        or $subscription->{branchcode} eq C4::Context->userenv->{'branch'}
2534
    ) {
2535
        return 1;
2536
    }
2537
     return 0;
2538
}
2539
2556
1;
2540
1;
2557
__END__
2541
__END__
2558
2542
(-)a/installer/data/mysql/de-DE/mandatory/userpermissions.sql (+1 lines)
Lines 51-56 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   (15, 'receive_serials', 'Zugang von Heften'),
51
   (15, 'receive_serials', 'Zugang von Heften'),
52
   (15, 'renew_subscription', 'Abonnements verlängern'),
52
   (15, 'renew_subscription', 'Abonnements verlängern'),
53
   (15, 'routing', 'Umlauflisten verwalten'),
53
   (15, 'routing', 'Umlauflisten verwalten'),
54
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
54
   (16, 'execute_reports', 'SQL-Reports ausführen'),
55
   (16, 'execute_reports', 'SQL-Reports ausführen'),
55
   (16, 'create_reports', 'SQL-Reports erstellen'),
56
   (16, 'create_reports', 'SQL-Reports erstellen'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+1 lines)
Lines 51-56 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   (15, 'receive_serials', 'Serials receiving'),
51
   (15, 'receive_serials', 'Serials receiving'),
52
   (15, 'renew_subscription', 'Renew a subscription'),
52
   (15, 'renew_subscription', 'Renew a subscription'),
53
   (15, 'routing', 'Routing'),
53
   (15, 'routing', 'Routing'),
54
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
54
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'create_reports', 'Create SQL Reports'),
56
   (16, 'create_reports', 'Create SQL Reports'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/es-ES/mandatory/userpermissions.sql (+1 lines)
Lines 51-56 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   (15, 'receive_serials', 'Serials receiving'),
51
   (15, 'receive_serials', 'Serials receiving'),
52
   (15, 'renew_subscription', 'Renew a subscription'),
52
   (15, 'renew_subscription', 'Renew a subscription'),
53
   (15, 'routing', 'Routing'),
53
   (15, 'routing', 'Routing'),
54
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
54
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'create_reports', 'Create SQL Reports'),
56
   (16, 'create_reports', 'Create SQL Reports'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql (+1 lines)
Lines 51-56 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   (15, 'receive_serials', 'Bulletiner les périodiques'),
51
   (15, 'receive_serials', 'Bulletiner les périodiques'),
52
   (15, 'renew_subscription', 'Renouveler les abonnements'),
52
   (15, 'renew_subscription', 'Renouveler les abonnements'),
53
   (15, 'routing', 'Mettre en circulation'),
53
   (15, 'routing', 'Mettre en circulation'),
54
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
54
   (16, 'execute_reports', 'Lancer les rapports SQL'),
55
   (16, 'execute_reports', 'Lancer les rapports SQL'),
55
   (16, 'create_reports', 'Créer les rapports SQL Reports'),
56
   (16, 'create_reports', 'Créer les rapports SQL Reports'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/it-IT/necessari/userpermissions.sql (+1 lines)
Lines 53-58 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
53
   (15, 'receive_serials', 'Ricevi fascicoli'),
53
   (15, 'receive_serials', 'Ricevi fascicoli'),
54
   (15, 'renew_subscription', 'Rinnova un abbonamento'),
54
   (15, 'renew_subscription', 'Rinnova un abbonamento'),
55
   (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'),
55
   (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'),
56
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
56
   (16, 'execute_reports', 'Esegui reports SQL'),
57
   (16, 'execute_reports', 'Esegui reports SQL'),
57
   (16, 'create_reports', 'Crea reports SQL'),
58
   (16, 'create_reports', 'Crea reports SQL'),
58
   (18, 'manage_courses', 'Add, edit and delete courses'),
59
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql (+1 lines)
Lines 71-76 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
71
   (15, 'receive_serials', 'Heftemottak'),
71
   (15, 'receive_serials', 'Heftemottak'),
72
   (15, 'renew_subscription', 'Fornye abonnementer'),
72
   (15, 'renew_subscription', 'Fornye abonnementer'),
73
   (15, 'routing', 'Sirkulasjon'),
73
   (15, 'routing', 'Sirkulasjon'),
74
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
74
   (16, 'execute_reports', 'Kjøre SQL-rapporter'),
75
   (16, 'execute_reports', 'Kjøre SQL-rapporter'),
75
   (16, 'create_reports', 'Opprette SQL-rapporter'),
76
   (16, 'create_reports', 'Opprette SQL-rapporter'),
76
   (18, 'manage_courses', 'Add, edit and delete courses'),
77
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql (+1 lines)
Lines 52-57 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
52
   (15, 'receive_serials', 'Serials receiving'),
52
   (15, 'receive_serials', 'Serials receiving'),
53
   (15, 'renew_subscription', 'Renew a subscription'),
53
   (15, 'renew_subscription', 'Renew a subscription'),
54
   (15, 'routing', 'Routing'),
54
   (15, 'routing', 'Routing'),
55
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
55
   (16, 'execute_reports', 'Execute SQL reports'),
56
   (16, 'execute_reports', 'Execute SQL reports'),
56
   (16, 'create_reports', 'Create SQL Reports'),
57
   (16, 'create_reports', 'Create SQL Reports'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
58
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql (+1 lines)
Lines 77-82 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
77
   (15, 'receive_serials',             'Serials receiving'),
77
   (15, 'receive_serials',             'Serials receiving'),
78
   (15, 'renew_subscription',          'Renew a subscription'),
78
   (15, 'renew_subscription',          'Renew a subscription'),
79
   (15, 'routing',                     'Routing'),
79
   (15, 'routing',                     'Routing'),
80
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
80
   (16, 'execute_reports', 'Execute SQL reports'),
81
   (16, 'execute_reports', 'Execute SQL reports'),
81
   (16, 'create_reports', 'Create SQL Reports'),
82
   (16, 'create_reports', 'Create SQL Reports'),
82
   (18, 'manage_courses', 'Add, edit and delete courses'),
83
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql (+1 lines)
Lines 77-82 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
77
   (15, 'receive_serials',             'Serials receiving'),
77
   (15, 'receive_serials',             'Serials receiving'),
78
   (15, 'renew_subscription',          'Renew a subscription'),
78
   (15, 'renew_subscription',          'Renew a subscription'),
79
   (15, 'routing',                     'Routing'),
79
   (15, 'routing',                     'Routing'),
80
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
80
   (16, 'execute_reports', 'Execute SQL reports'),
81
   (16, 'execute_reports', 'Execute SQL reports'),
81
   (16, 'create_reports', 'Create SQL Reports'),
82
   (16, 'create_reports', 'Create SQL Reports'),
82
   (18, 'manage_courses', 'Add, edit and delete courses'),
83
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 7139-7144 if ( CheckVersion($DBversion) ) { Link Here
7139
    SetVersion ($DBversion);
7139
    SetVersion ($DBversion);
7140
}
7140
}
7141
7141
7142
7143
$DBversion = "3.13.00.XXX";
7144
if ( CheckVersion($DBversion) ) {
7145
    $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependentBranches is used)')");
7146
    print "Upgrade to $DBversion done (Bug 8435: Add superserials permission)\n";
7147
    SetVersion($DBversion);
7148
}
7149
7142
=head1 FUNCTIONS
7150
=head1 FUNCTIONS
7143
7151
7144
=head2 TableExists($table)
7152
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (-4 / +6 lines)
Lines 141-146 Link Here
141
                  </tfoot>
141
                  </tfoot>
142
                  <tbody>
142
                  <tbody>
143
                    [% FOREACH subscription IN openedsubscriptions %]
143
                    [% FOREACH subscription IN openedsubscriptions %]
144
                    [% UNLESS subscription.cannotdisplay %]
144
                      <tr>
145
                      <tr>
145
                        <td>
146
                        <td>
146
                        [% IF ( subscription.issn ) %][% subscription.issn %]
147
                        [% IF ( subscription.issn ) %][% subscription.issn %]
Lines 177-189 Link Here
177
                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
178
                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
178
                        </td>
179
                        </td>
179
                        <td>
180
                        <td>
180
                        [% IF ( subscription.cannotedit ) %]
181
                        [% IF ( CAN_user_serials_receive_serials ) %]
181
                          &nbsp;
182
                          <a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&amp;serstatus=1,3,7">Serial receive</a>
182
                        [% ELSE %]
183
                          [% IF ( CAN_user_serials_receive_serials ) %]<a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&amp;serstatus=1,3,7">Serial receive</a>[% END %]
184
                        [% END %]
183
                        [% END %]
185
                        </td>
184
                        </td>
186
                      </tr>
185
                      </tr>
186
                      [% END %]
187
                    [% END %]
187
                    [% END %]
188
                  </tbody>
188
                  </tbody>
189
                </table>
189
                </table>
Lines 220-225 Link Here
220
                  </tfoot>
220
                  </tfoot>
221
                  <tbody>
221
                  <tbody>
222
                    [% FOREACH subscription IN closedsubscriptions %]
222
                    [% FOREACH subscription IN closedsubscriptions %]
223
                    [% UNLESS subscription.cannotdisplay %]
223
                      <tr>
224
                      <tr>
224
                        <td>
225
                        <td>
225
                          [% IF ( subscription.issn ) %]
226
                          [% IF ( subscription.issn ) %]
Lines 251-256 Link Here
251
                        </td>
252
                        </td>
252
                      </tr>
253
                      </tr>
253
                    [% END %]
254
                    [% END %]
255
                    [% END %]
254
                  </tbody>
256
                  </tbody>
255
                </table>
257
                </table>
256
              [% ELSE %]
258
              [% ELSE %]
(-)a/serials/serials-collection.pl (-2 / +2 lines)
Lines 37-44 my $op = $query->param('op') || q{}; Link Here
37
my $nbissues=$query->param('nbissues');
37
my $nbissues=$query->param('nbissues');
38
my $dbh = C4::Context->dbh;
38
my $dbh = C4::Context->dbh;
39
39
40
my ($template, $loggedinuser, $cookie);
40
my ($template, $loggedinuser, $cookie)
41
($template, $loggedinuser, $cookie)
42
  = get_template_and_user({template_name => "serials/serials-collection.tmpl",
41
  = get_template_and_user({template_name => "serials/serials-collection.tmpl",
43
                            query => $query,
42
                            query => $query,
44
                            type => "intranet",
43
                            type => "intranet",
Lines 105-110 if (@subscriptionid){ Link Here
105
   foreach my $subscriptionid (@subscriptionid){
104
   foreach my $subscriptionid (@subscriptionid){
106
    my $subs= GetSubscription($subscriptionid);
105
    my $subs= GetSubscription($subscriptionid);
107
    $closed = 1 if $subs->{closed};
106
    $closed = 1 if $subs->{closed};
107
108
    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
108
    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
109
    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
109
    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
110
    $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
110
    $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
(-)a/serials/serials-edit.pl (+1 lines)
Lines 134-139 foreach my $serialid (@serialids) { Link Here
134
        && !$processedserialid{$serialid} )
134
        && !$processedserialid{$serialid} )
135
    {
135
    {
136
        my $serinfo = GetSerialInformation($serialid); #TODO duplicates work done by GetSerials2 above
136
        my $serinfo = GetSerialInformation($serialid); #TODO duplicates work done by GetSerials2 above
137
137
        for my $d ( qw( publisheddate planneddate )){
138
        for my $d ( qw( publisheddate planneddate )){
138
            if ( $serinfo->{$d} =~m/^00/ ) {
139
            if ( $serinfo->{$d} =~m/^00/ ) {
139
                $serinfo->{$d} = q{};
140
                $serinfo->{$d} = q{};
(-)a/serials/serials-search.pl (-2 / +4 lines)
Lines 96-104 if ($routing) { Link Here
96
my (@openedsubscriptions, @closedsubscriptions);
96
my (@openedsubscriptions, @closedsubscriptions);
97
for my $sub ( @subscriptions ) {
97
for my $sub ( @subscriptions ) {
98
    unless ( $sub->{closed} ) {
98
    unless ( $sub->{closed} ) {
99
        push @openedsubscriptions, $sub;
99
        push @openedsubscriptions, $sub
100
            unless $sub->{cannotdisplay};
100
    } else {
101
    } else {
101
        push @closedsubscriptions, $sub;
102
        push @closedsubscriptions, $sub
103
            unless $sub->{cannotdisplay};
102
    }
104
    }
103
}
105
}
104
106
(-)a/serials/subscription-add.pl (-5 / +12 lines)
Lines 69-75 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
69
69
70
    my $subscriptionid = $query->param('subscriptionid');
70
    my $subscriptionid = $query->param('subscriptionid');
71
    $subs = GetSubscription($subscriptionid);
71
    $subs = GetSubscription($subscriptionid);
72
## FIXME : Check rights to edit if mod. Could/Should display an error message.
72
73
    ## FIXME : Check rights to edit if mod. Could/Should display an error message.
73
    if ($subs->{'cannotedit'} && $op eq 'modify'){
74
    if ($subs->{'cannotedit'} && $op eq 'modify'){
74
      carp "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
75
      carp "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
75
      print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
76
      print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
Lines 120-129 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
120
    }
121
    }
121
}
122
}
122
123
123
my $onlymine=C4::Context->preference('IndependentBranches') &&
124
my $userenv = C4::Context->userenv;
124
             C4::Context->userenv &&
125
my $onlymine =
125
             C4::Context->userenv->{flags} % 2 !=1 &&
126
     C4::Context->preference('IndependentBranches')
126
             C4::Context->userenv->{branch};
127
  && $userenv
128
  && $userenv->{flags} % 2 != 1
129
  && (
130
    not C4::Auth::haspermission( $userenv->{id}, { serials => 'superserials' } )
131
  )
132
  && $userenv->{branch};
133
127
my $branches = GetBranches($onlymine);
134
my $branches = GetBranches($onlymine);
128
my $branchloop;
135
my $branchloop;
129
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
136
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
(-)a/serials/subscription-detail.pl (-26 / +8 lines)
Lines 34-40 my $query = new CGI; Link Here
34
my $op = $query->param('op') || q{};
34
my $op = $query->param('op') || q{};
35
my $issueconfirmed = $query->param('issueconfirmed');
35
my $issueconfirmed = $query->param('issueconfirmed');
36
my $dbh = C4::Context->dbh;
36
my $dbh = C4::Context->dbh;
37
my ($template, $loggedinuser, $cookie, $hemisphere);
38
my $subscriptionid = $query->param('subscriptionid');
37
my $subscriptionid = $query->param('subscriptionid');
39
38
40
if ( $op and $op eq "close" ) {
39
if ( $op and $op eq "close" ) {
Lines 43-71 if ( $op and $op eq "close" ) { Link Here
43
    C4::Serials::ReopenSubscription( $subscriptionid );
42
    C4::Serials::ReopenSubscription( $subscriptionid );
44
}
43
}
45
44
46
my $subs = GetSubscription($subscriptionid);
47
48
$subs->{enddate} = GetExpirationDate($subscriptionid);
49
50
if ($op && $op eq 'del') {
51
	if ($subs->{'cannotedit'}){
52
		carp "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
53
		print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
54
	}
55
	DelSubscription($subscriptionid);
56
	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=serials-home.pl\"></html>";
57
	exit;
58
}
59
60
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
61
$totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue)
62
# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
45
# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
63
46
64
# Permission needed if it is a deletion (del) : delete_subscription
47
# Permission needed if it is a deletion (del) : delete_subscription
65
# Permission needed otherwise : *
48
# Permission needed otherwise : *
66
my $permission = ($op eq "del") ? "delete_subscription" : "*";
49
my $permission = ($op eq "del") ? "delete_subscription" : "*";
67
50
68
($template, $loggedinuser, $cookie)
51
my ($template, $loggedinuser, $cookie)
69
= get_template_and_user({template_name => "serials/subscription-detail.tmpl",
52
= get_template_and_user({template_name => "serials/subscription-detail.tmpl",
70
                query => $query,
53
                query => $query,
71
                type => "intranet",
54
                type => "intranet",
Lines 74-80 my $permission = ($op eq "del") ? "delete_subscription" : "*"; Link Here
74
                debug => 1,
57
                debug => 1,
75
                });
58
                });
76
59
77
$$subs{enddate} ||= GetExpirationDate($subscriptionid);
60
61
my $subs = GetSubscription($subscriptionid);
62
$subs->{enddate} ||= GetExpirationDate($subscriptionid);
63
64
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
65
$totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue)
78
66
79
if ($op eq 'del') {
67
if ($op eq 'del') {
80
	if ($$subs{'cannotedit'}){
68
	if ($$subs{'cannotedit'}){
Lines 161-172 $template->param( Link Here
161
    hasRouting  => $hasRouting,
149
    hasRouting  => $hasRouting,
162
    routing => C4::Context->preference("RoutingSerials"),
150
    routing => C4::Context->preference("RoutingSerials"),
163
    totalissues => $totalissues,
151
    totalissues => $totalissues,
164
    hemisphere => $hemisphere,
152
    cannotedit => (not C4::Serials::can_edit_subscription( $subs )),
165
    cannotedit =>(C4::Context->preference('IndependentBranches') &&
166
                C4::Context->userenv &&
167
                C4::Context->userenv->{flags} % 2 !=1  &&
168
                C4::Context->userenv->{branch} && $subs->{branchcode} &&
169
                (C4::Context->userenv->{branch} ne $subs->{branchcode})),
170
    'periodicity' . $subs->{periodicity} => 1,
153
    'periodicity' . $subs->{periodicity} => 1,
171
    'arrival' . $subs->{dow} => 1,
154
    'arrival' . $subs->{dow} => 1,
172
    'numberpattern' . $subs->{numberpattern} => 1,
155
    'numberpattern' . $subs->{numberpattern} => 1,
173
- 

Return to bug 8435