1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-07 16:15:22 +02:00

[ticket/10411] Use new teampage and legend class in ACP and memberlist

PHPBB3-10411
This commit is contained in:
Joas Schilling 2012-11-13 15:32:35 +01:00
parent 53cb148d70
commit 6a27a95f30
4 changed files with 184 additions and 56 deletions

View File

@ -108,6 +108,8 @@
<p>{L_TEAMPAGE_EXPLAIN}</p> <p>{L_TEAMPAGE_EXPLAIN}</p>
<!-- IF S_TEAMPAGE_CATEGORY and CUR_CATEGORY_NAME --><p><strong><a href="{U_ACTION}">{L_TEAMPAGE}</a> &raquo; {CUR_CATEGORY_NAME}</strong></p><!-- ENDIF -->
<table cellspacing="1"> <table cellspacing="1">
<col class="col1" /><col class="col2" /><col class="col2" /> <col class="col1" /><col class="col2" /><col class="col2" />
<thead> <thead>
@ -120,8 +122,15 @@
<tbody> <tbody>
<!-- BEGIN teampage --> <!-- BEGIN teampage -->
<tr> <tr>
<td><strong{teampage.GROUP_COLOUR}>{teampage.GROUP_NAME}</strong></td> <td>
<td style="text-align: center;">{teampage.GROUP_TYPE}</td> <!-- IF teampage.U_CATEGORY -->
<a href="{teampage.U_CATEGORY}">{teampage.GROUP_NAME}</a>
<!-- ELSE -->
<strong{teampage.GROUP_COLOUR}>{teampage.GROUP_NAME}</strong>
<!-- ENDIF -->
</td>
<td style="text-align: center;"><!-- IF teampage.GROUP_TYPE -->{teampage.GROUP_TYPE}<!-- ELSE -->-<!-- ENDIF -->
</td></td>
<td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;"> <td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;">
<!-- IF teampage.S_FIRST_ROW && not teampage.S_LAST_ROW --> <!-- IF teampage.S_FIRST_ROW && not teampage.S_LAST_ROW -->
{ICON_MOVE_UP_DISABLED} {ICON_MOVE_UP_DISABLED}
@ -147,6 +156,17 @@
</tbody> </tbody>
</table> </table>
<!-- IF not S_TEAMPAGE_CATEGORY -->
<form id="teampage_add_category" method="post" action="{U_ACTION_TEAMPAGE}">
<fieldset class="quick">
<input class="inputbox autowidth" type="text" name="category_name" placeholder="{L_CATEGORY_NAME}" />
<input class="button2" type="submit" name="submit" value="{L_ADD_CATEGORY}" />
<input type="hidden" name="action" value="add_category" />
{S_FORM_TOKEN}
</fieldset>
</form>
<!-- ENDIF -->
<form id="teampage_add_group" method="post" action="{U_ACTION_TEAMPAGE}"> <form id="teampage_add_group" method="post" action="{U_ACTION_TEAMPAGE}">
<fieldset class="quick"> <fieldset class="quick">
<select name="g"><option value="0">{L_SELECT_GROUP}</option>{S_GROUP_SELECT_TEAMPAGE}</select> <select name="g"><option value="0">{L_SELECT_GROUP}</option>{S_GROUP_SELECT_TEAMPAGE}</select>

View File

