".$locale['401']."
\n".$locale['402'];
} elseif ($status == "dely") {
$title = $locale['400'];
$message = "".$locale['405']."";
}
opentable($title);
echo "
".$message."
\n";
closetable();
tablebreak();
}
if ($step == "delete") {
$result = dbquery("SELECT * FROM ".$db_prefix."weblinks WHERE weblink_cat='$cat_id'");
if (dbrows($result) != 0) {
redirect(FUSION_SELF.$aidlink."&status=deln");
} else {
$result = dbquery("DELETE FROM ".$db_prefix."weblink_cats WHERE weblink_cat_id='$cat_id'");
redirect(FUSION_SELF.$aidlink."&status=dely");
}
} else {
if (isset($_POST['save_cat'])) {
$cat_name = stripinput($_POST['cat_name']);
$cat_description = stripinput($_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 = "weblink_id ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else if (isNum($_POST['cat_sort_by']) && $_POST['cat_sort_by'] == "2") {
$cat_sorting = "weblink_name ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else if (isNum($_POST['cat_sort_by']) && $_POST['cat_sort_by'] == "3") {
$cat_sorting = "weblink_datestamp ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else {
$cat_sorting = "weblink_name ASC";
}
if ($step == "edit") {
$result = dbquery("UPDATE ".$db_prefix."weblink_cats SET weblink_cat_name='$cat_name', weblink_cat_description='$cat_description', weblink_cat_sorting='$cat_sorting', weblink_cat_access='$cat_access' WHERE weblink_cat_id='$cat_id'");
} else {
$result = dbquery("INSERT INTO ".$db_prefix."weblink_cats (weblink_cat_name, weblink_cat_description, weblink_cat_sorting, weblink_cat_access) VALUES ('$cat_name', '$cat_description', '$cat_sorting', '$cat_access')");
}
redirect(FUSION_SELF.$aidlink);
}
if ($step == "edit") {
$result = dbquery("SELECT * FROM ".$db_prefix."weblink_cats WHERE weblink_cat_id='$cat_id'");
$data = dbarray($result);
$cat_name = $data['weblink_cat_name'];
$cat_description = $data['weblink_cat_description'];
$cat_sorting = explode(" ", $data['weblink_cat_sorting']);
if ($cat_sorting[0] == "weblink_id") { $cat_sort_by = "1"; }
if ($cat_sorting[0] == "weblink_name") { $cat_sort_by = "2"; }
if ($cat_sorting[0] == "weblink_datestamp") { $cat_sort_by = "3"; }
$cat_sort_order = $cat_sorting[1];
$cat_access = $data['weblink_cat_access'];
$formaction = FUSION_SELF.$aidlink."&step=edit&cat_id=".$data['weblink_cat_id'];
opentable($locale['420']);
} else {
$cat_name = "";
$cat_description = "";
$cat_sort_by = "weblink_name";
$cat_sort_order = "ASC";
$cat_access = "";
$formaction = FUSION_SELF.$aidlink;
opentable($locale['421']);
}
$user_groups = getusergroups(); $access_opts = ""; $sel = "";
while(list($key, $user_group) = each($user_groups)){
$sel = ($cat_access == $user_group['0'] ? " selected" : "");
$access_opts .= "\n";
}
echo "\n";
closetable();
tablebreak();
opentable($locale['440']);
echo "\n";
$result = dbquery("SELECT * FROM ".$db_prefix."weblink_cats ORDER BY weblink_cat_name");
if (dbrows($result) != 0) {
$i = 0;
echo "
".$locale['441']." |
".$locale['445']." |
".$locale['502']." |
\n";
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
echo "
".$data['weblink_cat_name'].""
.($data['weblink_cat_description'] ? " \n".trimlink($data['weblink_cat_description'], 45)."" : "")." |
".getgroupname($data['weblink_cat_access'])." |
".$locale['503']." -
".$locale['504']." |
\n";
$i++;
}
echo "
\n";
} else {
echo "".$locale['508']." |
\n\n";
}
closetable();
}
echo "\n";
require_once BASEDIR."footer.php";
?>