function parse_blocks($layout, $type = '') { global $db, $template, $userdata, $phpbb_root_path, $phpEx, $board_config, $lang, $portal_config, $theme, $bbcode_parse; include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; static $pos_array = array(); $layout_pos = array(); if (!isset($pos_array[$layout])) { $sql_pos = 'SELECT * FROM ' . BLOCKS_POSITION_TABLE . " WHERE layout ='" . $layout . "'"; if (!($block_pos_result = $db->sql_query($sql_pos))) { message_die(CRITICAL_ERROR, 'Could not query portal blocks position', '', __LINE__, __FILE__, $sql); } while ($block_pos_row = $db->sql_fetchrow($block_pos_result)) { $layout_pos[$block_pos_row['bposition']] = $block_pos_row['pkey']; } $db->sql_freeresult($block_pos_result); $pos_array[$layout] = $layout_pos; } else { $layout_pos = $pos_array[$layout]; } $block_info = array(); $temp_type = $type; if ($type == 'top') { $temp_pos = 't'; } else { if ($type == 'left') { $temp_pos = 'l'; } else { if ($type == 'bottom') { $temp_pos = 'b'; } else { if ($type == 'right') { $temp_pos = 'r'; } } } } $sql = "SELECT *\n FROM " . BLOCKS_TABLE . "\n WHERE layout ='" . $layout . "'\n AND active = '1'\n AND view IN " . portal_blocks_view() . "\n AND bposition = '" . $temp_pos . "'\n ORDER BY weight"; if (!($block_im_result = $db->sql_query($sql))) { message_die(CRITICAL_ERROR, "Could not query portal blocks information", "", __LINE__, __FILE__, $sql); } $block_info = $db->sql_fetchrowset($block_im_result); $db->sql_freeresult($block_im_result); $block_count = count($block_info); // If this block position (t,l,r,b) has block in it then switch them on. if ($block_count != 0) { $template->assign_var('S_' . strtoupper($type) . '_BLOCKS', TRUE); } for ($b_counter = 0; $b_counter < $block_count; $b_counter++) { $is_group_allowed = TRUE; if (!empty($block_info[$b_counter]['groups'])) { $is_group_allowed = FALSE; $group_content = explode(",", $block_info[$b_counter]['groups']); for ($i = 0; $i < count($group_content); $i++) { if (in_array(intval($group_content[$i]), block_groups($userdata['user_id']))) { $is_group_allowed = TRUE; } } } if (isset($is_group_allowed)) { $position = $type; $lang_exist = FALSE; $block_name = str_replace('blocks_imp_', '', $block_info[$b_counter]['blockfile']); if (file_exists('blocks/language/lang_' . $board_config['default_lang'] . '/lang_' . $block_name . '_block.' . $phpEx)) { $lang_exist = TRUE; include $phpbb_root_path . 'blocks/language/lang_' . $board_config['default_lang'] . '/lang_' . $block_name . '_block.' . $phpEx; } if (!empty($block_info[$b_counter]['blockfile'])) { $template->set_filenames(array($block_name . '_block' => $block_name . '_block.tpl')); $output_block = ''; include $phpbb_root_path . 'blocks/' . $block_info[$b_counter]['blockfile'] . '.' . $phpEx; $output_block = block_assign_var_from_handle($template, $block_name . '_block'); $template->assign_block_vars($position . '_blocks_row', array('OUTPUT' => $output_block)); if ($block_info[$b_counter]['titlebar'] == 1) { if ($lang_exist && $block_info[$b_counter]['local'] == 1) { $template->assign_block_vars($position . '_blocks_row.title', array('TITLE' => $lang['Title_' . $block_name])); } else { $template->assign_block_vars($position . '_blocks_row.title', array('TITLE' => $block_info[$b_counter]['title'])); } } if ($block_info[$b_counter]['border'] == 1) { $template->assign_block_vars($position . '_blocks_row.border', ''); } if ($block_info[$b_counter]['background'] == 1) { $template->assign_block_vars($position . '_blocks_row.background', ''); } } else { $text = $block_info[$b_counter]['content']; if ($block_info[$b_counter]['type']) { $text = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $text); if ($block_info[$b_counter]['block_bbcode_uid'] != '') { $text = $bbcode_parse->bbencode_second_pass($text, $block_info[$b_counter]['block_bbcode_uid']); } $text = $bbcode_parse->make_clickable($text); $text = $bbcode_parse->smilies_pass($text); $text = str_replace("\n", "\n<br />\n", $text); $text = $bbcode_parse->acronym_pass($text); $text = $bbcode_parse->smart_pass($text); $text = '<span class="postbody">' . $text . '</span>'; } $template->assign_block_vars($position . '_blocks_row', array('OUTPUT' => $text)); if ($block_info[$b_counter]['titlebar'] == 1) { if ($lang_exist && $block_info[$b_counter]['local'] == 1) { $template->assign_block_vars($position . '_blocks_row.title', array('TITLE' => $lang['Title_' . $block_name])); } else { $template->assign_block_vars($position . '_blocks_row.title', array('TITLE' => $block_info[$b_counter]['title'])); } } if ($block_info[$b_counter]['border'] == 1) { $template->assign_block_vars($position . '_blocks_row.border', ''); } if ($block_info[$b_counter]['background'] == 1) { $template->assign_block_vars($position . '_blocks_row.background', ''); } } } } }
parse_blocks($layout_id, 'top'); $template->assign_var('TOP_BLOCKS', block_assign_var_from_handle($template, 'top_blocks')); // Left Blocks $template->set_filenames(array('left_blocks' => 'blocks_left.tpl')); parse_blocks($layout_id, 'left'); $template->assign_var('LEFT_WIDTH', $portal_config['left_width']); $template->assign_var('LEFT_BLOCKS', block_assign_var_from_handle($template, 'left_blocks')); // Right Blocks $template->set_filenames(array('right_blocks' => 'blocks_right.tpl')); parse_blocks($layout_id, 'right'); $template->assign_var('RIGHT_WIDTH', $portal_config['right_width']); $template->assign_var('RIGHT_BLOCKS', block_assign_var_from_handle($template, 'right_blocks')); // Bottom Blocks $template->set_filenames(array('bottom_blocks' => 'blocks_bottom.tpl')); parse_blocks($layout_id, 'bottom'); $template->assign_var('BOTTOM_BLOCKS', block_assign_var_from_handle($template, 'bottom_blocks')); } // // END - Blocks // $template->pparse('overall_header'); // Disable Board Admin Override - BEGIN // Won't Work for Jnr. Admin... if ($board_config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN')) { $show_disabled_message = FALSE; if ($userdata['user_level'] != ADMIN) { $show_disabled_message = TRUE; } elseif ($userdata['user_level'] == ADMIN && intval($board_config['board_disable_adminview']) != 1) { $show_disabled_message = TRUE; } if ($show_disabled_message) {