fetch profile vcard for connection

This commit is contained in:
zotlabs 2017-02-27 21:14:09 -08:00
parent 47731c75fc
commit 85082ea509
2 changed files with 50 additions and 1 deletions

View File

@ -441,6 +441,33 @@ class Connedit extends \Zotlabs\Web\Controller {
goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'fetchvc') {
$url = str_replace('/channel/','/profile/',$orig_record[0]['xchan_url']) . '/vcard';
$x = z_fetch_url($url);
if($x['success']) {
$h = new \Zotlabs\Web\HTTPHeaders($x['header']);
$fields = $h->fetch();
if($fields) {
foreach($fields as $y) {
if(array_key_exists('content-type',$y)) {
$type = explode(';',trim($y['content-type']));
if($type && $type[0] === 'text/vcard' && $x['body']) {
$vc = \Sabre\VObject\Reader::read($x['body']);
$vcard = $vc->serialize();
if($vcard) {
set_abconfig(local_channel(),$orig_record[0]['abook_xchan'],'system','vcard',$vcard);
$this->connedit_clone($a);
}
}
}
}
}
}
goaway(z_root() . '/connedit/' . $contact_id);
}
if($cmd === 'resetphoto') {
q("update xchan set xchan_photo_date = '2001-01-01 00:00:00' where xchan_hash = '%s'",
dbesc($orig_record[0]['xchan_hash'])
@ -582,6 +609,13 @@ class Connedit extends \Zotlabs\Web\Controller {
'sel' => '',
'title' => t('Fetch updated permissions'),
),
'rephoto' => array(
'label' => t('Refresh Photo'),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/resetphoto',
'sel' => '',
'title' => t('Fetch updated photo'),
),
'recent' => array(
'label' => t('Recent Activity'),
@ -631,6 +665,17 @@ class Connedit extends \Zotlabs\Web\Controller {
);
if($contact['xchan_network'] === 'zot') {
$tools['fetchvc'] = [
'label' => t('Fetch Vcard'),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/fetchvc',
'sel' => '',
'title' => t('Fetch electronic calling card for this connection')
];
}
$sections = [];
$sections['perms'] = [

View File

@ -9,8 +9,12 @@
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dLabel">
<li><a href="{{$tools.view.url}}" title="{{$tools.view.title}}">{{$tools.view.label}}</a></li>
<li><a href="{{$tools.recent.url}}" title="{{$tools.recent.title}}">{{$tools.recent.label}}</a></li>
<li class="divider"></li>
{{if $tools.fetchvc}}
<li><a href="{{$tools.fetchvc.url}}" title="{{$tools.fetchvc.title}}">{{$tools.fetchvc.label}}</a></li>
{{/if}}
<li><a href="#" title="{{$tools.refresh.title}}" onclick="window.location.href='{{$tools.refresh.url}}'; return false;">{{$tools.refresh.label}}</a></li>
<li><a href="#" title="{{$tools.rephoto.title}}" onclick="window.location.href='{{$tools.rephoto.url}}'; return false;">{{$tools.rephoto.label}}</a></li>
<li class="divider"></li>
<li><a href="#" title="{{$tools.block.title}}" onclick="window.location.href='{{$tools.block.url}}'; return false;">{{$tools.block.label}}</a></li>
<li><a href="#" title="{{$tools.ignore.title}}" onclick="window.location.href='{{$tools.ignore.url}}'; return false;">{{$tools.ignore.label}}</a></li>
<li><a href="#" title="{{$tools.archive.title}}" onclick="window.location.href='{{$tools.archive.url}}'; return false;">{{$tools.archive.label}}</a></li>