Exemplo n.º 1
0
/**
 * Returns a status code that determines the possible actions of a user towards the event
 * -1: doesn't have permissions
 * 0: has permissions, can join
 * 1: has permissions, cannot join because the event is full
 * 2: is participating
 * 3: has permissions, but has to wait untill allowed to participate
 * 4: has permissions, but has already signed in on another event on this topic
 * @param type $userID
 * @param type $eventID
 */
function getParticipantsStatus($userID, $eventID)
{
    if (EventDatabaseManager::isEventAvailable($userID, $eventID)) {
        if (!EventDatabaseManager::isSignedIn($userID, $eventID)) {
            if (!EventDatabaseManager::isSignedForEventsTopic($userID, $eventID)) {
                if (!EventDatabaseManager::hasToWait($userID, $eventID)) {
                    if (!EventDatabaseManager::isEventFull($eventID)) {
                        return 0;
                    } else {
                        return 1;
                    }
                } else {
                    return 3;
                }
            } else {
                return 4;
            }
        } else {
            return 2;
        }
    } else {
        return -1;
    }
}