[Koha-patches] [PATCH 4/4] Bug 5806: This is my initial baseline commit. mod is driven by a system pref called searchMyLibraryOnly. If it is on then all data not in the logged in users home branch should be filtered (hidden). This system was designed with schools in mind so that several schools can share one library, effectively becoming one branch of the library. Not quite a consortium but inspired by the basic idea of a consortium.

Peter Lorimer peter at oslo.ie
Fri Jun 10 14:54:26 CEST 2011


---
 catalogue/search.pl                                |   36 +------------------
 circ/overdue.pl                                    |    9 +++++
 koha-tmpl/index.html                               |    6 ---
 .../prog/en/modules/catalogue/results.tt           |   12 ++++---
 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt   |    3 ++
 mainpage.pl                                        |    6 +++
 opac/opac-main.pl                                  |   35 ++++++++++++++++++-
 opac/opac-search.pl                                |   19 ++++++++++
 opac/opac-user.pl                                  |   14 ++++++++
 9 files changed, 93 insertions(+), 47 deletions(-)
 delete mode 100644 koha-tmpl/index.html
 mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt
 mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
 mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl

diff --git a/catalogue/search.pl b/catalogue/search.pl
index 8c35011..e1e9a98 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -150,7 +150,6 @@ use C4::Members qw(GetMember);
 use C4::VirtualShelves qw(GetRecentShelves);
 use POSIX qw(ceil floor);
 use C4::Branch; # GetBranches
-use Data::Dumper::Simple;
 
 my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
 # create a new CGI object
@@ -248,7 +247,7 @@ my @itemtypesloop;
 my $selected=1;
 my $cnt;
 my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
