public function getReference($entity) { switch ($entity->reference_class) { case 'registrations': // TODO: change this to ::find($id); return Registrations::find('first', array('conditions' => array('_id' => $entity->reference_id))); break; default: return null; break; } }
public function participants() { if (!isset($this->CURRENT_USER)) { $this->flashMessage('You must be logged in to view that page.', array('alertType' => 'error')); return $this->redirect('Leagues::index'); } if (!$this->league and !in_array($this->request->action, $league_id_exempt)) { $redirectUrl = $this->request->env('HTTP_REFERER') ?: '/'; $this->flashMessage('League not found.', array('alertType' => 'error')); return $this->redirect($redirectUrl); } $inLeague = array('league_id' => $this->league->_id); $active_list = Registrations::find('all', array('conditions' => $inLeague + array('status' => 'active'))); $pending_list = Registrations::find('all', array('conditions' => $inLeague + array('status' => array('$ne' => 'active')))); return compact('active_list', 'pending_list'); }
protected function _init() { parent::_init(); if (!isset($this->CURRENT_USER)) { $this->flashMessage('You must be logged in to view that page.', array('alertType' => 'error')); return $this->redirect('Leagues::index'); } if (!isset($this->request->id)) { #$this->flashMessage('Registration ID not supplied.', array('alertType' => 'error')); return $this->redirect('Leagues::index'); } $this->_registration = Registrations::find($this->request->id); if (!isset($this->_registration)) { $this->flashMessage('Could not load that registration.', array('alertType' => 'error')); return $this->redirect('Leagues::index'); } $this->set(array('registration' => $this->_registration, 'league' => $this->_registration->getLeague(), 'user' => $this->_registration->getUser())); }