]> git.mxchange.org Git - friendica.git/blob - mod/viewcontacts.php
Merge branch 'gettext' of https://github.com/fabrixxm/friendika into fabrixxm-gettext
[friendica.git] / mod / viewcontacts.php
1 <?php
2
3 function viewcontacts_init(&$a) {
4
5         profile_load($a,$a->argv[1]);
6
7 }
8
9
10 function viewcontacts_content(&$a) {
11
12         if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
13                 notice( t('Permission denied.') . EOL);
14                 return;
15         } 
16
17         $o .= '<h3>' . t('View Contacts') . '</h3>';
18
19
20         $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0",
21                 intval($a->profile['uid'])
22         );
23         if(count($r))
24                 $a->set_pager_total($r[0]['total']);
25
26         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 ORDER BY `name` ASC LIMIT %d , %d ",
27                 intval($a->profile['uid']),
28                 intval($a->pager['start']),
29                 intval($a->pager['itemspage'])
30         );
31         if(! count($r)) {
32                 notice( t('No contacts.') . EOL );
33                 return $o;
34         }
35
36         $tpl = load_view_file("view/viewcontact_template.tpl");
37
38         foreach($r as $rr) {
39                 if($rr['self'])
40                         continue;
41
42                 $o .= replace_macros($tpl, array(
43                         '$id' => $rr['id'],
44                         '$alt_text' => t('Visit $username\'s profile'),
45                         '$thumb' => $rr['thumb'], 
46                         '$name' => substr($rr['name'],0,20),
47                         '$username' => $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 }