aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wittig <michael.wittig@fu-berlin.de>2010-10-15 10:40:58 +0200
committerMichael Wittig <michael.wittig@fu-berlin.de>2010-10-15 10:40:58 +0200
commit471ff16376d373ff54cbce563f70f01c01f91bba (patch)
tree8a26fcd13437a0ebc8fec5d995d6f8f492108e95
parent2c713d8c5983063bd6c52379d18b27254c2a023b (diff)
downloaderlang-471ff16376d373ff54cbce563f70f01c01f91bba.tar.gz
erlang-471ff16376d373ff54cbce563f70f01c01f91bba.tar.xz
erlang-471ff16376d373ff54cbce563f70f01c01f91bba.zip
cldb commented from the bottom
-rw-r--r--server/cldb.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/server/cldb.erl b/server/cldb.erl
index 1d4aba0..c294471 100644
--- a/server/cldb.erl
+++ b/server/cldb.erl
@@ -109,7 +109,9 @@ logout(Pid) ->
_ ->
{error, invalid_user}
end.
-
+%% Makes an entry into the database for this user.
+%% If he is already registerd an error will be returned.
+%% In order to vote it is needed to login afterwards.
register(User, Pwd, Root) when is_list(User) and is_list(Pwd) ->
case find(User) of
{atomic, []} ->
@@ -126,10 +128,10 @@ register(User, Pwd, Root) when is_list(User) and is_list(Pwd) ->
_ ->
{error, duplicated_user}
end;
-
register(_,_,_) ->
{error, invalid_username}.
+%% functions to de- and increment the amount of votes a user got left.
dec_vote(User) when is_list(User) ->
{atomic, [Head|_]} = find(User),
if Head#user.votes > 0 ->
@@ -154,6 +156,7 @@ inc_vote(User) ->
end,
mnesia:transaction(F).
+%% Return rights of User (admin or nan).
check_rights(User) ->
{atomic, [UserRow|_]} = find(User),
UserRow#user.rights.
@@ -166,11 +169,14 @@ update_votes() ->
_ -> error
end.
+%% Increment the votes of every user.
+%% It will be called when a song has ended.
give_votes([User|Rest]) ->
inc_vote(User#user.name),
give_votes(Rest);
give_votes([]) -> ok.
+%% Returns the amount of votes from User.
get_votes(User) ->
case find(User) of
{atomic, [UserRow|_]} ->