From 2acad5a65979321f2bd7ef3d51c22ddbe077d99d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 28 Feb 2012 13:16:56 +0100 Subject: [PATCH] =?utf8?q?User:=20Bei=20Zugriffen=20auf=20die=20User=20DB?= =?utf8?q?=20vorher=20pr=C3=BCfen=20ob=20die=20Datenbank=20das=20schon=20k?= =?utf8?q?ann.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/User.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SL/User.pm b/SL/User.pm index 7ae2eb850..2addf2905 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -730,13 +730,16 @@ sub create_employee_entry { # add login to employee table if it does not exist # no error check for employee table, ignore if it does not exist - my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); + my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); + my ($good_db) = selectrow_query($form, $dbh, qq|select * from pg_tables where tablename = ? and schemaname = ?|, 'schema_info', 'public'); + my $can_delete; + ($can_delete) = selectrow_query($form, $dbh, qq|SELECT tag FROM schema_info WHERE tag = ?|, 'employee_deleted') if $good_db; if (!$id) { my $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|; do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel}, "user")); - } elsif ($update_existing) { + } elsif ($update_existing && $can_delete) { my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user', deleted = 'f' WHERE id = ?|; do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id); } -- 2.20.1