function approve($id) { if ($_POST) { $rs = new Information($id); $rs->from_array($_POST); $rs->save(); } }
function save($id = FALSE) { if ($_POST) { $information = new Information($id); $_POST['title'] = lang_encode($_POST['title']); $_POST['intro'] = lang_encode($_POST['intro']); $_POST['detail'] = lang_encode($_POST['detail']); if (!$id) { $_POST['user_id'] = $this->session->userdata('id'); } if ($_FILES['image']['name']) { if ($id) { $information->delete_file('uploads/information/thumbnail', 'image'); } $information->image = $information->upload($_FILES['image'], 'uploads/information/thumbnail', 77, 64); } $information->from_array($_POST); $information->save(); set_notify('success', lang('save_data_complete')); } redirect($_POST['referer']); }
function vote($id = NULL) { if (@$_POST['rating'] && $id) { $information = new Information($id); $information->rating = $information->rating + $_POST['rating']; $information->rating_count = $information->rating_count + 1; $information->save(); set_notify('success', 'บันทึกข้อมูลเรียบร้อยค่ะ'); } else { set_notify('error', 'กรุณาให้คะแนนก่อนทำการโหวตค่ะ'); } redirect($_SERVER['HTTP_REFERER']); }
function unstick_thread($id) { $data = new Information($id); $data->stick = null; $data->save(); set_notify('success', 'ยกเลิกการปักหมุดกระทู้เรียบร้อย'); redirect($_SERVER['HTTP_REFERER']); }
public static function add() { $post = new Information(); $post->contents = Request::post("contents"); $post->save(); }