From df24e3c8e0da6dc9f4a1ad50e58b8afa3a4dde3c Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 21 Oct 2003 13:05:15 +0000 Subject: [PATCH] Enable/disable fulltext indexing of a given forum git-svn-id: file:///svn/phpbb/trunk@4620 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_forums.php | 153 ++++++++++++++----------- phpBB/install/schemas/mysql_schema.sql | 1 + phpBB/language/en/lang_admin.php | 22 ++-- phpBB/posting.php | 22 ++-- 4 files changed, 106 insertions(+), 92 deletions(-) diff --git a/phpBB/adm/admin_forums.php b/phpBB/adm/admin_forums.php index 80a8c99fbf..ee88d4d0f5 100644 --- a/phpBB/adm/admin_forums.php +++ b/phpBB/adm/admin_forums.php @@ -35,10 +35,12 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); require('pagestart.' . $phpEx); // Get general vars -$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; -$action = (isset($_POST['action'])) ? htmlspecialchars($_POST['action']) : ''; -$forum_id = (isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0; -$parent_id = (isset($_REQUEST['parent_id'])) ? intval($_REQUEST['parent_id']) : 0; +$update = (isset($_POST['update'])) ? true : false; +$mode = request_var('mode', ''); +$action = request_var('action', ''); +$forum_id = request_var('f', 0); +$parent_id = request_var('parent_id', 0); + $forum_data = $errors = array(); // Do we have permissions? @@ -61,16 +63,15 @@ if (!$auth->acl_get($acl)) // Major routines -if (isset($_POST['update'])) +if ($update) { switch ($mode) { case 'delete': - $action_subforums = (!empty($_POST['action_subforums'])) ? $_POST['action_subforums'] : ''; - $subforums_to_id = (!empty($_POST['subforums_to_id'])) ? intval($_POST['subforums_to_id']) : 0; - - $action_posts = (!empty($_POST['action_posts'])) ? $_POST['action_posts'] : ''; - $posts_to_id = (!empty($_POST['posts_to_id'])) ? intval($_POST['posts_to_id']) : 0; + $action_subforums = request_var('action_subforums', ''); + $subforums_to_id = request_var('subforums_to_id', 0); + $action_posts = request_var('action_posts', ''); + $posts_to_id = request_var('posts_to_id', 0); delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); @@ -86,27 +87,28 @@ if (isset($_POST['update'])) case 'add': $forum_data += array( - 'parent_id' => $parent_id, - 'forum_type' => request_var('forum_type', FORUM_POST), - 'forum_status' => request_var('forum_status', ITEM_UNLOCKED), - 'forum_name' => request_var('forum_name', ''), - 'forum_link' => request_var('forum_link', ''), - 'forum_link_track' => request_var('forum_link_track', FALSE), - 'forum_desc' => str_replace("\n", '
', request_var('forum_desc', '')), - 'forum_image' => request_var('forum_image', ''), - 'forum_style' => request_var('forum_style', 0), - 'display_on_index' => request_var('display_on_index', FALSE), - 'forum_topics_per_page' => request_var('topics_per_page', 0), - 'enable_icons' => request_var('enable_icons', FALSE), - 'enable_prune' => request_var('enable_prune', FALSE), - 'prune_days' => request_var('prune_days', 7), - 'prune_viewed' => request_var('prune_viewed', 7), - 'prune_freq' => request_var('prune_freq', 1), - 'prune_old_polls' => request_var('prune_old_polls', FALSE), - 'prune_announce' => request_var('prune_announce', FALSE), - 'prune_sticky' => request_var('prune_sticky', FALSE), - 'forum_password' => request_var('forum_password', ''), - 'forum_password_confirm'=> request_var('forum_password_confirm', '') + 'parent_id' => $parent_id, + 'forum_type' => request_var('forum_type', FORUM_POST), + 'forum_status' => request_var('forum_status', ITEM_UNLOCKED), + 'forum_name' => request_var('forum_name', ''), + 'forum_link' => request_var('forum_link', ''), + 'forum_link_track' => request_var('forum_link_track', FALSE), + 'forum_desc' => str_replace("\n", '
', request_var('forum_desc', '')), + 'forum_image' => request_var('forum_image', ''), + 'forum_style' => request_var('forum_style', 0), + 'display_on_index' => request_var('display_on_index', FALSE), + 'forum_topics_per_page' => request_var('topics_per_page', 0), + 'enable_indexing' => request_var('enable_indexing',true), + 'enable_icons' => request_var('enable_icons', FALSE), + 'enable_prune' => request_var('enable_prune', FALSE), + 'prune_days' => request_var('prune_days', 7), + 'prune_viewed' => request_var('prune_viewed', 7), + 'prune_freq' => request_var('prune_freq', 1), + 'prune_old_polls' => request_var('prune_old_polls', FALSE), + 'prune_announce' => request_var('prune_announce', FALSE), + 'prune_sticky' => request_var('prune_sticky', FALSE), + 'forum_password' => request_var('forum_password', ''), + 'forum_password_confirm'=> request_var('forum_password_confirm', '') ); $errors = update_forum_data($forum_data); @@ -135,15 +137,15 @@ switch ($mode) } else { - $forum_id = request_var('f', 0); - $parent_id = request_var('parent_id', 0); - $style_id = request_var('style_id', 0); - $forum_type = request_var('forum_type', FORUM_POST); - $forum_status = request_var('forum_status', ITEM_UNLOCKED); - $forum_desc = request_var('forum_desc', ''); - $forum_name = request_var('forum_name', ''); - $forum_password = request_var('forum_password', ''); - $forum_password_confirm = request_var('forum_password_confirm', ''); + $forum_id = request_var('f', 0); + $parent_id = request_var('parent_id', 0); + $style_id = request_var('style_id', 0); + $forum_type = request_var('forum_type', FORUM_POST); + $forum_status = request_var('forum_status', ITEM_UNLOCKED); + $forum_desc = request_var('forum_desc', ''); + $forum_name = request_var('forum_name', ''); + $forum_password = request_var('forum_password', ''); + $forum_password_confirm = request_var('forum_password_confirm', ''); } // Show form to create/modify a forum @@ -199,15 +201,15 @@ switch ($mode) $statuslist = ''; + $indexing_yes = ($enable_indexing) ? ' checked="checked"' : ''; + $indexing_no = (!$enable_indexing) ? ' checked="checked"' : ''; $topic_icons_yes = ($enable_icons) ? ' checked="checked"' : ''; $topic_icons_no = (!$enable_icons) ? ' checked="checked"' : ''; - $display_index_yes = ($display_on_index) ? ' checked="checked"' : ''; $display_index_no = (!$display_on_index) ? ' checked="checked"' : ''; $prune_enable_yes = ($enable_prune) ? ' checked="checked"' : ''; $prune_enable_no = (!$enable_prune) ? ' checked="checked"' : ''; - $prune_old_polls_yes = ($forum_flags & 2) ? ' checked="checked"' : ''; $prune_old_polls_no = (!($forum_flags & 2)) ? ' checked="checked"' : ''; $prune_announce_yes = ($forum_flags & 4) ? ' checked="checked"' : ''; @@ -293,7 +295,7 @@ switch ($mode) ?> - lang['FORUM_STATUS'] ?>: + lang['FORUM_STATUS'] ?>: - lang['FORUM_PARENT'] ?>: + lang['FORUM_PARENT'] ?>: - lang['FORUM_LINK'] ?>:
lang['FORUM_LINK_EXPLAIN']; ?> + lang['FORUM_LINK'] ?>:
lang['FORUM_LINK_EXPLAIN']; ?> - lang['FORUM_LINK_TRACK'] ?>:
lang['FORUM_LINK_TRACK_EXPLAIN']; ?> + lang['FORUM_LINK_TRACK'] ?>:
lang['FORUM_LINK_TRACK_EXPLAIN']; ?> /> lang['YES']; ?>   /> lang['NO']; ?> - lang['FORUM_NAME']; ?>: + lang['FORUM_NAME']; ?>: - lang['FORUM_DESC'] ?>:
lang['FORUM_DESC_EXPLAIN']; ?> + lang['FORUM_DESC'] ?>:
lang['FORUM_DESC_EXPLAIN']; ?> - lang['FORUM_IMAGE']; ?>:
lang['FORUM_IMAGE_EXPLAIN']; ?> + lang['FORUM_IMAGE']; ?>:
lang['FORUM_IMAGE_EXPLAIN']; ?>
- lang['FORUM_STYLE'] ?>: + lang['FORUM_STYLE'] ?>: - lang['ENABLE_TOPIC_ICONS'] ?>: + lang['ENABLE_INDEXING'] ?>:
lang['ENABLE_INDEXING_EXPLAIN'] ?> + /> lang['YES']; ?>   /> lang['NO']; ?> + + + lang['ENABLE_TOPIC_ICONS'] ?>: /> lang['YES']; ?>   /> lang['NO']; ?> - lang['LIST_INDEX'] ?>:
lang['LIST_INDEX_EXPLAIN']; ?> + lang['LIST_INDEX'] ?>:
lang['LIST_INDEX_EXPLAIN']; ?> /> lang['YES']; ?>   /> lang['NO']; ?> - lang['FORUM_AUTO_PRUNE'] ?>:
lang['FORUM_AUTO_PRUNE_EXPLAIN']; ?> + lang['FORUM_AUTO_PRUNE'] ?>:
lang['FORUM_AUTO_PRUNE_EXPLAIN']; ?> /> lang['YES']; ?>   /> lang['NO']; ?> - lang['AUTO_PRUNE_FREQ'] ?>:
lang['AUTO_PRUNE_FREQ_EXPLAIN']; ?> + lang['AUTO_PRUNE_FREQ'] ?>:
lang['AUTO_PRUNE_FREQ_EXPLAIN']; ?> lang['DAYS']; ?> - lang['AUTO_PRUNE_DAYS'] ?>:
lang['AUTO_PRUNE_DAYS_EXPLAIN']; ?> + lang['AUTO_PRUNE_DAYS'] ?>:
lang['AUTO_PRUNE_DAYS_EXPLAIN']; ?> lang['DAYS']; ?> - lang['AUTO_PRUNE_VIEWED'] ?>:
lang['AUTO_PRUNE_VIEWED_EXPLAIN']; ?> + lang['AUTO_PRUNE_VIEWED'] ?>:
lang['AUTO_PRUNE_VIEWED_EXPLAIN']; ?> lang['DAYS']; ?> - lang['PRUNE_OLD_POLLS'] ?>:
lang['PRUNE_OLD_POLLS_EXPLAIN']; ?> + lang['PRUNE_OLD_POLLS'] ?>:
lang['PRUNE_OLD_POLLS_EXPLAIN']; ?> /> lang['YES']; ?>   /> lang['NO']; ?> - lang['PRUNE_ANNOUNCEMENTS'] ?>: + lang['PRUNE_ANNOUNCEMENTS'] ?>: /> lang['YES']; ?>   /> lang['NO']; ?> - lang['PRUNE_STICKY'] ?>: + lang['PRUNE_STICKY'] ?>: /> lang['YES']; ?>   /> lang['NO']; ?> - lang['FORUM_TOPICS_PAGE'] ?>:
lang['FORUM_TOPICS_PAGE_EXPLAIN']; ?> + lang['FORUM_TOPICS_PAGE'] ?>:
lang['FORUM_TOPICS_PAGE_EXPLAIN']; ?> - lang['FORUM_PASSWORD'] ?>:
lang['FORUM_PASSWORD_EXPLAIN']; ?> + lang['FORUM_PASSWORD'] ?>:
lang['FORUM_PASSWORD_EXPLAIN']; ?> - lang['FORUM_PASSWORD_CONFIRM'] ?>:
lang['FORUM_PASSWORD_CONFIRM_EXPLAIN']; ?> + lang['FORUM_PASSWORD_CONFIRM'] ?>:
lang['FORUM_PASSWORD_CONFIRM_EXPLAIN']; ?> - +sql_fetchrow($result)) { - ?> - - + + + +
lang['DELETE_ALL_POSTS'] ?>
lang['MOVE_POSTS_TO'] ?>
lang['MOVE_POSTS_TO'] ?>
@@ -543,14 +557,12 @@ switch ($mode) WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); - if (!($row = $db->sql_fetchrow($result))) + if (!extract($db->sql_fetchrow($result))) { trigger_error($user->lang['NO_FORUM']); } $db->sql_freeresult($result); - extract($row); - $forum_info = array($forum_id => $row); // Get the adjacent forum @@ -628,6 +640,7 @@ switch ($mode) $db->sql_transaction('commit'); $forum_data = get_forum_info($forum_id); + add_log('admin', $log_action, $forum_data['forum_name'], $move_forum_name); unset($forum_data); break; @@ -830,7 +843,7 @@ function get_forum_info($forum_id) WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) + if (!($row = $db->sql_fetchrow($result))) { trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); } diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index 7ace696bdd..370d47c790 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -204,6 +204,7 @@ CREATE TABLE phpbb_forums ( forum_last_poster_name varchar(30), forum_flags tinyint(4) DEFAULT '0' NOT NULL, display_on_index tinyint(1) DEFAULT '1' NOT NULL, + enable_indexing tinyint(1) DEFAULT '1' NOT NULL, enable_icons tinyint(1) DEFAULT '1' NOT NULL, enable_prune tinyint(1) DEFAULT '0' NOT NULL, prune_next int(11) UNSIGNED, diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index b65a7210b7..01e1c89636 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -851,6 +851,8 @@ $lang += array( 'NO_PARENT' => 'No Parent', 'LOCKED' => 'Locked', 'UNLOCKED' => 'Unlocked', + 'ENABLE_INDEXING' => 'Enable search indexing', + 'ENABLE_INDEXING_EXPLAIN' => 'If set to yes posts made to this forum will be indexed for searching.', 'ENABLE_TOPIC_ICONS'=> 'Enable Topic Icons', 'LIST_INDEX' => 'List Forum On Index', 'LIST_INDEX_EXPLAIN'=> 'Displays a link to this forum under the root parent forum on the index.', @@ -1021,21 +1023,23 @@ $lang += array( 'GROUP_DEFS_UPDATED' => 'Default group set for all members', + 'ADD_NEW_GROUP' => 'Create new group', + + 'GROUP_LIST' => 'Current members', 'GROUP_LIST_EXPLAIN' => 'This is a complete list of all the current users with membership of this group. You can delete members (except in certain special groups) or add new ones as you see fit.', 'GROUP_MEMBERS' => 'Group members', - 'GROUP_MEMBERS_EXPLAIN' => 'This is a complete listing of all the members of this usergroup. It includes seperate sections for leaders, pending and existing members. From here you can manage all aspects of who has membership of this group and what their role is.', - 'GROUP_MODERATORS' => 'Group Leaders', - 'GROUP_MODS' => 'Group leaders', - 'GROUP_MODS_EXPLAIN' => 'This is a list of users assigned group leader roles. Group leaders can add, approve and remove members of their group. If you wish to remove a user as a group leader but keep them within the group use demote instead of delete, delete will remove them from the group completely.', + 'GROUP_MEMBERS_EXPLAIN' => 'This is a complete listing of all the members of this usergroup. It includes seperate sections for leaders, pending and existing members. From here you can manage all aspects of who has membership of this group and what their role is. To remove a leader but keep them in the group use Demote rather than delete. Similarly use Promote to make an existing member a leader.', + 'GROUP_LEAD' => 'Group leaders', 'GROUP_PENDING' => 'Pending Users', - 'GROUP_PENDING_EXPLAIN' => 'These users have requested to join the group but have yet to be approved. You can approve or decline their request, or contact the user for further information.', - 'ADD_NEW_GROUP' => 'Create new group', 'GROUPS_NO_MEMBERS' => 'This group has no members', 'GROUPS_NO_MODS' => 'No group leaders defined', - 'USER_DEFAULT' => 'User default', - 'USER_GETS_GROUP_SET' => 'Set as default group', - 'USER_GETS_GROUP_SET_EXPLAIN' => 'Saying yes here will set this group as the default group for the added users', + 'SELECT_OPTION' => 'Select option', + 'ADD_USERS_EXPLAIN' => 'Here you can add new users to the group. You may select whether this group becomes the new default for the selected users. Additionally you can define them as group leaders. Please enter each username on a seperate line.', + 'USER_DEFAULT' => 'User default', + 'USER_GROUP_DEFAULT' => 'Set as default group', + 'USER_GROUP_DEFAULT_EXPLAIN' => 'Saying yes here will set this group as the default group for the added users', + 'USER_GROUP_LEADER' => 'Set as group leader', 'GROUP_USERS_EXIST' => 'The selected users are already members.', 'GROUP_USERS_ADDED' => 'New users added to group successfully.', 'GROUP_MODS_ADDED' => 'New group moderators added successfully.', diff --git a/phpBB/posting.php b/phpBB/posting.php index 6349a4b474..6ac334850c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -47,6 +47,7 @@ if ($delete && !$preview && !$refresh && $submit) } $error = array(); +$current_time = time(); // Was cancel pressed? If so then redirect to the appropriate page @@ -114,13 +115,12 @@ switch ($mode) $censors = array(); obtain_word_list($censors); -if ($sql != '') +if ($sql) { $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); + extract($db->sql_fetchrow($result)); $db->sql_freeresult($result); - extract($row); $quote_username = (!empty($username)) ? $username : ((isset($post_username)) ? $post_username : ''); @@ -139,8 +139,8 @@ if ($sql != '') $post_subject = (in_array($mode, array('quote', 'edit', 'delete'))) ? $post_subject : $topic_title; - $topic_time_limit = ($topic_time_limit) ? $topic_time_limit/86400 : $topic_time_limit; - $poll_length = ($poll_length) ? $poll_length/86400 : $poll_length; + $topic_time_limit = ($topic_time_limit) ? $topic_time_limit / 86400 : $topic_time_limit; + $poll_length = ($poll_length) ? $poll_length / 86400 : $poll_length; $poll_options = array(); // Get Poll Data @@ -370,9 +370,7 @@ if ($mode == 'delete') $html_status = ($config['allow_html'] && $auth->acl_get('f_html', $forum_id)) ? TRUE : FALSE; $bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? TRUE : FALSE; $smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? TRUE : FALSE; -//$img_status = ($config['allow_img'] && $auth->acl_get('f_img', $forum_id)) ? TRUE : FALSE; $img_status = ($auth->acl_get('f_img', $forum_id)) ? TRUE : FALSE; -//$flash_status = ($config['allow_flash'] && $auth->acl_get('f_flash', $forum_id)) ? TRUE : FALSE; $flash_status = ($auth->acl_get('f_flash', $forum_id)) ? TRUE : FALSE; $quote_status = ($config['allow_quote'] && $auth->acl_get('f_quote', $forum_id)) ? TRUE : FALSE; @@ -385,17 +383,14 @@ if ($mode == 'bump' && !$auth->acl_get('f_bump', $forum_id)) else if ($mode == 'bump') { // Check bump time range, is the user really allowed to bump the topic at this time? - $bump_type = (string) preg_replace('#^[0-9]+([m|h|d])$#', '\1', $config['bump_time_range']); - $bump_time = (int) preg_replace('#^([0-9]+)[m|h|d]$#', '\1', $config['bump_time_range']); - $bump_time = ($bump_type == 'm') ? $bump_time*60 : (($bump_type == 'h') ? $bump_time*3600 : $bump_time*86400); + preg_match('#^([0-9]+)(m|h|d)$#', $config['bump_time_range'], $match); + $bump_time = ($match[2] == 'm') ? $match[1] * 60 : (($match[2] == 'h') ? $match[1] * 3600 : $match[1] * 86400); if ($topic_last_post_time + $bump_time > time()) { trigger_error('BUMP_ERROR'); } - $current_time = time(); - $db->sql_transaction(); $db->sql_query('UPDATE ' . POSTS_TABLE . " @@ -2076,8 +2071,9 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ } // Fulltext parse - if ($data['message_md5'] != $data['post_checksum']) + if ($data['message_md5'] != $data['post_checksum'] && $enable_indexing) { + echo "HERE"; $search = new fulltext_search(); $result = $search->add($mode, $data['post_id'], $message, $subject); }