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