From 264cd7947d7291f78065f12824523ba6178a9936 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 22 May 2009 00:23:59 +0200 Subject: GroupListRequest hinzugef?gt --- src/modules/UserBackendMysql/UserBackendMysql.cpp | 22 ++++++++++++++++++++++ src/modules/UserBackendMysql/UserBackendMysql.h | 2 ++ 2 files changed, 24 insertions(+) (limited to 'src/modules') 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 UserBackendMysql::getUserInfo(unsigned long return boost::shared_ptr(); } +boost::shared_ptr > 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 >(); // TODO Error + + boost::shared_ptr > groups(new std::map()); + + 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 > getUserList(); virtual boost::shared_ptr getUserInfo(unsigned long uid); + virtual boost::shared_ptr > getGroupList(); + public: virtual ~UserBackendMysql() { if(mysql) { -- cgit v1.2.3