X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..b95edc0574dc2ebc65b197b1b1ad464821dfe519:/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp diff --git a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp index d6812f55..48ef3103 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp @@ -1,12 +1,17 @@ -#include "users_methods.h" +#include + +#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" - //------------------------------------------------------------------------------ void METHOD_USER_GET::execute(xmlrpc_c::paramList const & paramList, @@ -14,7 +19,6 @@ void METHOD_USER_GET::execute(xmlrpc_c::paramList const & paramList, { std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); -std::string enc; paramList.verifyEnd(2); std::map structVal; @@ -27,7 +31,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -54,7 +58,6 @@ void METHOD_USER_ADD::execute(xmlrpc_c::paramList const & paramList, { std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); -std::string enc; paramList.verifyEnd(2); ADMIN_INFO adminInfo; @@ -65,15 +68,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)) { @@ -98,7 +101,6 @@ void METHOD_USER_DEL::execute(xmlrpc_c::paramList const & paramList, { std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); -std::string enc; paramList.verifyEnd(2); ADMIN_INFO adminInfo; @@ -109,17 +111,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); @@ -136,7 +138,6 @@ void METHOD_USERS_GET::execute(xmlrpc_c::paramList const & paramList, xmlrpc_c::value * const retvalPtr) { std::string cookie = paramList.getString(0); -std::string enc; paramList.verifyEnd(1); std::map structVal; @@ -153,7 +154,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) @@ -190,7 +191,6 @@ void METHOD_USER_CHG::execute(xmlrpc_c::paramList const & paramList, std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); xmlrpc_c::value_struct info(paramList.getStruct(2)); -std::string enc; paramList.verifyEnd(3); ADMIN_INFO adminInfo; @@ -201,15 +201,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)) { @@ -221,11 +221,11 @@ USER_HELPER uhelper(u); if (!adminInfo.priviledges.userConf || !adminInfo.priviledges.userPasswd) { - uhelper.SetUserInfo(info, admin, login, *store); + uhelper.SetUserInfo(info, admin, login, *store, tariffs); } else { - uhelper.SetUserInfo(info, admin, login, *store); + uhelper.SetUserInfo(info, admin, login, *store, tariffs); } u->WriteConf(); @@ -243,7 +243,6 @@ std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); double amount = paramList.getDouble(2); std::string comment = IconvString(paramList.getString(3), "UTF-8", "KOI8-R"); -std::string enc; paramList.verifyEnd(4); ADMIN_INFO adminInfo; @@ -254,15 +253,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)) { @@ -270,10 +269,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; @@ -293,7 +292,6 @@ std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); double cash = paramList.getDouble(2); std::string comment = IconvString(paramList.getString(3), "UTF-8", "KOI8-R"); -std::string enc; paramList.verifyEnd(4); ADMIN_INFO adminInfo; @@ -304,15 +302,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)) { @@ -320,7 +318,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; @@ -341,7 +339,6 @@ std::string login = paramList.getString(1); std::string tariff = paramList.getString(2); bool delayed = paramList.getBoolean(3); std::string comment = IconvString(paramList.getString(4), "UTF-8", "KOI8-R"); -std::string enc; paramList.verifyEnd(5); ADMIN_INFO adminInfo; @@ -352,15 +349,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)) { @@ -372,24 +369,30 @@ if (tariffs->FindByName(tariff)) { if (delayed) { - if (u->property.nextTariff.Set(tariff, - admin, - login, - store)) + if (u->GetProperty().nextTariff.Set(tariff, + admin, + login, + store, + comment)) { u->WriteConf(); *retvalPtr = xmlrpc_c::value_boolean(true); return; } } - if (u->property.tariffName.Set(tariff, - admin, - login, - store)) + else { - u->WriteConf(); - *retvalPtr = xmlrpc_c::value_boolean(true); - return; + if (u->GetProperty().tariffName.Set(tariff, + admin, + login, + store, + comment)) + { + u->ResetNextTariff(); + u->WriteConf(); + *retvalPtr = xmlrpc_c::value_boolean(true); + return; + } } } @@ -434,7 +437,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) std::vector ips; -user_iter u; +USER_PTR u; int handle = users->OpenSearch(); if (!handle)