-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rather annoying commit that needs to be made because it won't let me …
…update!
- Loading branch information
Showing
77 changed files
with
24,244 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
class Forum_Posts extends Admin_Controller { | ||
|
||
public function __construct() { | ||
parent::__construct(); | ||
} | ||
|
||
public function index() { | ||
$post = new Forum_Post; | ||
$base_url = '/admin/forum_posts/index/'; | ||
$total_rows = $post->count(); | ||
$this->load->library('pagination'); | ||
$this->pagination->initialize(array( | ||
'total_rows' => $total_rows, | ||
'base_url' => $base_url.'page/', | ||
'per_page' => 20, | ||
'uri_segment' => 'page', | ||
'full_tag_open' => '<ul>', | ||
'full_tag_close' => '</ul>', | ||
'first_link' => '', | ||
'last_link' => '', | ||
'previous_link' => '', | ||
'next_link' => '', | ||
'cur_tag_open' => '<li class="active">', | ||
'cur_tag_close' => '</li>', | ||
'num_tag_open' => '<li>', | ||
'num_tag_close' => '</li>' | ||
)); | ||
$this->load->view('forum_posts/index', array( | ||
'posts' => $post->limit(20)->offset((int) param('page'))->get(), | ||
'pagination' => $this->pagination->create_links() | ||
)); | ||
} | ||
|
||
public function remove() { | ||
$id = param('id'); | ||
if(! $id) { | ||
show_404(); | ||
} | ||
$post = new Forum_Post($id); | ||
if(! $post->exists()) { | ||
show_404(); | ||
} | ||
$post->remove(); | ||
redirect('admin/forum_posts/index'); | ||
} | ||
|
||
public function edit() { | ||
$id = param('id'); | ||
if(! $id) { | ||
show_404(); | ||
} | ||
$post = new Forum_Post($id); | ||
if(! $post->exists()) { | ||
show_404(); | ||
} | ||
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce'); | ||
$this->load->view('forum_posts/edit', array( | ||
'post' => $post | ||
)); | ||
} | ||
|
||
public function update() { | ||
$id = $this->input->post('id'); | ||
if(! $id) { | ||
show_error('Undefined Post ID'); | ||
} | ||
$post = new Forum_Post($id); | ||
if(! $post->exists()) { | ||
show_404(); | ||
} | ||
$post->content = $this->input->post('content'); | ||
if($post->save() == FALSE) { | ||
flash('errors', $post->errors); | ||
redirect('admin/forum_posts/edit/id/'.$post->id); | ||
return; | ||
} | ||
redirect('admin/forum_posts/index'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
|
||
class Forum_Sections extends Admin_Controller { | ||
|
||
public function __construct() { | ||
parent::__construct(); | ||
} | ||
|
||
public function index() | ||
{ | ||
// Handle saving a new order | ||
if($this->input->is_ajax_request()) | ||
{ | ||
$order = $this->input->post('order'); | ||
$order = explode('&', $order); | ||
$new_order = array(); | ||
|
||
foreach($order as $item) | ||
{ | ||
$item = explode('=', $item); | ||
$new_order[] = (int)$item[1]; | ||
} | ||
|
||
// Now update the forum table | ||
foreach($new_order as $order => $id) | ||
{ | ||
$this->db->where('id', $id); | ||
$this->db->update('forum_sections', array( | ||
'order' => ($order+1) | ||
)); | ||
} | ||
|
||
// Output JSON | ||
header('Cache-Control: no-cache, must-revalidate'); | ||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
header('Content-type: application/json'); | ||
echo json_encode(array('success' => true)); | ||
// echo json_encode(array('error' => 'There was a problem saving the order')); | ||
exit; | ||
} | ||
|
||
// Forum sections | ||
$section = new Forum_Section; | ||
|
||
// Load assets | ||
$this->layout->js = array('jquery-ui-1.8.min'); | ||
|
||
// Load view | ||
$this->load->view('forum_sections/index', array( | ||
'sections' => $section->order_by('order', 'asc')->get() | ||
)); | ||
} | ||
|
||
public function add() { | ||
$section = new Forum_Section; | ||
$sections = array(); | ||
foreach($section->get() as $item) { | ||
$sections[$item->id] = $item->name; | ||
} | ||
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce'); | ||
$this->load->view('forum_sections/add', array( | ||
'sections' => $sections | ||
)); | ||
} | ||
|
||
public function create() { | ||
$section = new Forum_Section; | ||
$section->name = $this->input->post('name'); | ||
$section->description = $this->input->post('description'); | ||
$section->private = $this->input->post('private'); | ||
if($section->save() == FALSE) { | ||
flash('errors', $section->errors); | ||
redirect('admin/forum_sections/add'); | ||
return; | ||
} | ||
redirect('admin/forum_sections/index'); | ||
} | ||
|
||
public function edit() { | ||
$id = param('id'); | ||
if(! $id) { | ||
show_404(); | ||
} | ||
$section = new Forum_Section($id); | ||
if(! $section->exists()) { | ||
show_404(); | ||
} | ||
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce'); | ||
$this->load->view('forum_sections/edit', array( | ||
'section' => $section, | ||
)); | ||
} | ||
|
||
public function update() { | ||
$id = $this->input->post('id'); | ||
if(! $id) { | ||
show_error('Unknown Forum_Section Section ID'); | ||
} | ||
$section = new Forum_Section($id); | ||
if(! $section->exists()) { | ||
show_404(); | ||
} | ||
$section->name = $this->input->post('name'); | ||
$section->description = $this->input->post('description'); | ||
$section->private = $this->input->post('private'); | ||
if($section->save() == FALSE) { | ||
flash('errors', $section->errors); | ||
} | ||
redirect('admin/forum_sections/index'); | ||
} | ||
|
||
public function remove() { | ||
$id = param('id'); | ||
if(! $id) { | ||
show_404(); | ||
} | ||
$section = new Forum_Section($id); | ||
if(! $section->exists()) { | ||
show_404(); | ||
} | ||
$section->remove(); | ||
redirect('admin/forum_sections/index'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
class Forum_Threads extends Admin_Controller { | ||
|
||
public function __construct() { | ||
parent::__construct(); | ||
} | ||
|
||
public function index() { | ||
$thread = new Forum_Thread; | ||
$base_url = '/admin/forum_threads/index/'; | ||
$total_rows = $thread->count(); | ||
$this->load->library('pagination'); | ||
$this->pagination->initialize(array( | ||
'total_rows' => $total_rows, | ||
'base_url' => $base_url.'page/', | ||
'per_page' => 20, | ||
'uri_segment' => 'page', | ||
'full_tag_open' => '<ul>', | ||
'full_tag_close' => '</ul>', | ||
'first_link' => '', | ||
'last_link' => '', | ||
'previous_link' => '', | ||
'next_link' => '', | ||
'cur_tag_open' => '<li class="active">', | ||
'cur_tag_close' => '</li>', | ||
'num_tag_open' => '<li>', | ||
'num_tag_close' => '</li>' | ||
)); | ||
$this->load->view('forum_threads/index', array( | ||
'threads' => $thread->limit(20)->offset((int) param('page'))->get(), | ||
'pagination' => $this->pagination->create_links() | ||
)); | ||
} | ||
|
||
public function remove() { | ||
$id = param('id'); | ||
if(! $id) { | ||
show_404(); | ||
} | ||
$thread = new Forum_Thread($id); | ||
if(! $thread->exists()) { | ||
show_404(); | ||
} | ||
$thread->remove(); | ||
|
||
$this->db->where('thread_id', $thread->id); | ||
$this->db->delete('forum_posts'); | ||
|
||
redirect('admin/forum_threads/index'); | ||
} | ||
|
||
public function edit() { | ||
$id = param('id'); | ||
if(! $id) { | ||
show_404(); | ||
} | ||
$thread = new Forum_Thread($id); | ||
if(! $thread->exists()) { | ||
show_404(); | ||
} | ||
|
||
$post = new Forum_Post(); | ||
$post->where('thread_id', $thread->id)->order_by('created_at', 'asc'); | ||
$posts = $post->get(); | ||
|
||
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce'); | ||
$this->load->view('forum_threads/edit', array( | ||
'thread' => $thread, | ||
'posts' => $posts | ||
)); | ||
} | ||
|
||
public function update() { | ||
$id = $this->input->post('id'); | ||
if(! $id) { | ||
show_error('Undefined Thread ID'); | ||
} | ||
$thread = new Forum_Thread($id); | ||
if(! $thread->exists()) { | ||
show_404(); | ||
} | ||
|
||
$thread->title = $this->input->post('title'); | ||
|
||
if($thread->save() == FALSE) { | ||
flash('errors', $thread->errors); | ||
redirect('admin/forum_threads/edit/id/'.$thread->id); | ||
return; | ||
} | ||
redirect('admin/forum_threads/index'); | ||
} | ||
|
||
} |
Oops, something went wrong.