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