==== Wikka Mod 010 ====
Type: Feature Addition
----
===Credit:===
**[[http://web.archive.org/web/20040810214724/http://www.wakkawiki.com/JoeD | JoeDelaney]]**
[[http://web.archive.org/web/20040810215611/http://www.wakkawiki.com/PageDeleteHandler | PageDeleteHandler @ WakkaWiki]]
----
Added the ability for admin users to delete pages.
----
Create a file named "delete.php" with the following code and place it in your /handlers/page directory. You can access it by putting a "/delete" after any URL, provided you are the page owner.
This will //permanently// delete the current page, plus all comments on that page including those made by other users. It cannot be undone.
%%(php)
UserIsOwner())
{
if ($_POST)
{
$tag = $this->GetPageTag();
// delete the page
// delete from wakka_pages where tag=
// delete from wakka_links where from_tag =
// delete from wakka_acls where page_tag =
// delete from wakka_referrers where page_tag =
$delResult = $this->LoadSingle("delete from ".$this->config["table_prefix"]."pages where tag = '".mysql_escape_string($tag)."'");
$delResult = $this->LoadSingle("delete from ".$this->config["table_prefix"]."links where from_tag = '".mysql_escape_string($tag)."'");
$delResult = $this->LoadSingle("delete from ".$this->config["table_prefix"]."acls where page_tag = '".mysql_escape_string($tag)."'");
$delResult = $this->LoadSingle("delete from ".$this->config["table_prefix"]."referrers where page_tag = '".mysql_escape_string($tag)."'");
// also delete comments from the page
// this is messy, because comments have acls, so we have to find the comment names and delete those too
// finds comments for this page
$comments = $this->LoadComments($this->tag);
// delete the acls for each comment
if ($comments)
{
foreach ($comments as $comment)
{
$delResult = $this->LoadSingle("delete from ".$this->config["table_prefix"]."acls where page_tag = '".mysql_escape_string($comment["tag"])."'");
}
}
// finally delete the comments themselves
// delete from wakka_pages where comment_on= the current page
$delResult = $this->LoadSingle("delete from ".$this->config["table_prefix"]."pages where comment_on = '".mysql_escape_string($tag)."'");
$message = "Page has been deleted ";
// redirect back to main page
$this->SetMessage($message."!");
$this->Redirect($this->config["base_url"]);
}
else
{
// show form
?>
Delete Link($this->GetPageTag()) ?>
FormOpen("delete") ?>
FormClose());
}
}
else
{
print("
You're not the owner of this page.");
}
?>
%%