diff options
author | Mario <mario@mariovavti.com> | 2022-01-04 20:42:07 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-01-04 20:42:07 +0000 |
commit | b40e85855617812c8275878c5ca29fcaf9c209d7 (patch) | |
tree | 66d4f4e73455ff37e87638c91024be216bfc2854 /include/text.php | |
parent | 95a4ed7d6a770686e951e8651f3bc36c00f432f9 (diff) | |
download | volse-hubzilla-b40e85855617812c8275878c5ca29fcaf9c209d7.tar.gz volse-hubzilla-b40e85855617812c8275878c5ca29fcaf9c209d7.tar.bz2 volse-hubzilla-b40e85855617812c8275878c5ca29fcaf9c209d7.zip |
only display connections widget if there are any connections to show
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/include/text.php b/include/text.php index b11437862..9c59a9908 100644 --- a/include/text.php +++ b/include/text.php @@ -1009,56 +1009,58 @@ function contact_block() { $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra", intval(App::$profile['uid']) ); + if(count($r)) { $total = intval($r[0]['total']); } + if(! $total) { - $contacts = t('No connections'); - $micropro = null; - } else { + return $o; + } - $randfunc = db_getfunc('RAND'); + $randfunc = db_getfunc('RAND'); - $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d $abook_flags and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d", - intval(App::$profile['uid']), - intval($shown) - ); + $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d $abook_flags and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d", + intval(App::$profile['uid']), + intval($shown) + ); - if(count($r)) { - $contacts = t('Connections'); - $micropro = []; - foreach($r as $rr) { - - // There is no setting to discover if you are bi-directionally connected - // Use the ability to post comments as an indication that this relationship is more - // than wishful thinking; even though soapbox channels and feeds will disable it. - $rr['perminfo']['connpermcount']=0; - $rr['perminfo']['connperms']=t('Accepts').': '; - if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { - $rr['perminfo']['connpermcount']++; - $rr['perminfo']['connperms'] .= t('Comments'); - } - if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','send_stream'))) { - $rr['perminfo']['connpermcount']++; - $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ', ' : $rr['perminfo']['connperms'] ; - $rr['perminfo']['connperms'] .= t('Stream items'); - } - if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_wall'))) { - $rr['perminfo']['connpermcount']++; - $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ', ' : $rr['perminfo']['connperms'] ; - $rr['perminfo']['connperms'] .= t('Wall posts'); - } + if(! $r) { + return $o; + } - if ($rr['perminfo']['connpermcount'] == 0) { - $rr['perminfo']['connperms'] .= t('Nothing'); - } + $contacts = t('Connections'); + $micropro = []; + foreach($r as $rr) { - if(!$is_owner && $rr['perminfo']['connpermcount'] !== 0) - unset($rr['perminfo']); + // There is no setting to discover if you are bi-directionally connected + // Use the ability to post comments as an indication that this relationship is more + // than wishful thinking; even though soapbox channels and feeds will disable it. + $rr['perminfo']['connpermcount']=0; + $rr['perminfo']['connperms']=t('Accepts').': '; + if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { + $rr['perminfo']['connpermcount']++; + $rr['perminfo']['connperms'] .= t('Comments'); + } + if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','send_stream'))) { + $rr['perminfo']['connpermcount']++; + $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ', ' : $rr['perminfo']['connperms'] ; + $rr['perminfo']['connperms'] .= t('Stream items'); + } + if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_wall'))) { + $rr['perminfo']['connpermcount']++; + $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ', ' : $rr['perminfo']['connperms'] ; + $rr['perminfo']['connperms'] .= t('Wall posts'); + } - $micropro[] = micropro($rr,true,'mpfriend'); - } + if ($rr['perminfo']['connpermcount'] == 0) { + $rr['perminfo']['connperms'] .= t('Nothing'); } + + if(!$is_owner && $rr['perminfo']['connpermcount'] !== 0) + unset($rr['perminfo']); + + $micropro[] = micropro($rr,true,'mpfriend'); } $tpl = get_markup_template('contact_block.tpl'); |