---- ====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. An action is included at the bottom of this page that will allow the admin to list the hidden pages and restore them if desired. http://gmbtst.msvu.ca/wikitest/adminpanel.jpg All the changes must be implemented for the features to work. ====Hide Page Code==== 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 %%(php) IsAdmin()) { echo '
'; echo "* To hide page, set ACLS ''Read'' to null & click on Hide button above...
"; echo "* Note that unless the ACLS is set to null, then anybody with Read permission can re-create the page."; } 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 Code==== Sometimes it can be useful for the administrator to erase the history of a page. ''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.... %%(php) IsAdmin()) { echo '

'; } 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 "History can only be erased by an administrator."; } ?> %% ====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. (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.) %%(php) IsAdmin()) { echo "
"; include("hidepage.php"); echo "

"; include("adminerasehistory.php"); ?> [GetPageTag()."/delete"; ?>">Delete Page]
%% ~& I had to fix this - probably written for a version that did not have an actions folder. Here is my fix: - CharlotteFischer %%(php) IsAdmin()) { echo "
"; include($this->config['action_path']."/hidepage.php"); echo "

"; include($this->config['action_path']."/adminerasehistory.php"); ?> [GetPageTag()."/delete"; ?>">Delete Page]
%% ====View Hidden Pages Action==== This action is designed to work in conjunction with the Simple Admin Control Panel. It allows an administrator to view a list of pages which have been hidden, and restore them if desired. Use it by placing ""{{hiddenpages.php}}"" on a page. save this code as the file ##hiddenpages.php## in the actions directory... %%(php) IsAdmin()) { $unhide=$_REQUEST['unhide']; $unhidename=$_REQUEST['unhidename']; $this->query("UPDATE ".$this->config['table_prefix']."pages SET latest = 'Y' WHERE tag='$unhidename' AND latest = 'H' "); $thislink = $this->config["base_url"].$this->MiniHref($method, $tag); $counta = "0"; $query = "SELECT tag,owner,latest,time FROM ".$this->config['table_prefix']."pages WHERE latest = 'H' ORDER BY id asc"; $result = mysql_query($query); echo "
"; echo ""; ?> "; echo ""; echo ""; echo ""; $unhidepagelnk = $thislink.'&unhide=yes'.'&unhidename='.$row['tag']; echo ""; } echo "
The current hidden pages are.....

 

Page Name

Page Owner

Time Hidden

Un-Hide??

 ".$count."  ".$row['tag']."  ".$row['owner']."  ".$row['time']."   Restore?
"; } else { echo "In order to list hidden pages you need to be a designated administrator."; } ?> %% ---- CategoryUserContributions