]> git.mxchange.org Git - friendica.git/blob - mod/allfriends.php
8843265a99ed9a92a2637252b0911e69eabc2e58
[friendica.git] / mod / allfriends.php
1 <?php
2
3 require_once('include/socgraph.php');
4 require_once('include/Contact.php');
5 require_once('include/contact_selectors.php');
6 require_once('mod/contacts.php');
7
8 if(! function_exists('allfriends_content')) {
9 function allfriends_content(&$a) {
10
11         $o = '';
12         if(! local_user()) {
13                 notice( t('Permission denied.') . EOL);
14                 return;
15         }
16
17         if($a->argc > 1)
18                 $cid = intval($a->argv[1]);
19
20         if(! $cid)
21                 return;
22
23         $uid = $a->user[uid];
24
25         $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
26                 intval($cid),
27                 intval(local_user())
28         );
29
30         if(! count($c))
31                 return;
32
33         $a->page['aside'] = "";
34         profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
35
36         $total = count_all_friends(local_user(), $cid);
37
38         if(count($total))
39                 $a->set_pager_total($total);
40
41         $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
42
43         if(! count($r)) {
44                 $o .= t('No friends to display.');
45                 return $o;
46         }
47
48         $id = 0;
49
50         foreach($r as $rr) {
51
52                 //get further details of the contact
53                 $contact_details = get_contact_details_by_url($rr['url'], $uid);
54
55                 $photo_menu = '';
56
57                 // $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
58                 // If the contact is not common to the user, Connect/Follow' will be added to the photo menu
59                 if ($rr[cid]) {
60                         $rr[id] = $rr[cid];
61                         $photo_menu = contact_photo_menu ($rr);
62                 }
63                 else {
64                         $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
65                         $photo_menu = array(array(t("View Profile"), zrl($rr['url'])));
66                         $photo_menu[] = array(t("Connect/Follow"), $connlnk);
67                 }
68
69                 $entry = array(
70                         'url'           => $rr['url'],
71                         'itemurl'       => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
72                         'name'          => htmlentities($rr['name']),
73                         'thumb'         => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB),
74                         'img_hover'     => htmlentities($rr['name']),
75                         'details'       => $contact_details['location'],
76                         'tags'          => $contact_details['keywords'],
77                         'about'         => $contact_details['about'],
78                         'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
79                         'network'       => network_to_name($contact_details['network'], $contact_details['url']),
80                         'photo_menu'    => $photo_menu,
81                         'conntxt'       => t('Connect'),
82                         'connlnk'       => $connlnk,
83                         'id'            => ++$id,
84                 );
85                 $entries[] = $entry;
86         }
87
88         $tab_str = contacts_tab($a, $cid, 3);
89
90         $tpl = get_markup_template('viewcontact_template.tpl');
91
92         $o .= replace_macros($tpl,array(
93                 //'$title' => sprintf( t('Friends of %s'), htmlentities($c[0]['name'])),
94                 '$tab_str' => $tab_str,
95                 '$contacts' => $entries,
96                 '$paginate' => paginate($a),
97         ));
98
99         return $o;
100 }
101 }