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