[chronojump] Compujump can know if a user is admin (locally)



commit 4d8c39eed2dc5bc7fca319a3f4566103da414a8c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jan 8 17:50:06 2019 +0100

    Compujump can know if a user is admin (locally)

 src/config.cs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/config.cs b/src/config.cs
index 6cb46792..faa6467c 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -40,6 +40,7 @@ public class Config
        public bool Compujump;
        public string CompujumpServerURL = "";
        public int CompujumpStationID = -1;
+       public int CompujumpAdminID = -1; //undefined
        public Constants.Menuitem_modes CompujumpStationMode = Constants.Menuitem_modes.UNDEFINED;
        public string RunScriptOnExit;
        public bool PlaySoundsFromFile;
@@ -88,6 +89,8 @@ public class Config
                                                CompujumpServerURL = parts[1];
                                        else if(parts[0] == "CompujumpStationID" && parts[1] != "" && 
Util.IsNumber(parts[1], false))
                                                CompujumpStationID = Convert.ToInt32(parts[1]);
+                                       else if(parts[0] == "CompujumpAdminID" && parts[1] != "" && 
Util.IsNumber(parts[1], false))
+                                               CompujumpAdminID = Convert.ToInt32(parts[1]);
                                        else if(parts[0] == "CompujumpStationMode" && 
Enum.IsDefined(typeof(Constants.Menuitem_modes), parts[1]))
                                                CompujumpStationMode = (Constants.Menuitem_modes)
                                                        Enum.Parse(typeof(Constants.Menuitem_modes), 
parts[1]);
@@ -100,7 +103,17 @@ public class Config
                        }
                }
        }
-       
+
+       //p is currentPerson
+       public bool CompujumpUserIsAdmin(Person p)
+       {
+               LogB.Information("CompujumpUserIsAdmin ?");
+               LogB.Information(string.Format("{0}, {1}", p.UniqueID, CompujumpAdminID));
+               LogB.Information(string.Format("{0}, {1}, {2}", p != null, Compujump, p.UniqueID == 
CompujumpAdminID));
+
+               return (p != null && Compujump && p.UniqueID == CompujumpAdminID);
+       }
+
        /*
        public void Read()
        {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]