summaryrefslogtreecommitdiffstats
path: root/src/modules/UserBackendMysql/UserBackendMysql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/UserBackendMysql/UserBackendMysql.cpp')
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index 904c9a6..e6e6dda 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -129,14 +129,14 @@ void UserBackendMysql::configFinished() {
}
-boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 4)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -155,7 +155,7 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::
return users;
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -171,7 +171,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
query = boost::regex_replace(query, boost::regex("\\{UID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 4)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -192,7 +192,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -205,7 +205,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const st
std::string query = boost::regex_replace(queryUserByName, boost::regex("\\{USER\\}"), "\""+std::string(escapedName.get())+"\"", boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 4)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -226,7 +226,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const st
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -240,7 +240,7 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(u
std::string query = boost::regex_replace(queryListUserGroups, boost::regex("\\{UID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 1)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -254,14 +254,14 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(u
}
-boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
mysql_real_query(mysql, queryListGroups.c_str(), queryListGroups.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 2)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -277,7 +277,7 @@ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql:
return groups;
}
-std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfo(unsigned long gid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -293,7 +293,7 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Except
query = boost::regex_replace(query, boost::regex("\\{GID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 2)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -301,12 +301,12 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Except
MYSQL_ROW row = mysql_fetch_row(result);
if(row)
- return row[1];
+ return boost::shared_ptr<Common::GroupInfo>(new Common::GroupInfo(strtoul(row[0], 0, 10), row[1]));
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfoByName(const std::string &name) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -319,7 +319,7 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::
std::string query = boost::regex_replace(queryGroupByName, boost::regex("\\{GROUP\\}"), "\""+std::string(escapedName.get())+"\"", boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 2)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -327,12 +327,12 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::
MYSQL_ROW row = mysql_fetch_row(result);
if(row)
- return strtoul(row[0], 0, 10);
+ return boost::shared_ptr<Common::GroupInfo>(new Common::GroupInfo(strtoul(row[0], 0, 10), row[1]));
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -346,7 +346,7 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(u
std::string query = boost::regex_replace(queryListGroupUsers, boost::regex("\\{GID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 1)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);