Revision [2825]

This is an old revision of GmBowenAdminPageControlTool made by GmBowen on 2004-12-04 03:00:41.

 

Simple Admin Control Panel

For various reasons, administrators might need to remove content from the wiki in a (semi)permanent fashion (this is more and more true as legal culpability for offensive statements, etc. is extended....and because of this an administrator may not want to completely remove the content (so the "owner" is still identifiable), but make it so that it at least appears to no longer exist). Below is code for what is essentially a simple administrator control panel (appearing under the footer) that allows the administrator to "Hide a page" (it changes the "Y" to an "H" in the _pages database table (if the ACLS table for "Read" is set to null then only the administrator can re-create the page....at least that's how it tested out on my server), "Erase the History" of a page, or "Delete a Page". It provides a small table under the footer with these features in it at the bottom of the page.

All the changes must be implemented for the features to work.

Hide Page Action


Whenever the "Hide Page" button is clicked it changes the field "latest" for that page from "Y" to "H" and it therefore does not appear. If the ACLS permissions are set to null before "Hide Page" is clicked then only the admin can re-create the page.

1. The following code must be saved as hidepage.php and the file placed in the actions directory
<? // code developed by GMBowen to "hide" a given page (by changing "latest" to "H" in _pages table)
if ($this->IsAdmin())
{
    echo '<table><tr><td><form action="" method="post">
    <input type="submit" name="hidepage" value="Hide Page"></td></table></form>'
;
    echo "<small>* To <strong>hide</strong> page, <strong>set</strong> ACLS ''Read'' to <strong><i>null</i></strong> & click on Hide button above...</small><BR>";
    echo "<small>* Note that unless the ACLS is set to null, then anybody with Read permission can re-create the page.</small>";
}
if ($_POST['hidepage'] && $this->IsAdmin())
{
$thispage=$this->GetPageTag();
//$sql = "DELETE FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='N'";
$sql = "UPDATE ".$this->config['table_prefix']."pages SET latest='H' WHERE tag='$thispage' AND latest='Y'";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
 $url = $this->config['base_url'];
     $this->redirect($url."HomePage");
} ?>

2. The database table (wakka?)_pages must be changed. The field "latest" must be edited so that rather than being enum('Y', 'N') it now reads enum('Y', 'N', 'H')

Erase History Action

Sometimes it can be useful for the administrator to erase the history of a page. (And I know this is easy to do just on the URL line....but I use frames (Ya, I know, bad idea) and so sometimes the URL bar isn't visible....and that's deliberate eh?....so this addition solves the problem for me.)

Perhaps add code so there is one history page that shows "Previous history of this page removed by Administrator"?? --Mike

The following code must be saved as adminerasehistory.php and the file placed in the actions directory....
<?
// code developed by GMBowen & JGoguen to allow admins to erase history on a given page
if ($this->IsAdmin())
{
    echo '<table><tr><td><form action="" method="post">
    <input type="submit" name="erasehistory" value="Erase History"></td></table> <br /></form>'
;
}
if ($_POST['erasehistory'] && $this->IsAdmin())
{
$thispage=$this->GetPageTag();
$sql = "DELETE FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='N'";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
elseif ($_POST['erasehistory'] && !$this->IsAdmin())
{
echo "<i>History can only be erased by an administrator.</i>";
}
?>

Modification of Footer.php Code

The following code was added at the end of the footer.php file (just after the last "?>")......it includes code to "delete" a page
<? if ($this->IsAdmin())
{
echo "<table border=1><tr><td width=250>";
include("hidepage.php");
echo "</p></td><td valign=top>";
include("adminerasehistory.php");
?>
</td><td valign=top>
[<A HREF="<? echo $this->GetConfigValue("base_url").$this->GetPageTag()."/delete"; ?>"><strong>Delete Page</strong></A>]</td></tr></table>
<? } ?>
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki