From 3d811a17feb9b3d0fd4dc09023e3b7b5fe1623ac Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Dec 2016 23:26:31 -0800 Subject: provide call button on connections list if mobile|tablet and a phone number exists --- Zotlabs/Module/Connections.php | 12 +++++++++++- include/connections.php | 30 ++++++++++++++++++++++++++++++ view/css/mod_connections.css | 4 ++++ view/tpl/connection_template.tpl | 2 +- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index a0375cebb..950be660d 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -229,9 +229,17 @@ class Connections extends \Zotlabs\Web\Controller { $contacts = array(); if($r) { - + + vcard_query($r); + + foreach($r as $rr) { if($rr['xchan_url']) { + + if(($rr['vcard']) && is_array($rr['vcard']['tels']) && $rr['vcard']['tels'][0]['nr']) + $phone = ((\App::$is_mobile || \App::$is_tablet) ? $rr['vcard']['tels'][0]['nr'] : ''); + else + $phone = ''; $status_str = ''; $status = array( @@ -267,6 +275,8 @@ class Connections extends \Zotlabs\Web\Controller { 'network_label' => t('Network'), 'network' => network_to_name($rr['xchan_network']), 'public_forum' => ((intval($rr['xchan_pubforum'])) ? true : false), + 'call' => t('Call'), + 'phone' => $phone, 'status_label' => t('Status'), 'status' => $status_str, 'connected_label' => t('Connected'), diff --git a/include/connections.php b/include/connections.php index b85be33b2..44003bc93 100644 --- a/include/connections.php +++ b/include/connections.php @@ -858,3 +858,33 @@ function vcard_translate_type($type) { return [$type, t('Other') . ' (' . $type . ')']; } } + + +function vcard_query(&$r) { + + $arr = []; + + if($r && is_array($r) && count($r)) { + $uid = $r[0]['abook_channel']; + foreach($r as $rv) { + if($rv['abook_xchan'] && (! in_array("'" . dbesc($rv['abook_xchan']) . "'",$arr))) + $arr[] = "'" . dbesc($rv['abook_xchan']) . "'"; + } + } + + if($arr) { + $a = q("select * from abconfig where chan = %d and xchan in (" . protect_sprintf(implode(',', $arr)) . ") and cat = 'system' and k = 'vcard'", + intval($uid) + ); + if($a) { + foreach($a as $av) { + for($x = 0; $x < count($r); $x ++) { + if($r[$x]['abook_xchan'] == $av['xchan']) { + $vctmp = \Sabre\VObject\Reader::read($av['v']); + $r[$x]['vcard'] = (($vctmp) ? get_vcard_array($vctmp,$r[$x]['abook_id']) : [] ); + } + } + } + } + } +} \ No newline at end of file diff --git a/view/css/mod_connections.css b/view/css/mod_connections.css index a33430e48..00e6e2a70 100644 --- a/view/css/mod_connections.css +++ b/view/css/mod_connections.css @@ -33,3 +33,7 @@ .contact-info-label { font-weight: bold; } + +.connphone { + color: green; +} \ No newline at end of file diff --git a/view/tpl/connection_template.tpl b/view/tpl/connection_template.tpl index a238f5bc7..64d27e609 100755 --- a/view/tpl/connection_template.tpl +++ b/view/tpl/connection_template.tpl @@ -14,7 +14,7 @@ {{/if}} -

{{if $contact.public_forum}} {{/if}}{{$contact.name}}

+

{{if $contact.public_forum}} {{/if}}{{$contact.name}}{{if $contact.phone}} {{/if}}

-- cgit v1.2.3