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