Rev 484 | Rev 511 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
157 | freddie | 1 | <?php |
2 | |||
3 | require '../_taios.php'; |
||
4 | |||
176 | tom | 5 | $page = new Taios_Page('Edit Post', '../'); |
157 | freddie | 6 | |
169 | tom | 7 | if (isset($_GET['id'])) |
8 | { |
||
157 | freddie | 9 | $id = $_GET['id']; |
169 | tom | 10 | } |
11 | else if (isset($_POST['id'])) |
||
12 | { |
||
157 | freddie | 13 | $id = $_POST['id']; |
169 | tom | 14 | } |
157 | freddie | 15 | else |
169 | tom | 16 | { |
17 | $page->drawError('No ID set.'); |
||
18 | } |
||
157 | freddie | 19 | |
20 | $page->checkLoggedIn(); |
||
21 | |||
22 | $post = $page->getBlogPost($id); |
||
471 | muzer | 23 | if ((!$page->isUserAdmin($page->getLoggedInUser()) && $page->getLoggedInUser()->ID != $post->author->ID) || !$page->isUserNormal($page->getLoggedInUser())) |
157 | freddie | 24 | { |
25 | $page->drawError('You do not have permission to access this page.'); |
||
26 | } |
||
27 | |||
28 | $error = ''; |
||
29 | |||
492 | tom | 30 | if (isset($_POST['id'])) { |
157 | freddie | 31 | $title = $_POST['title']; |
32 | $content = $_POST['content']; |
||
33 | $category = $_POST['category']; |
||
34 | |||
492 | tom | 35 | if (empty($title)) { |
157 | freddie | 36 | $error = "No Title Specified"; |
492 | tom | 37 | } else if (empty($content)) { |
157 | freddie | 38 | $error = "No Content Specified"; |
492 | tom | 39 | } else { |
40 | $args = array($content, $title, $category, $id); |
||
41 | $page->query("UPDATE BlogPosts SET Content = ?, Title = ?, Category = ? WHERE ID = ?", $args); |
||
173 | tom | 42 | $page->redirect('post.php?id=' . $id); |
157 | freddie | 43 | } |
44 | } |
||
45 | |||
46 | $page->drawHeader(); |
||
47 | $page->drawBlogCategoriesMenu(); |
||
48 | $page->drawMiddle(); |
||
49 | |||
492 | tom | 50 | if (!empty($error)) { |
157 | freddie | 51 | $page->drawError($error, false); |
52 | } |
||
53 | |||
54 | ?> |
||
55 | |||
169 | tom | 56 | <form action="edit-post.php" method="post"> |
157 | freddie | 57 | <table> |
58 | <tr> |
||
59 | <td class="bold">Title: </td> |
||
171 | tom | 60 | <td><input type="text" name="title" value="<?php echo $post->title; ?>"/></td> |
157 | freddie | 61 | </tr> |
62 | <tr> |
||
63 | <td class="bold">Content: </td> |
||
203 | tom | 64 | <td><textarea name="content"><?php echo $post->content; ?></textarea></td> |
157 | freddie | 65 | </tr> |
66 | <tr> |
||
67 | <td class="bold">Catagory: </td> |
||
172 | tom | 68 | <td><input type="text" name="category" value="<?php echo $post->category; ?>" /></td> |
157 | freddie | 69 | </tr> |
70 | |||
71 | <?php |
||
169 | tom | 72 | write('<input type="hidden" name="id" value="' . $id . '" />'); |
157 | freddie | 73 | ?> |
74 | |||
75 | <tr> |
||
76 | <td class="bold"></td> |
||
176 | tom | 77 | <td><input type="submit" value="Edit" /></td> |
157 | freddie | 78 | </tr> |
79 | </table> |
||
80 | </form> |
||
81 | |||
82 | <?php |
||
83 | |||
84 | $page->drawFooter(); |
||
85 | |||
86 | ?> |
||
87 |