예제 #1
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new RoomSearchForm();
     $formName = $this->form->getName();
     $this->step = sfConfig::get('app_max_rooms_on_roomlist');
     $this->getUser()->syncParameters($this, 'room', 'index', array('offset', 'limit', $this->form->getName(), 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'name';
         $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, RoomPeer::getSortAliases(), $this->sort_direction);
     if (!is_null($this->{$formName})) {
         $this->filtered = true;
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->room_list = RoomPeer::searchRooms($this->form->getValue('Activity_id'), $this->form->getValue('is_active'), $this->form->getValue('namePattern'), $this->form->getValue('capacity'), $this->form->getValue('addressPattern'), $this->form->getValue('descriptionPattern'), $this->form->getFeaturesFieldsValues(), $c);
             $this->count = count($this->room_list);
             $this->room_list = array_slice($this->room_list, $this->offset, $this->limit);
         } else {
             $this->setTemplate('search');
         }
     } else {
         $c->setOffset($this->offset);
         if ($this->limit >= 0) {
             $c->setLimit($this->limit);
         }
         $this->filtered = false;
         $this->room_list = RoomPeer::doSelect($c);
         $this->count = RoomPeer::doCount(new Criteria());
     }
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
 }
예제 #2
0
 public function executeSearchRoomProcess(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     $this->handleZoneParameters($request);
     $this->form = new RoomSearchForm($this->activity);
     $this->form->setIsActive(true);
     $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
     if ($this->form->isValid()) {
         $this->rooms = RoomPeer::searchRooms($this->activity->getId(), $this->form->getValue('is_active'), $this->form->getValue('namePattern'), $this->form->getValue('capacity'), $this->form->getValue('addressPattern'), $this->form->getValue('descriptionPattern'), $this->form->getFeaturesFieldsValues());
         $this->rooms = $this->person->filterAccessibleRooms($this->rooms);
         $this->setTemplate('roomIndex');
     } else {
         $this->setTemplate('searchRoom');
     }
 }