X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDBUtils.pm;h=c9c70c95a94fabd69881b6d8c79465925ff75af3;hb=e713c3142d8c603b31d25fff371da47f56976aae;hp=d060bcb8e01ef00fdd78ea7899d2132b042f5288;hpb=bc40bcabc425b99f3b79a5544684a6fe8674adfe;p=kivitendo-erp.git diff --git a/SL/DBUtils.pm b/SL/DBUtils.pm index d060bcb8e..c9c70c95a 100644 --- a/SL/DBUtils.pm +++ b/SL/DBUtils.pm @@ -392,11 +392,20 @@ sub like { return "%" . SL::Util::trim($string // '') . "%"; } +sub role_is_superuser { + my ($dbh, $login) = @_; + my ($is_superuser) = $dbh->selectrow_array(qq|SELECT usesuper FROM pg_user WHERE usename = ?|, undef, $login); + + return $is_superuser; +} + 1; __END__ +=encoding utf-8 + =head1 NAME SL::DBUTils.pm: All about database connections in kivitendo @@ -426,23 +435,100 @@ SL::DBUTils.pm: All about database connections in kivitendo =head1 DESCRIPTION -DBUtils is the attempt to reduce the amount of overhead it takes to retrieve information from the database in kivitendo. Previously it would take about 15 lines of code just to get one single integer out of the database, including failure procedures and importing the necessary packages. Debugging would take even more. +DBUtils provides wrapper functions for low level database retrieval. It saves +you the trouble of mucking around with statement handles for small database +queries and does exception handling in the common cases for you. + +Query and retrieval function share the parameter scheme: + + query_or_retrieval(C