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