Skip to content
Permalink
Browse files

! Fixed #80. This is why I never use switch() in my code: it's confus…

…ing (PHP 7.3 seems to report a bug here), and it's longer than if() tests. Rewrote this one to something understandable, and not buggy. (Subs.php)
  • Loading branch information...
Nao committed Jun 26, 2019
1 parent a0fe1de commit 8b92ee855787b9d5b3513f224cc50f2123c8ffe0
Showing with 8 additions and 26 deletions.
  1. +8 −26 core/app/Subs.php
@@ -1651,32 +1651,14 @@ function setupThemeContext($forceload = false)
foreach ($context['news_lines'] as $id => &$item)
{
// The letter is allowed to be e, m, s or a for everyone, signed-in members, staff or admins only
switch ($item[0])
{
case 'a':
if (!we::$is_admin && !allowedTo('admin_forum'))
{
unset($context['news_lines'][$id]);
continue;
}
break;
case 's':
if (!we::$is_admin && !allowedTo(array('moderate_forum', 'moderate_board')))
{
unset($context['news_lines'][$id]);
continue;
}
break;
case 'm':
if (we::$is_guest)
{
unset($context['news_lines'][$id]);
continue;
}
break;
}
$item = substr($item, 1);
if ($item[0] === 'a' && !we::$is_admin && !allowedTo('admin_forum'))
unset($context['news_lines'][$id]);
elseif ($item[0] === 's' && !we::$is_admin && !allowedTo(array('moderate_forum', 'moderate_board')))
unset($context['news_lines'][$id]);
elseif ($item[0] === 'm' && we::$is_guest)
unset($context['news_lines'][$id]);
else
$item = substr($item, 1);
}
$context['fader_news_lines'] = array();
// Gotta be special for the javascript.

0 comments on commit 8b92ee8

Please sign in to comment.
You can’t perform that action at this time.