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