Koha/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc
Jonathan Druart 5f80977875 Bug 18403: Use patron-title.inc when hidepatronname is used
There is already a HidePatronName syspref to hide patron's information
on bibliographic
record detail pages and the hold list.

Test plan:
With the HidePatronName enabled, make sure the patron's information are
hidden from
the catalogue and hold list pages. If the logged in user is not allowed
to see the
patron's info, no link and no cardnumber will be displayed
With he HidePatronName disabled, make sure the patron's information are
displayed
if the logged in user is allowed to see the patron's info.

Technical note:
This patch improves the existing patron-title.inc include file to
display patron's
information. Using it everywhere patron's details are displayed will
permit to
homogenise the way they are displayed. The file takes now a patron
object (what
should be, in the future, the only way to use it), that way we can call
the new
method on it to know if patron's information can be shown by the logged
in used.

NOTE: I am not sure this syspref makes sense anymore. Should not we
remove it?

Signed-off-by: Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2018-02-12 15:41:38 -03:00

75 lines
3.5 KiB
PHP

[%- USE Koha -%]
[%- USE Branches -%]
[%- SET data = {} -%]
[%- IF patron -%]
[%- SET data.category_type = patron.category.category_type -%]
[%- SET data.surname = patron.surname -%]
[%- SET data.othernames = patron.othernames -%]
[%- SET data.firstname = patron.firstname -%]
[%- SET data.cardnumber = patron.cardnumber -%]
[%- SET data.borrowernumber = patron.borrowernumber -%]
[%- SET data.title = patron.title -%]
[%- ELSIF ( borrower.borrowernumber ) -%]
[%- SET data.category_type = borrower.category_type -%]
[%- SET data.surname = borrower.surname -%]
[%- SET data.othernames = borrower.othernames -%]
[%- SET data.firstname = borrower.firstname -%]
[%- SET data.cardnumber = borrower.cardnumber -%]
[%- SET data.borrowernumber = borrower.borrowernumber -%]
[%- SET data.title = borrower.title -%]
[%- ELSIF ( borrowernumber ) -%]
[%- SET data.category_type = category_type -%]
[%- SET data.surname = surname -%]
[%- SET data.othernames = othernames -%]
[%- SET data.firstname = firstname -%]
[%- SET data.cardnumber = cardnumber -%]
[%- SET data.borrowernumber = borrowernumber -%]
[%- SET data.title = title -%]
[%- END -%]
[%# Parameter no_html - if 1, the html tags are NOT generated %]
[% IF data.title %]
[%- IF no_html %]
[%- span_start = '' %]
[%- span_end = '' %]
[%- ELSE %]
[%- span_start = '<span class="patron-title">' %]
[%- span_end = '</span>' %]
[%- END %]
[%- SET data.title = span_start _ data.title _ span_end _ ' ' -%]
[%- END -%]
[%- SET display_patron_name = 1 -%]
[%- SET display_cardnumber = 1 -%]
[%- IF hide_patron_infos_if_needed %] [%# Should only be set if patron is set -%]
[%- SET can_see_patron_infos = logged_in_user.can_see_patron_infos( patron ) -%]
[%- UNLESS can_see_patron_infos -%]
[%- SET display_patron_name = 0 -%]
[%- SET display_cardnumber = 0 -%]
[%- ELSIF Koha.Preference('HidePatronName') -%]
[%- SET display_patron_name = 0 -%]
[%- END -%]
[%- END -%]
[%- IF hide_patron_infos_if_needed AND ( display_patron_name OR display_cardnumber ) -%]
[%- IF link_to == 'circulation_reserves' %]<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% data.borrowernumber %]#reserves">
[%- ELSE %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber %]">
[%- END -%]
[%- END -%]
[%- IF data.category_type == 'I' -%]
[%- UNLESS display_patron_name %][%- data.surname | html %] [% IF data.othernames %] [% END %]([% data.othernames | html %]) [% END -%]
[%- ELSIF display_patron_name -%]
[%- IF invert_name -%]
[% data.title%][%- data.surname | html %], [% data.firstname | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
[%- ELSE -%]
[% data.title %][%- data.firstname | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
[%- END -%]
[%- IF display_cardnumber AND data.cardnumber %]([% data.cardnumber | html %])[% END -%]
[%- ELSIF display_cardnumber -%]
[%- IF data.cardnumber -%][%# FIXME Cardnumber should always be defined, right? -%]
[%- data.cardnumber | html -%]
[%- END -%]
[%- ELSE -%]
A patron from library [% Branches.GetName( patron.branchcode ) -%]
[%- END -%]
[%- IF hide_patron_infos_if_needed AND ( display_patron_name OR display_cardnumber ) -%]
</a>
[%- END -%]