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

(-)a/C4/Auth.pm (-2 / +2 lines)
Lines 1615-1621 sub getuserflags { Link Here
1615
            $userflags->{$flag} = 0;
1615
            $userflags->{$flag} = 0;
1616
        }
1616
        }
1617
    }
1617
    }
1618
1619
    # get subpermissions and merge with top-level permissions
1618
    # get subpermissions and merge with top-level permissions
1620
    my $user_subperms = get_user_subpermissions($userid);
1619
    my $user_subperms = get_user_subpermissions($userid);
1621
    foreach my $module (keys %$user_subperms) {
1620
    foreach my $module (keys %$user_subperms) {
Lines 1711-1717 sub haspermission { Link Here
1711
    my ($userid, $flagsrequired) = @_;
1710
    my ($userid, $flagsrequired) = @_;
1712
    my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
1711
    my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
1713
    $sth->execute($userid);
1712
    $sth->execute($userid);
1714
    my $flags = getuserflags($sth->fetchrow(), $userid);
1713
    my $row = $sth->fetchrow();
1714
    my $flags = getuserflags($row, $userid);
1715
    if ( $userid eq C4::Context->config('user') ) {
1715
    if ( $userid eq C4::Context->config('user') ) {
1716
        # Super User Account from /etc/koha.conf
1716
        # Super User Account from /etc/koha.conf
1717
        $flags->{'superlibrarian'} = 1;
1717
        $flags->{'superlibrarian'} = 1;
(-)a/C4/Serials.pm (-66 / +50 lines)
Lines 20-25 package C4::Serials; Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
22
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 setlocale LC_TIME);
26
use POSIX qw(strftime setlocale LC_TIME);
Lines 228-242 sub GetSerialInformation { Link Here
228
    my ($serialid) = @_;
229
    my ($serialid) = @_;
229
    my $dbh        = C4::Context->dbh;
230
    my $dbh        = C4::Context->dbh;
230
    my $query      = qq|
231
    my $query      = qq|
231
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |;
232
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid
232
    if (   C4::Context->preference('IndependentBranches')
233
        && C4::Context->userenv
234
        && C4::Context->userenv->{'flags'} != 1
235
        && C4::Context->userenv->{'branch'} ) {
236
        $query .= "
237
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
238
    }
239
    $query .= qq|             
240
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
233
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
241
        WHERE  serialid = ?
234
        WHERE  serialid = ?
242
    |;
235
    |;
Lines 275-280 sub GetSerialInformation { Link Here
275
    $data->{ "status" . $data->{'serstatus'} } = 1;
268
    $data->{ "status" . $data->{'serstatus'} } = 1;
276
    $data->{'subscriptionexpired'} = HasSubscriptionExpired( $data->{'subscriptionid'} ) && $data->{'status'} == 1;
269
    $data->{'subscriptionexpired'} = HasSubscriptionExpired( $data->{'subscriptionid'} ) && $data->{'status'} == 1;
277
    $data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} );
270
    $data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} );
271
    $data->{cannotedit} = not can_edit_subscription( $data );
278
    return $data;
272
    return $data;
279
}
273
}
280
274
Lines 339-353 sub GetSubscription { Link Here
339
                subscriptionhistory.*,
333
                subscriptionhistory.*,
340
                aqbooksellers.name AS aqbooksellername,
334
                aqbooksellers.name AS aqbooksellername,
341
                biblio.title AS bibliotitle,
335
                biblio.title AS bibliotitle,
342
                subscription.biblionumber as bibnum);
336
                subscription.biblionumber as bibnum
343
    if (   C4::Context->preference('IndependentBranches')
344
        && C4::Context->userenv
345
        && C4::Context->userenv->{'flags'} != 1
346
        && C4::Context->userenv->{'branch'} ) {
347
        $query .= "
348
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
349
    }
350
    $query .= qq(             
351
       FROM subscription
337
       FROM subscription
352
       LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
338
       LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
353
       LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
339
       LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
Lines 355-370 sub GetSubscription { Link Here
355
       WHERE subscription.subscriptionid = ?
341
       WHERE subscription.subscriptionid = ?
356
    );
342
    );
357
343
358
    #     if (C4::Context->preference('IndependentBranches') &&
359
    #         C4::Context->userenv &&
360
    #         C4::Context->userenv->{'flags'} != 1){
