]> git.mxchange.org Git - friendica.git/blob - mod/common.php
remove html and use vcard-widget.tpl
[friendica.git] / mod / common.php
1 <?php
2
3 require_once('include/socgraph.php');
4
5 function common_content(&$a) {
6
7         $o = '';
8
9         $cmd = $a->argv[1];
10         $uid = intval($a->argv[2]);
11         $cid = intval($a->argv[3]);
12         $zcid = 0;
13
14         if($cmd !== 'loc' && $cmd != 'rem')
15                 return;
16         if(! $uid)
17                 return;
18
19         if($cmd === 'loc' && $cid) {    
20                 $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1",
21                         intval($cid),
22                         intval($uid)
23                 );
24         }
25         else {
26                 $c = q("select name, url, photo from contact where self = 1 and uid = %d limit 1",
27                         intval($uid)
28                 );
29         }       
30
31         $a->page['aside'] .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
32                 '$name' => $c[0]['name'],
33                 '$photo' => $c[0]['photo'],
34                 'url' => $a->get_baseurl() . '/contacts/' . $cid
35                 ));
36         
37
38         if(! count($c))
39                 return;
40
41         $o .= '<h2>' . t('Common Friends') . '</h2>';
42
43
44         if(! $cid) {
45                 if(get_my_url()) {
46                         $r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
47                                 dbesc(normalise_link(get_my_url())),
48                                 intval($profile_uid)
49                         );
50                         if(count($r))
51                                 $cid = $r[0]['id'];
52                         else {
53                                 $r = q("select id from gcontact where nurl = '%s' limit 1",
54                                         dbesc(normalise_link(get_my_url()))
55                                 );
56                                 if(count($r))
57                                         $zcid = $r[0]['id'];
58                         }
59                 }
60         }
61
62
63
64         if($cid == 0 && $zcid == 0)
65                 return; 
66
67
68         if($cid)
69                 $t = count_common_friends($uid,$cid);
70         else
71                 $t = count_common_friends_zcid($uid,$zcid);
72
73
74         $a->set_pager_total($t);
75
76         if(! $t) {
77                 notice( t('No contacts in common.') . EOL);
78                 return $o;
79         }
80
81
82         if($cid)
83                 $r = common_friends($uid,$cid);
84         else
85                 $r = common_friends_zcid($uid,$zcid);
86
87
88         if(! count($r)) {
89                 return $o;
90         }
91
92         $tpl = get_markup_template('common_friends.tpl');
93
94         foreach($r as $rr) {
95                         
96                 $o .= replace_macros($tpl,array(
97                         '$url' => $rr['url'],
98                         '$name' => $rr['name'],
99                         '$photo' => $rr['photo'],
100                         '$tags' => ''
101                 ));
102         }
103
104         $o .= cleardiv();
105 //      $o .= paginate($a);
106         return $o;
107 }