// Hook for attached accounts on show team page
$plugins->add_hook('showteam_user', 'accountswitcher_showteam');
/**
* Shows the attached accounts on show team page.
*
*
*/
function accountswitcher_showteam()
{
global $mybb, $db, $user, $theme, $lang, $eas, $as_user_userbit, $as_user_hidden, $user_sec_reason;
global $attachedUser, $userUid, $masterUid, $templates, $attachedPostUser, $numaccounts, $user_profilefield;
// Get the permission to view the list, super admins are always allowed
if (isset($mybb->settings['aj_groupperm'])
&& $mybb->settings['aj_groupperm'] != -1
&& !is_super_admin($mybb->user['uid'])
) {
if (!is_member($mybb->settings['aj_groupperm']) || $mybb->settings['aj_groupperm'] == '') {
return;
}
}
// Load profile field - disabled by default... Example:
//$user['profilefield'] = $eas->get_profilefield($user['uid']);
$user['attached_accounts'] = $as_user_userbit = $as_user_hidden = $numaccounts = '';
$mybb_asset_url = $mybb->asset_url;
// Get the attached users
if ($user['uid'] != 0 && $mybb->settings['aj_memberlist'] == 1) {
// Get usergroup permissions
$permissions = user_permissions((int)$user['uid']);
// Get the number of users attached to this account
$count = $eas->get_attached($user['uid']);
$hidden = $eas->get_hidden($user['uid']);
// Hide users with privacy setting enabled
if ($mybb->usergroup['cancp'] != 1
&& $mybb->user['uid'] != $user['uid']
&& $mybb->settings['aj_privacy'] == 1
&& $user['as_privacy'] == 1
) {
if (($mybb->user['as_uid'] != 0
&& $mybb->user['as_uid'] != $user['as_uid']
&& $mybb->user['as_uid'] != $user['uid']
)
|| ($mybb->user['as_uid'] == 0
&& $mybb->user['uid'] != $user['as_uid']
)
) {
return;
}
}
// If there are users attached and the current user can use the Enhanced Account Switcher...
if ($permissions['as_canswitch'] == 1 && $count > 0) {
$as_user_userbit = $eas->master_userlist($user['uid']);
}
// If there are no users attached to current account but the current account is attached to another user
if ($count == 0 && $user['as_uid'] != 0) {
// Get the master
$master = get_user((int)$user['as_uid']);
$hidden = $eas->get_hidden($master['uid']);
// Get masters permissions
$permission = user_permissions((int)$master['uid']);
// If master has permission to use the Enhanced Account Switcher, get the userlist
if ($permission['as_canswitch'] == 1) {
$userUid = $masterUid = (int)$master['uid'];
$attachedPostUser = htmlspecialchars_uni($master['username']);
$userAvatar = $eas->attached_avatar($master['avatar'], $master['avatardimensions']);
// Create link to master
if ($user['uid'] == $mybb->user['uid']) {
$attachedUser = '<span style="font-weight: bold;" title="Master Account">'.
format_name(
$attachedPostUser,
(int)$master['usergroup'],
(int)$master['displaygroup']
)
.'</span>';
$as_user_userbit .= eval($templates->render('accountswitcher_memberlist_switch'));
} else {
// Hide users with privacy setting enabled
if (($mybb->usergroup['cancp'] != 1
&& $mybb->user['uid'] != $master['uid']
&& $mybb->settings['aj_privacy'] == 1
&& $master['as_privacy'] == 1
)
&& (($mybb->user['as_uid'] > 0
&& $mybb->user['as_uid'] != $master['uid']
)
|| ($mybb->user['as_uid'] == 0
&& $mybb->user['uid'] != $master['as_uid']
)
)
) {
++$hidden;
$as_user_userbit .= '';
} else {
$attachedUser = '<span style="font-weight: bold;" title="Master Account">'.
build_profile_link(format_name(
$attachedPostUser,
(int)$master['usergroup'],
(int)$master['displaygroup']
), $userUid)
.'</span>';
$as_user_userbit .= eval($templates->render('accountswitcher_memberlist_link'));
}
}
// Get all users attached to master from the cache
$as_user_userbit .= $eas->attached_userlist($user['uid']);
}
}
if ($count > 0 || $count == 0 && $user['as_uid'] != 0) {
if (!isset($lang->aj_profile)) {
$lang->load('accountswitcher');
}
// Show hidden accounts if current user is post author or attached to hidden account
if ($user['uid'] == $mybb->user['uid']
|| $user['uid'] == $mybb->user['as_uid']
|| $user['as_uid'] == $mybb->user['uid']
) {
$hidden = 0;
}
// Accountlist link in postbit
if ($mybb->user['uid'] != 0 && $user['uid'] != 0 && $mybb->settings['aj_memberlist'] == 1) {
if ($count == 1) {
$numaccounts = $count;
$lang->aj_memberlist = $lang->aj_memberlist_one;
$numaccounts .= ' ';
} elseif ($count > 1) {
$numaccounts = $count;
$numaccounts .= ' ';
$lang->aj_memberlist = $lang->aj_memberlist_more;
} else {
$lang->aj_memberlist = $lang->aj_memberlist_linked;
}
if ($hidden > 0) {
$as_user_hidden .= $lang->sprintf($lang->aj_hidden, $hidden);
}
$user['attached_accounts'] .= eval($templates->render('accountswitcher_memberlist'));
}
}
if ($user['as_share'] != 0) {
$user['attached_accounts'] .= eval($templates->render('accountswitcher_memberlist_shared'));
}
}
}