Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions controller/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']),
]);
}
}
18 changes: 17 additions & 1 deletion event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
*
Expand Down Expand Up @@ -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'),
));

Expand Down
2 changes: 1 addition & 1 deletion language/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if U_SEARCH_MY_IDEAS %}
<li>
<a href="{{ U_SEARCH_MY_IDEAS }}" title="{{ lang('LIST_EGOSEARCH') }}" role="menuitem">
<i class="icon fa-lightbulb-o fa-fw" aria-hidden="true"></i><span>{{ lang('LIST_EGOSEARCH') }}</span>
</a>
</li>
{% endif %}

This file was deleted.

9 changes: 3 additions & 6 deletions styles/prosilver/template/index_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ <h2>{{ lang('TOP_IDEAS') }}</h2>
</dl>
</li>
</ul>
{% set ideas = top_ideas %}
{% include '@phpbb_ideas/index_list.html' %}
{% include '@phpbb_ideas/index_list.html' with {ideas: top_ideas} %}
</div>
</div>

Expand All @@ -45,8 +44,7 @@ <h2>{{ lang('LATEST_IDEAS') }}</h2>
</dl>
</li>
</ul>
{% set ideas = latest_ideas %}
{% include '@phpbb_ideas/index_list.html' %}
{% include '@phpbb_ideas/index_list.html' with {ideas: latest_ideas} %}
</div>
</div>

Expand All @@ -67,8 +65,7 @@ <h2>{{ lang('IMPLEMENTED_IDEAS') }}</h2>
</dl>
</li>
</ul>
{% set ideas = implemented_ideas %}
{% include '@phpbb_ideas/index_list.html' %}
{% include '@phpbb_ideas/index_list.html' with {ideas: implemented_ideas} %}
</div>
</div>

Expand Down
31 changes: 31 additions & 0 deletions tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 [
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/ideas_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion textreparser/plugins/clean_old_ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down