public function action_delete($id = null) { if ($type = Model_Type::find($id)) { $type->delete(); Session::set_flash('success', e('Deleted type #' . $id)); } else { Session::set_flash('error', e('Could not delete type #' . $id)); } Response::redirect('site/types'); }
public function action_index() { $data = Model_Data::find(1); $sources = Model_Source::find()->where('meta_update_user', $this->user)->get(); $monitor = array('iconw' => $data['iconw'], 'iconc' => $data['iconc'], 'iconu' => $data['iconu'], 'osdw' => $data['osdw'], 'osdu' => $data['osdu'], 'osdc' => $data['osdc'], 'soundw' => $data['soundw'], 'soundu' => $data['soundu'], 'soundc' => $data['soundc']); $s = array(); foreach ($sources as $source) { $type = Model_Type::find($source->typeID); array_push($s, array('id' => $source['id'], 'type' => array('id' => $source->typeID, 'name' => $type->name), 'content' => $source['content'])); } echo json_encode(array('data' => $monitor, 'sources' => $s)); }
public function action_index() { if ($_POST) { $val = \Validation::forge(); $val->add_field('id', 'Action', 'required|min_length[1]|max_length[20]'); $val->add_field('action', 'Value', 'required|min_length[1]|max_length[20]'); if ($val->run()) { $source = Model_Source::find($val->validated('id')); if ($val->validated('action') == 'get') { $type = Model_Type::find($source->typeID); $out = array('id' => $source['id'], 'type' => array('id' => $source->typeID, 'name' => $type->name), 'user' => $source['user'], 'pass' => $source['pass'], 'content' => $source['content']); } if ($val->validated('action') == 'remove') { } echo json_encode(array('source' => $out)); } } }
public function getTypeName() { $types = Model_Type::find('first', array('where' => array(array('id', $this->type)))); return $types ? $types->type_name : ''; }