From: Elena Mamontova Date: Mon, 29 Aug 2016 12:33:10 +0000 (+0300) Subject: ticket 37. The newTariff, currentTariff objects added, if (newTariff) X-Git-Tag: 2.409~110 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/819c746b5b93ad2422dc12df64a042ce62583ee3?ds=sidebyside;hp=5c0444f61fac031c47cac726e0b0bb9188f6eb18 ticket 37. The newTariff, currentTariff objects added, if (newTariff) checking and TariffChangeIsAllowed() function call added in the SetUserInfo() function. --- diff --git a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp index 5adbf441..5a738d16 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp @@ -381,16 +381,29 @@ if (tariffs->FindByName(tariff)) } else { - if (u->GetProperty().tariffName.Set(tariff, + const TARIFF * newTariff = tariffs->FindByName(tariff); + if (newTariff) + { + const TARIFF * currentTariff = u->GetTariff(); + std::string message = currentTariff->TariffChangeIsAllowed(*newTariff); + if (message.empty()) + { + if (u->GetProperty().tariffName.Set(tariff, admin, login, store, comment)) - { - u->ResetNextTariff(); - u->WriteConf(); - *retvalPtr = xmlrpc_c::value_boolean(true); - return; + { + u->ResetNextTariff(); + u->WriteConf(); + *retvalPtr = xmlrpc_c::value_boolean(true); + return; + } + } + else + { + GetStgLogger()("Tariff change is prohibited for user %s. %s", u->GetLogin().c_str(), message.c_str()); + } } } }