public function executeNew(sfWebRequest $request) { $this->forward404Unless($this->room = RoomPeer::retrieveByPk($request->getParameter('roomId')), sprintf('Object room does not exist (%s).', $request->getParameter('roomId'))); $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($this->getUser()->getAttribute('activityId')), sprintf('Object activity does not exist (%s).', $this->getUser()->getAttribute('activityId'))); $this->getUserAttributes(); $this->checkRoomAccess($this->room->getId(), $this->activity->getId()); $this->form = new ReservationForm(); $this->form->setDefaultRoom($this->room); $this->form->setDefaultActivity($this->activity); $this->form->setDefaultCustomUsers(null, $this->getCurrentUser(), $this->activity->getId()); $this->setFormDefaultOwner(); if ($request->hasParameter('duration')) { $duration = $request->getParameter('duration'); $this->form->setDefaultDuration($duration); } else { $duration = $this->form->getDefault('duration'); } if ($request->hasParameter('date')) { $date = $request->getParameter('date'); $this->form->setDefaultDate($date); if ($this->getUser()->getTemposUser()) { $userId = $this->getUser()->getTemposUser()->getId(); $cardId = null; } else { if ($this->getUser()->getTemposCard()) { $userId = null; $cardId = $this->getUser()->getTemposCard()->getId(); } } $reservations = ReservationPeer::getOverlappingReservations(null, $date, strtotime("+ {$duration} minutes", strtotime($date)), null, $userId, $cardId); $this->colliding_reservation = count($reservations) > 0 ? $reservations[0] : null; } else { $this->colliding_reservation = null; } }