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