fixing bug in thesaurus entry modification

This commit is contained in:
tipaul 2003-07-02 12:49:43 +00:00
parent 4cef812d06
commit 71817b0ab1
4 changed files with 53 additions and 12 deletions

View file

@ -51,8 +51,8 @@ It contains every functions to manage/find authorities.
@EXPORT = qw( &newauthority
&searchauthority
&delauthority
&modauthority
);
# FIXME - This is never used
=item newauthority
@ -133,6 +133,23 @@ sub newauthority {
return $id;
}
=item ModAuthority
$id = &ModAuthority($dbh,$id,$freelib);
modify a free lib
C<$dbh> is a DBI::db handle for the Koha database.
C<$id> is the entry id
C<$freelib> is the new freelib
=cut
sub modauthority {
my ($dbh,$id,$freelib) = @_;
my $sth = $dbh->prepare("update bibliothesaurus set freelib=? where id=?");
$sth->execute($freelib,$id);
}
=item SearchAuthority
$id = &SearchAuthority($dbh,$category,$branch,$searchstring,$type,$offset,$pagesize);
@ -161,7 +178,7 @@ sub searchauthority {
$query .= " and match (category,freelib) AGAINST ('$searchstring')" if ($searchstring);
# $query .= " and freelib like \"$searchstring%\"" if ($searchstring);
$query .= " order by category,freelib limit $offset,".($pagesize*4);
# warn "q : $query";
warn "q : $query";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;

View file

@ -33,7 +33,7 @@ $search_category=$input->param('category') unless $search_category;
#my $toponly = $input->param('toponly');
my $branch = $input->param('branch');
my $searchstring = $input->param('searchstring');
$searchstring=~ s/\,//g;
# $searchstring=~ s/\,//g;
my $id = $input->param('id');
my $offset=$input->param('offset');
my $father=$input->param('father');
@ -103,7 +103,7 @@ if ($op eq 'add_form') {
$template->param(category => "<input type=text name=\"category\" size=8 maxlength=8>");
}
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
# called by add_form, used to insert data in DB
} elsif ($op eq 'add_validate') {
my $dbh = C4::Context->dbh;
my $freelib = $input->param('freelib');
@ -111,6 +111,14 @@ if ($op eq 'add_form') {
newauthority($dbh,$input->param('category'),$input->param('father')." ".$input->param('stdlib'), $freelib,'',1,'');
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=thesaurus.pl?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$offset\"></html>";
exit;
################## MOD_VALIDATE ##################################
# called by add_form, used to modify data in DB
} elsif ($op eq 'mod_validate') {
my $dbh = C4::Context->dbh;
my $freelib = $input->param('freelib');
modauthority($dbh,$id,$freelib);
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=thesaurus.pl?branch=$branch&search_category=$search_category&offset=$offset&searchstring=".CGI::escapeHTML($searchstring)."\"></html>";
exit;
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {

View file

@ -34,9 +34,13 @@
<TMPL_IF name="add_form">
<!-------------------------------------------------------------------------------------------------->
<H1><TMPL_VAR name="action"></H1>
<H1><TMPL_IF name="search_category">Modify<TMPL_ELSE>Add</TMPL_IF></H1>
<form action='<TMPL_VAR name="script_name">' name=Aform method=post>
<input type=hidden name=op value='add_validate'>
<TMPL_IF name="search_category">
<input type=hidden name=op value='mod_validate'>
<TMPL_ELSE>
<input type=hidden name=op value='add_validate'>
</TMPL_IF>
<table cellpadding=3 cellspacing=3>
<tr>
<td>Category</td>
@ -44,7 +48,11 @@
</tr>
<tr>
<td>Authority lib</td>
<td><TMPL_VAR name="father"><input type="text" name="stdlib" value="<TMPL_VAR name="stdlib">" maxlength="80" size="80"></td>
<TMPL_IF name="id">
<td><TMPL_VAR name="father"><TMPL_VAR name="stdlib"><input type="hidden" name="stdlib" value="<TMPL_VAR name="stdlib">" ></td>
<TMPL_ELSE>
<td><TMPL_VAR name="father"><input type="text" name="stdlib" value="<TMPL_VAR name="stdlib">" maxlength="80" size="80"></td>
</TMPL_IF>
</tr>
<tr>
<td>Other lib</td>

View file

@ -34,9 +34,13 @@
</TMPL_IF>
<TMPL_IF name="add_form">
<!-------------------------------------------------------------------------------------------------->
<H1><TMPL_VAR name="action"></H1>
<H1><TMPL_IF name="search_category">Modification<TMPL_ELSE>Ajout</TMPL_IF></H1>
<form action='<TMPL_VAR name="script_name">' name=Aform method=post>
<input type=hidden name=op value='add_validate'>
<TMPL_IF name="search_category">
<input type=hidden name=op value='mod_validate'>
<TMPL_ELSE>
<input type=hidden name=op value='add_validate'>
</TMPL_IF>
<table cellpadding=3 cellspacing=3>
<tr>
@ -45,12 +49,16 @@
</tr>
<tr>
<td>autorit&eacute; lib</td>
<td><TMPL_VAR name="father"><input type=text name="stdlib" value='<TMPL_VAR name="stdlib">' maxlength="80" size="80"></td>
<td>Forme d'autorit&eacute;</td>
<TMPL_IF name="id">
<td><TMPL_VAR name="father"><TMPL_VAR name="stdlib"><input type="hidden" name="stdlib" value="<TMPL_VAR name="stdlib">" ></td>
<TMPL_ELSE>
<td><TMPL_VAR name="father"><input type="text" name="stdlib" value="<TMPL_VAR name="stdlib">" maxlength="80" size="80"></td>
</TMPL_IF>
</tr>
<tr>
<td>Autre lib</td>
<td>Autre forme</td>
<td><TMPL_VAR name="father"><input type=text name="freelib" value='<TMPL_VAR name="freelib">' maxlength="80" size="80"></td>
</tr>
<tr>