@ -811,7 +811,7 @@ class acp_groups
public function manage_position() public function manage_position()
{ {
global $config, $db, $template, $user; global $config, $db, $template, $user, $request;
$this->tpl_name = 'acp_groups_position'; $this->tpl_name = 'acp_groups_position';
$this->page_title = 'ACP_GROUPS_POSITION'; $this->page_title = 'ACP_GROUPS_POSITION';
@ -819,48 +819,90 @@ class acp_groups
$field = request_var('field', ''); $field = request_var('field', '');
$action = request_var('action', ''); $action = request_var('action', '');
$group_id = request_var('g', 0); $group_id = request_var('g', 0);
$teampage_id = request_var('t', 0);
$category_id = request_var('c', 0);
if ($field && !in_array($field, array('legend', 'teampage'))) if ($field && !in_array($field, array('legend', 'teampage')))
{ {
// Invalid mode // Invalid mode
trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
else if ($field) else if ($field == 'legend')
{ {
$group_position = new phpbb_group_positions($db, $field, $this->u_action); $group_position = new phpbb_groupposition_legend($db, $user, $this->u_action);
}
else if ($field == 'teampage')
{
$group_position = new phpbb_groupposition_teampage($db, $user, $this->u_action);
} }
switch ($action) if ($field == 'teampage')
{ {
case 'set_config_legend': switch ($action)
set_config('legend_sort_groupname', request_var('legend_sort_groupname', 0)); {
break; case 'add':
$group_position->add_group_teampage($group_id, $category_id);
break;
case 'set_config_teampage': case 'add_category':
set_config('teampage_forums', request_var('teampage_forums', 0)); $group_position->add_category_teampage($request->variable('category_name', '', true));
set_config('teampage_memberships', request_var('teampage_memberships', 0)); break;
break;
case 'add': case 'delete':
$group_position->add_group($group_id); $group_position->delete_teampage($teampage_id);
break; break;
case 'delete': case 'move_up':
$group_position->delete_group($group_id); $group_position->move_up_teampage($teampage_id);
break; break;
case 'move_up': case 'move_down':
$group_position->move_up($group_id); $group_position->move_down_teampage($teampage_id);
break; break;
}
case 'move_down': global $cache;
$group_position->move_down($group_id); $cache->destroy('sql', TEAMPAGE_TABLE);
break; }
else if ($field == 'legend')
{
switch ($action)
{
case 'add':
$group_position->add_group($group_id);
break;
case 'delete':
$group_position->delete_group($group_id);
break;
case 'move_up':
$group_position->move_up($group_id);
break;
case 'move_down':
$group_position->move_down($group_id);
break;
}
}
else
{
switch ($action)
{
case 'set_config_teampage':
set_config('teampage_forums', $request->variable('teampage_forums', 0));
set_config('teampage_memberships', $request->variable('teampage_memberships', 0));
break;
case 'set_config_legend':
set_config('legend_sort_groupname', $request->variable('legend_sort_groupname', 0));
break;
}
} }
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_legend, group_name ASC'; ORDER BY group_legend ASC, group_type DESC, group_name ASC';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$s_group_select_legend = ''; $s_group_select_legend = '';
@ -872,7 +914,7 @@ class acp_groups
$template->assign_block_vars('legend', array( $template->assign_block_vars('legend', array(
'GROUP_NAME' => $group_name, 'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '', 'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '',
'GROUP_TYPE' => $user->lang[phpbb_group_positions::group_type_language($row['group_type'])], 'GROUP_TYPE' => $user->lang[phpbb_groupposition_legend::group_type_language($row['group_type'])],
'U_MOVE_DOWN' => "{$this->u_action}&amp;field=legend&amp;action=move_down&amp;g=" . $row['group_id'], 'U_MOVE_DOWN' => "{$this->u_action}&amp;field=legend&amp;action=move_down&amp;g=" . $row['group_id'],
'U_MOVE_UP' => "{$this->u_action}&amp;field=legend&amp;action=move_up&amp;g=" . $row['group_id'], 'U_MOVE_UP' => "{$this->u_action}&amp;field=legend&amp;action=move_up&amp;g=" . $row['group_id'],
@ -881,46 +923,82 @@ class acp_groups
} }
else else
{ {
$s_group_select_legend .= '<option value="' . (int) $row['group_id'] . '">' . $group_name . '</option>'; $s_group_select_legend .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . (int) $row['group_id'] . '">' . $group_name . '</option>';
} }
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_teampage $category_url_param = (($category_id) ? '&amp;c=' . $category_id : '');
FROM ' . GROUPS_TABLE . '
ORDER BY group_teampage, group_name ASC'; $sql = 'SELECT t.*, g.group_name, g.group_colour, g.group_type
FROM ' . TEAMPAGE_TABLE . ' t
LEFT JOIN ' . GROUPS_TABLE . ' g
ON (t.group_id = g.group_id)
WHERE t.teampage_parent = ' . $category_id . '
OR t.teampage_id = ' . $category_id . '
ORDER BY t.teampage_position ASC';
$result = $db->sql_query($sql);
$category_data = array();
while ($row = $db->sql_fetchrow($result))
{
if ($row['teampage_id'] == $category_id)
{
$template->assign_vars(array(
'CUR_CATEGORY_NAME' => $row['teampage_name'],
));
continue;
}
if ($row['group_id'])
{
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
$group_type = $user->lang[phpbb_groupposition_teampage::group_type_language($row['group_type'])];
}
else
{
$group_name = $row['teampage_name'];
$group_type = '';
}
$template->assign_block_vars('teampage', array(
'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '',
'GROUP_TYPE' => $group_type,
'U_CATEGORY' => (!$row['group_id']) ? "{$this->u_action}&amp;c=" . $row['teampage_id'] : '',
'U_MOVE_DOWN' => "{$this->u_action}&amp;field=teampage&amp;action=move_down{$category_url_param}&amp;t=" . $row['teampage_id'],
'U_MOVE_UP' => "{$this->u_action}&amp;field=teampage&amp;action=move_up{$category_url_param}&amp;t=" . $row['teampage_id'],
'U_DELETE' => "{$this->u_action}&amp;field=teampage&amp;action=delete{$category_url_param}&amp;t=" . $row['teampage_id'],
));
}
$db->sql_freeresult($result);
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . TEAMPAGE_TABLE . ' t
ON (t.group_id = g.group_id)
WHERE t.teampage_id IS NULL
ORDER BY g.group_type DESC, g.group_name ASC';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$s_group_select_teampage = ''; $s_group_select_teampage = '';
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
if ($row['group_teampage']) $s_group_select_teampage .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . (int) $row['group_id'] . '">' . $group_name . '</option>';
{
$template->assign_block_vars('teampage', array(
'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '',
'GROUP_TYPE' => $user->lang[phpbb_group_positions::group_type_language($row['group_type'])],
'U_MOVE_DOWN' => "{$this->u_action}&amp;field=teampage&amp;action=move_down&amp;g=" . $row['group_id'],
'U_MOVE_UP' => "{$this->u_action}&amp;field=teampage&amp;action=move_up&amp;g=" . $row['group_id'],
'U_DELETE' => "{$this->u_action}&amp;field=teampage&amp;action=delete&amp;g=" . $row['group_id'],
));
}
else
{
$s_group_select_teampage .= '<option value="' . (int) $row['group_id'] . '">' . $group_name . '</option>';
}
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'U_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action,
'U_ACTION_LEGEND' => $this->u_action . '&amp;field=legend', 'U_ACTION_LEGEND' => $this->u_action . '&amp;field=legend',
'U_ACTION_TEAMPAGE' => $this->u_action . '&amp;field=teampage', 'U_ACTION_TEAMPAGE' => $this->u_action . '&amp;field=teampage' . $category_url_param,
'U_ACTION_TEAMPAGE_CAT' => $this->u_action . '&amp;field=teampage_cat',
'S_GROUP_SELECT_LEGEND' => $s_group_select_legend, 'S_GROUP_SELECT_LEGEND' => $s_group_select_legend,
'S_GROUP_SELECT_TEAMPAGE' => $s_group_select_teampage, 'S_GROUP_SELECT_TEAMPAGE' => $s_group_select_teampage,
'S_TEAMPAGE_CATEGORY' => $category_id,
'DISPLAY_FORUMS' => ($config['teampage_forums']) ? true : false, 'DISPLAY_FORUMS' => ($config['teampage_forums']) ? true : false,
'DISPLAY_MEMBERSHIPS' => $config['teampage_memberships'], 'DISPLAY_MEMBERSHIPS' => $config['teampage_memberships'],
'LEGEND_SORT_GROUPNAME' => ($config['legend_sort_groupname']) ? true : false, 'LEGEND_SORT_GROUPNAME' => ($config['legend_sort_groupname']) ? true : false,

View File

@ -36,12 +36,14 @@ if (empty($lang) || !is_array($lang))
$lang = array_merge($lang, array( $lang = array_merge($lang, array(
'ACP_GROUPS_MANAGE_EXPLAIN' => 'From this panel you can administer all your usergroups. You can delete, create and edit existing groups. Furthermore, you may choose group leaders, toggle open/hidden/closed group status and set the group name and description.', 'ACP_GROUPS_MANAGE_EXPLAIN' => 'From this panel you can administer all your usergroups. You can delete, create and edit existing groups. Furthermore, you may choose group leaders, toggle open/hidden/closed group status and set the group name and description.',
'ADD_CATEGORY' => 'Add category',
'ADD_USERS' => 'Add users', 'ADD_USERS' => 'Add users',
'ADD_USERS_EXPLAIN' => 'Here you can add new users to the group. You may select whether this group becomes the new default for the selected users. Additionally you can define them as group leaders. Please enter each username on a separate line.', 'ADD_USERS_EXPLAIN' => 'Here you can add new users to the group. You may select whether this group becomes the new default for the selected users. Additionally you can define them as group leaders. Please enter each username on a separate line.',
'COPY_PERMISSIONS' => 'Copy permissions from', 'COPY_PERMISSIONS' => 'Copy permissions from',
'COPY_PERMISSIONS_EXPLAIN' => 'Once created, the group will have the same permissions as the one you select here.', 'COPY_PERMISSIONS_EXPLAIN' => 'Once created, the group will have the same permissions as the one you select here.',
'CREATE_GROUP' => 'Create new group', 'CREATE_GROUP' => 'Create new group',
'CATEGORY_NAME' => 'Category name',
'GROUPS_NO_MEMBERS' => 'This group has no members', 'GROUPS_NO_MEMBERS' => 'This group has no members',
'GROUPS_NO_MODS' => 'No group leaders defined', 'GROUPS_NO_MODS' => 'No group leaders defined',
@ -130,6 +132,7 @@ $lang = array_merge($lang, array(
'SPECIAL_GROUPS' => 'Pre-defined groups', 'SPECIAL_GROUPS' => 'Pre-defined groups',
'SPECIAL_GROUPS_EXPLAIN' => 'Pre-defined groups are special groups, they cannot be deleted or directly modified. However you can still add users and alter basic settings.', 'SPECIAL_GROUPS_EXPLAIN' => 'Pre-defined groups are special groups, they cannot be deleted or directly modified. However you can still add users and alter basic settings.',
'TEAMPAGE' => 'Teampage',
'TEAMPAGE_DISP_ALL' => 'All memberships', 'TEAMPAGE_DISP_ALL' => 'All memberships',
'TEAMPAGE_DISP_DEFAULT' => 'Users default group only', 'TEAMPAGE_DISP_DEFAULT' => 'Users default group only',
'TEAMPAGE_DISP_FIRST' => 'First membership only', 'TEAMPAGE_DISP_FIRST' => 'First membership only',

View File

@ -71,12 +71,23 @@ switch ($mode)
$page_title = $user->lang['THE_TEAM']; $page_title = $user->lang['THE_TEAM'];
$template_html = 'memberlist_leaders.html'; $template_html = 'memberlist_leaders.html';
$sql = 'SELECT *
FROM ' . TEAMPAGE_TABLE . '
ORDER BY teampage_position ASC';
$result = $db->sql_query($sql, 3600);
$teampage_data = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$sql_ary = array( $sql_ary = array(
'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type, g.group_teampage, ug.user_id as ug_user_id', 'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id, t.teampage_id',
'FROM' => array(GROUPS_TABLE => 'g'), 'FROM' => array(GROUPS_TABLE => 'g'),
'LEFT_JOIN' => array( 'LEFT_JOIN' => array(
array(
'FROM' => array(TEAMPAGE_TABLE => 't'),
'ON' => 't.group_id = g.group_id',
),
array( array(
'FROM' => array(USER_GROUP_TABLE => 'ug'), 'FROM' => array(USER_GROUP_TABLE => 'ug'),
'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'], 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'],
@ -85,7 +96,7 @@ switch ($mode)
'WHERE' => '', 'WHERE' => '',
'ORDER_BY' => 'g.group_teampage ASC', 'ORDER_BY' => '',
); );
$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
@ -104,7 +115,7 @@ switch ($mode)
$row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']); $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
} }
if ($row['group_teampage']) if ($row['teampage_id'])
{ {
// Only put groups into the array we want to display. // Only put groups into the array we want to display.
// We are fetching all groups, to ensure we got all data for default groups. // We are fetching all groups, to ensure we got all data for default groups.
@ -204,10 +215,26 @@ switch ($mode)
} }
} }
foreach ($groups_ary as $group_id => $group_data) $parent_team = 0;
foreach ($teampage_data as $team_data)
{ {
if ($group_data['group_teampage']) // If this team entry has no group, it's a category
if (!$team_data['group_id'])
{ {
$template->assign_block_vars('group', array(
'GROUP_NAME' => $team_data['teampage_name'],
));
$parent_team = (int) $team_data['teampage_id'];
continue;
}
$group_data = $groups_ary[(int) $team_data['group_id']];
$group_id = (int) $team_data['group_id'];
if (!$team_data['teampage_parent'])
{
// If the group does not have a parent category, we display the groupname as category
$template->assign_block_vars('group', array( $template->assign_block_vars('group', array(
'GROUP_NAME' => $group_data['group_name'], 'GROUP_NAME' => $group_data['group_name'],
'GROUP_COLOR' => $group_data['group_colour'], 'GROUP_COLOR' => $group_data['group_colour'],
@ -223,7 +250,7 @@ switch ($mode)
if (isset($user_ary[$user_id])) if (isset($user_ary[$user_id]))
{ {
$row = $user_ary[$user_id]; $row = $user_ary[$user_id];
if ($config['teampage_memberships'] == 1 && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['group_teampage']) if ($config['teampage_memberships'] == 1 && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['teampage_id'])
{ {
// Display users in their primary group, instead of the first group, when it is displayed on the teampage. // Display users in their primary group, instead of the first group, when it is displayed on the teampage.
continue; continue;