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.
 
 
 
 
 
 

118 lines
3.2 KiB

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