Adding a system pref so you can stop users from reserving items that dont belong...
authorChris Cormack <chris@snaga.liblime.co.nz>
Wed, 14 Nov 2007 03:07:45 +0000 (21:07 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 14 Nov 2007 03:24:23 +0000 (21:24 -0600)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/systempreferences.pl
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/updatedatabase.pl
kohaversion.pl
reserve/request.pl

index f49ac06..71e2efe 100755 (executable)
@@ -75,8 +75,8 @@ my %tabsysprefs;
 # Authorities
     $tabsysprefs{authoritysep}="Authorities";
     $tabsysprefs{AuthDisplayHierarchy}="Authorities";
-       $tabsysprefs{dontmerge}="Authorities";
-       $tabsysprefs{BiblioAddsAuthorities}="Authorities";
+    $tabsysprefs{dontmerge}="Authorities";
+    $tabsysprefs{BiblioAddsAuthorities}="Authorities";
 # Catalogue
     $tabsysprefs{advancedMARCEditor}="Catalogue";
     $tabsysprefs{autoBarcode}="Catalogue";
@@ -116,6 +116,7 @@ my %tabsysprefs;
     $tabsysprefs{useDaysMode}="Circulation";
     $tabsysprefs{ReservesNeedReturns}="Circulation";
     $tabsysprefs{CircAutocompl}="Circulation";
+    $tabsysprefs{canreservefromotherbranches}="Circulation";
 
 # Intranet
     $tabsysprefs{TemplateEncoding}="Intranet";
index 64402b0..fd77f9e 100644 (file)
@@ -114,3 +114,5 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('QueryFuzzy','1','If ON, enables fuzzy option for searches',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('QueryWeightFields','1','If ON, enables field weighting',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries',NULL,'free');
+INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')"
+
index 5142bca..f96a660 100755 (executable)
@@ -661,6 +661,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.00.00.028";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
+       VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')");
+    print "Upgrade to $DBversion done (adding new system preference for changing reserve/holds behaviour with independent branches)\n";
+    SetVersion ($DBversion);
+}
+
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table
index 9b16b53..6aa0995 100644 (file)
@@ -8,7 +8,7 @@
 #        and is automatically called by Auth.pm when needed.
 
 sub kohaversion {
-    return "3.00.00.027";
+    return "3.00.00.028";
 }
 
 1;
index 65983ab..e7cbad5 100755 (executable)
@@ -317,13 +317,25 @@ foreach my $biblioitemnumber (@biblioitemnumbers) {
 
         # If there is no loan, return and transfer, we show a checkbox.
         $item->{notforloan} = $item->{notforloan} || 0;
-
+       
+       # if independent branches is on we need to check if the person can reserve
+       # for branches they arent logged in to
+       if ( C4::Context->preference("IndependantBranches") ) { 
+           if (! C4::Context->preference("canreservefromotherbranches")){
+               # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
+               my $userenv = C4::Context->userenv; 
+               if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+                   $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
+               } 
+           }
+       }
         # An item is available only if:
         if (
             not defined $reservedate    # not reserved yet
             and $issues->{'date_due'} eq ''         # not currently on loan
             and not $item->{itemlost}   # not lost
             and not $item->{notforloan} # not forbidden to loan
+           and not $item->{cantreserve}
             and $transfertwhen eq ''    # not currently on transfert
           )
         {