Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8ccdbe3d

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

  • ID 8ccdbe3d60faaed72573207e3917d43ffae61eca
  • Vorgänger 870e380d
  • Nachfolger fbd76394

licences strict

Unterschiede anzeigen:

bin/mozilla/licenses.pl
37 37

  
38 38
require "bin/mozilla/common.pl";
39 39

  
40
use strict;
41

  
40 42
sub quot {
41
  $lxdebug->enter_sub();
43
  $main::lxdebug->enter_sub();
42 44
  $_[0] =~ s/\"/\"/g;
43
  $lxdebug->leave_sub();
45
  $main::lxdebug->leave_sub();
44 46
  return $_[0];
45 47
}
46 48

  
47 49
sub form_header {
48
  $lxdebug->enter_sub();
50
  $main::lxdebug->enter_sub();
51

  
52
  $main::auth->assert('license_edit');
49 53

  
50
  $auth->assert('license_edit');
54
  my $form     = $main::form;
51 55

  
52 56
  $form->{jsscript} = 1;
53 57
  $form->header();
......
56 60
    qq|<body>
57 61

  
58 62
<form method=post action=$form->{script}>|);
59
  $lxdebug->leave_sub();
63
  $main::lxdebug->leave_sub();
60 64
}
61 65

  
62 66
sub form_footer {
63
  $lxdebug->enter_sub();
67
  $main::lxdebug->enter_sub();
68

  
69
  $main::auth->assert('license_edit');
64 70

  
65
  $auth->assert('license_edit');
71
  my $form     = $main::form;
66 72

  
67 73
  my @items = qw(old_callback previousform);
68 74
  push(@items, @{ $form->{"hidden"} });
......
76 82
</body>
77 83
</html>
78 84
|);
79
  $lxdebug->leave_sub();
85
  $main::lxdebug->leave_sub();
80 86
}
81 87

  
82 88
sub set_std_hidden {
83
  $lxdebug->enter_sub();
89
  $main::lxdebug->enter_sub();
90

  
91
  my $form     = $main::form;
92

  
84 93
  $form->{"hidden"} = ["comment", "validuntil", "quantity", @_];
85
  $lxdebug->leave_sub();
94
  $main::lxdebug->leave_sub();
86 95
}
87 96

  
88 97
sub print_part_selection {
89
  $lxdebug->enter_sub();
98
  $main::lxdebug->enter_sub();
90 99

  
91
  $auth->assert('license_edit');
100
  $main::auth->assert('license_edit');
101

  
102
  my $form     = $main::form;
103
  my $locale   = $main::locale;
92 104

  
93 105
  form_header();
94 106
  set_std_hidden("business");
......
109 121
  </tr>
110 122
        |);
111 123

  
112
  $j = 1;
