Skip to content

Commit 624076f

Browse files
committed
Do not show navbar manager if no menu has been selected
1 parent 968c4bb commit 624076f

File tree

4 files changed

+19
-31
lines changed

4 files changed

+19
-31
lines changed

event/sitemaker.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ public function show_sitemaker()
9393
[$style_name] = $this->template->get_user_style();
9494
$navbar = $this->navigation->get_settings($style_name);
9595

96-
if ($navbar['location'])
96+
if ($this->config['sm_navbar_menu'] && $navbar['location'])
9797
{
9898
$this->template->assign_vars(array_merge(
9999
array(
100100
'STYLE_NAME' => $style_name,
101101
'NAVBAR_LOCATION' => $navbar['location'],
102102
'NAVBAR_CSS' => $this->controller_helper->route('blitze_sitemaker_navbar_css', array(
103103
'style' => $style_name,
104-
'hash' => $navbar['last_modified']
104+
'hash' => $navbar['modified']
105105
)),
106106
),
107-
$this->navigation->build_menu($navbar['menu_id'], true)
107+
$this->navigation->build_menu($this->config['sm_navbar_menu'], true)
108108
));
109109
}
110110

services/navbar.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,9 @@ public function __construct(\phpbb\config\config $config, \phpbb\config\db_text
4646
*/
4747
public function get_settings($style)
4848
{
49-
if (!$menu_id = $this->config['sm_navbar_menu'])
50-
{
51-
return [
52-
'menu_id' => 0,
53-
'location' => '',
54-
'last_modified' => 0
55-
];
56-
}
57-
58-
$locations = $this->get_locations();
59-
6049
return [
61-
'menu_id' => $menu_id,
62-
'location' => &$locations[$style],
63-
'last_modified' => $this->get_last_modified(),
50+
'location' => &$this->get_locations()[$style],
51+
'modified' => $this->get_last_modified(),
6452
];
6553
}
6654

styles/all/template/navbar/location_base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{% set navbar_manager = '' %}
99
{% set default_location = 'overall_header_headerbar_after' %}
1010
{% set location_class = 'sm-navbar-location' %}
11-
{% if location === NAVBAR_LOCATION|default(default_location) %}
11+
{% if location === NAVBAR_LOCATION || (NAVBAR_LOCATION is defined && location === default_location) %}
1212
{% set navbar_manager %}
1313
<button id="sm-navbar-edit-btn"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></button>
1414
{% include('@blitze_sitemaker/navbar/manager.html') %}

tests/event/sitemaker_test.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ public function show_sitemaker_test_data()
146146
array(
147147
false,
148148
array(
149+
'sm_navbar_menu' => 0,
149150
'sm_hide_birthday' => true,
150151
'sm_hide_login' => true,
151152
'sm_hide_online' => true,
152153
'sm_show_forum_nav' => true,
153154
'sitemaker_startpage_controller' => '',
154155
),
155156
array(
156-
'menu_id' => 0,
157-
'location' => '',
158-
'last_modified' => 0,
157+
'location' => '',
158+
'modified' => 0,
159159
),
160160
array(
161161
'S_USER_LOGGED_IN' => true,
@@ -167,16 +167,16 @@ public function show_sitemaker_test_data()
167167
array(
168168
true,
169169
array(
170+
'sm_navbar_menu' => 2,
170171
'sm_hide_birthday' => true,
171172
'sm_hide_login' => true,
172173
'sm_hide_online' => true,
173174
'sm_show_forum_nav' => true,
174175
'sitemaker_startpage_controller' => '',
175176
),
176177
array(
177-
'menu_id' => 2,
178-
'location' => '',
179-
'last_modified' => 0,
178+
'location' => '',
179+
'modified' => 0,
180180
),
181181
array(
182182
'S_USER_LOGGED_IN' => true,
@@ -188,16 +188,16 @@ public function show_sitemaker_test_data()
188188
array(
189189
false,
190190
array(
191+
'sm_navbar_menu' => 2,
191192
'sm_hide_birthday' => false,
192193
'sm_hide_login' => false,
193194
'sm_hide_online' => false,
194195
'sm_show_forum_nav' => false,
195196
'sitemaker_startpage_controller' => 'some_controller',
196197
),
197198
array(
198-
'menu_id' => 2,
199-
'location' => 'some location',
200-
'last_modified' => 123456789,
199+
'location' => 'some location',
200+
'modified' => 123456789,
201201
),
202202
array(
203203
'S_USER_LOGGED_IN' => false,
@@ -213,16 +213,16 @@ public function show_sitemaker_test_data()
213213
array(
214214
true,
215215
array(
216+
'sm_navbar_menu' => 3,
216217
'sm_hide_birthday' => true,
217218
'sm_hide_login' => false,
218219
'sm_hide_online' => true,
219220
'sm_show_forum_nav' => true,
220221
'sitemaker_startpage_controller' => 'some_controller',
221222
),
222223
array(
223-
'menu_id' => 3,
224-
'location' => 'other location',
225-
'last_modified' => 213564546,
224+
'location' => 'other location',
225+
'modified' => 213564546,
226226
),
227227
array(
228228
'S_USER_LOGGED_IN' => true,
@@ -289,7 +289,7 @@ public function test_show_sitemaker($user_is_logged_in, array $config_data, arra
289289
->method('get_user_style')
290290
->willReturn(['prosilver']);
291291

292-
$this->navigation->expects($this->once())
292+
$this->navigation->expects($this->exactly(1))
293293
->method('get_settings')
294294
->with('prosilver')
295295
->willReturn($navbar_settings);

0 commit comments

Comments
 (0)