Make permission values 0 based but stsarting with UNKNOWN because when doing permission+0 in SQL, we get a 1-based value

pull/3630/head
Isaac Connor 2022-11-03 18:28:23 -04:00
parent d583c10fa6
commit 7fda500140
4 changed files with 4 additions and 4 deletions

View File

@ -64,7 +64,7 @@ Group_Permission::Permission Group_Permission::getPermission(int monitor_id) {
std::vector<Group_Permission> Group_Permission::find(int p_user_id) {
std::vector<Group_Permission> 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());

View File

@ -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;

View File

@ -47,7 +47,7 @@ void Monitor_Permission::Copy(const Monitor_Permission &mp) {
std::vector<Monitor_Permission> Monitor_Permission::find(int p_user_id) {
std::vector<Monitor_Permission> 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());

View File

@ -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;