|
@@ -67,7 +67,7 @@ function Groups()
|
|
*/
|
|
*/
|
|
function GroupList()
|
|
function GroupList()
|
|
{
|
|
{
|
|
- global $txt, $context, $sourcedir;
|
|
|
|
|
|
+ global $txt, $context, $sourcedir, $scripturl;
|
|
|
|
|
|
$context['page_title'] = $txt['viewing_groups'];
|
|
$context['page_title'] = $txt['viewing_groups'];
|
|
|
|
|
|
@@ -78,8 +78,14 @@ function GroupList()
|
|
$listOptions = array(
|
|
$listOptions = array(
|
|
'id' => 'group_lists',
|
|
'id' => 'group_lists',
|
|
'title' => $context['page_title'],
|
|
'title' => $context['page_title'],
|
|
|
|
+ 'base_href' => $scripturl . '?action=moderate;area=viewgroups;sa=view',
|
|
|
|
+ 'default_sort_col' => 'group',
|
|
'get_items' => array(
|
|
'get_items' => array(
|
|
- 'function' => 'list_getGroups',
|
|
|
|
|
|
+ 'file' => $sourcedir . '/Subs-Membergroups.php',
|
|
|
|
+ 'function' => 'list_getMembergroups',
|
|
|
|
+ 'params' => array(
|
|
|
|
+ 'regular',
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
'columns' => array(
|
|
'columns' => array(
|
|
'group' => array(
|
|
'group' => array(
|
|
@@ -87,17 +93,30 @@ function GroupList()
|
|
'value' => $txt['name'],
|
|
'value' => $txt['name'],
|
|
),
|
|
),
|
|
'data' => array(
|
|
'data' => array(
|
|
- 'function' => create_function('$group', '
|
|
|
|
- global $scripturl, $context;
|
|
|
|
-
|
|
|
|
- $output = \'<a href="\' . $scripturl . \'?action=\' . $context[\'current_action\'] . (isset($context[\'admin_area\']) ? \';area=\' . $context[\'admin_area\'] : \'\') . \';sa=members;group=\' . $group[\'id\'] . \'" \' . ($group[\'color\'] ? \'style="color: \' . $group[\'color\'] . \';"\' : \'\') . \'>\' . $group[\'name\'] . \'</a>\';
|
|
|
|
-
|
|
|
|
- if ($group[\'desc\'])
|
|
|
|
- $output .= \'<div class="smalltext">\' . $group[\'desc\'] . \'</div>\';
|
|
|
|
-
|
|
|
|
- return $output;
|
|
|
|
|
|
+ 'function' => create_function('$rowData', '
|
|
|
|
+ global $scripturl;
|
|
|
|
+
|
|
|
|
+ // Since the moderator group has no explicit members, no link is needed.
|
|
|
|
+ if ($rowData[\'id_group\'] == 3)
|
|
|
|
+ $group_name = $rowData[\'group_name\'];
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $color_style = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']);
|
|
|
|
+ $group_name = sprintf(\'<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Add a help option for moderator and administrator.
|
|
|
|
+ if ($rowData[\'id_group\'] == 1)
|
|
|
|
+ $group_name .= sprintf(\' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)\', $scripturl);
|
|
|
|
+ elseif ($rowData[\'id_group\'] == 3)
|
|
|
|
+ $group_name .= sprintf(\' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)\', $scripturl);
|
|
|
|
+
|
|
|
|
+ return $group_name;
|
|
'),
|
|
'),
|
|
- 'style' => 'width: 50%;',
|
|
|
|
|
|
+ ),
|
|
|
|
+ 'sort' => array(
|
|
|
|
+ 'default' => 'CASE WHEN mg.id_group < 4 THEN mg.id_group ELSE 4 END, mg.group_name',
|
|
|
|
+ 'reverse' => 'CASE WHEN mg.id_group < 4 THEN mg.id_group ELSE 4 END, mg.group_name DESC',
|
|
),
|
|
),
|
|
),
|
|
),
|
|
'icons' => array(
|
|
'icons' => array(
|
|
@@ -107,6 +126,10 @@ function GroupList()
|
|
'data' => array(
|
|
'data' => array(
|
|
'db' => 'icons',
|
|
'db' => 'icons',
|
|
),
|
|
),
|
|
|
|
+ 'sort' => array(
|
|
|
|
+ 'default' => 'mg.icons',
|
|
|
|
+ 'reverse' => 'mg.icons DESC',
|
|
|
|
+ )
|
|
),
|
|
),
|
|
'moderators' => array(
|
|
'moderators' => array(
|
|
'header' => array(
|
|
'header' => array(
|
|
@@ -125,8 +148,17 @@ function GroupList()
|
|
'value' => $txt['membergroups_members_top'],
|
|
'value' => $txt['membergroups_members_top'],
|
|
),
|
|
),
|
|
'data' => array(
|
|
'data' => array(
|
|
- 'comma_format' => true,
|
|
|
|
- 'db' => 'num_members',
|
|
|
|
|
|
+ 'function' => create_function('$rowData', '
|
|
|
|
+ global $txt;
|
|
|
|
+
|
|
|
|
+ // No explicit members for the moderator group.
|
|
|
|
+ return $rowData[\'id_group\'] == 3 ? $txt[\'membergroups_guests_na\'] : comma_format($rowData[\'num_members\']);
|
|
|
|
+ '),
|
|
|
|
+ 'class' => 'centercol',
|
|
|
|
+ ),
|
|
|
|
+ 'sort' => array(
|
|
|
|
+ 'default' => 'CASE WHEN mg.id_group < 4 THEN mg.id_group ELSE 4 END, 1',
|
|
|
|
+ 'reverse' => 'CASE WHEN mg.id_group < 4 THEN mg.id_group ELSE 4 END, 1 DESC',
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
@@ -139,147 +171,6 @@ function GroupList()
|
|
$context['default_list'] = 'group_lists';
|
|
$context['default_list'] = 'group_lists';
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * Get the group information for the list.
|
|
|
|
- * @param int $start
|
|
|
|
- * @param int $items_per_page
|
|
|
|
- * @param int $sort
|
|
|
|
- */
|
|
|
|
-function list_getGroups($start, $items_per_page, $sort)
|
|
|
|
-{
|
|
|
|
- global $smcFunc, $txt, $scripturl, $user_info, $settings, $context;
|
|
|
|
-
|
|
|
|
- // Yep, find the groups...
|
|
|
|
- $request = $smcFunc['db_query']('', '
|
|
|
|
- SELECT mg.id_group, mg.group_name, mg.description, mg.group_type, mg.online_color, mg.hidden,
|
|
|
|
- mg.icons, IFNULL(gm.id_member, 0) AS can_moderate
|
|
|
|
- FROM {db_prefix}membergroups AS mg
|
|
|
|
- LEFT JOIN {db_prefix}group_moderators AS gm ON (gm.id_group = mg.id_group AND gm.id_member = {int:current_member})
|
|
|
|
- WHERE mg.min_posts = {int:min_posts}
|
|
|
|
- AND mg.id_group != {int:mod_group}' . (allowedTo('admin_forum') ? '' : '
|
|
|
|
- AND mg.group_type != {int:is_protected}') . '
|
|
|
|
- ORDER BY group_name',
|
|
|
|
- array(
|
|
|
|
- 'current_member' => $user_info['id'],
|
|
|
|
- 'min_posts' => -1,
|
|
|
|
- 'mod_group' => 3,
|
|
|
|
- 'is_protected' => 1,
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
- // Start collecting the data.
|
|
|
|
- $groups = array();
|
|
|
|
- $group_ids = array();
|
|
|
|
- $context['can_moderate'] = allowedTo('manage_membergroups');
|
|
|
|
- while ($row = $smcFunc['db_fetch_assoc']($request))
|
|
|
|
- {
|
|
|
|
- // We only list the groups they can see.
|
|
|
|
- if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups'))
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- $row['icons'] = explode('#', $row['icons']);
|
|
|
|
-
|
|
|
|
- $groups[$row['id_group']] = array(
|
|
|
|
- 'id' => $row['id_group'],
|
|
|
|
- 'name' => $row['group_name'],
|
|
|
|
- 'desc' => $row['description'],
|
|
|
|
- 'color' => $row['online_color'],
|
|
|
|
- 'type' => $row['group_type'],
|
|
|
|
- 'num_members' => 0,
|
|
|
|
- 'moderators' => array(),
|
|
|
|
- 'icons' => !empty($row['icons'][0]) && !empty($row['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/' . $row['icons'][1] . '" alt="*" />', $row['icons'][0]) : '',
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $context['can_moderate'] |= $row['can_moderate'];
|
|
|
|
- $group_ids[] = $row['id_group'];
|
|
|
|
- }
|
|
|
|
- $smcFunc['db_free_result']($request);
|
|
|
|
-
|
|
|
|
- // Count up the members separately...
|
|
|
|
- if (!empty($group_ids))
|
|
|
|
- {
|
|
|
|
- $query = $smcFunc['db_query']('', '
|
|
|
|
- SELECT id_group, COUNT(*) AS num_members
|
|
|
|
- FROM {db_prefix}members
|
|
|
|
- WHERE id_group IN ({array_int:group_list})
|
|
|
|
- GROUP BY id_group',
|
|
|
|
- array(
|
|
|
|
- 'group_list' => $group_ids,
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
- while ($row = $smcFunc['db_fetch_assoc']($query))
|
|
|
|
- $groups[$row['id_group']]['num_members'] += $row['num_members'];
|
|
|
|
- $smcFunc['db_free_result']($query);
|
|
|
|
-
|
|
|
|
- // Only do additional groups if we can moderate...
|
|
|
|
- if ($context['can_moderate'])
|
|
|
|
- {
|
|
|
|
- $query = $smcFunc['db_query']('', '
|
|
|
|
- SELECT mg.id_group, COUNT(*) AS num_members
|
|
|
|
- FROM {db_prefix}membergroups AS mg
|
|
|
|
- INNER JOIN {db_prefix}members AS mem ON (mem.additional_groups != {string:blank_screen}
|
|
|
|
- AND mem.id_group != mg.id_group
|
|
|
|
- AND FIND_IN_SET(mg.id_group, mem.additional_groups) != 0)
|
|
|
|
- WHERE mg.id_group IN ({array_int:group_list})
|
|
|
|
- GROUP BY mg.id_group',
|
|
|
|
- array(
|
|
|
|
- 'group_list' => $group_ids,
|
|
|
|
- 'blank_screen' => '',
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
- while ($row = $smcFunc['db_fetch_assoc']($query))
|
|
|
|
- $groups[$row['id_group']]['num_members'] += $row['num_members'];
|
|
|
|
- $smcFunc['db_free_result']($query);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Get any group moderators.
|
|
|
|
- // Count up the members separately...
|
|
|
|
- if (!empty($group_ids))
|
|
|
|
- {
|
|
|
|
- $query = $smcFunc['db_query']('', '
|
|
|
|
- SELECT mods.id_group, mods.id_member, mem.member_name, mem.real_name
|
|
|
|
- FROM {db_prefix}group_moderators AS mods
|
|
|
|
- INNER JOIN {db_prefix}members AS mem ON (mem.id_member = mods.id_member)
|
|
|
|
- WHERE mods.id_group IN ({array_int:group_list})',
|
|
|
|
- array(
|
|
|
|
- 'group_list' => $group_ids,
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
- while ($row = $smcFunc['db_fetch_assoc']($query))
|
|
|
|
- $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
|
|
|
|
- $smcFunc['db_free_result']($query);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $groups;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * How many groups are there that are visible?
|
|
|
|
- *
|
|
|
|
- * @return int, the groups count.
|
|
|
|
- */
|
|
|
|
-function list_getGroupCount()
|
|
|
|
-{
|
|
|
|
- global $smcFunc;
|
|
|
|
-
|
|
|
|
- $request = $smcFunc['db_query']('', '
|
|
|
|
- SELECT COUNT(id_group) AS group_count
|
|
|
|
- FROM {db_prefix}membergroups
|
|
|
|
- WHERE mg.min_posts = {int:min_posts}
|
|
|
|
- AND mg.id_group != {int:mod_group}' . (allowedTo('admin_forum') ? '' : '
|
|
|
|
- AND mg.group_type != {int:is_protected}'),
|
|
|
|
- array(
|
|
|
|
- 'min_posts' => -1,
|
|
|
|
- 'mod_group' => 3,
|
|
|
|
- 'is_protected' => 1,
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
- list ($group_count) = $smcFunc['db_fetch_row']($request);
|
|
|
|
- $smcFunc['db_free_result']($request);
|
|
|
|
-
|
|
|
|
- return $group_count;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Display members of a group, and allow adding of members to a group. Silly function name though ;)
|
|
* Display members of a group, and allow adding of members to a group. Silly function name though ;)
|
|
* It can be called from ManageMembergroups if it needs templating within the admin environment.
|
|
* It can be called from ManageMembergroups if it needs templating within the admin environment.
|