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.'); } }
public static function isRoomActive($roomId) { $c = self::getActiveCriteria(true); $c->addAnd(RoomPeer::ID, $roomId, Criteria::EQUAL); return RoomPeer::doCount($c) > 0; }
/** * Returns the number of related Rooms. * * @param Criteria $criteria * @param boolean $distinct * @param Connection $con * @throws PropelException */ public function countRooms($criteria = null, $distinct = false, $con = null) { // include the Peer class include_once 'src/model/whiteboard/om/BaseRoomPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(RoomPeer::USER_ID, $this->getUserId()); return RoomPeer::doCount($criteria, $distinct, $con); }