/** * Get a array of informations over the events booking status (still bookable etc.) * [0] = $buchbar, is a event still bookable * [1] = $altbild, the description / reason for 0 (text?!) * [2] = $temp, The booking of the user (if he is logged in or a user id is given) * [3] = $buchgraf, Waitlist? No idea.. * [4] = $freieplaetze Number of free places! * sem_f012 * * @param int $art - The art (0 = overview, 1 = my bookings, 2 = my offers) * @param object $row - The event * @param int $usrid - The userid * @param string $uuid - The uuid * @param int $status - Which status has a booking * * @todo Rewrite, cleanup and optimize * @return array */ public static function getEventBookableArray($art, $row, $usrid, $uuid = null, $status = 1, $booking = null) { $database = JFactory::getDBO(); $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid= " . $database->quote($row->id) . " AND status = " . $database->quote($status) . " ORDER BY id"); $temps = $database->loadObjectList(); $gebucht = 0; foreach ($temps as $el) { $gebucht = $gebucht + $el->nrbooked; } if ($usrid < 0) { $sid = $usrid * -1; $database->setQuery("SELECT * FROM #__matukio_bookings WHERE id='{$sid}'"); $userid = 0; } else { if ($usrid == 0) { $usrid = -1; } $query = "SELECT * FROM #__matukio_bookings WHERE semid='" . $row->id . "' AND userid = '" . $usrid . "'"; $database->setQuery($query); } $temp = $database->loadObjectList(); // Saves one query.. hack for backward compat if (!empty($booking)) { $temp = array($booking); } if (empty($temp) && !empty($uuid)) { $query = "SELECT * FROM #__matukio_bookings WHERE uuid = " . $database->quote($uuid); $database->setQuery($query); $temp = $database->loadObjectList(); } $freieplaetze = $row->maxpupil - $gebucht; if ($freieplaetze < 0) { $freieplaetze = 0; } $buchbar = 3; $buchgraf = 2; $altbild = JTEXT::_('COM_MATUKIO_NOT_EXCEEDED'); $reglevel = MatukioHelperUtilsBasic::getUserLevel(); $neudatum = MatukioHelperUtilsDate::getCurrentDate(); if ($neudatum > $row->booked) { $buchbar = 1; $buchgraf = 0; $altbild = JTEXT::_('COM_MATUKIO_REGISTRATION_END'); } elseif ($row->cancelled == 1 or $freieplaetze < 1 and $row->stopbooking == 1 or $usrid == $row->publisher and MatukioHelperSettings::getSettings('booking_ownevents', 1) == 0) { $buchbar = 1; $buchgraf = 0; $altbild = JTEXT::_('COM_MATUKIO_UNBOOKABLE'); } elseif ($freieplaetze < 1 and ($row->stopbooking == 0 or $row->stopbooking == 2)) { $buchgraf = 1; $altbild = JTEXT::_('COM_MATUKIO_BOOKING_ON_WAITLIST'); } if (count($temp) > 0) { if (MatukioHelperSettings::getSettings('frontend_usermehrereplaetze', 1) == 0) { $buchbar = 2; $buchgraf = 0; $altbild = JTEXT::_('COM_MATUKIO_ALREADY_BOOKED'); } } if ($reglevel < 1) { $buchbar = 0; } if ($art == 1) { if ($temp[0]->status == MatukioHelperUtilsBooking::$WAITLIST) { $buchgraf = 1; $altbild = JTEXT::_('COM_MATUKIO_WAITLIST'); } elseif ($temp[0]->status == MatukioHelperUtilsBooking::$ACTIVE) { $buchgraf = 2; $altbild = JTEXT::_('COM_MATUKIO_PARTICIPANT_ASSURED'); } elseif ($temp[0]->status == MatukioHelperUtilsBooking::$ARCHIVED || $temp[0]->status == MatukioHelperUtilsBooking::$DELETED) { $buchgraf = 0; $altbild = JTEXT::_('COM_MATUKIO_DELETED_ARCHIVED'); } elseif ($temp[0]->status == MatukioHelperUtilsBooking::$PENDING) { $buchgraf = 3; $altbild = JTEXT::_('COM_MATUKIO_PENDING'); } if ($row->cancelled == 1) { $buchgraf = 0; $altbild = JTEXT::_('COM_MATUKIO_UNBOOKABLE'); } } if ($art == 2) { $buchgraf = 2; $altbild = JTEXT::_('COM_MATUKIO_EVENT_HAS_NOT_STARTED_YET'); if ($neudatum > $row->end) { $buchgraf = 0; $altbild = JTEXT::_('COM_MATUKIO_EVENT_HAS_ENDED'); } elseif ($neudatum > $row->begin) { $buchgraf = 1; $altbild = JTEXT::_('COM_MATUKIO_EVENT_IS_RUNNING'); } } return array($buchbar, $altbild, $temp, $buchgraf, $freieplaetze); }