Location: PHPKode > projects > Insecticida > insecticida_wiki/admin/moduleadmin.php
<?
###################################################
# Based in Workbench. 
# Copyright (C)2001 Stuart Wigley (hide@address.com) 
#
# moduleadmin.php 04/07/2007   
#
# This file is part of Insecticida.
#
# Insecticida is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Insecticida is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Insecticida; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
###############################################
session_start();
require_once("../config.php");
#if user has logged in get $login from session
if (($HTTP_SESSION_VARS["group"] == "1") && session_is_registered("login"))
{
	$login = $HTTP_SESSION_VARS["login"];
	require_once("$path/connect.php");
	require_once("$path/general.php"); 
	if ($HTTP_GET_VARS["moduleID"])
	{
		$moduleID = $HTTP_GET_VARS["moduleID"];
	}
	else if ($HTTP_POST_VARS["moduleID"])
	{
		$moduleID = $HTTP_POST_VARS["moduleID"];
	}
	$funpackDesc = $HTTP_POST_VARS["funpackDesc"];
	$fpinsert = $HTTP_POST_VARS["fpinsert"];
	$fpupdate = $HTTP_POST_VARS["fpupdate"];
	if ($moduleID)
	{
		if ($fpinsert)
		{
			$theQuery1 = "insert into funpack values ( '', '" . $funpackDesc . 
						 "', " . $moduleID . " )";
		    #echo("$theQuery1");
			mysql_query("$theQuery1") or die (mysql_error());
		}
		else if ($fpupdate)
		{
			$fpID = $HTTP_POST_VARS["fpID"];
			$theQuery1 = "update funpack set funpackDesc = '" . $funpackDesc . 
						 "' where funpackID = " . $fpID;
			mysql_query("$theQuery1") or die (mysql_error());
		}
	}
	
	include("$path/header.php");
?>
    <table cellspacing="0" class="table3">
	 <tr class="rowtitle">
	  <td><h5>Manage Modules</h5></td>
	 </tr>
	 <tr>
	  <td><p>This administration tool allows you to manage modules. You can add, edit and hide functional packs in each module.
	  </p></td>
	 </tr>
	 <tr>
	  <td><hr></td>
	 </tr>
	 <tr>
	  <td>
	   <form action="moduleadmin.php" method="get">
	    <select name="moduleID" onchange="this.form.submit()">
		<option value="">Choose
<?
$query = mysql_query("select * from mods where mods.isHidden='N' order by mods.modID") or die(mysql_error());
while ($result = mysql_fetch_array($query))
{
	echo("<option value=\"$result[modID]\"" );
	if ( $moduleID == $result[modID] ) echo( " selected" );
	echo( ">$result[modID] : $result[modName]");
}
?>
	    </select> 
		</form>
	  </td>
	 </tr>
	 <tr><td colspan="2"><hr></td></tr>
	 <tr>
	 <td>
	 <form method="post" name="moduleAdmin" action="moduleadmin.php">
<?

if ( $moduleID )
{
	echo("<input type=\"hidden\" name=\"moduleID\" value=\"$moduleID\">");
	#get all of the modules data
	$queryFunPack = mysql_query("select * from funpack where modID='$moduleID'") or die(mysql_error());
	echo("<table class=\"table1\">");
	echo("<tr bgcolor=\"#dddddd\"><td><strong>Functional Pack</strong></td><td><strong>Description</strong></td><td><strong>Operation</strong></td></tr>");
	while ($resultFunPack = mysql_fetch_array($queryFunPack))
	{
		if ($HTTP_GET_VARS["fpedit"] && ($HTTP_GET_VARS["fpID"] == $resultFunPack[funpackID]))
		{
			echo("<input type=\"hidden\" name=\"fpID\" value=\"$resultFunPack[funpackID]\">");
			echo("<tr><td>$resultFunPack[funpackID]</td><td><input type=\"text\" name=\"funpackDesc\" maxlength=\"".mysql_field_len($queryFunPack, 1)."\" value=\"$resultFunPack[funpackDesc]\"></td>");
			echo("<td><input type=\"hidden\" name=\"fpupdate\" value=\"1\"><a href=\"javascript:document.forms[2].submit()\" onClick=\"return validateForm('projectAdmin');\">Submit</a></td></tr>");
		}
		else {
			echo("<tr><td>$resultFunPack[funpackID]</td><td>$resultFunPack[funpackDesc]</td>");
			echo("<td><a href=\"moduleadmin.php?moduleID=$moduleID&fpedit=1&fpID=$resultFunPack[funpackID]\">Edit</a> &nbsp;&nbsp;");
			echo("<a href=\"funpackadmin.php?moduleID=$moduleID&fpID=$resultFunPack[funpackID]\">Admin</a>");
			echo("</td></tr>");
		}
	}
	if ($HTTP_GET_VARS["fpnew"])
	{
		echo("<tr><td>auto</td><td><input type=\"text\" name=\"funpackDesc\" ");
		#echo(" length=\"".mysql_field_len($queryFunPack, 1)."\"");
		echo(" maxlength=\"".mysql_field_len($queryFunPack, 1)."\"></td>");
		echo("<td><input type=\"hidden\" name=\"fpinsert\" value=\"1\"><a href=\"javascript:document.forms[2].submit()\" onClick=\"return validateForm('projectAdmin');\">Submit</a></td></tr>");
	}
	echo("<tr><td><a href=\"moduleadmin.php?moduleID=$moduleID&fpnew=1\">Add a new functional pack</a></td></tr>");
	echo("</table>");
}
?>  
       </td>
	  </tr>
	 </table>
  </form>
<?include("$path/footer.php");
}
else{
	include("$path/login.php");
	}
?>
Return current item: Insecticida