Skip to content

Commit

Permalink
Merge pull request #14 from VSEphpbb/updates/improvements
Browse files Browse the repository at this point in the history
Return early when announcement is disabled
  • Loading branch information
michaelcullum committed Jun 20, 2014
2 parents b83dc9b + 449d2be commit 153b1aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public function display_board_announcements($event)
'announcement_timestamp',
));

// Get announcement cookie if one exists
$cookie = $this->request->variable($this->config['cookie_name'] . '_ba_' . $board_announcement_data['announcement_timestamp'], '', true, \phpbb\request\request_interface::COOKIE);

// Do not continue if announcement has been disabled or dismissed
if (!$this->config['board_announcements_enable'] || !$this->user->data['board_announcements_status'] || $cookie)
{
return;
}

// Prepare board announcement message for display
$announcement_message = generate_text_for_display(
$board_announcement_data['announcement_text'],
Expand All @@ -115,16 +124,9 @@ public function display_board_announcements($event)
$board_announcement_data['announcement_options']
);

// Display announcement conditions
$display_announcement = (
$this->config['board_announcements_enable'] &&
$this->user->data['board_announcements_status'] &&
!$this->request->variable($this->config['cookie_name'] . '_ba_' . $board_announcement_data['announcement_timestamp'], '', true, \phpbb\request\request_interface::COOKIE)
) ? true : false;

// Output board announcement to the template
$this->template->assign_vars(array(
'S_BOARD_ANNOUNCEMENT' => $display_announcement,
'S_BOARD_ANNOUNCEMENT' => true,

'BOARD_ANNOUNCEMENT' => $announcement_message,
'BOARD_ANNOUNCEMENT_BGCOLOR' => $board_announcement_data['announcement_bgcolor'],
Expand Down
2 changes: 1 addition & 1 deletion styles/all/theme/boardannouncements.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* zero out any text margins and scroll any overflow */
#phpbb_announcement .inner p {
margin: 0;
overflow-x: scroll;
overflow-x: auto;
}

/* style the close button */
Expand Down

0 comments on commit 153b1aa

Please sign in to comment.