public function action_new() { if (Input::post('contents')) { if (Input::post('dont-fill-this-out')) { die ('I told you not to fill it out.'); } $last_scrap = Model_Setting::find(1); $last_short_id = ($last_scrap === NULL) ? 0 : $last_scrap->last_short_id; $short_id = Scrapyrd::inc($last_short_id); $contents = Input::post('contents'); $private = Input::post('private', '0'); if ($private != '0') { $short_id = sha1($contents.microtime(true)); } else { $last_scrap->last_short_id = $short_id; $last_scrap->save(); } $user_id = null; if ($this->template->logged_in) { $user_id = Session::get('user_id'); } $scrap = new Model_Scrap; $scrap->contents = $contents; $scrap->short_id = $short_id; $scrap->type = Input::post('type'); $scrap->private = $private; $scrap->created_at = time(); $scrap->updated_at = time(); $scrap->user_id = $user_id; $scrap->views = 0; $scrap->save(); if (Fuel::$env === Fuel::PRODUCTION) { Response::redirect('http://scrp.at/'.$short_id); } else { Response::redirect($short_id); } } else { $this->template->title = 'Error'; $this->template->content = 'Cannot create an empty Scrap!'; } }
public function action_delete($id = null) { if ($setting = Model_Setting::find($id)) { $setting->delete(); Session::set_flash('success', e('Deleted setting #' . $id)); } else { Session::set_flash('error', e('Could not delete setting #' . $id)); } Response::redirect('admin/settings'); }
public function action_index() { if (!$this->current_user->group->is_admin) { return $this->no_permission(); } $this->title('Settings'); $this->view = $this->theme->view('admin/settings/index'); if (Input::param() != array()) { foreach (Input::param('settings') as $setting => $value) { $s = Model_Setting::find('first', array('where' => array('setting' => $setting))); $s->value = $value; $s->save(); } Session::set_flash('success', 'Settings saved'); Response::redirect(Uri::current()); } }