|
From: Jon O. <jon...@us...> - 2006-08-22 20:22:00
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26767/includes Modified Files: mx_functions_admincp.php mx_functions_blockcp.php mx_functions_style.php Log Message: handy switch in common.php when upgrading sites several major fixes for the blockCP - adding blocks for functions with no blocks etc navigation menu adminCP rewritten. query data. no cache. subsilver narrow layout a couple of fixes when basedir restriction is activated Index: mx_functions_blockcp.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_blockcp.php,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mx_functions_blockcp.php 17 Jun 2006 20:09:07 -0000 1.13 --- mx_functions_blockcp.php 22 Aug 2006 20:21:50 -0000 1.14 *************** *** 60,70 **** * @return unknown */ ! function _controlpanel( $id, $new_block ) { global $blockcptemplate, $lang, $db, $board_config, $theme, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $phpEx, $mx_root_path, $s_hidden_fields, $userdata, $cookie_states, $module_nav_icon_url, $portalpage, $mx_request_vars, $images; $dynamic_block_id = $mx_request_vars->request('dynamic_block', MX_TYPE_INT, ''); ! if (empty($id)) { die('Invalid block panel call - no id'); --- 60,72 ---- * @return unknown */ ! function _controlpanel( $id, $new_block = false ) { global $blockcptemplate, $lang, $db, $board_config, $theme, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $phpEx, $mx_root_path, $s_hidden_fields, $userdata, $cookie_states, $module_nav_icon_url, $portalpage, $mx_request_vars, $images; + $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; + $dynamic_block_id = $mx_request_vars->request('dynamic_block', MX_TYPE_INT, ''); ! if ( empty($id) && !$new_block) { die('Invalid block panel call - no id'); *************** *** 225,231 **** 'L_NO' => $lang['No'], ! 'L_SETTING' => $new_block ? '' : $l_setting, ! 'L_DELETE' => $new_block ? '' : $lang['Delete'], ! 'L_EDIT' => $new_block ? '' : $lang['Edit'], 'L_AUTH_TITLE' => $lang['Auth_Block'], --- 227,233 ---- 'L_NO' => $lang['No'], ! 'L_SETTING' => $l_setting, ! 'L_DELETE' => $lang['Delete'], ! 'L_EDIT' => $lang['Edit'], 'L_AUTH_TITLE' => $lang['Auth_Block'], *************** *** 243,247 **** 'BLOCK_ID' => $block_id, ! 'BLOCK_TITLE' => $new_block ? '<span class="cattitle">'. $lang['Create_block'] . '</span>' : ' ' . $block_title, 'BLOCK_DESC' => ( $block_desc != '' ) ? ' - ' . $block_desc : '', --- 245,249 ---- 'BLOCK_ID' => $block_id, ! 'BLOCK_TITLE' => ' ' . $block_title, 'BLOCK_DESC' => ( $block_desc != '' ) ? ' - ' . $block_desc : '', *************** *** 359,404 **** // Activate BlockCP SubPanels, based on auth // ! $blockcptemplate->assign_block_vars('blockcp_general', array( ! 'L_TITLE' => $lang['Edit'], ! 'S_HIDDEN_FIELDS' => $s_hidden_general_fields, ! 'S_SUBMIT' => $buttonvalue ! )); ! ! if ($this->auth_mod) ! { ! $blockcptemplate->assign_block_vars('blockcp_general_add', array( ! 'L_TITLE' => $lang['Create_block'], ! 'S_HIDDEN_FIELDS' => $s_hidden_general_add_fields, ! 'S_SUBMIT' => $buttonvalue_add ! )); ! } ! ! if (!empty($this->block_parameters)) { ! $blockcptemplate->assign_block_vars('blockcp_settings', array( ! 'L_TITLE' => $lang['Settings'], ! 'S_HIDDEN_FIELDS' => $s_hidden_settings_fields, 'S_SUBMIT' => $buttonvalue )); } ! if ($this->auth_mod) { ! $blockcptemplate->assign_block_vars('blockcp_permissions', array( ! 'L_TITLE' => $lang['Permissions_adv'], ! 'S_HIDDEN_FIELDS' => $s_hidden_permissions_fields, ! 'S_SUBMIT' => $buttonvalue )); // - // Some general blockcp settings are moderator only - // - $blockcptemplate->assign_block_vars('blockcp_general.is_auth', array()); - - // - // Now query all permissions data (not needed if not authorized ;) - // - - // // Output values of individual auth fields - add // --- 361,382 ---- // Activate BlockCP SubPanels, based on auth // ! if (!$new_block) { ! $blockcptemplate->assign_block_vars('blockcp_general', array( ! 'L_TITLE' => $lang['Edit'], ! 'S_HIDDEN_FIELDS' => $s_hidden_general_fields, 'S_SUBMIT' => $buttonvalue )); } ! if ( ($this->auth_mod || $is_admin ) || $new_block) { ! $blockcptemplate->assign_block_vars('blockcp_general_adds', array( ! 'L_TITLE' => $lang['Create_block'], ! 'S_HIDDEN_FIELDS' => $s_hidden_general_add_fields, ! 'S_SUBMIT' => $buttonvalue_add )); // // Output values of individual auth fields - add // *************** *** 417,428 **** $cell_title = $field_names[$block_auth_fields[$j]]; ! $blockcptemplate->assign_block_vars('blockcp_general_add.block_auth_titles', array( 'CELL_TITLE' => $cell_title )); ! $blockcptemplate->assign_block_vars('blockcp_general_add.block_auth_data', array( 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j] )); } // --- 395,433 ---- $cell_title = $field_names[$block_auth_fields[$j]]; ! $blockcptemplate->assign_block_vars('blockcp_general_adds.block_auth_titles', array( 'CELL_TITLE' => $cell_title )); ! $blockcptemplate->assign_block_vars('blockcp_general_adds.block_auth_data', array( 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j] )); } + } + + if (!empty($this->block_parameters) && !$new_block) + { + $blockcptemplate->assign_block_vars('blockcp_settings', array( + 'L_TITLE' => $lang['Settings'], + 'S_HIDDEN_FIELDS' => $s_hidden_settings_fields, + 'S_SUBMIT' => $buttonvalue + )); + } + + if ( ($this->auth_mod || $is_admin) && !$new_block) + { + $blockcptemplate->assign_block_vars('blockcp_permissions', array( + 'L_TITLE' => $lang['Permissions_adv'], + 'S_HIDDEN_FIELDS' => $s_hidden_permissions_fields, + 'S_SUBMIT' => $buttonvalue + )); + + // + // Some general blockcp settings are moderator only + // + $blockcptemplate->assign_block_vars('blockcp_general.is_auth', array()); + + // + // Now query all permissions data (not needed if not authorized ;) + // // *************** *** 525,529 **** } ! if ($this->auth_mod) { $blockcptemplate->assign_block_vars('blockcp_delete', array( --- 530,534 ---- } ! if ( ($this->auth_mod || $is_admin) && !$new_block) { $blockcptemplate->assign_block_vars('blockcp_delete', array( *************** *** 559,579 **** * @access public * @param unknown_type $id - * @param unknown_type $new_block */ ! function generate_cp( $id = '', $new_block = false ) { ! $action = $new_block ? MX_ADD : MX_EDIT; ! switch ( $action ) ! { ! case MX_ADD: ! $function_id = $id; ! $this->_controlpanel($function_id, $new_block ); ! break; ! case MX_EDIT: ! $block_id = $id; ! $this->_controlpanel($block_id, $new_block ); ! break; ! } } --- 564,574 ---- * @access public * @param unknown_type $id */ ! function generate_cp( $id = '' ) { ! $newBlock = $id == 'noBlock' ? true : false; ! $block_id = $id == 'noBlock' ? '' : $id; ! $this->_controlpanel($block_id, $newBlock ); } Index: mx_functions_style.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_style.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mx_functions_style.php 27 Jun 2006 18:12:22 -0000 1.7 --- mx_functions_style.php 22 Aug 2006 20:21:50 -0000 1.8 *************** *** 122,128 **** } */ ! else if( file_exists($mx_root_path . $this->root . '/' . $filename) ) { ! $filename = $mx_root_path . $this->root . '/' . $filename; } else --- 122,128 ---- } */ ! else if( file_exists( $this->root . '/' . $filename) ) { ! $filename = $this->root . '/' . $filename; } else Index: mx_functions_admincp.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_admincp.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** mx_functions_admincp.php 15 Aug 2006 08:37:01 -0000 1.31 --- mx_functions_admincp.php 22 Aug 2006 20:21:49 -0000 1.32 *************** *** 3379,3438 **** * @access private */ ! function _get_data() { global $db, $template, $lang, $board_config, $userdata; ! $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; ! ! if (!$is_admin) { // ! // Authorization SQL // ! $auth_blocks = get_auth_blocks(); ! $auth_sql = " AND blk.block_id in ( ". $auth_blocks. " ) "; ! } ! ! // ! // ! // Generate dynamic block select ! $sql = "SELECT blk.*, function_admin, fnc.function_name, fnc.function_id, fnc.function_desc, fnc.module_id, mdl.module_name, mdl.module_id, mdl.module_desc ! FROM " . BLOCK_TABLE . " blk, ! " . FUNCTION_TABLE . " fnc, ! " . MODULE_TABLE . " mdl ! WHERE blk.function_id = fnc.function_id ! AND mdl.module_id = fnc.module_id ! " . $auth_sql . " ! ORDER BY mdl.module_name ASC, fnc.function_name ASC"; ! if( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't get list of Column/blocks", '', __LINE__, __FILE__, $sql); ! } ! if( $total_blocks = $db->sql_numrows($result) ) ! { ! $row = $db->sql_fetchrowset($result); ! } ! $db->sql_freeresult($result); ! $module_id = $function_id = $block_id = 0; ! for( $j = 0; $j < $total_blocks; $j++ ) ! { ! if( $row[$j]['module_id'] != $row[$j-1]['module_id'] ) { ! $module_desc_tmp = str_replace("\n", '', $row[$j]['module_desc']); ! $module_desc_tmp = str_replace("\r", '', $module_desc_tmp); ! $module_id = $row[$j]['module_id']; ! $module_title = !empty($row[$j]['module_name']) ? addslashes(strip_tags(trim($row[$j]['module_name']))) : ''; ! $module_desc = !empty($row[$j]['module_desc']) ? addslashes(strip_tags(trim($module_desc_tmp))) : ''; ! $this->_addModule($module_id, $module_title, $module_desc); } ! if( $row[$j]['function_id'] != $row[$j-1]['function_id'] ) { $function_desc_tmp = str_replace("\n", '', $row[$j]['function_desc']); $function_desc_tmp = str_replace("\r", '', $function_desc_tmp); --- 3379,3465 ---- * @access private */ ! function _get_data($all_functions = false) { global $db, $template, $lang, $board_config, $userdata; ! if ($all_functions) { + $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; + if (!$is_admin) + { + // + // Authorization SQL + // + $auth_blocks = get_auth_blocks(); + $auth_sql = " AND blk.block_id in ( ". $auth_blocks. " ) "; + } + // ! // First, get a module, function, block mapping // ! $sql = "SELECT * ! FROM " . BLOCK_TABLE . " blk, ! " . FUNCTION_TABLE . " fnc ! WHERE blk.function_id = fnc.function_id ! " . $auth_sql . " ! ORDER BY fnc.function_id ASC, blk.block_title ASC"; ! if( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't get list of Functions/Block", '', __LINE__, __FILE__, $sql); ! } ! if( $total_blocks = $db->sql_numrows($result) ) ! { ! $row = $db->sql_fetchrowset($result); ! } ! $db->sql_freeresult($result); ! $function_id = $block_id = 0; ! $functionBlocks = array(); ! for( $j = 0; $j < $total_blocks; $j++ ) { ! $functionBlocks[$row[$j]['function_id']][] = $row[$j]; ! } ! unset($row); ! // ! // Generate dynamic block select ! // ! $sql = "SELECT * ! FROM " . FUNCTION_TABLE . " fnc, ! " . MODULE_TABLE . " mdl ! WHERE mdl.module_id = fnc.module_id ! ORDER BY mdl.module_name ASC, fnc.function_name ASC"; ! ! if( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't get list of Modules/Functions", '', __LINE__, __FILE__, $sql); } ! if( $total_functions = $db->sql_numrows($result) ) ! { ! $row = $db->sql_fetchrowset($result); ! } ! ! $db->sql_freeresult($result); ! $module_id = $function_id = 0; ! ! for( $j = 0; $j < $total_functions; $j++ ) { + if( $row[$j]['module_id'] != $row[$j-1]['module_id'] ) + { + $module_desc_tmp = str_replace("\n", '', $row[$j]['module_desc']); + $module_desc_tmp = str_replace("\r", '', $module_desc_tmp); + + $module_id = $row[$j]['module_id']; + $module_title = !empty($row[$j]['module_name']) ? addslashes(strip_tags(trim($row[$j]['module_name']))) : ''; + $module_desc = !empty($row[$j]['module_desc']) ? addslashes(strip_tags(trim($module_desc_tmp))) : ''; + + $this->_addModule($module_id, $module_title, $module_desc); + } + $function_desc_tmp = str_replace("\n", '', $row[$j]['function_desc']); $function_desc_tmp = str_replace("\r", '', $function_desc_tmp); *************** *** 3443,3458 **** $this->_addFunction($module_id, $function_id, $function_title, $function_desc); } ! $block_desc_tmp = str_replace("\n", '', $row[$j]['block_desc']); ! $block_desc_tmp = str_replace("\r", '', $block_desc_tmp); ! $block_id = $row[$j]['block_id']; ! $block_title = !empty($row[$j]['block_title']) ? addslashes(strip_tags(trim($row[$j]['block_title']))) : ''; ! $block_desc = !empty($block_desc_tmp) ? ' (' . addslashes(strip_tags(trim($block_desc_tmp))) . ')' : ''; ! $this->_addBlock($module_id, $function_id, $block_id, $block_title, $block_desc); } - unset($row); } --- 3470,3569 ---- $this->_addFunction($module_id, $function_id, $function_title, $function_desc); + + // + // Get all function blocks (if any) + // + if (isset($functionBlocks[$function_id])) + { + foreach($functionBlocks[$function_id] as $key => $block_row) + { + $block_desc_tmp = str_replace("\n", '', $block_row['block_desc']); + $block_desc_tmp = str_replace("\r", '', $block_desc_tmp); + + $block_id = $block_row['block_id']; + $block_title = !empty($block_row['block_title']) ? addslashes(strip_tags(trim($block_row['block_title']))) : ''; + $block_desc = !empty($block_desc_tmp) ? ' (' . addslashes(strip_tags(trim($block_desc_tmp))) . ')' : ''; + + $this->_addBlock($module_id, $function_id, $block_id, $block_title, $block_desc); + } + } } + unset($row); ! } ! else ! { ! $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; ! if (!$is_admin) ! { ! // ! // Authorization SQL ! // ! $auth_blocks = get_auth_blocks(); ! $auth_sql = " AND blk.block_id in ( ". $auth_blocks. " ) "; ! } ! // ! // Generate dynamic block select ! // ! $sql = "SELECT blk.*, function_admin, fnc.function_name, fnc.function_id, fnc.function_desc, fnc.module_id, mdl.module_name, mdl.module_id, mdl.module_desc ! FROM " . BLOCK_TABLE . " blk, ! " . FUNCTION_TABLE . " fnc, ! " . MODULE_TABLE . " mdl ! WHERE blk.function_id = fnc.function_id ! AND mdl.module_id = fnc.module_id ! " . $auth_sql . " ! ORDER BY mdl.module_name ASC, fnc.function_name ASC"; ! if( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't get list of Modules/Functions", '', __LINE__, __FILE__, $sql); ! } ! ! if( $total_blocks = $db->sql_numrows($result) ) ! { ! $row = $db->sql_fetchrowset($result); ! } ! ! $db->sql_freeresult($result); ! $module_id = $function_id = $block_id = 0; ! ! for( $j = 0; $j < $total_blocks; $j++ ) ! { ! if( $row[$j]['module_id'] != $row[$j-1]['module_id'] ) ! { ! $module_desc_tmp = str_replace("\n", '', $row[$j]['module_desc']); ! $module_desc_tmp = str_replace("\r", '', $module_desc_tmp); ! ! $module_id = $row[$j]['module_id']; ! $module_title = !empty($row[$j]['module_name']) ? addslashes(strip_tags(trim($row[$j]['module_name']))) : ''; ! $module_desc = !empty($row[$j]['module_desc']) ? addslashes(strip_tags(trim($module_desc_tmp))) : ''; ! ! $this->_addModule($module_id, $module_title, $module_desc); ! } ! ! if( $row[$j]['function_id'] != $row[$j-1]['function_id'] ) ! { ! $function_desc_tmp = str_replace("\n", '', $row[$j]['function_desc']); ! $function_desc_tmp = str_replace("\r", '', $function_desc_tmp); ! ! $function_id = $row[$j]['function_id']; ! $function_title = !empty($row[$j]['function_name']) ? addslashes(strip_tags(trim($row[$j]['function_name']))) : ''; ! $function_desc = !empty($function_desc_tmp) ? addslashes(strip_tags(trim($function_desc_tmp))) : ''; ! ! $this->_addFunction($module_id, $function_id, $function_title, $function_desc); ! } ! ! $block_desc_tmp = str_replace("\n", '', $row[$j]['block_desc']); ! $block_desc_tmp = str_replace("\r", '', $block_desc_tmp); ! ! $block_id = $row[$j]['block_id']; ! $block_title = !empty($row[$j]['block_title']) ? addslashes(strip_tags(trim($row[$j]['block_title']))) : ''; ! $block_desc = !empty($block_desc_tmp) ? ' (' . addslashes(strip_tags(trim($block_desc_tmp))) . ')' : ''; ! ! $this->_addBlock($module_id, $function_id, $block_id, $block_title, $block_desc); ! } ! unset($row); } } *************** *** 3631,3637 **** * @param unknown_type $block_id */ ! function generate($block_id = '') { ! $this->_get_data(); $this->_generate_tpl($block_id); } --- 3742,3748 ---- * @param unknown_type $block_id */ ! function generate($block_id = '', $all_functions = false) { ! $this->_get_data($all_functions); $this->_generate_tpl($block_id); } |