diff options
Diffstat (limited to '')
-rw-r--r-- | server/cldb.erl | 10 |
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|_]} -> |