Bugzilla – Attachment 58712 Details for
Bug 13757
Make patron attributes editable in the opac if set to 'editable in OPAC'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13757: (followup) Staff interface changes
Bug-13757-followup-Staff-interface-changes.patch (text/plain), 10.57 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-01-09 18:02:19 UTC
(
hide
)
Description:
Bug 13757: (followup) Staff interface changes
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-01-09 18:02:19 UTC
Size:
10.57 KB
patch
obsolete
>From c6687b736475a043ab62f136212b364443c9c0d8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 19 Dec 2016 16:22:17 -0300 >Subject: [PATCH] Bug 13757: (followup) Staff interface changes > >This patch adds proper extended attributes display and handling on the >patron modifications moderation page (members-update.pl). > >It also adds changes checking to the opac-memberentry.pl page so it >only saves a modification request if there are changes (it only checked >regular fields and not the extended ones). > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../prog/en/modules/members/members-update.tt | 10 +++++++ > .../bootstrap/en/modules/opac-memberentry.tt | 14 ++------- > members/members-update.pl | 19 ++++++++---- > opac/opac-memberentry.pl | 35 ++++++++++++++++++---- > 4 files changed, 55 insertions(+), 23 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt >index 736cd6e..5e65ed7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt >@@ -62,10 +62,17 @@ > [% CASE 'altcontactcountry' %]<span>Alternate contact: Country</span> > [% CASE 'altcontactphone' %]<span>Alternate contact: Phone</span> > [% CASE 'smsalertnumber' %]<span>SMS alert number</span> >+[% CASE 'extended_attributes' %]<span>Additional attributes and identifiers</span> > [% CASE %][% field %] > [% END %] > [% END %] > >+[% BLOCK display_extended_attributes %] >+ [% FOREACH attr IN attributes %] >+ <span>[% attr.code %]: [% IF pending %][% attr.value %][% ELSE %][% attr.attribute %][% END %]</span><br/> >+ [% END %] >+[% END %] >+ > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Update patron records</div> > > <div id="doc2" class="yui-t7"> >@@ -111,6 +118,9 @@ > [% ELSIF key == 'branchcode' %] > <td>[% Branches.GetName( borrowers.$borrowernumber.$key ) %]</td> > <td>[% Branches.GetName( pm.$key ) %]</td> >+ [% ELSIF ( key == 'extended_attributes' ) %] >+ <td>[% PROCESS display_extended_attributes attributes=borrowers.$borrowernumber.$key %]</td> >+ <td>[% PROCESS display_extended_attributes attributes=pm.$key pending=1 %]</td> > [% ELSE %] > <td>[% borrowers.$borrowernumber.$key %]</td> > <td>[% pm.$key %]</td> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 422e1a8..91cbae4 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -911,8 +911,8 @@ > [% IF ( pa.type.authorised_value_category ) %] > <select id="[% form_id %]" name="patron_attribute_value"> > <option value=""></option> >- [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, pa_value.value || '', 1 ) %] >- [% IF ( auth_val.selected ) %] >+ [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, 1 ) %] >+ [% IF ( auth_val.authorised_value == pa_value.value ) %] > <option value="[% auth_val.authorised_value %]" selected="selected"> > [%# Yes, lib; GetAuthorisedValues takes care of intelligently setting this from lib_opac %] > [% auth_val.lib %] >@@ -931,22 +931,12 @@ > [% IF ( pa.type.repeatable ) %] > <a href="#" class="clone-attribute">New</a> > [% END %] >- [% IF ( pa.type.password_allowed ) %] >- </li><li><label for="[% form_id %]_password">Password:</label> >- <input type="password" maxlength="64" value="[% pa_value.password %]" id="[% form_id %]_password" name="patron_attribute_password" /> >- [% ELSE %] >- [%# To keep the form inputs lined up in the POST %] >- <input type="hidden" name="patron_attribute_password" value="" /> >- [% END %] > [% ELSE %] > [% IF ( pa.type.authorised_value_category ) %] > [% AuthorisedValues.GetByCode( pa.type.authorised_value, pa_value.value, 1 ) %] > [% ELSE %] > [% pa_value.value | html_line_break %] > [% END %] >- [% IF ( pa_value.password ) %] >- (Password: *******) >- [% END %] > [% END %] > </li> > [% END %] >diff --git a/members/members-update.pl b/members/members-update.pl >index 636b8b9..24179e6 100755 >--- a/members/members-update.pl >+++ b/members/members-update.pl >@@ -16,14 +16,16 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >+use Modern::Perl; > > use CGI qw ( -utf8 ); >+ > use C4::Auth; > use C4::Output; > use C4::Context; > use C4::Members; >+use C4::Members::Attributes qw( GetBorrowerAttributes ); >+use Koha::Patron::Attributes; > use Koha::Patron::Modifications; > > my $query = new CGI; >@@ -51,14 +53,19 @@ my $pending_modifications = > > my $borrowers; > foreach my $pm (@$pending_modifications) { >- $borrowers->{ $pm->{'borrowernumber'} } = >- GetMember( borrowernumber => $pm->{'borrowernumber'} ); >- >+ $borrowers->{ $pm->{borrowernumber} } >+ = GetMember( borrowernumber => $pm->{borrowernumber} ); >+ my $patron_attributes = Koha::Patron::Attributes->search( >+ { borrowernumber => $pm->{borrowernumber} } ); >+ $borrowers->{ $pm->{'borrowernumber'} }->{extended_attributes} >+ = $patron_attributes; > } > > $template->param( > PendingModifications => $pending_modifications, >- borrowers => $borrowers, >+ borrowers => $borrowers > ); > > output_html_with_http_headers $query, $cookie, $template->output; >+ >+1; >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 6883724..b3fed91 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -21,12 +21,13 @@ use CGI qw ( -utf8 ); > use Digest::MD5 qw( md5_base64 md5_hex ); > use Encode qw( encode ); > use JSON; >-use List::MoreUtils qw( each_array uniq ); >+use List::MoreUtils qw( any each_array uniq ); > use String::Random qw( random_string ); > > use C4::Auth; > use C4::Output; > use C4::Members; >+use C4::Members::Attributes qw( GetBorrowerAttributes ); > use C4::Form::MessagingPreferences; > use Koha::Patrons; > use Koha::Patron::Modification; >@@ -251,7 +252,9 @@ elsif ( $action eq 'update' ) { > } > else { > my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower ); >- if (%borrower_changes) { >+ my $extended_attributes_changes = ExtendedAttributesMatch( $borrowernumber, $attributes ); >+ >+ if ( %borrower_changes || $extended_attributes_changes ) { > ( $template, $borrowernumber, $cookie ) = get_template_and_user( > { > template_name => "opac-memberentry-update-submitted.tt", >@@ -283,6 +286,7 @@ elsif ( $action eq 'update' ) { > action => 'edit', > nochanges => 1, > borrower => GetMember( borrowernumber => $borrowernumber ), >+ patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ), > csrf_token => Koha::Token->new->generate_csrf({ > id => Encode::encode( 'UTF-8', $borrower->{userid} ), > secret => md5_base64( Encode::encode( 'UTF-8', C4::Context->config('pass') ) ), >@@ -468,6 +472,28 @@ sub DelEmptyFields { > return %borrower; > } > >+sub ExtendedAttributesMatch { >+ my ( $borrowernumber, $entered_attributes ) = @_; >+ >+ my @patron_attributes_arr = GetBorrowerAttributes( $borrowernumber, 1 ); >+ my $patron_attributes = $patron_attributes_arr[0]; >+ >+ if ( scalar @{$entered_attributes} != scalar @{$patron_attributes} ) { >+ return 1; >+ } >+ >+ foreach my $attr ( @{$patron_attributes} ) { >+ next if any { >+ $_->{code} eq $attr->{code} and $_->{value} eq $attr->{value}; >+ } >+ @{$entered_attributes}; >+ return 1; >+ } >+ >+ return 0; >+} >+ >+ > sub GeneratePatronAttributesForm { > my ( $borrowernumber, $entered_attributes ) = @_; > >@@ -538,9 +564,8 @@ sub ParsePatronAttributes { > > my @codes = $cgi->multi_param('patron_attribute_code'); > my @values = $cgi->multi_param('patron_attribute_value'); >- my @passwords = $cgi->multi_param('patron_attribute_password'); > >- my $ea = each_array( @codes, @values, @passwords ); >+ my $ea = each_array( @codes, @values ); > my @attributes; > my %dups = (); > >@@ -549,7 +574,7 @@ sub ParsePatronAttributes { > next if exists $dups{$code}->{$value}; > $dups{$code}->{$value} = 1; > >- push @attributes, { code => $code, value => $value, password => $password }; >+ push @attributes, { code => $code, value => $value }; > } > > return \@attributes; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13757
:
42254
|
42626
|
42627
|
47625
|
48040
|
48041
|
48042
|
48043
|
48379
|
48380
|
48381
|
48382
|
56924
|
56925
|
56926
|
56927
|
56928
|
56929
|
57041
|
57042
|
57043
|
57044
|
57045
|
57046
|
58252
|
58253
|
58254
|
58255
|
58351
|
58352
|
58353
|
58354
|
58355
|
58356
|
58357
|
58428
|
58429
|
58581
|
58703
|
58706
|
58707
|
58708
|
58709
|
58710
|
58711
|
58712
|
58713
|
58714
|
58715
|
59376
|
59737
|
59738
|
59739
|
59813
|
59896
|
59897
|
59898
|
60359
|
60360
|
61132
|
61133
|
61134
|
61135
|
61136
|
61137
|
61138
|
61139
|
61140
|
61141
|
61142
|
61143
|
61144
|
61145
|
61146
|
61147
|
61148
|
61149
|
61150
|
61492
|
61493
|
61555
|
61556
|
61557
|
61558
|
61559
|
61560
|
61561
|
61562
|
61563
|
61564
|
61565
|
61566
|
61567
|
61568
|
61569
|
61570
|
61571
|
61572
|
61573
|
61574
|
61575