/** * Executes show action * */ public function executeShow() { $request = $this->getRequest(); // get params $chatId = $request->getParameter('id'); $userId = $this->getUser()->getRaykuUserId(); // chat query & check access $criteria = new Criteria(); $criteria->add(WhiteboardChatPeer::ID, $chatId); if (!$this->getUser()->hasCredential('admin')) { $cPublicA = $criteria->getNewCriterion(WhiteboardChatPeer::IS_PUBLIC, true); $cPublicB = $criteria->getNewCriterion(WhiteboardChatPeer::EXPERT_ID, $userId); $cPublicC = $criteria->getNewCriterion(WhiteboardChatPeer::ASKER_ID, $userId); $cPublicA->addOr($cPublicB); $cPublicA->addOr($cPublicC); $criteria->add($cPublicA); } $chat = WhiteboardChatPeer::doSelectOne($criteria); $this->forward404Unless($chat); // messages query $msgCriteria = new Criteria(); $msgCriteria->add(WhiteboardMessagePeer::WHITEBOARD_CHAT_ID, $chatId); $msgCriteria->addAscendingOrderByColumn(WhiteboardMessagePeer::CREATED_AT); $messages = WhiteboardMessagePeer::doSelect($msgCriteria); // snapshots query $snapCriteria = new Criteria(); $snapCriteria->add(WhiteboardSnapshotPeer::WHITEBOARD_CHAT_ID, $chatId); $snapCriteria->addAscendingOrderByColumn(WhiteboardSnapshotPeer::CREATED_AT); $snapshots = WhiteboardSnapshotPeer::doSelect($snapCriteria); // assign variables to view $this->chat = $chat; $this->messages = $messages; $this->snapshots = $snapshots; }
/** * Gets an array of WhiteboardSnapshot objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this WhiteboardChat has previously been saved, it will retrieve * related WhiteboardSnapshots from storage. If this WhiteboardChat is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array WhiteboardSnapshot[] * @throws PropelException */ public function getWhiteboardSnapshots($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(WhiteboardChatPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collWhiteboardSnapshots === null) { if ($this->isNew()) { $this->collWhiteboardSnapshots = array(); } else { $criteria->add(WhiteboardSnapshotPeer::WHITEBOARD_CHAT_ID, $this->id); WhiteboardSnapshotPeer::addSelectColumns($criteria); $this->collWhiteboardSnapshots = WhiteboardSnapshotPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(WhiteboardSnapshotPeer::WHITEBOARD_CHAT_ID, $this->id); WhiteboardSnapshotPeer::addSelectColumns($criteria); if (!isset($this->lastWhiteboardSnapshotCriteria) || !$this->lastWhiteboardSnapshotCriteria->equals($criteria)) { $this->collWhiteboardSnapshots = WhiteboardSnapshotPeer::doSelect($criteria, $con); } } } $this->lastWhiteboardSnapshotCriteria = $criteria; return $this->collWhiteboardSnapshots; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(WhiteboardSnapshotPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(WhiteboardSnapshotPeer::DATABASE_NAME); $criteria->add(WhiteboardSnapshotPeer::ID, $pks, Criteria::IN); $objs = WhiteboardSnapshotPeer::doSelect($criteria, $con); } return $objs; }