diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-05-22 00:23:59 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-05-22 00:23:59 +0200 |
commit | 264cd7947d7291f78065f12824523ba6178a9936 (patch) | |
tree | 7261b9a33519cd783f614b147c44f484a1217618 /src/modules/UserBackendMysql | |
parent | e0e254548b6200d16bc3f4be3bd255b041a76532 (diff) | |
download | mad-264cd7947d7291f78065f12824523ba6178a9936.tar mad-264cd7947d7291f78065f12824523ba6178a9936.zip |
GroupListRequest hinzugef?gt
Diffstat (limited to 'src/modules/UserBackendMysql')
-rw-r--r-- | src/modules/UserBackendMysql/UserBackendMysql.cpp | 22 | ||||
-rw-r--r-- | src/modules/UserBackendMysql/UserBackendMysql.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp index a8751ee..139a416 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.cpp +++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp @@ -193,6 +193,28 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long return boost::shared_ptr<Common::UserInfo>(); } +boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() { + Net::ThreadManager::get()->detach(); + + mysql_ping(mysql); + + mysql_real_query(mysql, queryListGroups.c_str(), queryListGroups.length()); + MYSQL_RES *result = mysql_use_result(mysql); + + if(mysql_num_fields(result) < 2) + return boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> >(); // TODO Error + + boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > groups(new std::map<unsigned long, Common::GroupInfo>()); + + while(MYSQL_ROW row = mysql_fetch_row(result)) { + Common::GroupInfo group(strtoul(row[0], 0, 10), row[1]); + + groups->insert(std::make_pair(group.getGid(), group)); + } + + return groups; +} + void UserBackendMysql::registerBackend() { if(backend) diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h index de28069..8a75a6b 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.h +++ b/src/modules/UserBackendMysql/UserBackendMysql.h @@ -53,6 +53,8 @@ class UserBackendMysql : public Server::UserBackend, private Common::Configurabl virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList(); virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid); + virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList(); + public: virtual ~UserBackendMysql() { if(mysql) { |