]> git.mxchange.org Git - friendica.git/blob - mod/viewcontacts.php
merged multipart email changes
[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",
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 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                 notice( 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                 $o .= replace_macros($tpl, array(
51                         '$id' => $rr['id'],
52                         '$alt_text' => t('Visit $username\'s profile'),
53                         '$thumb' => $rr['thumb'], 
54                         '$name' => substr($rr['name'],0,20),
55                         '$username' => $rr['name'],
56                         '$url' => $rr['url'] 
57                 ));
58         }
59
60         $o .= '<div id="view-contact-end"></div>';
61
62         $o .= paginate($a);
63
64         return $o;
65 }