]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Ticket. The stgTime argument added in TariffChangeIsAllowed() function
[stg.git] / projects / stargazer / user_impl.cpp
index c160db75cb8a39ec8fd402a076fefe41d504780c..0e92975c2c0c064e97d1f8497cd78148aa27b086 100644 (file)
@@ -1178,10 +1178,24 @@ if (nextTariff.ConstData() != "")
     {
     const TARIFF * nt = tariffs->FindByName(nextTariff);
     if (nt == NULL)
+        {
         WriteServLog("Cannot change tariff for user %s. Tariff %s not exist.",
                      login.c_str(), property.tariffName.Get().c_str());
+        }
     else
-        property.tariffName.Set(nextTariff, sysAdmin, login, store);
+        {
+        std::string message = tariff->TariffChangeIsAllowed(*nt, stgTime);
+        if (message.empty())
+            {
+            property.tariffName.Set(nextTariff, sysAdmin, login, store);
+            }
+        else
+            {
+            WriteServLog("Tariff change is prohibited for user %s. %s",
+                         login.c_str(),
+                         message.c_str());
+            }
+        }
     ResetNextTariff();
     WriteConf();
     }