예제 #1
0
 /**
  * Gets the CSS classes (space-separated) for the Vacancies TD.
  *
  * @param tx_seminars_seminar $seminar the current seminar object
  *
  * @return string class attribute value filled with a list a space-separated CSS classes
  */
 public function getVacanciesClasses(tx_seminars_seminar $seminar)
 {
     if (!$seminar->needsRegistration() || !$seminar->hasDate() && !$this->configGetter->getConfValueBoolean('allowRegistrationForEventsWithoutDate')) {
         return '';
     }
     $classes = array();
     if ($seminar->hasDate() && $seminar->hasStarted()) {
         $classes[] = 'event-begin-date-over';
     }
     if ($seminar->hasVacancies()) {
         $classes[] = 'vacancies-available';
         if ($seminar->hasUnlimitedVacancies()) {
             $classes[] = 'vacancies-unlimited';
         } else {
             $classes[] = 'vacancies-' . $seminar->getVacancies();
         }
     } else {
         $classes[] = 'vacancies-0';
         if ($seminar->hasRegistrationQueue()) {
             $classes[] = 'has-registration-queue';
         }
     }
     // We add this class in addition to the number of vacancies so that
     // user stylesheets still can use the number of vacancies even for
     // events for which the registration deadline is over.
     if ($seminar->hasDate() && $seminar->isRegistrationDeadlineOver()) {
         $classes[] = 'registration-deadline-over';
     }
     $prefixedClasses = array_map(array($this, 'pi_getClassName'), $classes);
     return ' ' . implode(' ', $prefixedClasses);
 }
 /**
  * Checks whether a registration with a given number of seats could be
  * created, ie. an actual number is given and there are at least that many vacancies.
  *
  * @param tx_seminars_seminar $seminar the seminar object (that's the seminar we would like to register for)
  * @param int|string $numberOfSeats the number of seats to check (should be an integer, but we can't be sure of this)
  *
  * @return bool TRUE if there are at least that many vacancies, FALSE otherwise
  */
 public function canRegisterSeats(tx_seminars_seminar $seminar, $numberOfSeats)
 {
     $numberOfSeats = trim($numberOfSeats);
     // If no number of seats is given, ie. the user has not entered anything
     // or the field is not shown at all, assume 1.
     if ($numberOfSeats == '' || $numberOfSeats == '0') {
         $numberOfSeats = '1';
     }
     $numberOfSeatsInt = (int) $numberOfSeats;
     // Check whether we have a valid number
     if ($numberOfSeats == strval($numberOfSeatsInt)) {
         if ($seminar->hasUnlimitedVacancies()) {
             $result = TRUE;
         } else {
             $result = $seminar->hasRegistrationQueue() || $seminar->getVacancies() >= $numberOfSeatsInt;
         }
     } else {
         $result = FALSE;
     }
     return $result;
 }