Commit fe534e7e authored by Chris Graham's avatar Chris Graham

Fixed MANTIS-4212 (Problems displaying secondary group members)

parent 63ea4381
......@@ -547,8 +547,10 @@ class Module_groups
$promotion_info = new Tempcode();
}
$may_control_group = cns_may_control_group($id, get_member());
// To add
if (cns_may_control_group($id, get_member())) {
if ($may_control_group) {
$add_url = build_url(array('page' => '_SELF', 'type' => 'add_to', 'id' => $id), '_SELF');
} else {
$add_url = new Tempcode();
......@@ -606,13 +608,13 @@ class Module_groups
// Secondary members
$s_start = get_param_integer('s_start', 0);
$s_max = get_param_integer('s_max', intval(get_option('secondary_members_per_page')));
$_secondary_members = cns_get_group_members_raw($id, false, cns_may_control_group($id, get_member()), true, false, $s_max, $s_start);
$_secondary_members = cns_get_group_members_raw($id, false, false, true, false, $s_max, $s_start);
$secondary_members = new Tempcode();
$prospective_members = new Tempcode();
$s_max_rows = cns_get_group_members_raw_count($id, false, false, false);
$d_max_rows = cns_may_control_group($id, get_member()) ? cns_get_group_members_raw_count($id, false, true, false) : 0;
$s_max_rows = cns_get_group_members_raw_count($id, false, false, true, false);
$d_max_rows = $may_control_group ? cns_get_group_members_raw_count($id, false, true, true) : 0;
foreach ($_secondary_members as $secondary_member) {
if (!cns_may_control_group($id, get_member())) {
if (!$may_control_group) {
// Update to consistent map format, as we use it here
$secondary_member = array('gm_member_id' => $secondary_member, 'gm_validated' => 1, 'implicit' => false);
}
......@@ -628,7 +630,7 @@ class Module_groups
if ($secondary_member['gm_validated'] == 1) {
$url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true);
$remove_url = build_url(array('page' => '_SELF', 'type' => 'remove_from', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF');
$may_control = (cns_may_control_group($id, get_member()) && (!$secondary_member['implicit']));
$may_control = ($may_control_group && (!$secondary_member['implicit']));
$temp = do_template('CNS_VIEW_GROUP_MEMBER' . ($may_control ? '_SECONDARY' : ''), array(
'ID' => strval($secondary_member['gm_member_id']),
'REMOVE_URL' => $remove_url,
......
......@@ -136,7 +136,7 @@ function cns_get_group_members_raw($group_id, $include_primaries = true, $non_va
require_code('hooks/systems/cns_implicit_usergroups/' . $hook, false, $hook_dir == 'sources_custom');
$ob = object_factory('Hook_implicit_usergroups_' . $hook);
if (in_array($group_id, $ob->get_bound_group_ids())) {
$c = $ob->get_member_list($group_id);
$c = $ob->get_member_list($group_id, $max, $start);
if (!is_null($c)) {
foreach ($c as $member_id => $member_row) {
$members[$member_id] = $non_validated ? array('gm_member_id' => $member_id, 'gm_validated' => 1, 'm_username' => $member_row['m_username'], 'implicit' => true) : $member_id;
......
......@@ -906,7 +906,7 @@ class Forum_driver_cns extends Forum_driver_base
$group_ids = $ob->get_bound_group_ids();
foreach ($group_ids as $group_id) {
if (in_array($group_id, $groups)) {
$c = $ob->get_member_list($group_id);
$c = $ob->get_member_list($group_id, $max, $start);
if (!is_null($c)) {
foreach ($c as $member_id => $x) {
$out[$member_id] = $x;
......
......@@ -82,15 +82,17 @@ class Hook_implicit_usergroups_antispam_question
* Run function for implicit usergroup hooks. Finds all members in the group.
*
* @param GROUP $group_id The group ID to check (if only one group supported by the hook, can be ignored).
* @param ?integer $max Return up to this many entries for members (null: no limit)
* @param integer $start Return members after this offset
* @return ?array The list of members as a map between member ID and member row (null: unsupported by hook).
*/
public function get_member_list($group_id)
public function get_member_list($group_id, $max = null, $start = 0)
{
if ($this->field_id === null) {
return array();
}
return list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . $this->_where()));
return list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . $this->_where(), $max, $start));
}
/**
......
......@@ -38,11 +38,13 @@ class Hook_implicit_usergroups_under18s
* Run function for implicit usergroup hooks. Finds all members in the group.
*
* @param GROUP $group_id The group ID to check (if only one group supported by the hook, can be ignored).
* @param ?integer $max Return up to this many entries for members (null: no limit)
* @param integer $start Return members after this offset
* @return ?array The list of members as a map between member ID and member row (null: unsupported by hook).
*/
public function get_member_list($group_id)
public function get_member_list($group_id, $max = null, $start = 0)
{
return list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . $this->_where()));
return list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . $this->_where(), $max, $start));
}
/**
......
......@@ -74,9 +74,11 @@ class Hook_implicit_usergroups_usergroup_field_match
* Run function for implicit usergroup hooks. Finds all members in the group.
*
* @param GROUP $group_id The group ID to check (if only one group supported by the hook, can be ignored).
* @param ?integer $max Return up to this many entries for members (null: no limit)
* @param integer $start Return members after this offset
* @return ?array The list of members as a map between member ID and member row (null: unsupported by hook).
*/
public function get_member_list($group_id)
public function get_member_list($group_id, $max = null, $start = 0)
{
$out = array();
......@@ -84,7 +86,7 @@ class Hook_implicit_usergroups_usergroup_field_match
$for_group = $structure[$group_id];
foreach ($for_group as $pairs) {
$cpf_key = 'field_' . strval($pairs[0]);
$_members = $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('mf_member_id'), array($cpf_key => $pairs[1]));
$_members = $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('mf_member_id'), array($cpf_key => $pairs[1]), '', $max, $start);
foreach ($_members as $m) {
$member_id = $m['mf_member_id'];
$out[$member_id] = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment