diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 07f7d072e8..2f812c443d 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -70,6 +70,10 @@
+
+
+
+

{L_GROUP_RECEIVE_PM_EXPLAIN}
diff --git a/phpBB/adm/style/acp_groups_position.html b/phpBB/adm/style/acp_groups_position.html new file mode 100644 index 0000000000..bf6fda8742 --- /dev/null +++ b/phpBB/adm/style/acp_groups_position.html @@ -0,0 +1,158 @@ + + + + +

{L_MANAGE_LEGEND}

+ +
enctype="multipart/form-data"> + +
+ {L_LEGEND_SETTINGS} +
+

{L_LEGEND_SORT_GROUPNAME_EXPLAIN}
+
+ + +
+
+ +

+   + + + {S_FORM_TOKEN} +

+
+
+ +

{L_LEGEND_EXPLAIN}

+ + + + + + + + + + + + + + + + + + + + + + + +
{L_GROUP}{L_GROUP_TYPE}{L_ACTION}
{legend.GROUP_NAME}{legend.GROUP_TYPE} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_DELETE} +
{L_NO_GROUPS_ADDED}
+ +
+
+ + + + {S_FORM_TOKEN} +
+
+ +

{L_MANAGE_TEAMPAGE}

+ +
enctype="multipart/form-data"> + +
+ {L_TEAMPAGE_SETTINGS} +
+

{L_TEAMPAGE_MULTIPLE_EXPLAIN}
+
+ + +
+
+
+

{L_TEAMPAGE_FORUMS_EXPLAIN}
+
+ + +
+
+ +

+   + + + {S_FORM_TOKEN} +

+
+
+ +

{L_TEAMPAGE_EXPLAIN}

