Skip to content

Commit

Permalink
Add ability to change publish state #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Clidus committed Aug 14, 2016
1 parent 352590c commit 2371cae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ignition_application/controllers/ignition/blogAdmin.php
Expand Up @@ -91,14 +91,15 @@ public function edit($PostID)
$this->form_validation->set_rules('post', 'Post', 'trim|required|xss_clean');
$this->form_validation->set_rules('deck', 'Deck', 'trim|required|xss_clean');
$this->form_validation->set_rules('image', 'Image', 'trim|xss_clean');
$this->form_validation->set_rules('published', 'Published', 'trim|xss_clean');
$this->form_validation->set_error_delimiters('<div class="alert alert-danger">', '<a class="close" data-dismiss="alert" href="#">&times;</a></div>');

if ($this->form_validation->run())
{
// update db
$this->load->model('Blog');
$title = $this->input->post('title');
$this->Blog->update($PostID, $title, $this->getUrl($title), $this->input->post('post'), $this->input->post('deck'), $this->input->post('image'));
$this->Blog->update($PostID, $title, $this->getUrl($title), $this->input->post('post'), $this->input->post('deck'), $this->input->post('image'), $this->input->post('published'));
$success = true;
}
}
Expand Down
5 changes: 3 additions & 2 deletions ignition_application/models/ignition/blog.php
Expand Up @@ -37,14 +37,15 @@ function add($title, $url, $post, $userID, $deck)
}

// update blog post
function update($postID, $title, $url, $post, $deck, $image)
function update($postID, $title, $url, $post, $deck, $image, $published)
{
$post = array(
'Title' => $title,
'URL' => $url,
'Post' => $post,
'Deck' => $deck,
'Image' => $image
'Image' => $image,
'Published' => $published,
);

$this->db->where('PostID', $postID);
Expand Down
14 changes: 12 additions & 2 deletions ignition_application/views/admin/blog/edit.php
Expand Up @@ -33,13 +33,23 @@
<input class="form-control" type="text" name="deck" value="<?php echo $post->Deck ?>">
</div>
<div class="form-group">
<label for="url">Image</label>
<label for="image">Image</label>
<input class="form-control" type="text" name="image" value="<?php echo $post->Image ?>">
</div>
<div class="form-group">
<label for="url">Post</label>
<label for="post">Post</label>
<textarea id="blogPostTextArea" placeholder="Enter your text ..." class="form-control" name="post"><?php echo $post->Post ?></textarea>
</div>
<div class="form-group">
<label for="publish">Publish</label>
<?php
$options = array(
'0' => 'Draft',
'1' => 'Published',
);
echo form_dropdown('published', $options, $post->Published, 'class="form-control"');
?>
</div>
<input class="hidden" name="formType" value="post">
<button type="submit" class="btn btn-default">Post</button>
<a onclick="javascript:deleteBlogPost(<?php echo $post->PostID ?>);"><div class="btn btn-danger pull-right">Delete</div></a>
Expand Down

0 comments on commit 2371cae

Please sign in to comment.