Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.0 KiB

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