Lines 40-46
sub StringSearch {
Link Here
|
40 |
$searchstring = ''; |
40 |
$searchstring = ''; |
41 |
} |
41 |
} |
42 |
|
42 |
|
43 |
my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout"; |
43 |
my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype"; |
44 |
$query .= " FROM z3950servers"; |
44 |
$query .= " FROM z3950servers"; |
45 |
if ( $searchstring ne '' ) { $query .= " WHERE (name like ?)" } |
45 |
if ( $searchstring ne '' ) { $query .= " WHERE (name like ?)" } |
46 |
$query .= " ORDER BY rank,name"; |
46 |
$query .= " ORDER BY rank,name"; |
Lines 85-108
$template->param(script_name => $script_name,
Link Here
|
85 |
|
85 |
|
86 |
################## ADD_FORM ################################## |
86 |
################## ADD_FORM ################################## |
87 |
# called by default. Used to create form to add or modify a record |
87 |
# called by default. Used to create form to add or modify a record |
88 |
if ($op eq 'add_form') { |
88 |
if ( $op eq 'add_form' ) { |
89 |
$template->param(add_form => 1); |
89 |
$template->param( add_form => 1 ); |
90 |
#---- if primkey exists, it's a modify action, so read values to modify... |
90 |
|
91 |
my $data; |
91 |
#---- if primkey exists, it's a modify action, so read values to modify... |
92 |
if ($searchfield) { |
92 |
my $data; |
93 |
my $dbh = C4::Context->dbh; |
93 |
if ($searchfield) { |
94 |
my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout from z3950servers where (name = ?) order by rank,name"); |
94 |
my $dbh = C4::Context->dbh; |
95 |
$sth->execute($searchfield); |
95 |
my $sth = $dbh->prepare( |
96 |
$data=$sth->fetchrow_hashref; |
96 |
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" |
97 |
$sth->finish; |
97 |
); |
98 |
} |
98 |
$sth->execute($searchfield); |
99 |
$template->param( $_ => $data->{$_} ) |
99 |
$data = $sth->fetchrow_hashref; |
100 |
for ( qw( host port db userid password checked rank timeout encoding ) ); |
100 |
$sth->finish; |
101 |
$template->param( $_ . $data->{$_} => 1) |
101 |
} |
102 |
for ( qw( syntax ) ); |
102 |
$template->param( $_ => $data->{$_} ) |
103 |
# END $OP eq ADD_FORM |
103 |
for (qw( host port db userid password checked rank timeout encoding )); |
|
|
104 |
$template->param( $_ . $data->{$_} => 1 ) for (qw( syntax recordtype )); |
105 |
|
106 |
# END $OP eq ADD_FORM |
104 |
################## ADD_VALIDATE ################################## |
107 |
################## ADD_VALIDATE ################################## |
105 |
# called by add_form, used to insert/modify data in DB |
108 |
# called by add_form, used to insert/modify data in DB |
106 |
} elsif ($op eq 'add_validate') { |
109 |
} elsif ($op eq 'add_validate') { |
107 |
my $dbh=C4::Context->dbh; |
110 |
my $dbh=C4::Context->dbh; |
108 |
my $sth=$dbh->prepare("select * from z3950servers where name=?"); |
111 |
my $sth=$dbh->prepare("select * from z3950servers where name=?"); |
Lines 110-116
if ($op eq 'add_form') {
Link Here
|
110 |
my $checked = $input->param('checked') ? 1 : 0; |
113 |
my $checked = $input->param('checked') ? 1 : 0; |
111 |
if ($sth->rows) { |
114 |
if ($sth->rows) { |
112 |
$template->param(confirm_update => 1); |
115 |
$template->param(confirm_update => 1); |
113 |
$sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=? where name=?"); |
116 |
$sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?"); |
114 |
$sth->execute($input->param('host'), |
117 |
$sth->execute($input->param('host'), |
115 |
$input->param('port'), |
118 |
$input->param('port'), |
116 |
$input->param('db'), |
119 |
$input->param('db'), |
Lines 122-127
if ($op eq 'add_form') {
Link Here
|
122 |
$input->param('syntax'), |
125 |
$input->param('syntax'), |
123 |
$input->param('encoding'), |
126 |
$input->param('encoding'), |
124 |
$input->param('timeout'), |
127 |
$input->param('timeout'), |
|
|
128 |
$input->param('recordtype'), |
125 |
$input->param('searchfield'), |
129 |
$input->param('searchfield'), |
126 |
); |
130 |
); |
127 |
} |
131 |
} |
Lines 129-172
if ($op eq 'add_form') {
Link Here
|
129 |
$template->param(confirm_add => 1); |
133 |
$template->param(confirm_add => 1); |
130 |
$sth=$dbh->prepare( |
134 |
$sth=$dbh->prepare( |
131 |
"INSERT INTO z3950servers " . |
135 |
"INSERT INTO z3950servers " . |
132 |
"(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout) " . |
136 |
"(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " . |
133 |
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); |
137 |
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); |
134 |
$sth->execute( |
138 |
$sth->execute( |
135 |
$input->param( 'host' ), |
139 |
$input->param('host'), $input->param('port'), |
136 |
$input->param( 'port' ), |
140 |
$input->param('db'), $input->param('userid'), |
137 |
$input->param( 'db' ), |
141 |
$input->param('password'), $input->param('searchfield'), |
138 |
$input->param( 'userid' ), |
142 |
$checked, $input->param('rank'), |
139 |
$input->param( 'password' ), |
143 |
$input->param('syntax'), $input->param('encoding'), |
140 |
$input->param( 'searchfield' ), |
144 |
$input->param('timeout'), $input->param('recordtype') |
141 |
$checked, |
145 |
); |
142 |
$input->param( 'rank' ), |
146 |
} |
143 |
$input->param( 'syntax' ), |
147 |
$sth->finish; |
144 |
$input->param( 'encoding' ), |
148 |
|
145 |
$input->param( 'timeout' ) ); |
149 |
# END $OP eq ADD_VALIDATE |
146 |
} |
|
|
147 |
$sth->finish; |
148 |
# END $OP eq ADD_VALIDATE |
149 |
################## DELETE_CONFIRM ################################## |
150 |
################## DELETE_CONFIRM ################################## |
150 |
# called by default form, used to confirm deletion of data in DB |
151 |
# called by default form, used to confirm deletion of data in DB |
151 |
} elsif ($op eq 'delete_confirm') { |
152 |
} elsif ($op eq 'delete_confirm') { |
152 |
$template->param(delete_confirm => 1); |
153 |
$template->param( delete_confirm => 1 ); |
153 |
my $dbh = C4::Context->dbh; |
154 |
my $dbh = C4::Context->dbh; |
154 |
|
155 |
|
155 |
my $sth2=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout from z3950servers where (name = ?) order by rank,name"); |
156 |
my $sth2 = $dbh->prepare( |
156 |
$sth2->execute($searchfield); |
157 |
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" |
157 |
my $data=$sth2->fetchrow_hashref; |
158 |
); |
158 |
$sth2->finish; |
159 |
$sth2->execute($searchfield); |
159 |
|
160 |
my $data = $sth2->fetchrow_hashref; |
160 |
$template->param(host => $data->{'host'}, |
161 |
$sth2->finish; |
161 |
port => $data->{'port'}, |
162 |
|
162 |
db => $data->{'db'}, |
163 |
$template->param( |
163 |
userid => $data->{'userid'}, |
164 |
host => $data->{'host'}, |
164 |
password => $data->{'password'}, |
165 |
port => $data->{'port'}, |
165 |
checked => $data->{'checked'}, |
166 |
db => $data->{'db'}, |
166 |
rank => $data->{'rank'}, |
167 |
userid => $data->{'userid'}, |
167 |
syntax => $data->{'syntax'}, |
168 |
password => $data->{'password'}, |
168 |
timeout => $data->{'timeout'}, |
169 |
checked => $data->{'checked'}, |
169 |
encoding => $data->{'encoding'} ); |
170 |
rank => $data->{'rank'}, |
|
|
171 |
syntax => $data->{'syntax'}, |
172 |
timeout => $data->{'timeout'}, |
173 |
recordtype => $data->{'recordtype'}, |
174 |
encoding => $data->{'encoding'} |
175 |
); |
170 |
|
176 |
|
171 |
# END $OP eq DELETE_CONFIRM |
177 |
# END $OP eq DELETE_CONFIRM |
172 |
################## DELETE_CONFIRMED ################################## |
178 |
################## DELETE_CONFIRMED ################################## |
Lines 197-203
if ($op eq 'add_form') {
Link Here
|
197 |
rank => $results->[$i]{'rank'}, |
203 |
rank => $results->[$i]{'rank'}, |
198 |
syntax => $results->[$i]{'syntax'}, |
204 |
syntax => $results->[$i]{'syntax'}, |
199 |
encoding => $results->[$i]{'encoding'}, |
205 |
encoding => $results->[$i]{'encoding'}, |
200 |
timeout => $results->[$i]{'timeout'}); |
206 |
timeout => $results->[$i]{'timeout'}, |
|
|
207 |
recordtype => $results->[$i]{'recordtype'}); |
201 |
push @loop, \%row; |
208 |
push @loop, \%row; |
202 |
|
209 |
|
203 |
} |
210 |
} |