From fa14f97b9ad2260ca0918eae13431974e7fcfb26 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 17 Sep 2009 08:59:26 +0200 Subject: UserListManager: Added method to return the current user db as a user list --- src/modules/UserListManager/UserListManager.cpp | 30 +++++++++++++++++++++++++ src/modules/UserListManager/UserListManager.h | 2 ++ 2 files changed, 32 insertions(+) (limited to 'src/modules') diff --git a/src/modules/UserListManager/UserListManager.cpp b/src/modules/UserListManager/UserListManager.cpp index c6e2c64..18ed83c 100644 --- a/src/modules/UserListManager/UserListManager.cpp +++ b/src/modules/UserListManager/UserListManager.cpp @@ -18,6 +18,7 @@ */ #include "UserListManager.h" +#include "UserList.h" #include "Util.h" #include "RequestHandlers/UserListRequestHandlerGroup.h" #include "RequestHandlers/UserListUploadRequestHandler.h" @@ -25,6 +26,7 @@ #include #include #include +#include #include namespace Mad { @@ -79,6 +81,34 @@ void UserListManager::removeUserList(const std::string &name) { application->getStorageManager()->remove("UserList", name); } +boost::shared_ptr UserListManager::getCurrentUserList() { + boost::shared_ptr list(new UserList); + + boost::shared_ptr > userList = application->getUserManager()->getUserList(); + boost::shared_ptr > groupList = application->getUserManager()->getGroupList(); + + for(std::map::const_iterator user = userList->begin(); user != userList->end(); ++user) { + std::map::const_iterator group = groupList->find(user->second.getGid()); + std::string groupname; + + if(group != groupList->end()) { + groupname = group->second.getName(); + } + else { + std::ostringstream stream; + stream << user->second.getGid(); + groupname = stream.str(); + } + + UserListEntry entry(user->second.getUsername(), groupname); + entry.setDetail("Full name", user->second.getFullName()); + + list->push_back(entry); + } + + return list; +} + } } } diff --git a/src/modules/UserListManager/UserListManager.h b/src/modules/UserListManager/UserListManager.h index b31b27a..3f806e9 100644 --- a/src/modules/UserListManager/UserListManager.h +++ b/src/modules/UserListManager/UserListManager.h @@ -67,6 +67,8 @@ class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private bo boost::shared_ptr loadUserList(const std::string &name); void storeUserList(const std::string &name, const UserList *list); void removeUserList(const std::string &name); + + boost::shared_ptr getCurrentUserList(); }; } -- cgit v1.2.3