public function executeIndex(sfWebRequest $request) { $this->forward404Unless($this->room = RoomPeer::retrieveByPk($request->getParameter('roomId')), sprintf('Object room does not exist (%s).', $request->getParameter('roomId'))); $this->step = sfConfig::get('app_max_closeperiods_on_closeperiodlist'); $this->getUser()->syncParameters($this, 'closeperiod', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request); if (is_null($this->sort_column)) { $this->sort_column = 'start'; $this->sort_direction = 'up'; } if (is_null($this->offset)) { $this->offset = 0; } if (is_null($this->limit) || $this->limit <= 0) { $this->limit = $this->step; } $c = new Criteria(); SortCriteria::addSortCriteria($c, $this->sort_column, CloseperiodPeer::getSortAliases(), $this->sort_direction); $c->setOffset($this->offset); if ($this->limit >= 0) { $c->setLimit($this->limit); } $this->closeperiod_list = CloseperiodPeer::doSelectFromRoom($this->room->getId(), $c); $this->count = CloseperiodPeer::doCount(CloseperiodPeer::getFromRoomCriteria($this->room->getId())); if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) { $this->forward404(); } }