<?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")) {
// Do delete action
$act = isset($_GET['act']) ? $_GET['act'] : "";
if($act=="delete"){
$mid = isset($_GET['mid']) ? $_GET['mid'] : "";
$category = new Category($mid);
if($category->categoryDelete($mid)){
draw_success_message(CATEGORY_DELETED);
}else{
draw_important_message($category->error);
}
}
// Start main content
$all_categories = array();
$all_categories = Category::getAll();
draw_title_bar("Categories Management");
?>
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="main_text">
<tr>
<th width="60%">Category Title</th>
<th width="20%">Order</th>
<th width="20%">Actions</th>
</tr>
<?php
if($all_categories[1] > 0){
for($i=0;$i<$all_categories[1];$i++){
echo '
<tr ' . highlight(0) . ' onmouseover="oldColor=this.style.backgroundColor;this.style.backgroundColor=\'#FFFFCC\';" onmouseout="this.style.backgroundColor=oldColor">
<td align="left" style="cursor:pointer;" onclick="document.location.href=\'?admin=categories_edit&mid='.$all_categories[0][$i]['id'].'\'" title="click to edit" width="60%">'.$all_categories[0][$i]['category_name'].'</td>
<td align="center" width="20%" style="cursor:pointer;" onclick="document.location.href=\'?admin=categories_edit&mid='.$all_categories[0][$i]['id'].'\'" title="click to edit">'.$all_categories[0][$i]['category_order'].'</td>
<td align="center" width="20%">
<a href="?admin=categories_edit&mid='.$all_categories[0][$i]['id'].'">Edit</a> |
<a href="?admin=categories&act=delete&mid='.$all_categories[0][$i]['id'].'" onclick="if(!confirm(\'Are you sure you want to delete this category?\nNote: this will make all its category links invisible to your site visitors!\'))return false;" >Delete</a>
</td>
</tr>';
}
}else {
echo '
<tr>
<td colspan="3" align="center">No Categories Found</td>
</tr>';
}
?>
</table>
<?php
} else draw_important_message(NOT_AUTHORIZED);
?>