X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7df336e60c959c440b2c330f7a7ca9b0251db2a1..0bccec4ece837941fd6ff445bbfceb62be928788:/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp?ds=inline diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp index c9a2e3d3..841fafa1 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp @@ -26,7 +26,6 @@ #include "stg/user_property.h" #include "stg/user_conf.h" #include "stg/user_stat.h" -#include "stg/common.h" #include #include @@ -53,9 +52,9 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_ std::string answer; if (loginInStart) - answer += ""; + answer += ""; else - answer += ""; + answer += ""; answer += ""; @@ -127,8 +126,8 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_ answer += ""; answer += " lastTime) for (size_t j = 0; j < DIR_NUM; j++) answer += " MU" + x2str(j) + "=\"" + x2str(upload[j]) + "\""; @@ -177,7 +176,10 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_ int GET_USERS::Start(void *, const char * el, const char ** attr) { if (strcasecmp(el, m_tag.c_str()) != 0) + { + printfd(__FILE__, "Got wrong tag: '%s' instead of '%s'\n", el, m_tag.c_str()); return -1; + } while (attr && *attr && *(attr + 1)) { @@ -195,9 +197,9 @@ void GET_USERS::CreateAnswer() assert(h); if (m_lastUserUpdateTime > 0) - m_answer = "<" + m_tag + " LastUpdate=\"" + x2str(time(NULL)) + "\">"; + m_answer = ""; else - m_answer = GetOpenTag(); + m_answer = ""; USER_PTR u; @@ -206,7 +208,7 @@ void GET_USERS::CreateAnswer() m_users.CloseSearch(h); - m_answer += GetCloseTag(); + m_answer += ""; } int GET_USER::Start(void *, const char * el, const char ** attr) @@ -226,7 +228,7 @@ void GET_USER::CreateAnswer() CONST_USER_PTR u; if (m_users.FindByName(m_login, &u)) - m_answer = "<" + m_tag + " result=\"error\" reason=\"User not found.\"/>"; + m_answer = ""; else m_answer = UserToXML(*u, false, m_currAdmin.GetPriv()->userConf || m_currAdmin.GetPriv()->userPasswd); } @@ -572,8 +574,8 @@ int CHG_USER::ApplyChanges() if (!u->GetProperty().realName.Set(m_ucr.realName.const_data(), &m_currAdmin, m_login, &m_store)) return -1; - if (!m_usr.cash.empty()) + { if (m_cashMustBeAdded) { if (!u->GetProperty().cash.Set(m_usr.cash.const_data() + u->GetProperty().cash, @@ -582,19 +584,31 @@ int CHG_USER::ApplyChanges() &m_store, m_cashMsg)) return -1; - else - if (!u->GetProperty().cash.Set(m_usr.cash.const_data(), &m_currAdmin, m_login, &m_store, m_cashMsg)) - return -1; } - + else + { + if (!u->GetProperty().cash.Set(m_usr.cash.const_data(), &m_currAdmin, m_login, &m_store, m_cashMsg)) + return -1; + } + } if (!m_ucr.tariffName.empty()) { - if (m_tariffs.FindByName(m_ucr.tariffName.const_data())) + const TARIFF * newTariff = m_tariffs.FindByName(m_ucr.tariffName.const_data()); + if (newTariff) { - if (!u->GetProperty().tariffName.Set(m_ucr.tariffName.const_data(), &m_currAdmin, m_login, &m_store)) - return -1; - u->ResetNextTariff(); + const TARIFF * tariff = u->GetTariff(); + if (tariff->TariffChangeIsAllowed(*newTariff) == "") + { + if (!u->GetProperty().tariffName.Set(m_ucr.tariffName.const_data(), &m_currAdmin, m_login, &m_store)) + return -1; + u->ResetNextTariff(); + } + else + { + std::string message = tariff->TariffChangeIsAllowed(*newTariff); + GetStgLogger()("Tariff change is prohibited for user %s. %s", u->GetLogin().c_str(), message.c_str()); + } } else {