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