Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 44b3c39c

Von Sven Schöling vor fast 15 Jahren hinzugefügt

  • ID 44b3c39cbbc125b7e8fb2170c2b621c8ea311b29
  • Vorgänger 2dacd279
  • Nachfolger 3734c21e

admin strict

Unterschiede anzeigen:

bin/mozilla/admin.pl
32 32
#
33 33
#======================================================================
34 34

  
35
$menufile = "menu.ini";
35
my $menufile = "menu.ini";
36 36

  
37 37
use DBI;
38 38
use CGI;
......
55 55
require "bin/mozilla/common.pl";
56 56
require "bin/mozilla/admin_groups.pl";
57 57

  
58
our $cgi = new CGI('');
59

  
60
$form = new Form;
61

  
62
$locale = new Locale $language, "admin";
58
use strict;
63 59

  
60
our $cgi    = new CGI('');
61
our $form   = new Form;
62
our $locale = new Locale $main::language, "admin";
64 63
our $auth = SL::Auth->new();
64

  
65 65
if ($auth->session_tables_present()) {
66 66
  $auth->expire_sessions();
67 67
  $auth->restore_session();
......
78 78
$form->{favicon}    = "favicon.ico";
79 79

  
80 80
if ($form->{action}) {
81
  if ($auth->authenticate_root($form->{rpw}, 0) != Auth::OK) {
81
  if ($auth->authenticate_root($form->{rpw}, 0) != Auth->OK()) {
82 82
    $form->{error_message} = $locale->text('Incorrect Password!');
83 83
    adminlogin();
84 84
    exit;
......
88 88

  
89 89
  call_sub($locale->findsub($form->{action}));
90 90

  
91
} elsif ($auth->authenticate_root($form->{rpw}, 0) == Auth::OK) {
91
} elsif ($auth->authenticate_root($form->{rpw}, 0) == Auth->OK()) {
92 92

  
93 93
  $auth->create_or_refresh_session() if ($auth->session_tables_present());
94 94

  
......
108 108
# end
109 109

  
110 110
sub adminlogin {
111
  my $form     = $main::form;
112
  my $locale   = $main::locale;
111 113

  
112 114
  $form->{title} = qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
113 115

  
......
121 123
}
122 124

  
123 125
sub logout {
124
  $auth->destroy_session();
126
  $main::auth->destroy_session();
125 127
  adminlogin();
126 128
}
127 129

  
128 130
sub check_auth_db_and_tables {
131
  my $form     = $main::form;
132
  my $locale   = $main::locale;
133

  
129 134
  my %params;
130 135

  
131
  map { $params{"db_${_}"} = $auth->{DB_config}->{$_} } keys %{ $auth->{DB_config} };
136
  map { $params{"db_${_}"} = $main::auth->{DB_config}->{$_} } keys %{ $auth->{DB_config} };
132 137

  
133
  if (!$auth->check_database()) {
138
  if (!$main::auth->check_database()) {
134 139
    $form->{title} = $locale->text('Authentification database creation');
135 140
    $form->header();
136 141
    print $form->parse_html_template('admin/check_auth_database', \%params);
......
138 143
    exit 0;
139 144
  }
140 145

  
141
  if (!$auth->check_tables()) {
146
  if (!$main::auth->check_tables()) {
142 147
    $form->{title} = $locale->text('Authentification tables creation');
143 148
    $form->header();
144 149
    print $form->parse_html_template('admin/check_auth_tables', \%params);
......
146 151
    exit 0;
147 152
  }
148 153

  
149
  if (-f $memberfile) {
154
  if (-f $main::memberfile) {
150 155
    my $memberdir = "";
151 156

  
152
    if ($memberfile =~ m|^.*/|) {
157
    if ($main::memberfile =~ m|^.*/|) {
153 158
      $memberdir = $&;
154 159
    }
155 160

  
......
157 162

  
158 163
    $form->{title} = $locale->text('User data migration');
159 164
    $form->header();
160
    print $form->parse_html_template('admin/user_migration', { 'memberfile' => $memberfile,
165
    print $form->parse_html_template('admin/user_migration', { 'memberfile' => $main::memberfile,
161 166
                                                               'backupdir'  => $backupdir });
162 167

  
163 168
    exit 0
......
165 170
}
166 171

  
167 172
sub create_auth_db {
168
  $auth->create_database('superuser'          => $form->{db_superuser},
173
  my $form     = $main::form;
174

  
175
  $main::auth->create_database('superuser'          => $form->{db_superuser},
169 176
                         'superuser_password' => $form->{db_superuser_password},
170 177
                         'template'           => $form->{db_template});
171 178
  login();
172 179
}
173 180

  
174 181
sub create_auth_tables {
175
  $auth->create_tables();
176
  $auth->set_session_value('rpw', $form->{rpw});
177
  $auth->create_or_refresh_session();
182
  my $form     = $main::form;
183
  my $locale   = $main::locale;
184

  
185
  $main::auth->create_tables();
186
  $main::auth->set_session_value('rpw', $form->{rpw});
187
  $main::auth->create_or_refresh_session();
178 188

  
179
  if (!-f $memberfile) {
189
  if (!-f $main::memberfile) {
180 190
    # New installation -- create a standard group with full access
191
    my %members;
181 192
    my $group = {
182 193
      'name'        => $locale->text('Full Access'),
183 194
      'description' => $locale->text('Full access to all functions'),
......
185 196
      'members'     => [ map { $_->{id} } values %members ],
186 197
    };
187 198

  
188
    $auth->save_group($group);
199
    $main::auth->save_group($group);
189 200
  }
190 201

  
191 202
  login();
192 203
}
193 204

  
194 205
sub migrate_users {
195
  $lxdebug->enter_sub();
206
  $main::lxdebug->enter_sub();
207

  
208
  my $form     = $main::form;
209
  my $locale   = $main::locale;
196 210

  
197 211
  my $memberdir = "";
198 212

  
199
  if ($memberfile =~ m|^.*/|) {
213
  if ($main::memberfile =~ m|^.*/|) {
200 214
    $memberdir = $&;
201 215
  }
202 216

  
......
206 220
    $form->error(sprintf($locale->text('The directory "%s" could not be created:\n%s'), $backupdir, $!));
207 221
  }
208 222

  
209
  copy $memberfile, "users/member-file-migration/members";
223
  copy $main::memberfile, "users/member-file-migration/members";
210 224

  
211
  my $in = IO::File->new($memberfile, "r");
225
  my $in = IO::File->new($main::memberfile, "r");
212 226

  
213 227
  $form->error($locale->text('Could not open the old memberfile.')) if (!$in);
214 228

  
......
248 262
  map { $_->{dbpasswd} = unpack 'u', $_->{dbpasswd} } values %members;
249 263

  
250 264
  while (my ($login, $params) = each %members) {
251
    $auth->save_user($login, %{ $params });
252
    $auth->change_password($login, $params->{password}, 1);
265
    $main::auth->save_user($login, %{ $params });
266
    $main::auth->change_password($login, $params->{password}, 1);
253 267

  
254 268
    my $conf_file = "${memberdir}${login}.conf";
255 269

  
......
259 273
    }
260 274
  }
261 275

  
262
  unlink $memberfile;
276
  unlink $main::memberfile;
263 277

  
264 278
  my @member_list = sort { lc $a->{login} cmp lc $b->{login} } values %members;
265 279

  
......
267 281
  $form->header();
268 282
  print $form->parse_html_template('admin/user_migration_done', { 'MEMBERS' => \@member_list });
269 283

  
270
  $lxdebug->leave_sub();
284
  $main::lxdebug->leave_sub();
271 285
}
272 286

  
273 287
sub create_standard_group_ask {
288
  my $form     = $main::form;
289
  my $locale   = $main::locale;
290

  
274 291
  $form->{title} = $locale->text('Create a standard group');
275 292

  
276 293
  $form->header();
......
278 295
}
279 296

  
280 297
sub create_standard_group {
281
  my %members = $auth->read_all_users();
298
  my $form     = $main::form;
299
  my $locale   = $main::locale;
300

  
301
  my %members = $main::auth->read_all_users();
282 302

  
283
  my $groups = $auth->read_groups();
303
  my $groups = $main::auth->read_groups();
284 304

  
285 305
  foreach my $group (values %{$groups}) {
286 306
    if (($form->{group_id} != $group->{id})
......
296 316
    'members'     => [ map { $_->{id} } values %members ],
297 317
  };
298 318

  
299
  $auth->save_group($group);
319
  $main::auth->save_group($group);
300 320

  
301 321
  user_migration_complete(1);
302 322
}
......
308 328
sub user_migration_complete {
309 329
  my $standard_group_created = shift;
310 330

  
331
  my $form     = $main::form;
332
  my $locale   = $main::locale;
333

  
311 334
  $form->{title} = $locale->text('User migration complete');
312 335
  $form->header();
313 336

  
......
315 338
}
316 339

  
317 340
sub list_users {
318
  my %members = $auth->read_all_users();
341
  my $form     = $main::form;
342
  my $locale   = $main::locale;
343

  
344
  my %members = $main::auth->read_all_users();
319 345

  
320 346
  delete $members{"root login"};
321 347

  
322 348
  map { $_->{templates} =~ s|.*/||; } values %members;
323 349

  
324 350
  $form->{title}   = "Lx-Office ERP " . $locale->text('Administration');
325
  $form->{LOCKED}  = -e "$userspath/nologin";
351
  $form->{LOCKED}  = -e "$main::userspath/nologin";
326 352
  $form->{MEMBERS} = [ @members{sort { lc $a cmp lc $b } keys %members} ];
327 353

  
328 354
  $form->header();
......
331 357

  
332 358
sub add_user {
333 359

  
360
  my $form     = $main::form;
361
  my $locale   = $main::locale;
362

  
334 363
  $form->{title} =
335 364
      "Lx-Office ERP "
336 365
    . $locale->text('Administration') . " / "
......
349 378
}
350 379

  
351 380
sub edit_user {
381
  my $form     = $main::form;
382
  my $locale   = $main::locale;
383

  
352 384

  
353 385
  $form->{title} =
354 386
      "Lx-Office ERP "
......
370 402
sub edit_user_form {
371 403
  my ($myconfig) = @_;
372 404

  
405
  my $form     = $main::form;
406
  my $locale   = $main::locale;
407

  
373 408
  my @valid_dateformats = qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd);
374 409
  $form->{ALL_DATEFORMATS} = [ map { { "format" => $_, "selected" => $_ eq $myconfig->{dateformat} } } @valid_dateformats ];
375 410

  
376
  my @valid_numberformats = qw(1,000.00 1000.00 1.000,00 1000,00);
411
  my @valid_numberformats = ('1,000.00', '1000.00', '1.000,00', '1000,00');
377 412
  $form->{ALL_NUMBERFORMATS} = [ map { { "format" => $_, "selected" => $_ eq $myconfig->{numberformat} } } @valid_numberformats ];
378 413

  
379
  %countrycodes = User->country_codes;
414
  my %countrycodes = User->country_codes;
380 415
  $form->{ALL_COUNTRYCODES} = [];
381
  foreach $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
416
  foreach my $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
382 417
    push @{ $form->{ALL_COUNTRYCODES} }, { "value"    => $countrycode,
383 418
                                           "name"     => $countrycodes{$countrycode},
384 419
                                           "selected" => $countrycode eq $myconfig->{countrycode} };
385 420
  }
386 421

  
387 422
  # is there a templates basedir
388
  if (!-d "$templates") {
389
    $form->error(sprintf($locale->text("The directory %s does not exist."), $templates));
423
  if (!-d "$main::templates") {
424
    $form->error(sprintf($locale->text("The directory %s does not exist."), $main::templates));
390 425
  }
391 426

  
392
  opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $ERRNO");
427
  opendir TEMPLATEDIR, "$main::templates/." or $form->error("$main::templates : $ERRNO");
393 428
  my @all     = readdir(TEMPLATEDIR);
394
  my @alldir  = sort grep { -d "$templates/$_" && !/^\.\.?$/ } @all;
395
  my @allhtml = sort grep { -f "$templates/$_" && /\.html$/ } @all;
429
  my @alldir  = sort grep { -d "$main::templates/$_" && !/^\.\.?$/ } @all;
430
  my @allhtml = sort grep { -f "$main::templates/$_" && /\.html$/ } @all;
396 431
  closedir TEMPLATEDIR;
397 432

  
398 433
  @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
......
404 439

  
405 440
  $form->{ALL_TEMPLATES} = [ map { { "name", => $_, "selected" => $_ eq $myconfig->{templates} } } @alldir ];
406 441

  
407
  $lastitem = $allhtml[0];
442
  my $lastitem = $allhtml[0];
408 443
  $lastitem =~ s/-.*//g;
409 444
  $form->{ALL_MASTER_TEMPLATES} = [ { "name" => $lastitem, "selected" => $lastitem eq "German" } ];
410
  foreach $item (@allhtml) {
445
  foreach my $item (@allhtml) {
411 446
    $item =~ s/-.*//g;
412 447
    next if ($item eq $lastitem);
413 448

  
......
426 461
  my $groups = [];
427 462

  
428 463
  if ($form->{edit}) {
429
    my $user_id    = $auth->get_user_id($form->{login});
430
    my $all_groups = $auth->read_groups();
464
    my $user_id    = $main::auth->get_user_id($form->{login});
465
    my $all_groups = $main::auth->read_groups();
431 466

  
432 467
    foreach my $group (values %{ $all_groups }) {
433 468
      push @{ $groups }, $group if (grep { $user_id == $_ } @{ $group->{members} });
......
436 471
    $groups = [ sort { lc $a->{name} cmp lc $b->{name} } @{ $groups } ];
437 472
  }
438 473

  
439
  $form->{CAN_CHANGE_PASSWORD} = $auth->can_change_password();
474
  $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
440 475

  
441 476
  $form->header();
442 477
  print $form->parse_html_template("admin/edit_user", { 'GROUPS' => $groups });
443 478
}
444 479

  
445 480
sub save_user {
481
  my $form     = $main::form;
482
  my $locale   = $main::locale;
483

  
446 484
  $form->{dbdriver} = 'Pg';
447 485

  
448 486
  # no spaces allowed in login name
......
451 489

  
452 490
  # check for duplicates
453 491
  if (!$form->{edit}) {
454
    my %members = $auth->read_all_users();
492
    my %members = $main::auth->read_all_users();
455 493
    if ($members{$form->{login}}) {
456 494
      $form->show_generic_error($locale->text('Another user with the login #1 does already exist.', $form->{login}), 'back_button' => 1);
457 495
    }
......
468 506
  }
469 507

  
470 508
  # is there a basedir
471
  if (!-d "$templates") {
472
    $form->error(sprintf($locale->text("The directory %s does not exist."), $templates));
509
  if (!-d "$main::templates") {
510
    $form->error(sprintf($locale->text("The directory %s does not exist."), $main::templates));
473 511
  }
474 512

  
475 513
  # add base directory to $form->{templates}
476 514
  $form->{templates} =~ s|.*/||;
477
  $form->{templates} =  "$templates/$form->{templates}";
515
  $form->{templates} =  "$main::templates/$form->{templates}";
478 516

  
479
  $myconfig = new User($form->{login});
517
  my $myconfig = new User($form->{login});
480 518

  
481 519
  $form->isblank("dbname", $locale->text('Dataset missing!'));
482 520
  $form->isblank("dbuser", $locale->text('Database User missing!'));
483 521

  
484
  foreach $item (keys %{$form}) {
522
  foreach my $item (keys %{$form}) {
485 523
    $myconfig->{$item} = $form->{$item};
486 524
  }
487 525

  
......
492 530

  
493 531
  $myconfig->save_member();
494 532

  
495
  if ($auth->can_change_password()
533
  if ($main::auth->can_change_password()
496 534
      && defined $form->{new_password}
497 535
      && ($form->{new_password} ne '********')) {
498
    $auth->change_password($form->{login}, $form->{new_password});
536
    $main::auth->change_password($form->{login}, $form->{new_password});
499 537
  }
500 538

  
501
  if ($webdav) {
502
    @webdavdirs =
539
  my ($login, $password, $newfile);
540
  if ($main::webdav) {
541
    my @webdavdirs =
503 542
      qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
504
    foreach $directory (@webdavdirs) {
505
      $file = "webdav/" . $directory . "/webdav-user";
543
    foreach my $directory (@webdavdirs) {
544
      my $file = "webdav/" . $directory . "/webdav-user";
506 545
      if ($form->{$directory}) {
507 546
        if (open(HTACCESS, "$file")) {
508 547
          while (<HTACCESS>) {
......
536 575
  }
537 576

  
538 577
  $form->{templates}       =~ s|.*/||;
539
  $form->{templates}       =  "${templates}/$form->{templates}";
578
  $form->{templates}       =  "$main::templates/$form->{templates}";
540 579
  $form->{mastertemplates} =~ s|.*/||;
541 580

  
542 581
  # create user template directory and copy master files
......
548 587
      umask(007);
549 588

  
550 589
      # copy templates to the directory
551
      opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $ERRNO");
552
      @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|odt|xml|txb)$/,
590
      opendir TEMPLATEDIR, "$main::templates/." or $form->error("$main::templates : $ERRNO");
591
      my @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|odt|xml|txb)$/,
553 592
        readdir TEMPLATEDIR;
554 593
      closedir TEMPLATEDIR;
555 594

  
556
      foreach $file (@templates) {
557
        open(TEMP, "$templates/$file")
558
          or $form->error("$templates/$file : $ERRNO");
595
      foreach my $file (@templates) {
596
        open(TEMP, "$main::templates/$file")
597
          or $form->error("$main::templates/$file : $ERRNO");
559 598

  
560 599
        $file =~ s/\Q$form->{mastertemplates}\E-//;
561 600
        open(NEW, ">$form->{templates}/$file")
562 601
          or $form->error("$form->{templates}/$file : $ERRNO");
563 602

  
564
        while ($line = <TEMP>) {
603
        while (my $line = <TEMP>) {
565 604
          print NEW $line;
566 605
        }
567 606
        close(TEMP);
......
574 613

  
575 614
  # Add new user to his groups.
576 615
  if (ref $form->{new_user_group_ids} eq 'ARRAY') {
577
    my $all_groups = $auth->read_groups();
578
    my %user       = $auth->read_user($form->{login});
616
    my $all_groups = $main::auth->read_groups();
617
    my %user       = $main::auth->read_user($form->{login});
579 618

  
580 619
    foreach my $group_id (@{ $form->{new_user_group_ids} }) {
581 620
      my $group = $all_groups->{$group_id};
......
583 622
      next if !$group;
584 623

  
585 624
      push @{ $group->{members} }, $user{id};
586
      $auth->save_group($group);
625
      $main::auth->save_group($group);
587 626
    }
588 627
  }
589 628

  
......
592 631
}
593 632

  
594 633
sub save_user_as_new {
634
  my $form     = $main::form;
635

  
595 636
  $form->{login} = $form->{new_user_login};
596 637
  delete @{$form}{qw(edit new_user_login)};
597 638

  
......
599 640
}
600 641

  
601 642
sub delete_user {
602
  my %members   = $auth->read_all_users();
643
  my $form     = $main::form;
644
  my $locale   = $main::locale;
645

  
646
  my %members   = $main::auth->read_all_users();
603 647
  my $templates = $members{$form->{login}}->{templates};
604 648

  
605
  $auth->delete_user($form->{login});
649
  $main::auth->delete_user($form->{login});
606 650

  
607 651
  if ($templates) {
608 652
    my $templates_in_use = 0;
609 653

  
610
    foreach $login (keys %members) {
654
    foreach my $login (keys %members) {
611 655
      next if $form->{login} eq $login;
612 656
      next if $members{$login}->{templates} ne $templates;
613 657
      $templates_in_use = 1;
......
635 679
sub get_value {
636 680
  my $line = shift;
637 681

  
682
  my $form     = $main::form;
683

  
638 684
  my ($null, $value) = split(/=/, $line, 2);
639 685

  
640 686
  # remove comments
......
647 693
}
648 694

  
649 695
sub pg_database_administration {
696
  my $form     = $main::form;
650 697

  
651 698
  $form->{dbdriver} = 'Pg';
652 699
  dbselect_source();
......
654 701
}
655 702

  
656 703
sub dbselect_source {
704
  my $form     = $main::form;
705
  my $locale   = $main::locale;
706

  
657 707
  $form->{dbport}    = '5432';
658 708
  $form->{dbuser}    = 'postgres';
659 709
  $form->{dbdefault} = 'template1';
......
669 719
}
670 720

  
671 721
sub test_db_connection {
722
  my $form     = $main::form;
723
  my $locale   = $main::locale;
724

  
672 725
  $form->{dbdriver} = 'Pg';
673 726
  User::dbconnect_vars($form, $form->{dbname});
674 727

  
......
685 738
}
686 739

  
687 740
sub continue {
688
  call_sub($form->{"nextsub"});
689
}
690

  
691
sub back {
692
  call_sub($form->{"back_nextsub"});
741
  call_sub($main::form->{"nextsub"});
693 742
}
694 743

  
695 744
sub update_dataset {
745
  my $form     = $main::form;
746
  my $locale   = $main::locale;
747

  
696 748
  $form->{title} =
697 749
      "Lx-Office ERP "
698 750
    . $locale->text('Database Administration') . " / "
......
707 759
}
708 760

  
709 761
sub dbupdate {
762
  my $form     = $main::form;
763
  my $locale   = $main::locale;
764

  
710 765
  $form->{stylesheet} = "lx-office-erp.css";
711 766
  $form->{title}      = $locale->text("Dataset upgrade");
712 767
  $form->header();
......
742 797
}
743 798

  
744 799
sub create_dataset {
800
  my $form     = $main::form;
801
  my $locale   = $main::locale;
802

  
745 803
  $form->{dbsources} = join " ", map { "[${_}]" } sort User->dbsources($form);
746 804

  
747 805
  $form->{CHARTS} = [];
748 806

  
749
  opendir SQLDIR, "sql/." or $form - error($ERRNO);
750
  foreach $item (sort grep /-chart\.sql\z/, readdir SQLDIR) {
807
  opendir SQLDIR, "sql/." or $form->error($ERRNO);
808
  foreach my $item (sort grep /-chart\.sql\z/, readdir SQLDIR) {
751 809
    next if ($item eq 'Default-chart.sql');
752 810
    $item =~ s/-chart\.sql//;
753 811
    push @{ $form->{CHARTS} }, { "name"     => $item,
......
755 813
  }
756 814
  closedir SQLDIR;
757 815

  
758
  my $default_charset = $dbcharset;
816
  my $default_charset = $main::dbcharset;
759 817
  $default_charset ||= Common::DEFAULT_CHARSET;
760 818

  
761 819
  my $cluster_encoding = User->dbclusterencoding($form);
762 820
  if ($cluster_encoding && ($cluster_encoding =~ m/^(?:UTF-?8|UNICODE)$/i)) {
763
    if ($dbcharset !~ m/^UTF-?8$/i) {
821
    if ($main::dbcharset !~ m/^UTF-?8$/i) {
764 822
      $form->show_generic_error($locale->text('The selected  PostgreSQL installation uses UTF-8 as its encoding. ' .
765 823
                                              'Therefore you have to configure Lx-Office to use UTF-8 as well.'),
766 824
                                'back_button' => 1);
......
788 846
}
789 847

  
790 848
sub dbcreate {
849
  my $form     = $main::form;
850
  my $locale   = $main::locale;
851

  
791 852
  $form->isblank("db", $locale->text('Dataset missing!'));
792 853

  
793 854
  User->dbcreate(\%$form);
......
802 863
}
803 864

  
804 865
sub delete_dataset {
805
  @dbsources = User->dbsources_unused($form);
866
  my $form     = $main::form;
867
  my $locale   = $main::locale;
868

  
869
  my @dbsources = User->dbsources_unused($form);
806 870
  $form->error($locale->text('Nothing to delete!')) unless @dbsources;
807 871

  
808 872
  $form->{title} =
......
816 880
}
817 881

  
818 882
sub dbdelete {
883
  my $form     = $main::form;
884
  my $locale   = $main::locale;
819 885

  
820 886
  if (!$form->{db}) {
821 887
    $form->error($locale->text('No Dataset selected!'));
......
832 898
}
833 899

  
834 900
sub backup_dataset {
901
  my $form     = $main::form;
902
  my $locale   = $main::locale;
903

  
835 904
  $form->{title} =
836 905
      "Lx-Office ERP "
837 906
    . $locale->text('Database Administration') . " / "
838 907
    . $locale->text('Backup Dataset');
839 908

  
840
  if ("$pg_dump_exe" eq "DISABLED") {
909
  if ("$main::pg_dump_exe" eq "DISABLED") {
841 910
    $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.'));
842 911
  }
843 912

  
......
854 923
}
855 924

  
856 925
sub backup_dataset_start {
926
  my $form     = $main::form;
927
  my $locale   = $main::locale;
928

  
857 929
  $form->{title} =
858 930
      "Lx-Office ERP "
859 931
    . $locale->text('Database Administration') . " / "
860 932
    . $locale->text('Backup Dataset');
861 933

  
862
  $pg_dump_exe ||= "pg_dump";
934
  $main::pg_dump_exe ||= "pg_dump";
863 935

  
864
  if ("$pg_dump_exe" eq "DISABLED") {
936
  if ("$main::pg_dump_exe" eq "DISABLED") {
865 937
    $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.'));
866 938
  }
867 939

  
......
887 959
  push @args, ("-p", $form->{dbport}) if ($form->{dbport});
888 960
  push @args, $form->{dbname};
889 961

  
890
  my $cmd  = "${pg_dump_exe} " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args);
962
  my $cmd  = "$main::pg_dump_exe " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args);
891 963
  my $name = "dataset_backup_$form->{dbname}_" . strftime("%Y%m%d", localtime()) . ".tar";
892 964

  
893 965
  if ($form->{destination} ne "email") {
......
926 998

  
927 999
    map { $mail->{$_} = $form->{$_} } qw(from to cc subject message);
928 1000

  
929
    $mail->{charset}     = $dbcharset ? $dbcharset : Common::DEFAULT_CHARSET;
1001
    $mail->{charset}     = $main::dbcharset ? $main::dbcharset : Common::DEFAULT_CHARSET;
930 1002
    $mail->{attachments} = [ { "filename" => $tmp, "name" => $name } ];
931 1003
    $mail->send();
932 1004

  
......
944 1016
}
945 1017

  
946 1018
sub restore_dataset {
1019
  my $form     = $main::form;
1020
  my $locale   = $main::locale;
1021

  
947 1022
  $form->{title} =
948 1023
      "Lx-Office ERP "
949 1024
    . $locale->text('Database Administration') . " / "
950 1025
    . $locale->text('Restore Dataset');
951 1026

  
952
  if ("$pg_restore_exe" eq "DISABLED") {
1027
  if ("$main::pg_restore_exe" eq "DISABLED") {
953 1028
    $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.'));
954 1029
  }
955 1030

  
956
  my $default_charset   = $dbcharset;
1031
  my $default_charset   = $main::dbcharset;
957 1032
  $default_charset    ||= Common::DEFAULT_CHARSET;
958 1033

  
959 1034
  $form->{DBENCODINGS}  = [];
......
969 1044
}
970 1045

  
971 1046
sub restore_dataset_start {
1047
  my $form     = $main::form;
1048
  my $locale   = $main::locale;
1049

  
972 1050
  $form->{title} =
973 1051
      "Lx-Office ERP "
974 1052
    . $locale->text('Database Administration') . " / "
975 1053
    . $locale->text('Restore Dataset');
976 1054

  
977
  $pg_restore_exe ||= "pg_restore";
1055
  $main::pg_restore_exe ||= "pg_restore";
978 1056

  
979
  if ("$pg_restore_exe" eq "DISABLED") {
1057
  if ("$main::pg_restore_exe" eq "DISABLED") {
980 1058
    $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.'));
981 1059
  }
982 1060

  
......
1063 1141
  push @args, ("-p", $form->{dbport}) if ($form->{dbport});
1064 1142
  push @args, $tmp;
1065 1143

  
1066
  my $cmd = "${pg_restore_exe} " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args);
1144
  my $cmd = "$main::pg_restore_exe " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args);
1067 1145

  
1068 1146
  my $in = IO::File->new("$cmd 2>&1 |");
1069 1147

  
......
1074 1152
    $form->error($locale->text('The pg_restore process could not be started.'));
1075 1153
  }
1076 1154

  
1077
  $AUTOFLUSH = 1;
1155
  $English::AUTOFLUSH = 1;
1078 1156

  
1079 1157
  $form->header();
1080 1158
  print $form->parse_html_template("admin/restore_dataset_start_header");
......
1092 1170
}
1093 1171

  
1094 1172
sub unlock_system {
1173
  my $form     = $main::form;
1174
  my $locale   = $main::locale;
1095 1175

  
1096
  unlink "$userspath/nologin";
1176
  unlink "$main::userspath/nologin";
1097 1177

  
1098 1178
  $form->{callback} = "admin.pl?action=list_users";
1099 1179

  
......
1102 1182
}
1103 1183

  
1104 1184
sub lock_system {
1185
  my $form     = $main::form;
1186
  my $locale   = $main::locale;
1105 1187

  
1106
  open(FH, ">$userspath/nologin")
1188
  open(FH, ">$main::userspath/nologin")
1107 1189
    or $form->error($locale->text('Cannot create Lock!'));
1108 1190
  close(FH);
1109 1191

  
......
1114 1196
}
1115 1197

  
1116 1198
sub yes {
1117
  call_sub($form->{yes_nextsub});
1199
  call_sub($main::form->{yes_nextsub});
1118 1200
}
1119 1201

  
1120 1202
sub no {
1121
  call_sub($form->{no_nextsub});
1203
  call_sub($main::form->{no_nextsub});
1122 1204
}
1123 1205

  
1124 1206
sub add {
1125
  call_sub($form->{add_nextsub});
1207
  call_sub($main::form->{add_nextsub});
1126 1208
}
1127 1209

  
1128 1210
sub edit {
1211
  my $form     = $main::form;
1212

  
1129 1213
  $form->{edit_nextsub} ||= 'edit_user';
1130 1214

  
1131 1215
  call_sub($form->{edit_nextsub});
1132 1216
}
1133 1217

  
1134 1218
sub delete {
1219
  my $form     = $main::form;
1220

  
1135 1221
  $form->{delete_nextsub} ||= 'delete_user';
1136 1222

  
1137 1223
  call_sub($form->{delete_nextsub});
1138 1224
}
1139 1225

  
1140 1226
sub save {
1227
  my $form     = $main::form;
1228

  
1141 1229
  $form->{save_nextsub} ||= 'save_user';
1142 1230

  
1143 1231
  call_sub($form->{save_nextsub});
1144 1232
}
1145 1233

  
1146 1234
sub back {
1147
  call_sub($form->{back_nextsub});
1235
  call_sub($main::form->{back_nextsub});
1148 1236
}
1149 1237

  
1150 1238
sub dispatcher {
1239
  my $form     = $main::form;
1240
  my $locale   = $main::locale;
1241

  
1151 1242
  foreach my $action (qw(create_standard_group dont_create_standard_group
1152 1243
                         save_user delete_user save_user_as_new)) {
1153 1244
    if ($form->{"action_${action}"}) {

Auch abrufbar als: Unified diff