From ddb6cadf66c7f6c26430a14658d232a88bcceb7a Mon Sep 17 00:00:00 2001 From: Nicolas BERNSTEIN Date: Fri, 13 Apr 2012 19:26:18 +0200 Subject: Minor changes in navigation. --- lib/blog/edit.php | 6 +----- lib/blog/post.php | 2 +- lib/blog/view.php | 3 ++- tpl/blog/drafts.php | 12 +++++++++--- tpl/blog/view.php | 54 +++++++++++++++++++++++++++++------------------------ 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/lib/blog/edit.php b/lib/blog/edit.php index 854c94f..d76781c 100644 --- a/lib/blog/edit.php +++ b/lib/blog/edit.php @@ -39,11 +39,7 @@ if (isset($_POST['title']) && isset($_POST['tags']) && isset($_POST['text'])) { } sql("INSERT INTO blog_tags(post, tag) VALUES " . implode(',', $v)); } - if ($post['draft']) { - header("Location: drafts-blog"); - } else { - header("Location: blog"); - } + header("Location: view-blog-$postid"); die(); } } diff --git a/lib/blog/post.php b/lib/blog/post.php index 1f1525a..a17ba5b 100644 --- a/lib/blog/post.php +++ b/lib/blog/post.php @@ -28,7 +28,7 @@ if (isset($_POST['title']) && isset($_POST['text'])) { } sql("INSERT INTO blog_tags(post, tag) VALUES " . implode(',', $v)); } - header("Location: drafts-blog"); + header("Location: view-blog-$id"); die(); } } diff --git a/lib/blog/view.php b/lib/blog/view.php index 15c4d6e..fa375d8 100644 --- a/lib/blog/view.php +++ b/lib/blog/view.php @@ -15,7 +15,7 @@ $post = mysql_fetch_assoc(sql( "WHERE blog_posts.id = $postid" )); -assert_error($post && $post['draft'] == 0, +assert_error($post && ($post['draft'] == 0 || $post['owner_id'] == $user['id']), "This post does not exist."); $comments = array(); @@ -34,6 +34,7 @@ $can_post = ($user['priv'] >= $apps['blog']['drafts'] && $user['id'] != 0); $can_edit = ($user['priv'] >= $apps['blog']['edit'] && $user['id'] != 0); $can_delete = ($user['priv'] >= $apps['blog']['delete'] && $user['id'] != 0); $can_comment = ($user['priv'] >= $apps['blog']['comment'] && $user['id'] != 0); +$is_draft = ($post['draft'] != 0); $can_delcom = ($user['priv'] >= $apps['blog']['delcom'] && $user['id'] != 0); require("tpl/blog/view.php"); diff --git a/tpl/blog/drafts.php b/tpl/blog/drafts.php index 5440cbc..510f428 100644 --- a/tpl/blog/drafts.php +++ b/tpl/blog/drafts.php @@ -8,8 +8,9 @@ echo 'post a message'; echo '

My drafts

'; if (count($drafts) > 0) { + echo ''; foreach ($drafts as $post) { - echo '
'; + /*echo '
'; echo '
'; echo 'edit'; echo ' | delete'; @@ -17,8 +18,13 @@ if (count($drafts) > 0) { echo '
'; echo '

' . $post['title'] . '

'; echo $post['text_html']; - echo '
'; + echo '
';*/ + echo ''; + echo ''; } + echo '
TitleActions
' . $post['title'] . 'edit'; + echo ' | delete'; + echo ' | publish
'; } else { echo '

No drafts

'; } @@ -28,7 +34,7 @@ echo '

My published posts

'; if (count($pub) > 0) { echo ''; foreach ($pub as $post) { - echo ''; + echo ''; echo ''; } diff --git a/tpl/blog/view.php b/tpl/blog/view.php index 0f0c89c..32f1073 100644 --- a/tpl/blog/view.php +++ b/tpl/blog/view.php @@ -10,8 +10,10 @@ if ($can_edit && $post['owner_id'] == $user['id']) echo ' | edit'; if ($can_delete && $post['owner_id'] == $user['id']) echo ' | delete'; -if ($can_comment) +if ($can_comment && !$is_draft) echo ' | post comment'; +if ($is_draft) + echo ' | publish'; echo ''; echo '
published ' . $post['date'] . '
'; if ($post['tags'] != '') { @@ -19,31 +21,35 @@ if ($post['tags'] != '') { } echo $post['text_html']; -echo '

Comments

'; - -if (count($comments) == 0) { - echo 'No comments at the moment.'; -} else { - foreach ($comments as $comment) { - echo '
'; - $a = array(); - if ($can_delcom) $a[] = 'delete'; - if ($can_comment && $comment['author_id'] == $user['id']) - $a[] = 'edit'; - if (count($a) > 0) - echo '
' . implode(" | ", $a) . '
'; - - echo '

' . $comment['date'] . ' by ' . $comment['author'] . '

'; - echo '
' . $comment['text_html'] . '
'; - echo '
'; +if (!$is_draft) { + + echo '

Comments

'; + + if (count($comments) == 0) { + echo 'No comments at the moment.'; + } else { + foreach ($comments as $comment) { + echo '
'; + $a = array(); + if ($can_delcom) $a[] = 'delete'; + if ($can_comment && $comment['author_id'] == $user['id']) + $a[] = 'edit'; + if (count($a) > 0) + echo '
' . implode(" | ", $a) . '
'; + + echo '

' . $comment['date'] . ' by ' . $comment['author'] . '

'; + echo '
' . $comment['text_html'] . '
'; + echo '
'; + } + } + + echo '

Post a comment

'; + if ($can_comment) { + echo '
 
'; + } else { + echo 'Please log in or register to post a comment.'; } -} -echo '

Post a comment

'; -if ($can_comment) { - echo '
 
'; -} else { - echo 'Please log in or register to post a comment.'; } -- cgit v1.2.3
TitleActions
' . $post['title'] . '
' . $post['title'] . 'edit'; echo ' | delete