|
Lines 1146-1151
sub can_see_patrons_from {
Link Here
|
| 1146 |
); |
1146 |
); |
| 1147 |
} |
1147 |
} |
| 1148 |
|
1148 |
|
|
|
1149 |
=head3 libraries_where_can_see_patrons |
| 1150 |
|
| 1151 |
my $libraries = $patron-libraries_where_can_see_patrons; |
| 1152 |
|
| 1153 |
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. |
| 1154 |
The branchcodes are arbitrarily returned sorted. |
| 1155 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
| 1156 |
|
| 1157 |
An empty array means no restriction, the patron can see patron's infos from any libraries. |
| 1158 |
|
| 1159 |
=cut |
| 1160 |
|
| 1161 |
sub libraries_where_can_see_patrons { |
| 1162 |
my ($self) = @_; |
| 1163 |
|
| 1164 |
return $self->libraries_where_can_see_things( |
| 1165 |
{ |
| 1166 |
permission => 'borrowers', |
| 1167 |
subpermission => 'view_borrower_infos_from_any_libraries', |
| 1168 |
group_feature => 'ft_hide_patron_info', |
| 1169 |
} |
| 1170 |
); |
| 1171 |
} |
| 1172 |
|
| 1173 |
=head3 can_edit_item |
| 1174 |
|
| 1175 |
my $can_edit = $patron->can_edit_item( $item ); |
| 1176 |
|
| 1177 |
Return true if the patron (usually the logged in user) can edit the given item |
| 1178 |
|
| 1179 |
The parameter can be a Koha::Item, an item hashref, or a branchcode. |
| 1180 |
|
| 1181 |
=cut |
| 1182 |
|
| 1183 |
sub can_edit_item { |
| 1184 |
my ( $self, $item ) = @_; |
| 1185 |
|
| 1186 |
my $userenv = C4::Context->userenv(); |
| 1187 |
|
| 1188 |
my $ref = ref($item); |
| 1189 |
|
| 1190 |
my $branchcode = |
| 1191 |
$ref eq 'Koha::Item' ? $item->homebranch |
| 1192 |
: $ref eq 'HASH' ? $item->{homebranch} |
| 1193 |
: $ref eq q{} ? $item |
| 1194 |
: undef; |
| 1195 |
|
| 1196 |
return unless $branchcode; |
| 1197 |
|
| 1198 |
return 1 if C4::Context->IsSuperLibrarian(); |
| 1199 |
|
| 1200 |
if ( C4::Context->preference('IndependentBranches') ) { |
| 1201 |
return $userenv->{branch} eq $branchcode; |
| 1202 |
} |
| 1203 |
|
| 1204 |
return $self->can_edit_items_from($branchcode); |
| 1205 |
} |
| 1206 |
|
| 1207 |
=head3 can_edit_items_from |
| 1208 |
|
| 1209 |
my $can_edit = $patron->can_edit_items_from( $branchcode ); |
| 1210 |
|
| 1211 |
Return true if this user can edit items from the give home branchcode |
| 1212 |
|
| 1213 |
=cut |
| 1214 |
|
| 1215 |
sub can_edit_items_from { |
| 1216 |
my ( $self, $branchcode ) = @_; |
| 1217 |
|
| 1218 |
return $self->can_see_things_from( |
| 1219 |
{ |
| 1220 |
branchcode => $branchcode, |
| 1221 |
permission => 'editcatalogue', |
| 1222 |
subpermission => 'edit_any_item', |
| 1223 |
} |
| 1224 |
); |
| 1225 |
} |
| 1226 |
|
| 1227 |
=head3 libraries_where_can_edit_items |
| 1228 |
|
| 1229 |
my $libraries = $patron->libraries_where_can_edit_items; |
| 1230 |
|
| 1231 |
Return the list of branchcodes(!) of libraries the patron is allowed to items for. |
| 1232 |
The branchcodes are arbitrarily returned sorted. |
| 1233 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
| 1234 |
|
| 1235 |
An empty array means no restriction, the user can edit any item. |
| 1236 |
|
| 1237 |
=cut |
| 1238 |
|
| 1239 |
sub libraries_where_can_edit_items { |
| 1240 |
my ($self) = @_; |
| 1241 |
|
| 1242 |
return $self->libraries_where_can_see_things( |
| 1243 |
{ |
| 1244 |
permission => 'editcatalogue', |
| 1245 |
subpermission => 'edit_any_item', |
| 1246 |
group_feature => 'ft_limit_item_editing', |
| 1247 |
} |
| 1248 |
); |
| 1249 |
} |
| 1250 |
|
| 1149 |
=head3 can_see_things_from |
1251 |
=head3 can_see_things_from |
| 1150 |
|
1252 |
|
| 1151 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1253 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
|
Lines 1176-1205
sub can_see_things_from {
Link Here
|
| 1176 |
return $can; |
1278 |
return $can; |
| 1177 |
} |
1279 |
} |
| 1178 |
|
1280 |
|
| 1179 |
=head3 libraries_where_can_see_patrons |
|
|
| 1180 |
|
| 1181 |
my $libraries = $patron-libraries_where_can_see_patrons; |
| 1182 |
|
| 1183 |
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. |
| 1184 |
The branchcodes are arbitrarily returned sorted. |
| 1185 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
| 1186 |
|
| 1187 |
An empty array means no restriction, the patron can see patron's infos from any libraries. |
| 1188 |
|
| 1189 |
=cut |
| 1190 |
|
| 1191 |
sub libraries_where_can_see_patrons { |
| 1192 |
my ($self) = @_; |
| 1193 |
|
| 1194 |
return $self->libraries_where_can_see_things( |
| 1195 |
{ |
| 1196 |
permission => 'borrowers', |
| 1197 |
subpermission => 'view_borrower_infos_from_any_libraries', |
| 1198 |
group_feature => 'ft_hide_patron_info', |
| 1199 |
} |
| 1200 |
); |
| 1201 |
} |
| 1202 |
|
| 1203 |
=head3 libraries_where_can_see_things |
1281 |
=head3 libraries_where_can_see_things |
| 1204 |
|
1282 |
|
| 1205 |
my $libraries = $thing-libraries_where_can_see_things; |
1283 |
my $libraries = $thing-libraries_where_can_see_things; |
| 1206 |
- |
|
|