113
  for ($i = 1; $i <= scalar(@{ $form->{"parts"} }); $i++) {
114
    %p = %{ $form->{"parts"}->[$i - 1] };
124
  my $j = 1;
125
  for (my $i = 1; $i <= scalar(@{ $form->{"parts"} }); $i++) {
126
    my %p = %{ $form->{"parts"}->[$i - 1] };
127
    my $checked;
115 128
    if ($i == 1) {
116 129
      $checked = "checked";
117 130
    } else {
......
139 152
<input type=submit name=action value=| . $locale->text('Continue') . qq|>|);
140 153

  
141 154
  form_footer();
142
  $lxdebug->leave_sub();
155
  $main::lxdebug->leave_sub();
143 156
}
144 157

  
145 158
sub print_customer_selection {
146
  $lxdebug->enter_sub();
159
  $main::lxdebug->enter_sub();
160

  
161
  $main::auth->assert('license_edit');
147 162

  
148
  $auth->assert('license_edit');
163
  my $form     = $main::form;
164
  my $locale   = $main::locale;
149 165

  
150 166
  form_header();
151 167
  set_std_hidden("parts_id", "partnumber", "description");
......
170 186

  
171 187
  print(qq|<tr><td colspan=6><hr size=3 noshade></td></tr>|);
172 188

  
173
  $j = 1;
174
  for ($i = 1; $i <= scalar(@{ $form->{"all_customers"} }); $i++) {
175
    %c = %{ $form->{"all_customers"}->[$i - 1] };
189
  my $j = 1;
190
  for (my $i = 1; $i <= scalar(@{ $form->{"all_customers"} }); $i++) {
191
    my %c = %{ $form->{"all_customers"}->[$i - 1] };
192
    my $checked;
176 193
    if ($i == 1) {
177 194
      $checked = "checked";
178 195
    } else {
......
202 219
<input type=submit name=action value=| . $locale->text('Continue') . qq|>|);
203 220

  
204 221
  form_footer();
205
  $lxdebug->leave_sub();
222
  $main::lxdebug->leave_sub();
206 223
}
207 224

  
208 225
sub print_license_form {
209
  $lxdebug->enter_sub();
226
  $main::lxdebug->enter_sub();
210 227

  
211
  $auth->assert('license_edit');
228
  $main::auth->assert('license_edit');
229

  
230
  my $form     = $main::form;
231
  my %myconfig = %main::myconfig;
232
  my $locale   = $main::locale;
212 233

  
213 234
  print(
214 235
    qq|
......
236 257
      if (!defined($form->{"customer_id"})) {
237 258
        $form->{"customer_id"} = $_->{"id"};
238 259
      }
239
      $selected = ($_->{"id"} * 1) == $form->{"customer_id"} ? "selected" : "";
260
      my $selected = ($_->{"id"} * 1) == $form->{"customer_id"} ? "selected" : "";
240 261
      print(qq|<option $selected> $_->{"name"}--$_->{"id"}</option>|);
241 262
    }
242 263
    print(qq|</select></td>|);
......
291 312
    $form->write_trigger(\%myconfig, 1, "validuntil", "BL",
292 313
                         "trigger_validuntil"));
293 314

  
294
  $lxdebug->leave_sub();
315
  $main::lxdebug->leave_sub();
295 316
}
296 317

  
297 318
sub add {
298
  $lxdebug->enter_sub();
319
  $main::lxdebug->enter_sub();
320

  
321
  $main::auth->assert('license_edit');
299 322

  
300
  $auth->assert('license_edit');
323
  my $form     = $main::form;
324
  my $locale   = $main::locale;
301 325

  
302
  if (!$lizenzen) {
326
  if (!$main::lizenzen) {
303 327
    $form->error(
304 328
                 $locale->text(
305 329
                   'The licensing module has been deactivated in lx-erp.conf.')
......
309 333
  $form->{"initial"} = 1;
310 334

  
311 335
  do_add();
312
  $lxdebug->leave_sub();
336
  $main::lxdebug->leave_sub();
313 337
}
314 338

  
315 339
sub do_add {
316
  $lxdebug->enter_sub();
340
  $main::lxdebug->enter_sub();
317 341

  
318
  $auth->assert('license_edit');
342
  $main::auth->assert('license_edit');
343

  
344
  my $form     = $main::form;
345
  my %myconfig = %main::myconfig;
319 346

  
320 347
  $form->{"hidden"} = ["parts_id"];
321 348
  form_header();
322 349

  
323 350
  if ($form->{"ndx"}) {
324
    $ndx = $form->{"ndx"};
351
    my $ndx = $form->{"ndx"};
325 352
    foreach (keys(%{$form})) {
326 353
      next unless (/^new_.*_${ndx}$/);
327 354
      s/^new_//;
......
337 364
  if ($form->{"customer_name"}) {
338 365
    LICENSES->get_customers(\%myconfig, $form);
339 366
    if (scalar(@{ $form->{"all_customers"} }) == 1) {
340
      %c                       = %{ $form->{"all_customers"}->[0] };
367
      my %c                       = %{ $form->{"all_customers"}->[0] };
341 368
      $form->{"customer_id"}   = $c{"id"};
342 369
      $form->{"customer_name"} = $c{"name"};
343 370
    } elsif (scalar(@{ $form->{"all_customers"} }) == 0) {
......
376 403
  print_license_form($form->{"parts_id"} && $form->{"customer_id"});
377 404

  
378 405
  form_footer();
379
  $lxdebug->leave_sub();
406
  $main::lxdebug->leave_sub();
380 407
}
381 408

  
382 409
sub update {
383
  $lxdebug->enter_sub();
410
  $main::lxdebug->enter_sub();
411

  
412
  $main::auth->assert('license_edit');
384 413

  
385
  $auth->assert('license_edit');
414
  my $form     = $main::form;
386 415

  
387 416
  do_add();
388 417

  
389
  $lxdebug->leave_sub();
418
  $main::lxdebug->leave_sub();
390 419
}
391 420

  
392 421
sub continue {
393
  $lxdebug->enter_sub();
422
  $main::lxdebug->enter_sub();
423

  
424
  my $form     = $main::form;
425

  
394 426
  call_sub($form->{"nextsub"});
395
  $lxdebug->leave_sub();
427
  $main::lxdebug->leave_sub();
396 428
}
397 429

  
398 430
sub save {
399
  $lxdebug->enter_sub();
431
  $main::lxdebug->enter_sub();
400 432

  
401
  $auth->assert('license_edit');
433
  $main::auth->assert('license_edit');
434

  
435
  my $form     = $main::form;
436
  my %myconfig = %main::myconfig;
437
  my $locale   = $main::locale;
402 438

  
403 439
  ($form->{customername}, $form->{customer_id}) = split /--/,
404 440
    $form->{customer};
......
415 451
    $form->error($locale->text('Please enter a license key.'));
416 452
  }
417 453

  
418
  $rc = LICENSES->save_license(\%myconfig, \%$form);
454
  my $rc = LICENSES->save_license(\%myconfig, \%$form);
419 455

  
420 456
  # load previous variables
421 457
  if ($form->{previousform}) {
422 458

  
423 459
    # save the new form variables before splitting previousform
460
    my %newform;
424 461
    map { $newform{$_} = $form->{$_} } keys %$form;
425 462

  
426
    $previousform = $form->unescape($form->{previousform});
463
    my $previousform = $form->unescape($form->{previousform});
427 464

  
428 465
    # don't trample on previous variables
429 466
    map { delete $form->{$_} } keys %newform;
430 467

  
431 468
    # now take it apart and restore original values
432
    foreach $item (split /&/, $previousform) {
433
      ($key, $value) = split /=/, $item, 2;
469
    foreach my $item (split /&/, $previousform) {
470
      my ($key, $value) = split /=/, $item, 2;
434 471
      $value =~ s/%26/&/g;
435 472
      $form->{$key} = $value;
436 473
    }
......
442 479
    delete $form->{action};
443 480

  
444 481
    # restore original callback
445
    $callback = $form->unescape($form->{callback});
482
    my $callback = $form->unescape($form->{callback});
446 483
    $form->{callback} = $form->unescape($form->{old_callback});
447 484
    delete $form->{old_callback};
448 485

  
449 486
    # put callback together
450
    foreach $key (keys %$form) {
487
    foreach my $key (keys %$form) {
451 488
      next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
452 489

  
453 490
      # do single escape for Apache 2.0
454
      $value = $form->escape($form->{$key}, 1);
491
      my $value = $form->escape($form->{$key}, 1);
455 492
      $callback .= qq|&$key=$value|;
456 493
    }
457 494
    $form->{callback} = $callback;
......
466 503
    form_footer();
467 504
  }
468 505

  
469
  $lxdebug->leave_sub();
506
  $main::lxdebug->leave_sub();
470 507
}
471 508

  
472 509
sub search {
473
  $lxdebug->enter_sub();
510
  $main::lxdebug->enter_sub();
511

  
512
  $main::auth->assert('license_edit');
474 513

  
475
  $auth->assert('license_edit');
514
  my $form     = $main::form;
515
  my $locale   = $main::locale;
476 516

  
477
  if (!$lizenzen) {
517
  if (!$main::lizenzen) {
478 518
    $form->error(
479 519
                 $locale->text(
480 520
                   'The licensing module has been deactivated in lx-erp.conf.')
......
524 564
        |);
525 565

  
526 566
  form_footer();
527
  $lxdebug->leave_sub();
567
  $main::lxdebug->leave_sub();
528 568
}
529 569

  
530 570
sub do_search {
531
  $lxdebug->enter_sub();
571
  $main::lxdebug->enter_sub();
532 572

  
533
  $auth->assert('license_edit');
573
  $main::auth->assert('license_edit');
574

  
575
  my $form     = $main::form;
576
  my %myconfig = %main::myconfig;
577
  my $locale   = $main::locale;
534 578

  
535 579
  LICENSES->search(\%myconfig, $form);
536 580

  
537
  $callback = "";
581
  my $callback = "";
538 582
  map { $callback .= "\&${_}=" . $form->escape($form->{$_}, 1) }
539 583
    qw(db partnumber description customer_name all expiring_in show_expired);
540
  $details    = $form->{"script"} . "?action=details" . $callback . "\&id=";
541
  $invdetails = "is.pl?action=edit" . $callback . "\&id=";
584
  my $details    = $form->{"script"} . "?action=details" . $callback . "\&id=";
585
  my $invdetails = "is.pl?action=edit" . $callback . "\&id=";
542 586
  $callback   = $form->{"script"} . "?action=do_search" . $callback;
543 587

  
544 588
  $form->{"sortby"} = "validuntil" unless ($form->{"sortby"});
545 589
  $form->{"sortasc"} *= 1;
590
  my %columns;
546 591
  foreach (("partnumber", "description", "name", "validuntil", "invnumber")) {
547 592
    $columns{$_} = $callback . "\&sortby=${_}\&sortasc=";
548 593
    if ($form->{"sortby"} eq $_) {
......
595 640
      </tr>
596 641
        |);
597 642

  
598
  $j = 1;
599
  for ($i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) {
600
    $ref = $form->{"licenses"}->[$i];
643
  my $j = 1;
644
  for (my $i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) {
645
    my $ref = $form->{"licenses"}->[$i];
601 646
    print(
602 647
      qq|
603 648
          <tr class=listrow$j>
......
635 680
        |);
636 681

  
637 682
  form_footer();
638
  $lxdebug->leave_sub();
683
  $main::lxdebug->leave_sub();
639 684
}
640 685

  
641 686
sub details {
642
  $lxdebug->enter_sub();
687
  $main::lxdebug->enter_sub();
688

  
689
  $main::auth->assert('license_edit');
643 690

  
644
  $auth->assert('license_edit');
691
  my $form     = $main::form;
692
  my %myconfig = %main::myconfig;
693
  my $locale   = $main::locale;
645 694

  
646 695
  LICENSES->get_license(\%myconfig, $form);
647 696
  map(
......
696 745
        |);
697 746

  
698 747
  form_footer();
699
  $lxdebug->leave_sub();
748
  $main::lxdebug->leave_sub();
700 749
}
701 750

  
702 751
1;

Auch abrufbar als: Unified diff