Revision 44d893c2
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/User.pm | ||
---|---|---|
38 | 38 |
use Fcntl qw(:seek); |
39 | 39 |
|
40 | 40 |
#use SL::Auth; |
41 |
use SL::DB::AuthClient; |
|
41 | 42 |
use SL::DBConnect; |
42 | 43 |
use SL::DBUpgrade2; |
43 | 44 |
use SL::DBUtils; |
... | ... | |
224 | 225 |
return @dbsources; |
225 | 226 |
} |
226 | 227 |
|
227 |
sub dbclusterencoding { |
|
228 |
$main::lxdebug->enter_sub(); |
|
229 |
|
|
230 |
my ($self, $form) = @_; |
|
231 |
|
|
232 |
$form->{dbdefault} ||= $form->{dbuser}; |
|
233 |
|
|
234 |
dbconnect_vars($form, $form->{dbdefault}); |
|
235 |
|
|
236 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) || $form->dberror(); |
|
237 |
my $query = qq|SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'template0'|; |
|
238 |
my ($cluster_encoding) = $dbh->selectrow_array($query); |
|
239 |
$dbh->disconnect(); |
|
240 |
|
|
241 |
$main::lxdebug->leave_sub(); |
|
242 |
|
|
243 |
return $cluster_encoding; |
|
244 |
} |
|
245 |
|
|
246 | 228 |
sub dbcreate { |
247 | 229 |
$main::lxdebug->enter_sub(); |
248 | 230 |
|
... | ... | |
316 | 298 |
|
317 | 299 |
my ($self, $form) = @_; |
318 | 300 |
|
319 |
$form->{only_acc_db} = 1; |
|
301 |
my %dbexcl = map { $_->dbname => 1 } |
|
302 |
grep { ($_->dbhost eq $form->{dbhost}) && ($_->dbport eq $form->{dbport}) } |
|
303 |
@{ SL::DB::Manager::AuthClient->get_all }; |
|
320 | 304 |
|
321 |
my %members = $main::auth->read_all_users(); |
|
322 |
my %dbexcl = map { $_ => 1 } grep { $_ } map { $_->{dbname} } values %members; |
|
305 |
$form->{only_acc_db} = 1; |
|
323 | 306 |
|
324 | 307 |
$dbexcl{$form->{dbdefault}} = 1; |
325 | 308 |
$dbexcl{$main::auth->{DB_config}->{db}} = 1; |
... | ... | |
331 | 314 |
return @dbunused; |
332 | 315 |
} |
333 | 316 |
|
334 |
sub dbneedsupdate { |
|
335 |
$main::lxdebug->enter_sub(); |
|
336 |
|
|
337 |
my ($self, $form) = @_; |
|
338 |
|
|
339 |
my %members = $main::auth->read_all_users(); |
|
340 |
my $dbupdater = SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls; |
|
341 |
|
|
342 |
my ($query, $sth, %dbs_needing_updates); |
|
343 |
|
|
344 |
foreach my $login (grep /[a-z]/, keys %members) { |
|
345 |
my $member = $members{$login}; |
|
346 |
|
|
347 |
map { $form->{$_} = $member->{$_} } qw(dbname dbuser dbpasswd dbhost dbport); |
|
348 |
dbconnect_vars($form, $form->{dbname}); |
|
349 |
|
|
350 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options); |
|
351 |
|
|
352 |
next unless $dbh; |
|
353 |
|
|
354 |
my $version; |
|
355 |
|
|
356 |
$query = qq|SELECT version FROM defaults|; |
|
357 |
$sth = prepare_query($form, $dbh, $query); |
|
358 |
if ($sth->execute()) { |
|
359 |
($version) = $sth->fetchrow_array(); |
|
360 |
} |
|
361 |
$sth->finish(); |
|
362 |
|
|
363 |
$dbh->disconnect and next unless $version; |
|
364 |
|
|
365 |
my $update_available = $dbupdater->update_available($version) || $dbupdater->update2_available($dbh); |
|
366 |
$dbh->disconnect; |
|
367 |
|
|
368 |
if ($update_available) { |
|
369 |
my $dbinfo = {}; |
|
370 |
map { $dbinfo->{$_} = $member->{$_} } grep /^db/, keys %{ $member }; |
|
371 |
$dbs_needing_updates{$member->{dbhost} . "::" . $member->{dbname}} = $dbinfo; |
|
372 |
} |
|
373 |
} |
|
374 |
|
|
375 |
$main::lxdebug->leave_sub(); |
|
376 |
|
|
377 |
return values %dbs_needing_updates; |
|
378 |
} |
|
379 |
|
|
380 | 317 |
sub calc_version { |
381 | 318 |
$main::lxdebug->enter_sub(2); |
382 | 319 |
|
Auch abrufbar als: Unified diff
Datenbankverwaltung in neuen Admin-Controller verschoben