summaryrefslogtreecommitdiff
path: root/lib/notes/delete.php
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2011-09-17 16:48:29 +0200
committerNicolas BERNSTEIN <alexis211@gmail.com>2011-09-17 16:48:29 +0200
commitd0060968b77c39bdf8abffb071c971c166b59edb (patch)
tree0be52e00a25bd298235a0cf916fb07496d3ab95f /lib/notes/delete.php
downloadBits-d0060968b77c39bdf8abffb071c971c166b59edb.tar.gz
Bits-d0060968b77c39bdf8abffb071c971c166b59edb.zip
First commit.
Diffstat (limited to 'lib/notes/delete.php')
-rw-r--r--lib/notes/delete.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/notes/delete.php b/lib/notes/delete.php
new file mode 100644
index 0000000..e8ef31e
--- /dev/null
+++ b/lib/notes/delete.php
@@ -0,0 +1,13 @@
+<?php
+
+assert_redir(count($args) >= 3, 'notes');
+$noteid = intval($args[2]);
+
+$note = mysql_fetch_assoc(sql("SELECT owner FROM notes WHERE id = $noteid"));
+assert_error($note && $note['owner'] == $user['id'],
+ "This note does not exist, or you are not allowed to delete it.");
+
+token_validate("Do you really want to delete this note ? All children notes will become children of the root note.", "view-notes-$noteid");
+sql("DELETE FROM notes WHERE id = $noteid");
+sql("UPDATE notes SET parent = 0 WHERE parent = $noteid");
+header("Location: user-notes-" . $user['id']);