2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
2004-03-15 16:22:00 +00:00
|
|
|
include("path.php");
|
2005-02-09 02:20:21 +00:00
|
|
|
require(BASE."include/incl.php");
|
|
|
|
|
require(BASE."include/category.php");
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2006-06-17 06:10:10 +00:00
|
|
|
$aClean = array(); //array of filtered user input
|
|
|
|
|
|
|
|
|
|
$aClean['catId'] = makeSafe($_REQUEST['catId']);
|
|
|
|
|
$aClean['name'] = makeSafe($_REQUEST['name']);
|
|
|
|
|
$aClean['description'] = makeSafe($_REQUEST['description']);
|
|
|
|
|
$aClean['parentId'] = makeSafe($_REQUEST['parentId']);
|
|
|
|
|
$aClean['submit'] = makeSafe($_REQUEST['submit']);
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$_SESSION['current']->hasPriv("admin"))
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
errorpage();
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2006-06-17 06:10:10 +00:00
|
|
|
$oCat = new Category($aClean['catId']);
|
|
|
|
|
if($aClean['submit'])
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2006-06-17 06:10:10 +00:00
|
|
|
$oCat->update($aClean['name'],$aClean['description'],$aClean['parentId']);
|
2005-02-09 02:20:21 +00:00
|
|
|
redirect(apidb_fullurl("appbrowse.php?catId=".$oCat->iCatId));
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-02-09 02:20:21 +00:00
|
|
|
apidb_header("Add Category");
|
2006-06-17 06:10:10 +00:00
|
|
|
$sQuery = "SELECT catId, catName FROM appCategory WHERE catId!='".$aClean['catId']."'";
|
2005-02-09 02:20:21 +00:00
|
|
|
$hResult = query_appdb($sQuery);
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$aCatsIds[]=$oRow->catId;
|
|
|
|
|
$aCatsNames[]=$oRow->catName;
|
|
|
|
|
}
|
|
|
|
|
echo "<form method=\"post\" action=\"addCategory.php\">
|
|
|
|
|
<input type=\"hidden\" name=\"catId\" value=\"".$oCat->iCatId."\" />
|
|
|
|
|
<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
|
|
|
|
|
<tr>
|
|
|
|
|
<td width=\"15%\" class=\"box-label\"><b>Category name</b></td>
|
|
|
|
|
<td class=\"box-body\">
|
|
|
|
|
<input type=\"text\" size=\"50\" name=\"name\" value=\"".$oCat->sName."\" />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td width=\"15%\" class=\"box-label\"><b>Description</b></td>
|
|
|
|
|
<td class=\"box-body\">
|
|
|
|
|
<input type=\"text\" size=\"50\" name=\"description\" value=\"".$oCat->sDescription."\" />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td width=\"15%\" class=\"box-label\"><b>Parent</b></td>
|
|
|
|
|
<td class=\"box-body\">
|
|
|
|
|
".html_select("parentId",$aCatsIds,$oCat->iParentId,$aCatsNames)."
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan=\"2\" class=\"box-body\">
|
|
|
|
|
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</form>";
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
apidb_footer();
|
|
|
|
|
?>
|