<?php
// *** Make sure the file isn't accessed directly
if(!preg_match("/index.php/i", $_SERVER['SCRIPT_FILENAME'])){
//Give out an "access denied" error
echo "access denied";
//Block all other code
exit();
}
if (@$login->is_logged_in_as("mainadmin")) {
$submit = isset($_POST['subEditCategory']) ? $_POST['subEditCategory'] : "";
$mid = isset($_REQUEST['mid']) ? $_REQUEST['mid'] : "";
$category = new Category($mid);
if ($submit == BUTTON_SAVE_CHANGES) {
$params = Array();
if(isset($_POST['name'])) $params['name'] = $_POST['name'];
if(isset($_POST['order'])) $params['order'] = $_POST['order'];
if($category->categoryUpdate($params)) {
draw_success_message(CATEGORY_SAVED);
}else{
draw_important_message($category->error);
}
}
draw_title_bar("Edit Category");
?>
<form name='frmEditcategory' method='post'>
<?php draw_hidden_field("mid",$mid); ?>
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="main_text">
<tr>
<td>
* category Name: <br>
<input name="name" value="<?php echo $category->getName();?>" size="50">
<br><br>
* category Order: <br>
<?php // Output select tag as a total number of categories available
$total_categories = Category::getAll();
draw_numbers_select_field("order",$category->getOrder(2),1,$total_categories[1]);
?>
</td>
</tr>
</table><br>
<input class="form_button" type="submit" name="subEditCategory" value="<?php echo BUTTON_SAVE_CHANGES ?>">
</form>
<?php
} else draw_important_message(NOT_AUTHORIZED);
?>