Lines 1271-1276
sub can_see_patrons_from {
Link Here
|
1271 |
); |
1271 |
); |
1272 |
} |
1272 |
} |
1273 |
|
1273 |
|
|
|
1274 |
=head3 libraries_where_can_see_patrons |
1275 |
|
1276 |
my $libraries = $patron-libraries_where_can_see_patrons; |
1277 |
|
1278 |
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. |
1279 |
The branchcodes are arbitrarily returned sorted. |
1280 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1281 |
|
1282 |
An empty array means no restriction, the patron can see patron's infos from any libraries. |
1283 |
|
1284 |
=cut |
1285 |
|
1286 |
sub libraries_where_can_see_patrons { |
1287 |
my ($self) = @_; |
1288 |
|
1289 |
return $self->libraries_where_can_see_things( |
1290 |
{ |
1291 |
permission => 'borrowers', |
1292 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1293 |
group_feature => 'ft_hide_patron_info', |
1294 |
} |
1295 |
); |
1296 |
} |
1297 |
|
1298 |
=head3 can_edit_item |
1299 |
|
1300 |
my $can_edit = $patron->can_edit_item( $item ); |
1301 |
|
1302 |
Return true if the patron (usually the logged in user) can edit the given item |
1303 |
|
1304 |
The parameter can be a Koha::Item, an item hashref, or a branchcode. |
1305 |
|
1306 |
=cut |
1307 |
|
1308 |
sub can_edit_item { |
1309 |
my ( $self, $item ) = @_; |
1310 |
|
1311 |
my $userenv = C4::Context->userenv(); |
1312 |
|
1313 |
my $ref = ref($item); |
1314 |
|
1315 |
my $branchcode = |
1316 |
$ref eq 'Koha::Item' ? $item->homebranch |
1317 |
: $ref eq 'HASH' ? $item->{homebranch} |
1318 |
: $ref eq q{} ? $item |
1319 |
: undef; |
1320 |
|
1321 |
return unless $branchcode; |
1322 |
|
1323 |
return 1 if C4::Context->IsSuperLibrarian(); |
1324 |
|
1325 |
if ( C4::Context->preference('IndependentBranches') ) { |
1326 |
return $userenv->{branch} eq $branchcode; |
1327 |
} |
1328 |
|
1329 |
return $self->can_edit_items_from($branchcode); |
1330 |
} |
1331 |
|
1332 |
=head3 can_edit_items_from |
1333 |
|
1334 |
my $can_edit = $patron->can_edit_items_from( $branchcode ); |
1335 |
|
1336 |
Return true if this user can edit items from the give home branchcode |
1337 |
|
1338 |
=cut |
1339 |
|
1340 |
sub can_edit_items_from { |
1341 |
my ( $self, $branchcode ) = @_; |
1342 |
|
1343 |
return $self->can_see_things_from( |
1344 |
{ |
1345 |
branchcode => $branchcode, |
1346 |
permission => 'editcatalogue', |
1347 |
subpermission => 'edit_any_item', |
1348 |
} |
1349 |
); |
1350 |
} |
1351 |
|
1352 |
=head3 libraries_where_can_edit_items |
1353 |
|
1354 |
my $libraries = $patron->libraries_where_can_edit_items; |
1355 |
|
1356 |
Return the list of branchcodes(!) of libraries the patron is allowed to items for. |
1357 |
The branchcodes are arbitrarily returned sorted. |
1358 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1359 |
|
1360 |
An empty array means no restriction, the user can edit any item. |
1361 |
|
1362 |
=cut |
1363 |
|
1364 |
sub libraries_where_can_edit_items { |
1365 |
my ($self) = @_; |
1366 |
|
1367 |
return $self->libraries_where_can_see_things( |
1368 |
{ |
1369 |
permission => 'editcatalogue', |
1370 |
subpermission => 'edit_any_item', |
1371 |
group_feature => 'ft_limit_item_editing', |
1372 |
} |
1373 |
); |
1374 |
} |
1375 |
|
1274 |
=head3 can_see_things_from |
1376 |
=head3 can_see_things_from |
1275 |
|
1377 |
|
1276 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1378 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
Lines 1301-1330
sub can_see_things_from {
Link Here
|
1301 |
return $can; |
1403 |
return $can; |
1302 |
} |
1404 |
} |
1303 |
|
1405 |
|
1304 |
=head3 libraries_where_can_see_patrons |
|
|
1305 |
|
1306 |
my $libraries = $patron-libraries_where_can_see_patrons; |
1307 |
|
1308 |
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. |
1309 |
The branchcodes are arbitrarily returned sorted. |
1310 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1311 |
|
1312 |
An empty array means no restriction, the patron can see patron's infos from any libraries. |
1313 |
|
1314 |
=cut |
1315 |
|
1316 |
sub libraries_where_can_see_patrons { |
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 |
1406 |
=head3 libraries_where_can_see_things |
1329 |
|
1407 |
|
1330 |
my $libraries = $thing-libraries_where_can_see_things; |
1408 |
my $libraries = $thing-libraries_where_can_see_things; |
1331 |
- |
|
|