From 19d2dfb733b0ec6b66228462678d016891334138 Mon Sep 17 00:00:00 2001 From: Brendan Gallagher Date: Wed, 27 Apr 2016 16:24:18 +0000 Subject: [PATCH] DBRev for Bug 14686 - New menu option and permission for file uploading Signed-off-by: Brendan Gallagher --- Koha.pm | 2 +- .../mysql/atomicupdate/14686_permissions.sql | 20 ------------- installer/data/mysql/updatedatabase.pl | 29 +++++++++++++++++++ 3 files changed, 30 insertions(+), 21 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/14686_permissions.sql diff --git a/Koha.pm b/Koha.pm index 91b16e3b18..41f4f314b7 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.23.00.051"; +$VERSION = "3.23.00.052"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/14686_permissions.sql b/installer/data/mysql/atomicupdate/14686_permissions.sql deleted file mode 100644 index 24b4747842..0000000000 --- a/installer/data/mysql/atomicupdate/14686_permissions.sql +++ /dev/null @@ -1,20 +0,0 @@ --- Insert permission -INSERT IGNORE INTO permissions (module_bit, code, description) VALUES - (13, 'upload_general_files', 'Upload any file'), - (13, 'upload_manage', 'Manage uploaded files'); - --- Update user_permissions for current users (check count in uploaded_files) --- Note 9 == edit_catalogue and 13 == tools --- We do not insert if someone is superlibrarian, does not have edit_catalogue, --- or already has all tools -INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) - SELECT borrowernumber, 13, 'upload_general_files' - FROM borrowers bo - WHERE flags<>1 AND flags & POW(2,13) = 0 AND - ( flags & POW(2,9) > 0 OR ( - SELECT COUNT(*) FROM user_permissions - WHERE borrowernumber=bo.borrowernumber AND module_bit=9 ) > 0 ) - AND ( SELECT COUNT(*) FROM uploaded_files ) > 0 - -# Copy-paste for RM use: -# print "Upgrade to $DBversion done (Bug 14686 - New menu option and permission for file uploading)\n"; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index cf02734e6e..f99419bc43 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -12364,6 +12364,35 @@ $dbh->do(q{ } +$DBversion = "3.23.00.052"; +if ( CheckVersion($DBversion) ) { +## Insert permission + + $dbh->do(q{ + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES + (13, 'upload_general_files', 'Upload any file'), + (13, 'upload_manage', 'Manage uploaded files'); + }); +## Update user_permissions for current users (check count in uploaded_files) +## Note 9 == edit_catalogue and 13 == tools +## We do not insert if someone is superlibrarian, does not have edit_catalogue, +## or already has all tools + + $dbh->do(q{ + INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) + SELECT borrowernumber, 13, 'upload_general_files' + FROM borrowers bo + WHERE flags<>1 AND flags & POW(2,13) = 0 AND + ( flags & POW(2,9) > 0 OR + (SELECT COUNT(*) FROM user_permissions + WHERE borrowernumber=bo.borrowernumber AND module_bit=9 ) > 0 ) + AND ( SELECT COUNT(*) FROM uploaded_files ) > 0 + }); + + print "Upgrade to $DBversion done (Bug 14686 - New menu option and permission for file uploading)\n"; + +} + # 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