Rev 167 | Rev 172 | 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 | |||
5 | $page = new Taios_Page('Blog Posts', '../'); |
||
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); |
||
23 | if (!$page->isUserAdmin($page->getLoggedInUser()) && $page->getLoggedInUser()->ID != $post->author->ID) |
||
24 | { |
||
25 | $page->drawError('You do not have permission to access this page.'); |
||
26 | } |
||
27 | |||
28 | $error = ''; |
||
29 | |||
30 | if (isset($_POST['id'])) |
||
31 | { |
||
32 | $title = $_POST['title']; |
||
33 | $content = $_POST['content']; |
||
34 | $category = $_POST['category']; |
||
35 | |||
36 | if (empty($title)) |
||
37 | { |
||
38 | $error = "No Title Specified"; |
||
39 | } |
||
40 | else if (empty($content)) |
||
41 | { |
||
42 | $error = "No Content Specified"; |
||
43 | } |
||
44 | else |
||
45 | { |
||
169 | tom | 46 | $page->query('UPDATE BlogPosts SET Content = "' . $content . '", Title = "' . $title . '", Category = "' . $category . '" WHERE ID = ' . $id); |
157 | freddie | 47 | $page->redirect('index.php'); |
48 | } |
||
49 | } |
||
50 | |||
51 | $page->drawHeader(); |
||
52 | $page->drawBlogCategoriesMenu(); |
||
53 | $page->drawMiddle(); |
||
54 | |||
55 | if (!empty($error)) |
||
56 | { |
||
57 | $page->drawError($error, false); |
||
58 | } |
||
59 | |||
60 | ?> |
||
61 | |||
169 | tom | 62 | <form action="edit-post.php" method="post"> |
157 | freddie | 63 | <table> |
64 | <tr> |
||
65 | <td class="bold">Title: </td> |
||
162 | freddie | 66 | <td><input type="text" name="title" value="<?php echo $post->title; ?>/></td> |
157 | freddie | 67 | </tr> |
68 | <tr> |
||
69 | <td class="bold">Content: </td> |
||
161 | freddie | 70 | <td><textarea name="content" style="width: 500px; height: 300px;"><?php echo $post->content; ?></textarea></td> |
157 | freddie | 71 | </tr> |
72 | <tr> |
||
73 | <td class="bold">Catagory: </td> |
||
74 | <td><input type="text" name="category" /><?php echo $post->category; ?></td> |
||
75 | </tr> |
||
76 | |||
77 | <?php |
||
169 | tom | 78 | write('<input type="hidden" name="id" value="' . $id . '" />'); |
157 | freddie | 79 | ?> |
80 | |||
81 | <tr> |
||
82 | <td class="bold"></td> |
||
83 | <td><input type="submit" value="Post" /></td> |
||
84 | </tr> |
||
85 | </table> |
||
86 | </form> |
||
87 | |||
88 | <?php |
||
89 | |||
90 | $page->drawFooter(); |
||
91 | |||
92 | ?> |
||
93 |