2) && intval(argv(1)) && intval(argv(2))) { $r = q("SELECT abook_id FROM abook WHERE abook_id = %d and abook_channel = %d limit 1", intval(argv(2)), intval(local_channel()) ); if($r) $change = intval(argv(2)); } $o = ''; if((argc() > 1) && (intval(argv(1)))) { $r = q("SELECT * FROM profile WHERE id = %d AND uid = %d AND is_default = 0 LIMIT 1", intval(argv(1)), intval(local_channel()) ); if(! $r) { notice( t('Invalid profile identifier.') . EOL ); return; } $profile = $r[0]; $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_profile = '%s'", intval(local_channel()), dbesc($profile['profile_guid']) ); $ingroup = array(); if($r) foreach($r as $member) $ingroup[] = $member['abook_id']; $members = $r; if($change) { if(in_array($change,$ingroup)) { q("UPDATE abook SET abook_profile = '' WHERE abook_id = %d AND abook_channel = %d", intval($change), intval(local_channel()) ); } else { q("UPDATE abook SET abook_profile = '%s' WHERE abook_id = %d AND abook_channel = %d", dbesc($profile['profile_guid']), intval($change), intval(local_channel()) ); } $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_profile = '%s'", intval(local_channel()), dbesc($profile['profile_guid']) ); $members = $r; $ingroup = array(); if(count($r)) foreach($r as $member) $ingroup[] = $member['abook_id']; } $o .= '

' . t('Profile Visibility Editor') . '

'; $o .= '

' . t('Profile') . ' \'' . $profile['profile_name'] . '\'

'; $o .= '
' . t('Click on a contact to add or remove.') . '
'; } $o .= '
'; if($change) $o = ''; $o .= '
'; $o .= '

' . t('Visible To') . '

'; $o .= '
'; $o .= '
'; $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { if($member['xchan_url']) { $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['abook_id'] . '); return false;'; $o .= micropro($member,true,'mpprof', $textmode); } } $o .= '
'; $o .= '
'; $o .= '
'; $o .= '

' . t("All Connections") . '

'; $o .= '
'; $o .= '
'; $r = abook_connections(local_channel()); if($r) { $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); foreach($r as $member) { if(! in_array($member['abook_id'],$ingroup)) { $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['abook_id'] . '); return false;'; $o .= micropro($member,true,'mpprof',$textmode); } } } $o .= '
'; if($change) { echo $o; killme(); } $o .= '
'; return $o; } }