From 471ff16376d373ff54cbce563f70f01c01f91bba Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Fri, 15 Oct 2010 10:40:58 +0200 Subject: cldb commented from the bottom --- server/cldb.erl | 10 ++++++++-- 1 file 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|_]} -> -- cgit v1.2.3