1 package C4::Maintainance; #assumes C4/Maintainance
3 #package to deal with marking up output
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
28 use vars qw($VERSION @ISA @EXPORT);
30 # set the version for version checking
35 C4::Maintenance - Koha catalog maintenance functions
43 The functions in this module perform various catalog-maintenance
44 functions, including deleting and undeleting books, fixing
45 miscategorized items, etc.
54 @EXPORT = qw(&listsubjects &updatesub &shiftgroup &deletedbib &undeletebib
59 ($count, $results) = &listsubjects($subject, $n, $offset);
61 Finds the subjects that begin with C<$subject> in the bibliosubject
62 table of the Koha database.
64 C<&listsubjects> returns a two-element array. C<$results> is a
65 reference-to-array, in which each element is a reference-to-hash
66 giving information about the given subject. C<$count> is the number of
67 elements in C<@{$results}>.
69 Probably the only interesting field in C<$results->[$i]> is
70 C<subject>, the subject in question.
72 C<&listsubject> returns up to C<$n> items, starting at C<$offset>. If
73 C<$n> is 0, it will return all matching subjects.
77 # FIXME - This API is bogus. The way it's currently used, it should
78 # just return a list of strings.
80 my ($sub,$num,$offset)=@_;
82 my $query="Select * from bibliosubject where subject like '$sub%' group by subject";
83 # FIXME - Make $num and $offset optional.
84 # If $num was given, make sure $offset was, too.
86 $query.=" limit $offset,$num";
88 my $sth=$dbh->prepare($query);
93 while (my $data=$sth->fetchrow_hashref){
104 &updatesub($newsubject, $oldsubject);
106 Renames a subject from C<$oldsubject> to C<$newsubject> in the
107 bibliosubject table of the Koha database.
112 my ($sub,$oldsub)=@_;
114 $sub=$dbh->quote($sub);
115 $oldsub=$dbh->quote($oldsub);
116 my $query="update bibliosubject set subject=$sub where subject=$oldsub";
117 my $sth=$dbh->prepare($query);
125 &shiftgroup($biblionumber, $biblioitemnumber);
127 Changes the biblionumber associated with a given biblioitem.
128 C<$biblioitemnumber> is the number of the biblioitem to change.
129 C<$biblionumber> is the biblionumber to associate it with.
136 my $query="update biblioitems set biblionumber=$bib where biblioitemnumber=$bi";
137 my $sth=$dbh->prepare($query);
140 $query="update items set biblionumber=$bib where biblioitemnumber=$bi";
141 $sth=$dbh->prepare($query);
149 ($count, $results) = &deletedbib($title);
151 Looks up deleted books whose title begins with C<$title>.
153 C<&deletedbib> returns a two-element list. C<$results> is a
154 reference-to-array; each element is a reference-to-hash whose keys are
155 the fields of the deletedbiblio table in the Koha database. C<$count>
156 is the number of elements in C<$results>.
163 my $query="Select * from deletedbiblio where title like '$title%' order by title";
164 my $sth=$dbh->prepare($query);
168 while (my $data=$sth->fetchrow_hashref){
174 return($i,\@results);
179 &undeletebib($biblionumber);
181 Undeletes a book. C<&undeletebib> looks up the book with the given
182 biblionumber in the deletedbiblio table of the Koha database, and
183 moves its entry to the biblio table.
190 my $query="select * from deletedbiblio where biblionumber=$bib";
191 my $sth=$dbh->prepare($query);
193 if (my @data=$sth->fetchrow_array){
195 # FIXME - Doesn't this keep the same biblionumber? Isn't this
196 # forbidden by the definition of 'biblio'? Or doesn't it matter?
197 $query="Insert into biblio values (";
198 foreach my $temp (@data){
200 $query=$query."'$temp',";
204 $sth=$dbh->prepare($query);
208 $query="Delete from deletedbiblio where biblionumber=$bib";
209 $sth=$dbh->prepare($query);
217 &updatetype($biblioitemnumber, $itemtype);
219 Changes the type of the item with the given biblioitemnumber to be
227 # FIXME - Use $dbh->do(...);
228 my $sth=$dbh->prepare("Update biblioitems set itemtype='$type' where biblioitemnumber=$bi");
234 END { } # module clean-up code here (global destructor)
243 Koha Developement team <info@koha.org>