From e30fb761ec225a7797def0c3ab8d2d8bceea7e0c Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 13 Nov 2007 21:07:45 -0600 Subject: [PATCH] Adding a system pref so you can stop users from reserving items that dont belong at their branch Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- admin/systempreferences.pl | 5 +++-- installer/data/mysql/en/mandatory/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 9 +++++++++ kohaversion.pl | 2 +- reserve/request.pl | 14 +++++++++++++- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index f49ac06387..71e2efea51 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -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"; diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 64402b0379..fd77f9e20d 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -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')" + diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5142bca5e6..f96a660764 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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 diff --git a/kohaversion.pl b/kohaversion.pl index 9b16b5315e..6aa0995a4b 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -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; diff --git a/reserve/request.pl b/reserve/request.pl index 65983ab8e2..e7cbad573d 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -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 ) { -- 2.39.5