]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp
Merge branch 'master' into full-month-stats
[stg.git] / projects / stargazer / plugins / configuration / rpcconfig / users_methods.cpp
index 72fb399e313d204caad6924fb8af551499fb4bbe..4932e146ccfefce2d89428e3ef9de3c89297a931 100644 (file)
@@ -1,14 +1,16 @@
-#include "users_methods.h"
+#include <cerrno>
 
-#include "../../../users.h"
-#include "../../../admins.h"
-#include "../../../tariffs.h"
+#include "stg/users.h"
+#include "stg/admins.h"
+#include "stg/tariffs.h"
+#include "stg/user_ips.h"
+#include "stg/common.h"
+#include "stg/user_property.h"
 
+#include "users_methods.h"
 #include "rpcconfig.h"
 #include "user_helper.h"
-#include "user_ips.h"
 #include "utils.h"
-#include "common.h"
 
 //------------------------------------------------------------------------------
 
@@ -30,7 +32,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
 if (users->FindByName(login, &u))
     {
@@ -68,15 +70,15 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN admin;
+ADMIN * admin = NULL;
 
-if (admins->FindAdmin(adminInfo.admin, &admin))
+if (admins->Find(adminInfo.admin, &admin))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
 if (users->FindByName(login, &u))
     {
@@ -112,17 +114,17 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN admin;
+ADMIN admin;
 
-if (admins->FindAdmin(adminInfo.admin, &admin))
+if (admins->Find(adminInfo.admin, &admin))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
-if (users->FindByName(login, &u))
+if (!users->FindByName(login, &u))
     {
     users->Del(login, admin);
     *retvalPtr = xmlrpc_c::value_boolean(true);
@@ -156,7 +158,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
 bool hidePassword = !adminInfo.priviledges.userConf ||
                     !adminInfo.priviledges.userPasswd;
 
-user_iter u;
+USER_PTR u;
 
 int h = users->OpenSearch();
 if (!h)
@@ -204,15 +206,15 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN admin;
+ADMIN admin;
 
-if (admins->FindAdmin(adminInfo.admin, &admin))
+if (admins->Find(adminInfo.admin, &admin))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
 if (users->FindByName(login, &u))
     {
@@ -257,15 +259,15 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN admin;
+ADMIN admin;
 
-if (admins->FindAdmin(adminInfo.admin, &admin))
+if (admins->Find(adminInfo.admin, &admin))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
 if (users->FindByName(login, &u))
     {
@@ -273,10 +275,10 @@ if (users->FindByName(login, &u))
     return;
     }
 
-double cash = u->property.cash.Get();
+double cash = u->GetProperty().cash.Get();
 cash += amount;
 
-if (!u->property.cash.Set(cash, admin, login, store, comment))
+if (!u->GetProperty().cash.Set(cash, admin, login, store, comment))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
@@ -307,15 +309,15 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN admin;
+ADMIN admin;
 
-if (admins->FindAdmin(adminInfo.admin, &admin))
+if (admins->Find(adminInfo.admin, &admin))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
 if (users->FindByName(login, &u))
     {
@@ -323,7 +325,7 @@ if (users->FindByName(login, &u))
     return;
     }
 
-if (!u->property.cash.Set(cash, admin, login, store, comment))
+if (!u->GetProperty().cash.Set(cash, admin, login, store, comment))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
@@ -355,15 +357,15 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN admin;
+ADMIN admin;
 
-if (admins->FindAdmin(adminInfo.admin, &admin))
+if (admins->Find(adminInfo.admin, &admin))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
     }
 
-user_iter u;
+USER_PTR u;
 
 if (users->FindByName(login, &u))
     {
@@ -375,10 +377,10 @@ if (tariffs->FindByName(tariff))
     {
     if (delayed)
         {
-        if (u->property.nextTariff.Set(tariff,
-                                       admin,
-                                       login,
-                                       store))
+        if (u->GetProperty().nextTariff.Set(tariff,
+                                            admin,
+                                            login,
+                                            store))
             {
             u->WriteConf();
             *retvalPtr = xmlrpc_c::value_boolean(true);
@@ -387,11 +389,12 @@ if (tariffs->FindByName(tariff))
         }
     else
         {
-        if (u->property.tariffName.Set(tariff,
-                                       admin,
-                                       login,
-                                       store))
+        if (u->GetProperty().tariffName.Set(tariff,
+                                            admin,
+                                            login,
+                                            store))
             {
+            u->ResetNextTariff();
             u->WriteConf();
             *retvalPtr = xmlrpc_c::value_boolean(true);
             return;
@@ -440,7 +443,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
 
 std::vector<xmlrpc_c::value> ips;
 
-user_iter u;
+USER_PTR u;
 
 int handle = users->OpenSearch();
 if (!handle)