From 740e362dde31ee5d3ab82c5fac7542cb430d7dbc Mon Sep 17 00:00:00 2001 From: tonnesen Date: Fri, 26 Jul 2002 18:23:54 +0000 Subject: [PATCH] Added flags to borrowers table and userflags table. Also, OPAC scripts now check for the existence of a file named 'opac' in the directory they are run from and set the $type variable to 'opac' if it exists. No longer have to "trust" that the type query parameter is correct. --- Install.pm | 1 + detail.pl | 1 + koha.upgrade | 1 + search.pl | 2 + subjectsearch.pl | 1 + updater/updatedatabase | 91 +++++++++++++++++++++++++++++++++--------- 6 files changed, 78 insertions(+), 19 deletions(-) diff --git a/Install.pm b/Install.pm index 49802ece7f..e269a3ca09 100644 --- a/Install.pm +++ b/Install.pm @@ -946,6 +946,7 @@ sub installfiles { system("cp -R opac-html/* $::opacdir/htdocs/"); print getmessage('CopyingFiles', ['opac-cgi', "$::opacdir/cgi-bin" ]); system("cp -R opac-cgi/* $::opacdir/cgi-bin/"); + system("touch $::opacdir/cgi-bin/opac"); system("chown -R root.$::httpduser $::opacdir"); system("chown -R root.$::httpduser $::intranetdir"); diff --git a/detail.pl b/detail.pl index 70b9316117..7b8d006bcc 100755 --- a/detail.pl +++ b/detail.pl @@ -10,6 +10,7 @@ use C4::Auth; my $query=new CGI; my $type=$query->param('type'); +(-e "opac") && ($type='opac'); ($type) || ($type='intra'); my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0)); diff --git a/koha.upgrade b/koha.upgrade index 376d4ed3a0..32c2218590 100644 --- a/koha.upgrade +++ b/koha.upgrade @@ -310,6 +310,7 @@ print "Copying opac-html files to $opacdir/htdocs...\n"; system("cp -R opac-html/* $opacdir/htdocs/"); print "Copying opac-cgi files to $opacdir/cgi-bin...\n"; system("cp -R opac-cgi/* $opacdir/cgi-bin/"); +system("touch $::opacdir/cgi-bin/opac"); system("chown -R root.$httpduser $opacdir"); system("chown -R root.$httpduser $intranetdir"); diff --git a/search.pl b/search.pl index bc7884ebff..c015701c14 100755 --- a/search.pl +++ b/search.pl @@ -10,6 +10,8 @@ use C4::Output; # no contains picktemplate my $query=new CGI; my $type=$query->param('type'); +(-e "opac") && ($type='opac'); + my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0)); diff --git a/subjectsearch.pl b/subjectsearch.pl index d26be680f3..1cfd2c2a71 100755 --- a/subjectsearch.pl +++ b/subjectsearch.pl @@ -12,6 +12,7 @@ use C4::Output; my $input = new CGI; print $input->header; my $type=$input->param('type'); +(-e "opac") && ($type='opac'); print startpage(); print startmenu($type); my $blah; diff --git a/updater/updatedatabase b/updater/updatedatabase index af1b8058a5..5bc5b72bf1 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -21,7 +21,7 @@ use DBI; # Koha modules use C4::Database; -my $debug=0; +my $debug=1; my ( $sth, $sti, @@ -42,6 +42,11 @@ my %requiretables=( shelfcontents=>"( shelfnumber int not null, itemnumber int not null, flags int)", + userflags=>"( bit int not null, + flag char(30), + flagdesc char(255), + defaulton int + )", bookshelf=>"( shelfnumber int auto_increment primary key, shelfname char(255))", z3950queue=>"( id int auto_increment primary key, @@ -109,7 +114,8 @@ my %requirefields=( aqbooksellers=>{'invoicedisc' =>'float(6,4)', 'nocalc' => 'int(11)'}, borrowers=>{'userid' => 'char(30)', - 'password' => 'char(30)',}, + 'password' => 'char(30)', + 'flags' => 'int',}, aqorders=>{'budgetdate' => 'date'}, ); @@ -119,6 +125,33 @@ my %defaultprefs=( 'acquisitions'=> 'simple', ); + + + +# The uniquefieldrequired hash entry is used to determine which (if any) fields +# must not exist in the table for this row to be inserted. + +my %tabledata=( + userflags => [ + { uniquefieldrequired => 'bit', bit => 0, flag => 'superlibrarian', flagdesc => 'Access to all librarian functions', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 1, flag => 'circulate', flagdesc => 'Circulate books', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 2, flag => 'catalogue', flagdesc => 'Catalogue books', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 3, flag => 'parameters', flagdesc => 'Set Koha system paramters', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 4, flag => 'borrowers', flagdesc => 'Add or modify borrowers', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 5, flag => 'permissions', flagdesc => 'Set user permissions', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 6, flag => 'reserveforothers', flagdesc => 'Reserve books for patrons', defaulton => 0 }, + { uniquefieldrequired => 'bit', bit => 7, flag => 'borrow', flagdesc => 'Borrow books', defaulton => 1 }, + { uniquefieldrequired => 'bit', bit => 8, flag => 'reserveforself', flagdesc => 'Reserve books for self', defaulton => 0 }, + ], + systempreferences => [ + { uniquefieldrequired => 'variable', variable => 'autoMemberNum', value => '1' }, + { uniquefieldrequired => 'variable', variable => 'acquisitions', value => 'simple' }, + ], + +); + + + #------------------- # Initialize my $dbh=C4Connect; @@ -281,23 +314,37 @@ unless ($branchcategories{'codedescription'} eq 'text') { } -# Populate systempreferences if it is empty - -foreach $prefitem ( keys %defaultprefs ) { - $sth=$dbh->prepare("select value - from systempreferences - where variable=?"); - $sth->execute($prefitem); - unless ($sth->rows) { - print "Adding system preference item $prefitem with value " . - $defaultprefs{$prefitem} ."\n"; - $sti=$dbh->prepare(" - insert into systempreferences (variable, value) - values (?,?)"); - $sti->execute($prefitem,$defaultprefs{$prefitem}); - } # unless -} # foreach - +# Populate tables with required data + +foreach my $table (keys %tabledata) { + print "Checking for data required in table $table...\n"; + my $tablerows=$tabledata{$table}; + foreach my $row (@$tablerows) { + my $uniquefieldrequired=$row->{uniquefieldrequired}; + my $uniquevalue=$row->{$uniquefieldrequired}; + my $sth=$dbh->prepare("select $uniquefieldrequired from $table where $uniquefieldrequired=?"); + $sth->execute($uniquevalue); + unless ($sth->rows) { + print "Adding row to $table: "; + my @values; + my $fieldlist; + my $placeholders; + foreach my $field (keys %$row) { + (next) if ($field eq 'uniquefieldrequired'); + my $value=$row->{$field}; + push @values, $value; + print " $field => $value"; + $fieldlist.="$field,"; + $placeholders.="?,"; + } + print "\n"; + $fieldlist=~s/,$//; + $placeholders=~s/,$//; + my $sth=$dbh->prepare("insert into $table ($fieldlist) values ($placeholders)"); + $sth->execute(@values); + } + } +} $sth->finish; $dbh->disconnect; @@ -305,6 +352,12 @@ $dbh->disconnect; exit; # $Log$ +# Revision 1.4.2.19 2002/07/26 18:23:54 tonnesen +# Added flags to borrowers table and userflags table. Also, OPAC scripts now +# check for the existence of a file named 'opac' in the directory they are run +# from and set the $type variable to 'opac' if it exists. No longer have to +# "trust" that the type query parameter is correct. +# # Revision 1.4.2.18 2002/07/20 22:28:13 rangi # Fixing missing column (budgetdate) in aqorders # re bug 69 -- 2.39.5