From 6eea26c7296e0276b9c3beb6b28e31a9eda9a9d2 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Fri, 27 Jan 2023 12:55:17 +0000 Subject: [PATCH] Bug 32721: Database update to add userjs and usercss to branches table This patch adds the columns for userjs and usercss to the branches table Test plan as per previous commit Signed-off-by: Lucas Gass Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- api/v1/swagger/definitions/library.yaml | 10 ++++++++ .../bug_32721-add_branch_level_js.pl | 25 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl diff --git a/api/v1/swagger/definitions/library.yaml b/api/v1/swagger/definitions/library.yaml index de010c50d3..24d88b588f 100644 --- a/api/v1/swagger/definitions/library.yaml +++ b/api/v1/swagger/definitions/library.yaml @@ -107,6 +107,16 @@ properties: public: type: boolean description: If the library is visible to the public + userjs: + type: + - string + - "null" + description: Any branch-specific UserJS for the OPAC + usercss: + type: + - string + - "null" + description: Any branch-specific UserCSS for the OPAC smtp_server: type: - object diff --git a/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl b/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl new file mode 100644 index 0000000000..4471d96eef --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl @@ -0,0 +1,25 @@ +use Modern::Perl; + +return { + bug_number => "32721", + description => "Allow branch specific javascript and css to be injected into the OPAC depending on a branchcode", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + if( !column_exists( 'branches', 'userjs' ) ) { + $dbh->do(q{ + ALTER TABLE branches ADD COLUMN `userjs` longtext DEFAULT NULL AFTER `public` + }); + + say $out "Added column 'branches.userjs'"; + } + if( !column_exists( 'branches', 'usercss' ) ) { + $dbh->do(q{ + ALTER TABLE branches ADD COLUMN `usercss` longtext DEFAULT NULL AFTER `userjs` + }); + + say $out "Added column 'branches.usercss'"; + } + }, +}; \ No newline at end of file diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 022dc50533..21a403fec8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1609,6 +1609,8 @@ CREATE TABLE `branches` ( `marcorgcode` varchar(16) DEFAULT NULL COMMENT 'MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode', `pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'the ability to act as a pickup location', `public` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether this library should show in the opac', + `userjs` longtext DEFAULT NULL COMMENT 'branch specific javascript for the OPAC', + `usercss` longtext DEFAULT NULL COMMENT 'branch specific css for the OPAC', PRIMARY KEY (`branchcode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- 2.39.5