+ + + + + + + + + + + + + + + + + + + + + + + +
{L_GROUP}{L_GROUP_TYPE}{L_ACTION}
{teampage.GROUP_NAME}{teampage.GROUP_TYPE} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_DELETE} +
{L_NO_GROUPS_ADDED}
+ +
+
+ + + + {S_FORM_TOKEN} +
+
+ + diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 4ee105fa8d..8a4c4a329a 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1146,7 +1146,8 @@ function get_schema_struct() 'group_receive_pm' => array('BOOL', 0), 'group_message_limit' => array('UINT', 0), 'group_max_recipients' => array('UINT', 0), - 'group_legend' => array('BOOL', 1), + 'group_legend' => array('UINT', 0), + 'group_teampage' => array('UINT', 0), ), 'PRIMARY_KEY' => 'group_id', 'KEYS' => array( diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index d47c12eafd..dde556c19e 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -35,6 +35,12 @@ class acp_groups $form_key = 'acp_groups'; add_form_key($form_key); + if ($mode == 'position') + { + $this->manage_position(); + return; + } + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); // Check and set some common vars @@ -306,6 +312,7 @@ class acp_groups 'rank' => request_var('group_rank', 0), 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, 'legend' => isset($_REQUEST['group_legend']) ? 1 : 0, + 'teampage' => isset($_REQUEST['group_teampage']) ? 1 : 0, 'message_limit' => request_var('group_message_limit', 0), 'max_recipients' => request_var('group_max_recipients', 0), 'founder_manage' => 0, @@ -419,6 +426,7 @@ class acp_groups 'avatar_height' => 'int', 'receive_pm' => 'int', 'legend' => 'int', + 'teampage' => 'int', 'message_limit' => 'int', 'max_recipients'=> 'int', 'founder_manage'=> 'int', @@ -584,6 +592,7 @@ class acp_groups 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', 'GROUP_FOUNDER_MANAGE' => (isset($group_row['group_founder_manage']) && $group_row['group_founder_manage']) ? ' checked="checked"' : '', 'GROUP_LEGEND' => (isset($group_row['group_legend']) && $group_row['group_legend']) ? ' checked="checked"' : '', + 'GROUP_TEAMPAGE' => (isset($group_row['group_teampage']) && $group_row['group_teampage']) ? ' checked="checked"' : '', 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', @@ -793,4 +802,122 @@ class acp_groups } } } + + public function manage_position() + { + global $config, $db, $template, $user; + + $this->tpl_name = 'acp_groups_position'; + $this->page_title = 'ACP_GROUPS_POSITION'; + + $field = request_var('field', ''); + $action = request_var('action', ''); + $group_id = request_var('g', 0); + + if ($field && !in_array($field, array('legend', 'teampage'))) + { + // Invalid mode + trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); + } + else if ($field) + { + $group_position = new phpbb_group_positions($db, $field, $this->u_action); + } + + switch ($action) + { + case 'set_config_legend': + set_config('legend_sort_groupname', request_var('legend_sort_groupname', 0)); + break; + + case 'set_config_teampage': + set_config('teampage_forums', request_var('teampage_forums', 0)); + set_config('teampage_multiple', request_var('teampage_multiple', 0)); + break; + + 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; + } + + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_legend, group_name ASC'; + $result = $db->sql_query($sql); + + $s_group_select_legend = ''; + while ($row = $db->sql_fetchrow($result)) + { + $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + if ($row['group_legend']) + { + $template->assign_block_vars('legend', 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}&field=legend&action=move_down&g=" . $row['group_id'], + 'U_MOVE_UP' => "{$this->u_action}&field=legend&action=move_up&g=" . $row['group_id'], + 'U_DELETE' => "{$this->u_action}&field=legend&action=delete&g=" . $row['group_id'], + )); + } + else + { + $s_group_select_legend .= ''; + } + } + $db->sql_freeresult($result); + + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_teampage + FROM ' . GROUPS_TABLE . ' + ORDER BY group_teampage, group_name ASC'; + $result = $db->sql_query($sql); + + $s_group_select_teampage = ''; + while ($row = $db->sql_fetchrow($result)) + { + $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + if ($row['group_teampage']) + { + $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}&field=teampage&action=move_down&g=" . $row['group_id'], + 'U_MOVE_UP' => "{$this->u_action}&field=teampage&action=move_up&g=" . $row['group_id'], + 'U_DELETE' => "{$this->u_action}&field=teampage&action=delete&g=" . $row['group_id'], + )); + } + else + { + $s_group_select_teampage .= ''; + } + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'U_ACTION' => $this->u_action, + 'U_ACTION_LEGEND' => $this->u_action . '&field=legend', + 'U_ACTION_TEAMPAGE' => $this->u_action . '&field=teampage', + + 'S_GROUP_SELECT_LEGEND' => $s_group_select_legend, + 'S_GROUP_SELECT_TEAMPAGE' => $s_group_select_teampage, + 'DISPLAY_FORUMS' => ($config['teampage_forums']) ? true : false, + 'DISPLAY_MULTIPLE' => ($config['teampage_multiple']) ? true : false, + 'LEGEND_SORT_GROUPNAME' => ($config['legend_sort_groupname']) ? true : false, + )); + } } diff --git a/phpBB/includes/acp/info/acp_groups.php b/phpBB/includes/acp/info/acp_groups.php index bbf92d670e..36e8793007 100644 --- a/phpBB/includes/acp/info/acp_groups.php +++ b/phpBB/includes/acp/info/acp_groups.php @@ -21,6 +21,7 @@ class acp_groups_info 'version' => '1.0.0', 'modes' => array( 'manage' => array('title' => 'ACP_GROUPS_MANAGE', 'auth' => 'acl_a_group', 'cat' => array('ACP_GROUPS')), + 'position' => array('title' => 'ACP_GROUPS_POSITION', 'auth' => 'acl_a_group', 'cat' => array('ACP_GROUPS')), ), ); } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0a1260daed..dd96530265 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2457,6 +2457,69 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (!sizeof($error)) { + $current_legend = phpbb_group_positions::GROUP_DISABLED; + $current_teampage = phpbb_group_positions::GROUP_DISABLED; + + $legend = new phpbb_group_positions($db, 'legend'); + $teampage = new phpbb_group_positions($db, 'teampage'); + if ($group_id) + { + $current_legend = $legend->get_group_value($group_id); + $current_teampage = $teampage->get_group_value($group_id); + } + + if (!empty($group_attributes['group_legend'])) + { + if (($group_id && ($current_legend == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) + { + // Old group currently not in the legend or new group, add at the end. + $group_attributes['group_legend'] = 1 + $legend->get_group_count(); + } + else + { + // Group stayes in the legend + $group_attributes['group_legend'] = $current_legend; + } + } + else if ($group_id && ($current_legend > phpbb_group_positions::GROUP_DISABLED)) + { + // Group is removed from the legend + $legend->delete_group($group_id, true); + $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; + } + else + { + $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; + } + + if (!empty($group_attributes['group_teampage'])) + { + if (($group_id && ($current_teampage == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) + { + // Old group currently not on the teampage or new group, add at the end. + $group_attributes['group_teampage'] = 1 + $teampage->get_group_count(); + } + else + { + // Group stayes on the teampage + $group_attributes['group_teampage'] = $current_teampage; + } + } + else if ($group_id && ($current_teampage > phpbb_group_positions::GROUP_DISABLED)) + { + // Group is removed from the teampage + $teampage->delete_group($group_id, true); + $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; + } + else + { + $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; + } + + // Unset the objects, we don't need them anymore. + unset($legend); + unset($teampage); + $user_ary = array(); $sql_ary = array( 'group_name' => (string) $name, @@ -2681,6 +2744,14 @@ function group_delete($group_id, $group_name = false) } while ($start); + // Delete group from legend and teampage + $legend = new phpbb_group_positions($db, 'legend'); + $legend->delete_group($group_id); + unset($legend); + $teampage = new phpbb_group_positions($db, 'teampage'); + $teampage->delete_group($group_id); + unset($teampage); + // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; diff --git a/phpBB/includes/group_positions.php b/phpBB/includes/group_positions.php new file mode 100644 index 0000000000..fc44e3249d --- /dev/null +++ b/phpBB/includes/group_positions.php @@ -0,0 +1,261 @@ +adm_back_link = $adm_back_link; + + if (!in_array($field, array('teampage', 'legend'))) + { + $this->error('NO_MODE'); + } + + $this->db = $db; + $this->field = $field; + } + + /** + * Returns the group_{$this->field} for a given group, if the group exists. + * @param int $group_id group_id of the group to be selected + * @return int position of the group + */ + public function get_group_value($group_id) + { + $sql = 'SELECT group_' . $this->field . ' + FROM ' . GROUPS_TABLE . ' + WHERE group_id = ' . (int) $group_id; + $result = $this->db->sql_query($sql); + $current_value = $this->db->sql_fetchfield('group_' . $this->field); + $this->db->sql_freeresult($result); + + if ($current_value === false) + { + // Group not found. + $this->error('NO_GROUP'); + } + + return (int) $current_value; + } + + /** + * Get number of groups, displayed on the teampage/legend + * + * @return int value of the last group displayed + */ + public function get_group_count() + { + $sql = 'SELECT group_' . $this->field . ' + FROM ' . GROUPS_TABLE . ' + ORDER BY group_' . $this->field . ' DESC'; + $result = $this->db->sql_query_limit($sql, 1); + $group_count = (int) $this->db->sql_fetchfield('group_' . $this->field); + $this->db->sql_freeresult($result); + + return $group_count; + } + + /** + * Addes a group by group_id + * + * @param int $group_id group_id of the group to be added + * @return void + */ + public function add_group($group_id) + { + $current_value = $this->get_group_value($group_id); + + if ($current_value == self::GROUP_DISABLED) + { + // Group is currently not displayed, add it at the end. + $next_value = 1 + $this->get_group_count(); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = ' . $next_value . ' + WHERE group_' . $this->field . ' = ' . self::GROUP_DISABLED . ' + AND group_id = ' . (int) $group_id; + $this->db->sql_query($sql); + } + } + + /** + * Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list. + * + * @param int $group_id group_id of the group to be deleted + * @param bool $skip_group Skip setting the group to GROUP_DISABLED, to save the query, when you need to update it anyway. + * @return void + */ + public function delete_group($group_id, $skip_group = false) + { + $current_value = $this->get_group_value($group_id); + + if ($current_value != self::GROUP_DISABLED) + { + $this->db->sql_transaction('begin'); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = group_' . $this->field . ' - 1 + WHERE group_' . $this->field . ' > ' . $current_value; + $this->db->sql_query($sql); + + if (!$skip_group) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = ' . self::GROUP_DISABLED . ' + WHERE group_id = ' . (int) $group_id; + $this->db->sql_query($sql); + } + + $this->db->sql_transaction('commit'); + } + } + + /** + * Moves a group up by group_id + * + * @param int $group_id group_id of the group to be moved + * @return void + */ + public function move_up($group_id) + { + $this->move($group_id, 1); + } + + /** + * Moves a group down by group_id + * + * @param int $group_id group_id of the group to be moved + * @return void + */ + public function move_down($group_id) + { + $this->move($group_id, -1); + } + + /** + * Moves a group up/down + * + * @param int $group_id group_id of the group to be moved + * @param int $delta number of steps: + * - positive = move up + * - negative = move down + * @return void + */ + public function move($group_id, $delta) + { + if (!is_int($delta) || !$delta) + { + return; + } + + $move_up = ($delta > 0) ? true : false; + $current_value = $this->get_group_value($group_id); + + if ($current_value != self::GROUP_DISABLED) + { + $this->db->sql_transaction('begin'); + + // First we move all groups between our current value and the target value up/down 1, + // so we have a gap for our group to move. + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = group_' . $this->field . (($move_up) ? ' + 1' : ' - 1') . ' + WHERE group_' . $this->field . ' > ' . self::GROUP_DISABLED . ' + AND group_' . $this->field . (($move_up) ? ' >= ' : ' <= ') . ($current_value - $delta) . ' + AND group_' . $this->field . (($move_up) ? ' < ' : ' > ') . $current_value; + $this->db->sql_query($sql); + + // Because there might be fewer groups above/below the group than we wanted to move, + // we use the number of changed groups, to update the group. + $delta = (int) $this->db->sql_affectedrows(); + + if ($delta) + { + // And now finally, when we moved some other groups and built a gap, + // we can move the desired group to it. + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = group_' . $this->field . (($move_up) ? ' - ' : ' + ') . $delta . ' + WHERE group_id = ' . (int) $group_id; + $this->db->sql_query($sql); + } + + $this->db->sql_transaction('commit'); + } + } + + /** + * Get group type language var + * + * @param int $group_type group_type from the groups-table + * @return string name of the language variable for the given group-type. + */ + static public function group_type_language($group_type) + { + switch ($group_type) + { + case GROUP_OPEN: + return 'GROUP_REQUEST'; + case GROUP_CLOSED: + return 'GROUP_CLOSED'; + case GROUP_HIDDEN: + return 'GROUP_HIDDEN'; + case GROUP_SPECIAL: + return 'GROUP_SPECIAL'; + case GROUP_FREE: + return 'GROUP_OPEN'; + } + } + + /** + * Error + */ + public function error($message) + { + global $user; + trigger_error($user->lang[$message] . (($this->adm_back_link) ? adm_back_link($this->adm_back_link) : ''), E_USER_WARNING); + } +} diff --git a/phpBB/index.php b/phpBB/index.php index 95bdade42f..0830dd0686 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -36,17 +36,18 @@ $l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER' $l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER'; $l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER'; +$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 + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; + WHERE group_legend > 0 + ORDER BY ' . $order_legend . ' ASC'; } else { - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type + $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 ( @@ -54,9 +55,9 @@ else AND ug.user_id = ' . $user->data['user_id'] . ' AND ug.user_pending = 0 ) - WHERE g.group_legend = 1 + WHERE g.group_legend > 0 AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.group_name ASC'; + ORDER BY g.' . $order_legend . ' ASC'; } $result = $db->sql_query($sql); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fab79e6dc1..cf611ca951 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -930,8 +930,19 @@ function database_update_info() ), ), - // No changes from 3.1.0-dev to 3.1.0-A1 - '3.1.0-dev' => array(), + // Changes from 3.1.0-dev to 3.1.0-A1 + '3.1.0-dev' => array( + 'add_columns' => array( + GROUPS_TABLE => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + ), + 'change_columns' => array( + GROUPS_TABLE => array( + 'group_legend' => array('UINT', 0), + ), + ), + ), ); } @@ -1902,6 +1913,56 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': set_config('use_system_cron', 0); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + _sql($sql, $errored, $error_ary); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + _sql($sql, $errored, $error_ary); + + set_config('legend_sort_groupname', '0'); + set_config('teampage_multiple', '1'); + set_config('teampage_forums', '1'); + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $db->sql_query($sql); + + $next_legend = 1; + while ($row = $db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + _sql($sql, $errored, $error_ary); + + $next_legend++; + } + $db->sql_freeresult($result); + unset($next_legend); + + // Install modules + $modules_to_install = array( + 'position' => array( + 'base' => 'groups', + 'class' => 'acp', + 'title' => 'ACP_GROUPS_POSITION', + 'auth' => 'acl_a_group', + 'cat' => 'ACP_GROUPS', + ), + ); + + _add_modules($modules_to_install); + + $no_updates = false; break; } } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index ab622e8fde..e16b4ab64c 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -444,7 +444,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm INTEGER DEFAULT 0 NOT NULL, group_message_limit INTEGER DEFAULT 0 NOT NULL, group_max_recipients INTEGER DEFAULT 0 NOT NULL, - group_legend INTEGER DEFAULT 1 NOT NULL + group_legend INTEGER DEFAULT 0 NOT NULL, + group_teampage INTEGER DEFAULT 0 NOT NULL );; ALTER TABLE phpbb_groups ADD PRIMARY KEY (group_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 068373c9a1..a14e246c8f 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -546,7 +546,8 @@ CREATE TABLE [phpbb_groups] ( [group_receive_pm] [int] DEFAULT (0) NOT NULL , [group_message_limit] [int] DEFAULT (0) NOT NULL , [group_max_recipients] [int] DEFAULT (0) NOT NULL , - [group_legend] [int] DEFAULT (1) NOT NULL + [group_legend] [int] DEFAULT (0) NOT NULL , + [group_teampage] [int] DEFAULT (0) NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 0dd2a579e6..3b79afa942 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -316,7 +316,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_legend tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (group_id), KEY group_legend_name (group_legend, group_name(255)) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 071033ae53..a4b34c05db 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -316,7 +316,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_legend tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (group_id), KEY group_legend_name (group_legend, group_name) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 811c975d5d..9b516b4a56 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -605,7 +605,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm number(1) DEFAULT '0' NOT NULL, group_message_limit number(8) DEFAULT '0' NOT NULL, group_max_recipients number(8) DEFAULT '0' NOT NULL, - group_legend number(1) DEFAULT '1' NOT NULL, + group_legend number(8) DEFAULT '0' NOT NULL, + group_teampage number(8) DEFAULT '0' NOT NULL, CONSTRAINT pk_phpbb_groups PRIMARY KEY (group_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 217ecd3771..1b9c1a75aa 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -459,7 +459,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm INT2 DEFAULT '0' NOT NULL CHECK (group_receive_pm >= 0), group_message_limit INT4 DEFAULT '0' NOT NULL CHECK (group_message_limit >= 0), group_max_recipients INT4 DEFAULT '0' NOT NULL CHECK (group_max_recipients >= 0), - group_legend INT2 DEFAULT '1' NOT NULL CHECK (group_legend >= 0), + group_legend INT4 DEFAULT '0' NOT NULL CHECK (group_legend >= 0), + group_teampage INT4 DEFAULT '0' NOT NULL CHECK (group_teampage >= 0), PRIMARY KEY (group_id) ); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 88265d3173..f3259b8fe3 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -151,6 +151,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user_filter', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('legend_sort_groupname', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_anon_lastread', '0'); @@ -238,6 +239,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_password', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_username', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_multiple', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_forums', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); @@ -520,13 +523,13 @@ INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_reg INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- Groups -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED_COPPA', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GLOBAL_MODERATORS', 3, 0, '00AA00', 1, '', '', '', 0); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, '', '', '', 0); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED', 3, 0, '', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED_COPPA', 3, 0, '', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GLOBAL_MODERATORS', 3, 0, '00AA00', 2, 2, '', '', '', 0); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, 1, '', '', '', 0); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, 0, '', '', '', 5); # -- User -> Group INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (1, 1, 0, 0); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index e83b4342fb..9344a29929 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -308,7 +308,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', group_message_limit INTEGER UNSIGNED NOT NULL DEFAULT '0', group_max_recipients INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_legend INTEGER UNSIGNED NOT NULL DEFAULT '1' + group_legend INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_teampage INTEGER UNSIGNED NOT NULL DEFAULT '0' ); CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name); diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 25a020d8a2..847e763ae8 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -100,6 +100,7 @@ $lang = array_merge($lang, array( 'ACP_GROUPS_MANAGE' => 'Manage groups', 'ACP_GROUPS_MANAGEMENT' => 'Group management', 'ACP_GROUPS_PERMISSIONS' => 'Groups’ permissions', + 'ACP_GROUPS_POSITION' => 'Manage group positions', 'ACP_ICONS' => 'Topic icons', 'ACP_ICONS_SMILIES' => 'Topic icons/smilies', diff --git a/phpBB/language/en/acp/groups.php b/phpBB/language/en/acp/groups.php index 3b3953ac36..11342bf4f2 100644 --- a/phpBB/language/en/acp/groups.php +++ b/phpBB/language/en/acp/groups.php @@ -97,6 +97,8 @@ $lang = array_merge($lang, array( 'GROUP_SETTINGS_SAVE' => 'Group wide settings', 'GROUP_SKIP_AUTH' => 'Exempt group leader from permissions', 'GROUP_SKIP_AUTH_EXPLAIN' => 'If enabled group leader no longer inherit permissions from the group.', + 'GROUP_SPECIAL' => 'Pre-defined', + 'GROUP_TEAMPAGE' => 'Display group on teampage', 'GROUP_TYPE' => 'Group type', 'GROUP_TYPE_EXPLAIN' => 'This determines which users can join or view this group.', 'GROUP_UPDATED' => 'Group preferences updated successfully.', @@ -105,19 +107,34 @@ $lang = array_merge($lang, array( 'GROUP_USERS_EXIST' => 'The selected users are already members.', 'GROUP_USERS_REMOVE' => 'Users removed from group and new defaults set successfully.', + 'LEGEND_EXPLAIN' => 'These are the groups which are displayed in the group legend:', + 'LEGEND_SETTINGS' => 'Legend settings', + 'LEGEND_SORT_GROUPNAME' => 'Sort legend by group name', + 'LEGEND_SORT_GROUPNAME_EXPLAIN' => 'The order below is ignored when this option is enabled.', + + 'MANAGE_LEGEND' => 'Manage group legend', + 'MANAGE_TEAMPAGE' => 'Manage teampage', 'MAKE_DEFAULT_FOR_ALL' => 'Make default group for every member', 'MEMBERS' => 'Members', 'NO_GROUP' => 'No group specified.', + 'NO_GROUPS_ADDED' => 'No groups added yet.', 'NO_GROUPS_CREATED' => 'No groups created yet.', 'NO_PERMISSIONS' => 'Do not copy permissions', 'NO_USERS' => 'You haven’t entered any users.', 'NO_USERS_ADDED' => 'No users were added to the group.', 'NO_VALID_USERS' => 'You haven’t entered any users eligible for that action.', + 'SELECT_GROUP' => 'Select a group', '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.', + 'TEAMPAGE_EXPLAIN' => 'These are the groups which are displayed on the teampage:', + 'TEAMPAGE_FORUMS' => 'Display moderated forums', + 'TEAMPAGE_FORUMS_EXPLAIN' => 'If set to yes, moderators will have a list with all of the forums where they have moderator permissions displayed in their row. This can be very database intensive for big boards.', + 'TEAMPAGE_MULTIPLE' => 'Display users in all groups', + 'TEAMPAGE_MULTIPLE_EXPLAIN' => 'If set to no, the users will only be displayed in their primary group (If the primary group is not listed, the users will be displayed in their first displayed group).', + 'TEAMPAGE_SETTINGS' => 'Teampage settings', 'TOTAL_MEMBERS' => 'Members', 'USERS_APPROVED' => 'Users approved successfully.', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 0b2fd24871..06212c2d77 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -77,189 +77,196 @@ switch ($mode) $page_title = $user->lang['THE_TEAM']; $template_html = 'memberlist_leaders.html'; - $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false); + $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', - $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array(); - foreach ($user_ary as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $id_ary) - { - if (!$forum_id) - { - if ($auth_option == 'a_') - { - $admin_id_ary = array_merge($admin_id_ary, $id_ary); - } - else - { - $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary); - } - continue; - } - else - { - $mod_id_ary = array_merge($mod_id_ary, $id_ary); - } - - if ($forum_id) - { - foreach ($id_ary as $id) - { - $forum_id_ary[$id][] = $forum_id; - } - } - } - } - - $admin_id_ary = array_unique($admin_id_ary); - $global_mod_id_ary = array_unique($global_mod_id_ary); - - $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary); - $mod_id_ary = array_unique($mod_id_ary); - - // Admin group id... - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'ADMINISTRATORS'"; - $result = $db->sql_query($sql); - $admin_group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - // Get group memberships for the admin id ary... - $admin_memberships = group_memberships($admin_group_id, $admin_id_ary); - - $admin_user_ids = array(); - - if (!empty($admin_memberships)) - { - // ok, we only need the user ids... - foreach ($admin_memberships as $row) - { - $admin_user_ids[$row['user_id']] = true; - } - } - unset($admin_memberships); - - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forums = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forums[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id', - - 'FROM' => array( - USERS_TABLE => 'u', - GROUPS_TABLE => 'g' - ), + 'FROM' => array(GROUPS_TABLE => 'g'), 'LEFT_JOIN' => array( array( 'FROM' => array(USER_GROUP_TABLE => 'ug'), - 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $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'], + ), ), - 'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . ' - AND u.group_id = g.group_id', + 'WHERE' => '', - 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC' - )); - $result = $db->sql_query($sql); + 'ORDER_BY' => 'g.group_teampage ASC', + ); + $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); + + $group_ids = $groups_ary = array(); while ($row = $db->sql_fetchrow($result)) { - $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod'; - - // We sort out admins not within the 'Administrators' group. - // Else, we will list those as admin only having the permission to view logs for example. - if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']])) + if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) { - // Remove from admin_id_ary, because the user may be a mod instead - unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]); - - if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary)) - { - continue; - } - else - { - $which_row = 'mod'; - } + $row['group_name'] = $user->lang['GROUP_UNDISCLOSED']; + $row['u_group'] = ''; + } + else + { + $row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); } - $s_forum_select = ''; - $undisclosed_forum = false; - - if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary)) + if ($row['group_teampage']) { - if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']]))) + // Only put groups into the array we want to display. + // We are fetching all groups, to ensure we got all data for default groups. + $group_ids[] = (int) $row['group_id']; + } + $groups_ary[(int) $row['group_id']] = $row; + } + $db->sql_freeresult($result); + + $sql_ary = array( + 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id', + + 'FROM' => array( + USER_GROUP_TABLE => 'ug', + ), + + 'LEFT_JOIN' => array( + array( + 'FROM' => array(USERS_TABLE => 'u'), + 'ON' => 'ug.user_id = u.user_id AND ug.user_pending = 0', + ), + array( + 'FROM' => array(GROUPS_TABLE => 'g'), + 'ON' => 'ug.group_id = g.group_id', + ), + ), + + 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true), + + 'ORDER_BY' => 'u.username_clean ASC', + ); + + $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); + + $user_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['forums'] = ''; + $row['forums_ary'] = array(); + $user_ary[(int) $row['user_id']] = $row; + $user_ids[] = (int) $row['user_id']; + $group_users[(int) $row['group_id']][] = (int) $row['user_id']; + } + $db->sql_freeresult($result); + + if ($config['teampage_forums']) + { + $template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true); + // Get all moderators + $perm_ary = $auth->acl_get_list(array_unique($user_ids), array('m_'), false); + + foreach ($perm_ary as $forum_id => $forum_ary) + { + foreach ($forum_ary as $auth_option => $id_ary) { - foreach ($forum_id_ary[$row['user_id']] as $forum_id) + foreach ($id_ary as $id) { - if (isset($forums[$forum_id])) + if (!$forum_id) { - if ($auth->acl_get('f_list', $forum_id)) - { - $s_forum_select .= ''; - } - else - { - $undisclosed_forum = true; - } + $user_ary[$id]['forums'] = $user->lang['ALL_FORUMS']; + } + else + { + $user_ary[$id]['forums_ary'][] = $forum_id; } } } } - // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then... - if (!$s_forum_select && $undisclosed_forum) + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE; + $result = $db->sql_query($sql); + + $forums = array(); + while ($row = $db->sql_fetchrow($result)) { -// $s_forum_select = ''; - continue; + $forums[$row['forum_id']] = $row['forum_name']; } + $db->sql_freeresult($result); - // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden. - if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) + foreach ($user_ary as $user_id => $user_data) { - $group_name = $user->lang['GROUP_UNDISCLOSED']; - $u_group = ''; + if (!$user_data['forums']) + { + foreach ($user_data['forums_ary'] as $forum_id) + { + $user_ary[$user_id]['forums_options'] = true; + if (isset($forums[$forum_id])) + { + if ($auth->acl_get('f_list', $forum_id)) + { + $user_ary[$user_id]['forums'] .= ''; + } + } + } + } + } + } + + foreach ($groups_ary as $group_id => $group_data) + { + if ($group_data['group_teampage']) + { + $template->assign_block_vars('group', array( + 'GROUP_NAME' => $group_data['group_name'], + 'GROUP_COLOR' => $group_data['group_colour'], + 'U_GROUP' => $group_data['u_group'], + )); + } + + // Display group members. + if (!empty($group_users[$group_id])) + { + foreach ($group_users[$group_id] as $user_id) + { + if (isset($user_ary[$user_id])) + { + $row = $user_ary[$user_id]; + if (!$config['teampage_multiple'] && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['group_teampage']) + { + // Display users in their primary group, instead of the first group, when it is displayed on the teampage. + continue; + } + + $rank_title = $rank_img = $rank_img_src = ''; + get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src); + + $template->assign_block_vars('group.user', array( + 'USER_ID' => $row['user_id'], + 'FORUMS' => $row['forums'], + 'FORUM_OPTIONS' => (isset($row['forums_options'])) ? true : false, + 'RANK_TITLE' => $rank_title, + + 'GROUP_NAME' => $groups_ary[$row['default_group']]['group_name'], + 'GROUP_COLOR' => $groups_ary[$row['default_group']]['group_colour'], + 'U_GROUP' => $groups_ary[$row['default_group']]['u_group'], + + 'RANK_IMG' => $rank_img, + 'RANK_IMG_SRC' => $rank_img_src, + + 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', + + 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), + )); + + if (!$config['teampage_multiple']) + { + unset($user_ary[$user_id]); + } + } + } } - else - { - $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; - $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); - } - - $rank_title = $rank_img = ''; - get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src); - - $template->assign_block_vars($which_row, array( - 'USER_ID' => $row['user_id'], - 'FORUMS' => $s_forum_select, - 'RANK_TITLE' => $rank_title, - 'GROUP_NAME' => $group_name, - 'GROUP_COLOR' => $row['group_colour'], - - 'RANK_IMG' => $rank_img, - 'RANK_IMG_SRC' => $rank_img_src, - - 'U_GROUP' => $u_group, - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), - )); } - $db->sql_freeresult($result); $template->assign_vars(array( 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) diff --git a/phpBB/styles/prosilver/template/memberlist_leaders.html b/phpBB/styles/prosilver/template/memberlist_leaders.html index 090476e365..1a63793bc3 100644 --- a/phpBB/styles/prosilver/template/memberlist_leaders.html +++ b/phpBB/styles/prosilver/template/memberlist_leaders.html @@ -4,72 +4,43 @@
+
- + - + - - - - + + - + + + - + - +
{L_RANK} {L_ADMINISTRATORS}{L_RANK} {group.GROUP_NAME}{group.GROUP_NAME} {L_PRIMARY_GROUP}{L_FORUMS}{L_MODERATOR}
{admin.RANK_IMG}{admin.RANK_TITLE}{admin.USERNAME_FULL} - style="font-weight: bold; color:#{admin.GROUP_COLOR}" href="{admin.U_GROUP}">{admin.GROUP_NAME} + +
{group.user.RANK_IMG}{group.user.RANK_TITLE}{group.user.USERNAME_FULL} + style="font-weight: bold; color: #{group.user.GROUP_COLOR}" href="{group.user.U_GROUP}">{group.user.GROUP_NAME} - {admin.GROUP_NAME} + {group.user.GROUP_NAME} -{group.user.FORUMS}-
{L_NO_ADMINISTRATORS}{L_NO_MEMBERS}
+ -
-
- - - - - - - - - - - - - - - - - - - - - - -
{L_MODERATORS}  
{mod.RANK_IMG}{mod.RANK_TITLE}{mod.USERNAME_FULL} - style="font-weight: bold; color:#{mod.GROUP_COLOR}" href="{mod.U_GROUP}">{mod.GROUP_NAME} - - {mod.GROUP_NAME} - {L_ALL_FORUMS}
{L_NO_MODERATORS}
- -
-
-
diff --git a/phpBB/styles/subsilver2/template/memberlist_leaders.html b/phpBB/styles/subsilver2/template/memberlist_leaders.html index 57f5838e7f..75fff9f98a 100644 --- a/phpBB/styles/subsilver2/template/memberlist_leaders.html +++ b/phpBB/styles/subsilver2/template/memberlist_leaders.html @@ -5,57 +5,36 @@ - + + - + - - + + - - + + - - + + - + - - - - - - - - - - - - - - - - - - + +
{L_USERNAME}{L_FORUMS}{L_FORUMS} {L_PRIMARY_GROUP} {L_RANK} {L_SEND_MESSAGE}
{L_ADMINISTRATORS}{group.GROUP_NAME}{group.GROUP_NAME}
{admin.USERNAME_FULL} {group.user.USERNAME_FULL}{group.user.FORUMS}-   - - style="font-weight: bold; color:#{admin.GROUP_COLOR}" href="{admin.U_GROUP}">{admin.GROUP_NAME} + + style="font-weight: bold; color:#{group.user.GROUP_COLOR}" href="{group.user.U_GROUP}">{group.user.GROUP_NAME} - {admin.GROUP_NAME} + {group.user.GROUP_NAME}  {admin.RANK_IMG}{admin.RANK_TITLE} {PM_IMG} {group.user.RANK_IMG}{group.user.RANK_TITLE} {PM_IMG} 
{L_NO_ADMINISTRATORS}{L_NO_MEMBERS}
{L_MODERATORS}
{mod.USERNAME_FULL}{L_ALL_FORUMS}   - - style="font-weight: bold; color:#{mod.GROUP_COLOR}" href="{mod.U_GROUP}">{mod.GROUP_NAME} - - {mod.GROUP_NAME} - -  {mod.RANK_IMG}{mod.RANK_TITLE} {PM_IMG} 
{L_NO_MODERATORS}
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index ff4e018d12..74ad7eba0d 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -371,17 +371,18 @@ unset($vars_online); $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"), $counter, $config['topics_per_page'], $start); +$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 + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; + WHERE group_legend = > 0 + ORDER BY ' . $order_legend . ' ASC'; } else { - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type + $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 ( @@ -389,9 +390,9 @@ else AND ug.user_id = ' . $user->data['user_id'] . ' AND ug.user_pending = 0 ) - WHERE g.group_legend = 1 + WHERE g.group_legend > 0 AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.group_name ASC'; + ORDER BY g.' . $order_legend . ' ASC'; } $result = $db->sql_query($sql); diff --git a/tests/group_positions/fixtures/group_positions.xml b/tests/group_positions/fixtures/group_positions.xml new file mode 100644 index 0000000000..55b1c2e08d --- /dev/null +++ b/tests/group_positions/fixtures/group_positions.xml @@ -0,0 +1,23 @@ + + + + group_id + group_teampage + group_legend + + 1 + 0 + 0 + + + 2 + 1 + 0 + + + 3 + 2 + 1 + +
+
diff --git a/tests/group_positions/group_positions_test.php b/tests/group_positions/group_positions_test.php new file mode 100644 index 0000000000..b68f205b37 --- /dev/null +++ b/tests/group_positions/group_positions_test.php @@ -0,0 +1,287 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/group_positions.xml'); + } + + public static function get_group_value_data() + { + return array( + array('teampage', 1, 0), + array('teampage', 2, 1), + array('legend', 1, 0), + array('legend', 3, 1), + ); + } + + /** + * @dataProvider get_group_value_data + */ + public function test_get_group_value($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + + $test_class = new phpbb_group_positions($db, $field); + $this->assertEquals($expected, $test_class->get_group_value($group_id)); + } + + public static function get_group_count_data() + { + return array( + array('teampage', 2), + array('legend', 1), + ); + } + + /** + * @dataProvider get_group_count_data + */ + public function test_get_group_count($field, $expected) + { + global $db; + + $db = $this->new_dbal(); + + $test_class = new phpbb_group_positions($db, $field); + $this->assertEquals($expected, $test_class->get_group_count()); + } + + public static function add_group_data() + { + return array( + array('teampage', 1, array( + array('group_id' => 1, 'group_teampage' => 3, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider add_group_data + */ + public function test_add_group($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->add_group($group_id); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function delete_group_data() + { + return array( + array('teampage', 1, false, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, false, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, false, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 0, 'group_legend' => 1), + )), + array('teampage', 1, true, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, true, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, true, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider delete_group_data + */ + public function test_delete_group($field, $group_id, $skip_group, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->delete_group($group_id, $skip_group); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function move_up_data() + { + return array( + array('teampage', 1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider move_up_data + */ + public function test_move_up($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->move_up($group_id); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function move_down_data() + { + return array( + array('teampage', 1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider move_down_data + */ + public function test_move_down($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->move_down($group_id); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function move_data() + { + return array( + array('teampage', 1, 1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 1, -1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 3, 3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 2, 0, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, -1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 2, -3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, -1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider move_data + */ + public function test_move($field, $group_id, $increment, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->move($group_id, $increment); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } +} +