From ba3a392714f71a2083d45ec1274089bc53d211b8 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Mon, 20 May 2013 17:57:39 +0200
Subject: [PATCH] Bug 9032: Share a list: OPAC foundation
Content-Type: text/plain; charset=utf-8

Adds a Share button for OPAC private lists
Adds template and script for further development

Test plan:
Toggle the pref OpacAllowSharingPrivateList.
If enabled, you should see the Share button in OPAC/Private lists.
Click on the Share button. You should get Share a list.
Logout and try to go back to opac/opac-shareshelf.pl
It should now present you the login form.
---
 .../opac-tmpl/prog/en/modules/opac-shareshelf.tt   |   28 ++++++++++++
 .../opac-tmpl/prog/en/modules/opac-shelves.tt      |    7 +++
 opac/opac-shareshelf.pl                            |   45 ++++++++++++++++++++
 3 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-shareshelf.tt
 create mode 100755 opac/opac-shareshelf.pl

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shareshelf.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shareshelf.tt
new file mode 100644
index 0000000..7d3f817
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shareshelf.tt
@@ -0,0 +1,28 @@
+[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Share a list
+[% INCLUDE 'doc-head-close.inc' %]
+</head>
+<body id="opac-shareshelf">
+<div id="doc3" class="yui-t1">
+<div id="bd">
+[% INCLUDE 'masthead.inc' %]
+
+<div id="yui-main">
+  <div class="yui-b"><div class="yui-g">
+	<h1>Share a list</h1>
+    <p>Here follows the stuff for shelfnumber [% shelfnumber %]</p>
+</div>
+</div>
+</div>
+
+
+[% IF ( OpacNav ) %]
+  <div class="yui-b">
+  <div id="opacnav" class="container">
+  [% INCLUDE 'navigation.inc' %]
+  </div>
+  </div>
+[% END %]
+
+</div>
+</div>
+[% INCLUDE 'opac-bottom.inc' %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt
index 66ff9bc..dbb9b87 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt
@@ -1,3 +1,4 @@
+[% USE Koha %]
 [% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnList ) %]
 [% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnList ) %]
 
@@ -629,7 +630,13 @@ $(document).ready(function() {
                               [% ELSE %]
                                     <input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
                               [% END %]
+                              </form>
+                              [% IF Koha.Preference('OpacAllowSharingPrivateLists') %]
+                                <form action="opac-shareshelf.pl" method="post">
+                                  <input type="hidden" name="shelfnumber" value="[% shelveslooppri.shelf %]" />
+                                  <input type="submit" class="Share" value="Share" />
                                 </form>
+                              [% END %]
                             [% END %]&nbsp;
                             </td>
                           </tr>
diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl
new file mode 100755
index 0000000..914fcad
--- /dev/null
+++ b/opac/opac-shareshelf.pl
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+# Copyright 2013 Rijksmuseum
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use strict;
+use warnings;
+
+use CGI;
+
+use C4::Auth;
+use C4::Output;
+use C4::VirtualShelves;
+
+my $query= new CGI;
+my $shelfno= $query->param('shelfnumber')||0;
+
+my ($template, $loggedinuser, $cookie)= get_template_and_user({
+        template_name   => "opac-shareshelf.tmpl",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => 0, #should be a user
+});
+
+#TODO Check: pref value OpacAllowSharingPrivateList
+#TODO Check: only owner can share a list
+
+$template->param(
+    shelfnumber         => $shelfno,
+);
+output_html_with_http_headers $query, $cookie, $template->output;
-- 
1.7.7.6