From 0d4c0ffb84a2992d04a96fef865b8e1c2f8c2086 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Mon, 5 Feb 2001 18:48:15 +0000 Subject: [PATCH] loadmodules.pl allows redirection to different modules based on systemprefs Added subroutine in Search.pm load systemprefs from new systempreferences table in database. Initial use is to allow using my simplified acquisitions module in place of vendor-based acquisitions module. Default is vendor-based module. --- C4/Search.pm | 16 +++++++++++++++- loadmodules.pl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 loadmodules.pl diff --git a/C4/Search.pm b/C4/Search.pm index 8ac5f340bb..016dc6a6c1 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -19,7 +19,7 @@ $VERSION = 0.01; &itemdata &bibdata &GetItems &borrdata &getacctlist &itemnodata &itemcount &OpacSearch &borrdata2 &NewBorrowerNumber &bibitemdata &borrissues &getboracctrecord &ItemType &itemissues &FrontSearch &subject &subtitle -&addauthor &bibitems &barcodes &findguarantees &allissues); +&addauthor &bibitems &barcodes &findguarantees &allissues &systemprefs); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -1148,6 +1148,20 @@ sub barcodes{ return(@barcodes); } + +sub systemprefs { + my %systemprefs; + my $dbh=C4Connect; + my $sth=$dbh->prepare("select variable,value from systempreferences"); + $sth->execute; + while (my ($variable,$value)=$sth->fetchrow) { + $systemprefs{$variable}=$value; + } + $sth->finish; + $dbh->disconnect; + return(%systemprefs); +} + END { } # module clean-up code here (global destructor) diff --git a/loadmodules.pl b/loadmodules.pl new file mode 100755 index 0000000000..1f4c8cb7f0 --- /dev/null +++ b/loadmodules.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +#script to show list of budgets and bookfunds +#written 4/2/00 by chris@katipo.co.nz +#called as an include by the acquisitions index page + +use C4::Acquisitions; +use C4::Search; +use CGI; +my $input=new CGI; + +my $module=$input->param('module'); + +SWITCH: { + if ($module eq 'acquisitions') { acquisitions(); last SWITCH; } + if ($module eq 'somethingelse') { somethingelse(); last SWITCH; } +} + + +sub acquisitions { + my %systemprefs=systemprefs(); + ($systemprefs{'acquisitions'}) || ($systemprefs{'acquisitions'}='normal'); + if ($systemprefs{'acquisitions'} eq 'simple') { + print $input->redirect("/cgi-bin/koha/acqui.simple/addbooks.pl"); + } elsif ($systemprefs{'acquisitions'} eq 'normal') { + print $input ->redirect("/acquisitions"); + } else { + print $input ->redirect("/acquisitions"); + } +} + + +sub somethingelse { +# just an example subroutine +} -- 2.39.5