]> git.mxchange.org Git - friendica.git/blob - mod/viewcontacts.php
quattro post preview, style contacts pages, style for "shiny" class, fix contacts...
[friendica.git] / mod / viewcontacts.php
1 <?php
2 require_once('include/contact_selectors.php');
3
4 function viewcontacts_init(&$a) {
5
6         if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
7                 return;
8         }
9
10         profile_load($a,$a->argv[1]);
11 }
12
13
14 function viewcontacts_content(&$a) {
15
16         if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
17                 notice( t('Public access denied.') . EOL);
18                 return;
19         }
20
21         if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
22                 notice( t('Permission denied.') . EOL);
23                 return;
24         } 
25
26
27         $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 ",
28                 intval($a->profile['uid'])
29         );
30         if(count($r))
31                 $a->set_pager_total($r[0]['total']);
32
33         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 ORDER BY `name` ASC LIMIT %d , %d ",
34                 intval($a->profile['uid']),
35                 intval($a->pager['start']),
36                 intval($a->pager['itemspage'])
37         );
38         if(! count($r)) {
39                 info( t('No contacts.') . EOL );
40                 return $o;
41         }
42
43         $contacts = array();
44
45         foreach($r as $rr) {
46                 if($rr['self'])
47                         continue;
48
49             $url = $rr['url'];
50
51                 // route DFRN profiles through the redirect
52
53                 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
54
55                 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
56                         $url = 'redir/' . $rr['id'];
57
58                 $contacts[] = array(
59                         'id' => $rr['id'],
60                         'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']),
61                         'thumb' => $rr['thumb'], 
62                         'name' => substr($rr['name'],0,20),
63                         'username' => $rr['name'],
64                         'url' => $url,
65                         'sparkle' => '',
66                         'item' => $rr,
67                 );
68         }
69
70
71         $tpl = get_markup_template("viewcontact_template.tpl");
72         $o .= replace_macros($tpl, array(
73                 '$title' => t('View Contacts'),
74                 '$contacts' => $contacts,
75                 '$paginate' => paginate($a),
76         ));
77
78
79         return $o;
80 }