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.
 
 
 
 
 
 

120 lines
3.2 KiB

  1. <?php
  2. require_once('include/socgraph.php');
  3. require_once('include/contact_widgets.php');
  4. function suggest_init(App &$a) {
  5. if (! local_user()) {
  6. return;
  7. }
  8. if (x($_GET,'ignore') && intval($_GET['ignore'])) {
  9. // Check if we should do HTML-based delete confirmation
  10. if ($_REQUEST['confirm']) {
  11. // <form> can't take arguments in its "action" parameter
  12. // so add any arguments as hidden inputs
  13. $query = explode_querystring($a->query_string);
  14. $inputs = array();
  15. foreach ($query['args'] as $arg) {
  16. if (strpos($arg, 'confirm=') === false) {
  17. $arg_parts = explode('=', $arg);
  18. $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
  19. }
  20. }
  21. $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
  22. '$method' => 'get',
  23. '$message' => t('Do you really want to delete this suggestion?'),
  24. '$extra_inputs' => $inputs,
  25. '$confirm' => t('Yes'),
  26. '$confirm_url' => $query['base'],
  27. '$confirm_name' => 'confirmed',
  28. '$cancel' => t('Cancel'),
  29. ));
  30. $a->error = 1; // Set $a->error so the other module functions don't execute
  31. return;
  32. }
  33. // Now check how the user responded to the confirmation query
  34. if (!$_REQUEST['canceled']) {
  35. q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ",
  36. intval(local_user()),
  37. intval($_GET['ignore'])
  38. );
  39. }
  40. }
  41. }
  42. function suggest_content(App &$a) {
  43. require_once("mod/proxy.php");
  44. $o = '';
  45. if (! local_user()) {
  46. notice( t('Permission denied.') . EOL);
  47. return;
  48. }
  49. $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
  50. $a->page['aside'] .= findpeople_widget();
  51. $a->page['aside'] .= follow_widget();
  52. $r = suggestion_query(local_user());
  53. if (! dbm::is_result($r)) {
  54. $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
  55. return $o;
  56. }
  57. require_once 'include/contact_selectors.php';
  58. foreach ($r as $rr) {
  59. $connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
  60. $ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];
  61. $photo_menu = array(
  62. 'profile' => array(t("View Profile"), zrl($rr["url"])),
  63. 'follow' => array(t("Connect/Follow"), $connlnk),
  64. 'hide' => array(t('Ignore/Hide'), $ignlnk)
  65. );
  66. $contact_details = get_contact_details_by_url($rr["url"], local_user(), $rr);
  67. $entry = array(
  68. 'url' => zrl($rr['url']),
  69. 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
  70. 'img_hover' => $rr['url'],
  71. 'name' => $contact_details['name'],
  72. 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
  73. 'details' => $contact_details['location'],
  74. 'tags' => $contact_details['keywords'],
  75. 'about' => $contact_details['about'],
  76. 'account_type' => account_type($contact_details),
  77. 'ignlnk' => $ignlnk,
  78. 'ignid' => $rr['id'],
  79. 'conntxt' => t('Connect'),
  80. 'connlnk' => $connlnk,
  81. 'photo_menu' => $photo_menu,
  82. 'ignore' => t('Ignore/Hide'),
  83. 'network' => network_to_name($rr['network'], $rr['url']),
  84. 'id' => ++$id,
  85. );
  86. $entries[] = $entry;
  87. }
  88. $tpl = get_markup_template('viewcontact_template.tpl');
  89. $o .= replace_macros($tpl,array(
  90. '$title' => t('Friend Suggestions'),
  91. '$contacts' => $entries,
  92. ));
  93. return $o;
  94. }