public function admin_toggle($id = null) { if (!$id) { $this->notice('invalid'); } $data = $this->Campaign->find('first', array('fields' => array('Campaign.id', 'Campaign.active'), 'conditions' => array('Campaign.id' => $id), 'contain' => array('Newsletter' => array('fields' => array('Newsletter.id'))))); if (!$data['Campaign']['active'] && empty($data['Newsletter'])) { $this->notice(__('You can not enable a campaign with no mails.'), array('level' => 'warning', 'redirect' => true)); } return parent::admin_toggle($id); }
function admin_toggle($id = null) { if (!$id) { $this->Session->setFlash(__('Please select a campaign', true)); $this->redirect($this->referer()); } $data = $this->Campaign->find('first', array('fields' => array('Campaign.id', 'Campaign.active'), 'conditions' => array('Campaign.id' => $id), 'contain' => array('Newsletter' => array('fields' => array('Newsletter.id'))))); if (!$data['Campaign']['active'] && empty($data['Newsletter'])) { $this->Session->setFlash(__('You can not enable a campaign with no mails.', true)); $this->redirect($this->referer()); } return parent::admin_toggle($id); }