From 4915ed786c8c275f2e49c19149629242e5bef9ba Mon Sep 17 00:00:00 2001 From: truth_nz Date: Sun, 12 May 2002 15:37:53 +0000 Subject: [PATCH] New files, and changes to add associated webstes to a biblio. Adds a new table to database - so installer needs updating again. --- C4/Acquisitions.pm | 56 +++++++++++++++++++++++++++++++++- C4/Search.pm | 24 ++++++++++++++- addwebsite.pl | 24 +++++++++++++++ database.mysql | 12 ++++++++ deletewebsite.pl | 21 +++++++++++++ detail.pl | 50 +++++++++++++++++++++++++++++-- modbib.pl | 1 + modwebsites.pl | 75 ++++++++++++++++++++++++++++++++++++++++++++++ updatewebsite.pl | 32 ++++++++++++++++++++ 9 files changed, 291 insertions(+), 4 deletions(-) create mode 100755 addwebsite.pl create mode 100755 deletewebsite.pl create mode 100755 modwebsites.pl create mode 100755 updatewebsite.pl diff --git a/C4/Acquisitions.pm b/C4/Acquisitions.pm index f0cd5bdb74..a4d5d65a8a 100644 --- a/C4/Acquisitions.pm +++ b/C4/Acquisitions.pm @@ -19,7 +19,7 @@ $VERSION = 0.01; &getallorders &getrecorders &updatecurrencies &getorder &getcurrency &updaterecorder &updatecost &checkitems &modnote &getitemtypes &getbiblio &getbiblioitem &getitemsbybiblioitem &isbnsearch &keywordsearch -&websitesearch); +&websitesearch &addwebsite &updatewebsite &deletewebsite); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -1342,4 +1342,58 @@ biblio.biblionumber = biblioitems.biblionumber and ("; } # sub websitesearch +sub addwebsite { + my ($website) = @_; + my $dbh = C4Connect; + my $query; + + $website->{'biblionumber'} = $dbh->quote($website->{'biblionumber'}); + $website->{'title'} = $dbh->quote($website->{'title'}); + $website->{'description'} = $dbh->quote($website->{'description'}); + $website->{'url'} = $dbh->quote($website->{'url'}); + + $query = "Insert into websites set +biblionumber = $website->{'biblionumber'}, +title = $website->{'title'}, +description = $website->{'description'}, +url = $website->{'url'}"; + + $dbh->do($query); + + $dbh->disconnect; +} # sub website + + +sub updatewebsite { + my ($website) = @_; + my $dbh = C4Connect; + my $query; + + $website->{'title'} = $dbh->quote($website->{'title'}); + $website->{'description'} = $dbh->quote($website->{'description'}); + $website->{'url'} = $dbh->quote($website->{'url'}); + + $query = "Update websites set +title = $website->{'title'}, +description = $website->{'description'}, +url = $website->{'url'} +where websitenumber = $website->{'websitenumber'}"; + + $dbh->do($query); + + $dbh->disconnect; +} # sub updatewebsite + + +sub deletewebsite { + my ($websitenumber) = @_; + my $dbh = C4Connect; + my $query = "Delete from websites where websitenumber = $websitenumber"; + + $dbh->do($query); + + $dbh->disconnect; +} # sub deletewebsite + + END { } # module clean-up code here (global destructor) diff --git a/C4/Search.pm b/C4/Search.pm index 3c4d575776..d594e14ee0 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -21,7 +21,7 @@ $VERSION = 0.02; &borrdata2 &NewBorrowerNumber &bibitemdata &borrissues &getboracctrecord &ItemType &itemissues &subject &subtitle &addauthor &bibitems &barcodes &findguarantees &allissues &systemprefs -&findguarantor); +&findguarantor &getwebsites); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -1167,6 +1167,28 @@ sub barcodes{ return(@barcodes); } + + +sub getwebsites { + my ($biblionumber) = @_; + my $dbh = C4Connect; + my $query = "Select * from websites where biblionumber = $biblionumber"; + my $sth = $dbh->prepare($query); + my $count = 0; + my @results; + + $sth->execute; + while (my $data = $sth->fetchrow_hashref) { + $results[$count] = $data; + $count++; + } # while + + $sth->finish; + $dbh->disconnect; + return($count, @results); +} # sub getwebsites + + END { } # module clean-up code here (global destructor) =head1 NAME diff --git a/addwebsite.pl b/addwebsite.pl new file mode 100755 index 0000000000..7a9a07efea --- /dev/null +++ b/addwebsite.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use strict; +use C4::Acquisitions; +use CGI; + +my $input = new CGI; +my $biblionumber = $input->param('biblionumber'); +my $website = { + biblionumber => $biblionumber, + title => $input->param('title')?$input->param('title'):"", + description => $input->param('description')?$input->param('description'):"", + url => $input->param('url')?$input->param('url'):"" +}; # my $website + + +if (! $biblionumber) { + print $input->redirect("/catalogue/"); + +} else { + &addwebsite($website); + + print $input->redirect("modwebsites.pl?biblionumber=$biblionumber"); +} # else diff --git a/database.mysql b/database.mysql index 5cae357fb0..4d9890d377 100644 --- a/database.mysql +++ b/database.mysql @@ -799,3 +799,15 @@ CREATE TABLE users ( level smallint(6) ); +# +# Table structure for table 'websites' +# + +CREATE TABLE websites ( + websitenumber int(11) NOT NULL auto_increment, + biblionumber int(11) NOT NULL default '0', + title text, + description text, + url varchar(255), + PRIMARY KEY (websitenumber) +) TYPE=ISAM PACK_KEYS=1; diff --git a/deletewebsite.pl b/deletewebsite.pl new file mode 100755 index 0000000000..a28082cd04 --- /dev/null +++ b/deletewebsite.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use C4::Acquisitions; +use CGI; + +my $input = new CGI; +my $biblionumber = $input->param('biblionumber'); +my $websitenumber = $input->param('websitenumber'); + +if (! $biblionumber) { + print $input->redirect("/catalogue/"); + +} elsif (! $websitenumber) { + print $input->param("modwebsite.pl?biblionumber=$biblionumber"); + +} else { + &deletewebsite($websitenumber); + + print $input->redirect("modwebsites.pl?biblionumber=$biblionumber"); +} # else diff --git a/detail.pl b/detail.pl index fb81c10f4a..5d2145f2a6 100755 --- a/detail.pl +++ b/detail.pl @@ -11,11 +11,11 @@ use C4::Output; my $input = new CGI; my $type = $input->param('type'); my $bib = $input->param('bib'); -my $title = $input->param('title'); my @items = &ItemInfo(undef, $bib, $type); my @temp = split('\t', $items[0]); -my $dat = &bibdata($bib); my $count = @items; +my $dat = &bibdata($bib); +my ($websitecount, @websites) = &getwebsites($bib); my ($authorcount, $addauthor) = &addauthor($bib); my $additional = $addauthor->[0]->{'author'}; my $main; @@ -272,6 +272,27 @@ if ($type ne 'opac') { $dat->{'abstract'} +

+ + + + +EOF + + for (my $i = 0; $i < $websitecount; $i++) { + $websites[$i]->{'url'} =~ s/^http:\/\///; + print << "EOF"; + + + +EOF + } # for + + print << "EOF"; +
Links to Associated Websites
Title: $websites[$i]->{'title'}
+Description: $websites[$i]->{'description'}
+URL: http://$websites[$i]->{'url'}
+
EOF } else { if ($dat->{'abstract'} ne '') { @@ -284,6 +305,31 @@ EOF $dat->{'abstract'} +

+EOF + } # if + if ($websitecount) { + print << "EOF"; + + + + +EOF + + for (my $i = 0; $i < $websitecount; $i++) { + $websites[$i]->{'url'} =~ s/^http:\/\///; + print << "EOF"; + + + +EOF + } # for + + print << "EOF"; +
Link to Associated Websites
Title: $websites[$i]->{'title'}
+Description: $websites[$i]->{'description'}
+URL: http://$websites[$i]->{'url'}
+
EOF } # if } # else diff --git a/modbib.pl b/modbib.pl index f2c22fdca8..1baf558469 100755 --- a/modbib.pl +++ b/modbib.pl @@ -62,6 +62,7 @@ $dewey = ~ s/\.$//; $data->{'title'} = &tidyhtml($data->{'title'}); print << "EOF"; +Modify Website Links

diff --git a/modwebsites.pl b/modwebsites.pl new file mode 100755 index 0000000000..f9c231441e --- /dev/null +++ b/modwebsites.pl @@ -0,0 +1,75 @@ +#!/usr/bin/perl + +use strict; + +use C4::Search; +use CGI; +use C4::Output; + +my $input = new CGI; +my $biblionumber = $input->param('biblionumber'); +my ($count, @websites) = &getwebsites($biblionumber); + +if ($biblionumber eq '') { + print $input->redirect("/catalogue/"); +} # if + +print $input->header; +print startpage(); +print startmenu(); + +print << "EOF"; +

+Return to Details Page +EOF + +for (my $i = 0; $i < $count; $i++) { + print << "EOF" +

+ + + + + + + + + + + + + + + + +
Title
Description
URL
+ +

+EOF +} # for + +print << "EOF"; +

+

Add another Website Link

+
+ + + + + + + + + + + + + + +
Title
Description
URL
+ +
+EOF + +print endmenu(); +print endpage(); diff --git a/updatewebsite.pl b/updatewebsite.pl new file mode 100755 index 0000000000..126bef3254 --- /dev/null +++ b/updatewebsite.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +use strict; +use C4::Acquisitions; +use CGI; + +my $input = new CGI; +my $biblionumber = $input->param('biblionumber'); +my $websitenumber = $input->param('websitenumber'); +my $website = { + biblionumber => $biblionumber, + websitenumber => $websitenumber, + title => $input->param('title')?$input->param('title'):"", + description => $input->param('description')?$input->param('description'):"", + url => $input->param('url')?$input->param('url'):"" +}; # my $website + + +if ($input->param('delete')) { + print $input->redirect("deletewebsite.pl?biblionumber=$biblionumber&websitenumber=$websitenumber"); + +} elsif (! $biblionumber) { + print $input->redirect("/catalogue/"); + +} elsif (! $websitenumber) { + print $input->redirect("modwebsites.pl?biblionumber=$biblionumber"); + +} else { + &updatewebsite($website); + + print $input->redirect("modwebsites.pl?biblionumber=$biblionumber"); +} # else -- 2.39.5