diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-17 08:59:26 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-17 08:59:26 +0200 |
commit | fa14f97b9ad2260ca0918eae13431974e7fcfb26 (patch) | |
tree | 941ce7d70e7f15b791fd0f76eeaffca59a1b1853 /src/modules | |
parent | 2ba5228d0483798a9e122670d15a078c4478898f (diff) | |
download | mad-fa14f97b9ad2260ca0918eae13431974e7fcfb26.tar mad-fa14f97b9ad2260ca0918eae13431974e7fcfb26.zip |
UserListManager: Added method to return the current user db as a user list
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/UserListManager/UserListManager.cpp | 30 | ||||
-rw-r--r-- | src/modules/UserListManager/UserListManager.h | 2 |
2 files changed, 32 insertions, 0 deletions
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 <Server/Application.h> #include <Common/RequestManager.h> #include <Common/StorageManager.h> +#include <Common/UserManager.h> #include <Core/ConfigManager.h> namespace Mad { @@ -79,6 +81,34 @@ void UserListManager::removeUserList(const std::string &name) { application->getStorageManager()->remove("UserList", name); } +boost::shared_ptr<UserList> UserListManager::getCurrentUserList() { + boost::shared_ptr<UserList> list(new UserList); + + boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > userList = application->getUserManager()->getUserList(); + boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groupList = application->getUserManager()->getGroupList(); + + for(std::map<unsigned long, Common::UserInfo>::const_iterator user = userList->begin(); user != userList->end(); ++user) { + std::map<unsigned long, Common::GroupInfo>::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<UserList> loadUserList(const std::string &name); void storeUserList(const std::string &name, const UserList *list); void removeUserList(const std::string &name); + + boost::shared_ptr<UserList> getCurrentUserList(); }; } |