/** * Action: shout */ public function action_shout() { $shout = Model_Shout::factory(); if (Permission::has($shout, Permission_Interface::PERMISSION_CREATE) && Security::csrf_valid()) { $shout->author_id = Visitor::$user->id; $shout->shout = $_POST['shout']; $shout->created = time(); try { $shout->save(); } catch (Validation_Exception $e) { } } if ($this->ajax) { $section = $this->section_shouts(); $section->aside = true; $this->response->body($section); return; } $this->request->redirect(Route::get('shouts')->uri()); }
/** * Action: shout */ public function action_shout() { $shout = Model_Shout::factory(); $errors = array(); if (Permission::has($shout, Permission_Interface::PERMISSION_CREATE) && Security::csrf_valid()) { $shout->author_id = self::$user->id; $shout->shout = $_POST['shout']; $shout->created = time(); try { $shout->save(); } catch (Validation_Exception $e) { $errors = $e->array->errors('validate'); } } if ($this->ajax) { echo new View_Index_Shouts(); exit; } $this->request->redirect(Route::get('shouts')->uri()); }