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