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