Revision [2821]

This is an old revision of GmBowenAdminPageControlTool made by GmBowen on 2004-12-04 01:12:38.

 

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 is set to !* then only the page owner can re-create the page....if I could figure out how to get it so that a pagename that was in the database with an "H" couldn't be "re-created" then it'd be perfect...so that rather than giving the message "This page doesn't exist yet. Maybe you want to create it?" it would say "Creation of a page with this name is now blocked by the administrator"....Ideas or hints anyone??), "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 as a page. However, the original page owner can re-create the page (in the various ways possible)....and even then only if the ACLS permissions are set to "Read" equalling "!*" before it is clicked on, otherwise anyone could. If I can figure out how to (perhaps by getting it so "edit"/create page only happens if NOT in the database as a pagename) then I'll make it so that nobody can recreate the page (except for the administrator-only using a "show hidden page" action which will allow recovery by changing latest="H" to latest="Y"....I'll develop this action later).

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 <b>hide</b> page, <b>set</b> ACLS Read to <b>!*</b> & click on Hide button above...</small><BR>";
    echo "<small>* Note that the original owner can still re-create the page...unless you don't set the ACLS, then anybody with Read permission can.</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