Lines 1136-1145
Return true if the patron (usually the logged in user) can see the patron's info
Link Here
|
1136 |
|
1136 |
|
1137 |
sub can_see_patrons_from { |
1137 |
sub can_see_patrons_from { |
1138 |
my ( $self, $branchcode ) = @_; |
1138 |
my ( $self, $branchcode ) = @_; |
|
|
1139 |
|
1140 |
return $self->can_see_things_from( |
1141 |
{ |
1142 |
branchcode => $branchcode, |
1143 |
permission => 'borrowers', |
1144 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1145 |
} |
1146 |
); |
1147 |
} |
1148 |
|
1149 |
=head3 can_see_things_from |
1150 |
|
1151 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1152 |
|
1153 |
Return true if this "patron" ( usally the logged in user ) can perform some action on the given thing |
1154 |
|
1155 |
=cut |
1156 |
|
1157 |
sub can_see_things_from { |
1158 |
my ( $self, $params ) = @_; |
1159 |
my $branchcode = $params->{branchcode}; |
1160 |
my $permission = $params->{permission}; |
1161 |
my $subpermission = $params->{subpermission}; |
1162 |
|
1139 |
my $can = 0; |
1163 |
my $can = 0; |
1140 |
if ( $self->branchcode eq $branchcode ) { |
1164 |
if ( $self->branchcode eq $branchcode ) { |
1141 |
$can = 1; |
1165 |
$can = 1; |
1142 |
} elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { |
1166 |
} elsif ( $self->has_permission( { $permission => $subpermission } ) ) { |
1143 |
$can = 1; |
1167 |
$can = 1; |
1144 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1168 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1145 |
while ( my $library_group = $library_groups->next ) { |
1169 |
while ( my $library_group = $library_groups->next ) { |
Lines 1165-1171
An empty array means no restriction, the patron can see patron's infos from any
Link Here
|
1165 |
=cut |
1189 |
=cut |
1166 |
|
1190 |
|
1167 |
sub libraries_where_can_see_patrons { |
1191 |
sub libraries_where_can_see_patrons { |
1168 |
my ( $self ) = @_; |
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 |
1204 |
|
1205 |
my $libraries = $thing-libraries_where_can_see_things; |
1206 |
|
1207 |
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian |
1208 |
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ). |
1209 |
|
1210 |
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library) |
1211 |
|
1212 |
An empty array means no restriction, the thing can see thing's infos from any libraries. |
1213 |
|
1214 |
=cut |
1215 |
|
1216 |
sub libraries_where_can_see_things { |
1217 |
my ( $self, $params ) = @_; |
1218 |
my $permission = $params->{permission}; |
1219 |
my $subpermission = $params->{subpermission}; |
1220 |
my $group_feature = $params->{group_feature}; |
1221 |
|
1169 |
my $userenv = C4::Context->userenv; |
1222 |
my $userenv = C4::Context->userenv; |
1170 |
|
1223 |
|
1171 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
1224 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
Lines 1177-1187
sub libraries_where_can_see_patrons {
Link Here
|
1177 |
else { |
1230 |
else { |
1178 |
unless ( |
1231 |
unless ( |
1179 |
$self->has_permission( |
1232 |
$self->has_permission( |
1180 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
1233 |
{ $permission => $subpermission } |
1181 |
) |
1234 |
) |
1182 |
) |
1235 |
) |
1183 |
{ |
1236 |
{ |
1184 |
my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 }); |
1237 |
my $library_groups = $self->library->library_groups({ $group_feature => 1 }); |
1185 |
if ( $library_groups->count ) |
1238 |
if ( $library_groups->count ) |
1186 |
{ |
1239 |
{ |
1187 |
while ( my $library_group = $library_groups->next ) { |
1240 |
while ( my $library_group = $library_groups->next ) { |
1188 |
- |
|
|