Code: Select all
if( $mode != "" )
{
if( $mode == "edit" || $mode == "add" )
{
$cat_id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : 0;
$template->set_filenames(array(
"body" => "admin/FTP_categories_edit.tpl")
);
$s_hidden_fields = '';
if( $mode == "edit" )
{
if( $cat_id )
{
$sql = "SELECT *
FROM " . FTP_CATEGORIES_TABLE . "
WHERE cat_id = $cat_id";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not query database.", "Error", __LINE__, __FILE__, $sql);
}
$cat_info = $db->sql_fetchrow($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $cat_id . '" />';
}
else
{
message_die(GENERAL_MESSAGE, "You must choose category");
}
}
$sel_id = $cat_info['forum_id'];
//Drop Down Box
function get_forums($sel_id)
{
global $db, $HTTP_GET_VARS, $sel_id;
$sql = "SELECT forum_id, forum_name
FROM " . FORUMS_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't get list of forums from Forums Table", "", __LINE__, __FILE__, $sql);
}
$forumlist = '<select name="forum_id">';
while( $row = $db->sql_fetchrow($result) )
{
if ( $forum_id == $row['forum_id'] )
{
$status = "selected";
}
else
{
$status = '';
}
$forumlist .= '<option value="' .$row['forum_id'] . '" ' . $status . '>' . $row['forum_name'] . '</option>';
}
$forumlist .= '</select>';
return $forumlist;
}
// End Drop Down Box
$sel_id = $cat_info['group_id'];
//Group Drop Down
function get_groups($sel_id)
{
global $db, $sel_id;
$sql = "SELECT group_name, group_id
FROM " . GROUPS_TABLE . "
WHERE group_id = group_id
AND group_single_user = 0";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't get list of groups", "", __LINE__, __FILE__, $sql);
}
$grouplist = '<select name="group_id"><option>No Group Selected</option>';
while( $row = $db->sql_fetchrow($result) )
{
if ( $sel_id == $row['group_id'] )
{
$status = "selected";
}
else
{
$status = '';
}
$grouplist .= '<option value="' .$row['group_id'] . '" ' . $status . '>' . $row['group_name'] . '</option>';
}
$grouplist .= '</select>';
return $grouplist;
}
//END Group Drop Down
$user_text_yes = ( $cat_info['user_text'] ) ? "checked=\"checked\"" : "";
$user_text_no = ( !$cat_info['user_text'] ) ? "checked=\"checked\"" : "";
$auth_reply_yes = ( $cat_info['auth_reply'] ) ? "checked=\"checked\"" : "";
$auth_reply_no = ( !$cat_info['auth_reply'] ) ? "checked=\"checked\"" : "";
$auth_none = ( $cat_info['auth'] == 0 ) ? "checked=\"checked\"" : "";
$auth_registered = ( $cat_info['auth'] == 1 ) ? "checked=\"checked\"" : "";
$auth_group = ( $cat_info['auth'] == 2 ) ? "checked=\"checked\"" : "";
$forums = get_forums($new['forum_id']);
$groups = get_groups($new['group_id']);
$template->assign_vars(array(
"FORUM_ID" => $cat_info['forum_id'],
"CAT_TITLE" => $cat_info['cat_title'],
"SUBJECT_NAME" => $cat_info['subject_name'],
"SUBJECT_DESC" => $cat_info['subject_desc'],
"NOTICE" => $cat_info['notice'],
"FORUMS" => $forums,
"GROUPS" => $groups,
"USER_ID" => $cat_info['user_id'],
"POST_NOTICE" => $cat_info['post_notice'],
"L_ADD_CAT" => $lang['add_cat'],
"L_CAT_NAME" => $lang['cat_name'],
"L_ADD_SUBJECT" => $lang['add_subject'],
"L_ADD_SUBJECT_DESC" => $lang['add_subject_desc'],
"L_ADD_NOTICE_DESC" => $lang['add_notice_desc'],
"L_NOTICE" => $lang['notice_title'],
"L_WHICH_FORUM" => $lang['which_forum'],
"L_WHICH_FORUM_DESC" => $lang['which_forum_desc'],
"L_USER" => $lang['user'],
"L_USER_NAME_USE" => $lang['add_user_desc'],
"L_SPECIFIC_USER" => $lang['specific_user'],
"L_SPECIFIC_USER_DESC" => $lang['specific_user_desc'],
"L_SAVE" => $lang['save'],
"L_POST_NOTICE" => $lang['post_notice'],
"L_POST_NOTICE_EXAMPLE" => $lang['post_notice_example'],
"L_AUTH" => $lang['ftp_auth'],
"L_AUTH_EXPLAIN" => $lang['ftp_auth_explain'],
"L_GROUP" => $lang['group'],
"L_GROUP_DESCRIPTION2" => $lang['group_description2'],
"L_AUTH_REPLY" => $lang['auth_reply'],
"L_AUTH_REPLY_EXPLAIN" => $lang['auth_reply_explain'],
"L_GROUP" => $lang['group'],
"L_REGISTERED" => $lang['registered'],
"L_GUEST" => $lang['guest'],
"L_YES" => $lang['Yes'],
"L_NO" => $lang['No'],
"S_USER_TEXT_YES" => $user_text_yes,
"S_USER_TEXT_NO" => $user_text_no,
"S_AUTH_REPLY_YES" => $auth_reply_yes,
"S_AUTH_REPLY_NO" => $auth_reply_no,
"S_AUTH_NONE" => $auth_none,
"S_AUTH_REGISTERED" => $auth_registered,
"S_AUTH_GROUP" => $auth_group,
"S_WORDS_ACTION" => append_sid("admin_FTP_categories.$phpEx"),
"S_HIDDEN_FIELDS" => $s_hidden_fields)
);
$template->pparse("body");
include('./page_footer_admin.'.$phpEx);
}
else if( $mode == "save" )