Use C4::Context->preference, rather than getting all system
authorarensb <arensb>
Sat, 5 Oct 2002 23:56:13 +0000 (23:56 +0000)
committerarensb <arensb>
Sat, 5 Oct 2002 23:56:13 +0000 (23:56 +0000)
preferences and picking out only what's needed.

acqui/acquire.pl
acqui/newbiblio.pl
loadmodules.pl
memberentry.pl

index edb3ffe..53cc6c6 100755 (executable)
@@ -171,8 +171,10 @@ print <<EOP
 EOP
 ;
 
-my %systemprefs=systemprefs();
-if ($systemprefs{'autoBarcode'} eq '1') {
+my $auto_barcode = C4::Context->preference("autoBarcode") || 0;
+       # See whether barcodes should be automatically allocated.
+       # Defaults to 0, meaning "no".
+if ($auto_barcode eq '1') {
   my $dbh = C4::Context->dbh;
   my $query="Select barcode from items order by barcode desc";
   my $sth=$dbh->prepare($query);
index cd12eb4..97d11eb 100755 (executable)
@@ -231,8 +231,10 @@ print <<printend
 printend
 ;
 
-my %systemprefs=systemprefs();
-if ($systemprefs{'autoBarcode'} eq '1') {
+my $auto_barcode = C4::Context->preference("autoBarcode") || 0;
+       # See whether barcodes should be automatically allocated.
+       # Defaults to 0, meaning "no".
+if ($auto_barcode eq '1') {
   my $dbh = C4::Context->dbh;
   my $query="Select barcode from items order by barcode desc";
   my $sth=$dbh->prepare($query);
index 93e9115..7d36887 100755 (executable)
@@ -22,6 +22,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+use C4::Context;
 use C4::Acquisitions;
 use C4::Biblio;
 use C4::Search;
@@ -37,15 +38,15 @@ SWITCH: {
 
 
 sub acquisitions {
-    # FIXME
-    # instead of getting a hash, then reading/writing to it at least twice 
-    # and up to four times, maybe this should be a different function -
-    # areAquisitionsSimple() which returns a boolean
-    my %systemprefs=systemprefs();
-    ($systemprefs{'acquisitions'}) || ($systemprefs{'acquisitions'}='normal');
-    if ($systemprefs{'acquisitions'} eq 'simple') {
+    my $aq_type = C4::Context->preference("acquisitions") || "normal";
+               # Get the acquisition preference. This should be:
+               #       "simple" - minimal information required
+               #       "normal" - full information required
+               #       other - Same as "normal"
+
+    if ($aq_type eq 'simple') {
        print $input->redirect("/cgi-bin/koha/acqui.simple/addbooks.pl");
-    } elsif ($systemprefs{'acquisitions'} eq 'normal') {
+    } elsif ($aq_type eq 'normal') {
        print $input ->redirect("/acquisitions");
     } else {
        print $input ->redirect("/acquisitions");
index d1c56ad..d9c0804 100755 (executable)
@@ -61,12 +61,15 @@ if ($delete){
   }
   
   my $cardnumber=$data->{'cardnumber'};
-  my %systemprefs=systemprefs();
+  my $autonumber_members = C4::Context->preference("autoMemberNum") || 0;
+               # Find out whether member numbers should be generated
+               # automatically. Should be either "1" or something else.
+               # Defaults to "0", which is interpreted as "no".
   # FIXME
   # This logic should probably be moved out of the presentation code.
   # Not tonight though.
   #
-  if ($cardnumber eq '' && $systemprefs{'autoMemberNum'} eq '1') {
+  if ($cardnumber eq '' && $autonumber_members eq '1') {
     my $dbh = C4::Context->dbh;
     my $query="select max(substring(borrowers.cardnumber,2,7)) from borrowers";
     my $sth=$dbh->prepare($query);