Lines 85-174
$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,recordtype 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 recordtype ) ); |
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 |
$template->param(add_validate => 1); |
110 |
$template->param( add_validate => 1 ); |
108 |
my $dbh=C4::Context->dbh; |
111 |
my $dbh = C4::Context->dbh; |
109 |
my $sth=$dbh->prepare("select * from z3950servers where name=?"); |
112 |
my $sth = $dbh->prepare("select * from z3950servers where name=?"); |
110 |
$sth->execute($input->param('searchfield')); |
113 |
$sth->execute( $input->param('searchfield') ); |
111 |
my $checked = $input->param('checked') ? 1 : 0; |
114 |
my $checked = $input->param('checked') ? 1 : 0; |
112 |
if ($sth->rows) { |
115 |
if ( $sth->rows ) { |
113 |
$sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?"); |
116 |
$sth = $dbh->prepare( |
114 |
$sth->execute($input->param('host'), |
117 |
"update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?" |
115 |
$input->param('port'), |
118 |
); |
116 |
$input->param('db'), |
|
|
117 |
$input->param('userid'), |
118 |
$input->param('password'), |
119 |
$input->param('searchfield'), |
120 |
$checked, |
121 |
$input->param('rank'), |
122 |
$input->param('syntax'), |
123 |
$input->param('encoding'), |
124 |
$input->param('timeout'), |
125 |
$input->param('recordtype'), |
126 |
$input->param('searchfield'), |
127 |
); |
128 |
} |
129 |
else { |
130 |
$sth=$dbh->prepare( |
131 |
"INSERT INTO z3950servers " . |
132 |
"(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " . |
133 |
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); |
134 |
$sth->execute( |
119 |
$sth->execute( |
135 |
$input->param( 'host' ), |
120 |
$input->param('host'), $input->param('port'), |
136 |
$input->param( 'port' ), |
121 |
$input->param('db'), $input->param('userid'), |
137 |
$input->param( 'db' ), |
122 |
$input->param('password'), $input->param('searchfield'), |
138 |
$input->param( 'userid' ), |
123 |
$checked, $input->param('rank'), |
139 |
$input->param( 'password' ), |
124 |
$input->param('syntax'), $input->param('encoding'), |
140 |
$input->param( 'searchfield' ), |
125 |
$input->param('timeout'), $input->param('recordtype'), |
141 |
$checked, |
126 |
$input->param('searchfield'), |
142 |
$input->param( 'rank' ), |
127 |
); |
143 |
$input->param( 'syntax' ), |
128 |
} |
144 |
$input->param( 'encoding' ), |
129 |
else { |
145 |
$input->param( 'timeout' ), |
130 |
$sth = |
146 |
$input->param( 'recordtype' ) ); |
131 |
$dbh->prepare( "INSERT INTO z3950servers " |
147 |
} |
132 |
. "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " |
148 |
$sth->finish; |
133 |
. "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); |
149 |
# END $OP eq ADD_VALIDATE |
134 |
$sth->execute( |
|
|
135 |
$input->param('host'), $input->param('port'), |
136 |
$input->param('db'), $input->param('userid'), |
137 |
$input->param('password'), $input->param('searchfield'), |
138 |
$checked, $input->param('rank'), |
139 |
$input->param('syntax'), $input->param('encoding'), |
140 |
$input->param('timeout'), $input->param('recordtype') |
141 |
); |
142 |
} |
143 |
$sth->finish; |
144 |
|
145 |
# END $OP eq ADD_VALIDATE |
150 |
################## DELETE_CONFIRM ################################## |
146 |
################## DELETE_CONFIRM ################################## |
151 |
# called by default form, used to confirm deletion of data in DB |
147 |
# called by default form, used to confirm deletion of data in DB |
152 |
} elsif ($op eq 'delete_confirm') { |
148 |
} elsif ($op eq 'delete_confirm') { |
153 |
$template->param(delete_confirm => 1); |
149 |
$template->param( delete_confirm => 1 ); |
154 |
my $dbh = C4::Context->dbh; |
150 |
my $dbh = C4::Context->dbh; |
155 |
|
151 |
|
156 |
my $sth2=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name"); |
152 |
my $sth2 = $dbh->prepare( |
157 |
$sth2->execute($searchfield); |
153 |
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" |
158 |
my $data=$sth2->fetchrow_hashref; |
154 |
); |
159 |
$sth2->finish; |
155 |
$sth2->execute($searchfield); |
160 |
|
156 |
my $data = $sth2->fetchrow_hashref; |
161 |
$template->param(host => $data->{'host'}, |
157 |
$sth2->finish; |
162 |
port => $data->{'port'}, |
158 |
|
163 |
db => $data->{'db'}, |
159 |
$template->param( |
164 |
userid => $data->{'userid'}, |
160 |
host => $data->{'host'}, |
165 |
password => $data->{'password'}, |
161 |
port => $data->{'port'}, |
166 |
checked => $data->{'checked'}, |
162 |
db => $data->{'db'}, |
167 |
rank => $data->{'rank'}, |
163 |
userid => $data->{'userid'}, |
168 |
syntax => $data->{'syntax'}, |
164 |
password => $data->{'password'}, |
169 |
timeout => $data->{'timeout'}, |
165 |
checked => $data->{'checked'}, |
170 |
recordtype => $data->{'recordtype'}, |
166 |
rank => $data->{'rank'}, |
171 |
encoding => $data->{'encoding'} ); |
167 |
syntax => $data->{'syntax'}, |
|
|
168 |
timeout => $data->{'timeout'}, |
169 |
recordtype => $data->{'recordtype'}, |
170 |
encoding => $data->{'encoding'} |
171 |
); |
172 |
|
172 |
|
173 |
# END $OP eq DELETE_CONFIRM |
173 |
# END $OP eq DELETE_CONFIRM |
174 |
################## DELETE_CONFIRMED ################################## |
174 |
################## DELETE_CONFIRMED ################################## |