\n".$locale['413']."";
} elseif ($_GET['status'] == "dely") {
$message = $locale['414'];
}
if ($message) { echo "
\n"; }
}
if ((isset($_GET['action']) && $_GET['action'] == "delete") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) {
$result = dbcount("(page_id)", DB_CUSTOM_PAGES, "page_cat='".$_GET['cat_id']."'");
if (!empty($result)) {
redirect(FUSION_SELF.$aidlink."&status=deln");
} else {
$result = dbquery("DELETE FROM ".DB_CUSTOM_CATS." WHERE custom_cat_id='".$_GET['cat_id']."'");
redirect(FUSION_SELF.$aidlink."&status=dely");
}
} else {
if (isset($_POST['save_cat'])) {
$cat_name = stripinput(trim($_POST['cat_name']));
$cat_description = stripinput(trim($_POST['cat_description']));
$cat_access = isnum($_POST['cat_access']) ? $_POST['cat_access'] : "0";
if (isnum($_POST['cat_sort_by']) && $_POST['cat_sort_by'] == "1") {
$cat_sorting = "page_id ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else if (isnum($_POST['cat_sort_by']) && $_POST['cat_sort_by'] == "2") {
$cat_sorting = "page_title ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else {
$cat_sorting = "page_title ASC";
}
if ($cat_name) {
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) {
$result = dbquery("UPDATE ".DB_CUSTOM_CATS." SET custom_cat_name='$cat_name', custom_cat_description='$cat_description', custom_cat_sorting='$cat_sorting', custom_cat_access='$cat_access' WHERE custom_cat_id='".$_GET['cat_id']."'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
$checkCat = dbcount("(custom_cat_id)", DB_CUSTOM_CATS, "custom_cat_name='".$cat_name."'");
if ($checkCat == 0) {
$result = dbquery("INSERT INTO ".DB_CUSTOM_CATS." (custom_cat_name, custom_cat_description, custom_cat_sorting, custom_cat_access) VALUES ('$cat_name', '$cat_description', '$cat_sorting', '$cat_access')");
redirect(FUSION_SELF.$aidlink."&status=sn");
} else {
$error = 2;
}
}
} else {
$error = 1;
}
}
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) {
$result = dbquery("SELECT custom_cat_name, custom_cat_description, custom_cat_sorting, custom_cat_access FROM ".DB_CUSTOM_CATS." WHERE custom_cat_id='".$_GET['cat_id']."'");
if (dbrows($result)) {
$data = dbarray($result);
$cat_name = $data['custom_cat_name'];
$cat_description = $data['custom_cat_description'];
$cat_sorting = explode(" ", $data['custom_cat_sorting']);
if ($cat_sorting[0] == "page_id") { $cat_sort_by = "1"; }
if ($cat_sorting[0] == "page_title") { $cat_sort_by = "2"; }
$cat_sort_order = $cat_sorting[1];
$cat_access = $data['custom_cat_access'];
$formaction = FUSION_SELF.$aidlink."&action=edit&cat_id=".$_GET['cat_id'];
$openTable = $locale['401'];
} else {
redirect(FUSION_SELF.$aidlink);
}
} else {
$cat_name = "";
$cat_description = "";
$cat_sort_by = "2";
$cat_sort_order = "ASC";
$cat_access = "";
$formaction = FUSION_SELF.$aidlink;
$openTable = $locale['400'];
}
$user_groups = getusergroups(); $access_opts = ""; $sel = "";
while(list($key, $user_group) = each($user_groups)){
$sel = ($cat_access == $user_group['0'] ? " selected='selected'" : "");
$access_opts .= "\n";
}
if (isset($error) && isnum($error)) {
if ($error == 1) {
$errorMessage = $locale['460'];
} elseif ($error == 2) {
$errorMessage = $locale['461'];
}
if ($errorMessage) { echo "\n"; }
}
opentable($openTable);
echo "\n";
closetable();
opentable($locale['402']);
echo "\n";
$result = dbquery("SELECT custom_cat_id, custom_cat_name, custom_cat_description, custom_cat_access FROM ".DB_CUSTOM_CATS." ORDER BY custom_cat_name");
if (dbrows($result) != 0) {
$i = 0;
echo "\n";
echo "".$locale['440']." | \n";
echo "".$locale['441']." | \n";
echo "".$locale['442']." | \n";
echo "
\n";
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
echo "\n";
echo "".$data['custom_cat_name']."\n";
if ($data['custom_cat_description']) { echo " ".trimlink($data['custom_cat_description'], 45)." | \n"; }
echo "".getgroupname($data['custom_cat_access'])." | \n";
echo "".$locale['443']." -\n";
echo "".$locale['444']." | \n";
echo "
\n";
$i++;
}
echo "
\n";
} else {
echo "".$locale['445']." |
\n\n";
}
closetable();
}
require_once THEMES."templates/footer.php";
?>