mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17100] Move legend generation to group helper
... and moved HTML to actual HTML files. PHPBB3-17100
This commit is contained in:
parent
9cee7a77d6
commit
97933380bb
5 changed files with 85 additions and 86 deletions
|
@ -86,52 +86,10 @@ if (($mark_notification = $request->variable('mark_notification', 0)))
|
||||||
|
|
||||||
display_forums('', $config['load_moderators']);
|
display_forums('', $config['load_moderators']);
|
||||||
|
|
||||||
$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
|
|
||||||
// Grab group details for legend display
|
|
||||||
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
|
|
||||||
{
|
|
||||||
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
|
|
||||||
FROM ' . GROUPS_TABLE . '
|
|
||||||
WHERE group_legend > 0
|
|
||||||
ORDER BY ' . $order_legend . ' ASC';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
|
|
||||||
FROM ' . GROUPS_TABLE . ' g
|
|
||||||
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
|
|
||||||
ON (
|
|
||||||
g.group_id = ug.group_id
|
|
||||||
AND ug.user_id = ' . $user->data['user_id'] . '
|
|
||||||
AND ug.user_pending = 0
|
|
||||||
)
|
|
||||||
WHERE g.group_legend > 0
|
|
||||||
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
|
|
||||||
ORDER BY g.' . $order_legend . ' ASC';
|
|
||||||
}
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
/** @var \phpbb\group\helper $group_helper */
|
/** @var \phpbb\group\helper $group_helper */
|
||||||
$group_helper = $phpbb_container->get('group_helper');
|
$group_helper = $phpbb_container->get('group_helper');
|
||||||
|
|
||||||
$legend = array();
|
$group_helper->display_legend($db, $template);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
|
|
||||||
$group_name = $group_helper->get_name($row['group_name']);
|
|
||||||
|
|
||||||
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
|
|
||||||
{
|
|
||||||
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$legend = implode($user->lang['COMMA_SEPARATOR'], $legend);
|
|
||||||
|
|
||||||
// Generate birthday list if required ...
|
// Generate birthday list if required ...
|
||||||
$show_birthdays = ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'));
|
$show_birthdays = ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'));
|
||||||
|
@ -219,7 +177,6 @@ $template->assign_vars(array(
|
||||||
'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']),
|
'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']),
|
||||||
'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
|
'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
|
||||||
|
|
||||||
'LEGEND' => $legend,
|
|
||||||
'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),
|
'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),
|
||||||
|
|
||||||
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
|
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
|
||||||
|
|
|
@ -17,9 +17,11 @@ use phpbb\auth\auth;
|
||||||
use phpbb\avatar\helper as avatar_helper;
|
use phpbb\avatar\helper as avatar_helper;
|
||||||
use phpbb\cache\service as cache;
|
use phpbb\cache\service as cache;
|
||||||
use phpbb\config\config;
|
use phpbb\config\config;
|
||||||
|
use phpbb\db\driver\driver_interface;
|
||||||
use phpbb\language\language;
|
use phpbb\language\language;
|
||||||
use phpbb\event\dispatcher_interface;
|
use phpbb\event\dispatcher_interface;
|
||||||
use phpbb\path_helper;
|
use phpbb\path_helper;
|
||||||
|
use phpbb\template\template;
|
||||||
use phpbb\user;
|
use phpbb\user;
|
||||||
|
|
||||||
class helper
|
class helper
|
||||||
|
@ -294,8 +296,56 @@ class helper
|
||||||
*
|
*
|
||||||
* @return array Avatar data
|
* @return array Avatar data
|
||||||
*/
|
*/
|
||||||
function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
|
public function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
|
||||||
{
|
{
|
||||||
return $this->avatar_helper->get_group_avatar($group_row, $alt, $ignore_config, $lazy);
|
return $this->avatar_helper->get_group_avatar($group_row, $alt, $ignore_config, $lazy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display groups legend
|
||||||
|
*
|
||||||
|
* @param driver_interface $db
|
||||||
|
* @param template $template
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function display_legend(driver_interface $db, template $template): void
|
||||||
|
{
|
||||||
|
$order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
|
||||||
|
|
||||||
|
// Grab group details for legend display
|
||||||
|
if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
|
||||||
|
{
|
||||||
|
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
|
||||||
|
FROM ' . GROUPS_TABLE . '
|
||||||
|
WHERE group_legend > 0
|
||||||
|
ORDER BY ' . $order_legend . ' ASC';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
|
||||||
|
FROM ' . GROUPS_TABLE . ' g
|
||||||
|
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
|
||||||
|
ON (
|
||||||
|
g.group_id = ug.group_id
|
||||||
|
AND ug.user_id = ' . $this->user->data['user_id'] . '
|
||||||
|
AND ug.user_pending = 0
|
||||||
|
)
|
||||||
|
WHERE g.group_legend > 0
|
||||||
|
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $this->user->data['user_id'] . ')
|
||||||
|
ORDER BY g.' . $order_legend . ' ASC';
|
||||||
|
}
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$show_group_url = $row['group_name'] != 'BOTS' && $this->auth->acl_get('u_viewprofile');
|
||||||
|
|
||||||
|
$template->assign_block_vars('LEGEND', [
|
||||||
|
'GROUP_COLOR' => $row['group_colour'] ?: '',
|
||||||
|
'GROUP_NAME' => $this->get_name($row['group_name']),
|
||||||
|
'GROUP_URL' => $show_group_url ? append_sid("{$this->path_helper->get_phpbb_root_path()}memberlist.{$this->path_helper->get_php_ext()}", 'mode=group&g=' . $row['group_id']) : '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,21 @@
|
||||||
{TOTAL_USERS_ONLINE} ({L_ONLINE_EXPLAIN})<br />{RECORD_USERS}<br />
|
{TOTAL_USERS_ONLINE} ({L_ONLINE_EXPLAIN})<br />{RECORD_USERS}<br />
|
||||||
<!-- IF U_VIEWONLINE -->
|
<!-- IF U_VIEWONLINE -->
|
||||||
<br />{LOGGED_IN_USER_LIST}
|
<br />{LOGGED_IN_USER_LIST}
|
||||||
<!-- IF LEGEND --><br /><em>{L_LEGEND}{L_COLON} {LEGEND}</em><!-- ENDIF -->
|
{% if LEGEND|length > 0 %}
|
||||||
|
{% apply spaceless %}
|
||||||
|
<br>
|
||||||
|
<em>
|
||||||
|
{{ lang('LEGEND') ~ lang('COLON') }}
|
||||||
|
{% for group in LEGEND %}
|
||||||
|
{% if group.GROUP_URL %}
|
||||||
|
<a style="color:#{{ group.GROUP_COLOR }}" href="{{ group.GROUP_URL }}" alt="{{ group.GROUP_NAME }}">{{ group.GROUP_NAME }}</a>{% if not loop.last %}, {% endif %}
|
||||||
|
{% else %}
|
||||||
|
<span style="color:#{{ group.GROUP_COLOR }}">{{ group.GROUP_NAME }}</span>{% if not loop.last %}, {% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</em>
|
||||||
|
{% endapply %}
|
||||||
|
{% endif %}
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
<!-- EVENT index_body_block_online_append -->
|
<!-- EVENT index_body_block_online_append -->
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -47,7 +47,22 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- IF LEGEND --><p><em>{L_LEGEND}{L_COLON} {LEGEND}</em></p><!-- ENDIF -->
|
{% if LEGEND|length > 0 %}
|
||||||
|
{% apply spaceless %}
|
||||||
|
<p>
|
||||||
|
<em>
|
||||||
|
{{ lang('LEGEND') ~ lang('COLON') }}
|
||||||
|
{% for group in LEGEND %}
|
||||||
|
{% if group.GROUP_URL %}
|
||||||
|
<a style="color:#{{ group.GROUP_COLOR }}" href="{{ group.GROUP_URL }}" alt="{{ group.GROUP_NAME }}">{{ group.GROUP_NAME }}</a>{% if not loop.last %}, {% endif %}
|
||||||
|
{% else %}
|
||||||
|
<span style="color:#{{ group.GROUP_COLOR }}">{{ group.GROUP_NAME }}</span>{% if not loop.last %}, {% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</em>
|
||||||
|
</p>
|
||||||
|
{% endapply %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="action-bar bar-bottom">
|
<div class="action-bar bar-bottom">
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
|
|
@ -441,44 +441,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
unset($prev_id, $prev_ip);
|
unset($prev_id, $prev_ip);
|
||||||
|
|
||||||
$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
|
$group_helper->display_legend($db, $template);
|
||||||
// Grab group details for legend display
|
|
||||||
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
|
|
||||||
{
|
|
||||||
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
|
|
||||||
FROM ' . GROUPS_TABLE . '
|
|
||||||
WHERE group_legend > 0
|
|
||||||
ORDER BY ' . $order_legend . ' ASC';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
|
|
||||||
FROM ' . GROUPS_TABLE . ' g
|
|
||||||
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
|
|
||||||
ON (
|
|
||||||
g.group_id = ug.group_id
|
|
||||||
AND ug.user_id = ' . $user->data['user_id'] . '
|
|
||||||
AND ug.user_pending = 0
|
|
||||||
)
|
|
||||||
WHERE g.group_legend > 0
|
|
||||||
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
|
|
||||||
ORDER BY g.' . $order_legend . ' ASC';
|
|
||||||
}
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$legend = '';
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
if ($row['group_name'] == 'BOTS')
|
|
||||||
{
|
|
||||||
$legend .= (($legend != '') ? ', ' : '') . '<span style="color:#' . $row['group_colour'] . '">' . $user->lang['G_BOTS'] . '</span>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$legend .= (($legend != '') ? ', ' : '') . '<a style="color:#' . $row['group_colour'] . '" href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_helper->get_name($row['group_name']) . '</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
// Refreshing the page every 60 seconds...
|
// Refreshing the page every 60 seconds...
|
||||||
meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir&start=$start"));
|
meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir&start=$start"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue