mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
parent
9ad0b11442
commit
df1d47a996
@ -19,8 +19,12 @@
|
|||||||
|
|
||||||
#include "livestatus/contactstable.h"
|
#include "livestatus/contactstable.h"
|
||||||
#include "icinga/user.h"
|
#include "icinga/user.h"
|
||||||
|
#include "icinga/timeperiod.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
|
#include "base/objectlock.h"
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
using namespace livestatus;
|
using namespace livestatus;
|
||||||
@ -95,62 +99,119 @@ Value ContactsTable::PagerAccessor(const Value& row)
|
|||||||
|
|
||||||
Value ContactsTable::HostNotificationPeriodAccessor(const Value& row)
|
Value ContactsTable::HostNotificationPeriodAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* same as service */
|
||||||
return Empty;
|
TimePeriod::Ptr timeperiod = static_cast<User::Ptr>(row)->GetNotificationPeriod();
|
||||||
|
|
||||||
|
if (!timeperiod)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return timeperiod->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::ServiceNotificationPeriodAccessor(const Value& row)
|
Value ContactsTable::ServiceNotificationPeriodAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
TimePeriod::Ptr timeperiod = static_cast<User::Ptr>(row)->GetNotificationPeriod();
|
||||||
return Empty;
|
|
||||||
|
if (!timeperiod)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return timeperiod->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::CanSubmitCommandsAccessor(const Value& row)
|
Value ContactsTable::CanSubmitCommandsAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO - default 1*/
|
/* default enabled */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::HostNotificationsEnabledAccessor(const Value& row)
|
Value ContactsTable::HostNotificationsEnabledAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
return (static_cast<User::Ptr>(row)->GetEnableNotifications() ? 1 : 0);
|
||||||
return Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::ServiceNotificationsEnabledAccessor(const Value& row)
|
Value ContactsTable::ServiceNotificationsEnabledAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
return (static_cast<User::Ptr>(row)->GetEnableNotifications() ? 1 : 0);
|
||||||
return Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::InHostNotificationPeriodAccessor(const Value& row)
|
Value ContactsTable::InHostNotificationPeriodAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
TimePeriod::Ptr timeperiod = static_cast<User::Ptr>(row)->GetNotificationPeriod();
|
||||||
return Empty;
|
|
||||||
|
if (!timeperiod)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return timeperiod->IsInside(Utility::GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::InServiceNotificationPeriodAccessor(const Value& row)
|
Value ContactsTable::InServiceNotificationPeriodAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
TimePeriod::Ptr timeperiod = static_cast<User::Ptr>(row)->GetNotificationPeriod();
|
||||||
return Empty;
|
|
||||||
|
if (!timeperiod)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return timeperiod->IsInside(Utility::GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::CustomVariableNamesAccessor(const Value& row)
|
Value ContactsTable::CustomVariableNamesAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Dictionary::Ptr custom = static_cast<User::Ptr>(row)->GetCustom();
|
||||||
return Empty;
|
|
||||||
|
if (!custom)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Array::Ptr cv = boost::make_shared<Array>();
|
||||||
|
|
||||||
|
ObjectLock olock(custom);
|
||||||
|
String key;
|
||||||
|
Value value;
|
||||||
|
BOOST_FOREACH(boost::tie(key, value), custom) {
|
||||||
|
cv->Add(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::CustomVariableValuesAccessor(const Value& row)
|
Value ContactsTable::CustomVariableValuesAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Dictionary::Ptr custom = static_cast<User::Ptr>(row)->GetCustom();
|
||||||
return Empty;
|
|
||||||
|
if (!custom)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Array::Ptr cv = boost::make_shared<Array>();
|
||||||
|
|
||||||
|
ObjectLock olock(custom);
|
||||||
|
String key;
|
||||||
|
Value value;
|
||||||
|
BOOST_FOREACH(boost::tie(key, value), custom) {
|
||||||
|
cv->Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::CustomVariablesAccessor(const Value& row)
|
Value ContactsTable::CustomVariablesAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* TODO */
|
Dictionary::Ptr custom = static_cast<User::Ptr>(row)->GetCustom();
|
||||||
return Empty;
|
|
||||||
|
if (!custom)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Array::Ptr cv = boost::make_shared<Array>();
|
||||||
|
|
||||||
|
ObjectLock olock(custom);
|
||||||
|
String key;
|
||||||
|
Value value;
|
||||||
|
BOOST_FOREACH(boost::tie(key, value), custom) {
|
||||||
|
Array::Ptr key_val = boost::make_shared<Array>();
|
||||||
|
key_val->Add(key);
|
||||||
|
key_val->Add(value);
|
||||||
|
cv->Add(key_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ContactsTable::ModifiedAttributesAccessor(const Value& row)
|
Value ContactsTable::ModifiedAttributesAccessor(const Value& row)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user