diff --git a/src/include/user.h b/src/include/user.h index 8bc2f3f40..74cb68f74 100755 --- a/src/include/user.h +++ b/src/include/user.h @@ -7,3 +7,4 @@ #define USR_AUTSTR "AUTSTR" #define USR_PERMISSION "PERMISSION" #define USR_CONNECTED "CONNECTED" +#define USR_SUPERVISOR "SUPERVISOR" diff --git a/src/include/utility.cpp b/src/include/utility.cpp index 29b80b1c7..28c34f34c 100755 --- a/src/include/utility.cpp +++ b/src/include/utility.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include "../cg/cfban.h" @@ -763,6 +764,18 @@ long daytime() return timeloc->tm_sec + timeloc->tm_min * 100L + timeloc->tm_hour * 10000L; } +// @func Ritorna se l'utente attuale è un supervisore +bool supervisor() +{ + if (admin()) + return true; + + const TString & u = user(); + const TRectype & recuser = cache().get(LF_USER, u); + + return recuser.get_bool(USR_SUPERVISOR); +} + // DON'T cache this bool because hostname can be local or server static bool is_sirio_station(const char* hostname) { diff --git a/src/include/utility.h b/src/include/utility.h index 8a202a53c..92f12c647 100755 --- a/src/include/utility.h +++ b/src/include/utility.h @@ -97,6 +97,8 @@ const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza istream& eatwhite (istream& i); +bool supervisor(); + const TString& get_hostname(); bool is_debug_station(); bool is_power_station();