Exemple #1
0
 public function create()
 {
     $params = $this->params()->forum_post;
     if (empty($params['parent_id']) || !ctype_digit($params['parent_id'])) {
         $params['parent_id'] = null;
     }
     $this->forum_post = ForumPost::create(array_merge($params, ['creator_id' => $this->current_user->id, 'ip_addr' => $this->request()->remoteIp()]));
     if ($this->forum_post->errors()->blank()) {
         if (!$this->params()->forum_post['parent_id']) {
             $this->notice("Forum topic created");
             $this->redirectTo(['action' => "show", 'id' => $this->forum_post->root_id()]);
         } else {
             $this->notice("Response posted");
             $this->redirectTo(["#show", 'id' => $this->forum_post->root_id(), 'page' => ceil($this->forum_post->root()->response_count / 30.0)]);
         }
     } else {
         $this->render_error($this->forum_post);
     }
 }
Exemple #2
0
<?php

auto_set_params(array('forum_post' => array()));
$forum_post = ForumPost::create(array_merge(request::$params->forum_post, array('creator_id' => user::$current->id)));
if ($forum_post->record_errors->blank()) {
    if (empty(request::$params->forum_post['parent_id'])) {
        notice("Forum topic created");
        redirect_to("#show", array('id' => $forum_post->root_id));
    } else {
        notice("Response posted");
        redirect_to("#show", array('id' => $forum_post->root_id, 'page' => ceil($forum_post->root->response_count / 30)));
    }
} else {
    render_error($forum_post);
}