]> git.mxchange.org Git - friendica.git/blob - mod/viewcontacts.php
our implementation of "aspects" functionally complete
[friendica.git] / mod / viewcontacts.php
1 <?php
2
3 function viewcontacts_init(&$a) {
4
5         require_once("mod/profile.php");
6         profile_load($a,$a->argv[1]);
7
8 }
9
10
11 function viewcontacts_content(&$a) {
12
13         if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
14                 notice( t('Permission denied.') . EOL);
15                 return;
16         } 
17
18         $o .= '<h3>' . t('View Contacts') . '</h3>';
19
20
21         $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0",
22                 intval($a->profile['uid'])
23         );
24         if(count($r))
25                 $a->set_pager_total($r[0]['total']);
26
27         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 ORDER BY `name` ASC LIMIT %d , %d ",
28                 intval($a->profile['uid']),
29                 intval($a->pager['start']),
30                 intval($a->pager['itemspage'])
31         );
32         if(! count($r)) {
33                 notice( t('No contacts.') . EOL );
34                 return $o;
35         }
36
37         $tpl = file_get_contents("view/viewcontact_template.tpl");
38
39         foreach($r as $rr) {
40                 if($rr['self'])
41                         continue;
42
43                 $o .= replace_macros($tpl, array(
44                         '$id' => $rr['id'],
45                         '$alt_text' => t('Visit ') . $rr['name'] . t('\'s profile'),
46                         '$thumb' => $rr['thumb'], 
47                         '$name' => $rr['name'],
48                         '$url' => $rr['url'] 
49                 ));
50         }
51
52         $o .= '<div id="view-contact-end"></div>';
53
54         $o .= paginate($a);
55
56         return $o;
57 }