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

(-)a/Koha/Patron.pm (-5 / +57 lines)
Lines 1262-1271 Return true if the patron (usually the logged in user) can see the patron's info Link Here
1262
1262
1263
sub can_see_patrons_from {
1263
sub can_see_patrons_from {
1264
    my ( $self, $branchcode ) = @_;
1264
    my ( $self, $branchcode ) = @_;
1265
1266
    return $self->can_see_things_from(
1267
        {
1268
            branchcode => $branchcode,
1269
            permission => 'borrowers',
1270
            subpermission => 'view_borrower_infos_from_any_libraries',
1271
        }
1272
    );
1273
}
1274
1275
=head3 can_see_things_from
1276
1277
my $can_see = $thing->can_see_things_from( $branchcode );
1278
1279
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing
1280
1281
=cut
1282
1283
sub can_see_things_from {
1284
    my ( $self, $params ) = @_;
1285
    my $branchcode    = $params->{branchcode};
1286
    my $permission    = $params->{permission};
1287
    my $subpermission = $params->{subpermission};
1288
1265
    my $can = 0;
1289
    my $can = 0;
1266
    if ( $self->branchcode eq $branchcode ) {
1290
    if ( $self->branchcode eq $branchcode ) {
1267
        $can = 1;
1291
        $can = 1;
1268
    } elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) {
1292
    } elsif ( $self->has_permission( { $permission => $subpermission } ) ) {
1269
        $can = 1;
1293
        $can = 1;
1270
    } elsif ( my $library_groups = $self->library->library_groups ) {
1294
    } elsif ( my $library_groups = $self->library->library_groups ) {
1271
        while ( my $library_group = $library_groups->next ) {
1295
        while ( my $library_group = $library_groups->next ) {
Lines 1291-1297 An empty array means no restriction, the patron can see patron's infos from any Link Here
1291
=cut
1315
=cut
1292
1316
1293
sub libraries_where_can_see_patrons {
1317
sub libraries_where_can_see_patrons {
1294
    my ( $self ) = @_;
1318
    my ($self) = @_;
1319
1320
    return $self->libraries_where_can_see_things(
1321
        {
1322
            permission    => 'borrowers',
1323
            subpermission => 'view_borrower_infos_from_any_libraries',
1324
            group_feature => 'ft_hide_patron_info',
1325
        }
1326
    );
1327
}
1328
1329
=head3 libraries_where_can_see_things
1330
1331
my $libraries = $thing-libraries_where_can_see_things;
1332
1333
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian
1334
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ).
1335
1336
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library)
1337
1338
An empty array means no restriction, the thing can see thing's infos from any libraries.
1339
1340
=cut
1341
1342
sub libraries_where_can_see_things {
1343
    my ( $self, $params ) = @_;
1344
    my $permission    = $params->{permission};
1345
    my $subpermission = $params->{subpermission};
1346
    my $group_feature = $params->{group_feature};
1347
1295
    my $userenv = C4::Context->userenv;
1348
    my $userenv = C4::Context->userenv;
1296
1349
1297
    return () unless $userenv; # For tests, but userenv should be defined in tests...
1350
    return () unless $userenv; # For tests, but userenv should be defined in tests...
Lines 1303-1313 sub libraries_where_can_see_patrons { Link Here
1303
    else {
1356
    else {
1304
        unless (
1357
        unless (
1305
            $self->has_permission(
1358
            $self->has_permission(
1306
                { borrowers => 'view_borrower_infos_from_any_libraries' }
1359
                { $permission => $subpermission }
1307
            )
1360
            )
1308
          )
1361
          )
1309
        {
1362
        {
1310
            my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 });
1363
            my $library_groups = $self->library->library_groups({ $group_feature => 1 });
1311
            if ( $library_groups->count )
1364
            if ( $library_groups->count )
1312
            {
1365
            {
1313
                while ( my $library_group = $library_groups->next ) {
1366
                while ( my $library_group = $library_groups->next ) {
1314
- 

Return to bug 20256