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