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