Location: PHPKode > projects > Insecticida > insecticida_wiki/admin/funpackadmin.php
<?
###################################################
# This file is part of Insecticida. (http://sourceforge.net/projects/insecticida/)
# Copyright (C) 2001-2007 Guillermo Schwarz
#
# funpackadmin.php 10/07/2007   
#
# Based in Workbench v0.11 (http://workbench.sourceforge.net)
# Copyright (C)2001 Stuart Wigley (hide@address.com) 
#
# 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"];
	}
	if ($HTTP_POST_VARS["fpID"])
	{
		$fpID = $HTTP_POST_VARS["fpID"];
	}
	else if ($HTTP_GET_VARS["fpID"])
	{
		$fpID = $HTTP_GET_VARS["fpID"];
	}
	if ($HTTP_GET_VARS["usecaseID"])
	{
		$usecaseID = $HTTP_GET_VARS["usecaseID"];
	}
	else if ($HTTP_POST_VARS["usecaseID"])
	{
		$usecaseID = $HTTP_POST_VARS["usecaseID"];
	}
	$usecaseName = $HTTP_POST_VARS["usecaseName"];
	$usecaseDesc = $HTTP_POST_VARS["usecaseDesc"];
	$ucinsert = $HTTP_POST_VARS["ucinsert"];
	$ucupdate = $HTTP_POST_VARS["ucupdate"];
	$ucedit = $HTTP_GET_VARS["ucedit"];
	if ( $moduleID )
	{
		if ( $fpID )
		{
			if ( $ucinsert )
			{
				$theQuery1 = "insert into usecase values ( '', '" . $usecaseName . 
							 "', '" . $usecaseDesc . 
							 "', " . $fpID . " )";
				#echo("$theQuery1");
				mysql_query("$theQuery1") or die (mysql_error());
			}
			else if ( $ucupdate )
			{
				$theQuery1 = "update usecase set usecaseName = '" . $usecaseName . 
							 "', usecaseDesc = '" . $usecaseDesc . 
							 "' where usecaseID = " . $usecaseID;
				mysql_query("$theQuery1") or die (mysql_error());
			}
		}
	}
	
	include("$path/header.php");
?>
    <table cellspacing="0" class="table3">
	 <tr class="rowtitle">
	  <td><h5>Manage Functional Packs</h5></td>
	 </tr>
	 <tr>
	  <td><p>This administration tool allows you to manage functional packs. <br>
	        You can add, edit and hide use cases in functional packs. <br>
			 Typically you should have already added functional packs to modules.
			 <!-- 
				 $moduleID = "<?=$moduleID?>"
				 $fpID = "<?=$fpID?>"
				 $usecaseID = "<?=$usecaseID?>"
				 $usecaseName = "<?=$usecaseName?>"
				 $usecaseDesc = "<?=$usecaseDesc?>"
				 $ucinsert = "<?=$ucinsert?>"
				 $ucupdate = "<?=$ucupdate?>"
				 $ucedit = "<?=$ucedit?>"
			 -->
	  </p></td>
	 </tr>
	 <tr>
	  <td><hr></td>
	 </tr>
	 <tr>
	  <td>
	   <form action="funpackadmin.php" method="get">
	    Module: <select name="moduleID" onchange="this.form.submit()">
			<option value="">Choose</option>
<?
		$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]</option>");
		}
?>
		</select>
		Functional Pack: <select name="fpID" onchange="this.form.submit()">
			<option value="">Choose</option>
<?
	if ($moduleID)
	{
		$query = mysql_query("select * from funpack where funpack.modID=" . $moduleID) or die(mysql_error());
		while ($result = mysql_fetch_array($query))
		{
			echo("<option value=\"$result[funpackID]\"" );
			if ( $fpID == $result[funpackID] ) echo( " selected" );
			echo( ">$result[funpackID] : $result[funpackDesc]</option>");
		}
	}
?>
		</select> 
		</form>
	  </td>
	 </tr>
	 <tr><td colspan="2"><hr></td></tr>
	 <tr>
	 <td>
	 <form method="post" name="funpackadmin" action="funpackadmin.php">
