|
Lines 25-30
use CGI;
Link Here
|
| 25 |
use C4::Context; |
25 |
use C4::Context; |
| 26 |
use C4::Auth; |
26 |
use C4::Auth; |
| 27 |
use C4::Output; |
27 |
use C4::Output; |
|
|
28 |
use C4::Breeding; |
| 28 |
|
29 |
|
| 29 |
sub StringSearch { |
30 |
sub StringSearch { |
| 30 |
my ($searchstring,$type)=@_; |
31 |
my ($searchstring,$type)=@_; |
|
Lines 90-103
if ( $op eq 'add_form' ) {
Link Here
|
| 90 |
|
91 |
|
| 91 |
#---- if primkey exists, it's a modify action, so read values to modify... |
92 |
#---- if primkey exists, it's a modify action, so read values to modify... |
| 92 |
my $data; |
93 |
my $data; |
| 93 |
if ($searchfield) { |
94 |
if (defined($searchfield)) { |
| 94 |
my $dbh = C4::Context->dbh; |
95 |
$data = C4::Breeding::getZ3950server({name => $searchfield}); |
| 95 |
my $sth = $dbh->prepare( |
|
|
| 96 |
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" |
| 97 |
); |
| 98 |
$sth->execute($searchfield); |
| 99 |
$data = $sth->fetchrow_hashref; |
| 100 |
$sth->finish; |
| 101 |
} |
96 |
} |
| 102 |
$template->param( $_ => $data->{$_} ) |
97 |
$template->param( $_ => $data->{$_} ) |
| 103 |
for (qw( host port db userid password checked rank timeout encoding )); |
98 |
for (qw( host port db userid password checked rank timeout encoding )); |
|
Lines 107-164
if ( $op eq 'add_form' ) {
Link Here
|
| 107 |
################## ADD_VALIDATE ################################## |
102 |
################## ADD_VALIDATE ################################## |
| 108 |
# called by add_form, used to insert/modify data in DB |
103 |
# called by add_form, used to insert/modify data in DB |
| 109 |
} elsif ($op eq 'add_validate') { |
104 |
} elsif ($op eq 'add_validate') { |
| 110 |
my $dbh=C4::Context->dbh; |
105 |
my $params = castCGIToZ3950serverParams($input); |
| 111 |
my $sth=$dbh->prepare("select * from z3950servers where name=?"); |
106 |
my $dbh=C4::Context->dbh; |
| 112 |
$sth->execute($input->param('searchfield')); |
107 |
my ($sth, $sql, $server); |
| 113 |
my $checked = $input->param('checked') ? 1 : 0; |
108 |
|
| 114 |
if ($sth->rows) { |
109 |
$server = C4::Breeding::getZ3950server( $params->{id} ? {id => $params->{id}} : {name => $params->{name}} ); |
|
|
110 |
if ($server) { |
| 111 |
C4::Breeding::updateZ3950server($params); |
| 115 |
$template->param(confirm_update => 1); |
112 |
$template->param(confirm_update => 1); |
| 116 |
$sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?"); |
113 |
} |
| 117 |
$sth->execute($input->param('host'), |
114 |
else { |
| 118 |
$input->param('port'), |
115 |
C4::Breeding::addZ3950server($params); |
| 119 |
$input->param('db'), |
|
|
| 120 |
$input->param('userid'), |
| 121 |
$input->param('password'), |
| 122 |
$input->param('searchfield'), |
| 123 |
$checked, |
| 124 |
$input->param('rank'), |
| 125 |
$input->param('syntax'), |
| 126 |
$input->param('encoding'), |
| 127 |
$input->param('timeout'), |
| 128 |
$input->param('recordtype'), |
| 129 |
$input->param('searchfield'), |
| 130 |
); |
| 131 |
} |
| 132 |
else { |
| 133 |
$template->param(confirm_add => 1); |
116 |
$template->param(confirm_add => 1); |
| 134 |
$sth=$dbh->prepare( |
|
|
| 135 |
"INSERT INTO z3950servers " . |
| 136 |
"(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " . |
| 137 |
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); |
| 138 |
$sth->execute( |
| 139 |
$input->param('host'), $input->param('port'), |
| 140 |
$input->param('db'), $input->param('userid'), |
| 141 |
$input->param('password'), $input->param('searchfield'), |
| 142 |
$checked, $input->param('rank'), |
| 143 |
$input->param('syntax'), $input->param('encoding'), |
| 144 |
$input->param('timeout'), $input->param('recordtype') |
| 145 |
); |
| 146 |
} |
117 |
} |
| 147 |
$sth->finish; |
|
|
| 148 |
|
| 149 |
# END $OP eq ADD_VALIDATE |
118 |
# END $OP eq ADD_VALIDATE |
| 150 |
################## DELETE_CONFIRM ################################## |
119 |
################## DELETE_CONFIRM ################################## |
| 151 |
# called by default form, used to confirm deletion of data in DB |
120 |
# called by default form, used to confirm deletion of data in DB |
| 152 |
} elsif ($op eq 'delete_confirm') { |
121 |
} elsif ($op eq 'delete_confirm') { |
| 153 |
$template->param( delete_confirm => 1 ); |
122 |
$template->param( delete_confirm => 1 ); |
| 154 |
my $dbh = C4::Context->dbh; |
123 |
my $data = C4::Breeding::getZ3950server({name => $searchfield}); |
| 155 |
|
|
|
| 156 |
my $sth2 = $dbh->prepare( |
| 157 |
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" |
| 158 |
); |
| 159 |
$sth2->execute($searchfield); |
| 160 |
my $data = $sth2->fetchrow_hashref; |
| 161 |
$sth2->finish; |
| 162 |
|
124 |
|
| 163 |
$template->param( |
125 |
$template->param( |
| 164 |
host => $data->{'host'}, |
126 |
host => $data->{'host'}, |
|
Lines 179-188
if ( $op eq 'add_form' ) {
Link Here
|
| 179 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
141 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
| 180 |
} elsif ($op eq 'delete_confirmed') { |
142 |
} elsif ($op eq 'delete_confirmed') { |
| 181 |
$template->param(delete_confirmed => 1); |
143 |
$template->param(delete_confirmed => 1); |
| 182 |
my $dbh=C4::Context->dbh; |
144 |
my $server = C4::Breeding::getZ3950server({name => $searchfield}); |
| 183 |
my $sth=$dbh->prepare("delete from z3950servers where name=?"); |
145 |
C4::Breeding::deleteZ3950server($server->{id}); |
| 184 |
$sth->execute($searchfield); |
|
|
| 185 |
$sth->finish; |
| 186 |
# END $OP eq DELETE_CONFIRMED |
146 |
# END $OP eq DELETE_CONFIRMED |
| 187 |
################## DEFAULT ################################## |
147 |
################## DEFAULT ################################## |
| 188 |
} else { # DEFAULT |
148 |
} else { # DEFAULT |
|
Lines 219-221
if ( $op eq 'add_form' ) {
Link Here
|
| 219 |
} |
179 |
} |
| 220 |
} #---- END $OP eq DEFAULT |
180 |
} #---- END $OP eq DEFAULT |
| 221 |
output_html_with_http_headers $input, $cookie, $template->output; |
181 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 222 |
- |
182 |
|
|
|
183 |
sub castCGIToZ3950serverParams { |
| 184 |
my ($cgi) = @_; |
| 185 |
|
| 186 |
my $params = {}; |
| 187 |
$params->{'host'} = $input->param('host'), |
| 188 |
$params->{'port'} = $input->param('port'), |
| 189 |
$params->{'db'} = $input->param('db'), |
| 190 |
$params->{'userid'} = $input->param('userid'), |
| 191 |
$params->{'password'} = $input->param('password'), |
| 192 |
$params->{'name'} = $input->param('searchfield'), |
| 193 |
$params->{'checked'} = $input->param('checked') ? 1 : 0, |
| 194 |
$params->{'rank'} = $input->param('rank'), |
| 195 |
$params->{'syntax'} = $input->param('syntax'), |
| 196 |
$params->{'encoding'} = $input->param('encoding'), |
| 197 |
$params->{'timeout'} = $input->param('timeout'), |
| 198 |
$params->{'recordtype'} = $input->param('recordtype'), |
| 199 |
$params->{'searchfield'} = $input->param('searchfield'), |
| 200 |
return $params; |
| 201 |
} |