#include <algorithm>
#include <vector>
+#include "stg/locker.h"
+#include "stg/logger.h"
+#include "stg/store.h"
+#include "stg/admin.h"
#include "tariffs_impl.h"
-#include "stg_locker.h"
-#include "stg_logger.h"
-#include "store.h"
-#include "admin.h"
using namespace std;
return NULL;
}
//-----------------------------------------------------------------------------
-int TARIFFS_IMPL::Chg(const TARIFF_DATA & td, const ADMIN & admin)
+int TARIFFS_IMPL::Chg(const TARIFF_DATA & td, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->tariffChg)
{
- string s = admin.GetLogStr() + " Change tariff \'"
+ string s = admin->GetLogStr() + " Change tariff \'"
+ td.tariffConf.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
if (ti == tariffs.end())
{
strError = "Tariff \'" + td.tariffConf.name + "\' cannot be changed. Tariff does not exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
}
WriteServLog("%s Tariff \'%s\' changed.",
- admin.GetLogStr().c_str(), td.tariffConf.name.c_str());
+ admin->GetLogStr().c_str(), td.tariffConf.name.c_str());
return 0;
}
//-----------------------------------------------------------------------------
-int TARIFFS_IMPL::Del(const string & name, const ADMIN & admin)
+int TARIFFS_IMPL::Del(const string & name, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->tariffChg)
{
- string s = admin.GetLogStr() + " Delete tariff \'"
+ string s = admin->GetLogStr() + " Delete tariff \'"
+ name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
if (ti == tariffs.end())
{
strError = "Tariff \'" + name + "\' cannot be deleted. Tariff does not exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
tariffs.erase(ti);
WriteServLog("%s Tariff \'%s\' deleted.",
- admin.GetLogStr().c_str(),
+ admin->GetLogStr().c_str(),
name.c_str());
return 0;
}
//-----------------------------------------------------------------------------
-int TARIFFS_IMPL::Add(const string & name, const ADMIN & admin)
+int TARIFFS_IMPL::Add(const string & name, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->tariffChg)
{
- string s = admin.GetLogStr() + " Add tariff \'"
+ string s = admin->GetLogStr() + " Add tariff \'"
+ name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
if (ti != tariffs.end())
{
- strError = "Tariff \'" + name + "\' cannot be added. Tariff alredy exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ strError = "Tariff \'" + name + "\' cannot be added. Tariff already exist.";
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
}
WriteServLog("%s Tariff \'%s\' added.",
- admin.GetLogStr().c_str(), name.c_str());
+ admin->GetLogStr().c_str(), name.c_str());
return 0;
}