diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-07-10 02:08:03 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-07-10 02:08:03 +0200 |
commit | f892ec46086eee9c4bfb954469016829fb201532 (patch) | |
tree | c6abb16ea1b52953a37da995dc988c823685a46a /src/modules/UserBackendMysql/UserBackendMysql.cpp | |
parent | 5bf8b6ce656ffe0740ec116057577044e3925887 (diff) | |
download | mad-f892ec46086eee9c4bfb954469016829fb201532.tar mad-f892ec46086eee9c4bfb954469016829fb201532.zip |
updateUser und deleteUser zum UserBackendMysql, NetworkUserBackend und Client hinzugefügt
Diffstat (limited to 'src/modules/UserBackendMysql/UserBackendMysql.cpp')
-rw-r--r-- | src/modules/UserBackendMysql/UserBackendMysql.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp index 015c5a1..f169593 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.cpp +++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp @@ -116,6 +116,14 @@ bool UserBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool ha if(entry[3].empty()) queryAddUser = entry[2][0]; } + else if(entry[2].getKey().matches("UpdateUser")) { + if(entry[3].empty()) + queryUpdateUser = entry[2][0]; + } + else if(entry[2].getKey().matches("DeleteUser")) { + if(entry[3].empty()) + queryDeleteUser = entry[2][0]; + } else if(!entry[2].empty()) return false; } @@ -463,9 +471,6 @@ void UserBackendMysql::addUser(const Common::UserInfo &userInfo) throw(Core::Exc boost::lock_guard<boost::mutex> lock(mutex); - if(!mysql || mysql_ping(mysql)) - throw Core::Exception(Core::Exception::NOT_AVAILABLE); - ArgumentMap args; args.insert(std::make_pair("UID", userInfo.getUid())); args.insert(std::make_pair("GID", userInfo.getGid())); @@ -484,6 +489,46 @@ void UserBackendMysql::addUser(const Common::UserInfo &userInfo) throw(Core::Exc lastUpdate = boost::posix_time::microsec_clock::universal_time(); } +void UserBackendMysql::updateUser(unsigned long uid, const Common::UserInfo &userInfo) throw(Core::Exception) { + application->getThreadManager()->detach(); + + boost::lock_guard<boost::mutex> lock(mutex); + + ArgumentMap args; + args.insert(std::make_pair("ORIG_UID", uid)); + args.insert(std::make_pair("UID", userInfo.getUid())); + args.insert(std::make_pair("GID", userInfo.getGid())); + args.insert(std::make_pair("USER", userInfo.getUsername())); + args.insert(std::make_pair("FULL_NAME", userInfo.getFullName())); + + Result result = query(queryUpdateUser, args); + + if(result.getErrno()) { + if(result.getErrno() == ER_DUP_ENTRY) + throw Core::Exception(Core::Exception::DUPLICATE_ENTRY); + else + throw Core::Exception(Core::Exception::NOT_AVAILABLE); + } + + lastUpdate = boost::posix_time::microsec_clock::universal_time(); +} + +void UserBackendMysql::deleteUser(unsigned long uid) throw(Core::Exception) { + application->getThreadManager()->detach(); + + boost::lock_guard<boost::mutex> lock(mutex); + + ArgumentMap args; + args.insert(std::make_pair("UID", uid)); + + Result result = query(queryDeleteUser, args); + + if(result.getErrno()) + throw Core::Exception(Core::Exception::NOT_AVAILABLE); + + lastUpdate = boost::posix_time::microsec_clock::universal_time(); +} + } } } |