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.

81 lines
1.9 KiB

  1. <?php
  2. include_once('include/text.php');
  3. function match_content(&$a) {
  4. $o = '';
  5. if(! local_user())
  6. return;
  7. $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
  8. $o .= replace_macros(get_markup_template("section_title.tpl"),array(
  9. '$title' => t('Profile Match')
  10. ));
  11. $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
  12. intval(local_user())
  13. );
  14. if(! count($r))
  15. return;
  16. if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
  17. notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
  18. return;
  19. }
  20. $params = array();
  21. $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
  22. if($tags) {
  23. $params['s'] = $tags;
  24. if($a->pager['page'] != 1)
  25. $params['p'] = $a->pager['page'];
  26. if(strlen(get_config('system','directory_submit_url')))
  27. $x = post_url(get_server().'/msearch', $params);
  28. else
  29. $x = post_url($a->get_baseurl() . '/msearch', $params);
  30. $j = json_decode($x);
  31. if($j->total) {
  32. $a->set_pager_total($j->total);
  33. $a->set_pager_itemspage($j->items_page);
  34. }
  35. if(count($j->results)) {
  36. $tpl = get_markup_template('match.tpl');
  37. foreach($j->results as $jj) {
  38. $match_nurl = normalise_link($jj->url);
  39. $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
  40. intval(local_user()),
  41. dbesc($match_nurl));
  42. if (!count($match)) {
  43. $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
  44. $o .= replace_macros($tpl,array(
  45. '$url' => zrl($jj->url),
  46. '$name' => $jj->name,
  47. '$photo' => proxy_url($jj->photo),
  48. '$inttxt' => ' ' . t('is interested in:'),
  49. '$conntxt' => t('Connect'),
  50. '$connlnk' => $connlnk,
  51. '$tags' => $jj->tags
  52. ));
  53. }
  54. }
  55. }
  56. else {
  57. info( t('No matches') . EOL);
  58. }
  59. }
  60. $o .= cleardiv();
  61. $o .= paginate($a);
  62. return $o;
  63. }