aboutsummaryrefslogtreecommitdiffstats
path: root/server/cldb.erl
diff options
context:
space:
mode:
Diffstat (limited to 'server/cldb.erl')
-rw-r--r--server/cldb.erl10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/cldb.erl b/server/cldb.erl
index 28815a6..e6f414e 100644
--- a/server/cldb.erl
+++ b/server/cldb.erl
@@ -1,7 +1,7 @@
% The clientdatabase
-module(cldb).
--export([init/0, all/0, find/1, login/2, dec_vote/1, inc_vote/1, register/3, check_rights/1, update_votes/0, logout/1, set_client_pid/2]).
+-export([init/0, all/0, find/1, login/2, dec_vote/1, inc_vote/1, register/3, check_rights/1, update_votes/0, logout/1, set_client_pid/2, get_votes/1]).
-record(user, {name, passwd, votes, logged_in, pid, rights}).
init() ->
@@ -163,3 +163,11 @@ give_votes([User|Rest]) ->
inc_vote(User#user.name),
give_votes(Rest);
give_votes([]) -> ok.
+
+get_votes(User) ->
+ case find(User) of
+ {atomic, [UserRow|_]} ->
+ {ok, UserRow#user.votes};
+ _ ->
+ {error, user_not_found}
+ end.