Bug 18403: Guarantors
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 10 Apr 2017 13:23:37 +0000 (10:23 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 12 Feb 2018 18:41:41 +0000 (15:41 -0300)
Technically a kid from your library group could have a guarantor
attached to another
group of library, let's deal with this case.

Test plan:
- Create a kid from your library group
- With a superlibrarian staff user create a guarantor that is outside of
the group of
libraries of the kid
- Login with a limited staff user and confirm that on the patron detail
page you do not
see the link to the guarantor detail page.

Note that you see the firstname and surname of the guarantor
Q. should it be hidden?

Signed-off-by: Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
members/memberentry.pl

index 0957468..ed02f79 100644 (file)
@@ -460,7 +460,14 @@ $(document).ready(function() {
  [% ELSE %]
  <li id="contact-details" style="display: none">
  [% END %]
-     <span class="label">Patron #:</span> [% IF ( guarantorid ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid %]" target="blank">[% guarantorid |html %]</a>[% END %]
+     <span class="label">Patron #:</span>
+     [% IF guarantorid %]
+        [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
+            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid %]" target="blank">[% guarantorid | html %]</a>
+        [% ELSE %]
+            [% guarantorid | html %]
+        [% END %]
+    [% END %]
  </li>
         [% UNLESS nocontactname %]
  <li>
index 3898166..5ea5ac3 100644 (file)
@@ -271,14 +271,18 @@ function validate1(date) {
                 <span class="label">Guarantees:</span>
                 <ul>
                     [% FOREACH guarantee IN guarantees %]
-                        <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
+                        [% IF logged_in_user.can_see_patron_infos( guarantee ) %]
+                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
+                        [% ELSE %]
+                            <li>[% guarantee.firstname | html %] [% guarantee.surname | html %]</li>
+                        [% END %]
                     [% END %]
                 </ul>
             </li>
         [% ELSIF guarantor %]
             <li>
                 <span class="label">Guarantor:</span>
-                [% IF guarantor.borrowernumber %]
+                [% IF guarantor.borrowernumber AND logged_in_user.can_see_patron_infos( guarantor ) %]
                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.borrowernumber %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
                 [% ELSE %]
                     [% guarantor.firstname | html %] [% guarantor.surname | html %]
index 5f5c922..b72f8da 100755 (executable)
@@ -755,10 +755,13 @@ $template->param(
   check_member    => $check_member,#to know if the borrower already exist(=>1) or not (=>0) 
   "op$op"   => 1);
 
+$guarantorid = $borrower_data->{'guarantorid'} || $guarantorid;
+my $guarantor = $guarantorid ? Koha::Patrons->find( $guarantorid ) : undef;
 $template->param(
   nodouble  => $nodouble,
   borrowernumber  => $borrowernumber, #register number
-  guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid),
+  guarantor   => $guarantor,
+  guarantorid => $guarantorid,
   relshiploop => \@relshipdata,
   btitle=> $default_borrowertitle,
   guarantorinfo   => $guarantorinfo,