grey_goose
07-14-2011, 10:00 PM
Some may not have noticed, but vb4 no longer supports restricting Moderators from viewing Join-To-View/Invite Only content.
This modification does the following:
- Restricts Moderator access
- Hides the display of Social Groups set to Invite Only/Join-To-View (similar to this (https://vborg.vbsupport.ru/showthread.php?t=184715))
These are file edits. Back up your original files.
Included in the zip are changed files which can be used as replacements; for those that prefer to make the changes manually, here they are.
1) In /group.php
Find (~ line365):
// If a group id is specified, but the group doesn't exist, error out
if ($vbulletin->GPC['groupid'])
{
$group = fetch_socialgroupinfo($vbulletin->GPC['groupid'], true);
if (empty($group))
{
standard_error(fetch_error('invalidid', $vbphrase['social_group'], $vbulletin->options['contactuslink']));
}
Replace with:
// If a group id is specified, but the group doesn't exist, error out
if ($vbulletin->GPC['groupid'])
{
$group = fetch_socialgroupinfo($vbulletin->GPC['groupid'], true);
if (empty($group))
{
standard_error(fetch_error('invalidid', $vbphrase['social_group'], $vbulletin->options['contactuslink']));
}
$group = prepare_socialgroup($group);
// Disallow everything except joining if you can't view a
// group's content.
if(
!$group['canviewcontent']
AND $group['type'] == 'inviteonly'
AND $_REQUEST['do'] != 'join'
AND $_REQUEST['do'] != 'dojoin'
)
print_no_permission();
}
2) In /group.php
Find (~ line 653):
$group = prepare_socialgroup($group);
$group['canjoin'] = can_join_group($group);
$group['canleave'] = can_leave_group($group);
$show['pending_link'] = (fetch_socialgroup_modperm('caninvitemoderatemembe rs', $group) AND $group['moderatedmembers'] > 0);
$show['lastpostinfo'] = ($group['lastposterid']);
($hook = vBulletinHook::fetch_hook('group_list_groupbit')) ? eval($hook) : false;
$templater = vB_Template::create('socialgroups_grouplist_bit');
$templater->register('group', $group);
$templater->register('lastpostalt', $lastpostalt);
$grouplist .= $templater->render();
}
}
Replace with:
// Only show groups if we can view the
// content or this is an invitation
$group = prepare_socialgroup($group);
if(
$group['canviewcontent']
OR $group['type'] != 'inviteonly'
OR $_REQUEST['do'] == 'invitations'
)
{
$group['canjoin'] = can_join_group($group);
$group['canleave'] = can_leave_group($group);
$show['pending_link'] = (fetch_socialgroup_modperm('caninvitemoderatemembe rs', $group) AND $group['moderatedmembers'] > 0);
$show['lastpostinfo'] = ($group['lastposterid']);
($hook = vBulletinHook::fetch_hook('group_list_groupbit')) ? eval($hook) : false;
$templater = vB_Template::create('socialgroups_grouplist_bit');
$templater->register('group', $group);
$templater->register('lastpostalt', $lastpostalt);
$grouplist .= $templater->render();
}
}
}
3) In /includes/functions_socialgroup.php
Find (~ line 699):
) // The above means that you dont have to join to view
OR $group['membertype'] == 'member'
// Or can moderate comments
OR can_moderate(0, 'canmoderategroupmessages')
OR can_moderate(0, 'canremovegroupmessages')
OR can_moderate(0, 'candeletegroupmessages')
OR fetch_socialgroup_perm('canalwayspostmessage')
OR fetch_socialgroup_perm('canalwascreatediscussion')
)
);
Replace with:
) // The above means that you dont have to join to view
OR $group['membertype'] == 'member'
)
);
4) In /includes/functions_socialgroup.php
Find (~ line 1829):
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
$group = prepare_socialgroup($group, true);
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
Replace with:
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
// Only include groups whose content can be viewed.
$group = prepare_socialgroup($group, true);
if($group['canviewcontent'] OR $group['type'] != 'inviteonly')
{
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
}
5) In /includes/functions_socialgroup.php
Find (~ line 1893):
return $groups;
}
Replace with:
// Only include groups whose content can be viewed.
$visible_groups = array();
while($groups)
{
$group = prepare_socialgroup(array_shift($groups));
if($group['canviewcontent'] OR $group['type'] != 'inviteonly')
$visible_groups[] = $group;
}
return $visible_groups;
}
6) In /includes/functions_socialgroup.php
Find (~ line 1967):
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
Replace with:
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
// Only show groups we can view
$group = prepare_socialgroup($group);
if($group['canviewcontent'] OR $group['type'] != 'inviteonly')
{
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
}
$vbulletin->db->free_result($result);
return $groups;
}
Note: This is marked "Unsupported" as I am not the original author; this was done by a member of my site in his spare time who is allowing the modification to be shared. This works. He simply has no time for troubleshooting.
This modification does the following:
- Restricts Moderator access
- Hides the display of Social Groups set to Invite Only/Join-To-View (similar to this (https://vborg.vbsupport.ru/showthread.php?t=184715))
These are file edits. Back up your original files.
Included in the zip are changed files which can be used as replacements; for those that prefer to make the changes manually, here they are.
1) In /group.php
Find (~ line365):
// If a group id is specified, but the group doesn't exist, error out
if ($vbulletin->GPC['groupid'])
{
$group = fetch_socialgroupinfo($vbulletin->GPC['groupid'], true);
if (empty($group))
{
standard_error(fetch_error('invalidid', $vbphrase['social_group'], $vbulletin->options['contactuslink']));
}
Replace with:
// If a group id is specified, but the group doesn't exist, error out
if ($vbulletin->GPC['groupid'])
{
$group = fetch_socialgroupinfo($vbulletin->GPC['groupid'], true);
if (empty($group))
{
standard_error(fetch_error('invalidid', $vbphrase['social_group'], $vbulletin->options['contactuslink']));
}
$group = prepare_socialgroup($group);
// Disallow everything except joining if you can't view a
// group's content.
if(
!$group['canviewcontent']
AND $group['type'] == 'inviteonly'
AND $_REQUEST['do'] != 'join'
AND $_REQUEST['do'] != 'dojoin'
)
print_no_permission();
}
2) In /group.php
Find (~ line 653):
$group = prepare_socialgroup($group);
$group['canjoin'] = can_join_group($group);
$group['canleave'] = can_leave_group($group);
$show['pending_link'] = (fetch_socialgroup_modperm('caninvitemoderatemembe rs', $group) AND $group['moderatedmembers'] > 0);
$show['lastpostinfo'] = ($group['lastposterid']);
($hook = vBulletinHook::fetch_hook('group_list_groupbit')) ? eval($hook) : false;
$templater = vB_Template::create('socialgroups_grouplist_bit');
$templater->register('group', $group);
$templater->register('lastpostalt', $lastpostalt);
$grouplist .= $templater->render();
}
}
Replace with:
// Only show groups if we can view the
// content or this is an invitation
$group = prepare_socialgroup($group);
if(
$group['canviewcontent']
OR $group['type'] != 'inviteonly'
OR $_REQUEST['do'] == 'invitations'
)
{
$group['canjoin'] = can_join_group($group);
$group['canleave'] = can_leave_group($group);
$show['pending_link'] = (fetch_socialgroup_modperm('caninvitemoderatemembe rs', $group) AND $group['moderatedmembers'] > 0);
$show['lastpostinfo'] = ($group['lastposterid']);
($hook = vBulletinHook::fetch_hook('group_list_groupbit')) ? eval($hook) : false;
$templater = vB_Template::create('socialgroups_grouplist_bit');
$templater->register('group', $group);
$templater->register('lastpostalt', $lastpostalt);
$grouplist .= $templater->render();
}
}
}
3) In /includes/functions_socialgroup.php
Find (~ line 699):
) // The above means that you dont have to join to view
OR $group['membertype'] == 'member'
// Or can moderate comments
OR can_moderate(0, 'canmoderategroupmessages')
OR can_moderate(0, 'canremovegroupmessages')
OR can_moderate(0, 'candeletegroupmessages')
OR fetch_socialgroup_perm('canalwayspostmessage')
OR fetch_socialgroup_perm('canalwascreatediscussion')
)
);
Replace with:
) // The above means that you dont have to join to view
OR $group['membertype'] == 'member'
)
);
4) In /includes/functions_socialgroup.php
Find (~ line 1829):
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
$group = prepare_socialgroup($group, true);
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
Replace with:
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
// Only include groups whose content can be viewed.
$group = prepare_socialgroup($group, true);
if($group['canviewcontent'] OR $group['type'] != 'inviteonly')
{
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
}
5) In /includes/functions_socialgroup.php
Find (~ line 1893):
return $groups;
}
Replace with:
// Only include groups whose content can be viewed.
$visible_groups = array();
while($groups)
{
$group = prepare_socialgroup(array_shift($groups));
if($group['canviewcontent'] OR $group['type'] != 'inviteonly')
$visible_groups[] = $group;
}
return $visible_groups;
}
6) In /includes/functions_socialgroup.php
Find (~ line 1967):
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
Replace with:
$groups = array();
while ($group = $vbulletin->db->fetch_array($result))
{
// Only show groups we can view
$group = prepare_socialgroup($group);
if($group['canviewcontent'] OR $group['type'] != 'inviteonly')
{
$group['delete_group'] = can_delete_group($group);
$group['edit_group'] = can_edit_group($group);
$group['leave_group'] = can_leave_group($group);
$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);
$groups[] = $group;
}
}
$vbulletin->db->free_result($result);
return $groups;
}
Note: This is marked "Unsupported" as I am not the original author; this was done by a member of my site in his spare time who is allowing the modification to be shared. This works. He simply has no time for troubleshooting.