diff options
author | Jakob Pfender <jpfender@zedat.fu-berlin.de> | 2010-10-15 10:40:01 +0200 |
---|---|---|
committer | Jakob Pfender <jpfender@zedat.fu-berlin.de> | 2010-10-15 10:40:01 +0200 |
commit | 4b74a6cfa51c6971fffd809bcc35f8ec6ef381a0 (patch) | |
tree | 5f604b5fc3e5034e5032b803f8ff5a77dbc7f9a8 | |
parent | 770cd61fe93347933c957e8da6de499a5dcb64fd (diff) | |
parent | 471ff16376d373ff54cbce563f70f01c01f91bba (diff) | |
download | erlang-4b74a6cfa51c6971fffd809bcc35f8ec6ef381a0.tar.gz erlang-4b74a6cfa51c6971fffd809bcc35f8ec6ef381a0.tar.xz erlang-4b74a6cfa51c6971fffd809bcc35f8ec6ef381a0.zip |
Merge branch 'master' of ssh://git.animux.de/erlang
-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|_]} -> |