From e0c926e0104e3fb73d80d8bea07ea8b6f90807b3 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 23 Sep 2015 06:27:21 +1200 Subject: [PATCH] Bug 14298: Update database --- Koha.pm | 2 +- ...d_permissions_circulate_self_checkout.perl | 27 -------------- installer/data/mysql/updatedatabase.pl | 37 +++++++++++++++++++ 3 files changed, 38 insertions(+), 28 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_14298_add_permissions_circulate_self_checkout.perl diff --git a/Koha.pm b/Koha.pm index 69df817c24..e1e2e2315d 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "3.20.03.002"; +$VERSION = "3.20.03.003"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_14298_add_permissions_circulate_self_checkout.perl b/installer/data/mysql/atomicupdate/bug_14298_add_permissions_circulate_self_checkout.perl deleted file mode 100644 index 9ec23a051b..0000000000 --- a/installer/data/mysql/atomicupdate/bug_14298_add_permissions_circulate_self_checkout.perl +++ /dev/null @@ -1,27 +0,0 @@ -use Modern::Perl; - -use C4::Context; -my $dbh = C4::Context->dbh; - -$dbh->do(q| - INSERT INTO permissions (module_bit, code, description) - VALUES (1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID') -|); - -my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID'); - -$dbh->do(q| - UPDATE borrowers - SET flags=0 - WHERE userid=? -|, undef, $AutoSelfCheckID); - -$dbh->do(q| - DELETE FROM user_permissions - WHERE borrowernumber=(SELECT borrowernumber FROM borrowers WHERE userid=?) -|, undef, $AutoSelfCheckID); - -$dbh->do(q| - INSERT INTO user_permissions(borrowernumber, module_bit, code) - SELECT borrowernumber, 1, 'self_checkout' FROM borrowers WHERE userid=? -|, undef, $AutoSelfCheckID); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index ad799b058a..7037765981 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -10609,6 +10609,43 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.20.03.003"; +if ( CheckVersion($DBversion) ) { + $dbh->do( + q| + INSERT INTO permissions (module_bit, code, description) + VALUES (1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID') + | + ); + + my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID'); + + $dbh->do( + q| + UPDATE borrowers + SET flags=0 + WHERE userid=? + |, undef, $AutoSelfCheckID + ); + + $dbh->do( + q| + DELETE FROM user_permissions + WHERE borrowernumber=(SELECT borrowernumber FROM borrowers WHERE userid=?) + |, undef, $AutoSelfCheckID + ); + + $dbh->do( + q| + INSERT INTO user_permissions(borrowernumber, module_bit, code) + SELECT borrowernumber, 1, 'self_checkout' FROM borrowers WHERE userid=? + |, undef, $AutoSelfCheckID + ); + print +"Upgrade to $DBversion done (Bug 14298: AutoSelfCheckID user should only be able to access SCO )\n"; + SetVersion($DBversion); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5