Skip to content

Commit 851f71d

Browse files
authored
Merge pull request #155 from iMattPro/links
Move My Ideas link
2 parents f04dc5a + e436a6b commit 851f71d

11 files changed

Lines changed: 66 additions & 25 deletions

File tree

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,14 @@ jobs:
368368
db: "mcr.microsoft.com/mssql/server:2017-latest"
369369
db_alias: 'MSSQL 2017'
370370
- php: '7.2'
371-
db: "mcr.microsoft.com/mssql/server:2019-latest"
371+
db: "mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04"
372372
db_alias: 'MSSQL 2019'
373373

374374
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
375375

376376
services:
377377
mssql:
378-
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 }}
378+
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 }}
379379
env:
380380
SA_PASSWORD: "Pssw0rd_12"
381381
ACCEPT_EULA: "y"
@@ -415,7 +415,7 @@ jobs:
415415
env:
416416
MATRIX_DB: ${{ matrix.db }}
417417
run: |
418-
if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-latest' ]
418+
if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ]
419419
then
420420
db='mssql'
421421
else

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
[![Build Status](https://github.com/phpbb/ideas/workflows/Tests/badge.svg)](https://github.com/phpbb/ideas/actions)
5+
[![Build Status](https://github.com/phpbb/ideas/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbb/ideas/actions)
66
[![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)
77

88
## Contribute

controller/base.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use phpbb\auth\auth;
1414
use phpbb\config\config;
1515
use phpbb\controller\helper;
16-
use phpbb\ideas\ext;
1716
use phpbb\ideas\factory\linkhelper;
1817
use phpbb\language\language;
1918
use phpbb\pagination;
@@ -151,8 +150,6 @@ protected function display_common_vars()
151150
'S_DISPLAY_SEARCHBOX' => $this->auth->acl_get('u_search') && $this->auth->acl_get('f_search', $this->config['ideas_forum_id']) && $this->config['load_search'],
152151
'S_SEARCHBOX_ACTION' => append_sid("{$this->root_path}search.$this->php_ext"),
153152
'S_SEARCH_IDEAS_HIDDEN_FIELDS' => build_hidden_fields(['fid' => [$this->config['ideas_forum_id']]]),
154-
155-
'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1']),
156153
]);
157154
}
158155
}

