X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..87550f881db0f6583709f7797becb3eef7d5f254:/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..ff783471 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, @@ -27,7 +32,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -65,7 +70,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin = NULL; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -73,7 +78,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -109,7 +114,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -117,9 +122,9 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) 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); @@ -153,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) @@ -201,7 +206,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -209,7 +214,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -221,11 +226,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(); @@ -254,7 +259,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -262,7 +267,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -270,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; @@ -304,7 +309,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -312,7 +317,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -320,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; @@ -352,7 +357,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -360,7 +365,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -372,24 +377,27 @@ 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); 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)) + { + u->WriteConf(); + *retvalPtr = xmlrpc_c::value_boolean(true); + return; + } } } @@ -434,7 +442,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) std::vector ips; -user_iter u; +USER_PTR u; int handle = users->OpenSearch(); if (!handle)