diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-08 03:06:01 +0100 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-08 03:24:08 +0100 |
| commit | 1f0129e90f91a1257bc96591bca6bcfee505a630 (patch) | |
| tree | a987d34e062c5d7e55b66be040c64fc9da5c2a48 /database/sqlite | |
| parent | c5f027b4d0ad0490b0fb86c7a6331222a8165e7e (diff) | |
| download | eurephia-1f0129e90f91a1257bc96591bca6bcfee505a630.tar.gz eurephia-1f0129e90f91a1257bc96591bca6bcfee505a630.tar.xz eurephia-1f0129e90f91a1257bc96591bca6bcfee505a630.zip | |
edb-sqlite: Added update user function
Diffstat (limited to 'database/sqlite')
| -rw-r--r-- | database/sqlite/administration.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 4ae6047..9f69880 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -413,9 +413,9 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, eurephiaUSERINFO *user) { uinfo_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, user); // Query the database, find the user defined in the user map - uinf = sqlite_query_mapped(ctx, + uinf = sqlite_query_mapped(ctx, SQL_SELECT, "SELECT username, activated, deactivated, last_accessed, uid" - " FROM openvpn_users", uinfo_map); + " FROM openvpn_users", NULL, uinfo_map); if( uinf == NULL ) { eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a user"); @@ -456,7 +456,27 @@ int eDBadminAddUser(eurephiaCTX *ctx, eurephiaUSERINFO *usrinf) { } int eDBadminUpdateUser(eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *usrinf) { - return 0; + dbresult *uinf = NULL; + eurephiaUSERINFO *srch = NULL; + eDBfieldMap *data_map = NULL, *srch_map = NULL; + + assert( (ctx != NULL) && (uid != usrinf->uid) ); + + srch = eAdminPopulateUSERINFO(uid, NULL, NULL, NULL, NULL, NULL); + srch_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, srch); + + data_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, usrinf); + + // Query the database, find the user defined in the user map + uinf = sqlite_query_mapped(ctx, SQL_UPDATE, "UPDATE openvpn_users", data_map, srch_map); + + if( uinf == NULL ) { + eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a user"); + return 0; + } + eDBfreeMapping(srch_map); + eDBfreeMapping(data_map); + return 1; } int eDBadminDeleteUser(eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *usrinf) { |
