Example #1
0
 /**
  * New Reply
  *
  * Displays new reply form and adds reply to topic
  *
  * @param	int	$topic_id	Id of the topic to reply too
  * @access	public
  * @return	void
  */
 public function new_reply($topic_id = 0)
 {
     // Can't reply if you aren't logged it
     $this->ion_auth->logged_in() or redirect('users/login');
     // Get the topic and forum info
     $topic = $this->forum_posts_m->get_topic($topic_id);
     $forum = $this->forums_m->get(@$topic->forum_id);
     // Chech if there is a forum with that ID
     $topic and $forum or show_404();
     // If it's a quote reply get the flashdata
     if ($this->session->flashdata('forum_quote')) {
         $quote = unserialize($this->session->flashdata('forum_quote'));
         $reply->content = '[quote]' . $quote->content . '[/quote]';
     } else {
         $reply->content = set_value('content');
     }
     // Default's notify based on if the user is subscribed already
     $reply->notify = $this->forum_subscriptions_m->is_subscribed($this->user->id, $topic_id);
     // Decode the content.  This is required because of DB encoding.
     $reply->content = htmlspecialchars_decode($reply->content, ENT_QUOTES);
     // The form has been submitted one way or another
     if ($this->input->post('submit') or $this->input->post('preview')) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('content', 'Message', 'trim|required');
         $this->form_validation->set_rules('notify', 'Subscription notification', 'trim|strip_tags|max_length[1]');
         // Run form validation and add the reply
         if ($this->form_validation->run() === TRUE) {
             // Add the reply already
             if ($this->input->post('submit')) {
                 // Try and add the reply
                 if ($reply->id = $this->forum_posts_m->new_reply($this->user->id, $reply, $topic)) {
                     // Set Topic Update Time
                     $this->forum_posts_m->set_topic_update($topic->id);
                     // Set some info needed for notificaations
                     $reply->title = $topic->title;
                     $reply->topic_id = $topic->id;
                     $recipients = $this->forums_lib->get_recipients($topic_id);
                     // Send notifications
                     $this->forums_lib->notify_reply($recipients, $reply);
                     // User wants to be notified
                     if ($this->input->post('notify') == 1) {
                         $this->forum_subscriptions_m->add($this->user->id, $topic->id);
                     } else {
                         $this->forum_subscriptions_m->delete_by(array('user_id' => $this->user->id, 'topic_id' => $topic->id));
                     }
                     $this->session->set_flashdata('success', 'Reply has been added.');
                     redirect('forums/posts/view_reply/' . $reply->id);
                 } else {
                     show_error("There was a problem adding the reply.");
                 }
             } elseif ($this->input->post('preview')) {
                 $this->data->show_preview = TRUE;
             }
         } else {
             $this->data->messages['error'] = validation_errors();
         }
     }
     // Set variables for the view
     $this->data->quote =& $quote;
     $this->data->reply =& $reply;
     $this->data->forum =& $forum;
     $this->data->topic =& $topic;
     // Create BB Code buttons
     $this->data->bbcode_buttons = get_bbcode_buttons('content');
     // Template settings, then build
     $this->template->set_partial('bbcode', 'partials/bbcode');
     $this->template->set_breadcrumb($forum->title, 'forums/view/' . $topic->forum_id);
     $this->template->set_breadcrumb($topic->title, 'forums/topics/view/' . $topic->id);
     $this->template->set_breadcrumb('New Reply');
     $this->template->build('posts/reply_form', $this->data);
 }
Example #2
0
<p class="bbcode_buttons">
<?php 
foreach (get_bbcode_buttons('content') as $button) {
    ?>
	<?php 
    echo $button;
    ?>
&nbsp;
<?php 
}
?>
</p>
Example #3
0
 function new_topic($forum_id = 0)
 {
     if (!$this->ion_auth->logged_in()) {
         redirect('users/login');
     }
     // Get the forum name
     $forum = $this->forums_m->get($forum_id);
     // Chech if there is a forum with that ID
     if (!$forum) {
         show_404();
     }
     // Default this to a nope
     $this->data->show_preview = FALSE;
     if ($this->input->post('submit') or $this->input->post('preview')) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('title', 'Title', 'trim|strip_tags|required|max_length[100]');
         $this->form_validation->set_rules('content', 'Message', 'trim|required');
         if ($this->form_validation->run() === TRUE) {
             if ($this->input->post('submit')) {
                 $topic->title = set_value('title');
                 $topic->content = htmlspecialchars_decode(set_value('content'), ENT_QUOTES);
                 if ($topic->id = $this->forum_posts_m->new_topic($this->user->id, $topic, $forum)) {
                     $this->forum_posts_m->set_topic_update($topic->id);
                     // Add user to notify
                     if ($this->input->post('notify') == 1) {
                         $this->forum_subscriptions_m->add($this->user->id, $topic->id);
                     } else {
                         $this->forum_subscriptions_m->delete_by(array('user_id' => $this->user->id, 'topic_id' => $topic->id));
                     }
                     redirect('forums/topics/view/' . $topic->id);
                 } else {
                     show_error("Error Message:  Error Accured While Adding Topic");
                 }
             } elseif ($this->input->post('preview')) {
                 // Define and Parse Preview
                 //$this->data->preview = $this->forum_posts_m->postParse($message, $smileys);
                 $this->data->show_preview = TRUE;
             }
         } else {
             $this->data->validation_errors = $this->form_validation->error_string();
         }
     }
     $this->data->forum =& $forum;
     $this->data->topic =& $topic;
     $this->data->bbcode_buttons = get_bbcode_buttons('content');
     $this->template->set_partial('bbcode', 'partials/bbcode');
     $this->template->set_breadcrumb($forum->title, 'forums/view/' . $forum->id);
     $this->template->set_breadcrumb('New Topic');
     $this->template->build('posts/new_topic', $this->data);
 }