<?

if ( $moduleID && $fpID )
{
	echo("<input type=\"hidden\" name=\"moduleID\" value=\"$moduleID\">");
	echo("<input type=\"hidden\" name=\"fpID\" value=\"$fpID\">");
	#get all of the modules data
	$queryUseCase = mysql_query("select * from usecase where usecase.funpackID='$fpID'") or die(mysql_error());
	echo("<table class=\"table1\">");
	echo("<tr bgcolor=\"#dddddd\"><td><strong>Use case</strong></td>");
	echo("<td><strong>Name</strong></td>");
	echo("<td><strong>Description</strong></td>");
	echo("<td><strong>Java Class</strong></td>");
	echo("<td><strong>Java Package</strong></td>");
	echo("<td><strong>Operation</strong></td></tr>");
	while ($resultUseCase = mysql_fetch_array($queryUseCase))
	{
		if ($ucedit && ($usecaseID == $resultUseCase[usecaseID]))
		{
			echo("<input type=\"hidden\" name=\"usecaseID\" value=\"$resultUseCase[usecaseID]\">");
			echo("<tr>");
			echo("<td>$resultUseCase[usecaseID]</td>");
			echo("<td><input type=\"text\" name=\"usecaseName\" maxlength=\"".mysql_field_len($queryFunPack, 1)."\" value=\"$resultUseCase[usecaseName]\"></td>");
			echo("<td><input type=\"text\" name=\"usecaseDesc\" maxlength=\"".mysql_field_len($queryFunPack, 2)."\" value=\"$resultUseCase[usecaseDesc]\"></td>");
			echo("<td><input type=\"hidden\" name=\"ucupdate\" value=\"1\"><a href=\"javascript:document.forms[2].submit()\" onClick=\"return validateForm('projectAdmin');\">Submit</a></td></tr>");
		}
		else {
			echo("<tr><td>$resultUseCase[usecaseID]</td><td>$resultUseCase[usecaseName]</td>");
			echo("<td>$resultUseCase[usecaseDesc]</td>");
			echo("<td>$resultUseCase[javaClass]</td>");
			echo("<td>$resultUseCase[javaPackage]</td>");
			echo("<td><a href=\"funpackadmin.php?moduleID=$moduleID&fpID=$fpID&ucedit=1&usecaseID=$resultUseCase[usecaseID]\">Edit</a></td></tr>");
		}
	}
	if ($HTTP_GET_VARS["ucnew"])
	{
		$len = mysql_field_len($resultUseCase, 1);
		echo("<tr><td>auto</td>");
		echo("<td>$len<input type=\"text\" name=\"usecaseName\" size=\"". $len ."\"");
		echo(" maxlength=\"" . $len . "\"></td>");
		$len = mysql_field_len($resultUseCase, 2);
		echo("<td>$len<input type=\"text\" name=\"usecaseDesc\" size=\"". $len ."\"");
		echo(" maxlength=\"" . $len . "\"></td>");
		$len = mysql_field_len($resultUseCase, 3);
		echo("<td>$len<input type=\"text\" name=\"javaClass\" size=\"". $len ."\"");
		echo(" maxlength=\"" . $len . "\"></td>");
		$len = mysql_field_len($resultUseCase, 3);
		echo("<td>$len<input type=\"text\" name=\"javaPackage\" size=\"". $len ."\"");
		echo(" maxlength=\"" . $len . "\"></td>");
		echo("<td><input type=\"hidden\" name=\"ucinsert\" value=\"1\"><a href=\"javascript:document.forms[2].submit()\" onClick=\"return validateForm('projectAdmin');\">Submit</a></td></tr>");
	}
	echo("<tr><td colspan=\"3\"><a href=\"funpackadmin.php?moduleID=$moduleID&fpID=$fpID&ucnew=1\">Add a new use case</a></td></tr>");
	echo("</table>");
}
?>  
       </td>
	  </tr>
	 </table>
  </form>
<?include("$path/footer.php");
}
else{
	include("$path/login.php");
	}
?>
Return current item: Insecticida