public function types() { $types = array(); foreach (Zuha::enum('CONTACT_DETAIL') as $type) { $types[Inflector::underscore($type)] = $type; } return array_merge(array('email' => 'Email'), $types); }
/** * Ratings for contacts * * @return array */ public function ratings() { $ratings = array(); foreach (Zuha::enum('CONTACT_RATING') as $rating) { $ratings[Inflector::underscore($rating)] = $rating; } return array_merge(array('hot' => 'Hot', 'warm' => 'Warm', 'cold' => 'Cold'), $ratings); }
/** * Types function * An array of options for select inputs * * @return array */ public function types($name = null) { foreach (Zuha::enum('WEBPAGES_PAGE_TYPE') as $type) { $types[Inflector::underscore($type)] = $type; } $this->types = Set::merge($this->types, $types); if (!empty($name)) { return $this->types[$name]; } else { return $this->types; } }
/** * Edit method * * @param uuid $id */ public function edit($id = null) { if ($this->request->is('post') || $this->request->is('put')) { if ($this->Setting->add($this->request->data)) { $this->Session->setFlash(__('The Setting has been saved', true), 'flash_success'); $this->redirect($this->referer()); } else { $this->Session->setFlash(__('The Setting could not be saved. Please, try again.', true), 'flash_warning'); } } if (!$id && empty($this->request->data) && empty($this->request->params['named'])) { $this->Session->setFlash(__('Invalid Setting', true), 'flash_danger'); $this->redirect(array('action' => 'index')); } if (!empty($this->request->params['named'])) { $this->request->data = $this->Setting->find('first', array('conditions' => array('type_id' => Zuha::enum(null, $this->request->params['named']['type']), 'name' => $this->request->params['named']['name']))); $this->set('typeId', Zuha::enum(null, $this->request->params['named']['type'])); $this->request->data['Setting']['name'] = $this->request->params['named']['name']; $this->request->data['Setting']['description'] = $this->Setting->getDescription($this->request->params['named']['type'], $this->request->params['named']['name']); } if (empty($this->request->data)) { $this->request->data = $this->Setting->read(null, $id); $this->request->data['Setting']['description'] = $this->Setting->getDescription($this->request->data['Setting']['type'], $this->request->data['Setting']['name']); } $types = $this->Setting->types(); $this->set(compact('types')); $this->layout = 'default'; }