From: Meik S. <acy...@ph...> - 2009-08-12 15:01:07
|
Author: acydburn Date: Wed Aug 12 16:00:47 2009 New Revision: 9965 Log: ok, i am very sorry, but this needs to be fixed. Generally, our config table is not really suited for holding large datasets. Because feed settings for the forums to enable news feeds and excluded forums rely on the forums itself we have decided to introduce a forum_options table where custom options can be stored. Additionally, for this to work across all DBMS we support, we added a new method to the DBAL for the bitwise AND operator. Also moved the forum/topic feed template variable to the location where they belong to (forum and topic view) Modified: branches/phpBB-3_0_0/phpBB/adm/index.php branches/phpBB-3_0_0/phpBB/develop/create_schema_files.php branches/phpBB-3_0_0/phpBB/develop/mysql_upgrader.php branches/phpBB-3_0_0/phpBB/feed.php branches/phpBB-3_0_0/phpBB/includes/acp/acp_board.php branches/phpBB-3_0_0/phpBB/includes/constants.php branches/phpBB-3_0_0/phpBB/includes/db/dbal.php branches/phpBB-3_0_0/phpBB/includes/db/firebird.php branches/phpBB-3_0_0/phpBB/includes/db/oracle.php branches/phpBB-3_0_0/phpBB/includes/functions.php branches/phpBB-3_0_0/phpBB/includes/functions_admin.php branches/phpBB-3_0_0/phpBB/install/database_update.php branches/phpBB-3_0_0/phpBB/install/schemas/firebird_schema.sql branches/phpBB-3_0_0/phpBB/install/schemas/mssql_schema.sql branches/phpBB-3_0_0/phpBB/install/schemas/mysql_40_schema.sql branches/phpBB-3_0_0/phpBB/install/schemas/mysql_41_schema.sql branches/phpBB-3_0_0/phpBB/install/schemas/oracle_schema.sql branches/phpBB-3_0_0/phpBB/install/schemas/postgres_schema.sql branches/phpBB-3_0_0/phpBB/install/schemas/schema_data.sql branches/phpBB-3_0_0/phpBB/install/schemas/sqlite_schema.sql branches/phpBB-3_0_0/phpBB/styles/prosilver/template/overall_header.html branches/phpBB-3_0_0/phpBB/viewforum.php branches/phpBB-3_0_0/phpBB/viewtopic.php Modified: branches/phpBB-3_0_0/phpBB/adm/index.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/adm/index.php (original) --- branches/phpBB-3_0_0/phpBB/adm/index.php Wed Aug 12 16:00:47 2009 *************** *** 263,268 **** --- 263,274 ---- $tpl = ''; $name = 'config[' . $config_key . ']'; + // Make sure there is no notice printed out for non-existent config options (we simply set them) + if (!isset($new[$config_key])) + { + $new[$config_key] = ''; + } + switch ($tpl_type[0]) { case 'text': *************** *** 301,307 **** break; case 'select': - case 'select_multiple': case 'custom': $return = ''; --- 307,312 ---- *************** *** 340,360 **** } else { - if ($tpl_type[0] == 'select_multiple') - { - $new[$config_key] = @unserialize(trim($new[$config_key])); - } - $args = array($new[$config_key], $key); } $return = call_user_func_array($call, $args); ! if ($tpl_type[0] == 'select_multiple') ! { ! $tpl = '<select id="' . $key . '" name="' . $name . '[]" multiple="multiple">' . $return . '</select>'; ! } ! else if ($tpl_type[0] == 'select') { $tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>'; } --- 345,356 ---- } else { $args = array($new[$config_key], $key); } $return = call_user_func_array($call, $args); ! if ($tpl_type[0] == 'select') { $tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>'; } Modified: branches/phpBB-3_0_0/phpBB/develop/create_schema_files.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/develop/create_schema_files.php (original) --- branches/phpBB-3_0_0/phpBB/develop/create_schema_files.php Wed Aug 12 16:00:47 2009 *************** *** 1073,1078 **** --- 1073,1079 ---- 'forum_last_poster_name'=> array('VCHAR_UNI', ''), 'forum_last_poster_colour'=> array('VCHAR:6', ''), 'forum_flags' => array('TINT:4', 32), + 'forum_options' => array('UINT:20', 0), 'display_subforum_list' => array('BOOL', 1), 'display_on_index' => array('BOOL', 1), 'enable_indexing' => array('BOOL', 1), Modified: branches/phpBB-3_0_0/phpBB/develop/mysql_upgrader.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/develop/mysql_upgrader.php (original) --- branches/phpBB-3_0_0/phpBB/develop/mysql_upgrader.php Wed Aug 12 16:00:47 2009 *************** *** 563,568 **** --- 563,569 ---- 'forum_last_poster_name'=> array('VCHAR_UNI', ''), 'forum_last_poster_colour'=> array('VCHAR:6', ''), 'forum_flags' => array('TINT:4', 32), + 'forum_options' => array('UINT:20', 0), 'display_subforum_list' => array('BOOL', 1), 'display_on_index' => array('BOOL', 1), 'enable_indexing' => array('BOOL', 1), Modified: branches/phpBB-3_0_0/phpBB/feed.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/feed.php (original) --- branches/phpBB-3_0_0/phpBB/feed.php Wed Aug 12 16:00:47 2009 *************** *** 339,345 **** break; case 'news': ! if (empty($config['feed_news_id'])) { return false; } --- 339,355 ---- break; case 'news': ! global $db; ! ! // Get at least one news forum ! $sql = 'SELECT forum_id ! FROM ' . FORUMS_TABLE . ' ! WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); ! $result = $db->sql_query_limit($sql, 1, 0, 600); ! $s_feed_news = (int) $db->sql_fetchfield('forum_id'); ! $db->sql_freeresult($result); ! ! if (!$s_feed_news) { return false; } *************** *** 534,540 **** global $auth, $db, $config, $phpbb_root_path, $phpEx, $user; // Which forums should not be searched ? ! $exclude_forums = (!empty($config['feed_exclude_id'])) ? unserialize(trim($config['feed_exclude_id'])) : array(); // Exclude forums the user is not able to read $this->excluded_forums_ary = array_keys($auth->acl_getf('!f_read', true)); --- 544,561 ---- global $auth, $db, $config, $phpbb_root_path, $phpEx, $user; // Which forums should not be searched ? ! $exclude_forums = array(); ! ! $sql = 'SELECT forum_id ! FROM ' . FORUMS_TABLE . ' ! WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0'); ! $result = $db->sql_query($sql); ! ! while ($row = $db->sql_fetchrow($result)) ! { ! $exclude_forums[] = (int) $row['forum_id']; ! } ! $db->sql_freeresult($result); // Exclude forums the user is not able to read $this->excluded_forums_ary = array_keys($auth->acl_getf('!f_read', true)); *************** *** 883,889 **** { global $db, $config; ! $in_fid_ary = unserialize(trim($config['feed_news_id'])); if (!sizeof($in_fid_ary)) { --- 904,921 ---- { global $db, $config; ! // Get news forums... ! $sql = 'SELECT forum_id ! FROM ' . FORUMS_TABLE . ' ! WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); ! $result = $db->sql_query($sql); ! ! $in_fid_ary = array(); ! while ($row = $db->sql_fetchrow($result)) ! { ! $in_fid_ary[] = (int) $row['forum_id']; ! } ! $db->sql_freeresult($result); if (!sizeof($in_fid_ary)) { *************** *** 905,911 **** 'WHERE' => $db->sql_in_set('t.forum_id', $in_fid_ary) . ' AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id ! AND t.topic_poster = u.user_id', 'ORDER_BY' => 't.topic_time DESC', ); --- 937,944 ---- 'WHERE' => $db->sql_in_set('t.forum_id', $in_fid_ary) . ' AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id ! AND t.topic_poster = u.user_id ! AND t.topic_moved_id = 0', 'ORDER_BY' => 't.topic_time DESC', ); Modified: branches/phpBB-3_0_0/phpBB/includes/acp/acp_board.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/acp/acp_board.php (original) --- branches/phpBB-3_0_0/phpBB/includes/acp/acp_board.php Wed Aug 12 16:00:47 2009 *************** *** 272,279 **** 'feed_overall_topics_limit' => array('lang' => 'ACP_FEED_OVERALL_TOPIC_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => false), 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), ! 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'select_multiple', 'method' => 'select_news_forums', 'explain' => true ), ! 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'select_multiple', 'method' => 'select_exclude_forums', 'explain' => true), ) ); break; --- 272,279 ---- 'feed_overall_topics_limit' => array('lang' => 'ACP_FEED_OVERALL_TOPIC_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => false), 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), ! 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true), ! 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true), ) ); break; *************** *** 440,474 **** // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { ! if (strpos($config_name, 'legend') !== false) { continue; } ! if ($config_name == 'auth_method') { continue; } - // It could happen that the cfg array is not set. This happens within feed settings if unselecting all forums in the multiple select fields for example (it is the same as checkbox handling) - if (!isset($cfg_array[$config_name])) - { - $cfg_array[$config_name] = ''; - } - - // Erm, we spotted an array - if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) - { - // Get config *array* - $cfg_ = utf8_normalize_nfc(request_var('config', array('' => array('')), true)); - - // Check if the variable is set and an array - if (isset($cfg_[$config_name]) && is_array($cfg_[$config_name])) - { - $cfg_array[$config_name] = trim(serialize($cfg_[$config_name])); - } - } - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($config_name == 'email_function_name') --- 440,455 ---- // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { ! if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } ! if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id') { continue; } $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($config_name == 'email_function_name') *************** *** 484,489 **** --- 465,477 ---- } } + // Store news and exclude ids + if ($mode == 'feed' && $submit) + { + $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id'); + $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id'); + } + if ($mode == 'auth') { // Retrieve a list of auth plugins and check their config values *************** *** 902,918 **** { global $user, $config; ! // Determine ids to be selected ! $select_ids = (sizeof($value)) ? $value : false; ! ! $forum_list = make_forum_select($select_ids, false, true, true, true, false, true); // Build forum options ! $s_forum_options = ''; foreach ($forum_list as $f_id => $f_row) { $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } return $s_forum_options; } --- 890,906 ---- { global $user, $config; ! $forum_list = make_forum_select(false, false, true, true, true, false, true); // Build forum options ! $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; foreach ($forum_list as $f_id => $f_row) { + $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']); + $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } + $s_forum_options .= '</select>'; return $s_forum_options; } *************** *** 921,940 **** { global $user, $config; ! // Determine ids to be selected ! $select_ids = (sizeof($value)) ? $value : false; ! ! $forum_list = make_forum_select($select_ids, false, true, false, false, false, true); // Build forum options ! $s_forum_options = ''; foreach ($forum_list as $f_id => $f_row) { $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } return $s_forum_options; } } ?> \ No newline at end of file --- 909,956 ---- { global $user, $config; ! $forum_list = make_forum_select(false, false, true, false, false, false, true); // Build forum options ! $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; foreach ($forum_list as $f_id => $f_row) { + $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']); + $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } + $s_forum_options .= '</select>'; return $s_forum_options; } + + function store_feed_forums($option, $key) + { + global $db, $cache; + + // Get key + $values = request_var($key, array(0 => 0)); + + // Empty option bit for all forums + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_options = forum_options - ' . (1 << $option) . ' + WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0'); + $db->sql_query($sql); + + // Already emptied for all... + if (sizeof($values)) + { + // Set for selected forums + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_options = forum_options + ' . (1 << $option) . ' + WHERE ' . $db->sql_in_set('forum_id', $values); + $db->sql_query($sql); + } + + // Empty sql cache for forums table because options changed + $cache->destroy('sql', FORUMS_TABLE); + } + } ?> \ No newline at end of file Modified: branches/phpBB-3_0_0/phpBB/includes/constants.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/constants.php (original) --- branches/phpBB-3_0_0/phpBB/includes/constants.php Wed Aug 12 16:00:47 2009 *************** *** 93,98 **** --- 93,102 ---- define('FORUM_FLAG_POST_REVIEW', 32); define('FORUM_FLAG_QUICK_REPLY', 64); + // Forum Options... sequential order. Modifications should begin at number 10 (number 29 is maximum) + define('FORUM_OPTION_FEED_NEWS', 1); + define('FORUM_OPTION_FEED_EXCLUDE', 2); + // Optional text flags define('OPTION_FLAG_BBCODE', 1); define('OPTION_FLAG_SMILIES', 2); Modified: branches/phpBB-3_0_0/phpBB/includes/db/dbal.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/db/dbal.php (original) --- branches/phpBB-3_0_0/phpBB/includes/db/dbal.php Wed Aug 12 16:00:47 2009 *************** *** 412,417 **** --- 412,435 ---- } /** + * Run binary AND operator on DB column. + * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" + * + * @param string $column_name The column name to use + * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 + * @param string $compare Any custom SQL code after the check (for example "= 0") + */ + function sql_bit_and($column_name, $bit, $compare = '') + { + if (method_exists($this, '_sql_bit_and')) + { + return $this->_sql_bit_and($column_name, $bit, $compare); + } + + return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); + } + + /** * Run more than one insert statement. * * @param string $table table name to run the statements on Modified: branches/phpBB-3_0_0/phpBB/includes/db/firebird.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/db/firebird.php (original) --- branches/phpBB-3_0_0/phpBB/includes/db/firebird.php Wed Aug 12 16:00:47 2009 *************** *** 446,451 **** --- 446,456 ---- return $data; } + function _sql_bit_and($column_name, $bit, $compare = '') + { + return 'BIN_AND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); + } + /** * return sql error array * @access private Modified: branches/phpBB-3_0_0/phpBB/includes/db/oracle.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/db/oracle.php (original) --- branches/phpBB-3_0_0/phpBB/includes/db/oracle.php Wed Aug 12 16:00:47 2009 *************** *** 568,573 **** --- 568,578 ---- return $data; } + function _sql_bit_and($column_name, $bit, $compare = '') + { + return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); + } + /** * return sql error array * @access private Modified: branches/phpBB-3_0_0/phpBB/includes/functions.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/functions.php (original) --- branches/phpBB-3_0_0/phpBB/includes/functions.php Wed Aug 12 16:00:47 2009 *************** *** 3505,3511 **** $l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:' . $config['board_contact'] . '">' . $config['board_contact'] . '</a></p>'; } } ! if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) { // let's avoid loops --- 3505,3511 ---- $l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:' . $config['board_contact'] . '">' . $config['board_contact'] . '</a></p>'; } } ! if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) { // let's avoid loops *************** *** 3857,3862 **** --- 3857,3896 ---- ); } + /** + * Get option bitfield from custom data + * + * @param int $bit The bit/value to get + * @param int $data Current bitfield to check + * @return bool Returns true if value of constant is set in bitfield, else false + */ + function phpbb_optionget($bit, $data) + { + return ($data & 1 << (int) $bit) ? true : false; + } + + /** + * Set option bitfield + * + * @param int $bit The bit/value to set/unset + * @param bool $set True if option should be set, false if option should be unset. + * @param int $data Current bitfield to change + * + * @return int The new bitfield + */ + function phpbb_optionset($bit, $set, $data) + { + if ($set && !($data & 1 << $bit)) + { + $data += 1 << $bit; + } + else if (!$set && ($data & 1 << $bit)) + { + $data -= 1 << $bit; + } + + return $data; + } /** * Generate page header *************** *** 3917,3923 **** * } * </code> */ ! if ($forum_id) { $item_id = max($forum_id, 0); --- 3951,3957 ---- * } * </code> */ ! if ($forum_id) { $item_id = max($forum_id, 0); *************** *** 3926,3932 **** { $item_id = 0; } ! // workaround legacy code $item = 'forum'; $online_users = obtain_users_online($item_id, $item); --- 3960,3966 ---- { $item_id = 0; } ! // workaround legacy code $item = 'forum'; $online_users = obtain_users_online($item_id, $item); *************** *** 4005,4010 **** --- 4039,4057 ---- $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); + $s_feed_news = false; + + // Get option for news + if ($config['feed_enable']) + { + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); + $result = $db->sql_query_limit($sql, 1, 0, 600); + $s_feed_news = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + } + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], *************** *** 4082,4092 **** 'S_TOPIC_ID' => $topic_id, 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, - 'S_ENABLE_FEEDS_NEWS' => ($config['feed_news_id'] != '') ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, ! 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_id && strpos($user->page['page_name'], 'viewforum') !== false) ? true : false, ! 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && $topic_id && strpos($user->page['page_name'], 'viewtopic') !== false) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', --- 4129,4137 ---- 'S_TOPIC_ID' => $topic_id, 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, ! 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', Modified: branches/phpBB-3_0_0/phpBB/includes/functions_admin.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/functions_admin.php (original) --- branches/phpBB-3_0_0/phpBB/includes/functions_admin.php Wed Aug 12 16:00:47 2009 *************** *** 69,75 **** $acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel')); // This query is identical to the jumpbox one ! $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600); --- 69,75 ---- $acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel')); // This query is identical to the jumpbox one ! $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600); *************** *** 1364,1378 **** $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); $db->sql_query($sql); ! break; } ! $db->sql_transaction('commit'); break; case 'topic_approved': ! $db->sql_transaction('begin'); switch ($db->sql_layer) { --- 1364,1378 ---- $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); $db->sql_query($sql); ! break; } ! $db->sql_transaction('commit'); break; case 'topic_approved': ! $db->sql_transaction('begin'); switch ($db->sql_layer) { *************** *** 1409,1423 **** $db->sql_query($sql); break; } ! $db->sql_transaction('commit'); break; case 'post_reported': $post_ids = $post_reported = array(); ! $db->sql_transaction('begin'); ! $sql = 'SELECT p.post_id, p.post_reported FROM ' . POSTS_TABLE . " p $where_sql --- 1409,1423 ---- $db->sql_query($sql); break; } ! $db->sql_transaction('commit'); break; case 'post_reported': $post_ids = $post_reported = array(); ! $db->sql_transaction('begin'); ! $sql = 'SELECT p.post_id, p.post_reported FROM ' . POSTS_TABLE . " p $where_sql *************** *** 1468,1474 **** WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); break; --- 1468,1474 ---- WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); break; *************** *** 1481,1487 **** $topic_ids = $topic_reported = array(); $db->sql_transaction('begin'); ! $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_reported = 1"; --- 1481,1487 ---- $topic_ids = $topic_reported = array(); $db->sql_transaction('begin'); ! $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_reported = 1"; *************** *** 1514,1520 **** WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); break; --- 1514,1520 ---- WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); break; *************** *** 1522,1528 **** $post_ids = $post_attachment = array(); $db->sql_transaction('begin'); ! $sql = 'SELECT p.post_id, p.post_attachment FROM ' . POSTS_TABLE . " p $where_sql --- 1522,1528 ---- $post_ids = $post_attachment = array(); $db->sql_transaction('begin'); ! $sql = 'SELECT p.post_id, p.post_attachment FROM ' . POSTS_TABLE . " p $where_sql *************** *** 1573,1579 **** WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); break; --- 1573,1579 ---- WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); break; *************** *** 1619,1633 **** WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); ! break; case 'forum': $db->sql_transaction('begin'); ! // 1: Get the list of all forums $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . " f --- 1619,1633 ---- WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } ! $db->sql_transaction('commit'); ! break; case 'forum': $db->sql_transaction('begin'); ! // 1: Get the list of all forums $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . " f *************** *** 1828,1834 **** $db->sql_query($sql); } } ! $db->sql_transaction('commit'); break; --- 1828,1834 ---- $db->sql_query($sql); } } ! $db->sql_transaction('commit'); break; *************** *** 1836,1842 **** $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); $db->sql_transaction('begin'); ! $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; --- 1836,1842 ---- $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); $db->sql_transaction('begin'); ! $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; *************** *** 2160,2166 **** unset($topic_data); $db->sql_transaction('commit'); ! // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. --- 2160,2166 ---- unset($topic_data); $db->sql_transaction('commit'); ! // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. Modified: branches/phpBB-3_0_0/phpBB/install/database_update.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/database_update.php (original) --- branches/phpBB-3_0_0/phpBB/install/database_update.php Wed Aug 12 16:00:47 2009 *************** *** 707,712 **** --- 707,715 ---- PROFILE_FIELDS_TABLE => array( 'field_show_on_vt' => array('BOOL', 0), ), + FORUMS_TABLE => array( + 'forum_options' => array('UINT:20', 0), + ), ), 'change_columns' => array( USERS_TABLE => array( *************** *** 1086,1095 **** set_config('feed_forum', '1'); set_config('feed_topic', '1'); - set_config('feed_news_id', ''); - set_config('feed_item_statistics', '1'); - set_config('feed_exclude_id', ''); // Entries for smiley pagination set_config('smilies_per_page', '50'); --- 1089,1095 ---- Modified: branches/phpBB-3_0_0/phpBB/install/schemas/firebird_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/firebird_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/firebird_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 363,368 **** --- 363,369 ---- forum_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, forum_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, forum_flags INTEGER DEFAULT 32 NOT NULL, + forum_options INTEGER DEFAULT 0 NOT NULL, display_subforum_list INTEGER DEFAULT 1 NOT NULL, display_on_index INTEGER DEFAULT 1 NOT NULL, enable_indexing INTEGER DEFAULT 1 NOT NULL, Modified: branches/phpBB-3_0_0/phpBB/install/schemas/mssql_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/mssql_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/mssql_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 439,444 **** --- 439,445 ---- [forum_last_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , [forum_last_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , [forum_flags] [int] DEFAULT (32) NOT NULL , + [forum_options] [int] DEFAULT (0) NOT NULL , [display_subforum_list] [int] DEFAULT (1) NOT NULL , [display_on_index] [int] DEFAULT (1) NOT NULL , [enable_indexing] [int] DEFAULT (1) NOT NULL , Modified: branches/phpBB-3_0_0/phpBB/install/schemas/mysql_40_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/mysql_40_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/mysql_40_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 249,254 **** --- 249,255 ---- forum_last_poster_name blob NOT NULL, forum_last_poster_colour varbinary(6) DEFAULT '' NOT NULL, forum_flags tinyint(4) DEFAULT '32' NOT NULL, + forum_options int(20) UNSIGNED DEFAULT '0' NOT NULL, display_subforum_list tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, enable_indexing tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, Modified: branches/phpBB-3_0_0/phpBB/install/schemas/mysql_41_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/mysql_41_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/mysql_41_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 249,254 **** --- 249,255 ---- forum_last_poster_name varchar(255) DEFAULT '' NOT NULL, forum_last_poster_colour varchar(6) DEFAULT '' NOT NULL, forum_flags tinyint(4) DEFAULT '32' NOT NULL, + forum_options int(20) UNSIGNED DEFAULT '0' NOT NULL, display_subforum_list tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, enable_indexing tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, Modified: branches/phpBB-3_0_0/phpBB/install/schemas/oracle_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/oracle_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/oracle_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 505,510 **** --- 505,511 ---- forum_last_poster_name varchar2(765) DEFAULT '' , forum_last_poster_colour varchar2(6) DEFAULT '' , forum_flags number(4) DEFAULT '32' NOT NULL, + forum_options number(20) DEFAULT '0' NOT NULL, display_subforum_list number(1) DEFAULT '1' NOT NULL, display_on_index number(1) DEFAULT '1' NOT NULL, enable_indexing number(1) DEFAULT '1' NOT NULL, Modified: branches/phpBB-3_0_0/phpBB/install/schemas/postgres_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/postgres_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/postgres_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 382,387 **** --- 382,388 ---- forum_last_poster_name varchar(255) DEFAULT '' NOT NULL, forum_last_poster_colour varchar(6) DEFAULT '' NOT NULL, forum_flags INT2 DEFAULT '32' NOT NULL, + forum_options INT4 DEFAULT '0' NOT NULL CHECK (forum_options >= 0), display_subforum_list INT2 DEFAULT '1' NOT NULL CHECK (display_subforum_list >= 0), display_on_index INT2 DEFAULT '1' NOT NULL CHECK (display_on_index >= 0), enable_indexing INT2 DEFAULT '1' NOT NULL CHECK (enable_indexing >= 0), Modified: branches/phpBB-3_0_0/phpBB/install/schemas/schema_data.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/schema_data.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/schema_data.sql Wed Aug 12 16:00:47 2009 *************** *** 105,113 **** INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_overall_topics_limit', '15'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_forum', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_topic', '1'); - INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_news_id', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_item_statistics', '1'); - INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_exclude_id', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval', '15'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('force_server_vars', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('form_token_lifetime', '7200'); --- 105,111 ---- Modified: branches/phpBB-3_0_0/phpBB/install/schemas/sqlite_schema.sql ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/schemas/sqlite_schema.sql (original) --- branches/phpBB-3_0_0/phpBB/install/schemas/sqlite_schema.sql Wed Aug 12 16:00:47 2009 *************** *** 242,247 **** --- 242,248 ---- forum_last_poster_name varchar(255) NOT NULL DEFAULT '', forum_last_poster_colour varchar(6) NOT NULL DEFAULT '', forum_flags tinyint(4) NOT NULL DEFAULT '32', + forum_options INTEGER UNSIGNED NOT NULL DEFAULT '0', display_subforum_list INTEGER UNSIGNED NOT NULL DEFAULT '1', display_on_index INTEGER UNSIGNED NOT NULL DEFAULT '1', enable_indexing INTEGER UNSIGNED NOT NULL DEFAULT '1', Modified: branches/phpBB-3_0_0/phpBB/styles/prosilver/template/overall_header.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/styles/prosilver/template/overall_header.html (original) --- branches/phpBB-3_0_0/phpBB/styles/prosilver/template/overall_header.html Wed Aug 12 16:00:47 2009 *************** *** 20,27 **** <!-- IF S_ENABLE_FEEDS_NEWS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FEED_NEWS}" href="{U_FEED}?mode=news" /><!-- ENDIF --> <!-- IF S_ENABLE_FEEDS_FORUMS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_ALL_FORUMS}" href="{U_FEED}?mode=forums" /><!-- ENDIF --> <!-- IF S_ENABLE_FEEDS_TOPICS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_ALL_TOPICS}" href="{U_FEED}?mode=topics" /><!-- ENDIF --> ! <!-- IF S_ENABLE_FEEDS_FORUM and S_FORUM_ID --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FORUM} {FORUM_NAME}" href="{U_FEED}?f={S_FORUM_ID}" /><!-- ENDIF --> ! <!-- IF S_ENABLE_FEEDS_TOPIC and S_TOPIC_ID --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_TOPIC} {TOPIC_TITLE}" href="{U_FEED}?f={S_FORUM_ID}&t={S_TOPIC_ID}" /><!-- ENDIF --> <!-- ENDIF --> <!-- --- 20,27 ---- <!-- IF S_ENABLE_FEEDS_NEWS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FEED_NEWS}" href="{U_FEED}?mode=news" /><!-- ENDIF --> <!-- IF S_ENABLE_FEEDS_FORUMS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_ALL_FORUMS}" href="{U_FEED}?mode=forums" /><!-- ENDIF --> <!-- IF S_ENABLE_FEEDS_TOPICS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_ALL_TOPICS}" href="{U_FEED}?mode=topics" /><!-- ENDIF --> ! <!-- IF S_ENABLE_FEEDS_FORUM and S_FORUM_ID --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FORUM} - {FORUM_NAME}" href="{U_FEED}?f={S_FORUM_ID}" /><!-- ENDIF --> ! <!-- IF S_ENABLE_FEEDS_TOPIC and S_TOPIC_ID --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_TOPIC} - {TOPIC_TITLE}" href="{U_FEED}?f={S_FORUM_ID}&t={S_TOPIC_ID}" /><!-- ENDIF --> <!-- ENDIF --> <!-- Modified: branches/phpBB-3_0_0/phpBB/viewforum.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/viewforum.php (original) --- branches/phpBB-3_0_0/phpBB/viewforum.php Wed Aug 12 16:00:47 2009 *************** *** 310,315 **** --- 310,316 ---- 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true, 'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false, 'S_VIEWFORUM' => true, + 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false, 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", true, $user->session_id) : '', 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&f=' . $forum_id) : '', Modified: branches/phpBB-3_0_0/phpBB/viewtopic.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/viewtopic.php (original) --- branches/phpBB-3_0_0/phpBB/viewtopic.php Wed Aug 12 16:00:47 2009 *************** *** 620,625 **** --- 620,626 ---- 'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, + 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false, 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", 'U_FORUM' => $server_path, *************** *** 1180,1186 **** // Grab all profile fields from users in id cache for later use - similar to the poster cache $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache); ! // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs. $profile_fields_cache = array(); foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) --- 1181,1187 ---- // Grab all profile fields from users in id cache for later use - similar to the poster cache $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache); ! // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs. $profile_fields_cache = array(); foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) |