Skip to content

Commit 491d223

Browse files
committed
Move My Ideas link to user drop down
1 parent f04dc5a commit 491d223

6 files changed

Lines changed: 56 additions & 12 deletions

File tree

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.

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 [

0 commit comments

Comments
 (0)