361
    # #       $debug and warn "flags: ".C4::Context->userenv->{'flags'};
362
    #       $query.=" AND subscription.branchcode IN ('".C4::Context->userenv->{'branch'}."',\"\")";
363
    #     }
364
    $debug and warn "query : $query\nsubsid :$subscriptionid";
344
    $debug and warn "query : $query\nsubsid :$subscriptionid";
365
    my $sth = $dbh->prepare($query);
345
    my $sth = $dbh->prepare($query);
366
    $sth->execute($subscriptionid);
346
    $sth->execute($subscriptionid);
367
    return $sth->fetchrow_hashref;
347
    my $subscription = $sth->fetchrow_hashref;
348
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
349
    return $subscription;
368
}
350
}
369
351
370
=head2 GetFullSubscription
352
=head2 GetFullSubscription
Lines 391-405 sub GetFullSubscription { Link Here
391
            aqbooksellers.name as aqbooksellername,
373
            aqbooksellers.name as aqbooksellername,
392
            biblio.title as bibliotitle,
374
            biblio.title as bibliotitle,
393
            subscription.branchcode AS branchcode,
375
            subscription.branchcode AS branchcode,
394
            subscription.subscriptionid AS subscriptionid |;
376
            subscription.subscriptionid AS subscriptionid
395
    if (   C4::Context->preference('IndependentBranches')
396
        && C4::Context->userenv
397
        && C4::Context->userenv->{'flags'} != 1
398
        && C4::Context->userenv->{'branch'} ) {
399
        $query .= "
400
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
401
    }
402
    $query .= qq|
403
  FROM      serial 
377
  FROM      serial 
404
  LEFT JOIN subscription ON 
378
  LEFT JOIN subscription ON 
405
          (serial.subscriptionid=subscription.subscriptionid )
379
          (serial.subscriptionid=subscription.subscriptionid )
Lines 413-419 sub GetFullSubscription { Link Here
413
    $debug and warn "GetFullSubscription query: $query";
387
    $debug and warn "GetFullSubscription query: $query";
414
    my $sth = $dbh->prepare($query);
388
    my $sth = $dbh->prepare($query);
415
    $sth->execute($subscriptionid);
389
    $sth->execute($subscriptionid);
416
    return $sth->fetchall_arrayref( {} );
390
    my $subscriptions = $sth->fetchall_arrayref( {} );
391
    for my $subscription ( @$subscriptions ) {
392
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
393
    }
394
    return $subscriptions;
417
}
395
}
418
396
419
=head2 PrepareSerialsData
397
=head2 PrepareSerialsData
Lines 514-526 sub GetSubscriptionsFromBiblionumber { Link Here
514
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
492
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
515
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
493
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
516
        $subs->{ "status" . $subs->{'status'} }             = 1;
494
        $subs->{ "status" . $subs->{'status'} }             = 1;
517
        $subs->{'cannotedit'} =
518
          (      C4::Context->preference('IndependentBranches')
519
              && C4::Context->userenv
520
              && C4::Context->userenv->{flags} % 2 != 1
521
              && C4::Context->userenv->{branch}
522
              && $subs->{branchcode}
523
              && ( C4::Context->userenv->{branch} ne $subs->{branchcode} ) );
524
495
525
        if ( $subs->{enddate} eq '0000-00-00' ) {
496
        if ( $subs->{enddate} eq '0000-00-00' ) {
526
            $subs->{enddate} = '';
497
            $subs->{enddate} = '';
Lines 529-534 sub GetSubscriptionsFromBiblionumber { Link Here
529
        }
500
        }
530
        $subs->{'abouttoexpire'}       = abouttoexpire( $subs->{'subscriptionid'} );
501
        $subs->{'abouttoexpire'}       = abouttoexpire( $subs->{'subscriptionid'} );
531
        $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
502
        $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
503
        $subs->{cannotedit} = not can_edit_subscription( $subs );
532
        push @res, $subs;
504
        push @res, $subs;
533
    }
505
    }
534
    return \@res;
506
    return \@res;
