array(0, 0, 0, 0, 1, 1, 1, 3, 1, 1), 1 => array(0, 0, 1, 1, 1, 1, 1, 3, 1, 1), 2 => array(1, 1, 1, 1, 1, 1, 1, 3, 1, 1), 3 => array(0, 2, 2, 2, 2, 2, 2, 3, 2, 2), 4 => array(2, 2, 2, 2, 2, 2, 2, 3, 2, 2), 5 => array(0, 3, 3, 3, 3, 3, 3, 3, 3, 3), 6 => array(3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ); $simple_auth_types = array($lang['Public'], $lang['Registered'], $lang['Registered'] . " [" . $lang['Hidden'] . "]", $lang['Private'], $lang['Private'] . " [" . $lang['Hidden'] . "]", $lang['Moderators'], $lang['Moderators'] . " [" . $lang['Hidden'] . "]"); $forum_auth_fields = array("auth_view", "auth_read", "auth_post", "auth_reply", "auth_edit", "auth_delete", "auth_sticky", "auth_announce", "auth_vote", "auth_pollcreate"); $field_names = array( "auth_view" => $lang['View'], "auth_read" => $lang['Read'], "auth_post" => $lang['Post'], "auth_reply" => $lang['Reply'], "auth_edit" => $lang['Edit'], "auth_delete" => $lang['Delete'], "auth_sticky" => $lang['Sticky'], "auth_announce" => $lang['Announce'], "auth_vote" => $lang['Vote'], "auth_pollcreate" => $lang['Pollcreate']); $forum_auth_levels = array("ALL", "REG", "PRIVATE", "MOD", "ADMIN"); $forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN); if(isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL])) { $forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]); $forum_sql = "AND forum_id = $forum_id"; } else { unset($forum_id); $forum_sql = ""; } if( isset($HTTP_GET_VARS['adv']) ) { $adv = intval($HTTP_GET_VARS['adv']); } else { unset($adv); } // // Start program proper // if( isset($HTTP_POST_VARS['submit']) ) { $sql = ""; if(!empty($forum_id)) { $sql = "UPDATE " . FORUMS_TABLE . " SET "; if(isset($HTTP_POST_VARS['simpleauth'])) { $simple_ary = $simple_auth_ary[$HTTP_POST_VARS['simpleauth']]; for($i = 0; $i < count($simple_ary); $i++) { $sql .= $forum_auth_fields[$i] . " = " . $simple_ary[$i]; if($i < count($simple_ary) - 1) { $sql .= ", "; } } $sql .= " WHERE forum_id = $forum_id"; } else { for($i = 0; $i < count($forum_auth_fields); $i++) { $value = $HTTP_POST_VARS[$forum_auth_fields[$i]]; if($forum_auth_fields[$i] == 'auth_vote') { if( $HTTP_POST_VARS['auth_vote'] == AUTH_ALL ) { $value = AUTH_REG; } } $sql .= $forum_auth_fields[$i] . " = " . $value; if($i < count($forum_auth_fields) - 1) { $sql .= ", "; } } $sql .= " WHERE forum_id = $forum_id"; } if($sql != "") { if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't update auth table!", "", __LINE__, __FILE__, $sql); } } $forum_sql = ""; $adv = 0; } $template->assign_vars(array( "META" => '') ); $message = $lang['Forum_auth_updated'] . "

" . $lang['Click'] . " " . $lang['Here'] . " " . $lang['return_forum_auth_admin']; message_die(GENERAL_MESSAGE, $message); } // End of submit // // Get required information, either all forums if // no id was specified or just the requsted if it // was // $sql = "SELECT f.* FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c WHERE c.cat_id = f.cat_id $forum_sql ORDER BY c.cat_order ASC, f.forum_order ASC"; $f_result = $db->sql_query($sql); $forum_rows = $db->sql_fetchrowset($f_result); if( empty($forum_id) ) { // // Output the selection table if no forum id was // specified // $template->set_filenames(array( "body" => "admin/auth_select_body.tpl") ); $select_list = ""; $template->assign_vars(array( "L_AUTH_TITLE" => $lang['Auth_Control_Forum'], "L_AUTH_EXPLAIN" => $lang['Forum_auth_explain'], "L_AUTH_SELECT" => $lang['Select_a_Forum'], "L_LOOK_UP" => $lang['Look_up_Forum'], "S_AUTH_ACTION" => append_sid("admin_forumauth.$phpEx"), "S_AUTH_SELECT" => $select_list) ); } else { // // Output the authorisation details if an id was // specified // $template->set_filenames(array( "body" => "admin/auth_forum_body.tpl") ); $forum_name = $forum_rows[0]['forum_name']; reset($simple_auth_ary); while(list($key, $auth_levels) = each($simple_auth_ary)) { $matched = 1; for($k = 0; $k < count($auth_levels); $k++) { $matched_type = $key; if($forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k]) { $matched = 0; } } if($matched) break; } // // If we didn't get a match above then we // automatically switch into 'advanced' mode // if(!isset($adv) && !$matched) { $adv = 1; } $s_column_span == 0; if( empty($adv) ) { $simple_auth = ""; $template->assign_block_vars("forum_auth_titles", array( "CELL_TITLE" => $lang['Simple_mode']) ); $template->assign_block_vars("forum_auth_data", array( "S_AUTH_LEVELS_SELECT" => $simple_auth) ); $s_column_span++; } else { // // Output values of individual // fields // for($j = 0; $j < count($forum_auth_fields); $j++) { $custom_auth[$j] = "  "; $cell_title = $field_names[$forum_auth_fields[$j]]; $template->assign_block_vars("forum_auth_titles", array( "CELL_TITLE" => $cell_title) ); $template->assign_block_vars("forum_auth_data", array( "S_AUTH_LEVELS_SELECT" => $custom_auth[$j]) ); $s_column_span++; } } $adv_mode = (empty($adv)) ? "1" : "0"; $switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&adv=". $adv_mode); $switch_mode_text = ( empty($adv) ) ? $lang['Advanced_mode'] : $lang['Simple_mode']; $u_switch_mode = '' . $switch_mode_text . ''; $s_hidden_fields = ''; $template->assign_vars(array( "FORUM_NAME" => $forum_name, "L_AUTH_TITLE" => $lang['Auth_Control_Forum'], "L_AUTH_EXPLAIN" => $lang['Forum_auth_explain'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "U_SWITCH_MODE" => $u_switch_mode, "S_FORUMAUTH_ACTION" => append_sid("admin_forumauth.$phpEx"), "S_COLUMN_SPAN" => $s_column_span, "S_HIDDEN_FIELDS" => $s_hidden_fields) ); } include('page_header_admin.'.$phpEx); $template->pparse("body"); include('page_footer_admin.'.$phpEx); ?>