Lines 1280-1289
Return true if the patron (usually the logged in user) can see the patron's info
Link Here
|
1280 |
|
1280 |
|
1281 |
sub can_see_patrons_from { |
1281 |
sub can_see_patrons_from { |
1282 |
my ( $self, $branchcode ) = @_; |
1282 |
my ( $self, $branchcode ) = @_; |
|
|
1283 |
|
1284 |
return $self->can_see_things_from( |
1285 |
{ |
1286 |
branchcode => $branchcode, |
1287 |
permission => 'borrowers', |
1288 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1289 |
} |
1290 |
); |
1291 |
} |
1292 |
|
1293 |
=head3 can_see_things_from |
1294 |
|
1295 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1296 |
|
1297 |
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing |
1298 |
|
1299 |
=cut |
1300 |
|
1301 |
sub can_see_things_from { |
1302 |
my ( $self, $params ) = @_; |
1303 |
my $branchcode = $params->{branchcode}; |
1304 |
my $permission = $params->{permission}; |
1305 |
my $subpermission = $params->{subpermission}; |
1306 |
|
1283 |
my $can = 0; |
1307 |
my $can = 0; |
1284 |
if ( $self->branchcode eq $branchcode ) { |
1308 |
if ( $self->branchcode eq $branchcode ) { |
1285 |
$can = 1; |
1309 |
$can = 1; |
1286 |
} elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { |
1310 |
} elsif ( $self->has_permission( { $permission => $subpermission } ) ) { |
1287 |
$can = 1; |
1311 |
$can = 1; |
1288 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1312 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1289 |
while ( my $library_group = $library_groups->next ) { |
1313 |
while ( my $library_group = $library_groups->next ) { |
Lines 1309-1315
An empty array means no restriction, the patron can see patron's infos from any
Link Here
|
1309 |
=cut |
1333 |
=cut |
1310 |
|
1334 |
|
1311 |
sub libraries_where_can_see_patrons { |
1335 |
sub libraries_where_can_see_patrons { |
1312 |
my ( $self ) = @_; |
1336 |
my ($self) = @_; |
|
|
1337 |
|
1338 |
return $self->libraries_where_can_see_things( |
1339 |
{ |
1340 |
permission => 'borrowers', |
1341 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1342 |
group_feature => 'ft_hide_patron_info', |
1343 |
} |
1344 |
); |
1345 |
} |
1346 |
|
1347 |
=head3 libraries_where_can_see_things |
1348 |
|
1349 |
my $libraries = $thing-libraries_where_can_see_things; |
1350 |
|
1351 |
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian |
1352 |
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ). |
1353 |
|
1354 |
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library) |
1355 |
|
1356 |
An empty array means no restriction, the thing can see thing's infos from any libraries. |
1357 |
|
1358 |
=cut |
1359 |
|
1360 |
sub libraries_where_can_see_things { |
1361 |
my ( $self, $params ) = @_; |
1362 |
my $permission = $params->{permission}; |
1363 |
my $subpermission = $params->{subpermission}; |
1364 |
my $group_feature = $params->{group_feature}; |
1365 |
|
1313 |
my $userenv = C4::Context->userenv; |
1366 |
my $userenv = C4::Context->userenv; |
1314 |
|
1367 |
|
1315 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
1368 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
Lines 1321-1331
sub libraries_where_can_see_patrons {
Link Here
|
1321 |
else { |
1374 |
else { |
1322 |
unless ( |
1375 |
unless ( |
1323 |
$self->has_permission( |
1376 |
$self->has_permission( |
1324 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
1377 |
{ $permission => $subpermission } |
1325 |
) |
1378 |
) |
1326 |
) |
1379 |
) |
1327 |
{ |
1380 |
{ |
1328 |
my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 }); |
1381 |
my $library_groups = $self->library->library_groups({ $group_feature => 1 }); |
1329 |
if ( $library_groups->count ) |
1382 |
if ( $library_groups->count ) |
1330 |
{ |
1383 |
{ |
1331 |
while ( my $library_group = $library_groups->next ) { |
1384 |
while ( my $library_group = $library_groups->next ) { |
1332 |
- |
|
|