event/listener.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function __construct(auth $auth, config $config, helper $helper, idea $id
8282
public static function getSubscribedEvents()
8383
{
8484
return array(
85+
'core.page_header' => 'global_template_vars',
8586
'core.viewforum_get_topic_data' => 'ideas_forum_redirect',
8687
'core.viewtopic_modify_post_row' => 'show_post_buttons',
8788
'core.viewtopic_modify_page_title' => 'show_idea',
@@ -93,6 +94,22 @@ public static function getSubscribedEvents()
9394
);
9495
}
9596

97+
/**
98+
* Assign global template variables
99+
*
100+
* @return void
101+
*/
102+
public function global_template_vars()
103+
{
104+
if ($this->user->data['is_registered'] && !$this->user->data['is_bot'])
105+
{
106+
$this->template->assign_var(
107+
'U_SEARCH_MY_IDEAS',
108+
$this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1'])
109+
);
110+
}
111+
}
112+
96113
/**
97114
* Redirect users from the forum to the Ideas centre
98115
*
@@ -223,7 +240,6 @@ public function show_idea($event)
223240
'U_IDEA_VOTE' => $this->link_helper->get_idea_link($idea['idea_id'], 'vote', true),
224241
'U_IDEA_DUPLICATE' => $this->link_helper->get_idea_link($idea['duplicate_id']),
225242
'U_IDEA_STATUS_LINK'=> $this->helper->route('phpbb_ideas_list_controller', ['status' => $idea['idea_status']]),
226-
'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_MYIDEAS, 'status' => '-1']),
227243
'U_TITLE_LIVESEARCH'=> $this->helper->route('phpbb_ideas_livesearch_controller'),
228244
));
229245

language/en/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
'LATEST_IDEAS' => 'Latest Ideas',
5656
'LIST_DUPLICATE' => 'Duplicate ideas',
57-
'LIST_EGOSEARCH' => 'Your ideas',
57+
'LIST_EGOSEARCH' => 'My Ideas',
5858
'LIST_IMPLEMENTED' => 'Implemented ideas',
5959
'LIST_IN_PROGRESS' => 'In Progress ideas',
6060
'LIST_INVALID' => 'Invalid ideas',
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% if U_SEARCH_MY_IDEAS %}
2+
<li>
3+
<a href="{{ U_SEARCH_MY_IDEAS }}" title="{{ lang('LIST_EGOSEARCH') }}" role="menuitem">
4+
<i class="icon fa-lightbulb-o fa-fw" aria-hidden="true"></i><span>{{ lang('LIST_EGOSEARCH') }}</span>
5+
</a>
6+
</li>
7+
{% endif %}

styles/prosilver/template/event/navbar_header_quick_links_before.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

styles/prosilver/template/index_body.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ <h2>{{ lang('TOP_IDEAS') }}</h2>
2323
</dl>
2424
</li>
2525
</ul>
26-
{% set ideas = top_ideas %}
27-
{% include '@phpbb_ideas/index_list.html' %}
26+
{% include '@phpbb_ideas/index_list.html' with {ideas: top_ideas} %}
2827
</div>
2928
</div>
3029

@@ -45,8 +44,7 @@ <h2>{{ lang('LATEST_IDEAS') }}</h2>
4544
</dl>
4645
</li>
4746
</ul>
48-
{% set ideas = latest_ideas %}
49-
{% include '@phpbb_ideas/index_list.html' %}
47+
{% include '@phpbb_ideas/index_list.html' with {ideas: latest_ideas} %}
5048
</div>
5149
</div>
5250

@@ -67,8 +65,7 @@ <h2>{{ lang('IMPLEMENTED_IDEAS') }}</h2>
6765
</dl>
6866
</li>
6967
</ul>
70-
{% set ideas = implemented_ideas %}
71-
{% include '@phpbb_ideas/index_list.html' %}
68+
{% include '@phpbb_ideas/index_list.html' with {ideas: implemented_ideas} %}
7269
</div>
7370
</div>
7471

tests/event/listener_test.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function test_construct()
106106
public function test_getSubscribedEvents()
107107
{
108108
self::assertEquals(array(
109+
'core.page_header',
109110
'core.viewforum_get_topic_data',
110111
'core.viewtopic_modify_post_row',
111112
'core.viewtopic_modify_page_title',
@@ -117,6 +118,36 @@ public function test_getSubscribedEvents()
117118
), array_keys(\phpbb\ideas\event\listener::getSubscribedEvents()));
118119
}
119120

121+
public function global_template_vars_data()
122+
{
123+
return [
124+
'registered user' => [true, false, true],
125+
'unregistered user' => [false, false, false],
126+
'is bot user' => [true, true, false],
127+
'is bot guest' => [false, true, false],
128+
];
129+
}
130+
131+
/**
132+
* @dataProvider global_template_vars_data
133+
*/
134+
public function test_global_template_vars($is_registered, $is_bot, $expected)
135+
{
136+
$this->user->data['is_registered'] = $is_registered;
137+
$this->user->data['is_bot'] = $is_bot;
138+
139+
$this->helper->expects($expected ? $this->once() : $this->never())
140+
->method('route')
141+
->willReturn('phpbb_ideas_list_controller');
142+
143+
$this->template->expects($expected ? $this->once() : $this->never())
144+
->method('assign_var')
145+
->with('U_SEARCH_MY_IDEAS', 'phpbb_ideas_list_controller');
146+
147+
$listener = $this->get_listener();
148+
$listener->global_template_vars();
149+
}
150+
120151
public function show_idea_data()
121152
{
122153
return [

tests/functional/ideas_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ public function test_view_ideas_lists()
7575

7676
// Test my ideas list is empty when logged out
7777
$crawler = self::request('GET', "app.php/ideas/list/egosearch?status=-1&sid=$this->sid");
78-
$this->assertNotContainsLang('LIST_EGOSEARCH', $crawler->filter('#quick-links')->text());
78+
$this->assertNotContainsLang('LIST_EGOSEARCH', $crawler->filter('#nav-main')->text());
7979
$this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('h2')->text());
8080
$this->assertContainsLang('NO_IDEAS_DISPLAY', $crawler->filter('.topiclist.forums')->text());
8181

8282
// Test my ideas list works when logged in
8383
$this->login();
8484
$crawler = self::request('GET', "app.php/ideas/list/egosearch?status=-1&sid=$this->sid");
85-
$this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('#quick-links')->text());
85+
$this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('#nav-main')->text());
8686
$this->assertContainsLang('LIST_EGOSEARCH', $crawler->filter('h2')->text());
8787
$this->assertNotContainsLang('NO_IDEAS_DISPLAY', $crawler->filter('.topiclist.forums')->text());
8888
}

0 commit comments

Comments
 (0)