diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 676f9456..3218b803 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -368,14 +368,14 @@ jobs: db: "mcr.microsoft.com/mssql/server:2017-latest" db_alias: 'MSSQL 2017' - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2019-latest" + db: "mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04" db_alias: 'MSSQL 2019' name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} services: mssql: - image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} + image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} env: SA_PASSWORD: "Pssw0rd_12" ACCEPT_EULA: "y" @@ -415,7 +415,7 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-latest' ] + if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] then db='mssql' else diff --git a/README.md b/README.md index d9cd8f3d..9b6dc8cc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The official Ideas Centre used at [phpBB.com](https://www.phpbb.com/ideas/). This phpBB extension lets phpBB.com community members propose and vote on ideas to improve and enhance phpBB software. -[![Build Status](https://github.com/phpbb/ideas/workflows/Tests/badge.svg)](https://github.com/phpbb/ideas/actions) +[![Build Status](https://github.com/phpbb/ideas/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbb/ideas/actions) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpbb/ideas/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpbb/ideas/?branch=master) ## Contribute diff --git a/controller/base.php b/controller/base.php index 6c6b22c2..53f30077 100644 --- a/controller/base.php +++ b/controller/base.php @@ -13,7 +13,6 @@ use phpbb\auth\auth; use phpbb\config\config; use phpbb\controller\helper; -use phpbb\ideas\ext; use phpbb\ideas\factory\linkhelper; use phpbb\language\language; use phpbb\pagination; @@ -151,8 +150,6 @@ protected function display_common_vars() 'S_DISPLAY_SEARCHBOX' => $this->auth->acl_get('u_search') && $this->auth->acl_get('f_search', $this->config['ideas_forum_id']) && $this->config['load_search'], 'S_SEARCHBOX_ACTION' => append_sid("{$this->root_path}search.$this->php_ext"), 'S_SEARCH_IDEAS_HIDDEN_FIELDS' => build_hidden_fields(['fid' => [$this->config['ideas_forum_id']]]), - - 'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1']), ]); } } diff --git a/event/listener.php b/event/listener.php index a275ed74..bfe94f0a 100644 --- a/event/listener.php +++ b/event/listener.php @@ -82,6 +82,7 @@ public function __construct(auth $auth, config $config, helper $helper, idea $id public static function getSubscribedEvents() { return array( + 'core.page_header' => 'global_template_vars', 'core.viewforum_get_topic_data' => 'ideas_forum_redirect', 'core.viewtopic_modify_post_row' => 'show_post_buttons', 'core.viewtopic_modify_page_title' => 'show_idea', @@ -93,6 +94,22 @@ public static function getSubscribedEvents() ); } + /** + * Assign global template variables + * + * @return void + */ + public function global_template_vars() + { + if ($this->user->data['is_registered'] && !$this->user->data['is_bot']) + { + $this->template->assign_var( + 'U_SEARCH_MY_IDEAS', + $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1']) + ); + } + } + /** * Redirect users from the forum to the Ideas centre * @@ -223,7 +240,6 @@ public function show_idea($event) 'U_IDEA_VOTE' => $this->link_helper->get_idea_link($idea['idea_id'], 'vote', true), 'U_IDEA_DUPLICATE' => $this->link_helper->get_idea_link($idea['duplicate_id']), 'U_IDEA_STATUS_LINK'=> $this->helper->route('phpbb_ideas_list_controller', ['status' => $idea['idea_status']]), - 'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1']), 'U_TITLE_LIVESEARCH'=> $this->helper->route('phpbb_ideas_livesearch_controller'), )); diff --git a/language/en/common.php b/language/en/common.php index 7ede2932..9fdf298d 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -54,7 +54,7 @@ 'LATEST_IDEAS' => 'Latest Ideas', 'LIST_DUPLICATE' => 'Duplicate ideas', - 'LIST_EGOSEARCH' => 'Your ideas', + 'LIST_EGOSEARCH' => 'My Ideas', 'LIST_IMPLEMENTED' => 'Implemented ideas', 'LIST_IN_PROGRESS' => 'In Progress ideas', 'LIST_INVALID' => 'Invalid ideas', diff --git a/styles/prosilver/template/event/navbar_header_profile_list_after.html b/styles/prosilver/template/event/navbar_header_profile_list_after.html new file mode 100644 index 00000000..079bfe2b --- /dev/null +++ b/styles/prosilver/template/event/navbar_header_profile_list_after.html @@ -0,0 +1,7 @@ +{% if U_SEARCH_MY_IDEAS %} +
  • + + {{ lang('LIST_EGOSEARCH') }} + +
  • +{% endif %} diff --git a/styles/prosilver/template/event/navbar_header_quick_links_before.html b/styles/prosilver/template/event/navbar_header_quick_links_before.html deleted file mode 100644 index c64cecd3..00000000 --- a/styles/prosilver/template/event/navbar_header_quick_links_before.html +++ /dev/null @@ -1,7 +0,0 @@ -{% if S_REGISTERED_USER and U_SEARCH_MY_IDEAS %} -
  • - - {{ lang('LIST_EGOSEARCH') }} - -
  • -{% endif %} diff --git a/styles/prosilver/template/index_body.html b/styles/prosilver/template/index_body.html index 27c04ad7..1cf73753 100644 --- a/styles/prosilver/template/index_body.html +++ b/styles/prosilver/template/index_body.html @@ -23,8 +23,7 @@

    {{ lang('TOP_IDEAS') }}

    - {% set ideas = top_ideas %} - {% include '@phpbb_ideas/index_list.html' %} + {% include '@phpbb_ideas/index_list.html' with {ideas: top_ideas} %} @@ -45,8 +44,7 @@

    {{ lang('LATEST_IDEAS') }}

    - {% set ideas = latest_ideas %} - {% include '@phpbb_ideas/index_list.html' %} + {% include '@phpbb_ideas/index_list.html' with {ideas: latest_ideas} %} @@ -67,8 +65,7 @@

    {{ lang('IMPLEMENTED_IDEAS') }}

    - {% set ideas = implemented_ideas %} - {% include '@phpbb_ideas/index_list.html' %} + {% include '@phpbb_ideas/index_list.html' with {ideas: implemented_ideas} %} diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 361fdcbb..36480ee4 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -106,6 +106,7 @@ public function test_construct() public function test_getSubscribedEvents() { self::assertEquals(array( + 'core.page_header', 'core.viewforum_get_topic_data', 'core.viewtopic_modify_post_row', 'core.viewtopic_modify_page_title', @@ -117,6 +118,36 @@ public function test_getSubscribedEvents() ), array_keys(\phpbb\ideas\event\listener::getSubscribedEvents())); } + public function global_template_vars_data() + { + return [ + 'registered user' => [true, false, true], + 'unregistered user' => [false, false, false], + 'is bot user' => [true, true, false], + 'is bot guest' => [false, true, false], + ]; + } + + /** + * @dataProvider global_template_vars_data + */ + public function test_global_template_vars($is_registered, $is_bot, $expected) + { + $this->user->data['is_registered'] = $is_registered; + $this->user->data['is_bot'] = $is_bot; + + $this->helper->expects($expected ? $this->once() : $this->never()) + ->method('route') + ->willReturn('phpbb_ideas_list_controller'); + + $this->template->expects($expected ? $this->once() : $this->never()) + ->method('assign_var') + ->with('U_SEARCH_MY_IDEAS', 'phpbb_ideas_list_controller'); + + $listener = $this->get_listener(); + $listener->global_template_vars(); + } + public function show_idea_data() { return [ diff --git a/tests/functional/ideas_test.php b/tests/functional/ideas_test.php index 36d11340..e7fc097f 100644 --- a/tests/functional/ideas_test.php +++ b/tests/functional/ideas_test.php @@ -75,14 +75,14 @@ public function test_view_ideas_lists() // Test my ideas list is empty when logged out $crawler = self::request('GET', "app.php/ideas/list/egosearch?status=-1&sid=$this->sid"); - $this->assertNotContainsLang('LIST_EGOSEARCH', $crawler->filter('#quick-links')->text()); + $this->assertNotContainsLang('LIST_EGOSEARCH', $crawler->filter('#nav-main')->text()); $this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('h2')->text()); $this->assertContainsLang('NO_IDEAS_DISPLAY', $crawler->filter('.topiclist.forums')->text()); // Test my ideas list works when logged in $this->login(); $crawler = self::request('GET', "app.php/ideas/list/egosearch?status=-1&sid=$this->sid"); - $this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('#quick-links')->text()); + $this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('#nav-main')->text()); $this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('h2')->text()); $this->assertNotContainsLang('NO_IDEAS_DISPLAY', $crawler->filter('.topiclist.forums')->text()); } diff --git a/textreparser/plugins/clean_old_ideas.php b/textreparser/plugins/clean_old_ideas.php index 25a90716..d03ed505 100644 --- a/textreparser/plugins/clean_old_ideas.php +++ b/textreparser/plugins/clean_old_ideas.php @@ -90,7 +90,7 @@ protected function get_records_by_range_query($min_id, $max_id) /** * {@inheritdoc} */ - protected function reparse_record(array $record) + protected function reparse_record(array $record, bool $force_bbcode_reparsing = false) { $text = $record['text'];