]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp
Removed some unused stuff.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_admin.cpp
index a87c1dbfd765127462866f908b2bb62f724babdf..9d87f30047bc434e8d6688451cb713fd2ef990b4 100644 (file)
@@ -37,7 +37,7 @@ if (!priv->adminChg)
     return;
     }
 
     return;
     }
 
-string s;
+std::string s;
 //answerList->clear();
 answerList->erase(answerList->begin(), answerList->end());
 
 //answerList->clear();
 answerList->erase(answerList->begin(), answerList->end());
 
@@ -99,7 +99,7 @@ if (admins->Del(adminToDel, currAdmin) == 0)
     }
 else
     {
     }
 else
     {
-    string s;
+    std::string s;
     strprintf(&s, "<DelAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
     answerList->push_back(s);
     }
     strprintf(&s, "<DelAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
     answerList->push_back(s);
     }
@@ -155,7 +155,7 @@ if (admins->Add(adminToAdd, currAdmin) == 0)
     }
 else
     {
     }
 else
     {
-    string s;
+    std::string s;
     strprintf(&s, "<AddAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
     answerList->push_back(s);
     }
     strprintf(&s, "<AddAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
     answerList->push_back(s);
     }
@@ -212,49 +212,44 @@ void PARSER_CHG_ADMIN::CreateAnswer()
 {
 answerList->erase(answerList->begin(), answerList->end());
 
 {
 answerList->erase(answerList->begin(), answerList->end());
 
-ADMIN_CONF conf;
-conf.login = login;
+
 if (!login.res_empty())
     {
 if (!login.res_empty())
     {
-    string s;
-    //if (admins->FindAdmin(login.data()) != NULL)
-    //    {
-        if (!password.res_empty())
-            conf.password = password.data();
+    ADMIN * origAdmin = NULL;
 
 
-        if (!privAsString.res_empty())
-            {
-            int p = 0;
-            if (str2x(privAsString.data().c_str(), p) < 0)
-                {
-                strprintf(&s, "<ChgAdmin Result = \"Incorrect parameter Priv.\"/>" );
-                answerList->push_back(s);
-                return;
-                }
-            //memcpy(&conf.priv, &p, sizeof(conf.priv));
-            conf.priv.userStat      = (p & 0x0003) >> 0x00; // 1+2
-            conf.priv.userConf      = (p & 0x000C) >> 0x02; // 4+8
-            conf.priv.userCash      = (p & 0x0030) >> 0x04; // 10+20
-            conf.priv.userPasswd    = (p & 0x00C0) >> 0x06; // 40+80
-            conf.priv.userAddDel    = (p & 0x0300) >> 0x08; // 100+200
-            conf.priv.adminChg      = (p & 0x0C00) >> 0x0A; // 400+800
-            conf.priv.tariffChg     = (p & 0x3000) >> 0x0C; // 1000+2000
-            }
+    if (admins->Find(login, &origAdmin))
+        {
+        answerList->push_back(std::string("<ChgAdmin Result = \"Admin '") + login.data() + "' is not found.\"/>");
+        return;
+        }
 
 
-        if (admins->Change(conf, currAdmin) != 0)
-            {
-            strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
-            answerList->push_back(s);
-            }
-        else
+    ADMIN_CONF conf(origAdmin->GetConf());
+
+    if (!password.res_empty())
+        conf.password = password.data();
+
+    if (!privAsString.res_empty())
+        {
+        int p = 0;
+        if (str2x(privAsString.data().c_str(), p) < 0)
             {
             {
-            answerList->push_back("<ChgAdmin Result = \"Ok\"/>");
+            answerList->push_back("<ChgAdmin Result = \"Incorrect parameter Priv.\"/>");
+            return;
             }
             }
-        return;
-    //    }
-    //strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
-    //answerList->push_back(s);
-    //return;
+
+        conf.priv.FromInt(p);
+        }
+
+    if (admins->Change(conf, currAdmin) != 0)
+        {
+        std::string s;
+        strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
+        answerList->push_back(s);
+        }
+    else
+        {
+        answerList->push_back("<ChgAdmin Result = \"Ok\"/>");
+        }
     }
 else
     {
     }
 else
     {