Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2acad5a6

Von Sven Schöling vor mehr als 12 Jahren hinzugefügt

  • ID 2acad5a65979321f2bd7ef3d51c22ddbe077d99d
  • Vorgänger 2ee0204e
  • Nachfolger 682454ce

User: Bei Zugriffen auf die User DB vorher prüfen ob die Datenbank das schon kann.

Unterschiede anzeigen:

SL/User.pm
730 730

  
731 731
  # add login to employee table if it does not exist
732 732
  # no error check for employee table, ignore if it does not exist
733
  my ($id)  = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login});
733
  my ($id)         = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login});
734
  my ($good_db)    = selectrow_query($form, $dbh, qq|select * from pg_tables where tablename = ? and schemaname = ?|, 'schema_info', 'public');
735
  my  $can_delete;
736
     ($can_delete) = selectrow_query($form, $dbh, qq|SELECT tag FROM schema_info WHERE tag = ?|, 'employee_deleted') if $good_db;
734 737

  
735 738
  if (!$id) {
736 739
    my $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|;
737 740
    do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel}, "user"));
738 741

  
739
  } elsif ($update_existing) {
742
  } elsif ($update_existing && $can_delete) {
740 743
    my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user', deleted = 'f' WHERE id = ?|;
741 744
    do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id);
742 745
  }

Auch abrufbar als: Unified diff