compatutility: Use User(Group) Ptr, not name.

refs #4735
This commit is contained in:
Michael Friedrich 2013-10-01 16:32:29 +02:00
parent 7f1b6908fe
commit 09cc7632e7
3 changed files with 40 additions and 6 deletions

View File

@ -1088,7 +1088,15 @@ Value HostsTable::ContactsAccessor(const Value& row)
if (!hc)
return Empty;
return CompatUtility::GetServiceNotificationUsers(hc);
Array::Ptr contacts = CompatUtility::GetServiceNotificationUsers(hc);
Array::Ptr contact_names = boost::make_shared<Array>();
ObjectLock olock(contacts);
BOOST_FOREACH(const User::Ptr& user, contacts) {
contact_names->Add(user->GetName());
}
return contact_names;
}
Value HostsTable::DowntimesAccessor(const Value& row)
@ -1581,7 +1589,16 @@ Value HostsTable::ContactGroupsAccessor(const Value& row)
if (!hc)
return Empty;
return CompatUtility::GetServiceNotificationUserGroups(hc);
Array::Ptr contactgroups = CompatUtility::GetServiceNotificationUserGroups(hc);
Array::Ptr contactgroup_names = boost::make_shared<Array>();
ObjectLock olock(contactgroups);
BOOST_FOREACH(const UserGroup::Ptr& usergroup, contactgroups) {
contactgroup_names->Add(usergroup->GetName());
}
return contactgroup_names;
}
Value HostsTable::ServicesAccessor(const Value& row)

View File

@ -751,7 +751,15 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
Value ServicesTable::ContactsAccessor(const Value& row)
{
return CompatUtility::GetServiceNotificationUsers(static_cast<Service::Ptr>(row));
Array::Ptr contacts = CompatUtility::GetServiceNotificationUsers(static_cast<Service::Ptr>(row));
Array::Ptr contact_names = boost::make_shared<Array>();
ObjectLock olock(contacts);
BOOST_FOREACH(const User::Ptr& user, contacts) {
contact_names->Add(user->GetName());
}
return contact_names;
}
Value ServicesTable::DowntimesAccessor(const Value& row)
@ -1002,7 +1010,16 @@ Value ServicesTable::GroupsAccessor(const Value& row)
Value ServicesTable::ContactGroupsAccessor(const Value& row)
{
return CompatUtility::GetServiceNotificationUserGroups(static_cast<Service::Ptr>(row));
Array::Ptr contactgroups = CompatUtility::GetServiceNotificationUserGroups(static_cast<Service::Ptr>(row));
Array::Ptr contactgroup_names = boost::make_shared<Array>();
ObjectLock olock(contactgroups);
BOOST_FOREACH(const UserGroup::Ptr& usergroup, contactgroups) {
contactgroup_names->Add(usergroup->GetName());
}
return contactgroup_names;
}

View File

@ -504,7 +504,7 @@ Value CompatUtility::GetServiceNotificationUsers(const Service::Ptr& service)
}
BOOST_FOREACH(const User::Ptr& user, allUsers) {
contacts->Add(user->GetName());
contacts->Add(user);
}
return contacts;
@ -519,7 +519,7 @@ Value CompatUtility::GetServiceNotificationUserGroups(const Service::Ptr& servic
ObjectLock olock(notification);
BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
contactgroups->Add(ug->GetName());
contactgroups->Add(ug);
}
}