Bug 11759: (QA followup) Sysprefs should be kosher
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 19 Oct 2015 18:19:28 +0000 (15:19 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 20 Oct 2015 13:46:42 +0000 (10:46 -0300)
The introduced syspref was defined before we added new guidelines
for them. This patch puts them in sync with current standards. It also
splits them into:

 - A big on/off switch (BatchCheckouts)
 - Patron category filter (BatchCheckoutsValidCategories)

The latter is expected to go away if we move this into a boolean column
on the 'categories' table, which seems a better approach. I'm filling a
new bug for this last comment.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
circ/circulation.pl
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref

index ed470ec..828ed89 100755 (executable)
@@ -114,9 +114,9 @@ my $borrowernumber = $query->param('borrowernumber');
 my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
 my $batch = $query->param('batch');
 my $batch_allowed = 0;
-if ( $batch ) {
+if ( $batch && C4::Context->preference('BatchCheckouts') ) {
     $template_name = q|circ/circulation_batch_checkouts.tt|;
-    my @batch_category_codes = split '\|', C4::Context->preference('batch_checkouts');
+    my @batch_category_codes = split '\|', C4::Context->preference('BatchCheckoutsValidCategories');
     if ( grep {/^$borrower->{categorycode}$/} @batch_category_codes ) {
         $batch_allowed = 1;
     } else {
index 9e7b98b..578ab79 100644 (file)
@@ -63,7 +63,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Free'),
 ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Free'),
 ('BasketConfirmations','1','always ask for confirmation.|do not ask for confirmation.','When closing or reopening a basket,','Choice'),
-('batch_checkouts','',NULL,'Allow patron categories allowed to checkout in a batch','Free'),
+('BatchCheckouts','0','','Enable or disable batch checkouts','YesNo'),
+('BatchCheckoutsValidCategories','',NULL,'Patron categories allowed to checkout in a batch','Free'),
 ('BiblioAddsAuthorities','0',NULL,'If ON, adding a new biblio will check for an existing authority record and create one on the fly if one doesn\'t exist','YesNo'),
 ('BiblioDefaultView','normal','normal|marc|isbd','Choose the default detail view in the catalog; choose between normal, marc or isbd','Choice'),
 ('BibtexExportAdditionalFields',  '', NULL ,  'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.',  'textarea'),
index 152df42..c53b47f 100755 (executable)
@@ -11121,10 +11121,14 @@ if ( CheckVersion($DBversion) ) {
 }
 
 $DBversion = "3.21.00.XXX";
-if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
+        VALUES ('BatchCheckouts','0','','Enable or disable batch checkouts','YesNo')
+    |);
     $dbh->do(q|
         INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
-        VALUES ('batch_checkouts','','','Allow patron categories allowed to checkout in a batch','Free')
+        VALUES ('BatchCheckoutsValidCategories','',NULL,'Patron categories allowed to checkout in a batch','Free')
     |);
     print "Upgrade to $DBversion done (Bug 11759: Add batch_checkouts system preference)\n";
     SetVersion($DBversion);
index 12c1e98..8c058f1 100644 (file)
@@ -64,7 +64,8 @@
 <div id="menu">
 <ul>
     [% IF ( circview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% borrowernumber %]">Check out</a></li>
-    [% IF Koha.Preference('batch_checkouts').split('\|').grep(categorycode).size > 0 %]
+    [% IF Koha.Preference('BatchCheckouts') &&
+          Koha.Preference('BatchCheckoutsValidCategories').split('\|').grep(categorycode).size > 0 %]
       [% IF ( batch_checkout_view ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% borrowernumber %]&amp;batch=1">Batch check out</a></li>
     [% END %]
     [% IF ( CAN_user_borrowers ) %]
index 8b13ac1..d0d2aca 100644 (file)
@@ -714,6 +714,12 @@ Circulation:
             - course reserves
     Batch checkout:
         -
-            - "Allow some patron categories to checkout in a batch"
-            - pref: batch_checkouts
-            - "(list of patron category separated with a pipe '|')"
+            - pref: BatchCheckouts
+              choices:
+                  yes: Allow
+                  no: "Don't allow"
+            - "batch checkouts"
+        -
+            - "Patron categories allowed to checkout in a batch"
+            - pref: BatchCheckoutsValidCategories
+            - "(list of patron categories separated with a pipe '|')"