public function edit($postID) { $post = new Posts(); $post->load($postID); if (!$post->postID) { show_404(); } $this->load->library('form_validation'); $this->form_validation->set_rules('title', 'Title', 'trim|required|min_length[3]|max_length[255]|xss_clean'); $this->form_validation->set_rules('post', 'Text', 'trim|required|min_length[2]|max_length[255]|xss_clean'); $this->form_validation->set_error_delimiters('<div class="alert alert-info" role="alert">', '</div>'); if ($this->form_validation->run() == false) { $this->load->view('templates/template', ['main' => 'hello/add-edit', 'post' => $post]); } else { $post = new Posts(); $post->postID = $this->uri->segment(3); $post->title = $this->input->post('title'); $post->post = $this->input->post('post'); $post->date_added = date('Y-m-d H:i:s'); $post->userID = $this->session->userdata('userID'); $post->active = 1; $post->save(); $this->session->set_flashdata('message', 'Data updated'); redirect('hello/view/' . $postID); } }
/** * Добавляет новую должность */ public function addAction() { $result = array(); $presentPost = \Posts::findFirst("title='" . $this->request->get("title") . "'"); if ($presentPost != false) { $result['retcode'] = 1; $result['msgs'][] = "Посада із такою назвою вже існує!"; } else { $namePost = new \Posts(); $namePost->title = $this->request->get("title"); if ($namePost->save() == false) { $result['retcode'] = 2; $result['msgs'][] = "Неможливо додати посаду \n"; foreach ($namePost->getMessages() as $message) { $result['msgs'][] = $message + "\n"; } } else { $result['retcode'] = 0; $result['id'] = $namePost->id; $result['msgs'][] = "Нову посаду збережено"; } } $this->view->disable(); $this->response->setContentType('application/json', 'UTF-8'); echo json_encode($result); }
public function addAction() { if ($this->_status['response']['status'] && $this->_checkToken()) { $this->_status['response']['status'] = false; $this->_status['response']['code'] = 301; } $post = ['entry' => true]; if ($this->_status['response']['status'] && !$this->_getPost($post)) { $this->_status['response']['status'] = false; $this->_status['response']['code'] = 201; $this->_status['response']['detail'] = $post['empty']; } $templateList = ['title' => null, 'tag' => null, 'category' => null, 'content' => null]; $conditions = ['content']; if ($this->_status['response']['status'] && !$this->_mergeArray($this->_post['entry'], $templateList, $conditions)) { $this->_status['response']['status'] = false; $this->_status['response']['code'] = 202; $this->_status['response']['detail'] = $conditions; } if (!$this->_status['response']['status']) { return $this->response->setJsonContent($this->_status); } $posts = new Posts(); $posts->assign(['author' => $this->_id, 'title' => $this->_post['entry']['title'], 'content' => $this->_post['entry']['content']]); if (!$posts->save()) { $this->_status['response']['status'] = false; $this->_status['response']['code'] = 102; return $this->response->setJsonContent($this->_status); } if (!empty($this->_post['entry']['tag'])) { if (is_string($this->_post['entry']['tag'])) { $this->_post['entry']['tag'] = (array) $this->_post['entry']['tag']; } foreach ($this->_post['entry']['tag'] as $tag) { $tags = new Tags(); $tags->assign(['posts_id' => $posts->id, 'tag' => $tag]); if (!$tags->save()) { $this->_status['response']['status'] = false; $this->_status['response']['code'] = 102; return $this->response->setJsonContent($this->_status); } } } if (!empty($this->_post['entry']['category'])) { if (is_string($this->_post['entry']['category'])) { $this->_post['entry']['category'] = (array) $this->_post['entry']['category']; } foreach ($this->_post['entry']['category'] as $category) { $categories = new Categories(); $categories->assign(['posts_id' => $posts->id, 'category' => $category]); if (!$categories->save()) { $this->_status['response']['status'] = false; $this->_status['response']['code'] = 102; return $this->response->setJsonContent($this->_status); } } } return $this->response->setJsonContent($this->_status); }
public function addPost($user_id, $post_content, $location, $url_arr, $album, $cats) { $model = new Posts(); $model->post_content = $post_content; $model->post_comment_count = 0; $model->post_like_count = 0; $model->post_view_count = 0; $model->location = $location; $model->created_at = time(); $model->status = 1; $model->updated_at = time(); $model->user_id = $user_id; if (!$model->save(FALSE)) { return FALSE; } $cats = json_decode($cats, TRUE); foreach ($cats as $cat) { $cat_model = new CatPost(); $cat_model->cat_id = $cat; $cat_model->post_id = $model->post_id; $cat_model->status = 1; $cat_model->created_at = time(); $cat_model->updated_at = time(); if (!$cat_model->save(FALSE)) { return FALSE; } } if (is_array($url_arr)) { foreach ($url_arr as $url) { $image = new Images(); $image->post_id = $model->post_id; $image->created_at = time(); $image->created_by = $user_id; $image->updated_at = time(); $image->status = 1; $image->album_id = $album; $image->image_like_count = 0; $image->img_url = $url; if (!$image->save(FALSE)) { return FALSE; } } } else { $image = new Images(); $image->post_id = $model->post_id; $image->created_at = time(); $image->created_by = $user_id; $image->updated_at = time(); $image->status = 1; $image->album_id = $album; $image->image_like_count = 0; $image->img_url = $url_arr; if (!$image->save(FALSE)) { return FALSE; } } return $model->post_id; }
public function testStore() { $post = new Posts(); $post->id = 123; $post->title = 'GGC Test Post!'; $post->temp_username = '******'; $post->message = 'This is a fake data blah blah blah'; $post->topic_id = 1651; $post->save(); Posts::findOrFail($post->id); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $post = new Posts(); $post->status = 1; // не одобрен $post->user_id = Auth::id(); // юзер $post->title = Input::get('title'); $post->content = Input::get('content'); $post->lang = App::getLocale(); $post->save(); return Redirect::to('/managePosts'); }
public function createAction() { $post = new Posts(); $success = $post->save($this->request->getPost(), array('id_posta', 'poruka', 'created_at')); if ($success) { echo "Your message has been posted !"; } else { echo "Sorry, the following problems were generated: "; foreach ($post->getMessages() as $message) { echo $message->getMessage(), "<br/>"; } } $this->view->disable(); }
public function actionAdd($id) { $text = Yii::app()->getRequest()->getPost('text'); if ($text == 'Что нового') { $text = ''; } if (empty($text) && !isset($_POST['files'])) { echo json_encode(array('status' => 'error', 'data' => 'Заполните все обязательные поля!')); exit; } $timestamp = time(); $postObj = new Posts(); $postObj->content = $text; $postObj->status = 1; $postObj->create_time = $timestamp; $postObj->author_id = Yii::app()->user->id; $postObj->owner_id = $id; $postObj->unique_hash = md5(Yii::app()->user->id . $id . $timestamp); $postObj->_owner = $id; // С чьей стены будем получать последние записи $postObj->_last_id = Yii::app()->getRequest()->getPost('lastEntryId'); // id последней "видимой" записи $posts_files = PostsFiles::model(); if ($postObj->save()) { if (isset($_POST['files'])) { $posts_files->addFiles($postObj->id); } if (Yii::app()->request->isAjaxRequest) { $posts = $postObj->lastAfterId(); if (!empty($posts)) { $res = ''; foreach ($posts as $key => $item) { $files = $posts_files->findAll('posts_id = :posts_id', array(':posts_id' => $item['id'])); $res .= $this->renderPartial('//profile/profile/_wallItem', array('item' => $item, 'files' => $files, 'owner' => $id, 'display' => 'none'), true); } echo json_encode(array('status' => 'ok', 'data' => $res)); } else { echo json_encode(array('status' => 'error', 'data' => 'null')); } } else { throw new CException('Not Found', 404); } } else { if (Yii::app()->request->isAjaxRequest) { echo json_encode(array('status' => 'error', 'data' => 'Не могу соединиться с БД')); } else { throw new CException('Server error', 500); } } }
public function actionShare() { $user_id = Yii::app()->user->id; $res = false; if (Yii::app()->request->isAjaxRequest && !empty($user_id)) { $item_id = Yii::app()->getRequest()->getPost('item_id'); $sharedEntry = Posts::model()->findByPk($item_id); $newEntry = new Posts(); $newEntryHash = md5($sharedEntry->author_type . $sharedEntry->author_id . $user_id . $sharedEntry->creation_date); if ($sharedEntry->owner_id == $user_id || $sharedEntry->author_id == $user_id || $sharedEntry->status != 1) { // если запись уже есть на стене или если запись заблочена то не добавляем echo json_encode(array('status' => 'error', 'data' => 'Ошибка при копировании записи')); exit; } $newEntry->parent_id = $sharedEntry->id; // поле parent_id устанавливаем отличное от нуля (id расшариваемого поста) $newEntry->post_type = 'userwall'; // Все основные поля копируем как есть $newEntry->author_type = $sharedEntry->author_type; $newEntry->owner_type = 'user'; $newEntry->content = $sharedEntry->content; $newEntry->multimedia = $sharedEntry->multimedia; $newEntry->status = $sharedEntry->status; $newEntry->creation_date = time(); $newEntry->author_id = $sharedEntry->author_id; $newEntry->owner_id = $user_id; $newEntry->hash = $newEntryHash; // сохраняем новую и старую записи $transaction = $sharedEntry->dbConnection->beginTransaction(); try { $newEntry->save(); $sharedEntry->shares = intval($sharedEntry->shares) + 1; // увеличиваем счетчик share у копируемой записи $sharedEntry->save(); $transaction->commit(); $res = true; } catch (Exception $e) { $transaction->rollback(); $res = false; } if ($res == true) { echo json_encode(array('status' => 'ok', 'data' => 'shared')); } else { echo json_encode(array('status' => 'error', 'data' => 'Ошибка подключения к БД')); } } else { throw new CException('Not Found', 404); } }
/** * Store a newly created post in storage. * * @return Response */ public function store() { //$validator = Validator::make($data = Input::all(), Posts::$rules); // if ($validator->fails()) // { // return Redirect::back()->withErrors($validator)->withInput(); // } $post = new Posts(); $post->topic_id = Input::get('topic_id'); $post->temp_username = Input::get('temp_username'); $post->title = 'test'; $post->message = Input::get('message'); $post->save(); return Redirect::action('PostController@index'); }
public function addPost() { $memberID = Session::get('key'); $post = new Posts(); $post->title = Input::get('title'); $post->content = Input::get('content'); $post->visibility = Input::get('visibility'); $post->memberID = $memberID; $post->date = date("d.m.Y", time()); $post->save(); $posts = DB::table('posts')->where('memberID', $memberID)->orderBy('created_at', 'desc')->get(); $member = Members::find($memberID); $followings = DB::table('follow')->join('members', 'members.memberID', '=', 'follow.followMemberID')->where('follow.memberID', $memberID)->select('members.name', 'members.surname', 'members.memberID')->get(); $followers = DB::table('follow')->join('members', 'members.memberID', '=', 'follow.memberID')->where('follow.followMemberID', $memberID)->select('members.name', 'members.surname', 'members.memberID')->get(); return View::make('member/profile', array('share' => true, 'posts' => $posts, 'member' => $member, 'followers' => $followers, 'followings' => $followings)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id = '') { if ($id) { $model = $this->loadModel($id); } else { $model = new Posts(); } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Posts'])) { $model->attributes = $_POST['Posts']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new post */ public function create($latitude, $longitude, $content, $user) { $post = new Posts(); $post->users_id = $user->id; $post->latitude = $latitude; $post->longitude = $longitude; $post->content = $content; if ($post->save()) { return array(true, $post->toArray()); } else { $errors = array(); foreach ($post->getMessages() as $message) { $errors[] = (string) $message; } return array(false, $errors); } }
/** * Cria uma nova postagem * @param date $post_date_create data da criação do post * @param date $post_date_posted data que aparecerá no blog como postado * @param date $post_date_changed data da ultima modificação da postagem * @param int $post_author id do autor da postagem * @param int $post_editor id do editor da postagem * @param string $post_title titulo do post * @param string $post_content conteudo da postagem * @param id $post_status_id status do post * @return int id da nova postagem caso sucesso ou zero caso false */ public function createNewPost($post_date_create, $post_date_posted, $post_date_changed, $post_author, $post_editor, $post_title, $post_content, $post_status_id) { $post = new Posts(); $post->post_blog = 1; $post->post_date_create = $post_date_create; $post->post_date_posted = $post_date_posted; $post->post_date_changed = $post_date_changed; $post->post_author = $post_author; $post->post_editor = $post_editor; $post->post_title = $post_title; $post->post_content = $post_content; $post->post_status_id = $post_status_id; if ($post->save()) { return $post->post_id; } else { return -1; } }
public function run() { $this->controller->pageTitle = "New Post"; $this->controller->pageTitle = "New Post"; if (Yii::app()->request->isAjaxRequest) { $img = Yii::app()->request->getParam('img'); $content = CHtml::encode(Assist::removeXSS(Yii::app()->request->getParam('content'))); $content = preg_replace('/\\n/mi', '<br/>', $content); $proxy = new Posts(); $proxy->content = $content; $proxy->picture = $img; $proxy->userId = Yii::app()->user->id; $proxy->createTime = date('Y-m-d H:i:s', time()); $proxy->save(); echo CJSON::encode(array('code' => 200, 'message' => 'SUCCESS')); } else { $this->controller->render('newpost'); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Posts(); // var_dump(Posts); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Posts'])) { $_POST['Posts']['author_id'] = Yii::app()->session['uid']; // $_POST['Posts']['created_at'] = date('Y-m-d H:i:s'); // $_POST['Posts']['updated_at'] = date('Y-m-d H:i:s'); $model->attributes = $_POST['Posts']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } // echo " after redirect, the echo command should not be exceuted!"; // die; } $this->render('create', array('model' => $model)); }
public function savePostAction() { $this->view->title = "Збереження посади"; $errors = array(); if ($this->request->isPost()) { $namePost = new \Posts(); $namePost->title = $this->request->get("title"); if ($namePost->save() == false) { echo "Неможливо додати посаду \n"; foreach ($namePost->getMessages() as $message) { echo $message, "\n"; } } else { $response = new \Phalcon\Http\Response(); $response->redirect("/methodist/stafflist/posts"); return $response; } } }
public function newpostAction() { if ($this->request->isPost()) { //Receiving the variables sent by POST $title = $this->request->getPost('title'); $content = $this->request->getPost('content'); if (!$title && !$content) { return (new \Phalcon\Http\Response())->redirect('admin'); } //admin is logged in if ($this->session->get('user_id')) { $post = new Posts(); $post->setTitle($title); $post->setContent($content); $post->save(); return (new \Phalcon\Http\Response())->redirect('admin'); } else { $this->flash->error('Not logged in'); } } }
public function actionInsert() { if (isset($_POST['choose'])) { $post = new Posts(); $post->status = 0; $post->updated_at = time(); $post->created_at = time(); $post->user_id = 1; $post->post_content = $_POST['caption']; $post->save(FALSE); $image = new Images(); $image->created_at = time(); $image->updated_at = time(); $image->post_id = $post->post_id; $image->created_by = 1; $image->img_url = $_POST['image_standard_url']; $image->status = 0; $image->save(FALSE); } echo CJSON::encode(array('message' => 'success')); }
/** * Creates a new post */ public function createAction() { if (!$this->request->isPost()) { return $this->dispatcher->forward(array("controller" => "posts", "action" => "index")); } $post = new Posts(); $post->title = $this->request->getPost("title"); $post->body = $this->request->getPost("body"); $post->excerpt = $this->request->getPost("excerpt"); $post->published = $this->request->getPost("published"); $post->updated = $this->request->getPost("updated"); $post->pinged = $this->request->getPost("pinged"); $post->to_ping = $this->request->getPost("to_ping"); if (!$post->save()) { foreach ($post->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward(array("controller" => "posts", "action" => "new")); } $this->flash->success("post was created successfully"); return $this->dispatcher->forward(array("controller" => "posts", "action" => "index")); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Posts('create'); $mesg = ""; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); //prepare tags most used $tags_most_used = TagsPosts::mostTagsUsed(); //paging media $medias_paging = Medias::getUserMedias(); $list = $medias_paging[0]; $pages = $medias_paging[1]; if (isset($_POST['Posts'])) { $model->attributes = $_POST['Posts']; $model->created = date('Y-m-d h:i:s'); if (isset($_POST['featured_image_name'])) { $model->featured_image = $_POST['featured_image_name']; } if ($model->save()) { //add category to posts if (isset($_POST['Categories'])) { foreach ($_POST['Categories'] as $key => $value) { $category_post = new CategoriesPosts(); $category_post->post_id = $model->id; $category_post->category_id = $key; $category_post->save(); } } //add tags to posts if (isset($_POST['Tags'])) { TagsPosts::insertTagsPost($_POST['Tags'], $model->id); } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess, 'tags_most_used' => $tags_most_used, 'mesg' => $mesg, 'list' => $list, 'pages' => $pages)); }
/** * Save post * * @param \Posts $post * @param $error * @return bool */ protected function _save(\Posts &$post, &$error) { $isDraft = $post->getIsDraft(); $input = $this->request()->post('post', 'ARRAY', array()); $post->hydrate($input); $post->setExcerpt(nl2br($post->getExcerpt())); $post->setIsDraft(false); $error = Plugin::applyFilters('verify_' . $post->getTaxonomy() . '_form_data', $error); if (!$post->getAuthor()) { $post->setAuthor($this->getSessionUser()->getName()); } if (!$post->isDraft() && !($post->getPublishTime() || $post->getPublishTime()->isEmpty())) { $post->setPublishTime(new DateTime()); } if (empty($error) && $post->save()) { $post = Plugin::applyFilters('handling_' . $post->getTaxonomy() . '_form_data', $post); if ($isDraft) { $this->dispatch('after_publish_' . $post->getTaxonomy() . '_post', new CMSBackendEvent($this, array('post' => $post))); } else { $this->dispatch('after_save_' . $post->getTaxonomy() . '_post', new CMSBackendEvent($this, array('post' => $post))); } return true; } else { foreach ($post->getValidationFailures() as $validationFailure) { $error[$validationFailure->getColumn()] = $validationFailure->getMessage(); } } return false; }
public function actionAdd() { if (Yii::app()->request->isAjaxRequest) { $content = Yii::app()->getRequest()->getPost('content'); $owner_type = Yii::app()->getRequest()->getPost('owner_type'); // тип владельца (у кого на стене запостили) поста - user|company $owner_id = Yii::app()->getRequest()->getPost('owner_id'); // id владельца поста $author_type = Yii::app()->getRequest()->getPost('author_type'); // тип автора поста if ($author_type == 'user') { // если постим от юзера $author_id = Yii::app()->user->id; } /*else { // иначе проверяем наличие компании у этого пользователя и постим от имени компании }*/ $post_type = Yii::app()->getRequest()->getPost('post_type'); // тип поста (для их сортировки где либо) - userwall|companywall|communitywall $ts = time(); // Создание JSON массива для прикрепления файлов к посту. $multimedia = array(); // Доработать в дальнейшем - либо получаем готовый массив, либо парсим тут в php if (isset($_POST['files'])) { foreach ($_POST['files'] as $ind => $files) { $multimedia[$ind]['nomber'] = $ind + 1; $multimedia[$ind]['id'] = key($files); $multimedia[$ind]['type'] = current($files); $multimedia[$ind]['upload_date'] = time(); } } else { $files = array(); } if ($content == 'Что нового') { // если контент пуст, то выдём ошибку $content = ''; } if (empty($content)) { echo json_encode(array('status' => 'error', 'data' => 'Заполните все обязательные поля!')); exit; } $postObj = new Posts(); // создаём новый пост $postObj->parent_id = '0'; // 0 т.к. это новый пост и мы никого не расшариваем $postObj->post_type = $post_type; $postObj->author_type = $author_type; $postObj->owner_type = $owner_type; $postObj->author_id = $author_id; $postObj->owner_id = $owner_id; $postObj->creation_date = $ts; $postObj->content = $content; $postObj->multimedia = json_encode($multimedia); $postObj->hash = md5($author_type . $author_id . $owner_id . $ts); // уникальный ключ. Нужен для того что бы пользователь не репостил на свою страницу один и тот же пост $postObj->_owner_type = $owner_type; // С чьей стены будем получать последние записи $postObj->_owner_id = $owner_id; $postObj->_last_id = Yii::app()->getRequest()->getPost('lastEntryId'); // id последней "видимой" записи if ($postObj->save()) { $posts = $postObj->lastAfterId(); if (!empty($posts)) { $res = ''; $data = array('item' => $item, 'display' => 'none'); if (isset($files)) { $data['files'] = $files; } if (isset($id)) { $data['owner'] = $id; } foreach ($posts as $key => $item) { $res .= $this->renderPartial('//posts/_postItem', $data, true); } echo json_encode(array('status' => 'ok', 'data' => $res)); } else { echo json_encode(array('status' => 'error', 'data' => 'null')); } } else { echo json_encode(array('status' => 'error', 'data' => 'Не могу соединиться с БД')); } } else { throw new CException('Not Found', 404); } }
$data['content'] = $posts[$i]['content']; $data['created_at'] = $posts[$i]['created_at']; $author = Users::find($posts[$i]['author_id']); $data['author'] = $author->firstname; } $results[] = $data; die(json_encode($results)); }); $app->post('/api/v1/posts', function () use($app) { $posts = new Posts(); $posts->title = $app->request()->post('title'); $posts->slug = str_replace(' ', '-', $app->request()->post('slug')); $posts->content = $app->request()->post('content'); $posts->author_id = $app->request()->post('post_type'); $posts->author_id = $app->request()->post('author_id'); $posts->save(); die(json_encode($posts)); }); $app->put('/api/v1/posts/:id', function ($id) use($app) { $posts = Posts::find($id); $posts->title = $app->request()->post('title'); $posts->slug = str_replace(' ', '-', $app->request()->post('slug')); $posts->content = $app->request()->post('content'); $posts->author_id = $app->request()->post('author_id'); $posts->save(); die(json_encode($posts)); }); $app->delete('/api/v1/posts/:id', function ($id) use($app) { $posts = Posts::find($id); $posts->delete(); die(json_encode($posts));
$response->write(json_encode($pages)); }); //GET THE PARTICULAR USER $app->get('/api/v1/pages/:slug', function ($slug) use($app) { $response = $app->response(); $response->header('Access-Control-Allow-Origin', '*'); $pages = Posts::where('slug', $slug)->first(); $response->write(json_encode($pages)); }); $app->post('/api/v1/pages', function () use($app) { $pages = new Posts(); $pages->title = $app->request()->post('title'); $pages->slug = str_replace(' ', '-', $app->request()->post('slug')); $pages->content = $app->request()->post('content'); $pages->author_id = $app->request()->post('author_id'); $pages->save(); die(json_encode($pages)); }); $app->put('/api/v1/pages/:id', function ($id) use($app) { $pages = Posts::find($id); $pages->title = $app->request()->post('title'); $pages->slug = str_replace(' ', '-', $app->request()->post('slug')); $pages->content = $app->request()->post('content'); $pages->author_id = $app->request()->post('author_id'); $pages->save(); die(json_encode($pages)); }); $app->delete('/api/v1/pages/:id', function ($id) use($app) { $pages = Posts::find($id); $pages->delete(); die(json_encode($pages));
/** * Creates a new post */ public function createAction() { if (!$this->request->isPost()) { return $this->dispatcher->forward(array("controller" => "posts", "action" => "index")); } $post = new Posts(); $postTags = array(); $post->id = $this->request->getPost("id"); $post->tags = $postTags; $post->users_id = $this->session->get("user_id"); $post->title = $this->request->getPost("title"); $post->body = $this->request->getPost("body"); $post->excerpt = $this->request->getPost("excerpt"); $post->pinged = $this->request->getPost("pinged"); $post->to_ping = $this->request->getPost("to_ping"); $success = $post->save(); $tags = explode(",", $this->request->getPost("tags", array("trim", "lower"))); $post->addTags($tags); if (!$success) { foreach ($post->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward(array("controller" => "posts", "action" => "new")); } $this->sendPings(); $this->flash->success("post was created successfully"); return $this->dispatcher->forward(array("controller" => "posts", "action" => "index")); }