From 104dc80a61a504e698cfa5be736705822b9f447e Mon Sep 17 00:00:00 2001
From: Martin Persson <xarragon@gmail.com>
Date: Thu, 21 May 2015 17:28:14 +0200
Subject: [PATCH] [Signed-off] Bug 14246: Add koha_news.borrowernumber and
 store
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch adds a new column to koha_news that links a
borrowernumber to each item. This allows Koha to display the
author for each entry which makes it suitable as a simple CMS.

Sponsored-by: Halland County Library
Signed-off-by: Marc Véron <veron@veron.ch>
---
 installer/data/mysql/atomicupdate/add_news_author.pl |   12 ++++++++++++
 tools/koha-news.pl                                   |    1 +
 2 files changed, 13 insertions(+)
 create mode 100644 installer/data/mysql/atomicupdate/add_news_author.pl

diff --git a/installer/data/mysql/atomicupdate/add_news_author.pl b/installer/data/mysql/atomicupdate/add_news_author.pl
new file mode 100644
index 0000000..ce6c3dd
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/add_news_author.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use C4::Context;
+
+my $dbh = C4::Context->dbh;
+$dbh->do("ALTER TABLE opac_news ADD borrowernumber INT(11) NULL DEFAULT NULL;");
+$dbh->do("ALTER TABLE opac_news ADD CONSTRAINT fk_borrowernumber FOREIGN KEY (borrowernumber) REFERENCES borrowers(borrowernumber) ON DELETE SET NULL ON UPDATE SET NULL;");
+
+print "Upgrade done (Adding borrowernumber column and foreign key to opac_news)\n";
diff --git a/tools/koha-news.pl b/tools/koha-news.pl
index cf1e2b4..3a6c596 100755
--- a/tools/koha-news.pl
+++ b/tools/koha-news.pl
@@ -114,6 +114,7 @@ elsif ( $op eq 'add' ) {
                 timestamp      => $timestamp,
                 number         => $number,
                 branchcode     => $branchcode,
+                borrowernumber => $borrowernumber,
             }
         );
         print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
-- 
1.7.10.4