-my @newresults1;
+
 if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {                                                                 foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
     my %row =(  number=>$cnt++,
                 ccl => qq($itype_or_itemtype,phr),
@@ -540,9 +539,6 @@ for (my $i=0;$i<@servers;$i++) {
         my $page = $cgi->param('page') || 0;
         my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
                                        @{$results_hashref->{$server}->{"RECORDS"}});
-                                       
-                                       
-                                       
         $total = $total + $results_hashref->{$server}->{"hits"};
         ## If there's just one result, redirect to the detail page
         if ($total == 1) {         
@@ -579,21 +575,7 @@ for (my $i=0;$i<@servers;$i++) {
             }
             $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed;
             $template->param(results_per_page =>  $results_per_page);
-            
-my $i;           
-for  $i (0..scalar @newresults)
-{
-    
-    if (substr($newresults[$i]->{holdingbranch},0,3) eq C4::Branch->mybranch())
-    {
-       push @newresults1,$newresults[$i]; 
-      #print 'Holding Branch: ' . $newresults1[$i]->{holdingbranch} . '<br>Mu Branch:' . C4::Branch->mybranch(). '<hr>';
-    }  
-}
-
-           # $total = scalar @newresults1;
-            $template->param(SEARCH_RESULTS => \@newresults1);
-            #@newresults1 = @newresults;
+            $template->param(SEARCH_RESULTS => \@newresults);
 
             ## FIXME: add a global function for this, it's better than the current global one
             ## Build the page numbers on the bottom of the page
@@ -707,17 +689,3 @@ if (@{$barshelves}) {
 
 
 output_html_with_http_headers $cgi, $cookie, $template->output;
-
-#print Dumper(@newresults1);
-
-print scalar @newresults1;
-my @nr;
-my $i;
-for  $i (0..scalar @newresults1)
-{
-    
-    if (substr($newresults1[$i]->{holdingbranch},0,3) eq C4::Branch->mybranch())
-    {
-      print 'Holding Branch: ' . $newresults1[$i]->{holdingbranch} . '<br>Mu Branch:' . C4::Branch->mybranch(). '<hr>';
-    }  
-}
diff --git a/circ/overdue.pl b/circ/overdue.pl
index 18851a6..6e6aa4f 100755
--- a/circ/overdue.pl
+++ b/circ/overdue.pl
@@ -262,6 +262,12 @@ if ($noreport) {
     LEFT JOIN biblio      ON (biblio.biblionumber=items.biblionumber )
     WHERE 1=1 "; # placeholder, since it is possible that none of the additional
                  # conditions will be selected by user
+    
+ if (C4::Context->preference("searchMyLibraryOnly"))
+ {   
+    $strsth.=" AND issues.branchcode = '" . C4::Branch->mybranch() . "' ";
+  }  
+    
     $strsth.=" AND date_due               < '" . $todaysdate     . "' " unless ($showall);
     $strsth.=" AND (borrowers.firstname like '".$bornamefilter."%' or borrowers.surname like '".$bornamefilter."%' or borrowers.cardnumber like '".$bornamefilter."%')" if($bornamefilter) ;
     $strsth.=" AND borrowers.categorycode = '" . $borcatfilter   . "' " if $borcatfilter;
@@ -301,6 +307,7 @@ if ($noreport) {
             push @patron_attr_value_loop, { value => join(', ', sort { lc $a cmp lc $b } @displayvalues) };
         }
 
+
         push @overduedata, {
             duedate                => format_date($data->{date_due}),
             borrowernumber         => $data->{borrowernumber},
@@ -404,3 +411,5 @@ sub build_csv {
 
     return join("\n", @lines) . "\n";
 }
+
+
diff --git a/koha-tmpl/index.html b/koha-tmpl/index.html
deleted file mode 100644
index 5194d5b..0000000
--- a/koha-tmpl/index.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<body>
-<a href="intranet.html">Intranet</a>
-<a href="opac.html">OPAC</a>
-</body>
-</html>
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
index 95a1c9a..11f2cf4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
@@ -505,20 +505,22 @@ YAHOO.util.Event.onContentReady("searchheader", function () {
 
                                     [% IF ( SEARCH_RESULT.availablecount ) %]
                                     [% SEARCH_RESULT.availablecount %] available:
-                                    <ul>
+                                    <!-- <ul>
                                     [% FOREACH available_items_loo IN SEARCH_RESULT.available_items_loop %]
 
                                         [% IF ( noItemTypeImages ) %]<li>[% ELSE %][% IF ( item_level_itypes ) %][% IF ( available_items_loo.imageurl ) %]<li style="list-style: none; list-style-type: none;"><img src="[% available_items_loo.imageurl %]" title="[% available_items_loo.description %]" alt="[% available_items_loo.description %]" />[% ELSE %]<li>[% END %][% ELSE %]<li>[% END %][% END %]
-                                        [% IF ( available_items_loo.branchname ) %][% available_items_loo.branchname %][% END %]
+                                       [% IF ( available_items_loo.branchname ) %][% available_items_loo.branchname %][% END %]
                                         [% IF ( available_items_loo.location ) %][% available_items_loo.location %][% END %]
                                         [% IF ( available_items_loo.itemcallnumber ) %][<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=[% available_items_loo.itemcallnumber |url %]">[% available_items_loo.itemcallnumber %]</a>][% END %]
                                         ([% available_items_loo.count %])</li>
-                                    [% END %]</ul>
+                                        
+                                        
+                                    [% END %]</ul> -->
                                     [% END %]
 
                                    [% IF ( SEARCH_RESULT.onloancount ) %]
                                    <span class="status">[% SEARCH_RESULT.onloancount %] on loan:</span>
-                                    <ul>
+                                   <!-- <ul>
                                     [% FOREACH onloan_items_loo IN SEARCH_RESULT.onloan_items_loop %]
                                        [% IF ( noItemTypeImages ) %]<li>[% ELSE %][% IF ( item_level_itypes ) %]
                                         [% IF ( onloan_items_loo.imageurl ) %]
@@ -530,7 +532,7 @@ YAHOO.util.Event.onContentReady("searchheader", function () {
                                         [% IF ( onloan_items_loo.location ) %][% onloan_items_loo.location %][% END %]
                                         [% IF ( onloan_items_loo.itemcallnumber ) %][<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=[% onloan_items_loo.itemcallnumber |url %]">[% onloan_items_loo.itemcallnumber %]</a>][% END %]
                                         ([% onloan_items_loo.count %][% IF ( onloan_items_loo.longoverdue ) %], [% onloan_items_loo.longoverdue %] long overdue[% END %]) date due: [% onloan_items_loo.due_date %]</li>
-                                    [% END %]</ul>
+                                    [% END %]</ul> -->
                                     [% END %]
 
                                     [% IF ( SEARCH_RESULT.othercount ) %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt
old mode 100644
new mode 100755
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
old mode 100644
new mode 100755
index 58c6fa5..26c8670
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
@@ -67,6 +67,9 @@ $.tablesorter.addParser({
             });
 //]]>
 </script>
+[% IF (redirect) %]
+<script>location.href='/cgi-bin/koha/opac-main.pl'</script>
+[% END %]
 </head>
 <body id="opac-user">
 <div id="doc3" class="yui-t1">
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
old mode 100644
new mode 100755
diff --git a/mainpage.pl b/mainpage.pl
index 6a0c1af..dfeb6fc 100755
--- a/mainpage.pl
+++ b/mainpage.pl
@@ -24,6 +24,9 @@ use C4::Auth;
 use C4::AuthoritiesMarc;
 use C4::Koha;
 use C4::NewsChannels;
+use Data::Dumper::Simple;
+
+
 my $query     = new CGI;
 my $authtypes = getauthtypes;
 my @authtypesloop;
@@ -65,3 +68,6 @@ $template->param(
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;
+
+
+
diff --git a/opac/opac-main.pl b/opac/opac-main.pl
index 177d812..aeba92b 100755
--- a/opac/opac-main.pl
+++ b/opac/opac-main.pl
@@ -19,6 +19,7 @@
 use strict;
 use warnings;
 use CGI;
+use CGI::Session;
 use C4::Auth;    # get_template_and_user
 use C4::Output;
 use C4::VirtualShelves;
@@ -27,9 +28,13 @@ use C4::Members;         # GetMember
 use C4::NewsChannels;    # get_opac_news
 use C4::Acquisition;     # GetRecentAcqui
 use C4::Languages qw(getTranslatedLanguages accept_language);
+use Data::Dumper::Simple;
+
+
+my $input  = new CGI;
+my $dbh    = C4::Context->dbh;
+my $branch; # = C4::Context->userenv->{branch};
 
-my $input = new CGI;
-my $dbh   = C4::Context->dbh;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
@@ -47,6 +52,8 @@ $template->param(
 );
 
 
+
+
 my $borrower = GetMember( borrowernumber=>$borrowernumber );
 $template->param(
     textmessaging        => $borrower->{textmessaging},
@@ -95,4 +102,28 @@ if (C4::Context->preference('GoogleIndicTransliteration')) {
         $template->param('GoogleIndicTransliteration' => 1);
 }
 
+
+if (defined $input->param("library"))
+{
+    C4::Context->userenv->{branch} = $input->param("library");
+    $template->param(branch=>C4::Context->userenv->{branch});
+     my $session = C4::Auth::get_session("");
+                   C4::Context->set_userenv($session->param('branch',$input->param("library")));
+  
+}
+
+my $xx;
+if ($template->{VARS}{loggedinusername} eq '')
+{
+   
+      print $input->redirect("/index.htm");  
+}
+
+
 output_html_with_http_headers $input, $cookie, $template->output;
+
+
+
+
+
+
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index 68018b6..df7fd0e 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -39,6 +39,7 @@ use C4::Branch; # GetBranches
 use POSIX qw(ceil floor strftime);
 use URI::Escape;
 use Storable qw(thaw freeze);
+use Data::Dumper::Simple;
 
 
 my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
@@ -46,6 +47,7 @@ my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
 # FIXME: no_undef_params needs to be tested
 use CGI qw('-no_undef_params');
 my $cgi = new CGI;
+my @newresults1;
 
 BEGIN {
 	if (C4::Context->preference('BakerTaylorEnabled')) {
@@ -462,6 +464,7 @@ for (my $i=0;$i<@servers;$i++) {
             @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
                                         @{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
         }
+        @newresults1 = @newresults;
 		my $tag_quantity;
 		if (C4::Context->preference('TagsEnabled') and
 			$tag_quantity = C4::Context->preference('TagsShowOnList')) {
@@ -674,3 +677,19 @@ if (C4::Context->preference('GoogleIndicTransliteration')) {
 }
 
 output_with_http_headers $cgi, $cookie, $template->output, $content_type;
+
+#print Dumper(@newresults1);
+
+foreach (@newresults1) {
+				my $bibnum = $_->{biblionumber} or next;
+				$_->{itemsissued} = CountItemsIssued( $bibnum );
+				$_ ->{'TagLoop'} = get_tags({biblionumber=>$bibnum, approved=>1, 'sort'=>'-weight',
+										 });
+
+			}
+			
+			print C4::Branch->mybranch();
+			#print Dumper($template);
+			
+			
+			#print Dumper($template);
\ No newline at end of file
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index a2f7d9b..5a5355f 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -35,6 +35,7 @@ use C4::Items;
 use C4::Dates qw/format_date/;
 use C4::Letters;
 use C4::Branch; # GetBranches
+use Data::Dumper::Simple;
 
 use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
 
@@ -64,6 +65,8 @@ my $patronupdate = $query->param('patronupdate');
 # get borrower information ....
 my ( $borr ) = GetMemberDetails( $borrowernumber );
 
+
+
 for (qw(dateenrolled dateexpiry dateofbirth)) {
     ($borr->{$_}) and $borr->{$_} = format_date($borr->{$_});
 }
@@ -323,5 +326,16 @@ $template->param(
     dateformat    => C4::Context->preference("dateformat"),
 );
 
+
+
+
+if ($borr->{userid} eq $borr->{branchcode})
+{
+    $template->param(redirect=>1);
+    #print $query->redirect('/cgi-bin/koha/opac-main.pl');    
+}
+
+
 output_html_with_http_headers $query, $cookie, $template->output;
 
+
-- 
1.7.4.1



More information about the Koha-patches mailing list