예제 #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;
    }
}
 /**
  * Returns TRUE if the user is allowed to participate in the event
  * A user can sign in for the event if:
  * - an event is generally available to him/her (see getAvailableEventsForUser)
  * - an event is either of elearning type, or less than the maximum allowed number of participants have already signed in
  * - a user's last event on this topic was long ago enough
  * 
  * @param int $userID
  * @param int $eventID
  * @return boolean
  */
 public static function canParticipate($userID, $eventID)
 {
     if (EventDatabaseManager::isEventAvailable($userID, $eventID)) {
         if (!EventDatabaseManager::isEventFull($eventID)) {
             if (!EventDatabaseManager::hasToWait($userID, $eventID)) {
                 return !EventDatabaseManager::isSignedForEventsTopic($userID, $eventID);
             }
         }
     }
     return false;
 }