3 * @file mod/suggest.php
6 use Friendica\Content\ContactSelector;
7 use Friendica\Content\Widget;
8 use Friendica\Core\System;
9 use Friendica\Database\DBM;
10 use Friendica\Model\Contact;
11 use Friendica\Model\GContact;
12 use Friendica\Model\Profile;
14 function suggest_init(App $a) {
19 if (x($_GET,'ignore') && intval($_GET['ignore'])) {
20 // Check if we should do HTML-based delete confirmation
21 if ($_REQUEST['confirm']) {
22 // <form> can't take arguments in its "action" parameter
23 // so add any arguments as hidden inputs
24 $query = explode_querystring($a->query_string);
26 foreach ($query['args'] as $arg) {
27 if (strpos($arg, 'confirm=') === false) {
28 $arg_parts = explode('=', $arg);
29 $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
33 $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), [
35 '$message' => t('Do you really want to delete this suggestion?'),
36 '$extra_inputs' => $inputs,
37 '$confirm' => t('Yes'),
38 '$confirm_url' => $query['base'],
39 '$confirm_name' => 'confirmed',
40 '$cancel' => t('Cancel'),
42 $a->error = 1; // Set $a->error so the other module functions don't execute
45 // Now check how the user responded to the confirmation query
46 if (!$_REQUEST['canceled']) {
47 dba::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]);
53 function suggest_content(App $a) {
55 require_once("mod/proxy.php");
59 notice( t('Permission denied.') . EOL);
63 $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
65 $a->page['aside'] .= Widget::findPeople();
66 $a->page['aside'] .= Widget::follow();
69 $r = GContact::suggestionQuery(local_user());
71 if (! DBM::is_result($r)) {
72 $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
78 $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
79 $ignlnk = System::baseUrl() . '/suggest?ignore=' . $rr['id'];
81 'profile' => [t("View Profile"), Profile::zrl($rr["url"])],
82 'follow' => [t("Connect/Follow"), $connlnk],
83 'hide' => [t('Ignore/Hide'), $ignlnk]
86 $contact_details = Contact::getDetailsByURL($rr["url"], local_user(), $rr);
89 'url' => Profile::zrl($rr['url']),
90 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
91 'img_hover' => $rr['url'],
92 'name' => $contact_details['name'],
93 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
94 'details' => $contact_details['location'],
95 'tags' => $contact_details['keywords'],
96 'about' => $contact_details['about'],
97 'account_type' => Contact::getAccountType($contact_details),
100 'conntxt' => t('Connect'),
101 'connlnk' => $connlnk,
102 'photo_menu' => $photo_menu,
103 'ignore' => t('Ignore/Hide'),
104 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
110 $tpl = get_markup_template('viewcontact_template.tpl');
112 $o .= replace_macros($tpl,[
113 '$title' => t('Friend Suggestions'),
114 '$contacts' => $entries,