summaryrefslogblamecommitdiff
path: root/lib/notes/delete.php
blob: 179f788eccf45953cc12d848b4ba8e49379d7617 (plain) (tree)
1
2
3
4
5
6
7




                                         
                                                                   
                                                                                      





                                                                                                                                           
<?php

assert_redir(count($args) >= 3, 'notes');
$noteid = intval($args[2]);

$note = sql("SELECT owner FROM notes WHERE id = $noteid")->fetch();
assert_error($note && ($note['owner'] == $user['id'] || $user['priv'] >= $priv_admin),
	"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']);