connect link in directory

This commit is contained in:
friendica 2013-08-03 16:35:55 -07:00
parent 8a7fea45cc
commit e6a8bb211c
3 changed files with 27 additions and 4 deletions

View File

@ -53,6 +53,20 @@ function directory_content(&$a) {
} }
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG); logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
$contacts = array();
if(local_user()) {
$x = q("select abook_xchan from abook where abook_channel = %d",
intval(local_user())
);
if($x) {
foreach($x as $xx)
$contacts[] = $xx['abook_xchan'];
}
}
if($url) { if($url) {
$query = $url . '?f=' ; $query = $url . '?f=' ;
if($search) if($search)
@ -88,6 +102,10 @@ function directory_content(&$a) {
$profile_link = chanlink_url($rr['url']); $profile_link = chanlink_url($rr['url']);
$pdesc = (($rr['description']) ? $rr['description'] . '<br />' : ''); $pdesc = (($rr['description']) ? $rr['description'] . '<br />' : '');
$connect_link = ((local_user()) ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '');
if(in_array($rr['hash'],$contacts))
$connect_link = '';
$details = ''; $details = '';
if(strlen($rr['locale'])) if(strlen($rr['locale']))
@ -142,7 +160,8 @@ function directory_content(&$a) {
'marital' => $marital, 'marital' => $marital,
'homepage' => $homepage, 'homepage' => $homepage,
'about' => $about, 'about' => $about,
'conn_label' => t('Connect'),
'connect' => $connect_link,
); );
$arr = array('contact' => $rr, 'entry' => $entry); $arr = array('contact' => $rr, 'entry' => $entry);
@ -150,14 +169,13 @@ function directory_content(&$a) {
call_hooks('directory_item', $arr); call_hooks('directory_item', $arr);
$entries[] = $entry; $entries[] = $entry;
unset($profile); unset($profile);
unset($location); unset($location);
} }
logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA); // logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$search' => $search, '$search' => $search,

View File

@ -134,6 +134,8 @@ function dirsearch_content(&$a) {
$entry = array(); $entry = array();
$entry['name'] = $rr['xchan_name']; $entry['name'] = $rr['xchan_name'];
$entry['hash'] = $rr['xchan_hash'];
$entry['updated'] = (($rr['ud_date']) ? $rr['ud_date'] : '0000-00-00 00:00:00'); $entry['updated'] = (($rr['ud_date']) ? $rr['ud_date'] : '0000-00-00 00:00:00');
$entry['url'] = $rr['xchan_url']; $entry['url'] = $rr['xchan_url'];
$entry['photo'] = $rr['xchan_photo_m']; $entry['photo'] = $rr['xchan_photo_m'];

View File

@ -6,5 +6,8 @@
</div> </div>
<div class="contact-name" id="directory-name-{{$entry.id}}">{{$entry.name}}</div> <div class="contact-name" id="directory-name-{{$entry.id}}">{{$entry.name}}</div>
{{if $entry.connect}}
<div class="directory-connect"><a href="{{$entry.connect}}">{{$entry.conn_label}}</a></div>
{{/if}}
<div class="contact-details">{{$entry.details}}</div> <div class="contact-details">{{$entry.details}}</div>
</div> </div>