3 * @file mod/suggest.php
7 use Friendica\Content\ContactSelector;
8 use Friendica\Content\Widget;
9 use Friendica\Core\L10n;
10 use Friendica\Core\Renderer;
11 use Friendica\Core\System;
12 use Friendica\Database\DBA;
13 use Friendica\Model\Contact;
14 use Friendica\Model\GContact;
15 use Friendica\Util\Proxy as ProxyUtils;
17 function suggest_init(App $a)
23 if (!empty($_GET['ignore'])) {
24 // Check if we should do HTML-based delete confirmation
25 if ($_REQUEST['confirm']) {
26 // <form> can't take arguments in its "action" parameter
27 // so add any arguments as hidden inputs
28 $query = explode_querystring($a->query_string);
30 foreach ($query['args'] as $arg) {
31 if (strpos($arg, 'confirm=') === false) {
32 $arg_parts = explode('=', $arg);
33 $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
37 $a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
39 '$message' => L10n::t('Do you really want to delete this suggestion?'),
40 '$extra_inputs' => $inputs,
41 '$confirm' => L10n::t('Yes'),
42 '$confirm_url' => $query['base'],
43 '$confirm_name' => 'confirmed',
44 '$cancel' => L10n::t('Cancel'),
46 $a->error = 1; // Set $a->error so the other module functions don't execute
49 // Now check how the user responded to the confirmation query
50 if (!$_REQUEST['canceled']) {
51 DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]);
57 function suggest_content(App $a)
62 notice(L10n::t('Permission denied.') . EOL);
66 $_SESSION['return_path'] = $a->cmd;
68 $a->page['aside'] .= Widget::findPeople();
69 $a->page['aside'] .= Widget::follow();
72 $r = GContact::suggestionQuery(local_user());
74 if (! DBA::isResult($r)) {
75 $o .= L10n::t('No suggestions available. If this is a new site, please try again in 24 hours.');
84 $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
85 $ignlnk = System::baseUrl() . '/suggest?ignore=' . $rr['id'];
87 'profile' => [L10n::t("View Profile"), Contact::magicLink($rr["url"])],
88 'follow' => [L10n::t("Connect/Follow"), $connlnk],
89 'hide' => [L10n::t('Ignore/Hide'), $ignlnk]
92 $contact_details = Contact::getDetailsByURL($rr["url"], local_user(), $rr);
95 'url' => Contact::magicLink($rr['url']),
96 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
97 'img_hover' => $rr['url'],
98 'name' => $contact_details['name'],
99 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
100 'details' => $contact_details['location'],
101 'tags' => $contact_details['keywords'],
102 'about' => $contact_details['about'],
103 'account_type' => Contact::getAccountType($contact_details),
105 'ignid' => $rr['id'],
106 'conntxt' => L10n::t('Connect'),
107 'connlnk' => $connlnk,
108 'photo_menu' => $photo_menu,
109 'ignore' => L10n::t('Ignore/Hide'),
110 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
116 $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
118 $o .= Renderer::replaceMacros($tpl,[
119 '$title' => L10n::t('Friend Suggestions'),
120 '$contacts' => $entries,