summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/UserListManager/UserListManager.cpp30
-rw-r--r--src/modules/UserListManager/UserListManager.h2
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();
};
}