From c3bc616a9669b079523e905b6c3177171f19d1df Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 5 Sep 2015 00:30:54 +0200 Subject: added library function to get fullname diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index c535576..ef7740d 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -209,6 +209,26 @@ sub check_user return (0, 'OK', "user '" . $username . "' not known by rivendell"); } +sub get_fullname +{ + my ($dbh, $username) = @_; + + my $sql = qq{select FULL_NAME from USERS where LOGIN_NAME = ?;}; + my $sth = $dbh->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); + + $sth->execute($username) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my ($fullname) = $sth->fetchrow_array; + $sth->finish(); + + unless(defined $fullname) { + return (undef, 'ERROR', "user '" . $username . "' not known by rivendell") + } + return ($fullname, 'OK', 'success'); +} + sub get_users { my ($dbh) = @_; -- cgit v0.10.2