From 7fda5001406e465ebf2a37753a81b3f7716a0a56 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Nov 2022 18:28:23 -0400 Subject: [PATCH] Make permission values 0 based but stsarting with UNKNOWN because when doing permission+0 in SQL, we get a 1-based value --- src/zm_group_permission.cpp | 2 +- src/zm_group_permission.h | 2 +- src/zm_monitor_permission.cpp | 2 +- src/zm_monitor_permission.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/zm_group_permission.cpp b/src/zm_group_permission.cpp index 62cbeb67a..be837fa8b 100644 --- a/src/zm_group_permission.cpp +++ b/src/zm_group_permission.cpp @@ -64,7 +64,7 @@ Group_Permission::Permission Group_Permission::getPermission(int monitor_id) { std::vector Group_Permission::find(int p_user_id) { std::vector results; - std::string sql = stringtf("SELECT `Id`,`UserId`,`GroupId`,`Permission` FROM Groups_Permissions WHERE `UserId`='%d'", p_user_id); + std::string sql = stringtf("SELECT `Id`,`UserId`,`GroupId`,`Permission`+0 FROM Groups_Permissions WHERE `UserId`='%d'", p_user_id); MYSQL_RES *result = zmDbFetch(sql.c_str()); diff --git a/src/zm_group_permission.h b/src/zm_group_permission.h index 5b8e72817..db7479bed 100644 --- a/src/zm_group_permission.h +++ b/src/zm_group_permission.h @@ -27,7 +27,7 @@ class Group_Permission { public: - typedef enum { PERM_INHERIT=0, PERM_NONE = 1, PERM_VIEW, PERM_EDIT } Permission; + typedef enum { PERM_UNKNOWN=0, PERM_INHERIT, PERM_NONE, PERM_VIEW, PERM_EDIT } Permission; protected: int id; diff --git a/src/zm_monitor_permission.cpp b/src/zm_monitor_permission.cpp index 08d1d8d22..b71d8d63e 100644 --- a/src/zm_monitor_permission.cpp +++ b/src/zm_monitor_permission.cpp @@ -47,7 +47,7 @@ void Monitor_Permission::Copy(const Monitor_Permission &mp) { std::vector Monitor_Permission::find(int p_user_id) { std::vector results; - std::string sql = stringtf("SELECT `Id`,`UserId`,`MonitorId`,`Permission` FROM Monitors_Permissions WHERE `UserId`='%d'", p_user_id); + std::string sql = stringtf("SELECT `Id`,`UserId`,`MonitorId`,`Permission`+0 FROM Monitors_Permissions WHERE `UserId`='%d'", p_user_id); MYSQL_RES *result = zmDbFetch(sql.c_str()); diff --git a/src/zm_monitor_permission.h b/src/zm_monitor_permission.h index 5edce98c7..61cab4a74 100644 --- a/src/zm_monitor_permission.h +++ b/src/zm_monitor_permission.h @@ -27,7 +27,7 @@ class Monitor_Permission { public: - typedef enum { PERM_INHERIT=0, PERM_NONE = 1, PERM_VIEW, PERM_EDIT } Permission; + typedef enum { PERM_UNKNOWN=0, PERM_INHERIT, PERM_NONE, PERM_VIEW, PERM_EDIT } Permission; protected: int id;