Lines 554-569 sub GetFullSubscriptionsFromBiblionumber { Link Here
554
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
526
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
555
            biblio.title as bibliotitle,
527
            biblio.title as bibliotitle,
556
            subscription.branchcode AS branchcode,
528
            subscription.branchcode AS branchcode,
557
            subscription.subscriptionid AS subscriptionid|;
529
            subscription.subscriptionid AS subscriptionid
558
    if (   C4::Context->preference('IndependentBranches')
559
        && C4::Context->userenv
560
        && C4::Context->userenv->{'flags'} != 1
561
        && C4::Context->userenv->{'branch'} ) {
562
        $query .= "
563
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
564
    }
565
566
    $query .= qq|      
567
  FROM      serial 
530
  FROM      serial 
568
  LEFT JOIN subscription ON 
531
  LEFT JOIN subscription ON 
569
          (serial.subscriptionid=subscription.subscriptionid)
532
          (serial.subscriptionid=subscription.subscriptionid)
Lines 576-582 sub GetFullSubscriptionsFromBiblionumber { Link Here
576
          |;
539
          |;
577
    my $sth = $dbh->prepare($query);
540
    my $sth = $dbh->prepare($query);
578
    $sth->execute($biblionumber);
541
    $sth->execute($biblionumber);
579
    return $sth->fetchall_arrayref( {} );
542
    my $subscriptions = $sth->fetchall_arrayref( {} );
543
    for my $subscription ( @$subscriptions ) {
544
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
545
    }
546
    return $subscriptions;
580
}
547
}
581
548
582
=head2 GetSubscriptions
549
=head2 GetSubscriptions
Lines 651-669 sub GetSubscriptions { Link Here
651
    $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params );
618
    $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params );
652
    $sth = $dbh->prepare($sql);
619
    $sth = $dbh->prepare($sql);
653
    $sth->execute(@bind_params);
620
    $sth->execute(@bind_params);
654
    my @results;
621
    my $subscriptions = $sth->fetchall_arrayref( {} );
655
622
    for my $subscription ( @$subscriptions ) {
656
    while ( my $line = $sth->fetchrow_hashref ) {
623
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
657
        $line->{'cannotedit'} =
624
    }
658
          (      C4::Context->preference('IndependentBranches')
625
    return @$subscriptions;
659
              && C4::Context->userenv
660
              && C4::Context->userenv->{flags} % 2 != 1
661
              && C4::Context->userenv->{branch}
662
              && $line->{branchcode}
663
              && ( C4::Context->userenv->{branch} ne $line->{branchcode} ) );
664
        push @results, $line;
665
    }
666
    return @results;
667
}
626
}
668
627
669
=head2 SearchSubscriptions
628
=head2 SearchSubscriptions
Lines 748-753 sub SearchSubscriptions { Link Here
748
    my $results = $sth->fetchall_arrayref( {} );
707
    my $results = $sth->fetchall_arrayref( {} );
749
    $sth->finish;
708
    $sth->finish;
750
709
710
    for my $subscription ( @$results ) {
711
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
712
        $subscription->{cannotdisplay} =
713
            ( C4::Context->preference("IndependentBranches")
714
                and $subscription->{branchcode} ne C4::Context->userenv->{'branch'} ) ? 1 : 0;
715
    }
716
751
    return @$results;
717
    return @$results;
752
}
718
}
753
719
Lines 2828-2833 sub subscriptionCurrentlyOnOrder { Link Here
2828
    return $sth->fetchrow_array;
2794
    return $sth->fetchrow_array;
2829
}
2795
}
2830
2796
2797
sub can_edit_subscription {
2798
    my ( $subscription, $userid ) = @_;
2799
    my $flags = C4::Context->userenv->{flags};
2800
    $userid ||= C4::Context->userenv->{'id'};
2801
    my $independent_branches = C4::Context->preference('IndependentBranches');
2802
    return 1 unless $independent_branches;
2803
    if( $flags % 2 == 1 # superlibrarian
2804
        or C4::Auth::haspermission( $userid, {serials => 'superserials'}),
2805
        or C4::Auth::haspermission( $userid, {serials => 'edit_subscription'}),
2806
        or not defined $subscription->{branchcode}
2807
        or $subscription->{branchcode} eq ''
2808
        or $subscription->{branchcode} eq C4::Context->userenv->{'branch'}
2809
    ) {
2810
        return 1;
2811
    }
2812
     return 0;
2813
}
2814
2831
1;
2815
1;
2832
__END__
2816
__END__
2833
2817
(-)a/installer/data/mysql/de-DE/mandatory/userpermissions.sql (+1 lines)
Lines 52-57 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
52
   (15, 'receive_serials', 'Zugang von Heften'),
