Bugzilla – Attachment 28033 Details for
Bug 6254
Set default for privacy by patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6254 [1] - Can't set patron privacy by default
Bug-6254-1---Cant-set-patron-privacy-by-default.patch (text/plain), 20.49 KB, created by
Kyle M Hall (khall)
on 2014-05-07 17:51:12 UTC
(
hide
)
Description:
Bug 6254 [1] - Can't set patron privacy by default
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-05-07 17:51:12 UTC
Size:
20.49 KB
patch
obsolete
>From 18667db0534404f66556a65c38dcfb0ff89c3fae Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 5 Dec 2013 07:35:00 -0500 >Subject: [PATCH] Bug 6254 [1] - Can't set patron privacy by default > >There is currently no way to set the privacy setting for newly created >patrons. This patch adds a new field "default privacy" to the patron >categories such that each patron category may have a different default >privacy setting. > >Test Plan: >1) Apply this patch >2) Edit a patron category, change the default privacy to "forever" >3) Create a new patron of that category >4) Log into the catalog as that patron, verify the privacy setting > is set to "forever" >5) Repeat steps 2-4 with the settings "never" and "default" > >Signed-off-by: Joel Sasse <jsasse@plumcreeklibrary.net> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >Bug 6254 [QA Followup 1] - can't set patron privacy by default > >* Adds default privacy column to summary table >* Adds default privacy to delete category summary >* Adds "AFTER categorycode" to the database update >* Whitespace cleanup and formatting for affected code blocks >* Switch basic DBI queries to DBIx::Class to simplify code >* Adds reference to misc/cronjobs/batch_anonymise.pl to description > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >Bug 6254 [QA Followup 2] - can't set patron privacy by default > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >Bug 6254: QA FIX: remove trailing whitespaces > >This patch removes trailing whitespaces/tab and fix the fields order in >the updatedb entry (according to the kohastructure.pl). > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > C4/Members.pm | 10 ++ > admin/categorie.pl | 89 ++++++++------------ > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 ++ > .../prog/en/modules/admin/categorie.tt | 66 ++++++++++++-- > .../prog/en/modules/admin/patron-attr-types.tt | 2 +- > 6 files changed, 112 insertions(+), 63 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index f832495..61eb2d9 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -41,6 +41,7 @@ use Koha::DateUtils; > use Koha::Borrower::Debarments qw(IsDebarred); > use Text::Unaccent qw( unac_string ); > use Koha::AuthUtils qw(hash_password); >+use Koha::Database; > > our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug); > >@@ -836,6 +837,15 @@ sub AddMember { > $data{'dateenrolled'} = C4::Dates->new()->output("iso"); > } > >+ my $patron_category = >+ Koha::Database->new()->schema()->resultset('Category') >+ ->find( $data{'categorycode'} ); >+ $data{'privacy'} = >+ $patron_category->default_privacy() eq 'default' ? 1 >+ : $patron_category->default_privacy() eq 'never' ? 2 >+ : $patron_category->default_privacy() eq 'forever' ? 0 >+ : undef; >+ > # create a disabled account if no password provided > $data{'password'} = ($data{'password'})? hash_password($data{'password'}) : '!'; > $data{'borrowernumber'}=InsertInTable("borrowers",\%data); >diff --git a/admin/categorie.pl b/admin/categorie.pl >index e2ea4c6..ebb91e7 100755 >--- a/admin/categorie.pl >+++ b/admin/categorie.pl >@@ -45,6 +45,7 @@ use C4::Branch; > use C4::Output; > use C4::Dates; > use C4::Form::MessagingPreferences; >+use Koha::Database; > > sub StringSearch { > my ($searchstring,$type)=@_; >@@ -125,23 +126,28 @@ if ($op eq 'add_form') { > }; > } > >- $template->param(description => $data->{'description'}, >- enrolmentperiod => $data->{'enrolmentperiod'}, >- enrolmentperioddate => $data->{'enrolmentperioddate'}, >- upperagelimit => $data->{'upperagelimit'}, >- dateofbirthrequired => $data->{'dateofbirthrequired'}, >- enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'} || 0), >- overduenoticerequired => $data->{'overduenoticerequired'}, >- issuelimit => $data->{'issuelimit'}, >- reservefee => sprintf("%.2f",$data->{'reservefee'} || 0), >- hidelostitems => $data->{'hidelostitems'}, >- category_type => $data->{'category_type'}, >- SMSSendDriver => C4::Context->preference("SMSSendDriver"), >- TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"), >- "type_".$data->{'category_type'} => 1, >- branches_loop => \@branches_loop, >- BlockExpiredPatronOpacActions => $data->{'BlockExpiredPatronOpacActions'}, >- ); >+ $template->param( >+ description => $data->{'description'}, >+ enrolmentperiod => $data->{'enrolmentperiod'}, >+ enrolmentperioddate => $data->{'enrolmentperioddate'}, >+ upperagelimit => $data->{'upperagelimit'}, >+ dateofbirthrequired => $data->{'dateofbirthrequired'}, >+ enrolmentfee => sprintf( "%.2f", $data->{'enrolmentfee'} || 0 ), >+ overduenoticerequired => $data->{'overduenoticerequired'}, >+ issuelimit => $data->{'issuelimit'}, >+ reservefee => sprintf( "%.2f", $data->{'reservefee'} || 0 ), >+ hidelostitems => $data->{'hidelostitems'}, >+ category_type => $data->{'category_type'}, >+ SMSSendDriver => C4::Context->preference("SMSSendDriver"), >+ TalkingTechItivaPhone => >+ C4::Context->preference("TalkingTechItivaPhoneNotification"), >+ "type_" . $data->{'category_type'} => 1, >+ branches_loop => \@branches_loop, >+ BlockExpiredPatronOpacActions => >+ $data->{'BlockExpiredPatronOpacActions'}, >+ default_privacy => $data->{'default_privacy'}, >+ ); >+ > if (C4::Context->preference('EnhancedMessagingPreferences')) { > C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); > } >@@ -169,7 +175,8 @@ if ($op eq 'add_form') { > hidelostitems=?, > overduenoticerequired=?, > category_type=?, >- BlockExpiredPatronOpacActions=? >+ BlockExpiredPatronOpacActions=?, >+ default_privacy=? > WHERE categorycode=?" > ); > $sth->execute( >@@ -185,6 +192,7 @@ if ($op eq 'add_form') { > 'overduenoticerequired', > 'category_type', > 'block_expired', >+ 'default_privacy', > 'categorycode' > ) > ); >@@ -219,7 +227,8 @@ if ($op eq 'add_form') { > hidelostitems, > overduenoticerequired, > category_type, >- BlockExpiredPatronOpacActions >+ BlockExpiredPatronOpacActions, >+ default_privacy > ) > VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"); > $sth->execute( >@@ -235,7 +244,8 @@ if ($op eq 'add_form') { > 'hidelostitems', > 'overduenoticerequired', > 'category_type', >- 'block_expired' >+ 'block_expired', >+ 'default_privacy', > ) > ); > $sth->finish; >@@ -252,40 +262,14 @@ if ($op eq 'add_form') { > ################## DELETE_CONFIRM ################################## > # called by default form, used to confirm deletion of data in DB > } elsif ($op eq 'delete_confirm') { >+ my $schema = Koha::Database->new()->schema(); > $template->param(delete_confirm => 1); > >- my $dbh = C4::Context->dbh; >- my $sth=$dbh->prepare("select count(*) as total from borrowers where categorycode=?"); >- $sth->execute($categorycode); >- my $total = $sth->fetchrow_hashref; >- $sth->finish; >- $template->param(total => $total->{'total'}); >- >- my $sth2=$dbh->prepare("SELECT * FROM categories WHERE categorycode=?"); >- $sth2->execute($categorycode); >- my $data=$sth2->fetchrow_hashref; >- $sth2->finish; >- if ($total->{'total'} >0) { >- $template->param(totalgtzero => 1); >- } >- >- if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00') { >- $data->{'enrolmentperioddate'} = undef; >- } >- $template->param( description => $data->{'description'}, >- enrolmentperiod => $data->{'enrolmentperiod'}, >- enrolmentperioddate => $data->{'enrolmentperioddate'}, >- upperagelimit => $data->{'upperagelimit'}, >- dateofbirthrequired => $data->{'dateofbirthrequired'}, >- enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'} || 0), >- overduenoticerequired => $data->{'overduenoticerequired'}, >- issuelimit => $data->{'issuelimit'}, >- reservefee => sprintf("%.2f",$data->{'reservefee'} || 0), >- hidelostitems => $data->{'hidelostitems'}, >- category_type => $data->{'category_type'}, >- BlockExpiredPatronOpacActions => $data->{'BlockExpiredPatronOpacActions'}, >- ); >- # END $OP eq DELETE_CONFIRM >+ my $count = $schema->resultset('Borrower')->search( { categorycode => $categorycode } )->count(); >+ my $category = $schema->resultset('Category')->find($categorycode); >+ $category->enrolmentperioddate( C4::Dates::format_date( $category->enrolmentperioddate() ) ); >+ $template->param( category => $category, patrons_in_category => $count ); >+# END $OP eq DELETE_CONFIRM > ################## DELETE_CONFIRMED ################################## > # called by delete_confirm, used to effectively confirm deletion of data in DB > } elsif ($op eq 'delete_confirmed') { >@@ -329,6 +313,7 @@ if ($op eq 'add_form') { > reservefee => sprintf("%.2f",$results->[$i]{'reservefee'} || 0), > hidelostitems => $results->[$i]{'hidelostitems'}, > category_type => $results->[$i]{'category_type'}, >+ default_privacy => $results->[$i]{'default_privacy'}, > "type_".$results->[$i]{'category_type'} => 1, > branches => \@selected_branches, > ); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 92ab713..4c9e892 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -467,6 +467,7 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr > `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no) > `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff) > `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions >+ `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category > PRIMARY KEY (`categorycode`), > UNIQUE KEY `categorycode` (`categorycode`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 3b1718c..f09cb6b 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8465,6 +8465,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.15.00.XXX"; >+if(CheckVersion($DBversion)) { >+ $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER category_type"); >+ print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >index 6a64c01..263cc8b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >@@ -2,7 +2,7 @@ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Patron categories › [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] > [% IF ( add_validate ) %]Data recorded[% END %] >-[% IF ( delete_confirm ) %][% IF ( totalgtzero ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] >+[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] > [% IF ( delete_confirmed ) %]Category deleted[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > [% INCLUDE 'calendar.inc' %] >@@ -99,7 +99,7 @@ > > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] > [% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Data recorded[% END %] >-[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( totalgtzero ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] >+[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] > [% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Category deleted[% END %] > [% IF ( else ) %]Patron categories[% END %]</div> > >@@ -186,7 +186,7 @@ > [% END %] > [% END %] > </select> >- <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value. >+ <span>Select <i>All branches</i> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value. > </span> > </li> > <li><label for="block_expired">Block expired patrons</label> >@@ -213,6 +213,26 @@ > Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired. > </span> > </li> >+ <li> >+ <label for="default_privacy">Default privacy: </label> >+ <select id="default_privacy" name="default_privacy"> >+ [% SWITCH default_privacy %] >+ [% CASE 'forever' %] >+ <option value="default">Default</option> >+ <option value="never">Never</option> >+ <option value="forever" selected="selected">Forever</option> >+ [% CASE 'never' %] >+ <option value="default">Default</option> >+ <option value="never" selected="selected">Never</option> >+ <option value="forever">Forever</option> >+ [% CASE %] >+ <option value="default" selected="selected">Default</option> >+ <option value="never">Never</option> >+ <option value="forever">Forever</option> >+ [% END %] >+ </select> >+ <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span> >+ </li> > </ol> > </fieldset> > >@@ -232,16 +252,18 @@ > <form action="[% script_name %]" method="post"> > <input type="submit" value="OK" /> > </form> >- > [% END %] > > [% IF ( delete_confirm ) %] >- >- <form action="[% script_name %]" method="post"> >- <fieldset><legend> >- [% IF ( totalgtzero ) %] >- Category [% categorycode |html %] is in use. Deletion not possible![% ELSE %] >-Confirm deletion of category [% categorycode |html %][% END %]</legend> >+ <form action="[% script_name %]" method="post"> >+ <fieldset> >+ <legend> >+ [% IF ( patrons_in_category > 0 ) %] >+ Category [% categorycode |html %] is in use. Deletion not possible! >+ [% ELSE %] >+ Confirm deletion of category [% categorycode |html %] >+ [% END %] >+ </legend> > > [% IF ( totalgtzero ) %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %] > <table> >@@ -262,6 +284,19 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr> > <tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr> > <tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr> >+ <tr> >+ <th scope="row">Default privacy: </th> >+ <td> >+ [% SWITCH category.default_privacy %] >+ [% CASE 'default' %] >+ Default >+ [% CASE 'never' %] >+ Never >+ [% CASE 'forever' %] >+ Forever >+ [% END %] >+ </td> >+ </tr> > </table> > <fieldset class="action">[% IF ( totalgtzero ) %] > <input type="submit" value="OK" /></form> >@@ -309,6 +344,7 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <th scope="col">Messaging</th> > [% END %] > <th scope="col">Branches limitations</th> >+ <th scope="col">Default privacy</th> > <th scope="col"> </th> > <th scope="col"> </th> > </tr> >@@ -382,6 +418,16 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > No limitation > [% END %] > </td> >+ <td> >+ [% SWITCH loo.default_privacy %] >+ [% CASE 'default' %] >+ Default >+ [% CASE 'never' %] >+ Never >+ [% CASE 'forever' %] >+ Forever >+ [% END %] >+ </td> > <td><a href="[% loo.script_name %]?op=add_form&categorycode=[% loo.categorycode |uri %]">Edit</a></td> > <td><a href="[% loo.script_name %]?op=delete_confirm&categorycode=[% loo.categorycode |uri %]">Delete</a></td> > </tr> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >index e561ae5..2fb8a68 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >@@ -202,7 +202,7 @@ function CheckAttributeTypeForm(f) { > [% END %] > [% END %] > </select> >- <span>Select All if this attribute type must to be displayed all the time. Otherwise select librairies you want to associate with this value. >+ <span>Select All if this attribute type must to be displayed all the time. Otherwise select libraries you want to associate with this value. > </span> > </li> > <li> >-- >1.7.2.5
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 6254
:
19131
|
19132
|
19133
|
19272
|
19631
|
23309
|
23310
|
23317
|
23516
|
23520
|
23983
|
23985
|
23986
|
23987
|
24606
|
24696
|
24697
|
24698
|
24699
| 28033 |
28034
|
28035
|
28036