public function view($id) { if ($this->_isRest()) { $tag = $this->Tag->find('first', array('conditions' => array('id' => $id), 'recursive' => -1, 'contain' => array('EventTag' => array('fields' => 'event_id')))); if (empty($tag)) { throw MethodNotAllowedException('Invalid Tag'); } $eventIDs = array(); if (empty($tag['EventTag'])) { $tag['Tag']['count'] = 0; } else { foreach ($tag['EventTag'] as $eventTag) { $eventIDs[] = $eventTag['event_id']; } $conditions = array('Event.id' => $eventIDs); if (!$this->_isSiteAdmin()) { $conditions = array_merge($conditions, array('OR' => array(array('AND' => array(array('Event.distribution >' => 0), array('Event.published =' => 1))), array('Event.orgc' => $this->Auth->user('org'))))); } $events = $this->Tag->EventTag->Event->find('all', array('fields' => array('Event.id', 'Event.distribution', 'Event.orgc'), 'conditions' => $conditions)); $tag['Tag']['count'] = count($events); } unset($tag['EventTag']); $this->set('Tag', $tag['Tag']); $this->set('_serialize', 'Tag'); } else { throw new MethodNotAllowedException('This action is only for REST users.'); } }
public function inlineform2($controller) { $data = $controller->data; $action = Hash::get($data, 'action'); if ($action == 'update') { return $this->update($controller); } else { if ($action == 'add') { return $this->add($controller); } else { if ($action == 'delete') { return $this->delete($controller); } else { throw MethodNotAllowedException('Invalid Action'); } } } }