From 81c5530ab857a7d838d8fbde10966e94654075ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dark=E2=9D=B6?= <25451052+Dark1z@users.noreply.github.com> Date: Mon, 17 Jan 2022 23:40:01 +0530 Subject: [PATCH] RSI v1.1.0 Fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Darkā¶ <25451052+Dark1z@users.noreply.github.com> --- event/main_listener.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index 2800c2d..d78626f 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -121,19 +121,12 @@ public function search_modify_submit_parameters() */ public function search_native_index_before($event) { - $post_id = $event['post_id']; $words = $event['words']; $cur_words = $event['cur_words']; if ($this->config['dark1_rsi_enable']) { - $forum = $this->get_search_forum($post_id); - - if ($forum['dark1_rsi_f_enable'] >= consts::F_ENABLE_TOPIC && $forum['topic_time'] <= $this->config['dark1_rsi_time']) - { - $words['add']['post'] = $words['add']['title'] = $words['del']['post'] = $words['del']['title'] = []; - } - else if ($forum['dark1_rsi_f_enable'] == consts::F_ENABLE_POST && $forum['post_time'] <= $this->config['dark1_rsi_time']) + if ($this->get_search_forum_enable((int) $event['post_id'])) { $words['add']['post'] = $words['add']['title'] = $words['del']['post'] = $words['del']['title'] = []; } @@ -165,6 +158,24 @@ private function get_common_words_ary() + /** + * Get Search Forum Enable or Not + * + * @param int $post_id Post ID + * @return bool Enabled or Not + * @access private + */ + private function get_search_forum_enable($post_id) + { + $forum = $this->get_search_forum($post_id); + return (bool) ( + ($forum['dark1_rsi_f_enable'] >= consts::F_ENABLE_TOPIC && $forum['topic_time'] <= $this->config['dark1_rsi_time']) + || ($forum['dark1_rsi_f_enable'] == consts::F_ENABLE_POST && $forum['post_time'] <= $this->config['dark1_rsi_time']) + ); + } + + + /** * Get Search Forum *