52
   (15, 'receive_serials', 'Zugang von Heften'),
53
   (15, 'renew_subscription', 'Abonnements verlängern'),
53
   (15, 'renew_subscription', 'Abonnements verlängern'),
54
   (15, 'routing', 'Umlauflisten verwalten'),
54
   (15, 'routing', 'Umlauflisten verwalten'),
55
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
55
   (16, 'execute_reports', 'SQL-Reports ausführen'),
56
   (16, 'execute_reports', 'SQL-Reports ausführen'),
56
   (16, 'create_reports', 'SQL-Reports erstellen'),
57
   (16, 'create_reports', 'SQL-Reports erstellen'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
58
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/en/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/es-ES/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/fr-FR/1-Obligatoire/userpermissions.sql (+1 lines)
Lines 52-57 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
52
   (15, 'receive_serials', 'Bulletiner les périodiques'),
52
   (15, 'receive_serials', 'Bulletiner les périodiques'),
53
   (15, 'renew_subscription', 'Renouveler les abonnements'),
53
   (15, 'renew_subscription', 'Renouveler les abonnements'),
54
   (15, 'routing', 'Mettre en circulation'),
54
   (15, 'routing', 'Mettre en circulation'),
55
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
55
   (16, 'execute_reports', 'Lancer les rapports SQL'),
56
   (16, 'execute_reports', 'Lancer les rapports SQL'),
56
   (16, 'create_reports', 'Créer les rapports SQL Reports'),
57
   (16, 'create_reports', 'Créer les rapports SQL Reports'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
58
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/it-IT/necessari/userpermissions.sql (+1 lines)
Lines 54-59 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
54
   (15, 'receive_serials', 'Ricevi fascicoli'),
54
   (15, 'receive_serials', 'Ricevi fascicoli'),
55
   (15, 'renew_subscription', 'Rinnova un abbonamento'),
55
   (15, 'renew_subscription', 'Rinnova un abbonamento'),
56
   (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'),
56
   (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'),
57
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
57
   (16, 'execute_reports', 'Esegui reports SQL'),
58
   (16, 'execute_reports', 'Esegui reports SQL'),
58
   (16, 'create_reports', 'Crea reports SQL'),
59
   (16, 'create_reports', 'Crea reports SQL'),
59
   (18, 'manage_courses', 'Add, edit and delete courses'),
60
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql (+1 lines)
Lines 72-77 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
72
   (15, 'receive_serials', 'Heftemottak'),
72
   (15, 'receive_serials', 'Heftemottak'),
73
   (15, 'renew_subscription', 'Fornye abonnementer'),
73
   (15, 'renew_subscription', 'Fornye abonnementer'),
74
   (15, 'routing', 'Sirkulasjon'),
74
   (15, 'routing', 'Sirkulasjon'),
75
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
75
   (16, 'execute_reports', 'Kjøre SQL-rapporter'),
76
   (16, 'execute_reports', 'Kjøre SQL-rapporter'),
76
   (16, 'create_reports', 'Opprette SQL-rapporter'),
77
   (16, 'create_reports', 'Opprette SQL-rapporter'),
77
   (18, 'manage_courses', 'Add, edit and delete courses'),
78
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql (+1 lines)
Lines 53-58 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
53
   (15, 'receive_serials', 'Serials receiving'),
53
   (15, 'receive_serials', 'Serials receiving'),
54
   (15, 'renew_subscription', 'Renew a subscription'),
54
   (15, 'renew_subscription', 'Renew a subscription'),
55
   (15, 'routing', 'Routing'),
55
   (15, 'routing', 'Routing'),
56
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
56
   (16, 'execute_reports', 'Execute SQL reports'),
57
   (16, 'execute_reports', 'Execute SQL reports'),
57
   (16, 'create_reports', 'Create SQL Reports'),
58
   (16, 'create_reports', 'Create SQL Reports'),
58
   (18, 'manage_courses', 'Add, edit and delete courses'),
59
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql (+1 lines)
Lines 78-83 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
78
   (15, 'receive_serials',             'Serials receiving'),
78
   (15, 'receive_serials',             'Serials receiving'),
79
   (15, 'renew_subscription',          'Renew a subscription'),
79
   (15, 'renew_subscription',          'Renew a subscription'),
80
   (15, 'routing',                     'Routing'),
80
   (15, 'routing',                     'Routing'),
81
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
81
   (16, 'execute_reports', 'Execute SQL reports'),
82
   (16, 'execute_reports', 'Execute SQL reports'),
82
   (16, 'create_reports', 'Create SQL Reports'),
83
   (16, 'create_reports', 'Create SQL Reports'),
83
   (18, 'manage_courses', 'Add, edit and delete courses'),
84
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql (+1 lines)
Lines 78-83 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
78
   (15, 'receive_serials',             'Serials receiving'),
78
   (15, 'receive_serials',             'Serials receiving'),
79
   (15, 'renew_subscription',          'Renew a subscription'),
79
   (15, 'renew_subscription',          'Renew a subscription'),
80
   (15, 'routing',                     'Routing'),
80
   (15, 'routing',                     'Routing'),
81
   (15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependantBranches is used)'),
81
   (16, 'execute_reports', 'Execute SQL reports'),
82
   (16, 'execute_reports', 'Execute SQL reports'),
82
   (16, 'create_reports', 'Create SQL Reports'),
83
   (16, 'create_reports', 'Create SQL Reports'),
83
   (18, 'manage_courses', 'Add, edit and delete courses'),
84
   (18, 'manage_courses', 'Add, edit and delete courses'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 7636-7641 if ( CheckVersion($DBversion) ) { Link Here
7636
    SetVersion($DBversion);
7636
    SetVersion($DBversion);
7637
}
7637
}
7638
7638
7639
$DBversion = "3.13.00.XXX";
7640
if ( CheckVersion($DBversion) ) {
7641
    $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependentBranches is used)')");
7642
    print "Upgrade to $DBversion done (Bug 8435: Add superserials permission)\n";
7643
    SetVersion($DBversion);
7644
}
7645
7639
=head1 FUNCTIONS
7646
=head1 FUNCTIONS
7640
7647
7641
=head2 TableExists($table)
7648
=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 107-112 if (@subscriptionid){ Link Here
107
   foreach my $subscriptionid (@subscriptionid){
106
   foreach my $subscriptionid (@subscriptionid){
108
    my $subs= GetSubscription($subscriptionid);
107
    my $subs= GetSubscription($subscriptionid);
109
    $closed = 1 if $subs->{closed};
108
    $closed = 1 if $subs->{closed};
109
110
    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
110
    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
111
    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
111
    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
112
    $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
112
    $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 124-133 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
124
    }
125
    }
125
}
126
}
126
127
127
my $onlymine=C4::Context->preference('IndependentBranches') &&
128
my $userenv = C4::Context->userenv;
128
             C4::Context->userenv &&
129
my $onlymine =
129
             C4::Context->userenv->{flags} % 2 !=1 &&
130
     C4::Context->preference('IndependentBranches')
130
             C4::Context->userenv->{branch};
131
  && $userenv
132
  && $userenv->{flags} % 2 != 1
133
  && (
134
    not C4::Auth::haspermission( $userenv->{id}, { serials => 'superserials' } )
135
  )
136
  && $userenv->{branch};
137
131
my $branches = GetBranches($onlymine);
138
my $branches = GetBranches($onlymine);
132
my $branchloop;
139
my $branchloop;
133
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
140
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 155-166 $template->param( Link Here
155
    hasRouting  => $hasRouting,
143
    hasRouting  => $hasRouting,
156
    routing => C4::Context->preference("RoutingSerials"),
144
    routing => C4::Context->preference("RoutingSerials"),
157
    totalissues => $totalissues,
145
    totalissues => $totalissues,
158
    hemisphere => $hemisphere,
146
    cannotedit => (not C4::Serials::can_edit_subscription( $subs )),
159
    cannotedit =>(C4::Context->preference('IndependentBranches') &&
160
                C4::Context->userenv &&
161
                C4::Context->userenv->{flags} % 2 !=1  &&
162
                C4::Context->userenv->{branch} && $subs->{branchcode} &&
163
                (C4::Context->userenv->{branch} ne $subs->{branchcode})),
164
    frequency => $frequency,
147
    frequency => $frequency,
165
    numberpattern => $numberpattern,
148
    numberpattern => $numberpattern,
166
    has_X           => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
149
    has_X           => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
167
- 

Return to bug 8435