summaryrefslogtreecommitdiff
path: root/lib/blog/publish.php
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2012-02-12 19:50:55 +0100
committerNicolas BERNSTEIN <alexis211@gmail.com>2012-02-12 19:50:55 +0100
commit24547ccec6526fcef3cccb34bc35fb81f31236b3 (patch)
treefc908fb06a6b8b4d4131c7303c4fb3b7d348f9bf /lib/blog/publish.php
parentcd76af42463bd80539db8c9671a427a9f0fe5d69 (diff)
downloadBits-24547ccec6526fcef3cccb34bc35fb81f31236b3.tar.gz
Bits-24547ccec6526fcef3cccb34bc35fb81f31236b3.zip
A lot of changes : blogging system essentially.
Diffstat (limited to 'lib/blog/publish.php')
-rw-r--r--lib/blog/publish.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/blog/publish.php b/lib/blog/publish.php
new file mode 100644
index 0000000..1674911
--- /dev/null
+++ b/lib/blog/publish.php
@@ -0,0 +1,13 @@
+<?php
+
+assert_redir(count($args) >= 3, 'blog');
+$postid = intval($args[2]);
+
+$post = mysql_fetch_assoc(sql("SELECT owner, draft FROM blog_posts WHERE id = $postid"));
+assert_error($post && $post['owner'] == $user['id'],
+ "This note does not exist, or you are not allowed to delete it.");
+assert_error($post['draft'] == 1, "This post is already published.");
+
+token_validate("Are you sure this post is ready to be published ?", "blog");
+sql("UPDATE blog_posts SET draft = 0, date = NOW() WHERE id = $postid");
+header("Location: blog");